Mercurial > pidgin
annotate libpurple/protocols/jabber/ibb.c @ 28509:17617d892bc4
oscar: Properly support TLS when using clientLogin.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Fri, 06 Nov 2009 03:58:26 +0000 |
parents | 7921a53b94b3 |
children | 7b4ade7c6d8a |
rev | line source |
---|---|
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
1 /* |
28047
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
26803
diff
changeset
|
2 * Purple is the legal property of its developers, whose names are too numerous |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
26803
diff
changeset
|
3 * to list here. Please refer to the COPYRIGHT file distributed with this |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
26803
diff
changeset
|
4 * source distribution. |
8c991e09efcb
Update various header copyrights thanks to licensecheck.
Paul Aurich <paul@darkrain42.org>
parents:
26803
diff
changeset
|
5 * |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
6 * 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
|
7 * 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
|
8 * 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
|
9 * (at your option) any later version. |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
10 * |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
11 * 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
|
12 * 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
|
13 * 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
|
14 * GNU Library General Public License for more details. |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
15 * |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
16 * 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
|
17 * along with this program; if not, write to the Free Software |
28070
7921a53b94b3
Oops, Elliott correctly pointed out this was wrong...
Paul Aurich <paul@darkrain42.org>
parents:
28047
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
19 */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
20 |
25719
dc01f9b0aaa3
Patch from Phil Hannent to fix build on win32,
Marcus Lundblad <ml@update.uu.se>
parents:
25129
diff
changeset
|
21 #include "internal.h" |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
22 #include "ibb.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
23 #include "debug.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
24 #include "xmlnode.h" |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
25 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
26 #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
|
27 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
28 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
|
29 static GList *open_handlers = NULL; |
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 * |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
32 jabber_ibb_session_create(JabberStream *js, const gchar *sid, const gchar *who, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
33 gpointer user_data) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
34 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
35 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
|
36 sess->js = js; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
37 if (sid) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
38 sess->sid = g_strdup(sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
39 } else { |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
40 sess->sid = jabber_get_next_id(js); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
41 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
42 sess->who = g_strdup(who); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
43 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
|
44 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
|
45 sess->user_data = user_data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
46 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
47 g_hash_table_insert(jabber_ibb_sessions, sess->sid, sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
48 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
49 return sess; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
50 } |
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 * |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
53 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:
26465
diff
changeset
|
54 const char *id, xmlnode *open, gpointer user_data) |
25129
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 JabberIBBSession *sess = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
57 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
|
58 const gchar *block_size = xmlnode_get_attrib(open, "block-size"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
59 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
60 if (!open) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
61 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
62 } |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
63 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
64 if (!sid || !block_size) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
65 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
66 "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
|
67 g_free(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
68 return NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
69 } |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
70 |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
71 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:
26465
diff
changeset
|
72 sess->id = g_strdup(id); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
73 sess->block_size = atoi(block_size); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
74 /* 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
|
75 session is immediatly open... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
76 sess->state = JABBER_IBB_SESSION_OPENED; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
77 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
78 return sess; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
79 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
80 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
81 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
82 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
|
83 { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
84 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
|
85 sess->sid); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
86 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
87 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
|
88 jabber_ibb_session_close(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
89 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
90 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
91 if (sess->last_iq_id) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
92 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
|
93 sess->last_iq_id); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
94 jabber_iq_remove_callback_by_id(jabber_ibb_session_get_js(sess), |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
95 sess->last_iq_id); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
96 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
|
97 sess->last_iq_id = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
98 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
99 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
100 g_hash_table_remove(jabber_ibb_sessions, sess->sid); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
101 g_free(sess->id); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
102 g_free(sess->sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
103 g_free(sess->who); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
104 g_free(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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
107 const gchar * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
108 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
|
109 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
110 return sess->sid; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
113 JabberStream * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
114 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
|
115 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
116 return sess->js; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
119 const gchar * |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
120 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
|
121 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
122 return sess->who; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
125 guint16 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
126 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
|
127 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
128 return sess->send_seq; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
131 guint16 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
132 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
|
133 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
134 return sess->recv_seq; |
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 |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
137 JabberIBBSessionState |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
138 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
|
139 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
140 return sess->state; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
143 gsize |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
144 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
|
145 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
146 return sess->block_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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
149 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
150 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
|
151 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
152 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
|
153 sess->block_size = size; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
154 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
155 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
156 "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
|
157 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
160 gpointer |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
161 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
|
162 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
163 return sess->user_data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
164 } |
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 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
167 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
|
168 JabberIBBOpenedCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
169 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
170 sess->opened_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
171 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
172 |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
173 void |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
174 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
|
175 JabberIBBSentCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
176 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
177 sess->data_sent_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
178 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
179 |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
180 void |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
181 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
|
182 JabberIBBClosedCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
183 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
184 sess->closed_cb = cb; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
185 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
186 |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
187 void |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
188 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
|
189 JabberIBBDataCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
190 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
191 sess->data_received_cb = cb; |
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 |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
194 void |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
195 jabber_ibb_session_set_error_callback(JabberIBBSession *sess, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
196 JabberIBBErrorCallback *cb) |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
197 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
198 sess->error_cb = cb; |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
201 static void |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
202 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:
25952
diff
changeset
|
203 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:
25952
diff
changeset
|
204 xmlnode *packet, gpointer data) |
25129
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 JabberIBBSession *sess = (JabberIBBSession *) data; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
207 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
208 if (type == JABBER_IQ_ERROR) { |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
209 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
|
210 } else { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
211 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
|
212 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
213 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
214 if (sess->opened_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
215 sess->opened_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
216 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
219 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
220 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
|
221 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
222 if (jabber_ibb_session_get_state(sess) != JABBER_IBB_SESSION_NOT_OPENED) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
223 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
224 "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
|
225 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
226 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
|
227 xmlnode *open = xmlnode_new("open"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
228 gchar block_size[10]; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
229 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
230 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
|
231 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
|
232 xmlnode_set_attrib(open, "sid", jabber_ibb_session_get_sid(sess)); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
233 g_snprintf(block_size, sizeof(block_size), "%" G_GSIZE_FORMAT, |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
234 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
|
235 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
|
236 xmlnode_insert_child(set->node, open); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
237 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
238 jabber_iq_set_callback(set, jabber_ibb_session_opened_cb, sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
239 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
240 jabber_iq_send(set); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
241 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
244 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
245 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
|
246 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
247 JabberIBBSessionState state = jabber_ibb_session_get_state(sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
248 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
249 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
|
250 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
251 "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
|
252 "opened\n"); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
253 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
254 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
|
255 JABBER_IQ_SET); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
256 xmlnode *close = xmlnode_new("close"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
257 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
258 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
|
259 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
|
260 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
|
261 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
|
262 jabber_iq_send(set); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
263 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
|
264 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
267 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
268 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
|
269 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
270 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
|
271 JABBER_IQ_RESULT); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
272 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
273 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
|
274 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
|
275 jabber_iq_send(result); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
276 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
|
277 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
278 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
279 static void |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
280 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:
25952
diff
changeset
|
281 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:
25952
diff
changeset
|
282 xmlnode *packet, gpointer data) |
25129
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 JabberIBBSession *sess = (JabberIBBSession *) data; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
285 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
286 if (sess) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
287 /* reset callback */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
288 if (sess->last_iq_id) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
289 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
|
290 sess->last_iq_id = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
291 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
292 |
26465
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25952
diff
changeset
|
293 if (type == JABBER_IQ_ERROR) { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
294 jabber_ibb_session_close(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
295 sess->state = JABBER_IBB_SESSION_ERROR; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
296 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
297 if (sess->error_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
298 sess->error_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 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
301 if (sess->data_sent_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
302 sess->data_sent_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
303 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
304 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
305 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
306 /* the session has gone away, it was probably cancelled */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
307 purple_debug_info("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
308 "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
|
309 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
310 } |
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 void |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
313 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:
25755
diff
changeset
|
314 gsize size) |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
315 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
316 JabberIBBSessionState state = jabber_ibb_session_get_state(sess); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
317 |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
318 purple_debug_info("jabber", "sending data block of %" G_GSIZE_FORMAT " 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
|
319 size); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
320 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
321 if (state != JABBER_IBB_SESSION_OPENED) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
322 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
323 "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
|
324 } else if (size > jabber_ibb_session_get_block_size(sess)) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
325 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
326 "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
|
327 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
328 JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess), |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
329 JABBER_IQ_SET); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
330 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
|
331 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
|
332 char seq[10]; |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
333 g_snprintf(seq, sizeof(seq), "%u", jabber_ibb_session_get_send_seq(sess)); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
334 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
335 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
|
336 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
|
337 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
|
338 xmlnode_set_attrib(data_element, "seq", seq); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
339 xmlnode_insert_data(data_element, base64, -1); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
340 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
341 xmlnode_insert_child(set->node, data_element); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
342 |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
343 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
|
344 "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
|
345 sess->sid); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
346 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
|
347 sess->last_iq_id = g_strdup(xmlnode_get_attrib(set->node, "id")); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
348 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:
25755
diff
changeset
|
349 sess->last_iq_id); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
350 jabber_iq_send(set); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
351 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
352 g_free(base64); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
353 (sess->send_seq)++; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
354 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
355 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
356 |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
357 static void |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
358 jabber_ibb_send_error_response(JabberStream *js, const char *to, const char *id) |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
359 { |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
360 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
|
361 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
|
362 xmlnode *item_not_found = xmlnode_new("item-not-found"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
363 |
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
364 xmlnode_set_namespace(item_not_found, |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
365 "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
|
366 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
|
367 xmlnode_set_attrib(error, "type", "cancel"); |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
368 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:
26465
diff
changeset
|
369 xmlnode_set_attrib(result->node, "to", to); |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
370 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
|
371 xmlnode_insert_child(result->node, error); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
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 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
|
374 } |
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
375 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
376 void |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
377 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:
26465
diff
changeset
|
378 const char *id, xmlnode *child) |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
379 { |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
380 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:
26465
diff
changeset
|
381 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:
26465
diff
changeset
|
382 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:
26465
diff
changeset
|
383 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:
26465
diff
changeset
|
384 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:
26465
diff
changeset
|
385 xmlnode_get_attrib(child, "sid") : NULL; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
386 JabberIBBSession *sess = |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
387 sid ? g_hash_table_lookup(jabber_ibb_sessions, sid) : NULL; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
388 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
389 if (sess) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
390 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
391 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
|
392 /* 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
|
393 session, ignore it */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
394 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
395 "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
|
396 } else if (data) { |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
397 const gchar *seq_attr = xmlnode_get_attrib(child, "seq"); |
25759
69cf692c09f5
Fix error handling on missing "seq" attribute
Marcus Lundblad <ml@update.uu.se>
parents:
25756
diff
changeset
|
398 guint16 seq = (seq_attr ? atoi(seq_attr) : 0); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
399 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
400 /* 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
|
401 out-of-order packet */ |
25759
69cf692c09f5
Fix error handling on missing "seq" attribute
Marcus Lundblad <ml@update.uu.se>
parents:
25756
diff
changeset
|
402 if (seq_attr && seq == jabber_ibb_session_get_recv_seq(sess)) { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
403 /* sequence # is the expected... */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
404 JabberIq *result = jabber_iq_new(js, JABBER_IQ_RESULT); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
405 |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
406 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:
26465
diff
changeset
|
407 xmlnode_set_attrib(result->node, "to", who); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
408 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
409 if (sess->data_received_cb) { |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
410 gchar *base64 = xmlnode_get_data(child); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
411 gsize size; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
412 gpointer rawdata = purple_base64_decode(base64, &size); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
413 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
414 g_free(base64); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
415 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
416 if (rawdata) { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
417 purple_debug_info("jabber", |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
418 "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:
25755
diff
changeset
|
419 size); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
420 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
|
421 purple_debug_error("jabber", |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
422 "IBB: received a too large packet\n"); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
423 if (sess->error_cb) |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
424 sess->error_cb(sess); |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
425 g_free(rawdata); |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
426 return; |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
427 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
428 purple_debug_info("jabber", |
25722
be762644486f
Actually close the assoiciated jsx when closing an IBB session.
Marcus Lundblad <ml@update.uu.se>
parents:
25719
diff
changeset
|
429 "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
|
430 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
|
431 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
432 g_free(rawdata); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
433 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
434 purple_debug_error("jabber", |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
435 "IBB: invalid BASE64 data received\n"); |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
436 if (sess->error_cb) |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
437 sess->error_cb(sess); |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
438 return; |
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
439 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
440 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
441 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
442 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
443 (sess->recv_seq)++; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
444 jabber_iq_send(result); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
445 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
446 } else { |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
447 purple_debug_error("jabber", |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
448 "Received an out-of-order/invalid IBB packet\n"); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
449 sess->state = JABBER_IBB_SESSION_ERROR; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
450 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
451 if (sess->error_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
452 sess->error_cb(sess); |
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 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
455 } else if (close) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
456 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
|
457 purple_debug_info("jabber", "IBB: received close\n"); |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
458 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
459 if (sess->closed_cb) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
460 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
|
461 sess->closed_cb(sess); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
462 } |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
463 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
464 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
465 /* this should never happen */ |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
466 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
|
467 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
468 } else if (open) { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
469 JabberIq *result; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
470 const GList *iterator; |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
471 |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
472 /* run all open handlers registered until one returns true */ |
25952
5f9a24d1c25e
Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
25759
diff
changeset
|
473 for (iterator = open_handlers ; iterator ; |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
474 iterator = g_list_next(iterator)) { |
25756
151b4054ce40
Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents:
25755
diff
changeset
|
475 JabberIBBOpenHandler *handler = iterator->data; |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
476 |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
477 if (handler(js, who, id, child)) { |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
478 result = jabber_iq_new(js, JABBER_IQ_RESULT); |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
479 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:
26465
diff
changeset
|
480 jabber_iq_set_id(result, id); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
481 jabber_iq_send(result); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
482 return; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
483 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
484 } |
25733
51cbb9be484e
Set state error on IBBSession if the receiver gives an error.
Marcus Lundblad <ml@update.uu.se>
parents:
25722
diff
changeset
|
485 /* no open callback returned success, reject */ |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
486 jabber_ibb_send_error_response(js, who, id); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
487 } else { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
488 /* send error reply */ |
26473
50ff0162fe26
Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents:
26465
diff
changeset
|
489 jabber_ibb_send_error_response(js, who, id); |
25129
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
490 } |
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 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
493 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
494 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
|
495 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
496 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
|
497 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
498 |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
499 void |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
500 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
|
501 { |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
502 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
|
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_init(void) |
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 jabber_ibb_sessions = g_hash_table_new(g_str_hash, g_str_equal); |
26479
4dc4d0aa25f5
Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
509 |
26803
1dfa009f6db5
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
26479
diff
changeset
|
510 jabber_add_feature(XEP_0047_NAMESPACE, NULL); |
1dfa009f6db5
Clean up jabber prpl memory allocations on uninit.
Nick Hebner <hebnern@gmail.com>
parents:
26479
diff
changeset
|
511 |
26479
4dc4d0aa25f5
Move some IQ handler registrations to the appropriate init functions
Paul Aurich <paul@darkrain42.org>
parents:
26473
diff
changeset
|
512 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:
26473
diff
changeset
|
513 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:
26473
diff
changeset
|
514 jabber_iq_register_handler("open", XEP_0047_NAMESPACE, jabber_ibb_parse); |
25129
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_uninit(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 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
|
521 g_list_free(open_handlers); |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
522 jabber_ibb_sessions = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
523 open_handlers = NULL; |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
524 } |
b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff
changeset
|
525 |