2 * purple - Jabber Protocol Plugin
4 * Purple is the legal property of its developers, whose names are too numerous
5 * to list here. Please refer to the COPYRIGHT file distributed with this
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
24 #ifndef PURPLE_JABBER_CAPS_H_
25 #define PURPLE_JABBER_CAPS_H_
27 typedef struct _JabberCapsClientInfo JabberCapsClientInfo
;
32 /* Implementation of XEP-0115 - Entity Capabilities */
34 typedef struct _JabberCapsNodeExts JabberCapsNodeExts
;
36 typedef struct _JabberCapsTuple
{
42 struct _JabberCapsClientInfo
{
43 GList
*identities
; /* JabberIdentity */
44 GList
*features
; /* char * */
45 GList
*forms
; /* PurpleXmlNode * */
46 JabberCapsNodeExts
*exts
;
48 const JabberCapsTuple tuple
;
52 * This stores a set of exts "known" for a specific node (which indicates
53 * a specific client -- for reference, Pidgin, Finch, Meebo, et al share one
54 * node.) In XEP-0115 v1.3, exts are used for features that may or may not be
55 * present at a given time (PEP things, buzz might be disabled, etc).
57 * This structure is shared among all JabberCapsClientInfo instances matching
58 * a specific node (if the capstable key->hash == NULL, which indicates that
59 * the ClientInfo is using v1.3 caps as opposed to v1.5 caps).
61 * It's only exposed so that jabber_resource_has_capability can use it.
62 * Everyone else, STAY AWAY!
64 struct _JabberCapsNodeExts
{
66 GHashTable
*exts
; /* char *ext_name -> GList *features */
69 typedef void (*jabber_caps_get_info_cb
)(JabberCapsClientInfo
*info
, GList
*exts
, gpointer user_data
);
71 void jabber_caps_init(void);
72 void jabber_caps_uninit(void);
75 * Check whether all of the exts in a char* array are known to the given info.
77 gboolean
jabber_caps_exts_known(const JabberCapsClientInfo
*info
, char **exts
);
80 * Main entity capabilites function to get the capabilities of a contact.
82 * The callback will be called synchronously if we already have the
83 * capabilities for the specified (node,ver,hash) (and, if exts are specified,
84 * if we know what each means)
86 * @param exts A g_strsplit'd (NULL-terminated) array of strings. This
87 * function is responsible for freeing it.
89 void jabber_caps_get_info(JabberStream
*js
, const char *who
, const char *node
,
90 const char *ver
, const char *hash
,
91 char **exts
, jabber_caps_get_info_cb cb
,
95 * Takes a JabberCapsClientInfo pointer and returns the caps hash according to
96 * XEP-0115 Version 1.5.
98 * @param info A JabberCapsClientInfo pointer.
99 * @param hash Hash cipher to be used. Either sha-1 or md5.
100 * @return The base64 encoded SHA-1 hash; must be freed by caller
102 gchar
*jabber_caps_calculate_hash(JabberCapsClientInfo
*info
, PurpleHash
*hash
);
105 * Calculate SHA1 hash for own featureset.
107 void jabber_caps_calculate_own_hash(JabberStream
*js
);
109 /** Get the current caps hash.
112 const gchar
* jabber_caps_get_own_hash(JabberStream
*js
);
115 * Broadcast a new calculated hash using a <presence> stanza.
117 void jabber_caps_broadcast_change(void);
120 * Parse the <query/> element from an IQ stanza into a JabberCapsClientInfo
125 * @param query The 'query' element from an IQ reply stanza.
126 * @returns A JabberCapsClientInfo struct, or NULL on error
128 JabberCapsClientInfo
*jabber_caps_parse_client_info(PurpleXmlNode
*query
);
130 #endif /* PURPLE_JABBER_CAPS_H_ */