diff options
5 files changed, 33 insertions, 18 deletions
diff --git a/Swiften/Disco/DiscoServiceWalker.cpp b/Swiften/Disco/DiscoServiceWalker.cpp index f84262b..5803602 100644 --- a/Swiften/Disco/DiscoServiceWalker.cpp +++ b/Swiften/Disco/DiscoServiceWalker.cpp | |||
| @@ -1,18 +1,18 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * Copyright (c) 2010 Isode Limited. | 2 | * Copyright (c) 2010-2015 Isode Limited. |
| 3 | * All rights reserved. | 3 | * All rights reserved. |
| 4 | * See the COPYING file for more information. | 4 | * See the COPYING file for more information. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <Swiften/Disco/DiscoServiceWalker.h> | 7 | #include <Swiften/Disco/DiscoServiceWalker.h> |
| 8 | 8 | ||
| 9 | #include <boost/bind.hpp> | ||
| 10 | |||
| 9 | #include <Swiften/Base/Log.h> | 11 | #include <Swiften/Base/Log.h> |
| 10 | #include <Swiften/Base/foreach.h> | 12 | #include <Swiften/Base/foreach.h> |
| 11 | 13 | ||
| 12 | #include <boost/bind.hpp> | ||
| 13 | |||
| 14 | namespace Swift { | 14 | namespace Swift { |
| 15 | 15 | ||
| 16 | DiscoServiceWalker::DiscoServiceWalker(const JID& service, IQRouter* iqRouter, size_t maxSteps) : service_(service), iqRouter_(iqRouter), maxSteps_(maxSteps), active_(false) { | 16 | DiscoServiceWalker::DiscoServiceWalker(const JID& service, IQRouter* iqRouter, size_t maxSteps) : service_(service), iqRouter_(iqRouter), maxSteps_(maxSteps), active_(false) { |
| 17 | 17 | ||
| 18 | } | 18 | } |
| @@ -55,10 +55,11 @@ void DiscoServiceWalker::handleDiscoInfoResponse(boost::shared_ptr<DiscoInfo> in | |||
| 55 | return; | 55 | return; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | SWIFT_LOG(debug) << "Disco info response from " << request->getReceiver() << std::endl; | 58 | SWIFT_LOG(debug) << "Disco info response from " << request->getReceiver() << std::endl; |
| 59 | 59 | ||
| 60 | request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoInfoResponse, this, _1, _2, request)); | ||
| 60 | pendingDiscoInfoRequests_.erase(request); | 61 | pendingDiscoInfoRequests_.erase(request); |
| 61 | if (error) { | 62 | if (error) { |
| 62 | handleDiscoError(request->getReceiver(), error); | 63 | handleDiscoError(request->getReceiver(), error); |
| 63 | return; | 64 | return; |
| 64 | } | 65 | } |
| @@ -89,10 +90,11 @@ void DiscoServiceWalker::handleDiscoItemsResponse(boost::shared_ptr<DiscoItems> | |||
| 89 | if (!active_) { | 90 | if (!active_) { |
| 90 | return; | 91 | return; |
| 91 | } | 92 | } |
| 92 | 93 | ||
| 93 | SWIFT_LOG(debug) << "Received disco items from " << request->getReceiver() << std::endl; | 94 | SWIFT_LOG(debug) << "Received disco items from " << request->getReceiver() << std::endl; |
| 95 | request->onResponse.disconnect(boost::bind(&DiscoServiceWalker::handleDiscoItemsResponse, this, _1, _2, request)); | ||
| 94 | pendingDiscoItemsRequests_.erase(request); | 96 | pendingDiscoItemsRequests_.erase(request); |
| 95 | if (error) { | 97 | if (error) { |
| 96 | handleDiscoError(request->getReceiver(), error); | 98 | handleDiscoError(request->getReceiver(), error); |
| 97 | return; | 99 | return; |
| 98 | } | 100 | } |
diff --git a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp index dffc39b..ca29898 100644 --- a/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp +++ b/Swiften/FileTransfer/DefaultFileTransferTransporter.cpp | |||
| @@ -71,11 +71,16 @@ DefaultFileTransferTransporter::DefaultFileTransferTransporter( | |||
| 71 | boost::bind(&DefaultFileTransferTransporter::handleRemoteCandidateSelectFinished, this, _1, _2)); | 71 | boost::bind(&DefaultFileTransferTransporter::handleRemoteCandidateSelectFinished, this, _1, _2)); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | DefaultFileTransferTransporter::~DefaultFileTransferTransporter() { | 74 | DefaultFileTransferTransporter::~DefaultFileTransferTransporter() { |
| 75 | stopGeneratingLocalCandidates(); | 75 | stopGeneratingLocalCandidates(); |
| 76 | remoteCandidateSelector->onCandidateSelectFinished.disconnect( | ||
| 77 | boost::bind(&DefaultFileTransferTransporter::handleRemoteCandidateSelectFinished, this, _1, _2)); | ||
| 76 | delete remoteCandidateSelector; | 78 | delete remoteCandidateSelector; |
| 79 | |||
| 80 | localCandidateGenerator->onLocalTransportCandidatesGenerated.disconnect( | ||
| 81 | boost::bind(&DefaultFileTransferTransporter::handleLocalCandidatesGenerated, this, _1)); | ||
| 77 | delete localCandidateGenerator; | 82 | delete localCandidateGenerator; |
| 78 | } | 83 | } |
| 79 | 84 | ||
| 80 | void DefaultFileTransferTransporter::initialize() { | 85 | void DefaultFileTransferTransporter::initialize() { |
| 81 | s5bSessionID = s5bRegistry->generateSessionID(); | 86 | s5bSessionID = s5bRegistry->generateSessionID(); |
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp index 04d5d86..a38501b 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamClientSession.cpp | |||
| @@ -40,10 +40,12 @@ SOCKS5BytestreamClientSession::SOCKS5BytestreamClientSession( | |||
| 40 | weFailedTimeout->onTick.connect( | 40 | weFailedTimeout->onTick.connect( |
| 41 | boost::bind(&SOCKS5BytestreamClientSession::handleWeFailedTimeout, this)); | 41 | boost::bind(&SOCKS5BytestreamClientSession::handleWeFailedTimeout, this)); |
| 42 | } | 42 | } |
| 43 | 43 | ||
| 44 | SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() { | 44 | SOCKS5BytestreamClientSession::~SOCKS5BytestreamClientSession() { |
| 45 | weFailedTimeout->onTick.disconnect( | ||
| 46 | boost::bind(&SOCKS5BytestreamClientSession::handleWeFailedTimeout, this)); | ||
| 45 | weFailedTimeout->stop(); | 47 | weFailedTimeout->stop(); |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | void SOCKS5BytestreamClientSession::start() { | 50 | void SOCKS5BytestreamClientSession::start() { |
| 49 | assert(state == Initial); | 51 | assert(state == Initial); |
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp index 25a12ea..3221790 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.cpp | |||
| @@ -111,10 +111,11 @@ boost::shared_ptr<SOCKS5BytestreamClientSession> SOCKS5BytestreamProxiesManager: | |||
| 111 | SOCKS5BytestreamClientSession::ref connection = boost::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_); | 111 | SOCKS5BytestreamClientSession::ref connection = boost::make_shared<SOCKS5BytestreamClientSession>(connectionFactory_->createConnection(), addressPort, destAddr, timerFactory_); |
| 112 | return connection; | 112 | return connection; |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | void SOCKS5BytestreamProxiesManager::handleProxiesFound(std::vector<S5BProxyRequest::ref> proxyHosts) { | 115 | void SOCKS5BytestreamProxiesManager::handleProxiesFound(std::vector<S5BProxyRequest::ref> proxyHosts) { |
| 116 | proxyFinder_->onProxiesFound.disconnect(boost::bind(&SOCKS5BytestreamProxiesManager::handleProxiesFound, this, _1)); | ||
| 116 | foreach(S5BProxyRequest::ref proxy, proxyHosts) { | 117 | foreach(S5BProxyRequest::ref proxy, proxyHosts) { |
| 117 | if (proxy) { | 118 | if (proxy) { |
| 118 | if (HostAddress(proxy->getStreamHost().get().host).isValid()) { | 119 | if (HostAddress(proxy->getStreamHost().get().host).isValid()) { |
| 119 | addS5BProxy(proxy); | 120 | addS5BProxy(proxy); |
| 120 | onDiscoveredProxiesChanged(); | 121 | onDiscoveredProxiesChanged(); |
diff --git a/Swiften/QA/FileTransferTest/FileTransferTest.cpp b/Swiften/QA/FileTransferTest/FileTransferTest.cpp index 2d2d6c8..8faf8a9 100644 --- a/Swiften/QA/FileTransferTest/FileTransferTest.cpp +++ b/Swiften/QA/FileTransferTest/FileTransferTest.cpp | |||
| @@ -5,32 +5,32 @@ | |||
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <fstream> | 7 | #include <fstream> |
| 8 | 8 | ||
| 9 | #include <boost/algorithm/string.hpp> | 9 | #include <boost/algorithm/string.hpp> |
| 10 | #include <boost/numeric/conversion/cast.hpp> | ||
| 11 | #include <boost/filesystem.hpp> | 10 | #include <boost/filesystem.hpp> |
| 11 | #include <boost/numeric/conversion/cast.hpp> | ||
| 12 | 12 | ||
| 13 | #include <Swiften/Base/sleep.h> | 13 | #include <Swiften/Base/BoostRandomGenerator.h> |
| 14 | #include <Swiften/Base/foreach.h> | 14 | #include <Swiften/Base/Debug.h> |
| 15 | #include <Swiften/Base/Log.h> | 15 | #include <Swiften/Base/Log.h> |
| 16 | #include <Swiften/Client/ClientXMLTracer.h> | 16 | #include <Swiften/Base/foreach.h> |
| 17 | #include <Swiften/Base/sleep.h> | ||
| 17 | #include <Swiften/Client/Client.h> | 18 | #include <Swiften/Client/Client.h> |
| 18 | #include <Swiften/EventLoop/SimpleEventLoop.h> | 19 | #include <Swiften/Client/ClientXMLTracer.h> |
| 19 | #include <Swiften/Network/BoostNetworkFactories.h> | 20 | #include <Swiften/Disco/ClientDiscoManager.h> |
| 20 | #include <Swiften/Network/Timer.h> | ||
| 21 | #include <Swiften/Network/TimerFactory.h> | ||
| 22 | #include <Swiften/Disco/EntityCapsProvider.h> | 21 | #include <Swiften/Disco/EntityCapsProvider.h> |
| 23 | #include <Swiften/Elements/Presence.h> | 22 | #include <Swiften/Elements/Presence.h> |
| 24 | #include <Swiften/FileTransfer/ReadBytestream.h> | 23 | #include <Swiften/EventLoop/SimpleEventLoop.h> |
| 25 | #include <Swiften/Base/BoostRandomGenerator.h> | ||
| 26 | #include <Swiften/FileTransfer/FileReadBytestream.h> | 24 | #include <Swiften/FileTransfer/FileReadBytestream.h> |
| 27 | #include <Swiften/FileTransfer/OutgoingFileTransfer.h> | ||
| 28 | #include <Swiften/FileTransfer/FileTransferManager.h> | 25 | #include <Swiften/FileTransfer/FileTransferManager.h> |
| 29 | #include <Swiften/Disco/ClientDiscoManager.h> | ||
| 30 | #include <Swiften/FileTransfer/FileWriteBytestream.h> | 26 | #include <Swiften/FileTransfer/FileWriteBytestream.h> |
| 31 | #include <Swiften/Base/Debug.h> | 27 | #include <Swiften/FileTransfer/OutgoingFileTransfer.h> |
| 28 | #include <Swiften/FileTransfer/ReadBytestream.h> | ||
| 29 | #include <Swiften/Network/BoostNetworkFactories.h> | ||
| 30 | #include <Swiften/Network/Timer.h> | ||
| 31 | #include <Swiften/Network/TimerFactory.h> | ||
| 32 | 32 | ||
| 33 | using namespace Swift; | 33 | using namespace Swift; |
| 34 | 34 | ||
| 35 | static const std::string CLIENT_NAME = "Swiften FT Test"; | 35 | static const std::string CLIENT_NAME = "Swiften FT Test"; |
| 36 | static const std::string CLIENT_NODE = "http://swift.im"; | 36 | static const std::string CLIENT_NODE = "http://swift.im"; |
| @@ -57,12 +57,12 @@ class FileTransferTest { | |||
| 57 | 57 | ||
| 58 | receiver_ = boost::make_shared<Client>(JID(getenv("SWIFT_FILETRANSFERTEST2_JID")), getenv("SWIFT_FILETRANSFERTEST2_PASS"), networkFactories.get()); | 58 | receiver_ = boost::make_shared<Client>(JID(getenv("SWIFT_FILETRANSFERTEST2_JID")), getenv("SWIFT_FILETRANSFERTEST2_PASS"), networkFactories.get()); |
| 59 | receiver_->onConnected.connect(boost::bind(&FileTransferTest::handleReceiverConnected, this)); | 59 | receiver_->onConnected.connect(boost::bind(&FileTransferTest::handleReceiverConnected, this)); |
| 60 | receiver_->onDisconnected.connect(boost::bind(&FileTransferTest::handleReceiverDisconnected, this, _1)); | 60 | receiver_->onDisconnected.connect(boost::bind(&FileTransferTest::handleReceiverDisconnected, this, _1)); |
| 61 | 61 | ||
| 62 | new ClientXMLTracer(sender_.get()); | 62 | senderTracer_ = new ClientXMLTracer(sender_.get()); |
| 63 | new ClientXMLTracer(receiver_.get()); | 63 | receiverTracer_ = new ClientXMLTracer(receiver_.get()); |
| 64 | 64 | ||
| 65 | ClientOptions options; | 65 | ClientOptions options; |
| 66 | options.useTLS = ClientOptions::NeverUseTLS; | 66 | options.useTLS = ClientOptions::NeverUseTLS; |
| 67 | options.useStreamCompression = false; | 67 | options.useStreamCompression = false; |
| 68 | options.useStreamResumption = false; | 68 | options.useStreamResumption = false; |
| @@ -90,10 +90,13 @@ class FileTransferTest { | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | ~FileTransferTest() { | 92 | ~FileTransferTest() { |
| 93 | timeOut_->stop(); | 93 | timeOut_->stop(); |
| 94 | 94 | ||
| 95 | delete senderTracer_; | ||
| 96 | delete receiverTracer_; | ||
| 97 | |||
| 95 | if(boost::filesystem::exists(sendFilePath_)) { | 98 | if(boost::filesystem::exists(sendFilePath_)) { |
| 96 | boost::filesystem::remove(sendFilePath_); | 99 | boost::filesystem::remove(sendFilePath_); |
| 97 | } | 100 | } |
| 98 | 101 | ||
| 99 | if(boost::filesystem::exists(receiveFilePath_)) { | 102 | if(boost::filesystem::exists(receiveFilePath_)) { |
| @@ -237,18 +240,20 @@ class FileTransferTest { | |||
| 237 | } | 240 | } |
| 238 | 241 | ||
| 239 | private: | 242 | private: |
| 240 | int senderCandidates_; | 243 | int senderCandidates_; |
| 241 | boost::shared_ptr<Client> sender_; | 244 | boost::shared_ptr<Client> sender_; |
| 245 | ClientXMLTracer* senderTracer_; | ||
| 242 | ByteArray sendData_; | 246 | ByteArray sendData_; |
| 243 | OutgoingFileTransfer::ref outgoingFileTransfer_; | 247 | OutgoingFileTransfer::ref outgoingFileTransfer_; |
| 244 | boost::filesystem::path sendFilePath_; | 248 | boost::filesystem::path sendFilePath_; |
| 245 | boost::optional<FileTransferError> senderError_; | 249 | boost::optional<FileTransferError> senderError_; |
| 246 | bool senderIsDone_; | 250 | bool senderIsDone_; |
| 247 | 251 | ||
| 248 | int receiverCandidates_; | 252 | int receiverCandidates_; |
| 249 | boost::shared_ptr<Client> receiver_; | 253 | boost::shared_ptr<Client> receiver_; |
| 254 | ClientXMLTracer* receiverTracer_; | ||
| 250 | ByteArray receiveData_; | 255 | ByteArray receiveData_; |
| 251 | std::vector<IncomingFileTransfer::ref> incomingFileTransfers_; | 256 | std::vector<IncomingFileTransfer::ref> incomingFileTransfers_; |
| 252 | boost::filesystem::path receiveFilePath_; | 257 | boost::filesystem::path receiveFilePath_; |
| 253 | boost::optional<FileTransferError> receiverError_; | 258 | boost::optional<FileTransferError> receiverError_; |
| 254 | bool receiverIsDone_; | 259 | bool receiverIsDone_; |
Swift