summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2012-12-25 14:39:48 (GMT)
committerRemko Tronçon <git@el-tramo.be>2013-05-11 10:22:56 (GMT)
commit927d62cc54c8a5087dba6b61afa9ad30dc528a23 (patch)
treee67dc911bd30c0519d31a542d8e085bbb209879d /Swiften/Jingle/JingleSessionImpl.cpp
parent17b188343e7208b875af7af30d94f0bf948f6b93 (diff)
downloadswift-927d62cc54c8a5087dba6b61afa9ad30dc528a23.zip
swift-927d62cc54c8a5087dba6b61afa9ad30dc528a23.tar.bz2
File Transfer refactoring.
Allocate S5B server lazily. Forward forts lazily. Various state machine fixes. Temporarily disabling S5B proxy support. Change-Id: I3145e85a99b15a7e457306bbfbe9c0eb570191e4
Diffstat (limited to 'Swiften/Jingle/JingleSessionImpl.cpp')
-rw-r--r--Swiften/Jingle/JingleSessionImpl.cpp45
1 files changed, 30 insertions, 15 deletions
diff --git a/Swiften/Jingle/JingleSessionImpl.cpp b/Swiften/Jingle/JingleSessionImpl.cpp
index 53092fc..ff22d11 100644
--- a/Swiften/Jingle/JingleSessionImpl.cpp
+++ b/Swiften/Jingle/JingleSessionImpl.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010 Remko Tronçon
+ * Copyright (c) 2010-2013 Remko Tronçon
* Licensed under the GNU General Public License v3.
* See Documentation/Licenses/GPLv3.txt for more information.
*/
@@ -7,17 +7,19 @@
#include <Swiften/Jingle/JingleSessionImpl.h>
#include <boost/smart_ptr/make_shared.hpp>
+#include <boost/bind.hpp>
+#include <algorithm>
#include <Swiften/Parser/PayloadParsers/JingleParser.h>
#include <Swiften/Jingle/JingleContentID.h>
+#include <Swiften/Jingle/JingleSessionListener.h>
#include <Swiften/Elements/JingleContentPayload.h>
#include <Swiften/Queries/Request.h>
#include <Swiften/Queries/GenericRequest.h>
#include <Swiften/Base/Log.h>
-#include "Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h"
-#include "Swiften/FileTransfer/JingleTransport.h"
+#include <Swiften/Serializer/PayloadSerializers/JinglePayloadSerializer.h>
namespace Swift {
@@ -27,11 +29,11 @@ JingleSessionImpl::JingleSessionImpl(const JID& initiator, const JID& peerJID, c
void JingleSessionImpl::handleIncomingAction(JinglePayload::ref action) {
if (action->getAction() == JinglePayload::SessionTerminate) {
- onSessionTerminateReceived(action->getReason());
+ notifyListeners(&JingleSessionListener::handleSessionTerminateReceived, action->getReason());
return;
}
if (action->getAction() == JinglePayload::SessionInfo) {
- onSessionInfoReceived(action);
+ notifyListeners(&JingleSessionListener::handleSessionInfoReceived, action);
return;
}
@@ -45,19 +47,19 @@ void JingleSessionImpl::handleIncomingAction(JinglePayload::ref action) {
JingleTransportPayload::ref transport = content->getTransports().empty() ? JingleTransportPayload::ref() : content->getTransports()[0];
switch(action->getAction()) {
case JinglePayload::SessionAccept:
- onSessionAcceptReceived(contentID, description, transport);
+ notifyListeners(&JingleSessionListener::handleSessionAcceptReceived, contentID, description, transport);
return;
case JinglePayload::TransportAccept:
- onTransportAcceptReceived(contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportAcceptReceived, contentID, transport);
return;
case JinglePayload::TransportInfo:
- onTransportInfoReceived(contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportInfoReceived, contentID, transport);
return;
case JinglePayload::TransportReject:
- onTransportRejectReceived(contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportRejectReceived, contentID, transport);
return;
case JinglePayload::TransportReplace:
- onTransportReplaceReceived(contentID, transport);
+ notifyListeners(&JingleSessionListener::handleTransportReplaceReceived, contentID, transport);
return;
// following unused Jingle actions
case JinglePayload::ContentAccept:
@@ -136,7 +138,7 @@ void JingleSessionImpl::sendTransportAccept(const JingleContentID& id, JingleTra
sendSetRequest(payload);
}
-void JingleSessionImpl::sendTransportInfo(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
+std::string JingleSessionImpl::sendTransportInfo(const JingleContentID& id, JingleTransportPayload::ref transPayload) {
JinglePayload::ref payload = createPayload();
JingleContentPayload::ref content = boost::make_shared<JingleContentPayload>();
@@ -146,7 +148,7 @@ void JingleSessionImpl::sendTransportInfo(const JingleContentID& id, JingleTrans
payload->setAction(JinglePayload::TransportInfo);
payload->addPayload(content);
- sendSetRequest(payload);
+ return sendSetRequest(payload);
}
void JingleSessionImpl::sendTransportReject(const JingleContentID& /* id */, JingleTransportPayload::ref /* transPayload */) {
@@ -167,9 +169,13 @@ void JingleSessionImpl::sendTransportReplace(const JingleContentID& id, JingleTr
}
-void JingleSessionImpl::sendSetRequest(JinglePayload::ref payload) {
- boost::shared_ptr<GenericRequest<JinglePayload> > request = boost::make_shared<GenericRequest<JinglePayload> >(IQ::Set, peerJID, payload, iqRouter);
- request->send();
+std::string JingleSessionImpl::sendSetRequest(JinglePayload::ref payload) {
+ boost::shared_ptr<GenericRequest<JinglePayload> > request = boost::make_shared<GenericRequest<JinglePayload> >(
+ IQ::Set, peerJID, payload, iqRouter);
+ pendingRequests.insert(std::make_pair(
+ request,
+ request->onResponse.connect(boost::bind(&JingleSessionImpl::handleRequestResponse, this, request))));
+ return request->send();
}
@@ -180,6 +186,15 @@ JinglePayload::ref JingleSessionImpl::createPayload() const {
return payload;
}
+void JingleSessionImpl::handleRequestResponse(RequestRef request) {
+ RequestsMap::iterator i = pendingRequests.find(request);
+ assert(i != pendingRequests.end());
+ if (i->first->getPayloadGeneric()->getAction() == JinglePayload::TransportInfo) {
+ notifyListeners(&JingleSessionListener::handleTransportInfoAcknowledged, i->first->getID());
+ }
+ i->second.disconnect();
+ pendingRequests.erase(i);
+}
}