2 * purple - Jabber Protocol Plugin
4 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program 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
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #ifndef PURPLE_JABBER_CAPS_H_
23 #define PURPLE_JABBER_CAPS_H_
25 typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
29 /* Implementation of XEP-0115 - Entity Capabilities */
31 typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
33 typedef struct _JabberCapsTuple {
39 struct _JabberCapsClientInfo {
40 GList *identities; /* JabberIdentity */
41 GList *features; /* char * */
42 GList *forms; /* xmlnode * */
43 JabberCapsNodeExts *exts;
45 const JabberCapsTuple tuple;
49 * This stores a set of exts "known" for a specific node (which indicates
50 * a specific client -- for reference, Pidgin, Finch, Meebo, et al share one
51 * node.) In XEP-0115 v1.3, exts are used for features that may or may not be
52 * present at a given time (PEP things, buzz might be disabled, etc).
54 * This structure is shared among all JabberCapsClientInfo instances matching
55 * a specific node (if the capstable key->hash == NULL, which indicates that
56 * the ClientInfo is using v1.3 caps as opposed to v1.5 caps).
58 * It's only exposed so that jabber_resource_has_capability can use it.
59 * Everyone else, STAY AWAY!
61 struct _JabberCapsNodeExts {
63 GHashTable *exts; /* char *ext_name -> GList *features */
66 typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
68 void jabber_caps_init(void);
69 void jabber_caps_uninit(void);
72 * Check whether all of the exts in a char* array are known to the given info.
74 gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts);
77 * Main entity capabilites function to get the capabilities of a contact.
79 * The callback will be called synchronously if we already have the
80 * capabilities for the specified (node,ver,hash) (and, if exts are specified,
81 * if we know what each means)
83 * @param exts A g_strsplit'd (NULL-terminated) array of strings. This
84 * function is responsible for freeing it.
86 void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
87 const char *ver, const char *hash,
88 char **exts, jabber_caps_get_info_cb cb,
92 * Takes a JabberCapsClientInfo pointer and returns the caps hash according to
93 * XEP-0115 Version 1.5.
95 * @param info A JabberCapsClientInfo pointer.
96 * @param hash Hash cipher to be used. Either sha-1 or md5.
97 * @return The base64 encoded SHA-1 hash; must be freed by caller
99 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash);
102 * Calculate SHA1 hash for own featureset.
104 void jabber_caps_calculate_own_hash(JabberStream *js);
106 /** Get the current caps hash.
109 const gchar* jabber_caps_get_own_hash(JabberStream *js);
112 * Broadcast a new calculated hash using a <presence> stanza.
114 void jabber_caps_broadcast_change(void);
116 #endif /* PURPLE_JABBER_CAPS_H_ */