annotate libpurple/protocols/jabber/ibb.c @ 27170:5330ffe6ca86

Fix compile warning for non-VV.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 09 Jun 2009 03:42:23 +0000
parents 1dfa009f6db5
children 8c991e09efcb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
1 /*
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
2 * This program is free software; you can redistribute it and/or modify
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
3 * it under the terms of the GNU General Public License as published by
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
4 * the Free Software Foundation; either version 2 of the License, or
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
5 * (at your option) any later version.
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
6 *
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
7 * This program is distributed in the hope that it will be useful,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
10 * GNU Library General Public License for more details.
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
11 *
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
12 * You should have received a copy of the GNU General Public License
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
13 * along with this program; if not, write to the Free Software
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
15 */
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
16
25210
dc01f9b0aaa3 Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents: 23999
diff changeset
17 #include "internal.h"
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
18 #include "ibb.h"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
19 #include "debug.h"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
20 #include "xmlnode.h"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
21
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
22 #define JABBER_IBB_SESSION_DEFAULT_BLOCK_SIZE 4096
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
23
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
24 static GHashTable *jabber_ibb_sessions = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
25 static GList *open_handlers = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
26
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
27 JabberIBBSession *
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
28 jabber_ibb_session_create(JabberStream *js, const gchar *sid, const gchar *who,
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
29 gpointer user_data)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
30 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
31 JabberIBBSession *sess = g_new0(JabberIBBSession, 1);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
32 sess->js = js;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
33 if (sid) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
34 sess->sid = g_strdup(sid);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
35 } else {
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
36 sess->sid = jabber_get_next_id(js);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
37 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
38 sess->who = g_strdup(who);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
39 sess->block_size = JABBER_IBB_SESSION_DEFAULT_BLOCK_SIZE;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
40 sess->state = JABBER_IBB_SESSION_NOT_OPENED;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
41 sess->user_data = user_data;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
42
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
43 g_hash_table_insert(jabber_ibb_sessions, sess->sid, sess);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
44
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
45 return sess;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
46 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
47
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
48 JabberIBBSession *
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
49 jabber_ibb_session_create_from_xmlnode(JabberStream *js, const char *from,
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
50 const char *id, xmlnode *open, gpointer user_data)
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
51 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
52 JabberIBBSession *sess = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
53 const gchar *sid = xmlnode_get_attrib(open, "sid");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
54 const gchar *block_size = xmlnode_get_attrib(open, "block-size");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
55
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
56 if (!open) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
57 return NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
58 }
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
59
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
60 if (!sid || !block_size) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
61 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
62 "IBB session open tag requires sid and block-size attributes\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
63 g_free(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
64 return NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
65 }
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
66
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
67 sess = jabber_ibb_session_create(js, sid, from, user_data);
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
68 sess->id = g_strdup(id);
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
69 sess->block_size = atoi(block_size);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
70 /* if we create a session from an incoming <open/> request, it means the
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
71 session is immediatly open... */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
72 sess->state = JABBER_IBB_SESSION_OPENED;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
73
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
74 return sess;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
75 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
76
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
77 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
78 jabber_ibb_session_destroy(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
79 {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
80 purple_debug_info("jabber", "IBB: destroying session %p %s\n", sess,
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
81 sess->sid);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
82
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
83 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_OPENED) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
84 jabber_ibb_session_close(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
85 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
86
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
87 if (sess->last_iq_id) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
88 purple_debug_info("jabber", "IBB: removing callback for <iq/> %s\n",
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
89 sess->last_iq_id);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
90 jabber_iq_remove_callback_by_id(jabber_ibb_session_get_js(sess),
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
91 sess->last_iq_id);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
92 g_free(sess->last_iq_id);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
93 sess->last_iq_id = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
94 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
95
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
96 g_hash_table_remove(jabber_ibb_sessions, sess->sid);
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
97 g_free(sess->id);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
98 g_free(sess->sid);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
99 g_free(sess->who);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
100 g_free(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
101 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
102
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
103 const gchar *
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
104 jabber_ibb_session_get_sid(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
105 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
106 return sess->sid;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
107 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
108
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
109 JabberStream *
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
110 jabber_ibb_session_get_js(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
111 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
112 return sess->js;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
113 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
114
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
115 const gchar *
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
116 jabber_ibb_session_get_who(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
117 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
118 return sess->who;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
119 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
120
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
121 guint16
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
122 jabber_ibb_session_get_send_seq(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
123 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
124 return sess->send_seq;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
125 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
126
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
127 guint16
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
128 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
129 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
130 return sess->recv_seq;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
131 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
132
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
133 JabberIBBSessionState
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
134 jabber_ibb_session_get_state(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
135 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
136 return sess->state;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
137 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
138
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
139 gsize
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
140 jabber_ibb_session_get_block_size(const JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
141 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
142 return sess->block_size;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
143 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
144
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
145 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
146 jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
147 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
148 if (jabber_ibb_session_get_state(sess) == JABBER_IBB_SESSION_NOT_OPENED) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
149 sess->block_size = size;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
150 } else {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
151 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
152 "Can't set block size on an open IBB session\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
153 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
154 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
155
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
156 gpointer
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
157 jabber_ibb_session_get_user_data(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
158 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
159 return sess->user_data;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
160 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
161
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
162 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
163 jabber_ibb_session_set_opened_callback(JabberIBBSession *sess,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
164 JabberIBBOpenedCallback *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
165 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
166 sess->opened_cb = cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
167 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
168
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
169 void
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
170 jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
171 JabberIBBSentCallback *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
172 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
173 sess->data_sent_cb = cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
174 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
175
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
176 void
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
177 jabber_ibb_session_set_closed_callback(JabberIBBSession *sess,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
178 JabberIBBClosedCallback *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
179 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
180 sess->closed_cb = cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
181 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
182
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
183 void
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
184 jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
185 JabberIBBDataCallback *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
186 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
187 sess->data_received_cb = cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
188 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
189
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
190 void
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
191 jabber_ibb_session_set_error_callback(JabberIBBSession *sess,
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
192 JabberIBBErrorCallback *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
193 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
194 sess->error_cb = cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
195 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
196
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
197 static void
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
198 jabber_ibb_session_opened_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
199 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
200 xmlnode *packet, gpointer data)
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
201 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
202 JabberIBBSession *sess = (JabberIBBSession *) data;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
203
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
204 if (type == JABBER_IQ_ERROR) {
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
205 sess->state = JABBER_IBB_SESSION_ERROR;
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
206 } else {
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
207 sess->state = JABBER_IBB_SESSION_OPENED;
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
208 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
209
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
210 if (sess->opened_cb) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
211 sess->opened_cb(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
212 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
213 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
214
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
215 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
216 jabber_ibb_session_open(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
217 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
218 if (jabber_ibb_session_get_state(sess) != JABBER_IBB_SESSION_NOT_OPENED) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
219 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
220 "jabber_ibb_session called on an already open stream\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
221 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
222 JabberIq *set = jabber_iq_new(sess->js, JABBER_IQ_SET);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
223 xmlnode *open = xmlnode_new("open");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
224 gchar block_size[10];
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
225
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
226 xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
227 xmlnode_set_namespace(open, XEP_0047_NAMESPACE);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
228 xmlnode_set_attrib(open, "sid", jabber_ibb_session_get_sid(sess));
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
229 g_snprintf(block_size, sizeof(block_size), "%" G_GSIZE_FORMAT,
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
230 jabber_ibb_session_get_block_size(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
231 xmlnode_set_attrib(open, "block-size", block_size);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
232 xmlnode_insert_child(set->node, open);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
233
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
234 jabber_iq_set_callback(set, jabber_ibb_session_opened_cb, sess);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
235
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
236 jabber_iq_send(set);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
237 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
238 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
239
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
240 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
241 jabber_ibb_session_close(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
242 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
243 JabberIBBSessionState state = jabber_ibb_session_get_state(sess);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
244
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
245 if (state != JABBER_IBB_SESSION_OPENED && state != JABBER_IBB_SESSION_ERROR) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
246 purple_debug_error("jabber",
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
247 "jabber_ibb_session_close called on a session that has not been"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
248 "opened\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
249 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
250 JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
251 JABBER_IQ_SET);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
252 xmlnode *close = xmlnode_new("close");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
253
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
254 xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
255 xmlnode_set_namespace(close, XEP_0047_NAMESPACE);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
256 xmlnode_set_attrib(close, "sid", jabber_ibb_session_get_sid(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
257 xmlnode_insert_child(set->node, close);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
258 jabber_iq_send(set);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
259 sess->state = JABBER_IBB_SESSION_CLOSED;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
260 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
261 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
262
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
263 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
264 jabber_ibb_session_accept(JabberIBBSession *sess)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
265 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
266 JabberIq *result = jabber_iq_new(jabber_ibb_session_get_js(sess),
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
267 JABBER_IQ_RESULT);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
268
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
269 xmlnode_set_attrib(result->node, "to", jabber_ibb_session_get_who(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
270 jabber_iq_set_id(result, sess->id);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
271 jabber_iq_send(result);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
272 sess->state = JABBER_IBB_SESSION_OPENED;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
273 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
274
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
275 static void
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
276 jabber_ibb_session_send_acknowledge_cb(JabberStream *js, const char *from,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
277 JabberIqType type, const char *id,
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
278 xmlnode *packet, gpointer data)
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
279 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
280 JabberIBBSession *sess = (JabberIBBSession *) data;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
281
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
282 if (sess) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
283 /* reset callback */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
284 if (sess->last_iq_id) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
285 g_free(sess->last_iq_id);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
286 sess->last_iq_id = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
287 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
288
26547
ae41d8e827e3 Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents: 25443
diff changeset
289 if (type == JABBER_IQ_ERROR) {
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
290 jabber_ibb_session_close(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
291 sess->state = JABBER_IBB_SESSION_ERROR;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
292
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
293 if (sess->error_cb) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
294 sess->error_cb(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
295 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
296 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
297 if (sess->data_sent_cb) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
298 sess->data_sent_cb(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
299 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
300 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
301 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
302 /* the session has gone away, it was probably cancelled */
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
303 purple_debug_info("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
304 "got response from send data, but IBB session is no longer active\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
305 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
306 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
307
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
308 void
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
309 jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
310 gsize size)
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
311 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
312 JabberIBBSessionState state = jabber_ibb_session_get_state(sess);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
313
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
314 purple_debug_info("jabber", "sending data block of %" G_GSIZE_FORMAT " bytes on IBB stream\n",
25213
be762644486f Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents: 25210
diff changeset
315 size);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
316
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
317 if (state != JABBER_IBB_SESSION_OPENED) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
318 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
319 "trying to send data on a non-open IBB session\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
320 } else if (size > jabber_ibb_session_get_block_size(sess)) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
321 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
322 "trying to send a too large packet in the IBB session\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
323 } else {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
324 JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess),
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
325 JABBER_IQ_SET);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
326 xmlnode *data_element = xmlnode_new("data");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
327 char *base64 = purple_base64_encode(data, size);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
328 char seq[10];
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
329 g_snprintf(seq, sizeof(seq), "%u", jabber_ibb_session_get_send_seq(sess));
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
330
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
331 xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
332 xmlnode_set_namespace(data_element, XEP_0047_NAMESPACE);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
333 xmlnode_set_attrib(data_element, "sid", jabber_ibb_session_get_sid(sess));
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
334 xmlnode_set_attrib(data_element, "seq", seq);
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
335 xmlnode_insert_data(data_element, base64, -1);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
336
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
337 xmlnode_insert_child(set->node, data_element);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
338
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
339 purple_debug_info("jabber",
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
340 "IBB: setting send <iq/> callback for session %p %s\n", sess,
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
341 sess->sid);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
342 jabber_iq_set_callback(set, jabber_ibb_session_send_acknowledge_cb, sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
343 sess->last_iq_id = g_strdup(xmlnode_get_attrib(set->node, "id"));
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
344 purple_debug_info("jabber", "IBB: set sess->last_iq_id: %s\n",
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
345 sess->last_iq_id);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
346 jabber_iq_send(set);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
347
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
348 g_free(base64);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
349 (sess->send_seq)++;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
350 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
351 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
352
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
353 static void
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
354 jabber_ibb_send_error_response(JabberStream *js, const char *to, const char *id)
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
355 {
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
356 JabberIq *result = jabber_iq_new(js, JABBER_IQ_ERROR);
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
357 xmlnode *error = xmlnode_new("error");
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
358 xmlnode *item_not_found = xmlnode_new("item-not-found");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
359
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
360 xmlnode_set_namespace(item_not_found,
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
361 "urn:ietf:params:xml:ns:xmpp-stanzas");
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
362 xmlnode_set_attrib(error, "code", "440");
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
363 xmlnode_set_attrib(error, "type", "cancel");
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
364 jabber_iq_set_id(result, id);
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
365 xmlnode_set_attrib(result->node, "to", to);
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
366 xmlnode_insert_child(error, item_not_found);
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
367 xmlnode_insert_child(result->node, error);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
368
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
369 jabber_iq_send(result);
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
370 }
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
371
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
372 void
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
373 jabber_ibb_parse(JabberStream *js, const char *who, JabberIqType type,
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
374 const char *id, xmlnode *child)
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
375 {
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
376 const char *name = child->name;
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
377 gboolean data = g_str_equal(name, "data");
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
378 gboolean close = g_str_equal(name, "close");
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
379 gboolean open = g_str_equal(name, "open");
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
380 const gchar *sid = (data || close) ?
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
381 xmlnode_get_attrib(child, "sid") : NULL;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
382 JabberIBBSession *sess =
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
383 sid ? g_hash_table_lookup(jabber_ibb_sessions, sid) : NULL;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
384
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
385 if (sess) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
386
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
387 if (strcmp(who, jabber_ibb_session_get_who(sess)) != 0) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
388 /* the iq comes from a different JID than the remote JID of the
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
389 session, ignore it */
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
390 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
391 "Got IBB iq from wrong JID, ignoring\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
392 } else if (data) {
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
393 const gchar *seq_attr = xmlnode_get_attrib(child, "seq");
25250
69cf692c09f5 Fix error handling on missing "seq" attribute
Marcus Lundblad <ml@update.uu.se>
parents: 25247
diff changeset
394 guint16 seq = (seq_attr ? atoi(seq_attr) : 0);
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
395
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
396 /* reject the data, and set the session in error if we get an
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
397 out-of-order packet */
25250
69cf692c09f5 Fix error handling on missing "seq" attribute
Marcus Lundblad <ml@update.uu.se>
parents: 25247
diff changeset
398 if (seq_attr && seq == jabber_ibb_session_get_recv_seq(sess)) {
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
399 /* sequence # is the expected... */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
400 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
401
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
402 jabber_iq_set_id(result, id);
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
403 xmlnode_set_attrib(result->node, "to", who);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
404
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
405 if (sess->data_received_cb) {
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
406 gchar *base64 = xmlnode_get_data(child);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
407 gsize size;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
408 gpointer rawdata = purple_base64_decode(base64, &size);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
409
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
410 g_free(base64);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
411
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
412 if (rawdata) {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
413 purple_debug_info("jabber",
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
414 "got %" G_GSIZE_FORMAT " bytes of data on IBB stream\n",
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
415 size);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
416 if (size > jabber_ibb_session_get_block_size(sess)) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
417 purple_debug_error("jabber",
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
418 "IBB: received a too large packet\n");
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
419 if (sess->error_cb)
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
420 sess->error_cb(sess);
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
421 g_free(rawdata);
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
422 return;
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
423 } else {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
424 purple_debug_info("jabber",
25213
be762644486f Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents: 25210
diff changeset
425 "calling IBB callback for received data\n");
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
426 sess->data_received_cb(sess, rawdata, size);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
427 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
428 g_free(rawdata);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
429 } else {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
430 purple_debug_error("jabber",
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
431 "IBB: invalid BASE64 data received\n");
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
432 if (sess->error_cb)
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
433 sess->error_cb(sess);
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
434 return;
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
435
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
436 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
437 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
438
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
439 (sess->recv_seq)++;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
440 jabber_iq_send(result);
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
441
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
442 } else {
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
443 purple_debug_error("jabber",
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
444 "Received an out-of-order/invalid IBB packet\n");
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
445 sess->state = JABBER_IBB_SESSION_ERROR;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
446
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
447 if (sess->error_cb) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
448 sess->error_cb(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
449 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
450 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
451 } else if (close) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
452 sess->state = JABBER_IBB_SESSION_CLOSED;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
453 purple_debug_info("jabber", "IBB: received close\n");
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
454
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
455 if (sess->closed_cb) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
456 purple_debug_info("jabber", "IBB: calling closed handler\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
457 sess->closed_cb(sess);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
458 }
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
459
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
460 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
461 /* this should never happen */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
462 purple_debug_error("jabber", "Received bogus iq for IBB session\n");
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
463 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
464 } else if (open) {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
465 JabberIq *result;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
466 const GList *iterator;
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
467
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
468 /* run all open handlers registered until one returns true */
25443
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25250
diff changeset
469 for (iterator = open_handlers ; iterator ;
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
470 iterator = g_list_next(iterator)) {
25247
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25246
diff changeset
471 JabberIBBOpenHandler *handler = iterator->data;
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
472
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
473 if (handler(js, who, id, child)) {
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
474 result = jabber_iq_new(js, JABBER_IQ_RESULT);
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
475 xmlnode_set_attrib(result->node, "to", who);
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
476 jabber_iq_set_id(result, id);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
477 jabber_iq_send(result);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
478 return;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
479 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
480 }
25224
51cbb9be484e Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents: 25213
diff changeset
481 /* no open callback returned success, reject */
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
482 jabber_ibb_send_error_response(js, who, id);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
483 } else {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
484 /* send error reply */
26555
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 26547
diff changeset
485 jabber_ibb_send_error_response(js, who, id);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
486 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
487 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
488
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
489 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
490 jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
491 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
492 open_handlers = g_list_append(open_handlers, cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
493 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
494
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
495 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
496 jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
497 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
498 open_handlers = g_list_remove(open_handlers, cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
499 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
500
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
501 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
502 jabber_ibb_init(void)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
503 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
504 jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal);
26561
4dc4d0aa25f5 Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents: 26555
diff changeset
505
26885
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26561
diff changeset
506 jabber_add_feature(XEP_0047_NAMESPACE, NULL);
1dfa009f6db5 Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents: 26561
diff changeset
507
26561
4dc4d0aa25f5 Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents: 26555
diff changeset
508 jabber_iq_register_handler("close", XEP_0047_NAMESPACE, jabber_ibb_parse);
4dc4d0aa25f5 Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents: 26555
diff changeset
509 jabber_iq_register_handler("data", XEP_0047_NAMESPACE, jabber_ibb_parse);
4dc4d0aa25f5 Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents: 26555
diff changeset
510 jabber_iq_register_handler("open", XEP_0047_NAMESPACE, jabber_ibb_parse);
23999
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
511 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
512
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
513 void
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
514 jabber_ibb_uninit(void)
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
515 {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
516 g_hash_table_destroy(jabber_ibb_sessions);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
517 g_list_free(open_handlers);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
518 jabber_ibb_sessions = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
519 open_handlers = NULL;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
520 }
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
521