diff options
-rw-r--r-- | Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp index 6a059bf..483fdb3 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp @@ -11,23 +11,23 @@ */ #include <Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.h> #include <vector> -#include <boost/shared_ptr.hpp> #include <boost/bind.hpp> +#include <boost/shared_ptr.hpp> #include <boost/smart_ptr/make_shared.hpp> -#include <Swiften/Base/foreach.h> #include <Swiften/Base/Log.h> +#include <Swiften/Base/foreach.h> #include <Swiften/Elements/JingleS5BTransportPayload.h> #include <Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h> #include <Swiften/FileTransfer/SOCKS5BytestreamServerManager.h> -#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h> #include <Swiften/FileTransfer/SOCKS5BytestreamServerPortForwardingUser.h> +#include <Swiften/FileTransfer/SOCKS5BytestreamServerResourceUser.h> static const unsigned int LOCAL_PREFERENCE = 0; namespace Swift { LocalJingleTransportCandidateGenerator::LocalJingleTransportCandidateGenerator( @@ -70,35 +70,45 @@ void LocalJingleTransportCandidateGenerator::start() { handleDiscoveredProxiesChanged(); } } } void LocalJingleTransportCandidateGenerator::stop() { + if (s5bServerResourceUser_) { + s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); + } s5bServerResourceUser_.reset(); } void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool success) { triedServerInit_ = true; if (success) { if (options_.isAssistedAllowed()) { // try to setup port forwarding s5bServerPortForwardingUser_ = s5bServerManager->aquirePortForwardingUser(); + s5bServerPortForwardingUser_->onSetup.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); if (s5bServerPortForwardingUser_->isForwardingSetup()) { handlePortForwardingSetup(true); } } } else { SWIFT_LOG(warning) << "Unable to start SOCKS5 server" << std::endl; + if (s5bServerResourceUser_) { + s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); + } s5bServerResourceUser_.reset(); handlePortForwardingSetup(false); } checkS5BCandidatesReady(); } -void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool success) { +void LocalJingleTransportCandidateGenerator::handlePortForwardingSetup(bool /* success */) { + if (s5bServerPortForwardingUser_) { + s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); + } triedForwarding_ = true; checkS5BCandidatesReady(); } void LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged() { s5bProxy->onDiscoveredProxiesChanged.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); @@ -106,13 +116,13 @@ void LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged() { checkS5BCandidatesReady(); } void LocalJingleTransportCandidateGenerator::checkS5BCandidatesReady() { if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) && (!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) && - (!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_))) { + (!options_.isAssistedAllowed() || (options_.isAssistedAllowed() && triedForwarding_))) { emitOnLocalTransportCandidatesGenerated(); } } void LocalJingleTransportCandidateGenerator::emitOnLocalTransportCandidatesGenerated() { |