1 /** 2 * @file presence.h Presence 3 * 4 * purple 5 * 6 * Purple is the legal property of its developers, whose names are too numerous 7 * to list here. Please refer to the COPYRIGHT file distributed with this 8 * source distribution. 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA 23 */ 24 #ifndef PURPLE_JABBER_PRESENCE_H_ 25 #define PURPLE_JABBER_PRESENCE_H_ 26 27 typedef enum { 28 JABBER_PRESENCE_ERROR = -2, 29 JABBER_PRESENCE_PROBE = -1, 30 JABBER_PRESENCE_AVAILABLE, 31 JABBER_PRESENCE_UNAVAILABLE, 32 JABBER_PRESENCE_SUBSCRIBE, 33 JABBER_PRESENCE_SUBSCRIBED, 34 JABBER_PRESENCE_UNSUBSCRIBE, 35 JABBER_PRESENCE_UNSUBSCRIBED 36 } JabberPresenceType; 37 38 typedef struct _JabberPresenceChatInfo JabberPresenceChatInfo; 39 typedef struct _JabberPresence JabberPresence; 40 41 #include "buddy.h" 42 #include "chat.h" 43 #include "jabber.h" 44 #include "jutil.h" 45 #include "xmlnode.h" 46 47 struct _JabberPresenceChatInfo { 48 GSList *codes; 49 xmlnode *item; 50 }; 51 52 struct _JabberPresence { 53 JabberPresenceType type; 54 JabberID *jid_from; 55 const char *from; 56 const char *to; 57 const char *id; 58 59 JabberBuddy *jb; 60 JabberChat *chat; 61 JabberPresenceChatInfo chat_info; 62 xmlnode *caps; /* TODO: Temporary, see presence.c:parse_caps */ 63 64 JabberBuddyState state; 65 gchar *status; 66 int priority; 67 68 char *vcard_avatar_hash; 69 char *nickname; 70 71 gboolean delayed; 72 time_t sent; 73 int idle; 74 }; 75 76 typedef void (JabberPresenceHandler)(JabberStream *js, JabberPresence *presence, 77 xmlnode *child); 78 void jabber_presence_register_handler(const char *node, const char *xmlns, 79 JabberPresenceHandler *handler); 80 81 void jabber_presence_init(void); 82 void jabber_presence_uninit(void); 83 84 void jabber_set_status(PurpleAccount *account, PurpleStatus *status); 85 86 /** 87 * Send a full presence stanza. 88 * 89 * @param js A JabberStream object. 90 * @param force Force sending the presence stanza, irrespective of whether 91 * the contents seem to have changed. 92 */ 93 void jabber_presence_send(JabberStream *js, gboolean force); 94 95 xmlnode *jabber_presence_create(JabberBuddyState state, const char *msg, int priority); /* DEPRECATED */ 96 xmlnode *jabber_presence_create_js(JabberStream *js, JabberBuddyState state, const char *msg, int priority); 97 void jabber_presence_parse(JabberStream *js, xmlnode *packet); 98 void jabber_presence_subscription_set(JabberStream *js, const char *who, 99 const char *type); 100 void jabber_presence_fake_to_self(JabberStream *js, PurpleStatus *status); 101 void purple_status_to_jabber(const PurpleStatus *status, JabberBuddyState *state, char **msg, int *priority); 102 103 #endif /* PURPLE_JABBER_PRESENCE_H_ */ 104