Mercurial > pidgin.yaz
comparison libpurple/protocols/jabber/ibb.h @ 23999:b4ec5481a67a
Implements file transfers using in-band bytestreams for XMPP
using XEP-0047
Refs #6183
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Sat, 06 Sep 2008 07:49:05 +0000 |
parents | |
children | 151b4054ce40 |
comparison
equal
deleted
inserted
replaced
23998:ac3db6ba7078 | 23999:b4ec5481a67a |
---|---|
1 /* | |
2 * This program is free software; you can redistribute it and/or modify | |
3 * it under the terms of the GNU General Public License as published by | |
4 * the Free Software Foundation; either version 2 of the License, or | |
5 * (at your option) any later version. | |
6 * | |
7 * This program is distributed in the hope that it will be useful, | |
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
10 * GNU Library General Public License for more details. | |
11 * | |
12 * You should have received a copy of the GNU General Public License | |
13 * along with this program; if not, write to the Free Software | |
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA | |
15 */ | |
16 | |
17 #include "jabber.h" | |
18 #include "iq.h" | |
19 | |
20 #ifndef JABBER_IBB_SESSION | |
21 #define JABBER_IBB_SESSION | |
22 | |
23 #define XEP_0047_NAMESPACE "http://jabber.org/protocol/ibb" | |
24 | |
25 typedef struct _JabberIBBSession JabberIBBSession; | |
26 | |
27 typedef void | |
28 (JabberIBBDataCallback)(JabberIBBSession *, const gpointer data, gsize size); | |
29 | |
30 typedef void (JabberIBBOpenedCallback)(JabberIBBSession *); | |
31 typedef void (JabberIBBClosedCallback)(JabberIBBSession *); | |
32 typedef void (JabberIBBErrorCallback)(JabberIBBSession *); | |
33 typedef void (JabberIBBSentCallback)(JabberIBBSession *); | |
34 | |
35 typedef gboolean (JabberIBBOpenHandler)(JabberStream *js, xmlnode *packet); | |
36 | |
37 typedef enum { | |
38 JABBER_IBB_SESSION_NOT_OPENED, | |
39 JABBER_IBB_SESSION_OPENED, | |
40 JABBER_IBB_SESSION_CLOSED, | |
41 JABBER_IBB_SESSION_ERROR | |
42 } JabberIBBSessionState; | |
43 | |
44 struct _JabberIBBSession { | |
45 JabberStream *js; | |
46 gchar *who; | |
47 gchar *sid; | |
48 gchar *id; | |
49 guint16 send_seq; | |
50 guint16 recv_seq; | |
51 gsize block_size; | |
52 | |
53 /* session state */ | |
54 JabberIBBSessionState state; | |
55 | |
56 /* user data (f.ex. a handle to a PurpleXfer) */ | |
57 gpointer user_data; | |
58 | |
59 /* callbacks */ | |
60 JabberIBBOpenedCallback *opened_cb; | |
61 JabberIBBSentCallback *data_sent_cb; | |
62 JabberIBBClosedCallback *closed_cb; | |
63 /* callback for receiving data */ | |
64 JabberIBBDataCallback *data_received_cb; | |
65 JabberIBBErrorCallback *error_cb; | |
66 | |
67 /* store the last sent IQ (to permit cancel of callback) */ | |
68 gchar *last_iq_id; | |
69 }; | |
70 | |
71 JabberIBBSession *jabber_ibb_session_create(JabberStream *js, const gchar *sid, | |
72 const gchar *who, gpointer user_data); | |
73 JabberIBBSession *jabber_ibb_session_create_from_xmlnode(JabberStream *js, | |
74 xmlnode *packet, gpointer user_data); | |
75 | |
76 void jabber_ibb_session_destroy(JabberIBBSession *sess); | |
77 | |
78 void jabber_ibb_session_set_opened_callback(JabberIBBSession *sess, | |
79 JabberIBBOpenedCallback *cb); | |
80 void jabber_ibb_session_set_data_sent_callback(JabberIBBSession *sess, | |
81 JabberIBBSentCallback *cb); | |
82 void jabber_ibb_session_set_closed_callback(JabberIBBSession *sess, | |
83 JabberIBBClosedCallback *cb); | |
84 void jabber_ibb_session_set_data_received_callback(JabberIBBSession *sess, | |
85 JabberIBBDataCallback *cb); | |
86 void jabber_ibb_session_set_error_callback(JabberIBBSession *sess, | |
87 JabberIBBErrorCallback *cb); | |
88 | |
89 void jabber_ibb_session_open(JabberIBBSession *sess); | |
90 void jabber_ibb_session_close(JabberIBBSession *sess); | |
91 void jabber_ibb_session_accept(JabberIBBSession *sess); | |
92 void jabber_ibb_session_send_data(JabberIBBSession *sess, gpointer data, | |
93 gsize size); | |
94 | |
95 const gchar *jabber_ibb_session_get_sid(const JabberIBBSession *sess); | |
96 JabberStream *jabber_ibb_session_get_js(JabberIBBSession *sess); | |
97 const gchar *jabber_ibb_session_get_who(const JabberIBBSession *sess); | |
98 | |
99 guint16 jabber_ibb_session_get_send_seq(const JabberIBBSession *sess); | |
100 guint16 jabber_ibb_session_get_recv_seq(const JabberIBBSession *sess); | |
101 | |
102 JabberIBBSessionState jabber_ibb_session_get_state(const JabberIBBSession *sess); | |
103 | |
104 gsize jabber_ibb_session_get_block_size(const JabberIBBSession *sess); | |
105 void jabber_ibb_session_set_block_size(JabberIBBSession *sess, gsize size); | |
106 | |
107 gpointer jabber_ibb_session_get_user_data(JabberIBBSession *sess); | |
108 | |
109 /* handle incoming packet */ | |
110 void jabber_ibb_parse(JabberStream *js, xmlnode *packet); | |
111 | |
112 /* add a handler for open session */ | |
113 void jabber_ibb_register_open_handler(JabberIBBOpenHandler *cb); | |
114 void jabber_ibb_unregister_open_handler(JabberIBBOpenHandler *cb); | |
115 | |
116 void jabber_ibb_init(void); | |
117 void jabber_ibb_uninit(void); | |
118 | |
119 #endif /* JABBER_IBB_SESSION */ |