cpw.malu.xmpp.jingle_ft: e376edbf: Don't start connection attempts for the ...

malu at pidgin.im malu at pidgin.im
Sun Apr 5 16:50:29 EDT 2009


-----------------------------------------------------------------
Revision: e376edbf006d77ee04ae5c73d3f015133f4f4a60
Ancestor: e5bdc641d63e0e30e039327e133de6ede785b174
Author: malu at pidgin.im
Date: 2009-04-05T20:48:03
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/e376edbf006d77ee04ae5c73d3f015133f4f4a60

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

ChangeLog: 

Don't start connection attempts for the receiver until the user has accepted
the transfer. Prevents "leaking" the IP to unknown JIDs and also should keeps
the flow correct, not sending transport-accept before session-accept
Include the successful streamhos (streamhost-used) in transport-accept upon
successful connection.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/file-transfer.c	e860803fd3dc0a58553a646c003c69366777305a
+++ libpurple/protocols/jabber/jingle/file-transfer.c	0f6c1e54962127807d67ecb86f1321e7fd7e7f26
@@ -487,6 +487,7 @@ jingle_file_transfer_xfer_init(PurpleXfe
 			/* start the transfer */
 			purple_xfer_start(xfer, 0, NULL, 0);
 		} else if (JINGLE_IS_S5B(transport)) {
+			jingle_s5b_attempt_connect(session, JINGLE_S5B(transport));
 			jingle_s5b_gather_streamhosts(session, JINGLE_S5B(transport));	
 		}
 		g_object_unref(session);
@@ -642,9 +643,6 @@ jingle_file_transfer_handle_action_inter
 					const gchar *filename = 
 						purple_xfer_get_local_filename(xfer);
 					jingle_ibb_create_session(ibb, content, sid, who);
-				} else if (JINGLE_IS_S5B(transport)) {
-					/* attempt to connect bytestream */
-					jingle_s5b_attempt_connect(session, JINGLE_S5B(transport));
 				}
 				
 				g_object_unref(transport);
@@ -691,6 +689,11 @@ jingle_file_transfer_handle_action_inter
 			g_object_unref(session);
 			break;
 		}
+		case JINGLE_TRANSPORT_ACCEPT: {
+			
+				
+			break;
+		}
 		case JINGLE_TRANSPORT_REPLACE: {
 			JingleSession *session = jingle_content_get_session(content);
 			
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	075b05fb1064814c2ecefe6b2f515ea16267c5ca
+++ libpurple/protocols/jabber/jingle/s5b.c	9a6e7d7084e8beeaa27ec86c540e680dac3dbd9a
@@ -91,24 +91,41 @@ jingle_s5b_streamhost_copy(const JabberB
 	return new_sh;
 }
 
-static xmlnode *
-jingle_s5b_streamhost_to_xml(const JabberBytestreamsStreamhost *sh)
+static void
+jingle_s5b_streamhost_add_xml_internal(xmlnode *node, 
+	const JabberBytestreamsStreamhost *sh)
 {
-	xmlnode *streamhost = xmlnode_new("streamhost");
 	gchar port[10];
-	
-	if (streamhost) {
+
+	if (node) {
 		g_snprintf(port, 10, "%d", sh->port);
-		xmlnode_set_attrib(streamhost, "jid", sh->jid);
-		xmlnode_set_attrib(streamhost, "host", sh->host);
-		xmlnode_set_attrib(streamhost, "port", port);
+		xmlnode_set_attrib(node, "jid", sh->jid);
+		xmlnode_set_attrib(node, "host", sh->host);
+		xmlnode_set_attrib(node, "port", port);
 		if (sh->zeroconf)
-			xmlnode_set_attrib(streamhost, "zeroconf", sh->zeroconf);
+			xmlnode_set_attrib(node, "zeroconf", sh->zeroconf);
 	}
+}
+
+static xmlnode *
+jingle_s5b_streamhost_to_xml(const JabberBytestreamsStreamhost *sh)
+{
+	xmlnode *streamhost = xmlnode_new("streamhost");
 	
+	jingle_s5b_streamhost_add_xml_internal(streamhost, sh);
+	
 	return streamhost;
 }
 
+static xmlnode *
+jingle_s5b_streamhost_to_xml_used(const JabberBytestreamsStreamhost *sh)
+{
+	xmlnode *streamhost_used = xmlnode_new("streamhost-used");
+	
+	jingle_s5b_streamhost_add_xml_internal(streamhost_used, sh);
+	
+	return streamhost_used;
+}
 
 struct _JingleS5BPrivate {
 	/* S5B stuff here... */
@@ -126,6 +143,7 @@ struct _JingleS5BPrivate {
 	GList *remote_streamhosts;
 	GList *local_streamhosts;
 	GList *remaining_streamhosts; /* pointer to untested remote SHs */
+	JabberBytestreamsStreamhost *successfull_remote_streamhost;
 };
 
 #define JINGLE_S5B_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_S5B, JingleS5BPrivate))
@@ -339,6 +357,11 @@ jingle_s5b_to_xml_internal(JingleTranspo
 				(JabberBytestreamsStreamhost *) iter->data;
 			xmlnode_insert_child(node, jingle_s5b_streamhost_to_xml(sh));
 		}
+	} else if (action == JINGLE_TRANSPORT_ACCEPT) {
+		/* should include the chosen streamhost here... */
+		xmlnode_insert_child(node, 
+			jingle_s5b_streamhost_to_xml_used(
+				s5b->priv->successfull_remote_streamhost));
 	}
 
 	return node;
@@ -779,6 +802,7 @@ jingle_s5b_connect_cb(gpointer data, gin
 {
 	JingleS5BConnectData *cd = (JingleS5BConnectData *) data;
 	JingleS5B *s5b = cd->s5b;
+	JingleSession *session = cd->session;
 	
 	purple_debug_info("jingle-s5b", "Successful in connecting!\n");
 	
@@ -786,7 +810,11 @@ jingle_s5b_connect_cb(gpointer data, gin
 	
 	/* should stop trying to connect */
 	
+	/* set the currently tried streamhost as the successfull one */
+	s5b->priv->successfull_remote_streamhost =
+		(JabberBytestreamsStreamhost *) s5b->priv->remaining_streamhosts->data;
 	/* should send transport-info with streamhost-used */
+	jabber_iq_send(jingle_session_to_packet(session, JINGLE_TRANSPORT_ACCEPT));
 	
 	g_free(cd);
 }


More information about the Commits mailing list