pidgin.vv: 1028c2d4: Make IceUdp candidates know whether the ...

maiku at soc.pidgin.im maiku at soc.pidgin.im
Thu Mar 19 04:10:29 EDT 2009


-----------------------------------------------------------------
Revision: 1028c2d493ce00b2e66919c173aad03875c2f81b
Ancestor: 9676f44f4c05ee4d44f08d026dd186b308fb0767
Author: maiku at soc.pidgin.im
Date: 2009-03-19T07:34:25
Branch: im.pidgin.pidgin.vv
URL: http://d.pidgin.im/viewmtn/revision/info/1028c2d493ce00b2e66919c173aad03875c2f81b

Modified files:
        libpurple/protocols/jabber/jingle/iceudp.c
        libpurple/protocols/jabber/jingle/iceudp.h

ChangeLog: 

Make IceUdp candidates know whether the remote side knows about them.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jingle/iceudp.c	9e174b77f255cd922295898f3f21986c627f13d2
+++ libpurple/protocols/jabber/jingle/iceudp.c	d381ae5bfd793475ca90c4fc4e6ebdb6320e6e26
@@ -119,6 +119,8 @@ jingle_iceudp_candidate_new(guint compon
 
 	candidate->username = g_strdup(username);
 	candidate->password = g_strdup(password);
+
+	candidate->rem_known = FALSE;
 	return candidate;
 }
 
@@ -324,6 +326,7 @@ jingle_iceudp_parse_internal(xmlnode *ic
 				xmlnode_get_attrib(candidate, "rel-addr"));
 		iceudp_candidate->relport =
 				relport != NULL ? atoi(relport) : 0;
+		iceudp_candidate->rem_known = TRUE;
 		jingle_iceudp_add_remote_candidate(JINGLE_ICEUDP(transport), iceudp_candidate);
 	}
 
@@ -342,23 +345,28 @@ jingle_iceudp_to_xml_internal(JingleTran
 			action == JINGLE_TRANSPORT_REPLACE) {
 		JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(transport);
 		GList *iter = priv->local_candidates;
+		gboolean used_candidate = FALSE;
 
-		if (iter && iter->data) {
+		for (; iter; iter = g_list_next(iter)) {
 			JingleIceUdpCandidate *candidate = iter->data;
-			xmlnode_set_attrib(node, "pwd", candidate->password);
-			xmlnode_set_attrib(node, "ufrag", candidate->username);
-		}
+			xmlnode *xmltransport;
+			gchar *component, *generation, *network,
+					*port, *priority;
 
-		for (; iter; iter = g_list_next(iter)) {
-			JingleIceUdpCandidate *candidate = iter->data;
+			if (candidate->rem_known == TRUE)
+				continue;
 
-			xmlnode *xmltransport = xmlnode_new_child(node, "candidate");
-			gchar *component = g_strdup_printf("%d", candidate->component);
-			gchar *generation = g_strdup_printf("%d", candidate->generation);
-			gchar *network = g_strdup_printf("%d", candidate->network);
-			gchar *port = g_strdup_printf("%d", candidate->port);
-			gchar *priority = g_strdup_printf("%d", candidate->priority);
+			used_candidate = TRUE;
+			candidate->rem_known = TRUE;
 
+			xmltransport = xmlnode_new_child(node, "candidate");
+			component = g_strdup_printf("%d", candidate->component);
+			generation = g_strdup_printf("%d",
+					candidate->generation);
+			network = g_strdup_printf("%d", candidate->network);
+			port = g_strdup_printf("%d", candidate->port);
+			priority = g_strdup_printf("%d", candidate->priority);
+
 			xmlnode_set_attrib(xmltransport, "component", component);
 			xmlnode_set_attrib(xmltransport, "foundation", candidate->foundation);
 			xmlnode_set_attrib(xmltransport, "generation", generation);
@@ -389,6 +397,13 @@ jingle_iceudp_to_xml_internal(JingleTran
 			g_free(port);
 			g_free(priority);
 		}
+
+		if (used_candidate == TRUE) {
+			JingleIceUdpCandidate *candidate =
+					priv->local_candidates->data;
+			xmlnode_set_attrib(node, "pwd", candidate->password);
+			xmlnode_set_attrib(node, "ufrag", candidate->username);
+		}
 	}
 
 	return node;
============================================================
--- libpurple/protocols/jabber/jingle/iceudp.h	202e736fc53ba124543e94b5b8a1e3a75316da3b
+++ libpurple/protocols/jabber/jingle/iceudp.h	a7635fe12bc2553d8da5500a11871a5225dc95c2
@@ -78,6 +78,9 @@ struct _JingleIceUdpCandidate
 
 	gchar *username;
 	gchar *password;
+
+	gboolean rem_known;	/* TRUE if the remote side knows
+				 * about this candidate */
 };
 
 #ifdef __cplusplus


More information about the Commits mailing list