cpw.malu.xmpp.jingle_ft: fb105e90: Generate local <streamhost/>s for locall..

malu at pidgin.im malu at pidgin.im
Sat Mar 28 12:45:40 EDT 2009


-----------------------------------------------------------------
Revision: fb105e9012e4c958a93df6954706589c425d385a
Ancestor: 3c2adff3925e0f7b96b27070963646671e22ff8e
Author: malu at pidgin.im
Date: 2009-03-28T16:43:10
Branch: im.pidgin.cpw.malu.xmpp.jingle_ft
URL: http://d.pidgin.im/viewmtn/revision/info/fb105e9012e4c958a93df6954706589c425d385a

Modified files:
        libpurple/protocols/jabber/jingle/s5b.c

ChangeLog: 

Generate local <streamhost/>s for locally known bytestream proxies
Does not yet handle zeroconf proxies
Fixed a cut-n-paste "error" :)

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/s5b.c	72fb7ea54f99a4c2fa2ef0f234697776c9cdc5a5
+++ libpurple/protocols/jabber/jingle/s5b.c	4072378bd268e24eaa23ddc8e23bf02417eb5155
@@ -33,12 +33,14 @@ jingle_s5b_streamhost_create(const gchar
 {
 	JabberBytestreamsStreamhost *sh = g_new0(JabberBytestreamsStreamhost, 1);
 	
-	sh->jid = g_strdup(jid);
-	sh->host = g_strdup(host);
-	sh->port = port;
-	if (zeroconf)
-		sh->zeroconf = g_strdup(zeroconf);
-	
+	if (sh) {
+		sh->jid = g_strdup(jid);
+		sh->host = g_strdup(host);
+		sh->port = port;
+		if (zeroconf)
+			sh->zeroconf = g_strdup(zeroconf);
+	}
+
 	return sh;
 }
 
@@ -52,6 +54,22 @@ jingle_s5b_streamhost_destroy(JabberByte
 	g_free(sh);
 }
 
+JabberBytestreamsStreamhost *
+jingle_s5b_streamhost_copy(const JabberBytestreamsStreamhost *sh)
+{
+	JabberBytestreamsStreamhost *new_sh = g_new0(JabberBytestreamsStreamhost, 1);
+	
+	if (new_sh) {
+		new_sh->jid = g_strdup(sh->jid);
+		new_sh->host = g_strdup(sh->host);
+		new_sh->port = sh->port;
+		if (sh->zeroconf)
+			new_sh->zeroconf = g_strdup(sh->zeroconf);
+	}
+
+	return new_sh;
+}
+
 xmlnode *
 jingle_s5b_streamhost_to_xml(const JabberBytestreamsStreamhost *sh)
 {
@@ -218,7 +236,7 @@ jingle_s5b_to_xml_internal(JingleTranspo
 	const GList *iter;
 	JingleS5B *s5b = JINGLE_S5B(transport);
 	
-	purple_debug_info("jingle", "jingle_ibb_to_xml_internal\n");
+	purple_debug_info("jingle", "jingle_s5b_to_xml_internal\n");
 	if (action == JINGLE_SESSION_INITIATE || action == JINGLE_SESSION_ACCEPT) {
 		for (iter = JINGLE_S5B_GET_PRIVATE(s5b)->local_streamhosts; 
 			iter; 
@@ -242,6 +260,8 @@ jingle_s5b_listen_cb(int sock, gpointer 
 {
 	JingleS5B *s5b = ((JingleS5BListenData *) data)->s5b;
 	JingleSession *session = ((JingleS5BListenData *) data)->session;
+	JabberStream *js = jingle_session_get_js(session);
+	const GList *iter;
 	
 	JINGLE_S5B_GET_PRIVATE(s5b)->listen_data = NULL;
 	
@@ -249,7 +269,6 @@ jingle_s5b_listen_cb(int sock, gpointer 
 	
 	if (sock > 0) {
 		guint local_port = purple_network_get_port_from_fd(sock);
-		JabberStream *js = jingle_session_get_js(session);
 		const gchar *local_ip = purple_network_get_local_system_ip(js->fd);
 		const gchar *public_ip = purple_network_get_my_ip(js->fd);
 		const gchar *jid = g_strdup_printf("%s@%s/%s", js->user->node,
@@ -278,7 +297,23 @@ jingle_s5b_listen_cb(int sock, gpointer 
 		g_free(jid);
 	}
 	
-	/* should gather proxies here */
+	/* add bytestream proxies */
+	for (iter = js->bs_proxies ; iter ; iter = g_list_next(iter)) {
+		JabberBytestreamsStreamhost *sh =
+			(JabberBytestreamsStreamhost *) iter->data;
+		
+		purple_debug_info("jingle-s5b", 
+			"found local bytestream proxy jid = %s, host = %s, port %d\n",
+			sh->jid ? sh->jid : "(null)", sh->host ? sh->host : "(null)",
+			sh->port);
+		
+		/* is this check really nessesary? si.c does it so... */
+		if (sh->jid && sh->host && sh->port > 0) {
+			JINGLE_S5B_GET_PRIVATE(s5b)->local_streamhosts =
+				g_list_append(JINGLE_S5B_GET_PRIVATE(s5b)->local_streamhosts,
+					jingle_s5b_streamhost_copy(sh));		
+		}
+	}
 	
 	/* if we are the initiator send session-initiate */
 	if (jingle_session_is_initiator(session)) {


More information about the Commits mailing list