libpurple/protocols/jabber/jingle/iceudp.c

Sat, 20 Jul 2019 13:09:31 +0200

author
Fabrice Bellet <fabrice@bellet.info>
date
Sat, 20 Jul 2019 13:09:31 +0200
branch
release-2.x.y
changeset 39731
ea0961a2cf96
parent 39724
72a35ff95941
child 39732
e4ad09f72edf
permissions
-rw-r--r--

Fixes from pull request #516 review

26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
1 /**
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
2 * @file iceudp.c
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
3 *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
4 * purple
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
5 *
28322
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 26980
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 26980
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 26980
diff changeset
8 * source distribution.
ac8fec1d2234 Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents: 26980
diff changeset
9 *
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
14 *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
19 *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
23 */
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
24
26221
bc5d5d3fe4de Make it compile in Windows with the equivalent of --disable-vv.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
25 #include "internal.h"
bc5d5d3fe4de Make it compile in Windows with the equivalent of --disable-vv.
Michael Ruprecht <maiku@pidgin.im>
parents: 26166
diff changeset
26
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
27 #include "iceudp.h"
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
28 #include "jingle.h"
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
29 #include "debug.h"
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
30
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
31 #include <string.h>
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
32
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
33 struct _JingleIceUdpPrivate
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
34 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
35 GList *local_candidates;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
36 GList *remote_candidates;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
37 };
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
38
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
39 #define JINGLE_ICEUDP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_ICEUDP, JingleIceUdpPrivate))
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
40
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
41 static void jingle_iceudp_class_init (JingleIceUdpClass *klass);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
42 static void jingle_iceudp_init (JingleIceUdp *iceudp);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
43 static void jingle_iceudp_finalize (GObject *object);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
44 static void jingle_iceudp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
45 static void jingle_iceudp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
46 static JingleTransport *jingle_iceudp_parse_internal(xmlnode *iceudp);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
47 static xmlnode *jingle_iceudp_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
48
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
49 static JingleTransportClass *parent_class = NULL;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
50
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
51 enum {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
52 PROP_0,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
53 PROP_LOCAL_CANDIDATES,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
54 PROP_REMOTE_CANDIDATES,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
55 };
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
56
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
57 static JingleIceUdpCandidate *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
58 jingle_iceudp_candidate_copy(JingleIceUdpCandidate *candidate)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
59 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
60 JingleIceUdpCandidate *new_candidate = g_new0(JingleIceUdpCandidate, 1);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
61 new_candidate->component = candidate->component;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
62 new_candidate->foundation = g_strdup(candidate->foundation);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
63 new_candidate->generation = candidate->generation;
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
64 new_candidate->id = g_strdup(candidate->id);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
65 new_candidate->ip = g_strdup(candidate->ip);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
66 new_candidate->network = candidate->network;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
67 new_candidate->port = candidate->port;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
68 new_candidate->priority = candidate->priority;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
69 new_candidate->protocol = g_strdup(candidate->protocol);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
70 new_candidate->type = g_strdup(candidate->type);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
71
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
72 new_candidate->username = g_strdup(candidate->username);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
73 new_candidate->password = g_strdup(candidate->password);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
74
26414
848982f329c5 Don't forget to copy the rem_know attribute of IceUdp candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26413
diff changeset
75 new_candidate->rem_known = candidate->rem_known;
848982f329c5 Don't forget to copy the rem_know attribute of IceUdp candidates.
Michael Ruprecht <maiku@pidgin.im>
parents: 26413
diff changeset
76
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
77 return new_candidate;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
78 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
79
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
80 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
81 jingle_iceudp_candidate_free(JingleIceUdpCandidate *candidate)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
82 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
83 g_free(candidate->foundation);
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
84 g_free(candidate->id);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
85 g_free(candidate->ip);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
86 g_free(candidate->protocol);
26325
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
87 g_free(candidate->reladdr);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
88 g_free(candidate->type);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
89
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
90 g_free(candidate->username);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
91 g_free(candidate->password);
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
92 g_free(candidate);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
93 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
94
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
95 GType
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
96 jingle_iceudp_candidate_get_type()
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
97 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
98 static GType type = 0;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
99
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
100 if (type == 0) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
101 type = g_boxed_type_register_static("JingleIceUdpCandidate",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
102 (GBoxedCopyFunc)jingle_iceudp_candidate_copy,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
103 (GBoxedFreeFunc)jingle_iceudp_candidate_free);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
104 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
105 return type;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
106 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
107
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
108 JingleIceUdpCandidate *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
109 jingle_iceudp_candidate_new(guint component, const gchar *foundation,
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
110 guint generation, const gchar *id, const gchar *ip,
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
111 guint network, guint port, guint priority,
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
112 const gchar *protocol, const gchar *type,
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
113 const gchar *username, const gchar *password)
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
114 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
115 JingleIceUdpCandidate *candidate = g_new0(JingleIceUdpCandidate, 1);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
116 candidate->component = component;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
117 candidate->foundation = g_strdup(foundation);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
118 candidate->generation = generation;
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
119 candidate->id = g_strdup(id);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
120 candidate->ip = g_strdup(ip);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
121 candidate->network = network;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
122 candidate->port = port;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
123 candidate->priority = priority;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
124 candidate->protocol = g_strdup(protocol);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
125 candidate->type = g_strdup(type);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
126
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
127 candidate->username = g_strdup(username);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
128 candidate->password = g_strdup(password);
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
129
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
130 candidate->rem_known = FALSE;
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
131 return candidate;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
132 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
133
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
134 GType
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
135 jingle_iceudp_get_type()
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
136 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
137 static GType type = 0;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
138
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
139 if (type == 0) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
140 static const GTypeInfo info = {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
141 sizeof(JingleIceUdpClass),
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
142 NULL,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
143 NULL,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
144 (GClassInitFunc) jingle_iceudp_class_init,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
145 NULL,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
146 NULL,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
147 sizeof(JingleIceUdp),
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
148 0,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
149 (GInstanceInitFunc) jingle_iceudp_init,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
150 NULL
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
151 };
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
152 type = g_type_register_static(JINGLE_TYPE_TRANSPORT, "JingleIceUdp", &info, 0);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
153 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
154 return type;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
155 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
156
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
157 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
158 jingle_iceudp_class_init (JingleIceUdpClass *klass)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
159 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
160 GObjectClass *gobject_class = (GObjectClass*)klass;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
161 parent_class = g_type_class_peek_parent(klass);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
162
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
163 gobject_class->finalize = jingle_iceudp_finalize;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
164 gobject_class->set_property = jingle_iceudp_set_property;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
165 gobject_class->get_property = jingle_iceudp_get_property;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
166 klass->parent_class.to_xml = jingle_iceudp_to_xml_internal;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
167 klass->parent_class.parse = jingle_iceudp_parse_internal;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
168 klass->parent_class.transport_type = JINGLE_TRANSPORT_ICEUDP;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
169
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
170 g_object_class_install_property(gobject_class, PROP_LOCAL_CANDIDATES,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
171 g_param_spec_pointer("local-candidates",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
172 "Local candidates",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
173 "The local candidates for this transport.",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
174 G_PARAM_READABLE));
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
175
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
176 g_object_class_install_property(gobject_class, PROP_REMOTE_CANDIDATES,
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
177 g_param_spec_pointer("remote-candidates",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
178 "Remote candidates",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
179 "The remote candidates for this transport.",
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
180 G_PARAM_READABLE));
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
181
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
182 g_type_class_add_private(klass, sizeof(JingleIceUdpPrivate));
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
183 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
184
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
185 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
186 jingle_iceudp_init (JingleIceUdp *iceudp)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
187 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
188 iceudp->priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp);
26411
6b7c565cfa9a Fix a bunch of memsets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
189 iceudp->priv->local_candidates = NULL;
6b7c565cfa9a Fix a bunch of memsets.
Michael Ruprecht <maiku@pidgin.im>
parents: 26410
diff changeset
190 iceudp->priv->remote_candidates = NULL;
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
191 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
192
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
193 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
194 jingle_iceudp_finalize (GObject *iceudp)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
195 {
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
196 JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp);
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
197 GList *iter;
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
198
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
199 purple_debug_info("jingle","jingle_iceudp_finalize\n");
26410
5952dcb9ce6c Plug some memory leaks related to transports.
Michael Ruprecht <maiku@pidgin.im>
parents: 26407
diff changeset
200
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
201 iter = priv->local_candidates;
39731
ea0961a2cf96 Fixes from pull request #516 review
Fabrice Bellet <fabrice@bellet.info>
parents: 39724
diff changeset
202 while (iter) {
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
203 JingleIceUdpCandidate *c = iter->data;
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
204 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c);
39731
ea0961a2cf96 Fixes from pull request #516 review
Fabrice Bellet <fabrice@bellet.info>
parents: 39724
diff changeset
205 iter = g_list_delete_link(iter, iter);
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
206 }
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
207 iter = priv->remote_candidates;
39731
ea0961a2cf96 Fixes from pull request #516 review
Fabrice Bellet <fabrice@bellet.info>
parents: 39724
diff changeset
208 while (iter) {
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
209 JingleIceUdpCandidate *c = iter->data;
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
210 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c);
39731
ea0961a2cf96 Fixes from pull request #516 review
Fabrice Bellet <fabrice@bellet.info>
parents: 39724
diff changeset
211 iter = g_list_delete_link(iter, iter);
39724
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
212 }
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
213
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
214 priv->local_candidates = NULL;
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
215 priv->remote_candidates = NULL;
72a35ff95941 Fix more memory leaks
Fabrice Bellet <fabrice@bellet.info>
parents: 38259
diff changeset
216
26410
5952dcb9ce6c Plug some memory leaks related to transports.
Michael Ruprecht <maiku@pidgin.im>
parents: 26407
diff changeset
217 G_OBJECT_CLASS(parent_class)->finalize(iceudp);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
218 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
219
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
220 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
221 jingle_iceudp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
222 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
223 JingleIceUdp *iceudp;
32053
e11a51dcd2d8 jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <darkrain42@pidgin.im>
parents: 31294
diff changeset
224
e11a51dcd2d8 jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <darkrain42@pidgin.im>
parents: 31294
diff changeset
225 g_return_if_fail(object != NULL);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
226 g_return_if_fail(JINGLE_IS_ICEUDP(object));
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
227
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
228 iceudp = JINGLE_ICEUDP(object);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
229
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
230 switch (prop_id) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
231 case PROP_LOCAL_CANDIDATES:
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
232 iceudp->priv->local_candidates =
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
233 g_value_get_pointer(value);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
234 break;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
235 case PROP_REMOTE_CANDIDATES:
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
236 iceudp->priv->remote_candidates =
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
237 g_value_get_pointer(value);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
238 break;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 28322
diff changeset
239 default:
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
240 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
241 break;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
242 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
243 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
244
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
245 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
246 jingle_iceudp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
247 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
248 JingleIceUdp *iceudp;
32053
e11a51dcd2d8 jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <darkrain42@pidgin.im>
parents: 31294
diff changeset
249
e11a51dcd2d8 jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <darkrain42@pidgin.im>
parents: 31294
diff changeset
250 g_return_if_fail(object != NULL);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
251 g_return_if_fail(JINGLE_IS_ICEUDP(object));
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 28322
diff changeset
252
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
253 iceudp = JINGLE_ICEUDP(object);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
254
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
255 switch (prop_id) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
256 case PROP_LOCAL_CANDIDATES:
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
257 g_value_set_pointer(value, iceudp->priv->local_candidates);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
258 break;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
259 case PROP_REMOTE_CANDIDATES:
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
260 g_value_set_pointer(value, iceudp->priv->remote_candidates);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
261 break;
31294
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 28322
diff changeset
262 default:
73607ab89c6f Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents: 28322
diff changeset
263 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
264 break;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
265 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
266 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
267
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
268 void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
269 jingle_iceudp_add_local_candidate(JingleIceUdp *iceudp, JingleIceUdpCandidate *candidate)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
270 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
271 GList *iter = iceudp->priv->local_candidates;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
272
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
273 for (; iter; iter = g_list_next(iter)) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
274 JingleIceUdpCandidate *c = iter->data;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 32053
diff changeset
275 if (purple_strequal(c->id, candidate->id)) {
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
276 guint generation = c->generation + 1;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
277
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
278 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, c);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
279 iceudp->priv->local_candidates = g_list_delete_link(
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
280 iceudp->priv->local_candidates, iter);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
281
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
282 candidate->generation = generation;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
283
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
284 iceudp->priv->local_candidates = g_list_append(
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
285 iceudp->priv->local_candidates, candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
286 return;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
287 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
288 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
289
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
290 iceudp->priv->local_candidates = g_list_append(
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
291 iceudp->priv->local_candidates, candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
292 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
293
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
294 GList *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
295 jingle_iceudp_get_remote_candidates(JingleIceUdp *iceudp)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
296 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
297 return g_list_copy(iceudp->priv->remote_candidates);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
298 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
299
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
300 static JingleIceUdpCandidate *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
301 jingle_iceudp_get_remote_candidate_by_id(JingleIceUdp *iceudp,
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
302 const gchar *id)
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
303 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
304 GList *iter = iceudp->priv->remote_candidates;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
305 for (; iter; iter = g_list_next(iter)) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
306 JingleIceUdpCandidate *candidate = iter->data;
38258
9a6551eba09c Replace !strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 32053
diff changeset
307 if (purple_strequal(candidate->id, id)) {
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
308 return candidate;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
309 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
310 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
311 return NULL;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
312 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
313
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
314 static void
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
315 jingle_iceudp_add_remote_candidate(JingleIceUdp *iceudp, JingleIceUdpCandidate *candidate)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
316 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
317 JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(iceudp);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
318 JingleIceUdpCandidate *iceudp_candidate =
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
319 jingle_iceudp_get_remote_candidate_by_id(iceudp,
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
320 candidate->id);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
321 if (iceudp_candidate != NULL) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
322 priv->remote_candidates = g_list_remove(
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
323 priv->remote_candidates, iceudp_candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
324 g_boxed_free(JINGLE_TYPE_ICEUDP_CANDIDATE, iceudp_candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
325 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
326 priv->remote_candidates = g_list_append(priv->remote_candidates, candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
327 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
328
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
329 static JingleTransport *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
330 jingle_iceudp_parse_internal(xmlnode *iceudp)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
331 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
332 JingleTransport *transport = parent_class->parse(iceudp);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
333 xmlnode *candidate = xmlnode_get_child(iceudp, "candidate");
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
334 JingleIceUdpCandidate *iceudp_candidate = NULL;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
335
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
336 const gchar *username = xmlnode_get_attrib(iceudp, "ufrag");
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
337 const gchar *password = xmlnode_get_attrib(iceudp, "pwd");
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
338
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
339 for (; candidate; candidate = xmlnode_get_next_twin(candidate)) {
26980
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
340 const gchar *relport = xmlnode_get_attrib(candidate, "rel-port");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
341 const gchar *component = xmlnode_get_attrib(candidate, "component");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
342 const gchar *foundation = xmlnode_get_attrib(candidate, "foundation");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
343 const gchar *generation = xmlnode_get_attrib(candidate, "generation");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
344 const gchar *id = xmlnode_get_attrib(candidate, "id");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
345 const gchar *ip = xmlnode_get_attrib(candidate, "ip");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
346 const gchar *network = xmlnode_get_attrib(candidate, "network");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
347 const gchar *port = xmlnode_get_attrib(candidate, "port");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
348 const gchar *priority = xmlnode_get_attrib(candidate, "priority");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
349 const gchar *protocol = xmlnode_get_attrib(candidate, "protocol");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
350 const gchar *type = xmlnode_get_attrib(candidate, "type");
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
351
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
352 if (!component || !foundation || !generation || !id || !ip ||
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
353 !network || !port || !priority || !protocol || !type)
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
354 continue;
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
355
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
356 iceudp_candidate = jingle_iceudp_candidate_new(
26980
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
357 atoi(component),
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
358 foundation,
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
359 atoi(generation),
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
360 id,
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
361 ip,
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
362 atoi(network),
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
363 atoi(port),
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
364 atoi(priority),
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
365 protocol,
42d365c0076f Don't crash on malicious candidates missing attributes
Paul Aurich <darkrain42@pidgin.im>
parents: 26414
diff changeset
366 type,
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
367 username, password);
26325
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
368 iceudp_candidate->reladdr = g_strdup(
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
369 xmlnode_get_attrib(candidate, "rel-addr"));
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
370 iceudp_candidate->relport =
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
371 relport != NULL ? atoi(relport) : 0;
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
372 iceudp_candidate->rem_known = TRUE;
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
373 jingle_iceudp_add_remote_candidate(JINGLE_ICEUDP(transport), iceudp_candidate);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
374 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
375
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
376 return transport;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
377 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
378
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
379 static xmlnode *
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
380 jingle_iceudp_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action)
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
381 {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
382 xmlnode *node = parent_class->to_xml(transport, content, action);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
383
26407
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
384 if (action == JINGLE_SESSION_INITIATE ||
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
385 action == JINGLE_SESSION_ACCEPT ||
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
386 action == JINGLE_TRANSPORT_INFO ||
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
387 action == JINGLE_CONTENT_ADD ||
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
388 action == JINGLE_TRANSPORT_REPLACE) {
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
389 JingleIceUdpPrivate *priv = JINGLE_ICEUDP_GET_PRIVATE(transport);
48782a6424e0 Update Jingle Ice-Udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26334
diff changeset
390 GList *iter = priv->local_candidates;
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
391 gboolean used_candidate = FALSE;
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
392
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
393 for (; iter; iter = g_list_next(iter)) {
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
394 JingleIceUdpCandidate *candidate = iter->data;
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
395 xmlnode *xmltransport;
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
396 gchar *component, *generation, *network,
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
397 *port, *priority;
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
398
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
399 if (candidate->rem_known == TRUE)
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
400 continue;
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
401
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
402 used_candidate = TRUE;
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
403 candidate->rem_known = TRUE;
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
404
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
405 xmltransport = xmlnode_new_child(node, "candidate");
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
406 component = g_strdup_printf("%d", candidate->component);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
407 generation = g_strdup_printf("%d",
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
408 candidate->generation);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
409 network = g_strdup_printf("%d", candidate->network);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
410 port = g_strdup_printf("%d", candidate->port);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
411 priority = g_strdup_printf("%d", candidate->priority);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
412
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
413 xmlnode_set_attrib(xmltransport, "component", component);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
414 xmlnode_set_attrib(xmltransport, "foundation", candidate->foundation);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
415 xmlnode_set_attrib(xmltransport, "generation", generation);
26302
0fb3ad9495a5 Add the id attribute to ice-udp according to the XEP.
Michael Ruprecht <maiku@pidgin.im>
parents: 26221
diff changeset
416 xmlnode_set_attrib(xmltransport, "id", candidate->id);
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
417 xmlnode_set_attrib(xmltransport, "ip", candidate->ip);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
418 xmlnode_set_attrib(xmltransport, "network", network);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
419 xmlnode_set_attrib(xmltransport, "port", port);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
420 xmlnode_set_attrib(xmltransport, "priority", priority);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
421 xmlnode_set_attrib(xmltransport, "protocol", candidate->protocol);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
422
26325
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
423 if (candidate->reladdr != NULL &&
38259
c593fc9f5438 Replace strcmp() with purple_strequal()
qarkai <qarkai@gmail.com>
parents: 38258
diff changeset
424 (!purple_strequal(candidate->ip, candidate->reladdr) ||
26325
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
425 (candidate->port != candidate->relport))) {
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
426 gchar *relport = g_strdup_printf("%d",
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
427 candidate->relport);
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
428 xmlnode_set_attrib(xmltransport, "rel-addr",
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
429 candidate->reladdr);
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
430 xmlnode_set_attrib(xmltransport, "rel-port",
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
431 relport);
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
432 g_free(relport);
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
433 }
5427d1073629 Use the correct values for Jingle Ice-Udp's rel-addr and rel-port.
Michael Ruprecht <maiku@pidgin.im>
parents: 26302
diff changeset
434
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
435 xmlnode_set_attrib(xmltransport, "type", candidate->type);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
436
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
437 g_free(component);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
438 g_free(generation);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
439 g_free(network);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
440 g_free(port);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
441 g_free(priority);
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
442 }
26413
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
443
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
444 if (used_candidate == TRUE) {
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
445 JingleIceUdpCandidate *candidate =
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
446 priv->local_candidates->data;
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
447 xmlnode_set_attrib(node, "pwd", candidate->password);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
448 xmlnode_set_attrib(node, "ufrag", candidate->username);
ffcca54b2b47 Make IceUdp candidates know whether the remote side knows about them.
Michael Ruprecht <maiku@pidgin.im>
parents: 26411
diff changeset
449 }
26166
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
450 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
451
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
452 return node;
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
453 }
ad7d09fef256 Added a Jingle ice-udp transmitter.
Michael Ruprecht <maiku@pidgin.im>
parents:
diff changeset
454

mercurial