6 * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com>
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
22 #ifndef PURPLE_JABBER_H_
23 #define PURPLE_JABBER_H_
27 /* JABBER_CAP_XHTML = 1 << 0, */
28 /* JABBER_CAP_COMPOSING = 1 << 1, */
29 JABBER_CAP_SI = 1 << 2,
30 JABBER_CAP_SI_FILE_XFER = 1 << 3,
31 JABBER_CAP_BYTESTREAMS = 1 << 4,
32 JABBER_CAP_IBB = 1 << 5,
33 JABBER_CAP_CHAT_STATES = 1 << 6,
34 JABBER_CAP_IQ_SEARCH = 1 << 7,
35 JABBER_CAP_IQ_REGISTER = 1 << 8,
37 /* Google Talk extensions:
38 * http://code.google.com/apis/talk/jep_extensions/extensions.html
40 JABBER_CAP_GMAIL_NOTIFY = 1 << 9,
41 JABBER_CAP_GOOGLE_ROSTER = 1 << 10,
43 JABBER_CAP_PING = 1 << 11,
44 JABBER_CAP_ADHOC = 1 << 12,
45 JABBER_CAP_BLOCKING = 1 << 13,
47 JABBER_CAP_ITEMS = 1 << 14,
49 JABBER_CAP_RETRIEVED = 1 << 31
52 typedef struct _JabberStream JabberStream;
54 #include <libxml/parser.h>
56 #include "circbuffer.h"
57 #include "connection.h"
61 #include "mediamanager.h"
71 #ifdef HAVE_CYRUS_SASL
72 #include <sasl/sasl.h>
75 #define CAPS0115_NODE "http://pidgin.im/"
77 /* Index into attention_types list */
80 extern PurplePlugin *jabber_plugin;
83 JABBER_STREAM_OFFLINE,
84 JABBER_STREAM_CONNECTING,
85 JABBER_STREAM_INITIALIZING,
86 JABBER_STREAM_INITIALIZING_ENCRYPTION,
87 JABBER_STREAM_AUTHENTICATING,
88 JABBER_STREAM_REINITIALIZING,
89 JABBER_STREAM_CONNECTED
96 PurpleSrvQueryData *srv_query_data;
98 xmlParserCtxt *context;
107 JABBER_AUTH_DIGEST_MD5,
113 JabberStreamState state;
115 /* SASL authentication */
116 char *expected_rspauth;
121 * This boolean was added to eliminate a heinous bug where we would
122 * get into a loop with the server and move a buddy back and forth
123 * from one group to another.
125 * The sequence goes something like this:
126 * 1. Our resource and another resource both approve an authorization
127 * request at the exact same time. We put the buddy in group A and
128 * the other resource put the buddy in group B.
129 * 2. The server receives the roster add for group B and sends us a
131 * 3. We receive this roster push and modify our local blist. This
132 * triggers us to send a roster add for group B.
133 * 4. The server recieves our earlier roster add for group A and sends
135 * 5. We receive this roster push and modify our local blist. This
136 * triggers us to send a roster add for group A.
137 * 6. The server receives our earlier roster add for group B and sends
139 * (repeat steps 3 through 6 ad infinitum)
141 * This boolean is used to short-circuit the sending of a roster add
142 * when we receive a roster push.
144 * See these bug reports:
145 * http://trac.adiumx.com/ticket/8834
146 * http://developer.pidgin.im/ticket/5484
147 * http://developer.pidgin.im/ticket/6188
149 gboolean currently_parsing_roster_push;
153 PurpleRoomlist *roomlist;
154 GList *user_directories;
156 GHashTable *iq_callbacks;
160 GList *oob_file_transfers;
161 GList *file_transfers;
167 JabberBuddy *user_jb;
169 PurpleConnection *gc;
170 PurpleSslConnection *gsc;
172 gboolean registration;
174 char *initial_avatar_hash;
176 GSList *pending_avatar_requests;
178 GSList *pending_buddy_info_requests;
180 PurpleCircBuffer *write_buffer;
185 JabberCapabilities server_caps;
189 char *gmail_last_time;
190 char *gmail_last_tid;
194 /* OK, this stays at the end of the struct, so plugins can depend
195 * on the rest of the stuff being in the right place
197 #ifdef HAVE_CYRUS_SASL
199 sasl_callback_t *sasl_cb;
200 #else /* keep the struct the same size */
204 /* did someone say something about the end of the struct? */
205 #ifdef HAVE_CYRUS_SASL
206 const char *current_mech;
214 gboolean unregistration;
215 PurpleAccountUnregistrationCb unregistration_cb;
216 void *unregistration_user_data;
218 gboolean vcard_fetched;
219 /* Timer at login to push updated avatar */
222 /* Entity Capabilities hash */
225 /* does the local server support PEP? */
228 /* Is Buzz enabled? */
231 /* A list of JabberAdHocCommands supported by the server */
234 /* last presence update to check for differences */
235 JabberBuddyState old_state;
238 char *old_avatarhash;
240 /* same for user tune */
248 char *certificate_CN;
250 /* A purple timeout tag for the keepalive */
251 guint keepalive_timeout;
253 PurpleSrvResponse *srv_rec;
255 guint max_srv_rec_idx;
258 PurpleBOSHConnection *bosh;
261 * This linked list contains PurpleUtilFetchUrlData structs
262 * for when we lookup buddy icons from a url
266 /* keep a hash table of JingleSessions */
267 GHashTable *sessions;
269 /* maybe this should only be present when USE_VV? */
272 PurpleDnsQueryData *stun_query;
273 /* later add stuff to handle TURN relays... */
276 typedef gboolean (JabberFeatureEnabled)(JabberStream *js, const gchar *namespace);
278 typedef struct _JabberFeature
281 JabberFeatureEnabled *is_enabled;
284 typedef struct _JabberIdentity
292 typedef struct _JabberBytestreamsStreamhost {
297 } JabberBytestreamsStreamhost;
299 /* what kind of additional features as returned from disco#info are supported? */
300 extern GList *jabber_features;
301 extern GList *jabber_identities;
303 void jabber_stream_features_parse(JabberStream *js, xmlnode *packet);
304 void jabber_process_packet(JabberStream *js, xmlnode **packet);
305 void jabber_send(JabberStream *js, xmlnode *data);
306 void jabber_send_raw(JabberStream *js, const char *data, int len);
307 void jabber_send_signal_cb(PurpleConnection *pc, xmlnode **packet,
310 void jabber_stream_set_state(JabberStream *js, JabberStreamState state);
312 void jabber_register_parse(JabberStream *js, const char *from,
313 JabberIqType type, const char *id, xmlnode *query);
314 void jabber_register_start(JabberStream *js);
316 char *jabber_get_next_id(JabberStream *js);
318 /** Parse an error into a human-readable string and optionally a disconnect
320 * @param js the stream on which the error occurred.
321 * @param packet the error packet
322 * @param reason where to store the disconnection reason, or @c NULL if you
323 * don't care or you don't intend to close the connection.
325 char *jabber_parse_error(JabberStream *js, xmlnode *packet, PurpleConnectionError *reason);
327 void jabber_add_feature(const gchar *namespace, JabberFeatureEnabled cb); /* cb may be NULL */
328 void jabber_remove_feature(const gchar *namespace);
330 /** Adds an identity to this jabber library instance. For list of valid values visit the
331 * website of the XMPP Registrar ( http://www.xmpp.org/registrar/disco-categories.html#client ).
332 * @param category the category of the identity.
333 * @param type the type of the identity.
334 * @param language the language localization of the name. Can be NULL.
335 * @param name the name of the identity.
337 void jabber_add_identity(const gchar *category, const gchar *type, const gchar *lang, const gchar *name);
340 * Returns true if this connection is over a secure (SSL) stream. Use this
341 * instead of checking js->gsc because BOSH stores its PurpleSslConnection
342 * members in its own data structure.
344 gboolean jabber_stream_is_ssl(JabberStream *js);
346 /** PRPL functions */
347 const char *jabber_list_icon(PurpleAccount *a, PurpleBuddy *b);
348 const char* jabber_list_emblem(PurpleBuddy *b);
349 char *jabber_status_text(PurpleBuddy *b);
350 void jabber_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full);
351 GList *jabber_status_types(PurpleAccount *account);
352 void jabber_login(PurpleAccount *account);
353 void jabber_close(PurpleConnection *gc);
354 void jabber_idle_set(PurpleConnection *gc, int idle);
355 void jabber_blocklist_parse_push(JabberStream *js, const char *from,
356 JabberIqType type, const char *id,
358 void jabber_request_block_list(JabberStream *js);
359 void jabber_add_deny(PurpleConnection *gc, const char *who);
360 void jabber_rem_deny(PurpleConnection *gc, const char *who);
361 void jabber_keepalive(PurpleConnection *gc);
362 void jabber_register_gateway(JabberStream *js, const char *gateway);
363 void jabber_register_account(PurpleAccount *account);
364 void jabber_unregister_account(PurpleAccount *account, PurpleAccountUnregistrationCb cb, void *user_data);
365 gboolean jabber_send_attention(PurpleConnection *gc, const char *username, guint code);
366 GList *jabber_attention_types(PurpleAccount *account);
367 void jabber_convo_closed(PurpleConnection *gc, const char *who);
368 PurpleChat *jabber_find_blist_chat(PurpleAccount *account, const char *name);
369 gboolean jabber_offline_message(const PurpleBuddy *buddy);
370 int jabber_prpl_send_raw(PurpleConnection *gc, const char *buf, int len);
371 GList *jabber_actions(PurplePlugin *plugin, gpointer context);
373 gboolean jabber_audio_enabled(JabberStream *js, const char *unused);
374 gboolean jabber_video_enabled(JabberStream *js, const char *unused);
375 gboolean jabber_initiate_media(PurpleAccount *account, const char *who,
376 PurpleMediaSessionType type);
377 PurpleMediaCaps jabber_get_media_caps(PurpleAccount *account, const char *who);
379 void jabber_register_commands(void);
380 void jabber_unregister_commands(void);
382 void jabber_init_plugin(PurplePlugin *plugin);
383 void jabber_uninit_plugin(void);
385 #endif /* PURPLE_JABBER_H_ */