cpw.malu.xmpp.jingle_ft: ebe48bca: Fixed a crash in the connect timeout han...

malu at pidgin.im malu at pidgin.im
Tue Apr 14 17:55:31 EDT 2009


-----------------------------------------------------------------
Revision: ebe48bcae99c59d5523e5f5cb318b9eccc3916d0
Ancestor: 1be689a6f36b6dd2b33065e584ce180e50f27da9
Author: malu at pidgin.im
Date: 2009-04-14T21:49:44
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/ebe48bcae99c59d5523e5f5cb318b9eccc3916d0

Modified files:
        libpurple/protocols/jabber/jingle/file-transfer.c
        libpurple/protocols/jabber/jingle/s5b.c
        libpurple/protocols/jabber/jingle/s5b.h

ChangeLog: 

Fixed a crash in the connect timeout handler.
Added a function to check if a streamhost is a proxy
Does not yet try to connect to the proxy from the client suggesting the
streamhost.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	e0d2e2ec811a55fb905a2359406b9a68b3aa6da5
+++ libpurple/protocols/jabber/jingle/file-transfer.c	d68cea71420c402a1929ed0ae5db639fc8cdee16
@@ -724,9 +724,10 @@ jingle_file_transfer_handle_action_inter
 				xmlnode *streamhost_used = 
 					xmlnode_get_child(xmltransport, "streamhost-used");
 				
-				purple_debug_info("jingle-ft", "xmltransport %p\n", xmltransport);
-				
 				if (streamhost_used) {
+					const gchar *jid = xmlnode_get_attrib(streamhost_used, "jid");
+					JabberStream *js = jingle_session_get_js(session);
+
 					purple_debug_info("jingle-ft", "got streamhost-used\n");
 					/* stop connection attempts */
 					jingle_s5b_stop_connection_attempts(s5b);
@@ -743,9 +744,14 @@ jingle_file_transfer_handle_action_inter
 						/* also when receiving a <streamhost-used/> we need to 
 						 check if that is not one of our local streamhosts, 
 						 in which case it is a proxy, and we should connect to that */
-						
-						/* start transfer */
-						jingle_file_transfer_s5b_connect_callback(content);
+						if (jid && !jingle_s5b_streamhost_is_local(js, jid)) {
+							purple_debug_info("jingle-ft",
+								"got transport-accept on a proxy, "
+								"need to connect to the proxy\n");
+						} else {
+							/* start transfer */
+							jingle_file_transfer_s5b_connect_callback(content);
+						}
 					}
 				}
 			}
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	d18d4f3814413c43c47de0e6143f81bc51406f25
+++ libpurple/protocols/jabber/jingle/s5b.c	cc7039c795e4598285107ab8217e318eadc1c7ce
@@ -927,7 +927,7 @@ static void jingle_s5b_attempt_connect_i
 	
 static void jingle_s5b_attempt_connect_internal(gpointer data);
 
-static void
+static gboolean
 jingle_s5b_connect_timeout_cb(gpointer data)
 {
 	JingleS5B *s5b = ((JingleS5BConnectData *) data)->s5b;
@@ -935,6 +935,7 @@ jingle_s5b_connect_timeout_cb(gpointer d
 	purple_debug_info("jingle-s5b", "in jingle_s5b_connect_timeout_cb\n");
 	/* cancel timeout */
 	purple_timeout_remove(s5b->priv->connect_timeout);
+	s5b->priv->connect_timeout = 0;
 	
 	/* advance streamhost "counter" */
 	if (s5b->priv->remaining_streamhosts) {
@@ -945,6 +946,8 @@ jingle_s5b_connect_timeout_cb(gpointer d
 		 streamhost error (and potentially fallback to IBB) */
 		jingle_s5b_attempt_connect_internal(data);
 	}
+	
+	return FALSE;
 }
 
 static void
@@ -961,7 +964,6 @@ jingle_s5b_attempt_connect_internal(gpoi
 			(JabberBytestreamsStreamhost *) s5b->priv->remaining_streamhosts->data;
 		gchar *dstaddr = NULL;
 		gchar *hash = NULL;
-		JingleS5BConnectData *data = NULL;
 		
 		purple_debug_info("jingle-s5b", 
 			"attempting to connect to streamhost: %s, port: %d\n",
@@ -1100,4 +1102,24 @@ jingle_s5b_take_command(JingleS5B *s5b)
 		purple_timeout_remove(s5b->priv->connect_timeout);
 		s5b->priv->connect_timeout = 0;
 	}
+}
+
+gboolean
+jingle_s5b_streamhost_is_local(JabberStream *js, const gchar *jid)
+{
+	gchar *me = g_strdup_printf("%s@%s/%s", js->user->node, js->user->domain, 
+		js->user->resource);
+	gchar *me_bare = jabber_get_bare_jid(me);
+	gchar *bare_jid = jabber_get_bare_jid(jid);
+	gboolean equal = purple_strequal(bare_jid, me_bare);
+
+	purple_debug_info("jingle-s5b", 
+		"jingle_s5b_streamhost_is_local: comparing JIDs %s and %s\n",
+		me, jid);
+	
+	g_free(me);
+	g_free(me_bare);
+	g_free(bare_jid);
+
+	return equal;
 }
\ No newline at end of file
============================================================
--- libpurple/protocols/jabber/jingle/s5b.h	0c9668e6784fb2d27c245e26bd8faa6a19d334c8
+++ libpurple/protocols/jabber/jingle/s5b.h	242de1cda6996605f8569a1e5dae7053239bccf0
@@ -96,6 +96,10 @@ void jingle_s5b_take_command(JingleS5B *
 void jingle_s5b_surrender(JingleS5B *s5b);
 void jingle_s5b_take_command(JingleS5B *s5b);
 
+/* returns true if the given JID represents a local (to this side) streamhost
+	used to determine if a choosen streamhost is a proxy */
+gboolean jingle_s5b_streamhost_is_local(JabberStream *js, const gchar *jid);
+
 #ifdef __cplusplus
 }
 #endif


More information about the Commits mailing list