summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemko Tronçon <git@el-tramo.be>2011-10-16 08:16:56 (GMT)
committerRemko Tronçon <git@el-tramo.be>2011-10-16 08:16:56 (GMT)
commit76978866497a7dd9be96edef5fa06f470a6b324f (patch)
treef5fb6b922b0e3ba974f6d67640f0b4d195ed96cd
parent9e6b127cf35319b0e89d4d6f4dff55a80ce03c02 (diff)
downloadswift-76978866497a7dd9be96edef5fa06f470a6b324f.zip
swift-76978866497a7dd9be96edef5fa06f470a6b324f.tar.bz2
Hoist ProxyProvider creation out of Client.
-rw-r--r--Swiften/Client/CoreClient.cpp11
-rw-r--r--Swiften/Network/BoostNetworkFactories.cpp11
-rw-r--r--Swiften/Network/BoostNetworkFactories.h5
-rw-r--r--Swiften/Network/NetworkFactories.h2
4 files changed, 19 insertions, 10 deletions
diff --git a/Swiften/Client/CoreClient.cpp b/Swiften/Client/CoreClient.cpp
index 2a66905..a8a5c8f 100644
--- a/Swiften/Client/CoreClient.cpp
+++ b/Swiften/Client/CoreClient.cpp
@@ -17,11 +17,11 @@
#include <Swiften/TLS/CertificateVerificationError.h>
#include <Swiften/Network/ChainedConnector.h>
#include <Swiften/Network/NetworkFactories.h>
+#include <Swiften/Network/ProxyProvider.h>
#include <Swiften/TLS/PKCS12Certificate.h>
#include <Swiften/Session/BasicSessionStream.h>
#include <Swiften/Queries/IQRouter.h>
#include <Swiften/Client/ClientSessionStanzaChannel.h>
-#include <Swiften/Network/PlatformProxyProvider.h>
#include <Swiften/Network/SOCKS5ProxiedConnectionFactory.h>
#include <Swiften/Network/HTTPConnectProxiedConnectionFactory.h>
@@ -62,12 +62,11 @@ void CoreClient::connect(const std::string& host) {
disconnectRequested_ = false;
assert(!connector_);
assert(proxyConnectionFactories.empty());
- PlatformProxyProvider proxyProvider;
- if(proxyProvider.getSOCKS5Proxy().isValid()) {
- proxyConnectionFactories.push_back(new SOCKS5ProxiedConnectionFactory(networkFactories->getConnectionFactory(), proxyProvider.getSOCKS5Proxy()));
+ if(networkFactories->getProxyProvider()->getSOCKS5Proxy().isValid()) {
+ proxyConnectionFactories.push_back(new SOCKS5ProxiedConnectionFactory(networkFactories->getConnectionFactory(), networkFactories->getProxyProvider()->getSOCKS5Proxy()));
}
- if(proxyProvider.getHTTPConnectProxy().isValid()) {
- proxyConnectionFactories.push_back(new HTTPConnectProxiedConnectionFactory(networkFactories->getConnectionFactory(), proxyProvider.getHTTPConnectProxy()));
+ if(networkFactories->getProxyProvider()->getHTTPConnectProxy().isValid()) {
+ proxyConnectionFactories.push_back(new HTTPConnectProxiedConnectionFactory(networkFactories->getConnectionFactory(), networkFactories->getProxyProvider()->getHTTPConnectProxy()));
}
std::vector<ConnectionFactory*> connectionFactories(proxyConnectionFactories);
connectionFactories.push_back(networkFactories->getConnectionFactory());
diff --git a/Swiften/Network/BoostNetworkFactories.cpp b/Swiften/Network/BoostNetworkFactories.cpp
index 030fd49..2b4c04b 100644
--- a/Swiften/Network/BoostNetworkFactories.cpp
+++ b/Swiften/Network/BoostNetworkFactories.cpp
@@ -13,6 +13,7 @@
#include <Swiften/Parser/PlatformXMLParserFactory.h>
#include <Swiften/Network/NullNATTraverser.h>
#include <Swiften/TLS/PlatformTLSFactories.h>
+#include <Swiften/Network/PlatformProxyProvider.h>
namespace Swift {
@@ -28,13 +29,11 @@ BoostNetworkFactories::BoostNetworkFactories(EventLoop* eventLoop) {
#endif
xmlParserFactory = new PlatformXMLParserFactory();
tlsFactories = new PlatformTLSFactories();
-}
-
-TLSContextFactory* BoostNetworkFactories::getTLSContextFactory() const {
- return tlsFactories->getTLSContextFactory();
+ proxyProvider = new PlatformProxyProvider();
}
BoostNetworkFactories::~BoostNetworkFactories() {
+ delete proxyProvider;
delete tlsFactories;
delete xmlParserFactory;
delete natTraverser;
@@ -44,4 +43,8 @@ BoostNetworkFactories::~BoostNetworkFactories() {
delete timerFactory;
}
+TLSContextFactory* BoostNetworkFactories::getTLSContextFactory() const {
+ return tlsFactories->getTLSContextFactory();
+}
+
}
diff --git a/Swiften/Network/BoostNetworkFactories.h b/Swiften/Network/BoostNetworkFactories.h
index 8f2b17a..3d268d1 100644
--- a/Swiften/Network/BoostNetworkFactories.h
+++ b/Swiften/Network/BoostNetworkFactories.h
@@ -49,6 +49,10 @@ namespace Swift {
virtual TLSContextFactory* getTLSContextFactory() const;
+ virtual ProxyProvider* getProxyProvider() const {
+ return proxyProvider;
+ }
+
private:
BoostIOServiceThread ioServiceThread;
TimerFactory* timerFactory;
@@ -58,5 +62,6 @@ namespace Swift {
NATTraverser* natTraverser;
XMLParserFactory* xmlParserFactory;
PlatformTLSFactories* tlsFactories;
+ ProxyProvider* proxyProvider;
};
}
diff --git a/Swiften/Network/NetworkFactories.h b/Swiften/Network/NetworkFactories.h
index 2404460..6eba2f3 100644
--- a/Swiften/Network/NetworkFactories.h
+++ b/Swiften/Network/NetworkFactories.h
@@ -15,6 +15,7 @@ namespace Swift {
class XMLParserFactory;
class TLSContextFactory;
class CertificateFactory;
+ class ProxyProvider;
/**
* An interface collecting network factories.
@@ -30,5 +31,6 @@ namespace Swift {
virtual NATTraverser* getNATTraverser() const = 0;
virtual XMLParserFactory* getXMLParserFactory() const = 0;
virtual TLSContextFactory* getTLSContextFactory() const = 0;
+ virtual ProxyProvider* getProxyProvider() const = 0;
};
}