Mercurial > pidgin
annotate libpurple/protocols/jabber/ibb.c @ 25755:3918ed48d7a8
Removed debug output referencing a char * that can be NULL, causing crashes
on Windows.
Besides, the output wasn't really needed.
Thanks Phil, for finding this one...
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Mon, 15 Dec 2008 23:13:49 +0000 |
parents | 51cbb9be484e |
children | 151b4054ce40 |
rev | line source |
---|---|
25129
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. |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
6 * |
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. |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * |
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 */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
16 |
25719
dc01f9b0aaa3
Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents:
25129
diff
changeset
|
17 #include <glib.h> |
dc01f9b0aaa3
Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents:
25129
diff
changeset
|
18 #include <string.h> |
dc01f9b0aaa3
Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents:
25129
diff
changeset
|
19 |
dc01f9b0aaa3
Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents:
25129
diff
changeset
|
20 #include "internal.h" |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
21 #include "ibb.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 #include "debug.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
23 #include "xmlnode.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
24 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
25 #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
|
26 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
27 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
|
28 static GList *open_handlers = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
29 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
30 JabberIBBSession * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
31 jabber_ibb_session_create(JabberStream *js, const gchar *sid, const gchar *who, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
32 gpointer user_data) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
33 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
34 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
|
35 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
36 if (!sess) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
37 purple_debug_error("jabber", "Could not allocate IBB session object\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
38 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
40 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
41 sess->js = js; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
42 if (sid) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 sess->sid = g_strdup(sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
44 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
45 sess->sid = g_strdup(jabber_get_next_id(js)); |
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 sess->who = g_strdup(who); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
48 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
|
49 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
|
50 sess->user_data = user_data; |
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 g_hash_table_insert(jabber_ibb_sessions, sess->sid, sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
53 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
54 return sess; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
55 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
56 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
57 JabberIBBSession * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
58 jabber_ibb_session_create_from_xmlnode(JabberStream *js, xmlnode *packet, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
59 gpointer user_data) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
60 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
61 JabberIBBSession *sess = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
62 xmlnode *open = xmlnode_get_child_with_namespace(packet, "open", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
63 XEP_0047_NAMESPACE); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
64 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
|
65 const gchar *block_size = xmlnode_get_attrib(open, "block-size"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 gsize block_size_int; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
67 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
68 if (!open) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
69 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
70 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
71 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
72 sess = g_new0(JabberIBBSession, 1); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
73 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
74 if (!sess) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
75 purple_debug_error("jabber", "Could not allocate IBB session object\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
76 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
77 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
78 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
79 if (!sid || !block_size) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
81 "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
|
82 g_free(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
83 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
84 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
85 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
86 block_size_int = atoi(block_size); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
87 sess->js = js; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
88 sess->sid = g_strdup(sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
89 sess->id = g_strdup(xmlnode_get_attrib(packet, "id")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
90 sess->who = g_strdup(xmlnode_get_attrib(packet, "from")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
91 sess->block_size = block_size_int; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 /* 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
|
93 session is immediatly open... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
94 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
|
95 sess->user_data = user_data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
96 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
97 g_hash_table_insert(jabber_ibb_sessions, sess->sid, sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
98 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
99 return sess; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 } |
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 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 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
|
104 { |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
105 purple_debug_info("jabber", "IBB: destroying session %p %s\n", sess, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
106 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 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
|
109 jabber_ibb_session_close(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
110 } |
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 if (sess->last_iq_id) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
113 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
|
114 sess->last_iq_id); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
115 jabber_iq_remove_callback_by_id(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
|
116 sess->last_iq_id); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
117 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
|
118 sess->last_iq_id = NULL; |
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 g_hash_table_remove(jabber_ibb_sessions, sess->sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
122 g_free(sess->sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
123 g_free(sess->who); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
124 g_free(sess); |
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 const gchar * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
128 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
|
129 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
130 return sess->sid; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
133 JabberStream * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
134 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
|
135 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
136 return sess->js; |
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 const gchar * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 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
|
141 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
142 return sess->who; |
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 guint16 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 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
|
147 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
148 return sess->send_seq; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
151 guint16 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 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
|
153 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 return sess->recv_seq; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
157 JabberIBBSessionState |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
158 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
|
159 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
160 return sess->state; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
163 gsize |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
164 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
|
165 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
166 return sess->block_size; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
167 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
168 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
169 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
170 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
|
171 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
172 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
|
173 sess->block_size = size; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
174 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
175 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
176 "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
|
177 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
178 } |
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 gpointer |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 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
|
182 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
183 return sess->user_data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
184 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
185 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
186 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
187 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
|
188 JabberIBBOpenedCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
189 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
190 sess->opened_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
191 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
192 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
193 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
194 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
|
195 JabberIBBSentCallback *cb) |
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 sess->data_sent_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
198 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
199 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
200 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
201 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
|
202 JabberIBBClosedCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
203 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
204 sess->closed_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
205 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
206 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
208 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
|
209 JabberIBBDataCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
210 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
211 sess->data_received_cb = cb; |
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 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 jabber_ibb_session_set_error_callback(JabberIBBSession *sess, |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 JabberIBBErrorCallback *cb) |
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 sess->error_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
220 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
221 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
222 jabber_ibb_session_opened_cb(JabberStream *js, xmlnode *packet, gpointer data) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
223 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
224 JabberIBBSession *sess = (JabberIBBSession *) data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
225 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
226 if (strcmp(xmlnode_get_attrib(packet, "type"), "error") == 0) { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
227 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:
25722
diff
changeset
|
228 } else { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
229 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:
25722
diff
changeset
|
230 } |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
231 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
232 if (sess->opened_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
233 sess->opened_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
234 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
235 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
236 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
237 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
238 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
|
239 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
240 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
|
241 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
242 "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
|
243 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
244 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
|
245 xmlnode *open = xmlnode_new("open"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
246 gchar block_size[10]; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
247 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
248 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
|
249 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
|
250 xmlnode_set_attrib(open, "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
|
251 g_snprintf(block_size, sizeof(block_size), "%ld", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
252 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
|
253 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
|
254 xmlnode_insert_child(set->node, open); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
255 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
256 jabber_iq_set_callback(set, jabber_ibb_session_opened_cb, sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
257 |
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 } |
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 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
263 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
|
264 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
265 JabberIBBSessionState state = jabber_ibb_session_get_state(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
266 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
267 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
|
268 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
269 "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
|
270 "opened\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
271 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
272 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
|
273 JABBER_IQ_SET); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
274 xmlnode *close = xmlnode_new("close"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
275 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
276 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
|
277 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
|
278 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
|
279 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
|
280 jabber_iq_send(set); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
281 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
|
282 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
283 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
284 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
285 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
286 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
|
287 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
288 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
|
289 JABBER_IQ_RESULT); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
290 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
291 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
|
292 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
|
293 jabber_iq_send(result); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
294 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
|
295 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
296 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
297 static void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
298 jabber_ibb_session_send_acknowledge_cb(JabberStream *js, xmlnode *packet, gpointer data) |
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 JabberIBBSession *sess = (JabberIBBSession *) data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
301 xmlnode *error = xmlnode_get_child(packet, "error"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
302 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
303 if (sess) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
304 /* reset callback */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
305 if (sess->last_iq_id) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
306 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
|
307 sess->last_iq_id = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
308 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
309 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
310 if (error) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
311 jabber_ibb_session_close(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
312 sess->state = JABBER_IBB_SESSION_ERROR; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
313 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
314 if (sess->error_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
315 sess->error_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
316 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
317 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
318 if (sess->data_sent_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
319 sess->data_sent_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
320 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
321 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
322 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
323 /* the session has gone away, it was probably cancelled */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
324 purple_debug_info("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
325 "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
|
326 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
327 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
328 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
329 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
330 jabber_ibb_session_send_data(JabberIBBSession *sess, gpointer data, gsize size) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
331 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
332 JabberIBBSessionState state = jabber_ibb_session_get_state(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
333 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
334 purple_debug_info("jabber", "sending data block of %ld bytes on IBB stream\n", |
25722
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
335 size); |
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
336 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
337 if (state != JABBER_IBB_SESSION_OPENED) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
338 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
339 "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
|
340 } else 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
|
341 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
342 "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
|
343 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
344 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
|
345 JABBER_IQ_SET); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
346 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
|
347 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
|
348 char seq[10]; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
349 g_snprintf(seq, sizeof(seq), "%d", jabber_ibb_session_get_send_seq(sess)); |
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 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
|
352 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
|
353 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
|
354 xmlnode_set_attrib(data_element, "seq", seq); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
355 xmlnode_insert_data(data_element, base64, strlen(base64)); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
356 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
357 xmlnode_insert_child(set->node, data_element); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
358 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
359 purple_debug_info("jabber", |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
360 "IBB: setting send <iq/> callback for session %p %s\n", sess, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
361 sess->sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
362 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
|
363 sess->last_iq_id = g_strdup(xmlnode_get_attrib(set->node, "id")); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
364 purple_debug_info("jabber", "IBB: set sess->last_iq_id: %s %s\n", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
365 sess->last_iq_id, xmlnode_get_attrib(set->node, "id")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
366 jabber_iq_send(set); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
367 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
368 g_free(base64); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
369 (sess->send_seq)++; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
370 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
371 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
372 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
373 static void |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
374 jabber_ibb_send_error_response(JabberStream *js, xmlnode *packet) |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
375 { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
376 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:
25722
diff
changeset
|
377 xmlnode *error = xmlnode_new("error"); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
378 xmlnode *item_not_found = xmlnode_new("item-not-found"); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
379 |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
380 xmlnode_set_namespace(item_not_found, |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
381 "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:
25722
diff
changeset
|
382 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:
25722
diff
changeset
|
383 xmlnode_set_attrib(error, "type", "cancel"); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
384 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
385 xmlnode_set_attrib(result->node, "to", |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
386 xmlnode_get_attrib(packet, "from")); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
387 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:
25722
diff
changeset
|
388 xmlnode_insert_child(result->node, error); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
389 |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
390 jabber_iq_send(result); |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
391 } |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
392 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
393 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
394 jabber_ibb_parse(JabberStream *js, xmlnode *packet) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
395 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
396 xmlnode *data = xmlnode_get_child_with_namespace(packet, "data", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
397 XEP_0047_NAMESPACE); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
398 xmlnode *close = xmlnode_get_child_with_namespace(packet, "close", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
399 XEP_0047_NAMESPACE); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
400 xmlnode *open = xmlnode_get_child_with_namespace(packet, "open", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
401 XEP_0047_NAMESPACE); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
402 const gchar *sid = |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
403 data ? xmlnode_get_attrib(data, "sid") : |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
404 close ? xmlnode_get_attrib(close, "sid") : NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
405 JabberIBBSession *sess = |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
406 sid ? g_hash_table_lookup(jabber_ibb_sessions, sid) : NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
407 const gchar *who = xmlnode_get_attrib(packet, "from"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
408 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
409 if (sess) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
410 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
411 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
|
412 /* 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
|
413 session, ignore it */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
414 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
415 "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
|
416 } else if (data) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
417 guint16 seq = atoi(xmlnode_get_attrib(data, "seq")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
418 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
419 /* 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
|
420 out-of-order packet */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
421 if (seq == jabber_ibb_session_get_recv_seq(sess)) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
422 /* sequence # is the expected... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
423 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
424 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
425 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
426 xmlnode_set_attrib(result->node, "to", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
427 xmlnode_get_attrib(packet, "from")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
428 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
429 if (sess->data_received_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
430 gchar *base64 = xmlnode_get_data(data); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
431 gsize size; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
432 gpointer rawdata = purple_base64_decode(base64, &size); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
433 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
434 g_free(base64); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
435 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
436 if (rawdata) { |
25722
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
437 purple_debug_info("jabber", |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
438 "got %ld bytes of data on IBB stream\n", size); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
439 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
|
440 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
441 "IBB: received a too large packet\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
442 } else { |
25722
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
443 purple_debug_info("jabber", |
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
444 "calling IBB callback for received data\n"); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
445 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
|
446 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
447 g_free(rawdata); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
448 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
449 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
450 "IBB: invalid BASE64 data received\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
451 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
452 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
453 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
454 (sess->recv_seq)++; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
455 jabber_iq_send(result); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
456 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
457 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
458 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
459 "Received an out-of-order IBB packet\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
460 sess->state = JABBER_IBB_SESSION_ERROR; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
461 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
462 if (sess->error_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
463 sess->error_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
464 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
465 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
466 } else if (close) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
467 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
|
468 purple_debug_info("jabber", "IBB: received close\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
469 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
470 if (sess->closed_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
471 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
|
472 sess->closed_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
473 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
474 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
475 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
476 /* this should never happen */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
477 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
|
478 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
479 } else if (open) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
480 JabberIq *result; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
481 const GList *iterator; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
482 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
483 /* run all open handlers registered until one returns true */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
484 for (iterator = open_handlers ; iterator ; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
485 iterator = g_list_next(iterator)) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
486 JabberIBBOpenHandler *handler = (JabberIBBOpenHandler *) iterator->data; |
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 if (handler(js, packet)) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
489 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
490 xmlnode_set_attrib(result->node, "to", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
491 xmlnode_get_attrib(packet, "from")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
492 jabber_iq_set_id(result, xmlnode_get_attrib(packet, "id")); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
493 jabber_iq_send(result); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
494 return; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
495 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
496 } |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
497 /* no open callback returned success, reject */ |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
498 jabber_ibb_send_error_response(js, packet); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
499 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
500 /* send error reply */ |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
501 jabber_ibb_send_error_response(js, packet); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
502 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
505 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
506 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
|
507 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
508 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
|
509 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
510 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
511 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
512 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
|
513 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
514 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
|
515 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
516 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
517 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
518 jabber_ibb_init(void) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
519 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
520 jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
521 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
522 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
523 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
524 jabber_ibb_uninit(void) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
525 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
526 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
|
527 g_list_free(open_handlers); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
528 jabber_ibb_sessions = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
529 open_handlers = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
530 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
531 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
532 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
533 |