From 73e0ff12326f1a44c43e3a046ba34154deffbf9c Mon Sep 17 00:00:00 2001 From: Manjeet Dahiya Date: Sat, 24 Oct 2009 07:00:05 +0000 Subject: Fix for Issue 12: Proxy support Adding functions in QXmppConfiguration to specify QNetworkProxy. --- source/QXmppConfiguration.cpp | 23 +++++++++++++++++++++++ source/QXmppConfiguration.h | 6 ++++++ source/QXmppStream.cpp | 3 ++- 3 files changed, 31 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/QXmppConfiguration.cpp b/source/QXmppConfiguration.cpp index d40956ea..af643d4a 100644 --- a/source/QXmppConfiguration.cpp +++ b/source/QXmppConfiguration.cpp @@ -192,3 +192,26 @@ void QXmppConfiguration::setSASLAuthMechanism( { m_SASLAuthMechanism = mech; } + +/// Specifies the network proxy used for the connection made by QXmppClient. +/// The default value is QNetworkProxy::DefaultProxy that is the proxy is +/// determined based on the application proxy set using +/// QNetworkProxy::setApplicationProxy(). +/// \param proxy QNetworkProxy + +void QXmppConfiguration::setNetworkProxy(const QNetworkProxy& proxy) +{ + m_networkProxy = proxy; +} + +/// Returns the specified network proxy. +/// The default value is QNetworkProxy::DefaultProxy that is the proxy is +/// determined based on the application proxy set using +/// QNetworkProxy::setApplicationProxy(). +/// \return QNetworkProxy + +QNetworkProxy QXmppConfiguration::getNetworkProxy() +{ + return m_networkProxy; +} + diff --git a/source/QXmppConfiguration.h b/source/QXmppConfiguration.h index 9b144b56..cb3f60e9 100644 --- a/source/QXmppConfiguration.h +++ b/source/QXmppConfiguration.h @@ -26,6 +26,7 @@ #define QXMPPCONFIGURATION_H #include +#include class QXmppConfiguration { @@ -100,6 +101,9 @@ public: getSASLAuthMechanism() const; void setSASLAuthMechanism(QXmppConfiguration::SASLAuthMechanism); + void setNetworkProxy(const QNetworkProxy& proxy); + QNetworkProxy getNetworkProxy(); + private: QString m_host; int m_port; @@ -126,6 +130,8 @@ private: StreamSecurityMode m_streamSecurityMode; NonSASLAuthMechanism m_nonSASLAuthMechanism; SASLAuthMechanism m_SASLAuthMechanism; + + QNetworkProxy m_networkProxy; }; #endif // QXMPPCONFIGURATION_H diff --git a/source/QXmppStream.cpp b/source/QXmppStream.cpp index 9c4bd5bd..70e9a4e8 100644 --- a/source/QXmppStream.cpp +++ b/source/QXmppStream.cpp @@ -103,9 +103,10 @@ QXmppConfiguration& QXmppStream::getConfiguration() void QXmppStream::connect() { - // work with time out log(QString("Connecting to: %1:%2").arg(getConfiguration(). getHost()).arg(getConfiguration().getPort())); + + m_socket.setProxy(getConfiguration().getNetworkProxy()); m_socket.connectToHost(getConfiguration(). getHost(), getConfiguration().getPort()); } -- cgit v1.2.3