annotate libpurple/protocols/jabber/ibb.h @ 26759:6faa5d5b4f44

Don't breaking if the user runs `/ping <user's server>` a bunch. jabber_register_account and jabber_login really need a common 'init JabberStream' function.
author Paul Aurich <paul@darkrain42.org>
date Thu, 30 Apr 2009 04:59:11 +0000
parents 5767b7698c73
children 8c991e09efcb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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.
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
6 *
25129
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.
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
11 *
25129
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 */
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
16
26481
5767b7698c73 Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents: 26473
diff changeset
17 #ifndef PURPLE_JABBER_IBB_H_
5767b7698c73 Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents: 26473
diff changeset
18 #define PURPLE_JABBER_IBB_H_
25756
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25129
diff changeset
19
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
20 #include "jabber.h"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
21 #include "iq.h"
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
22
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
23 #define XEP_0047_NAMESPACE "http://jabber.org/protocol/ibb"
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 typedef struct _JabberIBBSession JabberIBBSession;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
26
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
27 typedef void
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
28 (JabberIBBDataCallback)(JabberIBBSession *, const gpointer data, gsize size);
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 typedef void (JabberIBBOpenedCallback)(JabberIBBSession *);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
31 typedef void (JabberIBBClosedCallback)(JabberIBBSession *);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
32 typedef void (JabberIBBErrorCallback)(JabberIBBSession *);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
33 typedef void (JabberIBBSentCallback)(JabberIBBSession *);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
34
26473
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
35 typedef gboolean (JabberIBBOpenHandler)(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: 25952
diff changeset
36 const char *id, xmlnode *open);
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
37
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
38 typedef enum {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
39 JABBER_IBB_SESSION_NOT_OPENED,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
40 JABBER_IBB_SESSION_OPENED,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
41 JABBER_IBB_SESSION_CLOSED,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
42 JABBER_IBB_SESSION_ERROR
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
43 } JabberIBBSessionState;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
44
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
45 struct _JabberIBBSession {
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
46 JabberStream *js;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
47 gchar *who;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
48 gchar *sid;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
49 gchar *id;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
50 guint16 send_seq;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
51 guint16 recv_seq;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
52 gsize block_size;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
53
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
54 /* session state */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
55 JabberIBBSessionState state;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
56
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
57 /* user data (f.ex. a handle to a PurpleXfer) */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
58 gpointer user_data;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
59
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
60 /* callbacks */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
61 JabberIBBOpenedCallback *opened_cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
62 JabberIBBSentCallback *data_sent_cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
63 JabberIBBClosedCallback *closed_cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
64 /* callback for receiving data */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
65 JabberIBBDataCallback *data_received_cb;
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
66 JabberIBBErrorCallback *error_cb;
25952
5f9a24d1c25e Remove some extra trailing whitespace I noticed after merging mlundblad's
Elliott Sales de Andrade <qulogic@pidgin.im>
parents: 25756
diff changeset
67
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
68 /* store the last sent IQ (to permit cancel of callback) */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
69 gchar *last_iq_id;
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 JabberIBBSession *jabber_ibb_session_create(JabberStream *js, const gchar *sid,
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
73 const gchar *who, gpointer user_data);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
74 JabberIBBSession *jabber_ibb_session_create_from_xmlnode(JabberStream *js,
26473
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
75 const gchar *from, const gchar *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
76
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
77 void 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
78
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
79 void 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
80 JabberIBBOpenedCallback *cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
81 void 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
82 JabberIBBSentCallback *cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
83 void 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
84 JabberIBBClosedCallback *cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
85 void 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
86 JabberIBBDataCallback *cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
87 void 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
88 JabberIBBErrorCallback *cb);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
89
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
90 void 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
91 void 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
92 void jabber_ibb_session_accept(JabberIBBSession *sess);
25756
151b4054ce40 Trigger error callbacks when receiving a malformed-ish packet.
Paul Aurich <paul@darkrain42.org>
parents: 25129
diff changeset
93 void jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
25129
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
94 gsize size);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
95
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
96 const gchar *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
97 JabberStream *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
98 const gchar *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
99
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
100 guint16 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
101 guint16 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
102
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
103 JabberIBBSessionState 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
104
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
105 gsize 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
106 void 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
107
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
108 gpointer 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
109
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
110 /* handle incoming packet */
26473
50ff0162fe26 Convert IBB parser (and everything that then stems from that) to new iq-handler
Paul Aurich <paul@darkrain42.org>
parents: 25952
diff changeset
111 void 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: 25952
diff changeset
112 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
113
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
114 /* add a handler for open session */
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
115 void 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
116 void 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
117
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
118 void jabber_ibb_init(void);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
119 void jabber_ibb_uninit(void);
b4ec5481a67a Implements file transfers using in-band bytestreams for XMPP
Marcus Lundblad <ml@update.uu.se>
parents:
diff changeset
120
26481
5767b7698c73 Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents: 26473
diff changeset
121 #endif /* PURPLE_JABBER_IBB_H_ */