1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/caps.h Fri Aug 21 13:25:11 2009 -0700
1.3 @@ -0,0 +1,116 @@
1.4 +/*
1.5 + * purple - Jabber Protocol Plugin
1.6 + *
1.7 + * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
1.8 + *
1.9 + * This program is free software; you can redistribute it and/or modify
1.10 + * it under the terms of the GNU General Public License as published by
1.11 + * the Free Software Foundation; either version 2 of the License, or
1.12 + * (at your option) any later version.
1.13 + *
1.14 + * This program is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.17 + * GNU General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU General Public License
1.20 + * along with this program; if not, write to the Free Software
1.21 + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1.22 + *
1.23 + */
1.24 +
1.25 +#ifndef PURPLE_JABBER_CAPS_H_
1.26 +#define PURPLE_JABBER_CAPS_H_
1.27 +
1.28 +typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
1.29 +
1.30 +#include "jabber.h"
1.31 +
1.32 +/* Implementation of XEP-0115 - Entity Capabilities */
1.33 +
1.34 +typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
1.35 +
1.36 +typedef struct _JabberCapsTuple {
1.37 + const char *node;
1.38 + const char *ver;
1.39 + const char *hash;
1.40 +} JabberCapsTuple;
1.41 +
1.42 +struct _JabberCapsClientInfo {
1.43 + GList *identities; /* JabberIdentity */
1.44 + GList *features; /* char * */
1.45 + GList *forms; /* xmlnode * */
1.46 + JabberCapsNodeExts *exts;
1.47 +
1.48 + const JabberCapsTuple tuple;
1.49 +};
1.50 +
1.51 +/*
1.52 + * This stores a set of exts "known" for a specific node (which indicates
1.53 + * a specific client -- for reference, Pidgin, Finch, Meebo, et al share one
1.54 + * node.) In XEP-0115 v1.3, exts are used for features that may or may not be
1.55 + * present at a given time (PEP things, buzz might be disabled, etc).
1.56 + *
1.57 + * This structure is shared among all JabberCapsClientInfo instances matching
1.58 + * a specific node (if the capstable key->hash == NULL, which indicates that
1.59 + * the ClientInfo is using v1.3 caps as opposed to v1.5 caps).
1.60 + *
1.61 + * It's only exposed so that jabber_resource_has_capability can use it.
1.62 + * Everyone else, STAY AWAY!
1.63 + */
1.64 +struct _JabberCapsNodeExts {
1.65 + guint ref;
1.66 + GHashTable *exts; /* char *ext_name -> GList *features */
1.67 +};
1.68 +
1.69 +typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
1.70 +
1.71 +void jabber_caps_init(void);
1.72 +void jabber_caps_uninit(void);
1.73 +
1.74 +/**
1.75 + * Check whether all of the exts in a char* array are known to the given info.
1.76 + */
1.77 +gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts);
1.78 +
1.79 +/**
1.80 + * Main entity capabilites function to get the capabilities of a contact.
1.81 + *
1.82 + * The callback will be called synchronously if we already have the
1.83 + * capabilities for the specified (node,ver,hash) (and, if exts are specified,
1.84 + * if we know what each means)
1.85 + *
1.86 + * @param exts A g_strsplit'd (NULL-terminated) array of strings. This
1.87 + * function is responsible for freeing it.
1.88 + */
1.89 +void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
1.90 + const char *ver, const char *hash,
1.91 + char **exts, jabber_caps_get_info_cb cb,
1.92 + gpointer user_data);
1.93 +
1.94 +/**
1.95 + * Takes a JabberCapsClientInfo pointer and returns the caps hash according to
1.96 + * XEP-0115 Version 1.5.
1.97 + *
1.98 + * @param info A JabberCapsClientInfo pointer.
1.99 + * @param hash Hash cipher to be used. Either sha-1 or md5.
1.100 + * @return The base64 encoded SHA-1 hash; must be freed by caller
1.101 + */
1.102 +gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash);
1.103 +
1.104 +/**
1.105 + * Calculate SHA1 hash for own featureset.
1.106 + */
1.107 +void jabber_caps_calculate_own_hash(JabberStream *js);
1.108 +
1.109 +/** Get the current caps hash.
1.110 + * @ret hash
1.111 +**/
1.112 +const gchar* jabber_caps_get_own_hash(JabberStream *js);
1.113 +
1.114 +/**
1.115 + * Broadcast a new calculated hash using a <presence> stanza.
1.116 + */
1.117 +void jabber_caps_broadcast_change(void);
1.118 +
1.119 +#endif /* PURPLE_JABBER_CAPS_H_ */