|
1 /* |
|
2 * gabble-connection.h - Header for GabbleConnection |
|
3 * Copyright (C) 2005 Collabora Ltd. |
|
4 * |
|
5 * |
|
6 * This library is free software; you can redistribute it and/or |
|
7 * modify it under the terms of the GNU Lesser General Public |
|
8 * License as published by the Free Software Foundation; either |
|
9 * version 2.1 of the License, or (at your option) any later version. |
|
10 * |
|
11 * This library is distributed in the hope that it will be useful, |
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
14 * Lesser General Public License for more details. |
|
15 * |
|
16 * You should have received a copy of the GNU Lesser General Public |
|
17 * License along with this library; if not, write to the Free Software |
|
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 */ |
|
20 |
|
21 #ifndef __GABBLE_CONNECTION_H__ |
|
22 #define __GABBLE_CONNECTION_H__ |
|
23 |
|
24 #include <dbus/dbus-glib.h> |
|
25 #include <glib-object.h> |
|
26 #include "loudmouth/loudmouth.h" |
|
27 |
|
28 #include "gabble-types.h" |
|
29 #include "gabble-error.h" |
|
30 #include "properties-mixin.h" |
|
31 #include "telepathy-constants.h" |
|
32 |
|
33 G_BEGIN_DECLS |
|
34 |
|
35 /* Default parameters for optional parameters */ |
|
36 #define GABBLE_PARAMS_DEFAULT_RESOURCE "Telepathy" |
|
37 #define GABBLE_PARAMS_DEFAULT_PORT 5222 |
|
38 #define GABBLE_PARAMS_DEFAULT_HTTPS_PROXY_PORT 443 |
|
39 #define GABBLE_PARAMS_DEFAULT_STUN_PORT 3478 |
|
40 |
|
41 /* order must match array of statuses in gabble-connection.c */ |
|
42 /* in increasing order of presence */ |
|
43 typedef enum |
|
44 { |
|
45 GABBLE_PRESENCE_OFFLINE = 0, |
|
46 GABBLE_PRESENCE_HIDDEN, |
|
47 GABBLE_PRESENCE_XA, |
|
48 GABBLE_PRESENCE_AWAY, |
|
49 GABBLE_PRESENCE_DND, |
|
50 GABBLE_PRESENCE_AVAILABLE, |
|
51 GABBLE_PRESENCE_CHAT, |
|
52 LAST_GABBLE_PRESENCE |
|
53 } GabblePresenceId; |
|
54 |
|
55 typedef enum |
|
56 { |
|
57 GABBLE_CONNECTION_FEATURES_NONE = 0, |
|
58 GABBLE_CONNECTION_FEATURES_GOOGLE_JINGLE_INFO = 1 << 0, |
|
59 GABBLE_CONNECTION_FEATURES_GOOGLE_ROSTER = 1 << 1, |
|
60 GABBLE_CONNECTION_FEATURES_PRESENCE_INVISIBLE = 1 << 2, |
|
61 GABBLE_CONNECTION_FEATURES_PRIVACY = 1 << 3, |
|
62 GABBLE_CONNECTION_FEATURES_SEARCH = 1 << 4, |
|
63 } GabbleConnectionFeatures; |
|
64 |
|
65 typedef struct _GabbleConnectionClass GabbleConnectionClass; |
|
66 |
|
67 typedef LmHandlerResult (*GabbleConnectionMsgReplyFunc) (GabbleConnection *conn, |
|
68 LmMessage *sent_msg, |
|
69 LmMessage *reply_msg, |
|
70 GObject *object, |
|
71 gpointer user_data); |
|
72 |
|
73 struct _GabbleConnectionClass { |
|
74 GObjectClass parent_class; |
|
75 |
|
76 GabblePropertiesMixinClass properties_class; |
|
77 }; |
|
78 |
|
79 struct _GabbleConnection { |
|
80 GObject parent; |
|
81 |
|
82 GabblePropertiesMixin properties; |
|
83 |
|
84 /* dbus object location */ |
|
85 gchar *bus_name; |
|
86 gchar *object_path; |
|
87 |
|
88 /* loudmouth connection */ |
|
89 LmConnection *lmconn; |
|
90 |
|
91 /* connection status */ |
|
92 TpConnectionStatus status; |
|
93 |
|
94 /* handles */ |
|
95 GabbleHandleRepo *handles; |
|
96 GabbleHandle self_handle; |
|
97 |
|
98 /* roster */ |
|
99 GabbleRoster *roster; |
|
100 |
|
101 /* DISCO! */ |
|
102 GabbleDisco *disco; |
|
103 |
|
104 /* connection feature flags */ |
|
105 GabbleConnectionFeatures features; |
|
106 |
|
107 /* presence */ |
|
108 GabblePresenceCache *presence_cache; |
|
109 |
|
110 /* vCard lookup helper */ |
|
111 GabbleVCardManager *vcard_manager; |
|
112 /* search related info */ |
|
113 /* jid which supports search feature */ |
|
114 gchar *search_service_jid; |
|
115 /* key names on which search request can be made */ |
|
116 gchar **search_key_names; |
|
117 /* maps search key "label" to "var" */ |
|
118 GHashTable *search_key_ht; |
|
119 /* instruction by service to do search */ |
|
120 gchar *search_instr; |
|
121 /* gives the detailed info of search results*/ |
|
122 gchar **search_reported_fields; |
|
123 /* needed to support search with and without data forms*/ |
|
124 gboolean search_form; |
|
125 /*avatar sha1*/ |
|
126 gchar* self_avatar_sha1; |
|
127 gpointer priv; |
|
128 }; |
|
129 |
|
130 typedef enum { |
|
131 GABBLE_CONNECTION_ALIAS_NONE = 0, |
|
132 GABBLE_CONNECTION_ALIAS_FROM_JID, |
|
133 GABBLE_CONNECTION_ALIAS_FROM_VCARD, |
|
134 GABBLE_CONNECTION_ALIAS_FROM_CONNMGR, |
|
135 GABBLE_CONNECTION_ALIAS_FROM_PRESENCE, |
|
136 GABBLE_CONNECTION_ALIAS_FROM_ROSTER |
|
137 } GabbleConnectionAliasSource; |
|
138 |
|
139 IMPORT_C GType gabble_connection_get_type(void); |
|
140 |
|
141 /* TYPE MACROS */ |
|
142 #define GABBLE_TYPE_CONNECTION \ |
|
143 (gabble_connection_get_type()) |
|
144 #define GABBLE_CONNECTION(obj) \ |
|
145 (G_TYPE_CHECK_INSTANCE_CAST((obj), GABBLE_TYPE_CONNECTION, GabbleConnection)) |
|
146 #define GABBLE_CONNECTION_CLASS(klass) \ |
|
147 (G_TYPE_CHECK_CLASS_CAST((klass), GABBLE_TYPE_CONNECTION, GabbleConnectionClass)) |
|
148 #define GABBLE_IS_CONNECTION(obj) \ |
|
149 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GABBLE_TYPE_CONNECTION)) |
|
150 #define GABBLE_IS_CONNECTION_CLASS(klass) \ |
|
151 (G_TYPE_CHECK_CLASS_TYPE((klass), GABBLE_TYPE_CONNECTION)) |
|
152 #define GABBLE_CONNECTION_GET_CLASS(obj) \ |
|
153 (G_TYPE_INSTANCE_GET_CLASS ((obj), GABBLE_TYPE_CONNECTION, GabbleConnectionClass)) |
|
154 |
|
155 gboolean _gabble_connection_set_properties_from_account (GabbleConnection *conn, const gchar *account, GError **error); |
|
156 gboolean _gabble_connection_register (GabbleConnection *conn, char **bus_name, char **object_path, GError **error); |
|
157 gboolean _gabble_connection_send (GabbleConnection *conn, LmMessage *msg, GError **error); |
|
158 gboolean _gabble_connection_send_with_reply (GabbleConnection *conn, LmMessage *msg, GabbleConnectionMsgReplyFunc reply_func, GObject *object, gpointer user_data, GError **error); |
|
159 void _gabble_connection_acknowledge_set_iq (GabbleConnection *conn, LmMessage *iq); |
|
160 void _gabble_connection_send_iq_error (GabbleConnection *conn, LmMessage *message, GabbleXmppError error, const gchar *errmsg); |
|
161 |
|
162 GabbleConnectionAliasSource _gabble_connection_get_cached_alias (GabbleConnection *, GabbleHandle, gchar **); |
|
163 |
|
164 const char *_gabble_connection_find_conference_server (GabbleConnection *); |
|
165 |
|
166 gboolean |
|
167 gabble_connection_add_status (GabbleConnection *self, |
|
168 const gchar *status, |
|
169 GHashTable *parms, |
|
170 GError **error); |
|
171 |
|
172 gboolean |
|
173 gabble_connection_advertise_capabilities (GabbleConnection *self, |
|
174 const GPtrArray *add, |
|
175 const gchar **remove, |
|
176 GPtrArray **ret, |
|
177 GError **error); |
|
178 |
|
179 gboolean |
|
180 gabble_connection_clear_status (GabbleConnection *self, |
|
181 GError **error); |
|
182 |
|
183 gboolean |
|
184 gabble_connection_connect (GabbleConnection *self, |
|
185 GError **error); |
|
186 |
|
187 //Mukesh - start |
|
188 gboolean |
|
189 gabble_connection_connect_blocking (GabbleConnection *self, |
|
190 GError **error); |
|
191 //Mukesh - end |
|
192 |
|
193 gboolean |
|
194 gabble_connection_disconnect (GabbleConnection *self, |
|
195 GError **error); |
|
196 |
|
197 gboolean |
|
198 gabble_connection_get_alias_flags (GabbleConnection *self, |
|
199 guint *ret, |
|
200 GError **error); |
|
201 |
|
202 gboolean |
|
203 gabble_connection_get_capabilities (GabbleConnection *self, |
|
204 const GArray *handles, |
|
205 GPtrArray **ret, |
|
206 GError **error); |
|
207 |
|
208 gboolean |
|
209 gabble_connection_get_interfaces (GabbleConnection *self, |
|
210 gchar ***ret, |
|
211 GError **error); |
|
212 |
|
213 void |
|
214 gabble_connection_get_presence (GabbleConnection *self, |
|
215 const GArray *contacts, |
|
216 DBusGMethodInvocation *context); |
|
217 |
|
218 gboolean |
|
219 gabble_connection_get_properties (GabbleConnection *self, |
|
220 const GArray *properties, |
|
221 GPtrArray **ret, |
|
222 GError **error); |
|
223 |
|
224 gboolean |
|
225 gabble_connection_get_protocol (GabbleConnection *self, |
|
226 gchar **ret, |
|
227 GError **error); |
|
228 |
|
229 gboolean |
|
230 gabble_connection_get_self_handle (GabbleConnection *self, |
|
231 guint *ret, |
|
232 GError **error); |
|
233 |
|
234 gboolean |
|
235 gabble_connection_get_status (GabbleConnection *self, |
|
236 guint *ret, |
|
237 GError **error); |
|
238 |
|
239 gboolean |
|
240 gabble_connection_get_statuses (GabbleConnection *self, |
|
241 GHashTable **ret, |
|
242 GError **error); |
|
243 |
|
244 void |
|
245 gabble_connection_hold_handles (GabbleConnection *self, |
|
246 guint handle_type, |
|
247 const GArray *handles, |
|
248 DBusGMethodInvocation *context); |
|
249 |
|
250 void |
|
251 gabble_connection_inspect_handles (GabbleConnection *self, |
|
252 guint handle_type, |
|
253 const GArray *handles, |
|
254 DBusGMethodInvocation *context); |
|
255 |
|
256 gboolean |
|
257 gabble_connection_list_channels (GabbleConnection *self, |
|
258 GPtrArray **ret, |
|
259 GError **error); |
|
260 |
|
261 gboolean |
|
262 gabble_connection_list_properties (GabbleConnection *self, |
|
263 GPtrArray **ret, |
|
264 GError **error); |
|
265 |
|
266 void |
|
267 gabble_connection_release_handles (GabbleConnection *self, |
|
268 guint handle_type, |
|
269 const GArray *handles, |
|
270 DBusGMethodInvocation *context); |
|
271 |
|
272 gboolean |
|
273 gabble_connection_remove_status (GabbleConnection *self, |
|
274 const gchar *status, |
|
275 GError **error); |
|
276 |
|
277 void |
|
278 gabble_connection_request_aliases (GabbleConnection *self, |
|
279 const GArray *contacts, |
|
280 DBusGMethodInvocation *context); |
|
281 |
|
282 void |
|
283 gabble_connection_request_channel (GabbleConnection *self, |
|
284 const gchar *type, |
|
285 guint handle_type, |
|
286 guint handle, |
|
287 gboolean suppress_handler, |
|
288 DBusGMethodInvocation *context); |
|
289 |
|
290 void |
|
291 gabble_connection_request_handles (GabbleConnection *self, |
|
292 guint handle_type, |
|
293 const gchar **names, |
|
294 DBusGMethodInvocation *context); |
|
295 |
|
296 gboolean |
|
297 gabble_connection_request_presence (GabbleConnection *self, |
|
298 const GArray *contacts, |
|
299 GError **error); |
|
300 |
|
301 gboolean |
|
302 gabble_connection_set_aliases (GabbleConnection *self, |
|
303 GHashTable *aliases, |
|
304 GError **error); |
|
305 |
|
306 gboolean |
|
307 gabble_connection_set_last_activity_time (GabbleConnection *self, |
|
308 guint time, |
|
309 GError **error); |
|
310 |
|
311 void |
|
312 gabble_connection_set_properties (GabbleConnection *self, |
|
313 const GPtrArray *properties, |
|
314 DBusGMethodInvocation *context); |
|
315 |
|
316 gboolean |
|
317 gabble_connection_set_status (GabbleConnection *self, |
|
318 GHashTable *statuses, |
|
319 GError **error); |
|
320 |
|
321 gboolean |
|
322 gabble_connection_set_avatar( GabbleConnection *self, const GArray* bin_image, gchar* mime, gchar**avatar_sha1, GError** err ); |
|
323 |
|
324 gboolean |
|
325 gabble_connection_clear_avatar( GabbleConnection *self, |
|
326 GError **error); |
|
327 |
|
328 |
|
329 LmMessage* gabble_connection_build_avatar(GabbleConnection *self, |
|
330 const GArray* bin_image, gchar* mime ); |
|
331 |
|
332 G_END_DECLS |
|
333 |
|
334 #endif /* #ifndef __GABBLE_CONNECTION_H__*/ |