1 /*
2  * bytestream-iface.h - Header for GabbleBytestream interface
3  * Copyright (C) 2007 Collabora Ltd.
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18  */
19 
20 #ifndef __GABBLE_BYTESTREAM_IFACE_H__
21 #define __GABBLE_BYTESTREAM_IFACE_H__
22 
23 #include <glib-object.h>
24 #include <wocky/wocky.h>
25 
26 G_BEGIN_DECLS
27 
28 typedef enum
29 {
30   /* Received a SI request, response not yet sent */
31   GABBLE_BYTESTREAM_STATE_LOCAL_PENDING = 0,
32   /* We accepted SI request.
33    * bytestream specific init steps not yet performed */
34   GABBLE_BYTESTREAM_STATE_ACCEPTED,
35   /* Remote contact accepted the SI request.
36    * bytestream specific initiation started */
37   GABBLE_BYTESTREAM_STATE_INITIATING,
38   /* Bytestream open */
39   GABBLE_BYTESTREAM_STATE_OPEN,
40   GABBLE_BYTESTREAM_STATE_CLOSING,
41   GABBLE_BYTESTREAM_STATE_CLOSED,
42   NUM_GABBLE_BYTESTREAM_STATES,
43 } GabbleBytestreamState;
44 
45 typedef void (* GabbleBytestreamAugmentSiAcceptReply) (
46     WockyNode *si, gpointer user_data);
47 
48 typedef struct _GabbleBytestreamIface GabbleBytestreamIface;
49 typedef struct _GabbleBytestreamIfaceClass GabbleBytestreamIfaceClass;
50 
51 struct _GabbleBytestreamIfaceClass {
52   GTypeInterface parent;
53 
54   gboolean (*initiate) (GabbleBytestreamIface *bytestream);
55   gboolean (*send) (GabbleBytestreamIface *bytestream, guint len,
56       const gchar *data);
57   void (*close) (GabbleBytestreamIface *bytestream, GError *error);
58   void (*accept) (GabbleBytestreamIface *bytestream,
59       GabbleBytestreamAugmentSiAcceptReply func, gpointer user_data);
60   void (*block_reading) (GabbleBytestreamIface *bytestream, gboolean block);
61 };
62 
63 GType gabble_bytestream_iface_get_type (void);
64 
65 /* TYPE MACROS */
66 #define GABBLE_TYPE_BYTESTREAM_IFACE \
67   (gabble_bytestream_iface_get_type ())
68 #define GABBLE_BYTESTREAM_IFACE(obj) \
69   (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_BYTESTREAM_IFACE, \
70                               GabbleBytestreamIface))
71 #define GABBLE_IS_BYTESTREAM_IFACE(obj) \
72   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_BYTESTREAM_IFACE))
73 #define GABBLE_BYTESTREAM_IFACE_GET_CLASS(obj) \
74   (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GABBLE_TYPE_BYTESTREAM_IFACE,\
75                               GabbleBytestreamIfaceClass))
76 
77 gboolean gabble_bytestream_iface_initiate (GabbleBytestreamIface *bytestream);
78 
79 gboolean gabble_bytestream_iface_send (GabbleBytestreamIface *bytestream,
80     guint len, const gchar *data);
81 
82 void gabble_bytestream_iface_close (GabbleBytestreamIface *bytestream,
83     GError *error);
84 
85 void gabble_bytestream_iface_accept (GabbleBytestreamIface *bytestream,
86     GabbleBytestreamAugmentSiAcceptReply func, gpointer user_data);
87 
88 void gabble_bytestream_iface_block_reading (GabbleBytestreamIface *bytestream,
89     gboolean block);
90 
91 G_END_DECLS
92 
93 #endif /* #ifndef __GABBLE_BYTESTREAM_IFACE_H__ */
94