diff options
author | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
---|---|---|
committer | Tobias Markmann <tm@ayena.de> | 2016-03-31 14:57:35 (GMT) |
commit | cfbdb43d2cadd40aa87338d41548e4bf89e146e6 (patch) | |
tree | 18d94153a302445196fc0c18586abf44a1ce4a38 /Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp | |
parent | 1d545a4a7fb877f021508094b88c1f17b30d8b4e (diff) | |
download | swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.zip swift-cfbdb43d2cadd40aa87338d41548e4bf89e146e6.tar.bz2 |
Convert tabs to 4 spaces for all source files
Removed trailing spaces and whitespace on empty lines
in the process.
Changed CheckTabs.py tool to disallow hard tabs in source
files.
Test-Information:
Manually checked 30 random files that the conversion worked
as expected.
Change-Id: I874f99d617bd3d2bb55f02d58f22f58f9b094480
Diffstat (limited to 'Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp')
-rw-r--r-- | Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp | 262 |
1 files changed, 131 insertions, 131 deletions
diff --git a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp index f6e6963..3703ba1 100644 --- a/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp +++ b/Swiften/FileTransfer/LocalJingleTransportCandidateGenerator.cpp @@ -31,162 +31,162 @@ static const unsigned int LOCAL_PREFERENCE = 0; namespace Swift { LocalJingleTransportCandidateGenerator::LocalJingleTransportCandidateGenerator( - SOCKS5BytestreamServerManager* s5bServerManager, - SOCKS5BytestreamProxiesManager* s5bProxy, - const JID& ownJID, - IDGenerator* idGenerator, - const FileTransferOptions& options) : - s5bServerManager(s5bServerManager), - s5bProxy(s5bProxy), - ownJID(ownJID), - idGenerator(idGenerator), - triedServerInit_(false), - triedForwarding_(false), - triedProxyDiscovery_(false), - options_(options) { + SOCKS5BytestreamServerManager* s5bServerManager, + SOCKS5BytestreamProxiesManager* s5bProxy, + const JID& ownJID, + IDGenerator* idGenerator, + const FileTransferOptions& options) : + s5bServerManager(s5bServerManager), + s5bProxy(s5bProxy), + ownJID(ownJID), + idGenerator(idGenerator), + triedServerInit_(false), + triedForwarding_(false), + triedProxyDiscovery_(false), + options_(options) { } LocalJingleTransportCandidateGenerator::~LocalJingleTransportCandidateGenerator() { - SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning) << std::endl; + SWIFT_LOG_ASSERT(!s5bServerInitializeRequest, warning) << std::endl; } void LocalJingleTransportCandidateGenerator::start() { - assert(!s5bServerInitializeRequest); - if (options_.isDirectAllowed() || options_.isAssistedAllowed()) { - s5bServerResourceUser_ = s5bServerManager->aquireResourceUser(); - if (s5bServerResourceUser_->isInitialized()) { - handleS5BServerInitialized(true); - } - else { - s5bServerResourceUser_->onSuccessfulInitialized.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); - } - } else { - handleS5BServerInitialized(false); - } - - if (options_.isProxiedAllowed()) { - s5bProxy->onDiscoveredProxiesChanged.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); - if (s5bProxy->getOrDiscoverS5BProxies().is_initialized()) { - handleDiscoveredProxiesChanged(); - } - } + assert(!s5bServerInitializeRequest); + if (options_.isDirectAllowed() || options_.isAssistedAllowed()) { + s5bServerResourceUser_ = s5bServerManager->aquireResourceUser(); + if (s5bServerResourceUser_->isInitialized()) { + handleS5BServerInitialized(true); + } + else { + s5bServerResourceUser_->onSuccessfulInitialized.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); + } + } else { + handleS5BServerInitialized(false); + } + + if (options_.isProxiedAllowed()) { + s5bProxy->onDiscoveredProxiesChanged.connect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); + if (s5bProxy->getOrDiscoverS5BProxies().is_initialized()) { + handleDiscoveredProxiesChanged(); + } + } } void LocalJingleTransportCandidateGenerator::stop() { - s5bProxy->onDiscoveredProxiesChanged.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); - if (s5bServerPortForwardingUser_) { - s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); - s5bServerPortForwardingUser_.reset(); - } - if (s5bServerResourceUser_) { - s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); - s5bServerResourceUser_.reset(); - } + s5bProxy->onDiscoveredProxiesChanged.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); + if (s5bServerPortForwardingUser_) { + s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); + s5bServerPortForwardingUser_.reset(); + } + if (s5bServerResourceUser_) { + s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); + s5bServerResourceUser_.reset(); + } } void LocalJingleTransportCandidateGenerator::handleS5BServerInitialized(bool success) { - if (s5bServerResourceUser_) { - s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); - } - 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(); + if (s5bServerResourceUser_) { + s5bServerResourceUser_->onSuccessfulInitialized.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleS5BServerInitialized, this, _1)); + } + 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 */) { - if (s5bServerPortForwardingUser_) { - s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); - } - triedForwarding_ = true; - checkS5BCandidatesReady(); + if (s5bServerPortForwardingUser_) { + s5bServerPortForwardingUser_->onSetup.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handlePortForwardingSetup, this, _1)); + } + triedForwarding_ = true; + checkS5BCandidatesReady(); } void LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged() { - if (s5bProxy) { - s5bProxy->onDiscoveredProxiesChanged.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); - } - triedProxyDiscovery_ = true; - checkS5BCandidatesReady(); + if (s5bProxy) { + s5bProxy->onDiscoveredProxiesChanged.disconnect(boost::bind(&LocalJingleTransportCandidateGenerator::handleDiscoveredProxiesChanged, this)); + } + triedProxyDiscovery_ = true; + checkS5BCandidatesReady(); } void LocalJingleTransportCandidateGenerator::checkS5BCandidatesReady() { - if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) && - (!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) && - (!options_.isAssistedAllowed() || (options_.isAssistedAllowed() && triedForwarding_))) { - emitOnLocalTransportCandidatesGenerated(); - } + if ((!options_.isDirectAllowed() || (options_.isDirectAllowed() && triedServerInit_)) && + (!options_.isProxiedAllowed() || (options_.isProxiedAllowed() && triedProxyDiscovery_)) && + (!options_.isAssistedAllowed() || (options_.isAssistedAllowed() && triedForwarding_))) { + emitOnLocalTransportCandidatesGenerated(); + } } void LocalJingleTransportCandidateGenerator::emitOnLocalTransportCandidatesGenerated() { - std::vector<JingleS5BTransportPayload::Candidate> candidates; - - if (options_.isDirectAllowed()) { - // get direct candidates - std::vector<HostAddressPort> directCandidates = s5bServerManager->getHostAddressPorts(); - foreach(HostAddressPort addressPort, directCandidates) { - if (addressPort.getAddress().getRawAddress().is_v6() && - addressPort.getAddress().getRawAddress().to_v6().is_link_local()) { - continue; - } - JingleS5BTransportPayload::Candidate candidate; - candidate.type = JingleS5BTransportPayload::Candidate::DirectType; - candidate.jid = ownJID; - candidate.hostPort = addressPort; - candidate.priority = 65536 * 126 + LOCAL_PREFERENCE; - candidate.cid = idGenerator->generateID(); - candidates.push_back(candidate); - } - } - - if (options_.isAssistedAllowed()) { - // get assissted candidates - std::vector<HostAddressPort> assisstedCandidates = s5bServerManager->getAssistedHostAddressPorts(); - foreach(HostAddressPort addressPort, assisstedCandidates) { - JingleS5BTransportPayload::Candidate candidate; - candidate.type = JingleS5BTransportPayload::Candidate::AssistedType; - candidate.jid = ownJID; - candidate.hostPort = addressPort; - candidate.priority = 65536 * 120 + LOCAL_PREFERENCE; - candidate.cid = idGenerator->generateID(); - candidates.push_back(candidate); - } - } - - if (options_.isProxiedAllowed() && s5bProxy->getOrDiscoverS5BProxies().is_initialized()) { - foreach(S5BProxyRequest::ref proxy, s5bProxy->getOrDiscoverS5BProxies().get()) { - if (proxy->getStreamHost()) { // FIXME: Added this test, because there were cases where this wasn't initialized. Investigate this. (Remko) - JingleS5BTransportPayload::Candidate candidate; - candidate.type = JingleS5BTransportPayload::Candidate::ProxyType; - candidate.jid = (*proxy->getStreamHost()).jid; - HostAddress address = (*proxy->getStreamHost()).host; - assert(address.isValid()); - candidate.hostPort = HostAddressPort(address, (*proxy->getStreamHost()).port); - candidate.priority = 65536 * 10 + LOCAL_PREFERENCE; - candidate.cid = idGenerator->generateID(); - candidates.push_back(candidate); - } - } - } - - onLocalTransportCandidatesGenerated(candidates); + std::vector<JingleS5BTransportPayload::Candidate> candidates; + + if (options_.isDirectAllowed()) { + // get direct candidates + std::vector<HostAddressPort> directCandidates = s5bServerManager->getHostAddressPorts(); + foreach(HostAddressPort addressPort, directCandidates) { + if (addressPort.getAddress().getRawAddress().is_v6() && + addressPort.getAddress().getRawAddress().to_v6().is_link_local()) { + continue; + } + JingleS5BTransportPayload::Candidate candidate; + candidate.type = JingleS5BTransportPayload::Candidate::DirectType; + candidate.jid = ownJID; + candidate.hostPort = addressPort; + candidate.priority = 65536 * 126 + LOCAL_PREFERENCE; + candidate.cid = idGenerator->generateID(); + candidates.push_back(candidate); + } + } + + if (options_.isAssistedAllowed()) { + // get assissted candidates + std::vector<HostAddressPort> assisstedCandidates = s5bServerManager->getAssistedHostAddressPorts(); + foreach(HostAddressPort addressPort, assisstedCandidates) { + JingleS5BTransportPayload::Candidate candidate; + candidate.type = JingleS5BTransportPayload::Candidate::AssistedType; + candidate.jid = ownJID; + candidate.hostPort = addressPort; + candidate.priority = 65536 * 120 + LOCAL_PREFERENCE; + candidate.cid = idGenerator->generateID(); + candidates.push_back(candidate); + } + } + + if (options_.isProxiedAllowed() && s5bProxy->getOrDiscoverS5BProxies().is_initialized()) { + foreach(S5BProxyRequest::ref proxy, s5bProxy->getOrDiscoverS5BProxies().get()) { + if (proxy->getStreamHost()) { // FIXME: Added this test, because there were cases where this wasn't initialized. Investigate this. (Remko) + JingleS5BTransportPayload::Candidate candidate; + candidate.type = JingleS5BTransportPayload::Candidate::ProxyType; + candidate.jid = (*proxy->getStreamHost()).jid; + HostAddress address = (*proxy->getStreamHost()).host; + assert(address.isValid()); + candidate.hostPort = HostAddressPort(address, (*proxy->getStreamHost()).port); + candidate.priority = 65536 * 10 + LOCAL_PREFERENCE; + candidate.cid = idGenerator->generateID(); + candidates.push_back(candidate); + } + } + } + + onLocalTransportCandidatesGenerated(candidates); } } |