Mercurial > pidgin
comparison libpurple/protocols/jabber/jingle/iceudp.c @ 26097:84ea07648377
Add the id attribute to ice-udp according to the XEP.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Thu, 05 Feb 2009 09:36:23 +0000 |
parents | db517c55c508 |
children | 36c7efb85220 |
comparison
equal
deleted
inserted
replaced
26096:ee3f63fbd071 | 26097:84ea07648377 |
---|---|
55 { | 55 { |
56 JingleIceUdpCandidate *new_candidate = g_new0(JingleIceUdpCandidate, 1); | 56 JingleIceUdpCandidate *new_candidate = g_new0(JingleIceUdpCandidate, 1); |
57 new_candidate->component = candidate->component; | 57 new_candidate->component = candidate->component; |
58 new_candidate->foundation = g_strdup(candidate->foundation); | 58 new_candidate->foundation = g_strdup(candidate->foundation); |
59 new_candidate->generation = candidate->generation; | 59 new_candidate->generation = candidate->generation; |
60 new_candidate->id = g_strdup(candidate->id); | |
60 new_candidate->ip = g_strdup(candidate->ip); | 61 new_candidate->ip = g_strdup(candidate->ip); |
61 new_candidate->network = candidate->network; | 62 new_candidate->network = candidate->network; |
62 new_candidate->port = candidate->port; | 63 new_candidate->port = candidate->port; |
63 new_candidate->priority = candidate->priority; | 64 new_candidate->priority = candidate->priority; |
64 new_candidate->protocol = g_strdup(candidate->protocol); | 65 new_candidate->protocol = g_strdup(candidate->protocol); |
72 | 73 |
73 static void | 74 static void |
74 jingle_iceudp_candidate_free(JingleIceUdpCandidate *candidate) | 75 jingle_iceudp_candidate_free(JingleIceUdpCandidate *candidate) |
75 { | 76 { |
76 g_free(candidate->foundation); | 77 g_free(candidate->foundation); |
78 g_free(candidate->id); | |
77 g_free(candidate->ip); | 79 g_free(candidate->ip); |
78 g_free(candidate->protocol); | 80 g_free(candidate->protocol); |
79 g_free(candidate->type); | 81 g_free(candidate->type); |
80 | 82 |
81 g_free(candidate->username); | 83 g_free(candidate->username); |
95 return type; | 97 return type; |
96 } | 98 } |
97 | 99 |
98 JingleIceUdpCandidate * | 100 JingleIceUdpCandidate * |
99 jingle_iceudp_candidate_new(guint component, const gchar *foundation, | 101 jingle_iceudp_candidate_new(guint component, const gchar *foundation, |
100 guint generation, const gchar *ip, guint network, | 102 guint generation, const gchar *id, const gchar *ip, |
101 guint port, guint priority, const gchar *protocol, | 103 guint network, guint port, guint priority, |
102 const gchar *type, const gchar *username, const gchar *password) | 104 const gchar *protocol, const gchar *type, |
105 const gchar *username, const gchar *password) | |
103 { | 106 { |
104 JingleIceUdpCandidate *candidate = g_new0(JingleIceUdpCandidate, 1); | 107 JingleIceUdpCandidate *candidate = g_new0(JingleIceUdpCandidate, 1); |
105 candidate->component = component; | 108 candidate->component = component; |
106 candidate->foundation = g_strdup(foundation); | 109 candidate->foundation = g_strdup(foundation); |
107 candidate->generation = generation; | 110 candidate->generation = generation; |
111 candidate->id = g_strdup(id); | |
108 candidate->ip = g_strdup(ip); | 112 candidate->ip = g_strdup(ip); |
109 candidate->network = network; | 113 candidate->network = network; |
110 candidate->port = port; | 114 candidate->port = port; |
111 candidate->priority = priority; | 115 candidate->priority = priority; |
112 candidate->protocol = g_strdup(protocol); | 116 candidate->protocol = g_strdup(protocol); |
231 { | 235 { |
232 GList *iter = iceudp->priv->local_candidates; | 236 GList *iter = iceudp->priv->local_candidates; |
233 | 237 |
234 for (; iter; iter = g_list_next(iter)) { | 238 for (; iter; iter = g_list_next(iter)) { |
235 JingleIceUdpCandidate *c = iter->data; | 239 JingleIceUdpCandidate *c = iter->data; |
236 if ((c->component == candidate->component) && | 240 if (!strcmp(c->id, candidate->id)) { |
237 !strcmp(c->foundation, candidate->foundation)) { | |
238 guint generation = c->generation + 1; | 241 guint generation = c->generation + 1; |
239 | 242 |
240 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c); | 243 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c); |
241 iceudp->priv->local_candidates = g_list_delete_link( | 244 iceudp->priv->local_candidates = g_list_delete_link( |
242 iceudp->priv->local_candidates, iter); | 245 iceudp->priv->local_candidates, iter); |
259 return g_list_copy(iceudp->priv->remote_candidates); | 262 return g_list_copy(iceudp->priv->remote_candidates); |
260 } | 263 } |
261 | 264 |
262 static JingleIceUdpCandidate * | 265 static JingleIceUdpCandidate * |
263 jingle_iceudp_get_remote_candidate_by_id(JingleIceUdp *iceudp, | 266 jingle_iceudp_get_remote_candidate_by_id(JingleIceUdp *iceudp, |
264 guint component, const gchar *foundation) | 267 const gchar *id) |
265 { | 268 { |
266 GList *iter = iceudp->priv->remote_candidates; | 269 GList *iter = iceudp->priv->remote_candidates; |
267 for (; iter; iter = g_list_next(iter)) { | 270 for (; iter; iter = g_list_next(iter)) { |
268 JingleIceUdpCandidate *candidate = iter->data; | 271 JingleIceUdpCandidate *candidate = iter->data; |
269 if ((candidate->component == component) && | 272 if (!strcmp(candidate->id, id)) { |
270 !strcmp(candidate->foundation, foundation)) { | |
271 return candidate; | 273 return candidate; |
272 } | 274 } |
273 } | 275 } |
274 return NULL; | 276 return NULL; |
275 } | 277 } |
278 jingle_iceudp_add_remote_candidate(JingleIceUdp *iceudp, JingleIceUdpCandidate *candidate) | 280 jingle_iceudp_add_remote_candidate(JingleIceUdp *iceudp, JingleIceUdpCandidate *candidate) |
279 { | 281 { |
280 JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp); | 282 JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp); |
281 JingleIceUdpCandidate *iceudp_candidate = | 283 JingleIceUdpCandidate *iceudp_candidate = |
282 jingle_iceudp_get_remote_candidate_by_id(iceudp, | 284 jingle_iceudp_get_remote_candidate_by_id(iceudp, |
283 candidate->component, candidate->foundation); | 285 candidate->id); |
284 if (iceudp_candidate != NULL) { | 286 if (iceudp_candidate != NULL) { |
285 priv->remote_candidates = g_list_remove( | 287 priv->remote_candidates = g_list_remove( |
286 priv->remote_candidates, iceudp_candidate); | 288 priv->remote_candidates, iceudp_candidate); |
287 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, iceudp_candidate); | 289 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, iceudp_candidate); |
288 } | 290 } |
302 for (; candidate; candidate = xmlnode_get_next_twin(candidate)) { | 304 for (; candidate; candidate = xmlnode_get_next_twin(candidate)) { |
303 iceudp_candidate = jingle_iceudp_candidate_new( | 305 iceudp_candidate = jingle_iceudp_candidate_new( |
304 atoi(xmlnode_get_attrib(candidate, "component")), | 306 atoi(xmlnode_get_attrib(candidate, "component")), |
305 xmlnode_get_attrib(candidate, "foundation"), | 307 xmlnode_get_attrib(candidate, "foundation"), |
306 atoi(xmlnode_get_attrib(candidate, "generation")), | 308 atoi(xmlnode_get_attrib(candidate, "generation")), |
309 xmlnode_get_attrib(candidate, "id"), | |
307 xmlnode_get_attrib(candidate, "ip"), | 310 xmlnode_get_attrib(candidate, "ip"), |
308 atoi(xmlnode_get_attrib(candidate, "network")), | 311 atoi(xmlnode_get_attrib(candidate, "network")), |
309 atoi(xmlnode_get_attrib(candidate, "port")), | 312 atoi(xmlnode_get_attrib(candidate, "port")), |
310 atoi(xmlnode_get_attrib(candidate, "priority")), | 313 atoi(xmlnode_get_attrib(candidate, "priority")), |
311 xmlnode_get_attrib(candidate, "protocol"), | 314 xmlnode_get_attrib(candidate, "protocol"), |
345 gchar *priority = g_strdup_printf("%d", candidate->priority); | 348 gchar *priority = g_strdup_printf("%d", candidate->priority); |
346 | 349 |
347 xmlnode_set_attrib(xmltransport, "component", component); | 350 xmlnode_set_attrib(xmltransport, "component", component); |
348 xmlnode_set_attrib(xmltransport, "foundation", candidate->foundation); | 351 xmlnode_set_attrib(xmltransport, "foundation", candidate->foundation); |
349 xmlnode_set_attrib(xmltransport, "generation", generation); | 352 xmlnode_set_attrib(xmltransport, "generation", generation); |
353 xmlnode_set_attrib(xmltransport, "id", candidate->id); | |
350 xmlnode_set_attrib(xmltransport, "ip", candidate->ip); | 354 xmlnode_set_attrib(xmltransport, "ip", candidate->ip); |
351 xmlnode_set_attrib(xmltransport, "network", network); | 355 xmlnode_set_attrib(xmltransport, "network", network); |
352 xmlnode_set_attrib(xmltransport, "port", port); | 356 xmlnode_set_attrib(xmltransport, "port", port); |
353 xmlnode_set_attrib(xmltransport, "priority", priority); | 357 xmlnode_set_attrib(xmltransport, "priority", priority); |
354 xmlnode_set_attrib(xmltransport, "protocol", candidate->protocol); | 358 xmlnode_set_attrib(xmltransport, "protocol", candidate->protocol); |