[telepathy-gabble/master] query fallback-socks5-proxy if defined
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Apr 3 08:41:36 PDT 2009
---
src/bytestream-factory.c | 52 ++++++++++++++++++++++++++++++++++++++--------
1 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/src/bytestream-factory.c b/src/bytestream-factory.c
index 2f6014b..db8acb9 100644
--- a/src/bytestream-factory.c
+++ b/src/bytestream-factory.c
@@ -244,21 +244,16 @@ socks5_proxy_query_reply_cb (GabbleConnection *conn,
}
static void
-disco_item_found_cb (GabbleDisco *disco,
- GabbleDiscoItem *item,
- GabbleBytestreamFactory *self)
+send_proxy_query (GabbleBytestreamFactory *self,
+ const gchar *jid)
{
GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
self);
LmMessage *query;
- if (tp_strdiff (item->category, "proxy") ||
- tp_strdiff (item->type, "bytestreams"))
- return;
-
- DEBUG ("send SOCKS5 query to %s", item->jid);
+ DEBUG ("send SOCKS5 query to %s", jid);
- query = lm_message_build (item->jid, LM_MESSAGE_TYPE_IQ,
+ query = lm_message_build (jid, LM_MESSAGE_TYPE_IQ,
'@', "type", "get",
'(', "query", "",
'@', "xmlns", NS_BYTESTREAMS,
@@ -270,6 +265,42 @@ disco_item_found_cb (GabbleDisco *disco,
lm_message_unref (query);
}
+static void
+disco_item_found_cb (GabbleDisco *disco,
+ GabbleDiscoItem *item,
+ GabbleBytestreamFactory *self)
+{
+ if (tp_strdiff (item->category, "proxy") ||
+ tp_strdiff (item->type, "bytestreams"))
+ return;
+
+ send_proxy_query (self, item->jid);
+}
+
+static void
+conn_status_changed_cb (GabbleConnection *conn,
+ TpConnectionStatus status,
+ TpConnectionStatusReason reason,
+ gpointer user_data)
+{
+ GabbleBytestreamFactory *self = GABBLE_BYTESTREAM_FACTORY (user_data);
+ GabbleBytestreamFactoryPrivate *priv = GABBLE_BYTESTREAM_FACTORY_GET_PRIVATE (
+ self);
+
+ if (status == TP_CONNECTION_STATUS_CONNECTED)
+ {
+ /* Send SOCKS5 query to fallback SOCKS5 proxy if any */
+ gchar *jid;
+
+ g_object_get (priv->conn, "fallback-socks5-proxy", &jid, NULL);
+ if (jid == NULL)
+ return;
+
+ send_proxy_query (self, jid);
+ g_free (jid);
+ }
+}
+
static GObject *
gabble_bytestream_factory_constructor (GType type,
guint n_props,
@@ -309,6 +340,9 @@ gabble_bytestream_factory_constructor (GType type,
gabble_signal_connect_weak (priv->conn->disco, "item-found",
G_CALLBACK (disco_item_found_cb), G_OBJECT (self));
+ gabble_signal_connect_weak (priv->conn, "status-changed",
+ G_CALLBACK (conn_status_changed_cb), G_OBJECT (self));
+
return obj;
}
--
1.5.6.5
More information about the telepathy-commits
mailing list