Mercurial > pidgin
annotate libpurple/protocols/jabber/jingle/session.c @ 26929:f82f3dc29f9b
Don't try to process BOSH packet if there's no data (avoid a purple_strcasestr assertion).
Also print friendlier error messages.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Thu, 21 May 2009 21:09:17 +0000 |
parents | d1a0c36cc4ea |
children | c585572e80dd |
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 session.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 |
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 |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
21 #include "internal.h" |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
22 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
23 #include "content.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
24 #include "debug.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
25 #include "session.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
26 #include "jingle.h" |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
27 |
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
30 struct _JingleSessionPrivate |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
31 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
32 gchar *sid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
33 JabberStream *js; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
34 gchar *remote_jid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
35 gchar *local_jid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
36 gboolean is_initiator; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
37 gboolean state; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
38 GList *contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
39 GList *pending_contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
40 }; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
41 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
42 #define JINGLE_SESSION_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_SESSION, JingleSessionPrivate)) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
43 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
44 static void jingle_session_class_init (JingleSessionClass *klass); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
45 static void jingle_session_init (JingleSession *session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
46 static void jingle_session_finalize (GObject *object); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
47 static void jingle_session_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
48 static void jingle_session_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
49 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
50 static GObjectClass *parent_class = NULL; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
51 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
52 enum { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
53 PROP_0, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
54 PROP_SID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
55 PROP_JS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
56 PROP_REMOTE_JID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
57 PROP_LOCAL_JID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
58 PROP_IS_INITIATOR, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
59 PROP_STATE, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
60 PROP_CONTENTS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
61 PROP_PENDING_CONTENTS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
62 }; |
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 GType |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
65 jingle_session_get_type() |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
66 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
67 static GType type = 0; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
68 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
69 if (type == 0) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
70 static const GTypeInfo info = { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
71 sizeof(JingleSessionClass), |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
72 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
73 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
74 (GClassInitFunc) jingle_session_class_init, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
75 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
76 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
77 sizeof(JingleSession), |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
78 0, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
79 (GInstanceInitFunc) jingle_session_init, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
80 NULL |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
81 }; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
82 type = g_type_register_static(G_TYPE_OBJECT, "JingleSession", &info, 0); |
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 return type; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
85 } |
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 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
88 jingle_session_class_init (JingleSessionClass *klass) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
89 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
90 GObjectClass *gobject_class = (GObjectClass*)klass; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
91 parent_class = g_type_class_peek_parent(klass); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
92 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
93 gobject_class->finalize = jingle_session_finalize; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
94 gobject_class->set_property = jingle_session_set_property; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
95 gobject_class->get_property = jingle_session_get_property; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
96 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
97 g_object_class_install_property(gobject_class, PROP_SID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
98 g_param_spec_string("sid", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
99 "Session ID", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
100 "The unique session ID of the Jingle Session.", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
101 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
102 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
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 g_object_class_install_property(gobject_class, PROP_JS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
105 g_param_spec_pointer("js", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
106 "JabberStream", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
107 "The Jabber stream associated with this session.", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
108 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
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 g_object_class_install_property(gobject_class, PROP_REMOTE_JID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
111 g_param_spec_string("remote-jid", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
112 "Remote JID", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
113 "The JID of the remote participant.", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
114 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
115 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
116 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
117 g_object_class_install_property(gobject_class, PROP_LOCAL_JID, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
118 g_param_spec_string("local-jid", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
119 "Local JID", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
120 "The JID of the local participant.", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
121 NULL, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
122 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
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 g_object_class_install_property(gobject_class, PROP_IS_INITIATOR, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
125 g_param_spec_boolean("is-initiator", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
126 "Is Initiator", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
127 "Whether or not the local JID is the initiator of the session.", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
128 FALSE, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
129 G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE)); |
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 g_object_class_install_property(gobject_class, PROP_STATE, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
132 g_param_spec_boolean("state", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
133 "State", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
134 "The state of the session (PENDING=FALSE, ACTIVE=TRUE).", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
135 FALSE, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
136 G_PARAM_READABLE)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
137 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
138 g_object_class_install_property(gobject_class, PROP_CONTENTS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
139 g_param_spec_pointer("contents", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
140 "Contents", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
141 "The active contents contained within this session", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
142 G_PARAM_READABLE)); |
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 g_object_class_install_property(gobject_class, PROP_PENDING_CONTENTS, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
145 g_param_spec_pointer("pending-contents", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
146 "Pending contents", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
147 "The pending contents contained within this session", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
148 G_PARAM_READABLE)); |
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 g_type_class_add_private(klass, sizeof(JingleSessionPrivate)); |
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
153 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
154 jingle_session_init (JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
155 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
156 session->priv = JINGLE_SESSION_GET_PRIVATE(session); |
26291
30cc73d99789
Fix a bunch of memsets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26284
diff
changeset
|
157 memset(session->priv, 0, sizeof(*session->priv)); |
24938
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
160 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
161 jingle_session_finalize (GObject *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
162 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
163 JingleSessionPrivate *priv = JINGLE_SESSION_GET_PRIVATE(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
164 purple_debug_info("jingle","jingle_session_finalize\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
165 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
166 g_hash_table_remove(priv->js->sessions, priv->sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
167 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
168 g_free(priv->sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
169 g_free(priv->remote_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
170 g_free(priv->local_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
171 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
172 for (; priv->contents; priv->contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
173 g_list_delete_link(priv->contents, priv->contents)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
174 g_object_unref(priv->contents->data); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
175 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
176 for (; priv->pending_contents; priv->pending_contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
177 g_list_delete_link(priv->pending_contents, priv->pending_contents)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
178 g_object_unref(priv->pending_contents->data); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
179 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
180 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
181 parent_class->finalize(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
182 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
183 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
184 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
185 jingle_session_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
186 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
187 JingleSession *session; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
188 g_return_if_fail(JINGLE_IS_SESSION(object)); |
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 session = JINGLE_SESSION(object); |
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 switch (prop_id) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
193 case PROP_SID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
194 g_free(session->priv->sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
195 session->priv->sid = g_value_dup_string(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
196 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
197 case PROP_JS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
198 session->priv->js = g_value_get_pointer(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
199 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
200 case PROP_REMOTE_JID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
201 g_free(session->priv->remote_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
202 session->priv->remote_jid = g_value_dup_string(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
203 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
204 case PROP_LOCAL_JID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
205 g_free(session->priv->local_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
206 session->priv->local_jid = g_value_dup_string(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
207 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
208 case PROP_IS_INITIATOR: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
209 session->priv->is_initiator = g_value_get_boolean(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
210 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
211 case PROP_STATE: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
212 session->priv->state = g_value_get_boolean(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
213 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
214 case PROP_CONTENTS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
215 session->priv->contents = g_value_get_pointer(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
216 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
217 case PROP_PENDING_CONTENTS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
218 session->priv->pending_contents = g_value_get_pointer(value); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
219 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
220 default: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
221 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
222 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
223 } |
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
226 static void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
227 jingle_session_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
228 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
229 JingleSession *session; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
230 g_return_if_fail(JINGLE_IS_SESSION(object)); |
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 session = JINGLE_SESSION(object); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
233 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
234 switch (prop_id) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
235 case PROP_SID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
236 g_value_set_string(value, session->priv->sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
237 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
238 case PROP_JS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
239 g_value_set_pointer(value, session->priv->js); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
240 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
241 case PROP_REMOTE_JID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
242 g_value_set_string(value, session->priv->remote_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
243 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
244 case PROP_LOCAL_JID: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
245 g_value_set_string(value, session->priv->local_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
246 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
247 case PROP_IS_INITIATOR: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
248 g_value_set_boolean(value, session->priv->is_initiator); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
249 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
250 case PROP_STATE: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
251 g_value_set_boolean(value, session->priv->state); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
252 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
253 case PROP_CONTENTS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
254 g_value_set_pointer(value, session->priv->contents); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
255 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
256 case PROP_PENDING_CONTENTS: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
257 g_value_set_pointer(value, session->priv->pending_contents); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
258 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
259 default: |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
260 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
261 break; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
262 } |
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 JingleSession * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
267 jingle_session_create(JabberStream *js, const gchar *sid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
268 const gchar *local_jid, const gchar *remote_jid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
269 gboolean is_initiator) |
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 JingleSession *session = g_object_new(jingle_session_get_type(), |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
272 "js", js, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
273 "sid", sid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
274 "local-jid", local_jid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
275 "remote-jid", remote_jid, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
276 "is_initiator", is_initiator, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
277 NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
278 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
279 /* insert it into the hash table */ |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
280 if (!js->sessions) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
281 purple_debug_info("jingle", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
282 "Creating hash table for sessions\n"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
283 js->sessions = g_hash_table_new(g_str_hash, g_str_equal); |
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 purple_debug_info("jingle", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
286 "inserting session with key: %s into table\n", sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
287 g_hash_table_insert(js->sessions, g_strdup(sid), session); |
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 return session; |
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
292 JabberStream * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
293 jingle_session_get_js(JingleSession *session) |
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 JabberStream *js; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
296 g_object_get(session, "js", &js, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
297 return js; |
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 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
300 gchar * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
301 jingle_session_get_sid(JingleSession *session) |
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 gchar *sid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
304 g_object_get(session, "sid", &sid, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
305 return sid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
306 } |
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 gchar * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
309 jingle_session_get_local_jid(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
310 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
311 gchar *local_jid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
312 g_object_get(session, "local-jid", &local_jid, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
313 return local_jid; |
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 gchar * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
317 jingle_session_get_remote_jid(JingleSession *session) |
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 gchar *remote_jid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
320 g_object_get(session, "remote-jid", &remote_jid, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
321 return remote_jid; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
322 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
323 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
324 gboolean |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
325 jingle_session_is_initiator(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
326 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
327 gboolean is_initiator; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
328 g_object_get(session, "is-initiator", &is_initiator, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
329 return is_initiator; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
330 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
331 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
332 gboolean |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
333 jingle_session_get_state(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
334 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
335 gboolean state; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
336 g_object_get(session, "state", &state, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
337 return state; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
338 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
339 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
340 GList * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
341 jingle_session_get_contents(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
342 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
343 GList *contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
344 g_object_get(session, "contents", &contents, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
345 return contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
346 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
347 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
348 GList * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
349 jingle_session_get_pending_contents(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
350 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
351 GList *pending_contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
352 g_object_get(session, "pending-contents", &pending_contents, NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
353 return pending_contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
354 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
355 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
356 JingleSession * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
357 jingle_session_find_by_sid(JabberStream *js, const gchar *sid) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
358 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
359 purple_debug_info("jingle", "find_by_id %s\n", sid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
360 purple_debug_info("jingle", "lookup: %p\n", (js->sessions) ? |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
361 g_hash_table_lookup(js->sessions, sid) : NULL); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
362 return (JingleSession *) (js->sessions) ? |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
363 g_hash_table_lookup(js->sessions, sid) : NULL; |
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 |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
366 #if GLIB_CHECK_VERSION(2,4,0) |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
367 static gboolean find_by_jid_ghr(gpointer key, |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
368 gpointer value, gpointer user_data) |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
369 { |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
370 JingleSession *session = (JingleSession *)value; |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
371 const gchar *jid = user_data; |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
372 gboolean use_bare = g_utf8_strchr(jid, -1, '/') == NULL; |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
373 gchar *remote_jid = jingle_session_get_remote_jid(session); |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
374 gchar *cmp_jid = use_bare ? jabber_get_bare_jid(remote_jid) |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
375 : g_strdup(remote_jid); |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
376 g_free(remote_jid); |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
377 if (g_str_equal(jid, cmp_jid)) { |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
378 g_free(cmp_jid); |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
379 return TRUE; |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
380 } |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
381 g_free(cmp_jid); |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
382 |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
383 return FALSE; |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
384 } |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
385 |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
386 #else /* GLIB_CHECK_VERSION 2.4.0 */ |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
387 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
388 /* Ugly code; g_hash_table_find version above is much nicer */ |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
389 struct session_find_jid |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
390 { |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
391 const gchar *jid; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
392 JingleSession *ret; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
393 gboolean use_bare; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
394 }; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
395 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
396 static void find_by_jid_ghr(gpointer key, gpointer value, gpointer user_data) |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
397 { |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
398 JingleSession *session = (JingleSession *)value; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
399 struct session_find_jid *data = user_data; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
400 gchar *remote_jid; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
401 gchar *cmp_jid; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
402 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
403 if (data->ret != NULL) |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
404 return; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
405 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
406 remote_jid = jingle_session_get_remote_jid(session); |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
407 cmp_jid = data->use_bare ? jabber_get_bare_jid(remote_jid) |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
408 : g_strdup(remote_jid); |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
409 g_free(remote_jid); |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
410 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
411 if (g_str_equal(data->jid, cmp_jid)) |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
412 data->ret = session; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
413 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
414 g_free(cmp_jid); |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
415 } |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
416 #endif /* GLIB_CHECK_VERSION 2.4.0 */ |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
417 |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
418 JingleSession * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
419 jingle_session_find_by_jid(JabberStream *js, const gchar *jid) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
420 { |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
421 #if GLIB_CHECK_VERSION(2,4,0) |
26010
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
422 return js->sessions != NULL ? |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
423 g_hash_table_find(js->sessions, |
db517c55c508
Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
24938
diff
changeset
|
424 find_by_jid_ghr, (gpointer)jid) : NULL; |
26732
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
425 #else |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
426 struct session_find_jid data; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
427 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
428 if (js->sessions == NULL) |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
429 return NULL; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
430 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
431 data.jid = jid; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
432 data.ret = NULL; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
433 data.use_bare = g_utf8_strchr(jid, -1, '/') == NULL; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
434 |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
435 g_hash_table_foreach(js->sessions, find_by_jid_ghr, &data); |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
436 return data.ret; |
d1a0c36cc4ea
Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents:
26304
diff
changeset
|
437 #endif |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
438 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
439 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
440 static xmlnode * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
441 jingle_add_jingle_packet(JingleSession *session, |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
442 JabberIq *iq, JingleActionType action) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
443 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
444 xmlnode *jingle = iq ? |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
445 xmlnode_new_child(iq->node, "jingle") : |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
446 xmlnode_new("jingle"); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
447 gchar *local_jid = jingle_session_get_local_jid(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
448 gchar *remote_jid = jingle_session_get_remote_jid(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
449 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
450 xmlnode_set_namespace(jingle, JINGLE); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
451 xmlnode_set_attrib(jingle, "action", jingle_get_action_name(action)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
452 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
453 if (jingle_session_is_initiator(session)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
454 xmlnode_set_attrib(jingle, "initiator", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
455 jingle_session_get_local_jid(session)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
456 xmlnode_set_attrib(jingle, "responder", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
457 jingle_session_get_remote_jid(session)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
458 } else { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
459 xmlnode_set_attrib(jingle, "initiator", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
460 jingle_session_get_remote_jid(session)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
461 xmlnode_set_attrib(jingle, "responder", |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
462 jingle_session_get_local_jid(session)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
463 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
464 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
465 g_free(local_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
466 g_free(remote_jid); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
467 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
468 xmlnode_set_attrib(jingle, "sid", jingle_session_get_sid(session)); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
469 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
470 return jingle; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
471 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
472 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
473 JabberIq * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
474 jingle_session_create_ack(JingleSession *session, const xmlnode *jingle) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
475 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
476 JabberIq *result = jabber_iq_new( |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
477 jingle_session_get_js(session), |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
478 JABBER_IQ_RESULT); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
479 xmlnode *packet = xmlnode_get_parent(jingle); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
480 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
481 xmlnode_set_attrib(result->node, "from", 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
|
482 xmlnode_set_attrib(result->node, "to", xmlnode_get_attrib(packet, "from")); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
483 return result; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
484 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
485 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
486 static JabberIq * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
487 jingle_create_iq(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
488 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
489 JabberStream *js = jingle_session_get_js(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
490 JabberIq *result = jabber_iq_new(js, JABBER_IQ_SET); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
491 gchar *from = jingle_session_get_local_jid(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
492 gchar *to = jingle_session_get_remote_jid(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
493 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
494 xmlnode_set_attrib(result->node, "from", from); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
495 xmlnode_set_attrib(result->node, "to", to); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
496 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
497 g_free(from); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
498 g_free(to); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
499 return result; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
500 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
501 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
502 xmlnode * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
503 jingle_session_to_xml(JingleSession *session, xmlnode *jingle, JingleActionType action) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
504 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
505 if (action != JINGLE_SESSION_INFO && action != JINGLE_SESSION_TERMINATE) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
506 GList *iter; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
507 if (action == JINGLE_CONTENT_ACCEPT |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
508 || action == JINGLE_CONTENT_ADD |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
509 || action == JINGLE_CONTENT_REMOVE) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
510 iter = jingle_session_get_pending_contents(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
511 else |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
512 iter = jingle_session_get_contents(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
513 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
514 for (; iter; iter = g_list_next(iter)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
515 jingle_content_to_xml(iter->data, jingle, action); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
516 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
517 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
518 return jingle; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
519 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
520 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
521 JabberIq * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
522 jingle_session_to_packet(JingleSession *session, JingleActionType action) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
523 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
524 JabberIq *iq = jingle_create_iq(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
525 xmlnode *jingle = jingle_add_jingle_packet(session, iq, action); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
526 jingle_session_to_xml(session, jingle, action); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
527 return iq; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
528 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
529 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
530 void jingle_session_handle_action(JingleSession *session, xmlnode *jingle, JingleActionType action) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
531 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
532 GList *iter; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
533 if (action == JINGLE_CONTENT_ADD || action == JINGLE_CONTENT_REMOVE) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
534 iter = jingle_session_get_pending_contents(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
535 else |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
536 iter = jingle_session_get_contents(session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
537 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
538 for (; iter; iter = g_list_next(iter)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
539 jingle_content_handle_action(iter->data, jingle, action); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
540 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
541 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
542 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
543 JingleContent * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
544 jingle_session_find_content(JingleSession *session, const gchar *name, const gchar *creator) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
545 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
546 GList *iter = session->priv->contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
547 for (; iter; iter = g_list_next(iter)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
548 JingleContent *content = iter->data; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
549 gchar *cname = jingle_content_get_name(content); |
26301
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
550 gboolean result = !strcmp(name, cname); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
551 g_free(cname); |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
552 |
26301
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
553 if (creator != NULL) { |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
554 gchar *ccreator = jingle_content_get_creator(content); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
555 result = (result && !strcmp(creator, ccreator)); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
556 g_free(ccreator); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
557 } |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
558 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
559 if (result == TRUE) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
560 return content; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
561 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
562 return NULL; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
563 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
564 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
565 JingleContent * |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
566 jingle_session_find_pending_content(JingleSession *session, const gchar *name, const gchar *creator) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
567 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
568 GList *iter = session->priv->pending_contents; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
569 for (; iter; iter = g_list_next(iter)) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
570 JingleContent *content = iter->data; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
571 gchar *cname = jingle_content_get_name(content); |
26301
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
572 gboolean result = !strcmp(name, cname); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
573 g_free(cname); |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
574 |
26301
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
575 if (creator != NULL) { |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
576 gchar *ccreator = jingle_content_get_creator(content); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
577 result = (result && !strcmp(creator, ccreator)); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
578 g_free(ccreator); |
08e4ad2fcd63
Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26291
diff
changeset
|
579 } |
24938
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
580 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
581 if (result == TRUE) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
582 return content; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
583 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
584 return NULL; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
585 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
586 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
587 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
588 jingle_session_add_content(JingleSession *session, JingleContent* content) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
589 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
590 session->priv->contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
591 g_list_append(session->priv->contents, content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
592 jingle_content_set_session(content, session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
593 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
594 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
595 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
596 jingle_session_remove_content(JingleSession *session, const gchar *name, const gchar *creator) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
597 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
598 JingleContent *content = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
599 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
|
600 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
601 if (content) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
602 session->priv->contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
603 g_list_remove(session->priv->contents, content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
604 g_object_unref(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
605 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
606 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
607 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
608 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
609 jingle_session_add_pending_content(JingleSession *session, JingleContent* content) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
610 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
611 session->priv->pending_contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
612 g_list_append(session->priv->pending_contents, content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
613 jingle_content_set_session(content, session); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
614 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
615 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
616 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
617 jingle_session_remove_pending_content(JingleSession *session, const gchar *name, const gchar *creator) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
618 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
619 JingleContent *content = jingle_session_find_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
|
620 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
621 if (content) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
622 session->priv->pending_contents = |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
623 g_list_remove(session->priv->pending_contents, content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
624 g_object_unref(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
625 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
626 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
627 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
628 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
629 jingle_session_accept_content(JingleSession *session, const gchar *name, const gchar *creator) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
630 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
631 JingleContent *content = jingle_session_find_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
|
632 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
633 if (content) { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
634 g_object_ref(content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
635 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
|
636 jingle_session_add_content(session, content); |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
637 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
638 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
639 |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
640 void |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
641 jingle_session_accept_session(JingleSession *session) |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
642 { |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
643 session->priv->state = TRUE; |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
644 } |
bd598b606ca4
Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff
changeset
|
645 |
26284
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
646 JabberIq * |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
647 jingle_session_terminate_packet(JingleSession *session, const gchar *reason) |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
648 { |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
649 JabberIq *iq = jingle_session_to_packet(session, |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
650 JINGLE_SESSION_TERMINATE); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
651 xmlnode *jingle = xmlnode_get_child(iq->node, "jingle"); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
652 |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
653 if (reason != NULL) { |
26303 | 654 xmlnode *reason_node; |
26284
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
655 reason_node = xmlnode_new_child(jingle, "reason"); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
656 xmlnode_new_child(reason_node, reason); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
657 } |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
658 return iq; |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
659 } |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
660 |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
661 JabberIq * |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
662 jingle_session_redirect_packet(JingleSession *session, const gchar *sid) |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
663 { |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
664 JabberIq *iq = jingle_session_terminate_packet(session, |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
665 "alternative-session"); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
666 xmlnode *alt_session; |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
667 |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
668 if (sid == NULL) |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
669 return iq; |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
670 |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
671 alt_session = xmlnode_get_child(iq->node, |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
672 "jingle/reason/alternative-session"); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
673 |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
674 if (alt_session != NULL) { |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
675 xmlnode *sid_node = xmlnode_new_child(alt_session, "sid"); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
676 xmlnode_insert_data(sid_node, sid, -1); |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
677 } |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
678 return iq; |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
679 } |
4f47eeaa1414
Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
26010
diff
changeset
|
680 |