Commit 517e2ca9 authored by Junker's avatar Junker
Browse files

main commit

parents
# HTTP File Upload plugin for libpurple (XMPP Protocol)
Experimental XEP-0363: HTTP File Upload plugin for libpurple (Pidgin, Finch, etc.)
/*
* purple - Jabber Protocol Plugin
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#ifndef PURPLE_JABBER_ADHOCCOMMANDS_H_
#define PURPLE_JABBER_ADHOCCOMMANDS_H_
#include "jabber.h"
/* Implementation of XEP-0050 */
void jabber_adhoc_disco_result_cb(JabberStream *js, const char *from,
JabberIqType type, const char *id,
xmlnode *packet, gpointer data);
void jabber_adhoc_execute(JabberStream *js, JabberAdHocCommands *cmd);
void jabber_adhoc_execute_action(PurpleBlistNode *node, gpointer data);
void jabber_adhoc_got_list(JabberStream *js, const char *from, xmlnode *query);
void jabber_adhoc_server_get_list(JabberStream *js);
void jabber_adhoc_init_server_commands(JabberStream *js, GList **m);
#endif /* PURPLE_JABBER_ADHOCCOMMANDS_H_ */
/**
* @file auth.h Authentication routines
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_H_
#define PURPLE_JABBER_AUTH_H_
typedef struct _JabberSaslMech JabberSaslMech;
#include "jabber.h"
#include "xmlnode.h"
typedef enum {
JABBER_SASL_STATE_FAIL = -1, /* Abort, Retry, Fail? */
JABBER_SASL_STATE_OK = 0, /* Hooray! */
JABBER_SASL_STATE_CONTINUE = 1 /* More authentication required */
} JabberSaslState;
struct _JabberSaslMech {
gint8 priority; /* Higher priority will be tried before lower priority */
const gchar *name;
JabberSaslState (*start)(JabberStream *js, xmlnode *mechanisms, xmlnode **reply, char **msg);
JabberSaslState (*handle_challenge)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg);
JabberSaslState (*handle_success)(JabberStream *js, xmlnode *packet, char **msg);
JabberSaslState (*handle_failure)(JabberStream *js, xmlnode *packet, xmlnode **reply, char **msg);
void (*dispose)(JabberStream *js);
};
void jabber_auth_start(JabberStream *js, xmlnode *packet);
void jabber_auth_start_old(JabberStream *js);
void jabber_auth_handle_challenge(JabberStream *js, xmlnode *packet);
void jabber_auth_handle_success(JabberStream *js, xmlnode *packet);
void jabber_auth_handle_failure(JabberStream *js, xmlnode *packet);
JabberSaslMech *jabber_auth_get_plain_mech(void);
JabberSaslMech *jabber_auth_get_digest_md5_mech(void);
JabberSaslMech **jabber_auth_get_scram_mechs(gint *count);
#ifdef HAVE_CYRUS_SASL
JabberSaslMech *jabber_auth_get_cyrus_mech(void);
#endif
void jabber_auth_add_mech(JabberSaslMech *);
void jabber_auth_remove_mech(JabberSaslMech *);
void jabber_auth_init(void);
void jabber_auth_uninit(void);
#endif /* PURPLE_JABBER_AUTH_H_ */
/**
* @file auth_digest_md5.h Implementation of SASL DIGEST-MD5 authentication
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_DIGEST_MD5_H_
#define PURPLE_JABBER_AUTH_DIGEST_MD5_H_
#include "internal.h"
/*
* Every function in this file is ONLY exposed for tests.
* DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
*/
/*
* Parse a DIGEST-MD5 challenge.
*/
GHashTable *jabber_auth_digest_md5_parse(const char *challenge);
#endif /* PURPLE_JABBER_AUTH_DIGEST_MD5_H_ */
/**
* @file auth_scram.h Implementation of SASL-SCRAM authentication
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_AUTH_SCRAM_H_
#define PURPLE_JABBER_AUTH_SCRAM_H_
/*
* Every function in this file is ONLY exposed for tests.
* DO NOT USE ANYTHING HERE OR YOU WILL BE SENT TO THE PIT OF DESPAIR.
*/
/* Per-connection state stored between messages.
* This is stored in js->auth_data_mech.
*/
typedef struct {
const char *mech_substr;
const char *name;
guint size;
} JabberScramHash;
typedef struct {
const JabberScramHash *hash;
char *cnonce;
GString *auth_message;
GString *client_proof;
GString *server_signature;
gchar *password;
gboolean channel_binding;
int step;
} JabberScramData;
#include "auth.h"
/**
* Implements the Hi() function as described in the SASL-SCRAM I-D.
*
* @param hash The struct corresponding to the hash function to be used.
* @param str The string to perform the PBKDF2 operation on.
* @param salt The salt.
* @param iterations The number of iterations to perform.
*
* @returns A newly allocated string containing the result. The string is
* NOT null-terminated and its length is the length of the binary
* output of the hash function in-use.
*/
guchar *jabber_scram_hi(const JabberScramHash *hash, const GString *str,
GString *salt, guint iterations);
/**
* Calculates the proofs as described in Section 3 of the SASL-SCRAM I-D.
*
* @param data A JabberScramData structure. hash and auth_message must be
* set. client_proof and server_signature will be set as a result
* of this function.
* @param salt The salt (as specified by the server)
* @param iterations The number of iterations to perform.
*
* @returns TRUE if the proofs were successfully calculated. FALSE otherwise.
*/
gboolean jabber_scram_calc_proofs(JabberScramData *data, GString *salt,
guint iterations);
/**
* Feed the algorithm with the data from the server.
*/
gboolean jabber_scram_feed_parser(JabberScramData *data, gchar *in, gchar **out);
/**
* Clean up and destroy the data struct
*/
void jabber_scram_data_destroy(JabberScramData *data);
#endif /* PURPLE_JABBER_AUTH_SCRAM_H_ */
/**
* @file bosh.h Bidirectional-streams over Synchronous HTTP (BOSH) (XEP-0124 and XEP-0206)
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_BOSH_H_
#define PURPLE_JABBER_BOSH_H_
typedef struct _PurpleBOSHConnection PurpleBOSHConnection;
#include "jabber.h"
void jabber_bosh_init(void);
void jabber_bosh_uninit(void);
PurpleBOSHConnection* jabber_bosh_connection_init(JabberStream *js, const char *url);
void jabber_bosh_connection_destroy(PurpleBOSHConnection *conn);
gboolean jabber_bosh_connection_is_ssl(PurpleBOSHConnection *conn);
void jabber_bosh_connection_send_keepalive(PurpleBOSHConnection *conn);
void jabber_bosh_connection_connect(PurpleBOSHConnection *conn);
void jabber_bosh_connection_close(PurpleBOSHConnection *conn);
void jabber_bosh_connection_send_raw(PurpleBOSHConnection *conn, const char *data);
#endif /* PURPLE_JABBER_BOSH_H_ */
/**
* @file buddy.h Buddy handlers
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_BUDDY_H_
#define PURPLE_JABBER_BUDDY_H_
typedef struct _JabberBuddy JabberBuddy;
#include "jabber.h"
#include "caps.h"
#include "jutil.h"
struct _JabberBuddy {
/**
* A sorted list of resources in priority descending order.
* This means that the first resource in the list is the
* "most available" (see resource_compare_cb in buddy.c for
* details). Don't play with this yourself, let
* jabber_buddy_track_resource and jabber_buddy_remove_resource do it.
*/
GList *resources;
char *error_msg;
enum {
JABBER_INVISIBLE_NONE = 0,
JABBER_INVISIBLE_SERVER = 1 << 1,
JABBER_INVIS_BUDDY = 1 << 2
} invisible;
enum {
JABBER_SUB_NONE = 0,
JABBER_SUB_PENDING = 1 << 1,
JABBER_SUB_TO = 1 << 2,
JABBER_SUB_FROM = 1 << 3,
JABBER_SUB_BOTH = (JABBER_SUB_TO | JABBER_SUB_FROM),
JABBER_SUB_REMOVE = 1 << 4
} subscription;
};
typedef struct _JabberAdHocCommands {
char *jid;
char *node;
char *name;
} JabberAdHocCommands;
typedef struct _JabberBuddyResource {
JabberBuddy *jb;
char *name;
int priority;
JabberBuddyState state;
char *status;
time_t idle;
JabberCapabilities capabilities;
char *thread_id;
enum {
JABBER_CHAT_STATES_UNKNOWN,
JABBER_CHAT_STATES_UNSUPPORTED,
JABBER_CHAT_STATES_SUPPORTED
} chat_states;
struct {
char *version;
char *name;
char *os;
} client;
/* tz_off == PURPLE_NO_TZ_OFF when unset */
long tz_off;
struct {
JabberCapsClientInfo *info;
GList *exts;
} caps;
GList *commands;
gboolean commands_fetched;
} JabberBuddyResource;
void jabber_buddy_free(JabberBuddy *jb);
JabberBuddy *jabber_buddy_find(JabberStream *js, const char *name,
gboolean create);
JabberBuddyResource *jabber_buddy_find_resource(JabberBuddy *jb,
const char *resource);
JabberBuddyResource *jabber_buddy_track_resource(JabberBuddy *jb, const char *resource,
int priority, JabberBuddyState state, const char *status);
void jabber_buddy_remove_resource(JabberBuddy *jb, const char *resource);
void jabber_buddy_get_info(PurpleConnection *gc, const char *who);
GList *jabber_blist_node_menu(PurpleBlistNode *node);
void jabber_set_info(PurpleConnection *gc, const char *info);
void jabber_setup_set_info(PurplePluginAction *action);
void jabber_set_buddy_icon(PurpleConnection *gc, PurpleStoredImage *img);
void jabber_user_search(JabberStream *js, const char *directory);
void jabber_user_search_begin(PurplePluginAction *);
void jabber_buddy_remove_all_pending_buddy_info_requests(JabberStream *js);
void jabber_vcard_fetch_mine(JabberStream *js);
gboolean jabber_resource_know_capabilities(const JabberBuddyResource *jbr);
gboolean jabber_resource_has_capability(const JabberBuddyResource *jbr,
const gchar *cap);
gboolean jabber_buddy_has_capability(const JabberBuddy *jb, const gchar *cap);
const gchar *
jabber_resource_get_identity_category_type(const JabberBuddyResource *jbr,
const gchar *category);
#endif /* PURPLE_JABBER_BUDDY_H_ */
/*
* purple - Jabber Protocol Plugin
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#ifndef PURPLE_JABBER_CAPS_H_
#define PURPLE_JABBER_CAPS_H_
typedef struct _JabberCapsClientInfo JabberCapsClientInfo;
#include "jabber.h"
/* Implementation of XEP-0115 - Entity Capabilities */
typedef struct _JabberCapsNodeExts JabberCapsNodeExts;
typedef struct _JabberCapsTuple {
const char *node;
const char *ver;
const char *hash;
} JabberCapsTuple;
struct _JabberCapsClientInfo {
GList *identities; /* JabberIdentity */
GList *features; /* char * */
GList *forms; /* xmlnode * */
JabberCapsNodeExts *exts;
const JabberCapsTuple tuple;
};
/*
* This stores a set of exts "known" for a specific node (which indicates
* a specific client -- for reference, Pidgin, Finch, Meebo, et al share one
* node.) In XEP-0115 v1.3, exts are used for features that may or may not be
* present at a given time (PEP things, buzz might be disabled, etc).
*
* This structure is shared among all JabberCapsClientInfo instances matching
* a specific node (if the capstable key->hash == NULL, which indicates that
* the ClientInfo is using v1.3 caps as opposed to v1.5 caps).
*
* It's only exposed so that jabber_resource_has_capability can use it.
* Everyone else, STAY AWAY!
*/
struct _JabberCapsNodeExts {
guint ref;
GHashTable *exts; /* char *ext_name -> GList *features */
};
typedef void (*jabber_caps_get_info_cb)(JabberCapsClientInfo *info, GList *exts, gpointer user_data);
void jabber_caps_init(void);
void jabber_caps_uninit(void);
/**
* Check whether all of the exts in a char* array are known to the given info.
*/
gboolean jabber_caps_exts_known(const JabberCapsClientInfo *info, char **exts);
/**
* Main entity capabilites function to get the capabilities of a contact.
*
* The callback will be called synchronously if we already have the
* capabilities for the specified (node,ver,hash) (and, if exts are specified,
* if we know what each means)
*
* @param exts A g_strsplit'd (NULL-terminated) array of strings. This
* function is responsible for freeing it.
*/
void jabber_caps_get_info(JabberStream *js, const char *who, const char *node,
const char *ver, const char *hash,
char **exts, jabber_caps_get_info_cb cb,
gpointer user_data);
/**
* Takes a JabberCapsClientInfo pointer and returns the caps hash according to
* XEP-0115 Version 1.5.
*
* @param info A JabberCapsClientInfo pointer.
* @param hash Hash cipher to be used. Either sha-1 or md5.
* @return The base64 encoded SHA-1 hash; must be freed by caller
*/
gchar *jabber_caps_calculate_hash(JabberCapsClientInfo *info, const char *hash);
/**
* Calculate SHA1 hash for own featureset.
*/
void jabber_caps_calculate_own_hash(JabberStream *js);
/** Get the current caps hash.
* @ret hash
**/
const gchar* jabber_caps_get_own_hash(JabberStream *js);
/**
* Broadcast a new calculated hash using a <presence> stanza.
*/
void jabber_caps_broadcast_change(void);
/**
* Parse the <query/> element from an IQ stanza into a JabberCapsClientInfo
* struct.
*
* Exposed for tests
*
* @param query The 'query' element from an IQ reply stanza.
* @returns A JabberCapsClientInfo struct, or NULL on error
*/
JabberCapsClientInfo *jabber_caps_parse_client_info(xmlnode *query);
#endif /* PURPLE_JABBER_CAPS_H_ */
/**
* @file chat.h Chat stuff
*
* purple
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*/
#ifndef PURPLE_JABBER_CHAT_H_
#define PURPLE_JABBER_CHAT_H_
#include "internal.h"
#include "connection.h"
#include "conversation.h"
#include "request.h"
#include "roomlist.h"
#include "jabber.h"
typedef struct _JabberChatMember {
char *handle;
char *jid;
} JabberChatMember;
typedef struct _JabberChat {
JabberStream *js;
char *room;
char *server;
char *handle;
GHashTable *components;
int id;
PurpleConversation *conv;
gboolean muc;
gboolean xhtml;
PurpleRequestType config_dialog_type;
void *config_dialog_handle;
GHashTable *members;
gboolean left;
time_t joined;
} JabberChat;
GList *jabber_chat_info(PurpleConnection *gc);
GHashTable *jabber_chat_info_defaults(PurpleConnection *gc, const char *chat_name);
char *jabber_get_chat_name(GHashTable *data);