diff options
-rw-r--r-- | Swiften/Network/UnixProxyProvider.cpp | 34 | ||||
-rw-r--r-- | Swiften/Network/UnixProxyProvider.h | 13 |
2 files changed, 28 insertions, 19 deletions
diff --git a/Swiften/Network/UnixProxyProvider.cpp b/Swiften/Network/UnixProxyProvider.cpp index 04c95e4..7790ad8 100644 --- a/Swiften/Network/UnixProxyProvider.cpp +++ b/Swiften/Network/UnixProxyProvider.cpp @@ -10,25 +10,33 @@ #include <Swiften/Base/foreach.h> #include <Swiften/Network/UnixProxyProvider.h> +#if defined(HAVE_GCONF) +# include "Swiften/Network/GConfProxyProvider.h" +#endif namespace Swift { UnixProxyProvider::UnixProxyProvider() : -#if defined(HAVE_GCONF) - gconfProxyProvider(), -#endif + gconfProxyProvider(0), environmentProxyProvider() { +#if defined(HAVE_GCONF) + gconfProxyProvider = new GConfProxyProvider(); +#endif +} + +UnixProxyProvider::~UnixProxyProvider() { + delete gconfProxyProvider; } HostAddressPort UnixProxyProvider::getSOCKS5Proxy() const { HostAddressPort proxy; -#if defined(HAVE_GCONF) - proxy = gconfProxyProvider.getSOCKS5Proxy(); - if(proxy.isValid()) { - return proxy; + if (gconfProxyProvider) { + proxy = gconfProxyProvider.getSOCKS5Proxy(); + if(proxy.isValid()) { + return proxy; + } } -#endif proxy = environmentProxyProvider.getSOCKS5Proxy(); if(proxy.isValid()) { return proxy; @@ -38,12 +46,12 @@ HostAddressPort UnixProxyProvider::getSOCKS5Proxy() const { HostAddressPort UnixProxyProvider::getHTTPConnectProxy() const { HostAddressPort proxy; -#if defined(HAVE_GCONF) - proxy = gconfProxyProvider.getHTTPConnectProxy(); - if(proxy.isValid()) { - return proxy; + if (gconfProxyProvider) { + proxy = gconfProxyProvider.getHTTPConnectProxy(); + if(proxy.isValid()) { + return proxy; + } } -#endif proxy = environmentProxyProvider.getHTTPConnectProxy(); if(proxy.isValid()) { return proxy; diff --git a/Swiften/Network/UnixProxyProvider.h b/Swiften/Network/UnixProxyProvider.h index 8657a95..37a4d05 100644 --- a/Swiften/Network/UnixProxyProvider.h +++ b/Swiften/Network/UnixProxyProvider.h @@ -5,21 +5,22 @@ */ #pragma once -#if defined(HAVE_GCONF) -# include "Swiften/Network/GConfProxyProvider.h" -#endif + #include <Swiften/Network/EnvironmentProxyProvider.h> namespace Swift { + class GConfProxyProvider; + class UnixProxyProvider : public ProxyProvider { public: UnixProxyProvider(); + ~UnixProxyProvider(); + virtual HostAddressPort getHTTPConnectProxy() const; virtual HostAddressPort getSOCKS5Proxy() const; + private: -#if defined(HAVE_GCONF) - GConfProxyProvider gconfProxyProvider; -#endif + GConfProxyProvider* gconfProxyProvider; EnvironmentProxyProvider environmentProxyProvider; }; } |