1 /*
2  * bytestream-factory.h - Header for GabbleBytestreamFactory
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 __BYTESTREAM_FACTORY_H__
21 #define __BYTESTREAM_FACTORY_H__
22 
23 #include <glib-object.h>
24 #include <telepathy-glib/telepathy-glib.h>
25 #include "types.h"
26 #include "bytestream-iface.h"
27 #include "bytestream-ibb.h"
28 #include "bytestream-muc.h"
29 #include "bytestream-multiple.h"
30 #include "bytestream-socks5.h"
31 #include "connection.h"
32 
33 G_BEGIN_DECLS
34 
35 typedef struct _GabbleBytestreamFactoryClass GabbleBytestreamFactoryClass;
36 typedef struct _GabbleBytestreamFactoryPrivate GabbleBytestreamFactoryPrivate;
37 
38 struct _GabbleBytestreamFactoryClass {
39   GObjectClass parent_class;
40 };
41 
42 struct _GabbleBytestreamFactory {
43   GObject parent;
44 
45   GabbleBytestreamFactoryPrivate *priv;
46 };
47 
48 GType gabble_bytestream_factory_get_type (void);
49 
50 /* TYPE MACROS */
51 #define GABBLE_TYPE_BYTESTREAM_FACTORY \
52   (gabble_bytestream_factory_get_type ())
53 #define GABBLE_BYTESTREAM_FACTORY(obj) \
54   (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_BYTESTREAM_FACTORY,\
55                               GabbleBytestreamFactory))
56 #define GABBLE_BYTESTREAM_FACTORY_CLASS(klass) \
57   (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_BYTESTREAM_FACTORY,\
58                            GabbleBytestreamFactoryClass))
59 #define GABBLE_IS_BYTESTREAM_FACTORY(obj) \
60   (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_BYTESTREAM_FACTORY))
61 #define GABBLE_IS_BYTESTREAM_FACTORY_CLASS(klass) \
62   (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_BYTESTREAM_FACTORY))
63 #define GABBLE_BYTESTREAM_FACTORY_GET_CLASS(obj) \
64   (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_BYTESTREAM_FACTORY,\
65                               GabbleBytestreamFactoryClass))
66 
67 typedef struct {
68     gchar *jid;
69     gchar *host;
70     guint16 port;
71 } GabbleSocks5Proxy;
72 
73 typedef void (* GabbleBytestreamFactoryNegotiateReplyFunc) (
74     GabbleBytestreamIface *bytestream, WockyStanza *msg,
75     GObject *object, gpointer user_data);
76 
77 GabbleBytestreamFactory *gabble_bytestream_factory_new (
78     GabbleConnection *conn);
79 
80 GabbleBytestreamMuc *gabble_bytestream_factory_create_muc (
81     GabbleBytestreamFactory *fac, TpHandle peer_handle, const gchar *stream_id,
82     GabbleBytestreamState state);
83 
84 GabbleBytestreamIface *gabble_bytestream_factory_create_from_method (
85     GabbleBytestreamFactory *self, const gchar *stream_method,
86     TpHandle peer_handle, const gchar *stream_id, const gchar *stream_init_id,
87     const gchar *peer_resource, const gchar *self_jid,
88     GabbleBytestreamState state);
89 
90 WockyStanza *gabble_bytestream_factory_make_stream_init_iq (
91     const gchar *full_jid, const gchar *stream_id, const gchar *profile);
92 
93 WockyStanza *gabble_bytestream_factory_make_accept_iq (const gchar *full_jid,
94     const gchar *stream_init_id, const gchar *stream_method);
95 
96 WockyStanza *gabble_bytestream_factory_make_multi_accept_iq (
97     const gchar *full_jid, const gchar *stream_init_id,
98     GList *stream_methods);
99 
100 void gabble_bytestream_factory_negotiate_stream (
101     GabbleBytestreamFactory *fac, WockyStanza *msg, const gchar *stream_id,
102     GabbleBytestreamFactoryNegotiateReplyFunc func,
103     gpointer user_data, GObject *object);
104 
105 gchar *gabble_bytestream_factory_generate_stream_id (void);
106 
107 GSList *gabble_bytestream_factory_get_socks5_proxies (
108     GabbleBytestreamFactory *self);
109 
110 void gabble_bytestream_factory_query_socks5_proxies (
111     GabbleBytestreamFactory *self);
112 
113 G_END_DECLS
114 
115 #endif /* #ifndef __BYTESTREAM_FACTORY_H__ */
116