annotate libpurple/protocols/jabber/jingle/rawudp.c @ 32819:2c6510167895 default tip

propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24) to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 02 Jun 2012 02:30:49 +0000
parents c9da7f5fbd0e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
1 /**
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
2 * @file rawudp.c
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
3 *
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
4 * purple
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
5 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26756
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26756
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26756
diff changeset
8 * source distribution.
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26756
diff changeset
9 *
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
14 *
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
19 *
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
23 */
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
24
26010
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24957
diff changeset
25 #include "internal.h"
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24957
diff changeset
26
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
27 #include "rawudp.h"
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
28 #include "jingle.h"
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
29 #include "debug.h"
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
30
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
31 #include <string.h>
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
32
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
33 struct _JingleRawUdpPrivate
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
34 {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
35 GList *local_candidates;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
36 GList *remote_candidates;
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
37 };
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
38
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
39 #define JINGLE_RAWUDP_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_RAWUDP, JingleRawUdpPrivate))
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
40
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
41 static void jingle_rawudp_class_init (JingleRawUdpClass *klass);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
42 static void jingle_rawudp_init (JingleRawUdp *rawudp);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
43 static void jingle_rawudp_finalize (GObject *object);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
44 static void jingle_rawudp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
45 static void jingle_rawudp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
46 static JingleTransport *jingle_rawudp_parse_internal(xmlnode *rawudp);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
47 static xmlnode *jingle_rawudp_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
48
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
49 static JingleTransportClass *parent_class = NULL;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
50
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
51 enum {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
52 PROP_0,
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
53 PROP_LOCAL_CANDIDATES,
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
54 PROP_REMOTE_CANDIDATES,
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
55 };
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
56
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
57 static JingleRawUdpCandidate *
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
58 jingle_rawudp_candidate_copy(JingleRawUdpCandidate *candidate)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
59 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
60 JingleRawUdpCandidate *new_candidate = g_new0(JingleRawUdpCandidate, 1);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
61 new_candidate->generation = candidate->generation;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
62 new_candidate->component = candidate->component;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
63 new_candidate->id = g_strdup(candidate->id);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
64 new_candidate->ip = g_strdup(candidate->ip);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
65 new_candidate->port = candidate->port;
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
66
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
67 new_candidate->rem_known = candidate->rem_known;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
68 return new_candidate;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
69 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
70
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
71 static void
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
72 jingle_rawudp_candidate_free(JingleRawUdpCandidate *candidate)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
73 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
74 g_free(candidate->id);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
75 g_free(candidate->ip);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
76 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
77
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
78 GType
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
79 jingle_rawudp_candidate_get_type()
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
80 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
81 static GType type = 0;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
82
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
83 if (type == 0) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
84 type = g_boxed_type_register_static("JingleRawUdpCandidate",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
85 (GBoxedCopyFunc)jingle_rawudp_candidate_copy,
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
86 (GBoxedFreeFunc)jingle_rawudp_candidate_free);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
87 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
88 return type;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
89 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
90
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
91 JingleRawUdpCandidate *
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
92 jingle_rawudp_candidate_new(const gchar *id, guint generation, guint component, const gchar *ip, guint port)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
93 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
94 JingleRawUdpCandidate *candidate = g_new0(JingleRawUdpCandidate, 1);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
95 candidate->generation = generation;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
96 candidate->component = component;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
97 candidate->id = g_strdup(id);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
98 candidate->ip = g_strdup(ip);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
99 candidate->port = port;
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
100
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
101 candidate->rem_known = FALSE;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
102 return candidate;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
103 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
104
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
105 GType
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
106 jingle_rawudp_get_type()
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
107 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
108 static GType type = 0;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
109
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
110 if (type == 0) {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
111 static const GTypeInfo info = {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
112 sizeof(JingleRawUdpClass),
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
113 NULL,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
114 NULL,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
115 (GClassInitFunc) jingle_rawudp_class_init,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
116 NULL,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
117 NULL,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
118 sizeof(JingleRawUdp),
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
119 0,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
120 (GInstanceInitFunc) jingle_rawudp_init,
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
121 NULL
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
122 };
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
123 type = g_type_register_static(JINGLE_TYPE_TRANSPORT, "JingleRawUdp", &info, 0);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
124 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
125 return type;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
126 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
127
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
128 static void
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
129 jingle_rawudp_class_init (JingleRawUdpClass *klass)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
130 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
131 GObjectClass *gobject_class = (GObjectClass*)klass;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
132 parent_class = g_type_class_peek_parent(klass);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
133
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
134 gobject_class->finalize = jingle_rawudp_finalize;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
135 gobject_class->set_property = jingle_rawudp_set_property;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
136 gobject_class->get_property = jingle_rawudp_get_property;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
137 klass->parent_class.to_xml = jingle_rawudp_to_xml_internal;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
138 klass->parent_class.parse = jingle_rawudp_parse_internal;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
139 klass->parent_class.transport_type = JINGLE_TRANSPORT_RAWUDP;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
140
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
141 g_object_class_install_property(gobject_class, PROP_LOCAL_CANDIDATES,
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
142 g_param_spec_pointer("local-candidates",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
143 "Local candidates",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
144 "The local candidates for this transport.",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
145 G_PARAM_READABLE));
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
146
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
147 g_object_class_install_property(gobject_class, PROP_REMOTE_CANDIDATES,
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
148 g_param_spec_pointer("remote-candidates",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
149 "Remote candidates",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
150 "The remote candidates for this transport.",
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
151 G_PARAM_READABLE));
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
152
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
153 g_type_class_add_private(klass, sizeof(JingleRawUdpPrivate));
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
154 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
155
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
156 static void
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
157 jingle_rawudp_init (JingleRawUdp *rawudp)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
158 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
159 rawudp->priv = JINGLE_RAWUDP_GET_PRIVATE(rawudp);
26291
30cc73d99789 Fix a bunch of memsets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26290
diff changeset
160 rawudp->priv->local_candidates = NULL;
30cc73d99789 Fix a bunch of memsets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26290
diff changeset
161 rawudp->priv->remote_candidates = NULL;
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
162 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
163
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
164 static void
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
165 jingle_rawudp_finalize (GObject *rawudp)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
166 {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
167 /* JingleRawUdpPrivate *priv = JINGLE_RAWUDP_GET_PRIVATE(rawudp); */
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
168 purple_debug_info("jingle","jingle_rawudp_finalize\n");
26290
44684f0d2e42 Plug some memory leaks related to transports.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26288
diff changeset
169
44684f0d2e42 Plug some memory leaks related to transports.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26288
diff changeset
170 G_OBJECT_CLASS(parent_class)->finalize(rawudp);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
171 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
172
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
173 static void
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
174 jingle_rawudp_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
175 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
176 JingleRawUdp *rawudp;
32323
c9da7f5fbd0e jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
177
c9da7f5fbd0e jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
178 g_return_if_fail(object != NULL);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
179 g_return_if_fail(JINGLE_IS_RAWUDP(object));
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
180
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
181 rawudp = JINGLE_RAWUDP(object);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
182
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
183 switch (prop_id) {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
184 case PROP_LOCAL_CANDIDATES:
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
185 rawudp->priv->local_candidates =
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
186 g_value_get_pointer(value);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
187 break;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
188 case PROP_REMOTE_CANDIDATES:
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
189 rawudp->priv->remote_candidates =
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
190 g_value_get_pointer(value);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
191 break;
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 28048
diff changeset
192 default:
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
193 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
194 break;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
195 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
196 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
197
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
198 static void
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
199 jingle_rawudp_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
200 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
201 JingleRawUdp *rawudp;
32323
c9da7f5fbd0e jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
202
c9da7f5fbd0e jabber: Add a few extra g_return_if_fails to the Jingle code
Paul Aurich <paul@darkrain42.org>
parents: 31086
diff changeset
203 g_return_if_fail(object != NULL);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
204 g_return_if_fail(JINGLE_IS_RAWUDP(object));
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 28048
diff changeset
205
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
206 rawudp = JINGLE_RAWUDP(object);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
207
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
208 switch (prop_id) {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
209 case PROP_LOCAL_CANDIDATES:
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
210 g_value_set_pointer(value, rawudp->priv->local_candidates);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
211 break;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
212 case PROP_REMOTE_CANDIDATES:
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
213 g_value_set_pointer(value, rawudp->priv->remote_candidates);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
214 break;
31086
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 28048
diff changeset
215 default:
a8cc50c2279f Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents: 28048
diff changeset
216 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
217 break;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
218 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
219 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
220
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
221 void
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
222 jingle_rawudp_add_local_candidate(JingleRawUdp *rawudp, JingleRawUdpCandidate *candidate)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
223 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
224 GList *iter = rawudp->priv->local_candidates;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
225
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
226 for (; iter; iter = g_list_next(iter)) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
227 JingleRawUdpCandidate *c = iter->data;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
228 if (!strcmp(c->id, candidate->id)) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
229 guint generation = c->generation + 1;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
230
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
231 g_boxed_free(JINGLE_TYPE_RAWUDP_CANDIDATE, c);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
232 rawudp->priv->local_candidates = g_list_delete_link(
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
233 rawudp->priv->local_candidates, iter);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
234
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
235 candidate->generation = generation;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
236
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
237 rawudp->priv->local_candidates = g_list_append(
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
238 rawudp->priv->local_candidates, candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
239 return;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
240 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
241 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
242
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
243 rawudp->priv->local_candidates = g_list_append(
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
244 rawudp->priv->local_candidates, candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
245 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
246
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
247 GList *
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
248 jingle_rawudp_get_remote_candidates(JingleRawUdp *rawudp)
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
249 {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
250 return g_list_copy(rawudp->priv->remote_candidates);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
251 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
252
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
253 static JingleRawUdpCandidate *
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
254 jingle_rawudp_get_remote_candidate_by_id(JingleRawUdp *rawudp, gchar *id)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
255 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
256 GList *iter = rawudp->priv->remote_candidates;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
257 for (; iter; iter = g_list_next(iter)) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
258 JingleRawUdpCandidate *candidate = iter->data;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
259 if (!strcmp(candidate->id, id)) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
260 return candidate;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
261 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
262 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
263 return NULL;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
264 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
265
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
266 static void
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
267 jingle_rawudp_add_remote_candidate(JingleRawUdp *rawudp, JingleRawUdpCandidate *candidate)
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
268 {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
269 JingleRawUdpPrivate *priv = JINGLE_RAWUDP_GET_PRIVATE(rawudp);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
270 JingleRawUdpCandidate *rawudp_candidate =
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
271 jingle_rawudp_get_remote_candidate_by_id(rawudp, candidate->id);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
272 if (rawudp_candidate != NULL) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
273 priv->remote_candidates = g_list_remove(
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
274 priv->remote_candidates, rawudp_candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
275 g_boxed_free(JINGLE_TYPE_RAWUDP_CANDIDATE, rawudp_candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
276 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
277 priv->remote_candidates = g_list_append(priv->remote_candidates, candidate);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
278 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
279
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
280 static JingleTransport *
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
281 jingle_rawudp_parse_internal(xmlnode *rawudp)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
282 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
283 JingleTransport *transport = parent_class->parse(rawudp);
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
284 JingleRawUdpPrivate *priv = JINGLE_RAWUDP_GET_PRIVATE(transport);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
285 xmlnode *candidate = xmlnode_get_child(rawudp, "candidate");
24957
835a7003eed3 Silence warning.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24954
diff changeset
286 JingleRawUdpCandidate *rawudp_candidate = NULL;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
287
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
288 for (; candidate; candidate = xmlnode_get_next_twin(candidate)) {
26756
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
289 const gchar *id = xmlnode_get_attrib(candidate, "id");
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
290 const gchar *generation = xmlnode_get_attrib(candidate, "generation");
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
291 const gchar *component = xmlnode_get_attrib(candidate, "component");
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
292 const gchar *ip = xmlnode_get_attrib(candidate, "ip");
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
293 const gchar *port = xmlnode_get_attrib(candidate, "port");
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
294
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
295 if (!id || !generation || !component || !ip || !port)
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
296 continue;
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
297
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
298 rawudp_candidate = jingle_rawudp_candidate_new(
26756
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
299 id,
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
300 atoi(generation),
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
301 atoi(component),
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
302 ip,
cfde0f7fd54f Don't crash on malicious candidates missing attributes
Paul Aurich <paul@darkrain42.org>
parents: 26295
diff changeset
303 atoi(port));
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
304 rawudp_candidate->rem_known = TRUE;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
305 jingle_rawudp_add_remote_candidate(JINGLE_RAWUDP(transport), rawudp_candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
306 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
307
24957
835a7003eed3 Silence warning.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24954
diff changeset
308 if (rawudp_candidate != NULL &&
835a7003eed3 Silence warning.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24954
diff changeset
309 g_list_length(priv->remote_candidates) == 1) {
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
310 /* manufacture rtcp candidate */
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
311 rawudp_candidate = g_boxed_copy(JINGLE_TYPE_RAWUDP_CANDIDATE, rawudp_candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
312 rawudp_candidate->component = 2;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
313 rawudp_candidate->port = rawudp_candidate->port + 1;
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
314 rawudp_candidate->rem_known = TRUE;
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
315 jingle_rawudp_add_remote_candidate(JINGLE_RAWUDP(transport), rawudp_candidate);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
316 }
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
317
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
318 return transport;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
319 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
320
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
321 static xmlnode *
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
322 jingle_rawudp_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action)
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
323 {
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
324 xmlnode *node = parent_class->to_xml(transport, content, action);
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
325
26288
c8d8624efd04 Make Jingle Raw-Udp send candidates in session-accept packet.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26010
diff changeset
326 if (action == JINGLE_SESSION_INITIATE ||
c8d8624efd04 Make Jingle Raw-Udp send candidates in session-accept packet.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26010
diff changeset
327 action == JINGLE_TRANSPORT_INFO ||
c8d8624efd04 Make Jingle Raw-Udp send candidates in session-accept packet.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26010
diff changeset
328 action == JINGLE_SESSION_ACCEPT) {
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
329 JingleRawUdpPrivate *priv = JINGLE_RAWUDP_GET_PRIVATE(transport);
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
330 GList *iter = priv->local_candidates;
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
331
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
332 for (; iter; iter = g_list_next(iter)) {
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
333 JingleRawUdpCandidate *candidate = iter->data;
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
334 xmlnode *xmltransport;
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
335 gchar *generation, *component, *port;
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
336
26295
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
337 if (candidate->rem_known == TRUE)
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
338 continue;
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
339 candidate->rem_known = TRUE;
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
340
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
341 xmltransport = xmlnode_new_child(node, "candidate");
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
342 generation = g_strdup_printf("%d", candidate->generation);
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
343 component = g_strdup_printf("%d", candidate->component);
5631378c68c8 Make RawUdp candidates know if they have been sent to the remote client.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26291
diff changeset
344 port = g_strdup_printf("%d", candidate->port);
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
345
24954
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
346 xmlnode_set_attrib(xmltransport, "generation", generation);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
347 xmlnode_set_attrib(xmltransport, "component", component);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
348 xmlnode_set_attrib(xmltransport, "id", candidate->id);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
349 xmlnode_set_attrib(xmltransport, "ip", candidate->ip);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
350 xmlnode_set_attrib(xmltransport, "port", port);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
351
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
352 g_free(port);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
353 g_free(generation);
365eb0b68d5f Update Jingle raw-udp to latest spec version.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24947
diff changeset
354 }
24947
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
355 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
356
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
357 return node;
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
358 }
7252e3d0c627 Add files I missed committing before and remove a few unnecessary functions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
359