Frameworks/libpurple.framework/Versions/0.6.2/Headers/caps.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2151 Frameworks/libpurple.framework/Versions/0.6.0/Headers/caps.h@ff7dc80dc373
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
     1 /*
     2  * purple - Jabber Protocol Plugin
     3  *
     4  * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
     5  *
     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.
    10  *
    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.
    15  *
    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
    19  *
    20  */
    21 
    22 #ifndef PURPLE_JABBER_CAPS_H_
    23 #define PURPLE_JABBER_CAPS_H_
    24 
    25 typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
    26 
    27 #include "jabber.h"
    28 
    29 /* Implementation of XEP-0115 - Entity Capabilities */
    30 
    31 typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
    32 
    33 typedef struct _JabberCapsTuple {
    34 	const char *node;
    35 	const char *ver;
    36 	const char *hash;
    37 } JabberCapsTuple;
    38 
    39 struct _JabberCapsClientInfo {
    40 	GList *identities; /* JabberIdentity */
    41 	GList *features; /* char * */
    42 	GList *forms; /* xmlnode * */
    43 	JabberCapsNodeExts *exts;
    44 
    45 	const JabberCapsTuple tuple;
    46 };
    47 
    48 /*
    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).
    53  *
    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).
    57  *
    58  * It's only exposed so that jabber_resource_has_capability can use it.
    59  * Everyone else, STAY AWAY!
    60  */
    61 struct _JabberCapsNodeExts {
    62 	guint ref;
    63 	GHashTable *exts; /* char *ext_name -> GList *features */
    64 };
    65 
    66 typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
    67 
    68 void jabber_caps_init(void);
    69 void jabber_caps_uninit(void);
    70 
    71 /**
    72  * Check whether all of the exts in a char* array are known to the given info.
    73  */
    74 gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts);
    75 
    76 /**
    77  * Main entity capabilites function to get the capabilities of a contact.
    78  *
    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)
    82  *
    83  * @param exts A g_strsplit'd (NULL-terminated) array of strings. This
    84  *             function is responsible for freeing it.
    85  */
    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,
    89                           gpointer user_data);
    90 
    91 /**
    92  *	Takes a JabberCapsClientInfo pointer and returns the caps hash according to
    93  *	XEP-0115 Version 1.5.
    94  *
    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
    98  */
    99 gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash);
   100 
   101 /**
   102  *  Calculate SHA1 hash for own featureset.
   103  */
   104 void jabber_caps_calculate_own_hash(JabberStream *js);
   105 
   106 /** Get the current caps hash.
   107  * 	@ret hash
   108 **/
   109 const gchar* jabber_caps_get_own_hash(JabberStream *js);
   110 
   111 /**
   112  *  Broadcast a new calculated hash using a <presence> stanza.
   113  */
   114 void jabber_caps_broadcast_change(void);
   115 
   116 #endif /* PURPLE_JABBER_CAPS_H_ */