Author: erijo
Date: Fri Oct 22 14:15:30 2010
New Revision: 7942
Log:
Added support for connecting to a jabber server thru a http proxy
Modified:
trunk/jabber/src/client.cpp
trunk/jabber/src/client.h
Modified: trunk/jabber/src/client.cpp
==============================================================================
--- trunk/jabber/src/client.cpp (original)
+++ trunk/jabber/src/client.cpp Fri Oct 22 14:15:30 2010
@@ -26,6 +26,7 @@
#include "sessionmanager.h"
#include "vcard.h"
+#include <gloox/connectionhttpproxy.h>
#include <gloox/connectiontcpclient.h>
#include <gloox/disco.h>
#include <gloox/message.h>
@@ -49,6 +50,7 @@
mySessionManager(NULL),
myJid(username + "/" + config.getResource()),
myClient(myJid, password),
+ myTcpClient(NULL),
myRosterManager(myClient.rosterManager()),
myVCardManager(&myClient)
{
@@ -63,11 +65,34 @@
myClient.disco()->setIdentity("client", "pc");
myClient.disco()->setVersion("Licq", LICQ_VERSION_STRING);
- if (!config.getServer().empty())
- myClient.setServer(config.getServer());
- if (config.getPort() != -1)
- myClient.setPort(config.getPort());
myClient.setTls(config.getTlsPolicy());
+
+ const Config::Proxy& proxy = config.getProxy();
+ if (proxy.myType == Config::Proxy::TYPE_DISABLED)
+ {
+ if (!config.getServer().empty())
+ myClient.setServer(config.getServer());
+ if (config.getPort() != -1)
+ myClient.setPort(config.getPort());
+ }
+ else if (proxy.myType == Config::Proxy::TYPE_HTTP)
+ {
+ myTcpClient = new gloox::ConnectionTCPClient(
+ myClient.logInstance(), proxy.myServer, proxy.myPort);
+
+ std::string server = myClient.server();
+ if (!config.getServer().empty())
+ server = config.getServer();
+
+ gloox::ConnectionHTTPProxy* httpProxy =
+ new gloox::ConnectionHTTPProxy(
+ &myClient, myTcpClient, myClient.logInstance(),
+ server, config.getPort());
+
+ httpProxy->setProxyAuth(proxy.myUsername, proxy.myPassword);
+
+ myClient.setConnectionImpl(httpProxy);
+ }
}
Client::~Client()
@@ -80,7 +105,10 @@
int Client::getSocket()
{
- return static_cast<gloox::ConnectionTCPClient*>(
+ if (myTcpClient != NULL)
+ return myTcpClient->socket();
+ else
+ return static_cast<gloox::ConnectionTCPClient*>(
myClient.connectionImpl())->socket();
}
Modified: trunk/jabber/src/client.h
==============================================================================
--- trunk/jabber/src/client.h (original)
+++ trunk/jabber/src/client.h Fri Oct 22 14:15:30 2010
@@ -35,6 +35,7 @@
namespace gloox
{
class Client;
+class ConnectionTCPClient;
class RosterManager;
}
@@ -120,6 +121,7 @@
SessionManager* mySessionManager;
gloox::JID myJid;
gloox::Client myClient;
+ gloox::ConnectionTCPClient* myTcpClient;
gloox::RosterManager* myRosterManager;
gloox::VCardManager myVCardManager;
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.