annotate libpurple/protocols/jabber/jingle/jingle.c @ 29303:40b523845a6e

propagate from branch 'im.pidgin.pidgin' (head 8c322571bfb4f2d00c9126e59746445f877be296) to branch 'im.pidgin.cpw.attention_ui' (head f2b8ccc32a73cb137e1a4f3fd5fb55266df2feed)
author Marcus Lundblad <ml@update.uu.se>
date Tue, 03 Nov 2009 18:27:22 +0000
parents e0a9b3e18c9d
children fc8c85e8b6e1 a7e16735b218
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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 *
28048
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26472
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: 26472
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: 26472
diff changeset
8 * source distribution.
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26472
diff changeset
9 *
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
10 * 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
11 * 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
12 * 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
13 * (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
14 *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
15 * 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
16 * 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
17 * 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
18 * 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
19 *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
20 * 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
21 * 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
22 * 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
23 *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
24 */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
25
26010
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
26 #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
27 #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
28
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
29 #include "content.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
30 #include "debug.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
31 #include "jingle.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
32 #include <string.h>
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
33 #include "session.h"
24966
bee5ab815291 Added a Jingle ice-udp transmitter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24949
diff changeset
34 #include "iceudp.h"
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
35 #include "rawudp.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
36 #include "rtp.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
37
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
38 GType
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
39 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
40 {
26009
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
41 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
42 return JINGLE_TYPE_RAWUDP;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
43 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
44 return JINGLE_TYPE_ICEUDP;
24966
bee5ab815291 Added a Jingle ice-udp transmitter.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24949
diff changeset
45 #if 0
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
46 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
47 return JINGLE_TYPE_SOCKS;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
48 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
49 return JINGLE_TYPE_IBB;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
50 #endif
26009
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
51 #ifdef USE_VV
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
52 else if (!strcmp(type, JINGLE_APP_RTP))
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
53 return JINGLE_TYPE_RTP;
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
54 #endif
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
55 #if 0
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
56 else if (!strcmp(type, JINGLE_APP_FT))
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
57 return JINGLE_TYPE_FT;
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
58 else if (!strcmp(type, JINGLE_APP_XML))
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
59 return JINGLE_TYPE_XML;
59188d904773 Fix compiling with --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24966
diff changeset
60 #endif
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
61 else
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
62 return G_TYPE_NONE;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
63 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
64
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
65 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
66 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
67 {
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
68 /* Send error */
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
69 }
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
70
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
71 static void
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
72 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
73 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
74 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
75 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
76
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
77 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
78 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
79 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
80 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
81 /* signal here */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
82 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
85 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
86 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
87 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
88 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
89 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
90
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
91 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
92 JingleContent *pending_content =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
93 jingle_content_parse(content);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
94 if (pending_content == NULL) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
95 purple_debug_error("jingle",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
96 "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
97 /* XXX: send error here */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
98 } else {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
99 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
100 pending_content);
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
104 /* XXX: signal here */
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
107 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
108 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
109 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
110 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
111 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
112
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
113 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
114 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
115 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
116 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
117
28287
e0a9b3e18c9d Fix a crash when content modify contains unknown content.
maiku@pidgin.im
parents: 28048
diff changeset
118 if (local_content != NULL) {
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
119 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
120 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
121 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
122 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
123 g_free(local_senders);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
124 } else {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
125 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
126 /* XXX: send error */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
127 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
128 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
131 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
132 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
133 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
134 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
135 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
136
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
137 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
138 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
139 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
140 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
141 /* signal here */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
142 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
145 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
146 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
147 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
148 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
149
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
150 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
151
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
152 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
153 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
154 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
155 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
156 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
157 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
158
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
159 static void
26087
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
160 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
161 {
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
162 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
163
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
164 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
165
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
166 jingle_session_accept_session(session);
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
167
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
168 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
169 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
170 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
171 JingleContent *parsed_content =
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
172 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
173 if (parsed_content == NULL) {
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
174 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
175 /* XXX: send error */
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
176 } else {
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
177 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
178 JINGLE_DESCRIPTION_INFO);
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
179 }
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
180 }
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
181 }
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
182
0a5737e1e969 Update to newest XEP-0166 Jingle spec.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26080
diff changeset
183 static void
26283
abcc94ace5ea Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26282
diff changeset
184 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
185 {
abcc94ace5ea Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26282
diff changeset
186 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
187 }
abcc94ace5ea Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26282
diff changeset
188
abcc94ace5ea Update to be closer to the current Jingle XEP.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26282
diff changeset
189 static void
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
190 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
191 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
192 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
193
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
194 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
195
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
196 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
197
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
198 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
199 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
200 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
201 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
202 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
203 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
204 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
205 /* XXX: send error */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
206 } else {
24949
1a2d446cb8a0 Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24938
diff changeset
207 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
208 JINGLE_SESSION_ACCEPT);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
209 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
210 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
213 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
214 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
215 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
216 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
217 /* XXX: call signal */
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
220 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
221 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
222 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
223 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
224
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
225 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
226 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
227 if (parsed_content == NULL) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
228 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
229 /* XXX: send error */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
230 } else {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
231 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
232 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
233 JINGLE_SESSION_INITIATE);
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
237 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
238 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
239
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
240 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
241 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
242 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
243 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
244
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
245 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
246 JINGLE_SESSION_TERMINATE);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
247 /* display reason? */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
248 g_object_unref(session);
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
251 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
252 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
253 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
254 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
255
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
256 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
257
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
258 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
259 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
260 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
261 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
262 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
263 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
266 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
267 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
268 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
269 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
270
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
271 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
272
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
273 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
274 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
275 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
276 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
277 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
278 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
279 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
280 /* XXX: send error */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
281 } else {
24949
1a2d446cb8a0 Fix support for audio and video (at the same time) sessions.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 24938
diff changeset
282 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
283 JINGLE_TRANSPORT_INFO);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
284 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
285 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
288 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
289 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
290 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
291 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
292
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
293 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
294
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
295 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
296 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
297 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
298 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
299 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
300 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
303 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
304 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
305 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
306 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
307
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
308 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
309
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
310 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
311 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
312 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
313 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
314 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
315 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
316
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
317 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
318 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
319 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
320
26281
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
321 typedef struct {
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
322 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
323 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
324 } JingleAction;
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
325
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
326 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
327 {"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
328 {"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
329 {"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
330 {"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
331 {"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
332 {"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
333 {"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
334 {"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
335 {"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
336 {"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
337 {"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
338 {"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
339 {"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
340 {"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
341 {"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
342 {"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
343 };
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
344
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
345 const gchar *
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
346 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
347 {
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
348 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
349 }
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
350
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
351 JingleActionType
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
352 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
353 {
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
354 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
355 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
356 /* 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
357 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
358 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
359 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
360 return i;
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
361 }
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
362 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
363 }
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
364
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
365 void
26472
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
366 jingle_parse(JabberStream *js, const char *from, JabberIqType type,
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
367 const char *id, xmlnode *jingle)
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
368 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
369 const gchar *action;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
370 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
371 JingleActionType action_type;
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
372 JingleSession *session;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
373
26472
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
374 if (type != JABBER_IQ_SET) {
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
375 /* TODO: send iq error here */
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
376 return;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
377 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
378
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
379 if (!(action = xmlnode_get_attrib(jingle, "action"))) {
26472
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
380 /* TODO: send iq error here */
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
381 return;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
382 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
383
26281
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
384 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
385
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
386 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
387 action);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
388
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
389 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
390 /* send iq error here */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
391 return;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
392 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
393
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
394 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
395 && strcmp(action, "session-initiate")) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
396 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
397 /* send iq error here */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
398 return;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
399 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
400
26281
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
401 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
402 if (session) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
403 /* 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
404 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
405 "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
406 /* 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
407 return;
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
408 } else {
26472
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
409 char *own_jid = g_strdup_printf("%s@%s/%s", js->user->node,
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
410 js->user->domain, js->user->resource);
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
411 session = jingle_session_create(js, sid, own_jid, from, FALSE);
3c684403ea10 Fix merge for ./jingle/
Paul Aurich <paul@darkrain42.org>
parents: 26283
diff changeset
412 g_free(own_jid);
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
413 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
414 }
26281
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
415
925af7142249 Restructure Jingle action handlers to only require modification in one place.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26087
diff changeset
416 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
417 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
418
26010
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
419 static void
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
420 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
421 {
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
422 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
423 }
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
424
24938
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
425 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
426 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
427 {
26010
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26009
diff changeset
428 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
429 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
430 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
431 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
432
26080
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
433 GParameter *
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
434 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
435 {
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
436 /* 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
437 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
438 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
439 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
440 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
441
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
442 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
443 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
444
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
445 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
446 "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
447 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
448 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
449 g_value_init(&params[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
450 g_value_set_string(&params[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
451 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
452 "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
453 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
454 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
455 g_value_init(&params[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
456 g_value_set_uint(&params[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
457 }
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
458
88f183f7dfc7 Add automatic discovery of GTalk STUN servers when using a Gtalk account
Marcus Lundblad <ml@update.uu.se>
parents: 26010
diff changeset
459 *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
460 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
461 }