Replace functions which called once with their bodies
[pidgin-git.git] / libpurple / protocols / jabber / ibb.h
blob24c568175ca078c5c5493716b51376babd51527e
1 /*
2 * purple - Handling of XEP-0047: In-Band Bytestreams.
4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
6 * source distribution.
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
24 #ifndef PURPLE_JABBER_IBB_H
25 #define PURPLE_JABBER_IBB_H
27 #include "jabber.h"
28 #include "iq.h"
30 typedef struct _JabberIBBSession JabberIBBSession;
32 typedef void
33 (JabberIBBDataCallback)(JabberIBBSession *, const gpointer data, gsize size);
35 typedef void (JabberIBBOpenedCallback)(JabberIBBSession *);
36 typedef void (JabberIBBClosedCallback)(JabberIBBSession *);
37 typedef void (JabberIBBErrorCallback)(JabberIBBSession *);
38 typedef void (JabberIBBSentCallback)(JabberIBBSession *);
40 typedef gboolean (JabberIBBOpenHandler)(JabberStream *js, const char *from,
41 const char *id, PurpleXmlNode *open);
43 typedef enum {
44 JABBER_IBB_SESSION_NOT_OPENED,
45 JABBER_IBB_SESSION_OPENED,
46 JABBER_IBB_SESSION_CLOSED,
47 JABBER_IBB_SESSION_ERROR
48 } JabberIBBSessionState;
50 struct _JabberIBBSession {
51 JabberStream *js;
52 gchar *who;
53 gchar *sid;
54 gchar *id;
55 guint16 send_seq;
56 guint16 recv_seq;
57 gsize block_size;
59 /* session state */
60 JabberIBBSessionState state;
62 /* user data (f.ex. a handle to a PurpleXfer) */
63 gpointer user_data;
65 /* callbacks */
66 JabberIBBOpenedCallback *opened_cb;
67 JabberIBBSentCallback *data_sent_cb;
68 JabberIBBClosedCallback *closed_cb;
69 /* callback for receiving data */
70 JabberIBBDataCallback *data_received_cb;
71 JabberIBBErrorCallback *error_cb;
73 /* store the last sent IQ (to permit cancel of callback) */
74 gchar *last_iq_id;
77 JabberIBBSession *jabber_ibb_session_create(JabberStream *js, const gchar *sid,
78 const gchar *who, gpointer user_data);
79 JabberIBBSession *jabber_ibb_session_create_from_xmlnode(JabberStream *js,
80 const gchar *from, const gchar *id, PurpleXmlNode *open, gpointer user_data);
82 void jabber_ibb_session_destroy(JabberIBBSession *sess);
84 void jabber_ibb_session_set_opened_callback(JabberIBBSession *sess,
85 JabberIBBOpenedCallback *cb);
86 void jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess,
87 JabberIBBSentCallback *cb);
88 void jabber_ibb_session_set_closed_callback(JabberIBBSession *sess,
89 JabberIBBClosedCallback *cb);
90 void jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess,
91 JabberIBBDataCallback *cb);
92 void jabber_ibb_session_set_error_callback(JabberIBBSession *sess,
93 JabberIBBErrorCallback *cb);
95 void jabber_ibb_session_open(JabberIBBSession *sess);
96 void jabber_ibb_session_close(JabberIBBSession *sess);
97 void jabber_ibb_session_accept(JabberIBBSession *sess);
98 void jabber_ibb_session_send_data(JabberIBBSession *sess, gconstpointer data,
99 gsize size);
101 const gchar *jabber_ibb_session_get_sid(const JabberIBBSession *sess);
102 JabberStream *jabber_ibb_session_get_js(JabberIBBSession *sess);
103 const gchar *jabber_ibb_session_get_who(const JabberIBBSession *sess);
105 guint16 jabber_ibb_session_get_send_seq(const JabberIBBSession *sess);
106 guint16 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess);
108 JabberIBBSessionState jabber_ibb_session_get_state(const JabberIBBSession *sess);
110 gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess);
111 void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size);
113 /* get maximum size data block to send (in bytes)
114 (before encoded to BASE64) */
115 gsize jabber_ibb_session_get_max_data_size(const JabberIBBSession *sess);
117 gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess);
119 /* handle incoming packet */
120 void jabber_ibb_parse(JabberStream *js, const char *who, JabberIqType type,
121 const char *id, PurpleXmlNode *child);
123 /* add a handler for open session */
124 void jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb);
125 void jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb);
127 void jabber_ibb_init(void);
128 void jabber_ibb_uninit(void);
130 #endif /* PURPLE_JABBER_IBB_H */