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
Evan@653
     1
/*
Evan@653
     2
 * purple - Jabber Protocol Plugin
Evan@653
     3
 *
Evan@653
     4
 * Copyright (C) 2007, Andreas Monitzer <andy@monitzer.com>
Evan@653
     5
 *
Evan@653
     6
 * This program is free software; you can redistribute it and/or modify
Evan@653
     7
 * it under the terms of the GNU General Public License as published by
Evan@653
     8
 * the Free Software Foundation; either version 2 of the License, or
Evan@653
     9
 * (at your option) any later version.
Evan@653
    10
 *
Evan@653
    11
 * This program is distributed in the hope that it will be useful,
Evan@653
    12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Evan@653
    13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
Evan@653
    14
 * GNU General Public License for more details.
Evan@653
    15
 *
Evan@653
    16
 * You should have received a copy of the GNU General Public License
Evan@653
    17
 * along with this program; if not, write to the Free Software
Evan@653
    18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA	 02111-1307	 USA
Evan@653
    19
 *
Evan@653
    20
 */
Evan@653
    21
zacw@1759
    22
#ifndef PURPLE_JABBER_CAPS_H_
zacw@1759
    23
#define PURPLE_JABBER_CAPS_H_
Evan@653
    24
Evan@653
    25
typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
Evan@653
    26
Evan@653
    27
#include "jabber.h"
Evan@653
    28
zacw@2069
    29
/* Implementation of XEP-0115 - Entity Capabilities */
Evan@653
    30
zacw@2069
    31
typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
Evan@653
    32
zacw@2151
    33
typedef struct _JabberCapsTuple {
zacw@2151
    34
	const char *node;
zacw@2151
    35
	const char *ver;
zacw@2151
    36
	const char *hash;
zacw@2151
    37
} JabberCapsTuple;
zacw@2151
    38
Evan@653
    39
struct _JabberCapsClientInfo {
zacw@2069
    40
	GList *identities; /* JabberIdentity */
Evan@653
    41
	GList *features; /* char * */
zacw@2069
    42
	GList *forms; /* xmlnode * */
zacw@2069
    43
	JabberCapsNodeExts *exts;
zacw@2151
    44
zacw@2151
    45
	const JabberCapsTuple tuple;
Evan@653
    46
};
Evan@653
    47
zacw@2069
    48
/*
zacw@2069
    49
 * This stores a set of exts "known" for a specific node (which indicates
zacw@2069
    50
 * a specific client -- for reference, Pidgin, Finch, Meebo, et al share one
zacw@2069
    51
 * node.) In XEP-0115 v1.3, exts are used for features that may or may not be
zacw@2069
    52
 * present at a given time (PEP things, buzz might be disabled, etc).
zacw@2069
    53
 *
zacw@2069
    54
 * This structure is shared among all JabberCapsClientInfo instances matching
zacw@2069
    55
 * a specific node (if the capstable key->hash == NULL, which indicates that
zacw@2069
    56
 * the ClientInfo is using v1.3 caps as opposed to v1.5 caps).
zacw@2069
    57
 *
zacw@2069
    58
 * It's only exposed so that jabber_resource_has_capability can use it.
zacw@2069
    59
 * Everyone else, STAY AWAY!
zacw@2069
    60
 */
zacw@2069
    61
struct _JabberCapsNodeExts {
zacw@2069
    62
	guint ref;
zacw@2069
    63
	GHashTable *exts; /* char *ext_name -> GList *features */
zacw@2069
    64
};
zacw@2069
    65
zacw@2069
    66
typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
Evan@653
    67
Evan@653
    68
void jabber_caps_init(void);
zacw@2069
    69
void jabber_caps_uninit(void);
Evan@653
    70
zacw@2151
    71
/**
zacw@2151
    72
 * Check whether all of the exts in a char* array are known to the given info.
zacw@2151
    73
 */
zacw@2151
    74
gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts);
zacw@2069
    75
zacw@2069
    76
/**
zacw@2069
    77
 * Main entity capabilites function to get the capabilities of a contact.
zacw@2069
    78
 *
zacw@2069
    79
 * The callback will be called synchronously if we already have the
zacw@2069
    80
 * capabilities for the specified (node,ver,hash) (and, if exts are specified,
zacw@2069
    81
 * if we know what each means)
zacw@2151
    82
 *
zacw@2151
    83
 * @param exts A g_strsplit'd (NULL-terminated) array of strings. This
zacw@2151
    84
 *             function is responsible for freeing it.
zacw@2069
    85
 */
zacw@2069
    86
void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
zacw@2069
    87
                          const char *ver, const char *hash,
zacw@2151
    88
                          char **exts, jabber_caps_get_info_cb cb,
zacw@2069
    89
                          gpointer user_data);
zacw@2069
    90
zacw@2069
    91
/**
zacw@2069
    92
 *	Takes a JabberCapsClientInfo pointer and returns the caps hash according to
zacw@2069
    93
 *	XEP-0115 Version 1.5.
zacw@2069
    94
 *
zacw@2069
    95
 *	@param info A JabberCapsClientInfo pointer.
zacw@2069
    96
 *	@param hash Hash cipher to be used. Either sha-1 or md5.
zacw@2069
    97
 *	@return		The base64 encoded SHA-1 hash; must be freed by caller
zacw@2069
    98
 */
zacw@2069
    99
gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash);
zacw@2069
   100
zacw@2069
   101
/**
zacw@2069
   102
 *  Calculate SHA1 hash for own featureset.
zacw@2069
   103
 */
zacw@2069
   104
void jabber_caps_calculate_own_hash(JabberStream *js);
zacw@2069
   105
zacw@2069
   106
/** Get the current caps hash.
zacw@2069
   107
 * 	@ret hash
zacw@2069
   108
**/
zacw@2069
   109
const gchar* jabber_caps_get_own_hash(JabberStream *js);
zacw@2069
   110
zacw@2069
   111
/**
zacw@2069
   112
 *  Broadcast a new calculated hash using a <presence> stanza.
zacw@2069
   113
 */
zacw@2069
   114
void jabber_caps_broadcast_change(void);
Evan@653
   115
zacw@1759
   116
#endif /* PURPLE_JABBER_CAPS_H_ */