pidgin: e9179f69: Use Service Discovery to look up informa...

datallah at pidgin.im datallah at pidgin.im
Sun Jul 27 19:40:39 EDT 2008


-----------------------------------------------------------------
Revision: e9179f6992531a71364a9bb343ed1c64938f6fc9
Ancestor: e6d719466aabdf9193fa5a1be424bc651b35e0e0
Author: datallah at pidgin.im
Date: 2008-07-27T23:36:15
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/e9179f6992531a71364a9bb343ed1c64938f6fc9

Modified files:
        libpurple/protocols/jabber/disco.c
        libpurple/protocols/jabber/libxmpp.c
        libpurple/protocols/jabber/si.c

ChangeLog: 

Use Service Discovery to look up information about the manually specified FT
proxy for XMPP instead of having a manually specified port and etc.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/disco.c	091b432ce26cf0eeed08aa0b0198e38098df1765
+++ libpurple/protocols/jabber/disco.c	7f85a8a092ed6670ee147af38b8482042416e2ee
@@ -73,6 +73,15 @@ jabber_disco_bytestream_server_cb(Jabber
 			  "jid='%s' host='%s' port='%d' zeroconf='%s'\n",
 			   from ? from : "", sh->host ? sh->host : "",
 			   sh->port, sh->zeroconf ? sh->zeroconf : "");
+
+	/* TODO: When we support zeroconf proxies, fix this to handle them */
+	if (!(sh->jid && sh->host && sh->port > 0)) {
+		g_free(sh->jid);
+		g_free(sh->host);
+		g_free(sh->zeroconf);
+		g_free(sh);
+		js->bs_proxies = g_list_remove(js->bs_proxies, sh);
+	}
 }
 
 
@@ -329,6 +338,7 @@ jabber_disco_finish_server_info_result_c
 static void
 jabber_disco_finish_server_info_result_cb(JabberStream *js)
 {
+	const char *ft_proxies;
 
 	jabber_vcard_fetch_mine(js);
 
@@ -339,11 +349,44 @@ jabber_disco_finish_server_info_result_c
 
 	/* Send initial presence; this will trigger receipt of presence for contacts on the roster */
 	jabber_presence_send(js->gc->account, NULL);
-	
+
 	if (js->server_caps & JABBER_CAP_ADHOC) {
 		/* The server supports ad-hoc commands, so let's request the list */
 		jabber_adhoc_server_get_list(js);
 	}
+
+	/* If there are manually specified bytestream proxies, query them */
+	ft_proxies = purple_account_get_string(js->gc->account, "ft_proxies", NULL);
+	if (ft_proxies) {
+		JabberIq *iq;
+		JabberBytestreamsStreamhost *sh;
+		int i;
+		char *tmp;
+		gchar **ft_proxy_list = g_strsplit(ft_proxies, ",", 0);
+
+		for(i = 0; ft_proxy_list[i]; i++) {
+			g_strstrip(ft_proxy_list[i]);
+			if(!(*ft_proxy_list[i]))
+				continue;
+
+			/* We used to allow specifying a port directly here; get rid of it */
+			if((tmp = strchr(ft_proxy_list[i], ':')))
+				*tmp = '\0';
+
+			sh = g_new0(JabberBytestreamsStreamhost, 1);
+			sh->jid = g_strdup(ft_proxy_list[i]);
+			js->bs_proxies = g_list_prepend(js->bs_proxies, sh);
+
+			iq = jabber_iq_new_query(js, JABBER_IQ_GET,
+						 "http://jabber.org/protocol/bytestreams");
+			xmlnode_set_attrib(iq->node, "to", sh->jid);
+			jabber_iq_set_callback(iq, jabber_disco_bytestream_server_cb, sh);
+			jabber_iq_send(iq);
+		}
+
+		g_strfreev(ft_proxy_list);
+	}
+
 }
 
 static void
============================================================
--- libpurple/protocols/jabber/libxmpp.c	90ba16a3f3ee3336863a2d62bf39df8451cc3832
+++ libpurple/protocols/jabber/libxmpp.c	37c5d833d44d6b92546bfac621deebad97d7f961
@@ -236,7 +236,7 @@ init_plugin(PurplePlugin *plugin)
 	option = purple_account_option_string_new(_("File transfer proxies"),
 						  "ft_proxies",
 						/* TODO: Is this an acceptable default? */
-						  "proxy.jabber.org:7777");
+						  "proxy.jabber.org");
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,
 						  option);
 
============================================================
--- libpurple/protocols/jabber/si.c	3a82e5902038877892223bc1b5164303625dc9cf
+++ libpurple/protocols/jabber/si.c	4b09bb24a92388e97a79e473b80bb30051f593b7
@@ -721,7 +721,6 @@ jabber_si_xfer_bytestreams_listen_cb(int
 	JabberSIXfer *jsx;
 	JabberIq *iq;
 	xmlnode *query, *streamhost;
-	const char *ft_proxies;
 	char port[6];
 	GList *tmp;
 	JabberBytestreamsStreamhost *sh, *sh2;
@@ -785,52 +784,6 @@ jabber_si_xfer_bytestreams_listen_cb(int
 				jabber_si_xfer_bytestreams_send_connected_cb, xfer);
 	}
 
-	/* insert proxies here */
-	ft_proxies = purple_account_get_string(xfer->account, "ft_proxies", NULL);
-	if (ft_proxies) {
-		int i, portnum;
-		char *tmp;
-		gchar **ft_proxy_list = g_strsplit(ft_proxies, ",", 0);
-
-		g_list_foreach(jsx->streamhosts, jabber_si_free_streamhost, NULL);
-		g_list_free(jsx->streamhosts);
-		jsx->streamhosts = NULL;
-
-		for(i = 0; ft_proxy_list[i]; i++) {
-			g_strstrip(ft_proxy_list[i]);
-			if(!(*ft_proxy_list[i]))
-				continue;
-
-			if((tmp = strchr(ft_proxy_list[i], ':'))) {
-				portnum = atoi(tmp + 1);
-				*tmp = '\0';
-			} else
-				portnum = 7777;
-
-			g_snprintf(port, sizeof(port), "%hu", portnum);
-
-			purple_debug_info("jabber", "jabber_si_xfer_bytestreams_listen_cb() will be looking at jsx %p: jsx->streamhosts %p and ft_proxy_list[%i] %p\n",
-							  jsx, jsx->streamhosts, i, ft_proxy_list[i]);
-			if(g_list_find_custom(jsx->streamhosts, ft_proxy_list[i], jabber_si_compare_jid) != NULL)
-				continue;
-
-			streamhost_count++;
-			streamhost = xmlnode_new_child(query, "streamhost");
-			xmlnode_set_attrib(streamhost, "jid", ft_proxy_list[i]);
-			xmlnode_set_attrib(streamhost, "host", ft_proxy_list[i]);
-			xmlnode_set_attrib(streamhost, "port", port);
-
-			sh = g_new0(JabberBytestreamsStreamhost, 1);
-			sh->jid = g_strdup(ft_proxy_list[i]);
-			sh->host = g_strdup(ft_proxy_list[i]);
-			sh->port = portnum;
-
-			jsx->streamhosts = g_list_prepend(jsx->streamhosts, sh);
-		}
-
-		g_strfreev(ft_proxy_list);
-	}
-
 	for (tmp = jsx->js->bs_proxies; tmp; tmp = tmp->next) {
 		sh = tmp->data;
 


More information about the Commits mailing list