annotate libpurple/protocols/jabber/jingle/session.c @ 28398:c585572e80dd

Remove specific copyright lines from the XMPP prpl.
author Paul Aurich <paul@darkrain42.org>
date Sat, 22 Aug 2009 02:52:30 +0000
parents d1a0c36cc4ea
children 90361789d5ac 39716f7d2c93
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26014
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 *
28398
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26814
diff changeset
6 * Purple is the legal property of its developers, whose names are too numerous
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26814
diff changeset
7 * to list here. Please refer to the COPYRIGHT file distributed with this
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26814
diff changeset
8 * source distribution.
c585572e80dd Remove specific copyright lines from the XMPP prpl.
Paul Aurich <paul@darkrain42.org>
parents: 26814
diff changeset
9 *
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
13 * (at your option) any later version.
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
14 *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
18 * GNU General Public License for more details.
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
19 *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
23 */
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
24
26092
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
25 #include "internal.h"
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
26
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
27 #include "content.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
28 #include "debug.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
29 #include "session.h"
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
30 #include "jingle.h"
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 #include <string.h>
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
33
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
34 struct _JingleSessionPrivate
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
35 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
36 gchar *sid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
37 JabberStream *js;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
38 gchar *remote_jid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
39 gchar *local_jid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
40 gboolean is_initiator;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
41 gboolean state;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
42 GList *contents;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
43 GList *pending_contents;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
44 };
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
45
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
46 #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
47
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_class_init (JingleSessionClass *klass);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
49 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
50 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
51 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
52 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
53
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
54 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
55
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
56 enum {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
57 PROP_0,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
58 PROP_SID,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
59 PROP_JS,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
60 PROP_REMOTE_JID,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
61 PROP_LOCAL_JID,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
62 PROP_IS_INITIATOR,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
63 PROP_STATE,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
64 PROP_CONTENTS,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
65 PROP_PENDING_CONTENTS,
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
68 GType
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
69 jingle_session_get_type()
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
70 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
71 static GType type = 0;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
72
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
73 if (type == 0) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
74 static const GTypeInfo info = {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
75 sizeof(JingleSessionClass),
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 NULL,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
78 (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
79 NULL,
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 sizeof(JingleSession),
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
82 0,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
83 (GInstanceInitFunc) jingle_session_init,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
84 NULL
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 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
87 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
88 return type;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
91 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
92 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
93 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
94 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
95 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
96
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
97 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
98 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
99 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
100
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
101 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
102 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
103 "Session ID",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
104 "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
105 NULL,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
106 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
107
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
108 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
109 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
110 "JabberStream",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
111 "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
112 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
113
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
114 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
115 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
116 "Remote JID",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
117 "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
118 NULL,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
119 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
120
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
121 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
122 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
123 "Local JID",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
124 "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
125 NULL,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
126 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
127
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
128 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
129 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
130 "Is Initiator",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
131 "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
132 FALSE,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
133 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
134
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
135 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
136 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
137 "State",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
138 "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
139 FALSE,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
140 G_PARAM_READABLE));
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
141
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
142 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
143 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
144 "Contents",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
145 "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
146 G_PARAM_READABLE));
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
147
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
148 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
149 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
150 "Pending contents",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
151 "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
152 G_PARAM_READABLE));
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
153
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
154 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
155 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
156
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
157 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
158 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
159 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
160 session->priv = JINGLE_SESSION_GET_PRIVATE(session);
26373
30cc73d99789 Fix a bunch of memsets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26366
diff changeset
161 memset(session->priv, 0, sizeof(*session->priv));
26014
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
164 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
165 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
166 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
167 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
168 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
169
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
170 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
171
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
172 g_free(priv->sid);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
173 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
174 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
175
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
176 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
177 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
178 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
179 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
180 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
181 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
182 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
183 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
184
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
185 parent_class->finalize(session);
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
188 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
189 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
190 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
191 JingleSession *session;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
192 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
193
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
194 session = JINGLE_SESSION(object);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
195
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
196 switch (prop_id) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
197 case PROP_SID:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
198 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
199 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
200 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
201 case PROP_JS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
202 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
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_REMOTE_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->remote_jid);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
206 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
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_LOCAL_JID:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
209 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
210 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
211 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
212 case PROP_IS_INITIATOR:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
213 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
214 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
215 case PROP_STATE:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
216 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
217 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
218 case PROP_CONTENTS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
219 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
220 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
221 case PROP_PENDING_CONTENTS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
222 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
223 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
224 default:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
225 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
226 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
227 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
230 static void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
231 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
232 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
233 JingleSession *session;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
234 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
235
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
236 session = JINGLE_SESSION(object);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
237
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
238 switch (prop_id) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
239 case PROP_SID:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
240 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
241 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
242 case PROP_JS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
243 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
244 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
245 case PROP_REMOTE_JID:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
246 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
247 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
248 case PROP_LOCAL_JID:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
249 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
250 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
251 case PROP_IS_INITIATOR:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
252 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
253 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
254 case PROP_STATE:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
255 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
256 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
257 case PROP_CONTENTS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
258 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
259 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
260 case PROP_PENDING_CONTENTS:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
261 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
262 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
263 default:
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
264 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
265 break;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
266 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
267 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
268
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
269
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
270 JingleSession *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
271 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
272 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
273 gboolean is_initiator)
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
274 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
275 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
276 "js", js,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
277 "sid", sid,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
278 "local-jid", local_jid,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
279 "remote-jid", remote_jid,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
280 "is_initiator", is_initiator,
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
281 NULL);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
282
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
283 /* 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
284 if (!js->sessions) {
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 "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
287 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
288 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
289 purple_debug_info("jingle",
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
290 "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
291 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
292
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
293 return 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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
296 JabberStream *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
297 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
298 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
299 JabberStream *js;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
300 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
301 return js;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
304 gchar *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
305 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
306 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
307 gchar *sid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
308 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
309 return sid;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
312 gchar *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
313 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
314 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
315 gchar *local_jid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
316 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
317 return local_jid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
318 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
319
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
320 gchar *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
321 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
322 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
323 gchar *remote_jid;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
324 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
325 return remote_jid;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
328 gboolean
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
329 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
330 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
331 gboolean is_initiator;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
332 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
333 return is_initiator;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
336 gboolean
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
337 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
338 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
339 gboolean state;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
340 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
341 return state;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
344 GList *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
345 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
346 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
347 GList *contents;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
348 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
349 return contents;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
352 GList *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
353 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
354 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
355 GList *pending_contents;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
356 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
357 return pending_contents;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
360 JingleSession *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
361 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
362 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
363 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
364 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
365 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
366 return (JingleSession *) (js->sessions) ?
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
367 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
368 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
369
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
370 #if GLIB_CHECK_VERSION(2,4,0)
26092
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
371 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: 26014
diff changeset
372 gpointer value, gpointer user_data)
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
373 {
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
374 JingleSession *session = (JingleSession *)value;
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
375 const gchar *jid = user_data;
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
376 gboolean use_bare = g_utf8_strchr(jid, -1, '/') == NULL;
26092
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
377 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: 26014
diff changeset
378 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: 26014
diff changeset
379 : g_strdup(remote_jid);
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
380 g_free(remote_jid);
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
381 if (g_str_equal(jid, cmp_jid)) {
26092
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
382 g_free(cmp_jid);
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
383 return TRUE;
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
384 }
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
385 g_free(cmp_jid);
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
386
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
387 return FALSE;
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
388 }
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
389
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
390 #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: 26386
diff changeset
391
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
392 /* 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: 26386
diff changeset
393 struct session_find_jid
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
394 {
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
395 const gchar *jid;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
396 JingleSession *ret;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
397 gboolean use_bare;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
398 };
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
399
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
400 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: 26386
diff changeset
401 {
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
402 JingleSession *session = (JingleSession *)value;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
403 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: 26386
diff changeset
404 gchar *remote_jid;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
405 gchar *cmp_jid;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
406
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
407 if (data->ret != NULL)
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
408 return;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
409
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
410 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: 26386
diff changeset
411 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: 26386
diff changeset
412 : g_strdup(remote_jid);
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
413 g_free(remote_jid);
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
414
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
415 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: 26386
diff changeset
416 data->ret = session;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
417
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
418 g_free(cmp_jid);
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
419 }
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
420 #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: 26386
diff changeset
421
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
422 JingleSession *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
423 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
424 {
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
425 #if GLIB_CHECK_VERSION(2,4,0)
26092
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
426 return js->sessions != NULL ?
db517c55c508 Make it compile in Windows with the equivalent of --disable-vv.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26014
diff changeset
427 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: 26014
diff changeset
428 find_by_jid_ghr, (gpointer)jid) : NULL;
26814
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
429 #else
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
430 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: 26386
diff changeset
431
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
432 if (js->sessions == NULL)
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
433 return NULL;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
434
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
435 data.jid = jid;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
436 data.ret = NULL;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
437 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: 26386
diff changeset
438
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
439 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: 26386
diff changeset
440 return data.ret;
d1a0c36cc4ea Provide alternative find_by_jid that doesn't use g_hash_table_find
Paul Aurich <paul@darkrain42.org>
parents: 26386
diff changeset
441 #endif
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
442 }
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 static xmlnode *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
445 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
446 JabberIq *iq, JingleActionType action)
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
447 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
448 xmlnode *jingle = iq ?
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
449 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
450 xmlnode_new("jingle");
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
451 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
452 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
453
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
454 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
455 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
456
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
457 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
458 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
459 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
460 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
461 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
462 } else {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
463 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
464 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
465 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
466 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
467 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
468
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
469 g_free(local_jid);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
470 g_free(remote_jid);
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 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
473
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
474 return 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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
477 JabberIq *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
478 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
479 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
480 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
481 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
482 JABBER_IQ_RESULT);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
483 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
484 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
485 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
486 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
487 return result;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
490 static JabberIq *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
491 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
492 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
493 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
494 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
495 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
496 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
497
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
498 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
499 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
500
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
501 g_free(from);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
502 g_free(to);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
503 return result;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
506 xmlnode *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
507 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
508 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
509 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
510 GList *iter;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
511 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
512 || action == JINGLE_CONTENT_ADD
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
513 || action == JINGLE_CONTENT_REMOVE)
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
514 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
515 else
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
516 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
517
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
518 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
519 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
520 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
521 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
522 return jingle;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
525 JabberIq *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
526 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
527 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
528 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
529 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
530 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
531 return iq;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
532 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
533
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
534 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
535 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
536 GList *iter;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
537 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
538 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
539 else
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
540 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
541
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
542 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
543 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
544 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
547 JingleContent *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
548 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
549 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
550 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
551 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
552 JingleContent *content = iter->data;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
553 gchar *cname = jingle_content_get_name(content);
26383
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
554 gboolean result = !strcmp(name, cname);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
555 g_free(cname);
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
556
26383
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
557 if (creator != NULL) {
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
558 gchar *ccreator = jingle_content_get_creator(content);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
559 result = (result && !strcmp(creator, ccreator));
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
560 g_free(ccreator);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
561 }
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
562
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
563 if (result == TRUE)
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
564 return content;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
565 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
566 return NULL;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
569 JingleContent *
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
570 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
571 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
572 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
573 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
574 JingleContent *content = iter->data;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
575 gchar *cname = jingle_content_get_name(content);
26383
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
576 gboolean result = !strcmp(name, cname);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
577 g_free(cname);
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
578
26383
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
579 if (creator != NULL) {
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
580 gchar *ccreator = jingle_content_get_creator(content);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
581 result = (result && !strcmp(creator, ccreator));
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
582 g_free(ccreator);
08e4ad2fcd63 Have creator == NULL be a wildcard.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26373
diff changeset
583 }
26014
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
584
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
585 if (result == TRUE)
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
586 return content;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
587 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
588 return NULL;
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
591 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
592 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
593 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
594 session->priv->contents =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
595 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
596 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
597 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
598
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
599 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
600 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
601 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
602 JingleContent *content =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
603 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
604
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
605 if (content) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
606 session->priv->contents =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
607 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
608 g_object_unref(content);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
609 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
612 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
613 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
614 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
615 session->priv->pending_contents =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
616 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
617 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
618 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
619
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
620 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
621 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
622 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
623 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
624
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
625 if (content) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
626 session->priv->pending_contents =
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
627 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
628 g_object_unref(content);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
629 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
632 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
633 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
634 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
635 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
636
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
637 if (content) {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
638 g_object_ref(content);
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
639 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
640 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
641 }
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
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
644 void
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
645 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
646 {
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
647 session->priv->state = TRUE;
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
648 }
bd598b606ca4 Restructure Jingle code to more easily support multiple application types.
Mike Ruprecht <maiku@soc.pidgin.im>
parents:
diff changeset
649
26366
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
650 JabberIq *
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
651 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: 26092
diff changeset
652 {
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
653 JabberIq *iq = jingle_session_to_packet(session,
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
654 JINGLE_SESSION_TERMINATE);
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
655 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: 26092
diff changeset
656
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
657 if (reason != NULL) {
26385
3824cd706fa3 Silence a warning.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26366
diff changeset
658 xmlnode *reason_node;
26366
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
659 reason_node = xmlnode_new_child(jingle, "reason");
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
660 xmlnode_new_child(reason_node, reason);
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
661 }
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
662 return iq;
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
663 }
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
664
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
665 JabberIq *
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
666 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: 26092
diff changeset
667 {
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
668 JabberIq *iq = jingle_session_terminate_packet(session,
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
669 "alternative-session");
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
670 xmlnode *alt_session;
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
671
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
672 if (sid == NULL)
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
673 return iq;
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
674
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
675 alt_session = xmlnode_get_child(iq->node,
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
676 "jingle/reason/alternative-session");
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
677
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
678 if (alt_session != NULL) {
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
679 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: 26092
diff changeset
680 xmlnode_insert_data(sid_node, sid, -1);
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
681 }
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
682 return iq;
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
683 }
4f47eeaa1414 Add functions for more easily creating session-terminate packets.
Mike Ruprecht <maiku@soc.pidgin.im>
parents: 26092
diff changeset
684