diff options
Diffstat (limited to 'Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h')
-rw-r--r-- | Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h | 49 |
1 files changed, 38 insertions, 11 deletions
diff --git a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h index f3fed80..06db76c 100644 --- a/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h +++ b/Swiften/FileTransfer/SOCKS5BytestreamProxiesManager.h @@ -4,6 +4,13 @@ * See Documentation/Licenses/BSD-simplified.txt for more information. */ +/* + * Copyright (c) 2015 Isode Limited. + * All rights reserved. + * See the COPYING file for more information. + */ + + #pragma once #include <string> @@ -13,11 +20,13 @@ #include <Swiften/Elements/S5BProxyRequest.h> #include <Swiften/FileTransfer/SOCKS5BytestreamClientSession.h> #include <Swiften/JID/JID.h> -#include <Swiften/Network/ConnectionFactory.h> -#include <Swiften/Network/TimerFactory.h> +#include <Swiften/FileTransfer/SOCKS5BytestreamProxyFinder.h> namespace Swift { - class SOCKS5BytestreamProxiesDiscoverRequest; + class TimerFactory; + class ConnectionFactory; + class DomainNameResolver; + class DomainNameResolveError; /** * - manages list of working S5B proxies @@ -25,26 +34,44 @@ namespace Swift { */ class SWIFTEN_API SOCKS5BytestreamProxiesManager { public: - SOCKS5BytestreamProxiesManager(ConnectionFactory*, TimerFactory*); - - boost::shared_ptr<SOCKS5BytestreamProxiesDiscoverRequest> createDiscoverProxiesRequest(); + SOCKS5BytestreamProxiesManager(ConnectionFactory*, TimerFactory*, DomainNameResolver*, IQRouter*, const JID&); + ~SOCKS5BytestreamProxiesManager(); void addS5BProxy(S5BProxyRequest::ref); - const std::vector<S5BProxyRequest::ref>& getS5BProxies() const; + + /* + * Returns a list of external S5B proxies. If the optinal return value is not initialized a discovery process has been started and + * onDiscoveredProxiesChanged signal will be emitted when it is finished. + */ + const boost::optional<std::vector<S5BProxyRequest::ref> >& getOrDiscoverS5BProxies(); void connectToProxies(const std::string& sessionID); boost::shared_ptr<SOCKS5BytestreamClientSession> getProxySessionAndCloseOthers(const JID& proxyJID, const std::string& sessionID); boost::shared_ptr<SOCKS5BytestreamClientSession> createSOCKS5BytestreamClientSession(HostAddressPort addressPort, const std::string& destAddr); + public: + boost::signal<void ()> onDiscoveredProxiesChanged; + + private: + void handleProxyFound(S5BProxyRequest::ref proxy); + void handleNameLookupResult(const std::vector<HostAddress>&, boost::optional<DomainNameResolveError>, S5BProxyRequest::ref proxy); + + void queryForProxies(); + private: - ConnectionFactory* connectionFactory; - TimerFactory* timerFactory; + ConnectionFactory* connectionFactory_; + TimerFactory* timerFactory_; + DomainNameResolver* resolver_; + IQRouter* iqRouter_; + JID serviceRoot_; typedef std::map<JID, boost::shared_ptr<SOCKS5BytestreamClientSession> > ProxyJIDClientSessionMap; - std::map<std::string, ProxyJIDClientSessionMap> proxySessions; + std::map<std::string, ProxyJIDClientSessionMap> proxySessions_; + + boost::shared_ptr<SOCKS5BytestreamProxyFinder> proxyFinder_; - std::vector<S5BProxyRequest::ref> localS5BProxies; + boost::optional<std::vector<S5BProxyRequest::ref> > localS5BProxies_; }; } |