summaryrefslogtreecommitdiff
path: root/wocky/wocky-connector.c
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2010-08-26 11:29:12 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2010-10-04 12:53:45 -0400
commit668837041c03de92be41bd70247bde4b733dc6e8 (patch)
tree8d6a98793101e4de8c81c3cce254ee3dbaac329f /wocky/wocky-connector.c
parent3d8bd1bd1e3857f1a14dbba92a8fe6bf7f790054 (diff)
Added support for HTTP Connect Proxy
This patch registers an HTTP Connect extension to GLib proxy facility. This extension is triggered (whenever an HTTPS proxy is set) when legacy_ssl is being by providing a https:// base URI to the GSocketClient connect method.
Diffstat (limited to 'wocky/wocky-connector.c')
-rw-r--r--wocky/wocky-connector.c33
1 files changed, 29 insertions, 4 deletions
diff --git a/wocky/wocky-connector.c b/wocky/wocky-connector.c
index 696cfe2..7924b72 100644
--- a/wocky/wocky-connector.c
+++ b/wocky/wocky-connector.c
@@ -101,6 +101,7 @@
#define DEBUG_FLAG DEBUG_CONNECTOR
#include "wocky-debug.h"
+#include "wocky-http-proxy.h"
#include "wocky-sasl-auth.h"
#include "wocky-tls-handler.h"
#include "wocky-tls-connector.h"
@@ -575,6 +576,11 @@ wocky_connector_class_init (WockyConnectorClass *klass)
oclass->dispose = wocky_connector_dispose;
oclass->finalize = wocky_connector_finalize;
+#if HAVE_GIO_PROXY
+ /* Ensure that HTTP Proxy extension is registered */
+ _wocky_http_proxy_get_type ();
+#endif
+
/**
* WockyConnector:plaintext-auth-allowed:
*
@@ -803,6 +809,27 @@ wocky_connector_finalize (GObject *object)
}
static void
+connect_to_host_async (WockyConnector *connector,
+ const gchar *host,
+ guint port)
+{
+ WockyConnectorPrivate *priv = connector->priv;
+
+#if HAVE_GIO_PROXY
+ /* Legacy SSL mode is just like doing HTTPS, so let's trigger HTTPS
+ * proxy setting if any */
+ gchar *uri = g_strdup_printf ("%s://%s:%i",
+ priv->legacy_ssl ? "https" : "xmpp-client", host, port);
+ g_socket_client_connect_to_uri_async (priv->client,
+ uri, port, NULL, tcp_host_connected, connector);
+ g_free (uri);
+#else
+ g_socket_client_connect_to_host_async (priv->client,
+ host, port, NULL, tcp_host_connected, connector);
+#endif
+}
+
+static void
tcp_srv_connected (GObject *source,
GAsyncResult *result,
gpointer connector)
@@ -858,8 +885,7 @@ tcp_srv_connected (GObject *source,
wocky_decode_jid (priv->jid, &node, &host, NULL);
if ((host != NULL) && (*host != '\0'))
- g_socket_client_connect_to_host_async (priv->client,
- host, port, priv->cancellable, tcp_host_connected, connector);
+ connect_to_host_async (connector, host, port);
else
abort_connect_code (self, WOCKY_CONNECTOR_ERROR_BAD_JID,
"JID contains no domain: %s", priv->jid);
@@ -2285,8 +2311,7 @@ connector_connect_async (WockyConnector *self,
const gchar *srv = (priv->xmpp_host == NULL) ? host : priv->xmpp_host;
DEBUG ("host: %s; port: %d", priv->xmpp_host, priv->xmpp_port);
- g_socket_client_connect_to_host_async (priv->client, srv, port,
- priv->cancellable, tcp_host_connected, self);
+ connect_to_host_async (self, srv, port);
}
else
{