Mercurial > pidgin
annotate libpurple/protocols/jabber/jingle/jingle.c @ 26432:0adf41b3de79
Add a resource selector when initiating media.
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Sat, 04 Apr 2009 02:26:49 +0000 |
parents | abcc94ace5ea |
children | 3c684403ea10 |
rev | line source |
---|---|
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
1 /* |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
2 * @file jingle.c |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
3 * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
4 * purple - Jabber Protocol Plugin |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
5 * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
9 * (at your option) any later version. |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
10 * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
15 * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
19 * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
20 */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
21 |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
22 #include "internal.h" |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
23 #include "network.h" |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
24 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
25 #include "content.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
26 #include "debug.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
27 #include "jingle.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
28 #include <string.h> |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
29 #include "session.h" |
24966
bee5ab815291
Added a Jingle ice-udp transmitter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24949
diff
changeset
|
30 #include "iceudp.h" |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
31 #include "rawudp.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
32 #include "rtp.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
33 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
34 GType |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
35 jingle_get_type(const gchar *type) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
36 { |
26009
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
37 if (!strcmp(type, JINGLE_TRANSPORT_RAWUDP)) |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
38 return JINGLE_TYPE_RAWUDP; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
39 else if (!strcmp(type, JINGLE_TRANSPORT_ICEUDP)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
40 return JINGLE_TYPE_ICEUDP; |
24966
bee5ab815291
Added a Jingle ice-udp transmitter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24949
diff
changeset
|
41 #if 0 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
42 else if (!strcmp(type, JINGLE_TRANSPORT_SOCKS)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
43 return JINGLE_TYPE_SOCKS; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
44 else if (!strcmp(type, JINGLE_TRANSPORT_IBB)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
45 return JINGLE_TYPE_IBB; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
46 #endif |
26009
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
47 #ifdef USE_VV |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
48 else if (!strcmp(type, JINGLE_APP_RTP)) |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
49 return JINGLE_TYPE_RTP; |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
50 #endif |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
51 #if 0 |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
52 else if (!strcmp(type, JINGLE_APP_FT)) |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
53 return JINGLE_TYPE_FT; |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
54 else if (!strcmp(type, JINGLE_APP_XML)) |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
55 return JINGLE_TYPE_XML; |
59188d904773
Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24966
diff
changeset
|
56 #endif |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
57 else |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
58 return G_TYPE_NONE; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
59 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
60 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
61 static void |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
62 jingle_handle_unknown_type(JingleSession *session, xmlnode *jingle) |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
63 { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
64 /* Send error */ |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
65 } |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
66 |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
67 static void |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
68 jingle_handle_content_accept(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
69 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
70 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
71 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
72 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
73 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
74 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
75 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
76 jingle_session_accept_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
77 /* signal here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
78 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
79 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
80 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
81 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
82 jingle_handle_content_add(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
83 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
84 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
85 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
86 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
87 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
88 JingleContent *pending_content = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
89 jingle_content_parse(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
90 if (pending_content == NULL) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
91 purple_debug_error("jingle", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
92 "Error parsing \"content-add\" content.\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
93 /* XXX: send error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
94 } else { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
95 jingle_session_add_pending_content(session, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
96 pending_content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
97 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
98 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
99 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
100 /* XXX: signal here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
101 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
102 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
103 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
104 jingle_handle_content_modify(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
105 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
106 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
107 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
108 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
109 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
110 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
111 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
112 JingleContent *local_content = jingle_session_find_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
113 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
114 if (content != NULL) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
115 const gchar *senders = xmlnode_get_attrib(content, "senders"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
116 gchar *local_senders = jingle_content_get_senders(local_content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
117 if (strcmp(senders, local_senders)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
118 jingle_content_modify(local_content, senders); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
119 g_free(local_senders); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
120 } else { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
121 purple_debug_error("jingle", "content_modify: unknown content\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
122 /* XXX: send error */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
123 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
124 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
125 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
126 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
127 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
128 jingle_handle_content_reject(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
129 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
130 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
131 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
132 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
133 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
134 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
135 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
136 jingle_session_remove_pending_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
137 /* signal here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
138 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
139 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
140 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
141 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
142 jingle_handle_content_remove(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
143 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
144 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
145 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
146 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
147 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
148 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
149 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
150 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
151 jingle_session_remove_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
152 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
153 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
154 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
155 static void |
26087
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
156 jingle_handle_description_info(JingleSession *session, xmlnode *jingle) |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
157 { |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
158 xmlnode *content = xmlnode_get_child(jingle, "content"); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
159 |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
160 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
161 |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
162 jingle_session_accept_session(session); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
163 |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
164 for (; content; content = xmlnode_get_next_twin(content)) { |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
165 const gchar *name = xmlnode_get_attrib(content, "name"); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
166 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
167 JingleContent *parsed_content = |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
168 jingle_session_find_content(session, name, creator); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
169 if (parsed_content == NULL) { |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
170 purple_debug_error("jingle", "Error parsing content\n"); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
171 /* XXX: send error */ |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
172 } else { |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
173 jingle_content_handle_action(parsed_content, content, |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
174 JINGLE_DESCRIPTION_INFO); |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
175 } |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
176 } |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
177 } |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
178 |
0a5737e1e969
Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26080
diff
changeset
|
179 static void |
26283
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
180 jingle_handle_security_info(JingleSession *session, xmlnode *jingle) |
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
181 { |
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
182 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
183 } |
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
184 |
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
185 static void |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
186 jingle_handle_session_accept(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
187 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
188 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
189 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
190 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
191 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
192 jingle_session_accept_session(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
193 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
194 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
195 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
196 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
24949
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
197 JingleContent *parsed_content = |
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
198 jingle_session_find_content(session, name, creator); |
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
199 if (parsed_content == NULL) { |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
200 purple_debug_error("jingle", "Error parsing content\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
201 /* XXX: send error */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
202 } else { |
24949
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
203 jingle_content_handle_action(parsed_content, content, |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
204 JINGLE_SESSION_ACCEPT); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
205 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
206 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
207 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
208 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
209 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
210 jingle_handle_session_info(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
211 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
212 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
213 /* XXX: call signal */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
214 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
215 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
216 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
217 jingle_handle_session_initiate(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
218 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
219 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
220 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
221 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
222 JingleContent *parsed_content = jingle_content_parse(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
223 if (parsed_content == NULL) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
224 purple_debug_error("jingle", "Error parsing content\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
225 /* XXX: send error */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
226 } else { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
227 jingle_session_add_content(session, parsed_content); |
24949
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
228 jingle_content_handle_action(parsed_content, content, |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
229 JINGLE_SESSION_INITIATE); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
230 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
231 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
232 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
233 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
234 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
235 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
236 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
237 jingle_handle_session_terminate(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
238 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
239 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
240 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
241 jingle_session_handle_action(session, jingle, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
242 JINGLE_SESSION_TERMINATE); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
243 /* display reason? */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
244 g_object_unref(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
245 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
246 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
247 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
248 jingle_handle_transport_accept(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
249 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
250 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
251 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
252 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
253 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
254 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
255 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
256 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
257 JingleContent *content = jingle_session_find_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
258 jingle_content_accept_transport(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
259 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
260 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
261 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
262 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
263 jingle_handle_transport_info(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
264 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
265 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
266 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
267 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
268 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
269 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
270 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
271 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
24949
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
272 JingleContent *parsed_content = |
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
273 jingle_session_find_content(session, name, creator); |
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
274 if (parsed_content == NULL) { |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
275 purple_debug_error("jingle", "Error parsing content\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
276 /* XXX: send error */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
277 } else { |
24949
1a2d446cb8a0
Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
278 jingle_content_handle_action(parsed_content, content, |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
279 JINGLE_TRANSPORT_INFO); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
280 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
281 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
282 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
283 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
284 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
285 jingle_handle_transport_reject(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
286 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
287 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
288 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
289 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
290 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
291 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
292 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
293 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
294 JingleContent *content = jingle_session_find_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
295 jingle_content_remove_pending_transport(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
296 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
297 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
298 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
299 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
300 jingle_handle_transport_replace(JingleSession *session, xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
301 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
302 xmlnode *content = xmlnode_get_child(jingle, "content"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
303 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
304 jabber_iq_send(jingle_session_create_ack(session, jingle)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
305 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
306 for (; content; content = xmlnode_get_next_twin(content)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
307 const gchar *name = xmlnode_get_attrib(content, "name"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
308 const gchar *creator = xmlnode_get_attrib(content, "creator"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
309 xmlnode *xmltransport = xmlnode_get_child(content, "transport"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
310 JingleTransport *transport = jingle_transport_parse(xmltransport); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
311 JingleContent *content = jingle_session_find_content(session, name, creator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
312 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
313 jingle_content_set_pending_transport(content, transport); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
314 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
315 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
316 |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
317 typedef struct { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
318 const char *name; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
319 void (*handler)(JingleSession*, xmlnode*); |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
320 } JingleAction; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
321 |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
322 static const JingleAction jingle_actions[] = { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
323 {"unknown-type", jingle_handle_unknown_type}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
324 {"content-accept", jingle_handle_content_accept}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
325 {"content-add", jingle_handle_content_add}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
326 {"content-modify", jingle_handle_content_modify}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
327 {"content-reject", jingle_handle_content_reject}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
328 {"content-remove", jingle_handle_content_remove}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
329 {"description-info", jingle_handle_description_info}, |
26283
abcc94ace5ea
Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26282
diff
changeset
|
330 {"security-info", jingle_handle_security_info}, |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
331 {"session-accept", jingle_handle_session_accept}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
332 {"session-info", jingle_handle_session_info}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
333 {"session-initiate", jingle_handle_session_initiate}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
334 {"session-terminate", jingle_handle_session_terminate}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
335 {"transport-accept", jingle_handle_transport_accept}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
336 {"transport-info", jingle_handle_transport_info}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
337 {"transport-reject", jingle_handle_transport_reject}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
338 {"transport-replace", jingle_handle_transport_replace}, |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
339 }; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
340 |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
341 const gchar * |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
342 jingle_get_action_name(JingleActionType action) |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
343 { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
344 return jingle_actions[action].name; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
345 } |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
346 |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
347 JingleActionType |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
348 jingle_get_action_type(const gchar *action) |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
349 { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
350 static const int num_actions = |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
351 sizeof(jingle_actions)/sizeof(JingleAction); |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
352 /* Start at 1 to skip the unknown-action type */ |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
353 int i = 1; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
354 for (; i < num_actions; ++i) { |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
355 if (!strcmp(action, jingle_actions[i].name)) |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
356 return i; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
357 } |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
358 return JINGLE_UNKNOWN_TYPE; |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
359 } |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
360 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
361 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
362 jingle_parse(JabberStream *js, xmlnode *packet) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
363 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
364 const gchar *type = xmlnode_get_attrib(packet, "type"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
365 xmlnode *jingle; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
366 const gchar *action; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
367 const gchar *sid; |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
368 JingleActionType action_type; |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
369 JingleSession *session; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
370 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
371 if (!type || strcmp(type, "set")) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
372 /* send iq error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
373 return; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
374 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
375 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
376 /* is this a Jingle package? */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
377 if (!(jingle = xmlnode_get_child(packet, "jingle"))) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
378 /* send iq error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
379 return; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
380 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
381 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
382 if (!(action = xmlnode_get_attrib(jingle, "action"))) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
383 /* send iq error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
384 return; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
385 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
386 |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
387 action_type = jingle_get_action_type(action); |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
388 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
389 purple_debug_info("jabber", "got Jingle package action = %s\n", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
390 action); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
391 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
392 if (!(sid = xmlnode_get_attrib(jingle, "sid"))) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
393 /* send iq error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
394 return; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
395 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
396 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
397 if (!(session = jingle_session_find_by_sid(js, sid)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
398 && strcmp(action, "session-initiate")) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
399 purple_debug_error("jingle", "jabber_jingle_session_parse couldn't find session\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
400 /* send iq error here */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
401 return; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
402 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
403 |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
404 if (action_type == JINGLE_SESSION_INITIATE) { |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
405 if (session) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
406 /* This should only happen if you start a session with yourself */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
407 purple_debug_error("jingle", "Jingle session with " |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
408 "id={%s} already exists\n", sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
409 /* send iq error */ |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
410 return; |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
411 } else { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
412 session = jingle_session_create(js, sid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
413 xmlnode_get_attrib(packet, "to"), |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
414 xmlnode_get_attrib(packet, "from"), FALSE); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
415 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
416 } |
26281
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
417 |
925af7142249
Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26087
diff
changeset
|
418 jingle_actions[action_type].handler(session, jingle); |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
419 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
420 |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
421 static void |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
422 jingle_terminate_sessions_gh(gpointer key, gpointer value, gpointer user_data) |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
423 { |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
424 g_object_unref(value); |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
425 } |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
426 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
427 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
428 jingle_terminate_sessions(JabberStream *js) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
429 { |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
430 if (js->sessions) |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
431 g_hash_table_foreach(js->sessions, |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26009
diff
changeset
|
432 jingle_terminate_sessions_gh, NULL); |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
433 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
434 |
26080
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
435 GParameter * |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
436 jingle_get_params(JabberStream *js, guint *num) |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
437 { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
438 /* don't set a STUN server if one is set globally in prefs, in that case |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
439 this will be handled in media.c */ |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
440 gboolean has_account_stun = js->stun_ip && !purple_network_get_stun_ip(); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
441 guint num_params = has_account_stun ? 2 : 0; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
442 GParameter *params = NULL; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
443 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
444 if (num_params > 0) { |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
445 params = g_new0(GParameter, num_params); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
446 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
447 purple_debug_info("jabber", |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
448 "setting param stun-ip for stream using Google auto-config: %s\n", |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
449 js->stun_ip); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
450 params[0].name = "stun-ip"; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
451 g_value_init(¶ms[0].value, G_TYPE_STRING); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
452 g_value_set_string(¶ms[0].value, js->stun_ip); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
453 purple_debug_info("jabber", |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
454 "setting param stun-port for stream using Google auto-config: %d\n", |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
455 js->stun_port); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
456 params[1].name = "stun-port"; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
457 g_value_init(¶ms[1].value, G_TYPE_UINT); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
458 g_value_set_uint(¶ms[1].value, js->stun_port); |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
459 } |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
460 |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
461 *num = num_params; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
462 return params; |
88f183f7dfc7
Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents:
26010
diff
changeset
|
463 } |