Sat, 17 Aug 2013 23:27:20 +0530
Renamed prpl.[ch] to protocol.[ch]
--- a/finch/finch.c Sat Aug 17 23:20:39 2013 +0530 +++ b/finch/finch.c Sat Aug 17 23:27:20 2013 +0530 @@ -31,7 +31,7 @@ #include "log.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "pounce.h" #include "savedstatuses.h" #include "sound.h"
--- a/finch/gntft.c Sat Aug 17 23:20:39 2013 +0530 +++ b/finch/gntft.c Sat Aug 17 23:27:20 2013 +0530 @@ -36,7 +36,7 @@ #include "debug.h" #include "notify.h" #include "ft.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" #include "gntft.h"
--- a/finch/gntpounce.c Sat Aug 17 23:20:39 2013 +0530 +++ b/finch/gntpounce.c Sat Aug 17 23:27:20 2013 +0530 @@ -43,7 +43,7 @@ #include "conversation.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "server.h" #include "util.h"
--- a/libpurple/Makefile.am Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/Makefile.am Sat Aug 17 23:27:20 2013 +0530 @@ -81,7 +81,7 @@ prefs.c \ presence.c \ proxy.c \ - prpl.c \ + protocol.c \ request.c \ roomlist.c \ savedstatuses.c \ @@ -152,7 +152,7 @@ prefs.h \ presence.h \ proxy.h \ - prpl.h \ + protocol.h \ request.h \ roomlist.h \ savedstatuses.h \ @@ -231,7 +231,7 @@ blistnodetypes.h buddylist.h buddyicon.h connection.h conversation.h \ conversationtypes.h conversations.h core.h ft.h log.h notify.h \ prefs.h presence.h roomlist.h savedstatuses.h smiley.h status.h \ - server.h util.h xmlnode.h prpl.h + server.h util.h xmlnode.h protocol.h purple_build_coreheaders = $(addprefix $(srcdir)/, $(purple_coreheaders)) \ $(addprefix $(srcdir)/media/, $(purple_mediaheaders)) \
--- a/libpurple/account.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/account.h Sat Aug 17 23:27:20 2013 +0530 @@ -53,7 +53,7 @@ #include "connection.h" #include "log.h" #include "proxy.h" -#include "prpl.h" +#include "protocol.h" #include "status.h" #include "keyring.h" #include "xmlnode.h"
--- a/libpurple/buddyicon.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/buddyicon.h Sat Aug 17 23:27:20 2013 +0530 @@ -38,7 +38,7 @@ #include "account.h" #include "buddylist.h" #include "imgstore.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" G_BEGIN_DECLS
--- a/libpurple/buddylist.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/buddylist.c Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "notify.h" #include "pounce.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "server.h" #include "signals.h" #include "util.h"
--- a/libpurple/connection.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/connection.h Sat Aug 17 23:27:20 2013 +0530 @@ -155,7 +155,7 @@ #include <time.h> #include "account.h" -#include "prpl.h" +#include "protocol.h" #include "status.h" #include "sslconn.h"
--- a/libpurple/conversation.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/conversation.c Sat Aug 17 23:27:20 2013 +0530 @@ -29,7 +29,7 @@ #include "imgstore.h" #include "notify.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "signals.h" #include "util.h"
--- a/libpurple/plugins/perl/common/module.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/plugins/perl/common/module.h Sat Aug 17 23:27:20 2013 +0530 @@ -60,7 +60,7 @@ #include "pounce.h" #include "prefs.h" #include "presence.h" -#include "prpl.h" +#include "protocol.h" #include "proxy.h" #include "request.h" #include "roomlist.h" @@ -233,7 +233,7 @@ typedef PurpleProxyInfo * Purple__ProxyInfo; typedef PurpleProxyType Purple__ProxyType; -/* prpl.h */ +/* protocol.h */ typedef PurpleBuddyIconSpec * Purple__Buddy__Icon__Spec; typedef PurpleIconScaleRules Purple__IconScaleRules; typedef PurplePluginProtocolInfo * Purple__PluginProtocolInfo;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocol.c Sat Aug 17 23:27:20 2013 +0530 @@ -0,0 +1,756 @@ +/* + * 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 + * + */ +#include "internal.h" +#include "accountopt.h" +#include "conversation.h" +#include "debug.h" +#include "network.h" +#include "notify.h" +#include "protocol.h" +#include "request.h" +#include "util.h" + +static GHashTable *protocols = NULL; + +/**************************************************************************/ +/** @name Attention Type API */ +/**************************************************************************/ + +struct _PurpleAttentionType +{ + const char *name; /**< Shown in GUI elements */ + const char *incoming_description; /**< Shown when sent */ + const char *outgoing_description; /**< Shown when receied */ + const char *icon_name; /**< Icon to display (optional) */ + const char *unlocalized_name; /**< Unlocalized name for UIs needing it */ +}; + + +PurpleAttentionType * +purple_attention_type_new(const char *ulname, const char *name, + const char *inc_desc, const char *out_desc) +{ + PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1); + + purple_attention_type_set_name(attn, name); + purple_attention_type_set_incoming_desc(attn, inc_desc); + purple_attention_type_set_outgoing_desc(attn, out_desc); + purple_attention_type_set_unlocalized_name(attn, ulname); + + return attn; +} + + +void +purple_attention_type_set_name(PurpleAttentionType *type, const char *name) +{ + g_return_if_fail(type != NULL); + + type->name = name; +} + +void +purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc) +{ + g_return_if_fail(type != NULL); + + type->incoming_description = desc; +} + +void +purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc) +{ + g_return_if_fail(type != NULL); + + type->outgoing_description = desc; +} + +void +purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name) +{ + g_return_if_fail(type != NULL); + + type->icon_name = name; +} + +void +purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname) +{ + g_return_if_fail(type != NULL); + + type->unlocalized_name = ulname; +} + +const char * +purple_attention_type_get_name(const PurpleAttentionType *type) +{ + g_return_val_if_fail(type != NULL, NULL); + + return type->name; +} + +const char * +purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) +{ + g_return_val_if_fail(type != NULL, NULL); + + return type->incoming_description; +} + +const char * +purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) +{ + g_return_val_if_fail(type != NULL, NULL); + + return type->outgoing_description; +} + +const char * +purple_attention_type_get_icon_name(const PurpleAttentionType *type) +{ + g_return_val_if_fail(type != NULL, NULL); + + if(type->icon_name == NULL || *(type->icon_name) == '\0') + return NULL; + + return type->icon_name; +} + +const char * +purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) +{ + g_return_val_if_fail(type != NULL, NULL); + + return type->unlocalized_name; +} + +/**************************************************************************/ +/** @name Protocol Plugin API */ +/**************************************************************************/ +void +purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle, + time_t idle_time) +{ + g_return_if_fail(account != NULL); + g_return_if_fail(purple_account_is_connected(account)); + + purple_presence_set_idle(purple_account_get_presence(account), + idle, idle_time); +} + +void +purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time) +{ + PurplePresence *presence; + + g_return_if_fail(account != NULL); + g_return_if_fail(purple_account_is_connected(account)); + + if (login_time == 0) + login_time = time(NULL); + + presence = purple_account_get_presence(account); + + purple_presence_set_login_time(presence, login_time); +} + +void +purple_prpl_got_account_status(PurpleAccount *account, const char *status_id, ...) +{ + PurplePresence *presence; + PurpleStatus *status; + va_list args; + + g_return_if_fail(account != NULL); + g_return_if_fail(status_id != NULL); + g_return_if_fail(purple_account_is_connected(account)); + + presence = purple_account_get_presence(account); + status = purple_presence_get_status(presence, status_id); + + g_return_if_fail(status != NULL); + + va_start(args, status_id); + purple_status_set_active_with_attrs(status, TRUE, args); + va_end(args); +} + +void +purple_prpl_got_account_actions(PurpleAccount *account) +{ + + g_return_if_fail(account != NULL); + g_return_if_fail(purple_account_is_connected(account)); + + purple_signal_emit(purple_accounts_get_handle(), "account-actions-changed", + account); +} + +void +purple_prpl_got_user_idle(PurpleAccount *account, const char *name, + gboolean idle, time_t idle_time) +{ + PurplePresence *presence; + GSList *list; + + g_return_if_fail(account != NULL); + g_return_if_fail(name != NULL); + g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); + + if ((list = purple_blist_find_buddies(account, name)) == NULL) + return; + + while (list) { + presence = purple_buddy_get_presence(list->data); + list = g_slist_delete_link(list, list); + purple_presence_set_idle(presence, idle, idle_time); + } +} + +void +purple_prpl_got_user_login_time(PurpleAccount *account, const char *name, + time_t login_time) +{ + GSList *list; + PurplePresence *presence; + + g_return_if_fail(account != NULL); + g_return_if_fail(name != NULL); + + if ((list = purple_blist_find_buddies(account, name)) == NULL) + return; + + if (login_time == 0) + login_time = time(NULL); + + while (list) { + PurpleBuddy *buddy = list->data; + presence = purple_buddy_get_presence(buddy); + list = g_slist_delete_link(list, list); + + if (purple_presence_get_login_time(presence) != login_time) + { + purple_presence_set_login_time(presence, login_time); + + purple_signal_emit(purple_blist_get_handle(), "buddy-got-login-time", buddy); + } + } +} + +void +purple_prpl_got_user_status(PurpleAccount *account, const char *name, + const char *status_id, ...) +{ + GSList *list, *l; + PurpleBuddy *buddy; + PurplePresence *presence; + PurpleStatus *status; + PurpleStatus *old_status; + va_list args; + + g_return_if_fail(account != NULL); + g_return_if_fail(name != NULL); + g_return_if_fail(status_id != NULL); + g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); + + if((list = purple_blist_find_buddies(account, name)) == NULL) + return; + + for(l = list; l != NULL; l = l->next) { + buddy = l->data; + + presence = purple_buddy_get_presence(buddy); + status = purple_presence_get_status(presence, status_id); + + if(NULL == status) + /* + * TODO: This should never happen, right? We should call + * g_warning() or something. + */ + continue; + + old_status = purple_presence_get_active_status(presence); + + va_start(args, status_id); + purple_status_set_active_with_attrs(status, TRUE, args); + va_end(args); + + purple_buddy_update_status(buddy, old_status); + } + + g_slist_free(list); + + /* The buddy is no longer online, they are therefore by definition not + * still typing to us. */ + if (!purple_status_is_online(status)) { + serv_got_typing_stopped(purple_account_get_connection(account), name); + purple_prpl_got_media_caps(account, name); + } +} + +void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name, + const char *status_id) +{ + GSList *list, *l; + PurpleBuddy *buddy; + PurplePresence *presence; + PurpleStatus *status; + + g_return_if_fail(account != NULL); + g_return_if_fail(name != NULL); + g_return_if_fail(status_id != NULL); + g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); + + if((list = purple_blist_find_buddies(account, name)) == NULL) + return; + + for(l = list; l != NULL; l = l->next) { + buddy = l->data; + + presence = purple_buddy_get_presence(buddy); + status = purple_presence_get_status(presence, status_id); + + if(NULL == status) + continue; + + if (purple_status_is_active(status)) { + purple_status_set_active(status, FALSE); + purple_buddy_update_status(buddy, status); + } + } + + g_slist_free(list); +} + +static void +do_prpl_change_account_status(PurpleAccount *account, + PurpleStatus *old_status, PurpleStatus *new_status) +{ + PurplePluginProtocolInfo *prpl_info; + + if (purple_status_is_online(new_status) && + purple_account_is_disconnected(account) && + purple_network_is_available()) + { + purple_account_connect(account); + return; + } + + if (!purple_status_is_online(new_status)) + { + if (!purple_account_is_disconnected(account)) + purple_account_disconnect(account); + /* Clear out the unsaved password if we switch to offline status */ + if (!purple_account_get_remember_password(account)) + purple_account_set_password(account, NULL, NULL, NULL); + + return; + } + + if (purple_account_is_connecting(account)) + /* + * We don't need to call the set_status PRPL function because + * the PRPL will take care of setting its status during the + * connection process. + */ + return; + + prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account)); + + if (prpl_info == NULL) + return; + + if (!purple_account_is_disconnected(account) && prpl_info->set_status != NULL) + { + prpl_info->set_status(account, new_status); + } +} + +void +purple_prpl_change_account_status(PurpleAccount *account, + PurpleStatus *old_status, PurpleStatus *new_status) +{ + g_return_if_fail(account != NULL); + g_return_if_fail(new_status != NULL); + g_return_if_fail(!purple_status_is_exclusive(new_status) || old_status != NULL); + + do_prpl_change_account_status(account, old_status, new_status); + + purple_signal_emit(purple_accounts_get_handle(), "account-status-changed", + account, old_status, new_status); +} + +GList * +purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence) +{ + GList *statuses = NULL; + GList *l; + PurpleStatus *status; + + g_return_val_if_fail(account != NULL, NULL); + g_return_val_if_fail(presence != NULL, NULL); + + for (l = purple_account_get_status_types(account); l != NULL; l = l->next) + { + status = purple_status_new((PurpleStatusType *)l->data, presence); + statuses = g_list_prepend(statuses, status); + } + + statuses = g_list_reverse(statuses); + + return statuses; +} + +static void +purple_prpl_attention(PurpleConversation *conv, const char *who, + guint type, PurpleMessageFlags flags, time_t mtime) +{ + PurpleAccount *account = purple_conversation_get_account(conv); + purple_signal_emit(purple_conversations_get_handle(), + flags == PURPLE_MESSAGE_SEND ? "sent-attention" : "got-attention", + account, who, conv, type); +} + +void +purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code) +{ + PurpleAttentionType *attn; + PurpleMessageFlags flags; + PurplePluginProtocolInfo *prpl_info; + PurpleIMConversation *im; + gboolean (*send_attention)(PurpleConnection *, const char *, guint); + PurpleBuddy *buddy; + const char *alias; + gchar *description; + time_t mtime; + + g_return_if_fail(gc != NULL); + g_return_if_fail(who != NULL); + + prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_connection_get_account(gc))); + send_attention = prpl_info->send_attention; + g_return_if_fail(send_attention != NULL); + + mtime = time(NULL); + + attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code); + + if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL) + alias = purple_buddy_get_contact_alias(buddy); + else + alias = who; + + if (attn && purple_attention_type_get_outgoing_desc(attn)) { + description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias); + } else { + description = g_strdup_printf(_("Requesting %s's attention..."), alias); + } + + flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM; + + purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n", + description, who); + + if (!send_attention(gc, who, type_code)) + return; + + im = purple_im_conversation_new(purple_connection_get_account(gc), who); + purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, description, flags, mtime); + purple_prpl_attention(PURPLE_CONVERSATION(im), who, type_code, PURPLE_MESSAGE_SEND, time(NULL)); + + g_free(description); +} + +static void +got_attention(PurpleConnection *gc, int id, const char *who, guint type_code) +{ + PurpleMessageFlags flags; + PurpleAttentionType *attn; + PurpleBuddy *buddy; + const char *alias; + gchar *description; + time_t mtime; + + mtime = time(NULL); + + attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code); + + /* PURPLE_MESSAGE_NOTIFY is for attention messages. */ + flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV; + + /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display + * it next to the attention command. And if it is null, display a generic icon. */ + + if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL) + alias = purple_buddy_get_contact_alias(buddy); + else + alias = who; + + if (attn && purple_attention_type_get_incoming_desc(attn)) { + description = g_strdup_printf(purple_attention_type_get_incoming_desc(attn), alias); + } else { + description = g_strdup_printf(_("%s has requested your attention!"), alias); + } + + purple_debug_info("server", "got_attention: got '%s' from %s\n", + description, who); + + if (id == -1) + serv_got_im(gc, who, description, flags, mtime); + else + serv_got_chat_in(gc, id, who, flags, description, mtime); + + /* TODO: sounds (depending on PurpleAttentionType), shaking, etc. */ + + g_free(description); +} + +void +purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code) +{ + PurpleConversation *conv = NULL; + PurpleAccount *account = purple_connection_get_account(gc); + + got_attention(gc, -1, who, type_code); + conv = + purple_conversations_find_with_account(who, account); + if (conv) + purple_prpl_attention(conv, who, type_code, PURPLE_MESSAGE_RECV, + time(NULL)); +} + +void +purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code) +{ + got_attention(gc, id, who, type_code); +} + +gboolean +purple_prpl_initiate_media(PurpleAccount *account, + const char *who, + PurpleMediaSessionType type) +{ +#ifdef USE_VV + PurpleConnection *gc = NULL; + PurplePluginProtocolInfo *prpl_info = NULL; + + if (account) + gc = purple_account_get_connection(account); + if (gc) + prpl_info = purple_connection_get_protocol_info(gc); + + if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, initiate_media)) { + /* should check that the protocol supports this media type here? */ + return prpl_info->initiate_media(account, who, type); + } else +#endif + return FALSE; +} + +PurpleMediaCaps +purple_prpl_get_media_caps(PurpleAccount *account, const char *who) +{ +#ifdef USE_VV + PurpleConnection *gc = NULL; + PurplePluginProtocolInfo *prpl_info = NULL; + + if (account) + gc = purple_account_get_connection(account); + if (gc) + prpl_info = purple_connection_get_protocol_info(gc); + + if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, + get_media_caps)) { + return prpl_info->get_media_caps(account, who); + } +#endif + return PURPLE_MEDIA_CAPS_NONE; +} + +void +purple_prpl_got_media_caps(PurpleAccount *account, const char *name) +{ +#ifdef USE_VV + GSList *list; + + g_return_if_fail(account != NULL); + g_return_if_fail(name != NULL); + + if ((list = purple_blist_find_buddies(account, name)) == NULL) + return; + + while (list) { + PurpleBuddy *buddy = list->data; + PurpleMediaCaps oldcaps = purple_buddy_get_media_caps(buddy); + PurpleMediaCaps newcaps = 0; + const gchar *bname = purple_buddy_get_name(buddy); + list = g_slist_delete_link(list, list); + + + newcaps = purple_prpl_get_media_caps(account, bname); + purple_buddy_set_media_caps(buddy, newcaps); + + if (oldcaps == newcaps) + continue; + + purple_signal_emit(purple_blist_get_handle(), + "buddy-caps-changed", buddy, + newcaps, oldcaps); + } +#endif +} + +PurpleProtocolAction * +purple_protocol_action_new(const char* label, + PurpleProtocolActionCallback callback) +{ + PurpleProtocolAction *action; + + g_return_val_if_fail(label != NULL && callback != NULL, NULL); + + action = g_new0(PurpleProtocolAction, 1); + + action->label = g_strdup(label); + action->callback = callback; + + return action; +} + +void +purple_protocol_action_free(PurpleProtocolAction *action) +{ + g_return_if_fail(action != NULL); + + g_free(action->label); + g_free(action); +} + +/************************************************************************** + * Protocols API + **************************************************************************/ +static void +purple_protocol_destroy(PurplePluginProtocolInfo *prpl_info) +{ + GList *accounts, *l; + + accounts = purple_accounts_get_all_active(); + for (l = accounts; l != NULL; l = l->next) { + PurpleAccount *account = PURPLE_ACCOUNT(l->data); + if (purple_account_is_disconnected(account)) + continue; + + if (purple_strequal(prpl_info->id, purple_account_get_protocol_id(account))) + purple_account_disconnect(account); + } + + g_list_free(accounts); + + while (prpl_info->user_splits) { + PurpleAccountUserSplit *split = prpl_info->user_splits->data; + purple_account_user_split_destroy(split); + prpl_info->user_splits = g_list_delete_link(prpl_info->user_splits, + prpl_info->user_splits); + } + + while (prpl_info->protocol_options) { + PurpleAccountOption *option = prpl_info->protocol_options->data; + purple_account_option_destroy(option); + prpl_info->protocol_options = + g_list_delete_link(prpl_info->protocol_options, + prpl_info->protocol_options); + } + + purple_request_close_with_handle(prpl_info); + purple_notify_close_with_handle(prpl_info); + + purple_signals_disconnect_by_handle(prpl_info); + purple_signals_unregister_by_instance(prpl_info); + + purple_prefs_disconnect_by_handle(prpl_info); +} + +PurplePluginProtocolInfo * +purple_find_protocol_info(const char *id) +{ + return g_hash_table_lookup(protocols, id); +} + +gboolean +purple_protocols_add(PurplePluginProtocolInfo *prpl_info) +{ + if (purple_find_protocol_info(prpl_info->id)) + return FALSE; + + g_hash_table_insert(protocols, g_strdup(prpl_info->id), prpl_info); + return TRUE; +} + +gboolean purple_protocols_remove(PurplePluginProtocolInfo *prpl_info) +{ + if (purple_find_protocol_info(prpl_info->id) == NULL) + return FALSE; + + g_hash_table_remove(protocols, prpl_info->id); + purple_protocol_destroy(prpl_info); + + return TRUE; +} + +GList * +purple_protocols_get_all(void) +{ + GList *ret = NULL; + PurplePluginProtocolInfo *prpl_info; + GHashTableIter iter; + + g_hash_table_iter_init(&iter, protocols); + while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&prpl_info)) + ret = g_list_append(ret, prpl_info); + + return ret; +} + +/************************************************************************** + * Protocols Subsystem API + **************************************************************************/ +void +purple_protocols_init(void) +{ + protocols = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, + (GDestroyNotify)purple_protocol_destroy); +} + +void * +purple_protocols_get_handle(void) +{ + static int handle; + + return &handle; +} + +void +purple_protocols_uninit(void) +{ + g_hash_table_destroy(protocols); +} +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocol.h Sat Aug 17 23:27:20 2013 +0530 @@ -0,0 +1,1055 @@ +/** + * @file protocol.h Protocol Plugin functions + * @ingroup core + */ + +/* 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 + */ + +/* this file should be all that prpls need to include. therefore, by including + * this file, they should get glib, proxy, purple_connection, prpl, etc. */ + +#ifndef _PURPLE_PRPL_H_ +#define _PURPLE_PRPL_H_ + +typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo; + +typedef struct _PurpleProtocolAction PurpleProtocolAction; + +typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *); + +/** Represents "nudges" and "buzzes" that you may send to a buddy to attract + * their attention (or vice-versa). + */ +typedef struct _PurpleAttentionType PurpleAttentionType; + +/**************************************************************************/ +/** @name Basic Protocol Information */ +/**************************************************************************/ + +typedef enum { + PURPLE_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */ + PURPLE_ICON_SCALE_SEND = 0x02 /**< We scale the icon before we send it to the server */ +} PurpleIconScaleRules; + + +/** + * A description of a Buddy Icon specification. This tells Purple what kind of image file + * it should give this prpl, and what kind of image file it should expect back. + * Dimensions less than 1 should be ignored and the image not scaled. + */ +typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec; + +/** + * A description of a file transfer thumbnail specification. + * This tells the UI if and what image formats the prpl support for file + * transfer thumbnails. + */ +typedef struct _PurpleThumbnailSpec PurpleThumbnailSpec; + +/** + * This \#define exists just to make it easier to fill out the buddy icon + * field in the prpl info struct for protocols that couldn't care less. + */ +#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0} + +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + +#include "buddylist.h" +#include "conversations.h" +#include "ft.h" +#include "imgstore.h" +#include "media.h" +#include "notify.h" +#include "proxy.h" +#include "roomlist.h" +#include "status.h" +#include "whiteboard.h" + + +/** @copydoc PurpleBuddyIconSpec */ +struct _PurpleBuddyIconSpec { + /** This is a comma-delimited list of image formats or @c NULL if icons + * are not supported. Neither the core nor the prpl will actually + * check to see if the data it's given matches this; it's entirely up + * to the UI to do what it wants + */ + char *format; + + int min_width; /**< Minimum width of this icon */ + int min_height; /**< Minimum height of this icon */ + int max_width; /**< Maximum width of this icon */ + int max_height; /**< Maximum height of this icon */ + size_t max_filesize; /**< Maximum size in bytes */ + PurpleIconScaleRules scale_rules; /**< How to stretch this icon */ +}; + +/** Represents an entry containing information that must be supplied by the + * user when joining a chat. + */ +struct proto_chat_entry { + const char *label; /**< User-friendly name of the entry */ + const char *identifier; /**< Used by the PRPL to identify the option */ + gboolean required; /**< True if it's required */ + gboolean is_int; /**< True if the entry expects an integer */ + int min; /**< Minimum value in case of integer */ + int max; /**< Maximum value in case of integer */ + gboolean secret; /**< True if the entry is secret (password) */ +}; + +/** + * Protocol options + * + * These should all be stuff that some plugins can do and others can't. + */ +typedef enum +{ + /** + * User names are unique to a chat and are not shared between rooms. + * + * XMPP lets you choose what name you want in chats, so it shouldn't + * be pulling the aliases from the buddy list for the chat list; + * it gets annoying. + */ + OPT_PROTO_UNIQUE_CHATNAME = 0x00000004, + + /** + * Chat rooms have topics. + * + * IRC and XMPP support this. + */ + OPT_PROTO_CHAT_TOPIC = 0x00000008, + + /** + * Don't require passwords for sign-in. + * + * Zephyr doesn't require passwords, so there's no + * need for a password prompt. + */ + OPT_PROTO_NO_PASSWORD = 0x00000010, + + /** + * Notify on new mail. + * + * MSN and Yahoo notify you when you have new mail. + */ + OPT_PROTO_MAIL_CHECK = 0x00000020, + + /** + * Images in IMs. + * + * Oscar lets you send images in direct IMs. + */ + OPT_PROTO_IM_IMAGE = 0x00000040, + + /** + * Allow passwords to be optional. + * + * Passwords in IRC are optional, and are needed for certain + * functionality. + */ + OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080, + + /** + * Allows font size to be specified in sane point size + * + * Probably just XMPP and Y!M + */ + OPT_PROTO_USE_POINTSIZE = 0x00000100, + + /** + * Set the Register button active even when the username has not + * been specified. + * + * Gadu-Gadu doesn't need a username to register new account (because + * usernames are assigned by the server). + */ + OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200, + + /** + * Indicates that slash commands are native to this protocol. + * Used as a hint that unknown commands should not be sent as messages. + */ + OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400, + + /** + * Indicates that this protocol supports sending a user-supplied message + * along with an invitation. + */ + OPT_PROTO_INVITE_MESSAGE = 0x00000800, + + /** + * Indicates that this protocol supports sending a user-supplied message + * along with an authorization acceptance. + */ + OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE = 0x00001000, + + /** + * Indicates that this protocol supports sending a user-supplied message + * along with an authorization denial. + */ + OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE = 0x00002000 + +} PurpleProtocolOptions; + +/** + * Represents an action that the protocol can perform. This shows up in the + * Accounts menu, under a submenu with the name of the account. + */ +struct _PurpleProtocolAction { + char *label; + PurpleProtocolActionCallback callback; + PurpleConnection *connection; + gpointer user_data; +}; + +/** + * A protocol plugin information structure. + * + * Every protocol plugin initializes this structure. It is the gateway + * between purple and the protocol plugin. Many of these callbacks can be + * NULL. If a callback must be implemented, it has a comment indicating so. + */ +struct _PurplePluginProtocolInfo +{ + const char *id; + const char *name; + + /** + * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo). + * This allows adding more functions to this struct without requiring a major version bump. + */ + unsigned long struct_size; + + /* NOTE: + * If more functions are added, they should accessed using the following syntax: + * + * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function)) + * prpl->new_function(...); + * + * instead of + * + * if (prpl->new_function != NULL) + * prpl->new_function(...); + * + * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member + * functions (e.g. login, send_im etc.) too. + */ + + PurpleProtocolOptions options; /**< Protocol options. */ + + GList *user_splits; /**< A GList of PurpleAccountUserSplit */ + GList *protocol_options; /**< A GList of PurpleAccountOption */ + + PurpleBuddyIconSpec icon_spec; /**< The icon spec. */ + + /** + * Callback that returns the actions the protocol can perform + */ + GList *(*get_actions)(PurpleConnection *); + + /** + * Returns the base icon name for the given buddy and account. + * If buddy is NULL and the account is non-NULL, it will return the + * name to use for the account's icon. If both are NULL, it will + * return the name to use for the protocol's icon. + * + * This must be implemented. + */ + const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy); + + /** + * Fills the four char**'s with string identifiers for "emblems" + * that the UI will interpret and display as relevant + */ + const char *(*list_emblem)(PurpleBuddy *buddy); + + /** + * Gets a short string representing this buddy's status. This will + * be shown on the buddy list. + */ + char *(*status_text)(PurpleBuddy *buddy); + + /** + * Allows the prpl to add text to a buddy's tooltip. + */ + void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full); + + /** + * Returns a list of #PurpleStatusType which exist for this account; + * this must be implemented, and must add at least the offline and + * online states. + */ + GList *(*status_types)(PurpleAccount *account); + + /** + * Returns a list of #PurpleMenuAction structs, which represent extra + * actions to be shown in (for example) the right-click menu for @a + * node. + */ + GList *(*blist_node_menu)(PurpleBlistNode *node); + + /** + * Returns a list of #proto_chat_entry structs, which represent + * information required by the PRPL to join a chat. libpurple will + * call join_chat along with the information filled by the user. + * + * @return A list of #proto_chat_entry structs + */ + GList *(*chat_info)(PurpleConnection *); + + /** + * Returns a hashtable which maps #proto_chat_entry struct identifiers + * to default options as strings based on chat_name. The resulting + * hashtable should be created with g_hash_table_new_full(g_str_hash, + * g_str_equal, NULL, g_free);. Use #get_chat_name if you instead need + * to extract a chat name from a hashtable. + * + * @param chat_name The chat name to be turned into components + * @return Hashtable containing the information extracted from chat_name + */ + GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name); + + /* All the server-related functions */ + + /** This must be implemented. */ + void (*login)(PurpleAccount *); + + /** This must be implemented. */ + void (*close)(PurpleConnection *); + + /** + * This PRPL function should return a positive value on success. + * If the message is too big to be sent, return -E2BIG. If + * the account is not connected, return -ENOTCONN. If the + * PRPL is unable to send the message for another reason, return + * some other negative value. You can use one of the valid + * errno values, or just big something. If the message should + * not be echoed to the conversation window, return 0. + */ + int (*send_im)(PurpleConnection *, const char *who, + const char *message, + PurpleMessageFlags flags); + + void (*set_info)(PurpleConnection *, const char *info); + + /** + * @return If this protocol requires the PURPLE_IM_TYPING message to + * be sent repeatedly to signify that the user is still + * typing, then the PRPL should return the number of + * seconds to wait before sending a subsequent notification. + * Otherwise the PRPL should return 0. + */ + unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleIMTypingState state); + + /** + * Should arrange for purple_notify_userinfo() to be called with + * @a who's user info. + */ + void (*get_info)(PurpleConnection *, const char *who); + void (*set_status)(PurpleAccount *account, PurpleStatus *status); + + void (*set_idle)(PurpleConnection *, int idletime); + void (*change_passwd)(PurpleConnection *, const char *old_pass, + const char *new_pass); + + /** + * Add a buddy to a group on the server. + * + * This PRPL function may be called in situations in which the buddy is + * already in the specified group. If the protocol supports + * authorization and the user is not already authorized to see the + * status of \a buddy, \a add_buddy should request authorization. + * + * If authorization is required, then use the supplied invite message. + */ + void (*add_buddy)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message); + void (*add_buddies)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message); + void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); + void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups); + void (*add_permit)(PurpleConnection *, const char *name); + void (*add_deny)(PurpleConnection *, const char *name); + void (*rem_permit)(PurpleConnection *, const char *name); + void (*rem_deny)(PurpleConnection *, const char *name); + void (*set_permit_deny)(PurpleConnection *); + + /** + * Called when the user requests joining a chat. Should arrange for + * #serv_got_joined_chat to be called. + * + * @param components A hashtable containing information required to + * join the chat as described by the entries returned + * by #chat_info. It may also be called when accepting + * an invitation, in which case this matches the + * data parameter passed to #serv_got_chat_invite. + */ + void (*join_chat)(PurpleConnection *, GHashTable *components); + + /** + * Called when the user refuses a chat invitation. + * + * @param components A hashtable containing information required to + * join the chat as passed to #serv_got_chat_invite. + */ + void (*reject_chat)(PurpleConnection *, GHashTable *components); + + /** + * Returns a chat name based on the information in components. Use + * #chat_info_defaults if you instead need to generate a hashtable + * from a chat name. + * + * @param components A hashtable containing information about the chat. + */ + char *(*get_chat_name)(GHashTable *components); + + /** + * Invite a user to join a chat. + * + * @param id The id of the chat to invite the user to. + * @param message A message displayed to the user when the invitation + * is received. + * @param who The name of the user to send the invation to. + */ + void (*chat_invite)(PurpleConnection *, int id, + const char *message, const char *who); + /** + * Called when the user requests leaving a chat. + * + * @param id The id of the chat to leave + */ + void (*chat_leave)(PurpleConnection *, int id); + + /** + * Send a whisper to a user in a chat. + * + * @param id The id of the chat. + * @param who The name of the user to send the whisper to. + * @param message The message of the whisper. + */ + void (*chat_whisper)(PurpleConnection *, int id, + const char *who, const char *message); + + /** + * Send a message to a chat. + * This PRPL function should return a positive value on success. + * If the message is too big to be sent, return -E2BIG. If + * the account is not connected, return -ENOTCONN. If the + * PRPL is unable to send the message for another reason, return + * some other negative value. You can use one of the valid + * errno values, or just big something. + * + * @param id The id of the chat to send the message to. + * @param message The message to send to the chat. + * @param flags A bitwise OR of #PurpleMessageFlags representing + * message flags. + * @return A positive number or 0 in case of success, + * a negative error number in case of failure. + */ + int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags); + + /** If implemented, this will be called regularly for this prpl's + * active connections. You'd want to do this if you need to repeatedly + * send some kind of keepalive packet to the server to avoid being + * disconnected. ("Regularly" is defined by + * <code>KEEPALIVE_INTERVAL</code> in <tt>libpurple/connection.c</tt>.) + */ + void (*keepalive)(PurpleConnection *); + + /** new user registration */ + void (*register_user)(PurpleAccount *); + + /** + * @deprecated Use #PurplePluginProtocolInfo.get_info instead. + */ + void (*get_cb_info)(PurpleConnection *, int, const char *who); + + /** save/store buddy's alias on server list/roster */ + void (*alias_buddy)(PurpleConnection *, const char *who, + const char *alias); + + /** change a buddy's group on a server list/roster */ + void (*group_buddy)(PurpleConnection *, const char *who, + const char *old_group, const char *new_group); + + /** rename a group on a server list/roster */ + void (*rename_group)(PurpleConnection *, const char *old_name, + PurpleGroup *group, GList *moved_buddies); + + void (*buddy_free)(PurpleBuddy *); + + void (*convo_closed)(PurpleConnection *, const char *who); + + /** + * Convert the username @a who to its canonical form. Also checks for + * validity. + * + * For example, AIM treats "fOo BaR" and "foobar" as the same user; this + * function should return the same normalized string for both of those. + * On the other hand, both of these are invalid for protocols with + * number-based usernames, so function should return NULL in such case. + * + * @param account The account the username is related to. Can + * be NULL. + * @param who The username to convert. + * @return Normalized username, or NULL, if it's invalid. + */ + const char *(*normalize)(const PurpleAccount *account, const char *who); + + /** + * Set the buddy icon for the given connection to @a img. The prpl + * does NOT own a reference to @a img; if it needs one, it must + * #purple_imgstore_ref(@a img) itself. + */ + void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img); + + void (*remove_group)(PurpleConnection *gc, PurpleGroup *group); + + /** Gets the real name of a participant in a chat. For example, on + * XMPP this turns a chat room nick <tt>foo</tt> into + * <tt>room\@server/foo</tt> + * @param gc the connection on which the room is. + * @param id the ID of the chat room. + * @param who the nickname of the chat participant. + * @return the real name of the participant. This string must be + * freed by the caller. + */ + char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who); + + void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic); + + PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name); + + /* room listing prpl callbacks */ + PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc); + void (*roomlist_cancel)(PurpleRoomlist *list); + void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category); + + /* file transfer callbacks */ + gboolean (*can_receive_file)(PurpleConnection *, const char *who); + void (*send_file)(PurpleConnection *, const char *who, const char *filename); + PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who); + + /** Checks whether offline messages to @a buddy are supported. + * @return @c TRUE if @a buddy can be sent messages while they are + * offline, or @c FALSE if not. + */ + gboolean (*offline_message)(const PurpleBuddy *buddy); + + PurpleWhiteboardPrplOps *whiteboard_prpl_ops; + + /** For use in plugins that may understand the underlying protocol */ + int (*send_raw)(PurpleConnection *gc, const char *buf, int len); + + /* room list serialize */ + char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room); + + /** Remove the user from the server. The account can either be + * connected or disconnected. After the removal is finished, the + * connection will stay open and has to be closed! + */ + /* This is here rather than next to register_user for API compatibility + * reasons. + */ + void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data); + + /* Attention API for sending & receiving zaps/nudges/buzzes etc. */ + gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); + GList *(*get_attention_types)(PurpleAccount *acct); + + /** This allows protocols to specify additional strings to be used for + * various purposes. The idea is to stuff a bunch of strings in this hash + * table instead of expanding the struct for every addition. This hash + * table is allocated every call and MUST be unrefed by the caller. + * + * @param account The account to specify. This can be NULL. + * @return The protocol's string hash table. The hash table should be + * destroyed by the caller when it's no longer needed. + */ + GHashTable *(*get_account_text_table)(PurpleAccount *account); + + /** + * Initiate a media session with the given contact. + * + * @param account The account to initiate the media session on. + * @param who The remote user to initiate the session with. + * @param type The type of media session to initiate. + * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created) + */ + gboolean (*initiate_media)(PurpleAccount *account, const char *who, + PurpleMediaSessionType type); + + /** + * Checks to see if the given contact supports the given type of media session. + * + * @param account The account the contact is on. + * @param who The remote user to check for media capability with. + * @return The media caps the contact supports. + */ + PurpleMediaCaps (*get_media_caps)(PurpleAccount *account, + const char *who); + + /** + * Returns an array of "PurpleMood"s, with the last one having + * "mood" set to @c NULL. + */ + PurpleMood *(*get_moods)(PurpleAccount *account); + + /** + * Set the user's "friendly name" (or alias or nickname or + * whatever term you want to call it) on the server. The + * protocol plugin should call success_cb or failure_cb + * *asynchronously* (if it knows immediately that the set will fail, + * call one of the callbacks from an idle/0-second timeout) depending + * on if the nickname is set successfully. + * + * @param gc The connection for which to set an alias + * @param alias The new server-side alias/nickname for this account, + * or NULL to unset the alias/nickname (or return it to + * a protocol-specific "default"). + * @param success_cb Callback to be called if the public alias is set + * @param failure_cb Callback to be called if setting the public alias + * fails + * @see purple_account_set_public_alias + */ + void (*set_public_alias)(PurpleConnection *gc, const char *alias, + PurpleSetPublicAliasSuccessCallback success_cb, + PurpleSetPublicAliasFailureCallback failure_cb); + /** + * Retrieve the user's "friendly name" as set on the server. + * The protocol plugin should call success_cb or failure_cb + * *asynchronously* (even if it knows immediately that the get will fail, + * call one of the callbacks from an idle/0-second timeout) depending + * on if the nickname is retrieved. + * + * @param gc The connection for which to retireve the alias + * @param success_cb Callback to be called with the retrieved alias + * @param failure_cb Callback to be called if the prpl is unable to + * retrieve the alias + * @see purple_account_get_public_alias + */ + void (*get_public_alias)(PurpleConnection *gc, + PurpleGetPublicAliasSuccessCallback success_cb, + PurpleGetPublicAliasFailureCallback failure_cb); +}; + +#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \ + (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size && \ + prpl->member != NULL) + +G_BEGIN_DECLS + +/**************************************************************************/ +/** @name Attention Type API */ +/**************************************************************************/ +/*@{*/ + +/** + * Creates a new #PurpleAttentionType object and sets its mandatory parameters. + * + * @param ulname A non-localized string that can be used by UIs in need of such + * non-localized strings. This should be the same as @a name, + * without localization. + * @param name A localized string that the UI may display for the event. This + * should be the same string as @a ulname, with localization. + * @param inc_desc A localized description shown when the event is received. + * @param out_desc A localized description shown when the event is sent. + * + * @return A pointer to the new object. + */ +PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name, + const char *inc_desc, const char *out_desc); + +/** + * Sets the displayed name of the attention-demanding event. + * + * @param type The attention type. + * @param name The localized name that will be displayed by UIs. This should be + * the same string given as the unlocalized name, but with + * localization. + */ +void purple_attention_type_set_name(PurpleAttentionType *type, const char *name); + +/** + * Sets the description of the attention-demanding event shown in conversations + * when the event is received. + * + * @param type The attention type. + * @param desc The localized description for incoming events. + */ +void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc); + +/** + * Sets the description of the attention-demanding event shown in conversations + * when the event is sent. + * + * @param type The attention type. + * @param desc The localized description for outgoing events. + */ +void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc); + +/** + * Sets the name of the icon to display for the attention event; this is optional. + * + * @param type The attention type. + * @param name The icon's name. + * @note Icons are optional for attention events. + */ +void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name); + +/** + * Sets the unlocalized name of the attention event; some UIs may need this, + * thus it is required. + * + * @param type The attention type. + * @param ulname The unlocalized name. This should be the same string given as + * the localized name, but without localization. + */ +void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname); + +/** + * Get the attention type's name as displayed by the UI. + * + * @param type The attention type. + * + * @return The name. + */ +const char *purple_attention_type_get_name(const PurpleAttentionType *type); + +/** + * Get the attention type's description shown when the event is received. + * + * @param type The attention type. + * @return The description. + */ +const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type); + +/** + * Get the attention type's description shown when the event is sent. + * + * @param type The attention type. + * @return The description. + */ +const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type); + +/** + * Get the attention type's icon name. + * + * @param type The attention type. + * @return The icon name or @c NULL if unset/empty. + * @note Icons are optional for attention events. + */ +const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type); + +/** + * Get the attention type's unlocalized name; this is useful for some UIs. + * + * @param type The attention type + * @return The unlocalized name. + */ +const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type); + +/*@}*/ + +/**************************************************************************/ +/** @name Protocol Plugin API */ +/**************************************************************************/ +/*@{*/ + +/** + * Notifies Purple that our account's idle state and time have changed. + * + * This is meant to be called from protocol plugins. + * + * @param account The account. + * @param idle The user's idle state. + * @param idle_time The user's idle time. + */ +void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle, + time_t idle_time); + +/** + * Notifies Purple of our account's log-in time. + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param login_time The user's log-in time. + */ +void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time); + +/** + * Notifies Purple that our account's status has changed. + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param status_id The status ID. + * @param ... A NULL-terminated list of attribute IDs and values, + * beginning with the value for @a attr_id. + */ +void purple_prpl_got_account_status(PurpleAccount *account, + const char *status_id, ...) G_GNUC_NULL_TERMINATED; + +/** + * Notifies Purple that our account's actions have changed. This is only + * called after the initial connection. Emits the account-actions-changed + * signal. + * + * This is meant to be called from protocol plugins. + * + * @param account The account. + * + * @see account-actions-changed + */ +void purple_prpl_got_account_actions(PurpleAccount *account); + +/** + * Notifies Purple that a buddy's idle state and time have changed. + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param name The name of the buddy. + * @param idle The user's idle state. + * @param idle_time The user's idle time. This is the time at + * which the user became idle, in seconds since + * the epoch. If the PRPL does not know this value + * then it should pass 0. + */ +void purple_prpl_got_user_idle(PurpleAccount *account, const char *name, + gboolean idle, time_t idle_time); + +/** + * Notifies Purple of a buddy's log-in time. + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param name The name of the buddy. + * @param login_time The user's log-in time. + */ +void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name, + time_t login_time); + +/** + * Notifies Purple that a buddy's status has been activated. + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param name The name of the buddy. + * @param status_id The status ID. + * @param ... A NULL-terminated list of attribute IDs and values, + * beginning with the value for @a attr_id. + */ +void purple_prpl_got_user_status(PurpleAccount *account, const char *name, + const char *status_id, ...) G_GNUC_NULL_TERMINATED; + +/** + * Notifies libpurple that a buddy's status has been deactivated + * + * This is meant to be called from protocol plugins. + * + * @param account The account the user is on. + * @param name The name of the buddy. + * @param status_id The status ID. + */ +void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name, + const char *status_id); + +/** + * Informs the server that our account's status changed. + * + * @param account The account the user is on. + * @param old_status The previous status. + * @param new_status The status that was activated, or deactivated + * (in the case of independent statuses). + */ +void purple_prpl_change_account_status(PurpleAccount *account, + PurpleStatus *old_status, + PurpleStatus *new_status); + +/** + * Retrieves the list of stock status types from a prpl. + * + * @param account The account the user is on. + * @param presence The presence for which we're going to get statuses + * + * @return List of statuses + */ +GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence); + +/** + * Send an attention request message. + * + * @param gc The connection to send the message on. + * @param who Whose attention to request. + * @param type_code An index into the prpl's attention_types list determining the type + * of the attention request command to send. 0 if prpl only defines one + * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM). + * + * Note that you can't send arbitrary PurpleAttentionType's, because there is + * only a fixed set of attention commands. + */ +void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code); + +/** + * Process an incoming attention message. + * + * @param gc The connection that received the attention message. + * @param who Who requested your attention. + * @param type_code An index into the prpl's attention_types list determining the type + * of the attention request command to send. + */ +void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code); + +/** + * Process an incoming attention message in a chat. + * + * @param gc The connection that received the attention message. + * @param id The chat id. + * @param who Who requested your attention. + * @param type_code An index into the prpl's attention_types list determining the type + * of the attention request command to send. + */ +void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code); + +/** + * Determines if the contact supports the given media session type. + * + * @param account The account the user is on. + * @param who The name of the contact to check capabilities for. + * + * @return The media caps the contact supports. + */ +PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account, + const char *who); + +/** + * Initiates a media session with the given contact. + * + * @param account The account the user is on. + * @param who The name of the contact to start a session with. + * @param type The type of media session to start. + * + * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created) + */ +gboolean purple_prpl_initiate_media(PurpleAccount *account, + const char *who, + PurpleMediaSessionType type); + +/** + * Signals that the prpl received capabilities for the given contact. + * + * This function is intended to be used only by prpls. + * + * @param account The account the user is on. + * @param who The name of the contact for which capabilities have been received. + */ +void purple_prpl_got_media_caps(PurpleAccount *account, const char *who); + +/** TODO A sanity check is needed + * Allocates and returns a new PurpleProtocolAction. Use this to add actions in + * a list in the get_actions function of the protocol. + * + * @param label The description of the action to show to the user. + * @param callback The callback to call when the user selects this action. + */ +PurpleProtocolAction *purple_protocol_action_new(const char* label, + PurpleProtocolActionCallback callback); + +/** TODO A sanity check is needed + * Frees a PurpleProtocolAction + * + * @param action The PurpleProtocolAction to free. + */ +void purple_protocol_action_free(PurpleProtocolAction *action); + +/**************************************************************************/ +/** @name Protocols API */ +/**************************************************************************/ +/*@{*/ + +/** + * Finds a protocol plugin info structure by ID. + * + * @param id The protocol's ID. + */ +PurplePluginProtocolInfo *purple_find_protocol_info(const char *id); + +/** TODO A sanity check is needed + * Adds a protocol to the list of protocols. + * + * @param prpl_info The protocol to add. + * + * @return TRUE if the protocol was added, else FALSE. + */ +gboolean purple_protocols_add(PurplePluginProtocolInfo *prpl_info); + +/** TODO A sanity check is needed + * Removes a protocol from the list of protocols. This will disconnect all + * connected accounts using this protocol, and free the protocol's user splits + * and protocol options. + * + * @param prpl_info The protocol to remove. + * + * @return TRUE if the protocol was removed, else FALSE. + */ +gboolean purple_protocols_remove(PurplePluginProtocolInfo *prpl_info); + +/** TODO A sanity check is needed + * Returns a list of all loaded protocols. + * + * @constreturn A list of all loaded protocols. + */ +GList *purple_protocols_get_all(void); + +/*@}*/ + +/**************************************************************************/ +/** @name Protocols Subsytem API */ +/**************************************************************************/ +/*@{*/ + +/** + * Initializes the protocols subsystem. + */ +void purple_protocols_init(void); + +/** TODO Make protocols use this handle, instead of plugins handle + * Returns the protocols subsystem handle. + * + * @return The protocols subsystem handle. + */ +void *purple_protocols_get_handle(void); + +/** + * Uninitializes the protocols subsystem. + */ +void purple_protocols_uninit(void); + +/*@}*/ + +G_END_DECLS + +#endif /* _PRPL_H_ */
--- a/libpurple/protocols/irc/irc.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/irc/irc.c Sat Aug 17 23:27:20 2013 +0530 @@ -30,7 +30,7 @@ #include "conversation.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "plugins.h" #include "util.h" #include "version.h"
--- a/libpurple/protocols/jabber/buddy.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/jabber/buddy.c Sat Aug 17 23:27:20 2013 +0530 @@ -23,7 +23,7 @@ #include "internal.h" #include "debug.h" #include "imgstore.h" -#include "prpl.h" +#include "protocol.h" #include "notify.h" #include "request.h" #include "util.h"
--- a/libpurple/protocols/jabber/chat.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/jabber/chat.c Sat Aug 17 23:27:20 2013 +0530 @@ -22,7 +22,7 @@ */ #include "internal.h" #include "debug.h" -#include "prpl.h" /* for proto_chat_entry */ +#include "protocol.h" /* for proto_chat_entry */ #include "notify.h" #include "request.h" #include "roomlist.h"
--- a/libpurple/protocols/jabber/jabber.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/jabber/jabber.c Sat Aug 17 23:27:20 2013 +0530 @@ -37,7 +37,7 @@ #include "notify.h" #include "pluginpref.h" #include "proxy.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "server.h" #include "status.h"
--- a/libpurple/protocols/msn/msn.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/msn/msn.c Sat Aug 17 23:27:20 2013 +0530 @@ -41,7 +41,7 @@ #include "util.h" #include "cmds.h" #include "core.h" -#include "prpl.h" +#include "protocol.h" #include "msnutils.h" #include "version.h"
--- a/libpurple/protocols/mxit/roster.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/mxit/roster.c Sat Aug 17 23:27:20 2013 +0530 @@ -325,7 +325,7 @@ /* now re-instate his presence again */ if ( contact ) { - /* update the buddy's status (reference: "libpurple/prpl.h") */ + /* update the buddy's status (reference: "libpurple/protocol.h") */ if ( contact->statusMsg ) purple_prpl_got_user_status( session->acc, newbuddy->name, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL ); else @@ -422,7 +422,7 @@ else contact->avatarId = NULL; - /* update the buddy's status (reference: "libpurple/prpl.h") */ + /* update the buddy's status (reference: "libpurple/protocol.h") */ purple_prpl_got_user_status( session->acc, contact->username, mxit_statuses[contact->presence].id, NULL ); /* update the buddy's mood */ @@ -488,7 +488,7 @@ if ( ( statusMsg ) && ( statusMsg[0] != '\0' ) ) contact->statusMsg = g_markup_escape_text( statusMsg, -1 ); - /* update the buddy's status (reference: "libpurple/prpl.h") */ + /* update the buddy's status (reference: "libpurple/protocol.h") */ if ( contact->statusMsg ) purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL ); else
--- a/libpurple/protocols/novell/novell.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/novell/novell.c Sat Aug 17 23:27:20 2013 +0530 @@ -22,7 +22,7 @@ #include "accountopt.h" #include "debug.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "server.h" #include "nmuser.h" #include "notify.h"
--- a/libpurple/protocols/null/nullprpl.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/null/nullprpl.c Sat Aug 17 23:27:20 2013 +0530 @@ -61,7 +61,7 @@ #include "debug.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "roomlist.h" #include "status.h" #include "util.h" @@ -333,7 +333,7 @@ } static GList *nullprpl_chat_info(PurpleConnection *gc) { - struct proto_chat_entry *pce; /* defined in prpl.h */ + struct proto_chat_entry *pce; /* defined in protocol.h */ purple_debug_info("nullprpl", "returning chat setting 'room'\n"); @@ -1050,7 +1050,7 @@ /* - * prpl stuff. see prpl.h for more information. + * Protocol stuff. see protocol.h for more information. */ static PurplePluginProtocolInfo prpl_info =
--- a/libpurple/protocols/oscar/oscar.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/oscar/oscar.c Sat Aug 17 23:27:20 2013 +0530 @@ -41,7 +41,7 @@ #include "imgstore.h" #include "network.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "proxy.h" #include "request.h" #include "util.h"
--- a/libpurple/protocols/oscar/oscarcommon.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/oscar/oscarcommon.h Sat Aug 17 23:27:20 2013 +0530 @@ -27,7 +27,7 @@ #include "internal.h" #include "accountopt.h" -#include "prpl.h" +#include "protocol.h" #include "version.h" #include "notify.h" #include "status.h"
--- a/libpurple/protocols/sametime/sametime.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/sametime/sametime.c Sat Aug 17 23:27:20 2013 +0530 @@ -41,7 +41,7 @@ #include "mime.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "util.h" #include "version.h"
--- a/libpurple/protocols/silc/silcpurple.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/silc/silcpurple.h Sat Aug 17 23:27:20 2013 +0530 @@ -29,7 +29,7 @@ #include "debug.h" #include "ft.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "roomlist.h" #include "server.h"
--- a/libpurple/protocols/simple/simple.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/simple/simple.c Sat Aug 17 23:27:20 2013 +0530 @@ -32,7 +32,7 @@ #include "dnsquery.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "plugins.h" #include "util.h" #include "version.h"
--- a/libpurple/protocols/simple/simple.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/simple/simple.h Sat Aug 17 23:27:20 2013 +0530 @@ -32,7 +32,7 @@ #include "dnssrv.h" #include "network.h" #include "proxy.h" -#include "prpl.h" +#include "protocol.h" #include "sipmsg.h"
--- a/libpurple/protocols/simple/sipmsg.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/simple/sipmsg.c Sat Aug 17 23:27:20 2013 +0530 @@ -27,7 +27,7 @@ #include "conversation.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "plugins.h" #include "util.h" #include "version.h"
--- a/libpurple/protocols/yahoo/libymsg.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/libymsg.c Sat Aug 17 23:27:20 2013 +0530 @@ -33,7 +33,7 @@ #include "http.h" #include "network.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "proxy.h" #include "request.h" #include "server.h"
--- a/libpurple/protocols/yahoo/libymsg.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/libymsg.h Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "circularbuffer.h" #include "cmds.h" #include "http.h" -#include "prpl.h" +#include "protocol.h" #include "network.h" #define YAHOO_PAGER_HOST_REQ_URL "http://vcs1.msg.yahoo.com/capacity"
--- a/libpurple/protocols/yahoo/util.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/util.c Sat Aug 17 23:27:20 2013 +0530 @@ -26,7 +26,7 @@ #include "debug.h" #include "internal.h" -#include "prpl.h" +#include "protocol.h" #include "libymsg.h"
--- a/libpurple/protocols/yahoo/yahoo_doodle.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/yahoo_doodle.c Sat Aug 17 23:27:20 2013 +0530 @@ -33,7 +33,7 @@ #include "cmds.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "proxy.h" #include "request.h" #include "server.h"
--- a/libpurple/protocols/yahoo/yahoo_filexfer.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/yahoo_filexfer.c Sat Aug 17 23:27:20 2013 +0530 @@ -25,7 +25,7 @@ #include "internal.h" #include "dnsquery.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" #include "debug.h" #include "http.h"
--- a/libpurple/protocols/yahoo/yahoo_friend.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/yahoo_friend.c Sat Aug 17 23:27:20 2013 +0530 @@ -22,7 +22,7 @@ */ #include "internal.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" #include "debug.h"
--- a/libpurple/protocols/yahoo/yahoo_picture.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/yahoo_picture.c Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "buddylist.h" #include "debug.h" #include "http.h" -#include "prpl.h" +#include "protocol.h" #include "proxy.h" #include "util.h"
--- a/libpurple/protocols/yahoo/yahoochat.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/yahoochat.c Sat Aug 17 23:27:20 2013 +0530 @@ -34,7 +34,7 @@ #include "debug.h" #include "http.h" -#include "prpl.h" +#include "protocol.h" #include "conversation.h" #include "notify.h"
--- a/libpurple/protocols/yahoo/ycht.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/yahoo/ycht.c Sat Aug 17 23:27:20 2013 +0530 @@ -26,7 +26,7 @@ */ #include "internal.h" -#include "prpl.h" +#include "protocol.h" #include "notify.h" #include "account.h" #include "proxy.h"
--- a/libpurple/protocols/zephyr/zephyr.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/protocols/zephyr/zephyr.c Sat Aug 17 23:27:20 2013 +0530 @@ -32,7 +32,7 @@ #include "debug.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "server.h" #include "util.h" #include "cmds.h"
--- a/libpurple/prpl.c Sat Aug 17 23:20:39 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,756 +0,0 @@ -/* - * 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 - * - */ -#include "internal.h" -#include "accountopt.h" -#include "conversation.h" -#include "debug.h" -#include "network.h" -#include "notify.h" -#include "prpl.h" -#include "request.h" -#include "util.h" - -static GHashTable *protocols = NULL; - -/**************************************************************************/ -/** @name Attention Type API */ -/**************************************************************************/ - -struct _PurpleAttentionType -{ - const char *name; /**< Shown in GUI elements */ - const char *incoming_description; /**< Shown when sent */ - const char *outgoing_description; /**< Shown when receied */ - const char *icon_name; /**< Icon to display (optional) */ - const char *unlocalized_name; /**< Unlocalized name for UIs needing it */ -}; - - -PurpleAttentionType * -purple_attention_type_new(const char *ulname, const char *name, - const char *inc_desc, const char *out_desc) -{ - PurpleAttentionType *attn = g_new0(PurpleAttentionType, 1); - - purple_attention_type_set_name(attn, name); - purple_attention_type_set_incoming_desc(attn, inc_desc); - purple_attention_type_set_outgoing_desc(attn, out_desc); - purple_attention_type_set_unlocalized_name(attn, ulname); - - return attn; -} - - -void -purple_attention_type_set_name(PurpleAttentionType *type, const char *name) -{ - g_return_if_fail(type != NULL); - - type->name = name; -} - -void -purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc) -{ - g_return_if_fail(type != NULL); - - type->incoming_description = desc; -} - -void -purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc) -{ - g_return_if_fail(type != NULL); - - type->outgoing_description = desc; -} - -void -purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name) -{ - g_return_if_fail(type != NULL); - - type->icon_name = name; -} - -void -purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname) -{ - g_return_if_fail(type != NULL); - - type->unlocalized_name = ulname; -} - -const char * -purple_attention_type_get_name(const PurpleAttentionType *type) -{ - g_return_val_if_fail(type != NULL, NULL); - - return type->name; -} - -const char * -purple_attention_type_get_incoming_desc(const PurpleAttentionType *type) -{ - g_return_val_if_fail(type != NULL, NULL); - - return type->incoming_description; -} - -const char * -purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type) -{ - g_return_val_if_fail(type != NULL, NULL); - - return type->outgoing_description; -} - -const char * -purple_attention_type_get_icon_name(const PurpleAttentionType *type) -{ - g_return_val_if_fail(type != NULL, NULL); - - if(type->icon_name == NULL || *(type->icon_name) == '\0') - return NULL; - - return type->icon_name; -} - -const char * -purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type) -{ - g_return_val_if_fail(type != NULL, NULL); - - return type->unlocalized_name; -} - -/**************************************************************************/ -/** @name Protocol Plugin API */ -/**************************************************************************/ -void -purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle, - time_t idle_time) -{ - g_return_if_fail(account != NULL); - g_return_if_fail(purple_account_is_connected(account)); - - purple_presence_set_idle(purple_account_get_presence(account), - idle, idle_time); -} - -void -purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time) -{ - PurplePresence *presence; - - g_return_if_fail(account != NULL); - g_return_if_fail(purple_account_is_connected(account)); - - if (login_time == 0) - login_time = time(NULL); - - presence = purple_account_get_presence(account); - - purple_presence_set_login_time(presence, login_time); -} - -void -purple_prpl_got_account_status(PurpleAccount *account, const char *status_id, ...) -{ - PurplePresence *presence; - PurpleStatus *status; - va_list args; - - g_return_if_fail(account != NULL); - g_return_if_fail(status_id != NULL); - g_return_if_fail(purple_account_is_connected(account)); - - presence = purple_account_get_presence(account); - status = purple_presence_get_status(presence, status_id); - - g_return_if_fail(status != NULL); - - va_start(args, status_id); - purple_status_set_active_with_attrs(status, TRUE, args); - va_end(args); -} - -void -purple_prpl_got_account_actions(PurpleAccount *account) -{ - - g_return_if_fail(account != NULL); - g_return_if_fail(purple_account_is_connected(account)); - - purple_signal_emit(purple_accounts_get_handle(), "account-actions-changed", - account); -} - -void -purple_prpl_got_user_idle(PurpleAccount *account, const char *name, - gboolean idle, time_t idle_time) -{ - PurplePresence *presence; - GSList *list; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if ((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - while (list) { - presence = purple_buddy_get_presence(list->data); - list = g_slist_delete_link(list, list); - purple_presence_set_idle(presence, idle, idle_time); - } -} - -void -purple_prpl_got_user_login_time(PurpleAccount *account, const char *name, - time_t login_time) -{ - GSList *list; - PurplePresence *presence; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - - if ((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - if (login_time == 0) - login_time = time(NULL); - - while (list) { - PurpleBuddy *buddy = list->data; - presence = purple_buddy_get_presence(buddy); - list = g_slist_delete_link(list, list); - - if (purple_presence_get_login_time(presence) != login_time) - { - purple_presence_set_login_time(presence, login_time); - - purple_signal_emit(purple_blist_get_handle(), "buddy-got-login-time", buddy); - } - } -} - -void -purple_prpl_got_user_status(PurpleAccount *account, const char *name, - const char *status_id, ...) -{ - GSList *list, *l; - PurpleBuddy *buddy; - PurplePresence *presence; - PurpleStatus *status; - PurpleStatus *old_status; - va_list args; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(status_id != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - for(l = list; l != NULL; l = l->next) { - buddy = l->data; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_status(presence, status_id); - - if(NULL == status) - /* - * TODO: This should never happen, right? We should call - * g_warning() or something. - */ - continue; - - old_status = purple_presence_get_active_status(presence); - - va_start(args, status_id); - purple_status_set_active_with_attrs(status, TRUE, args); - va_end(args); - - purple_buddy_update_status(buddy, old_status); - } - - g_slist_free(list); - - /* The buddy is no longer online, they are therefore by definition not - * still typing to us. */ - if (!purple_status_is_online(status)) { - serv_got_typing_stopped(purple_account_get_connection(account), name); - purple_prpl_got_media_caps(account, name); - } -} - -void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name, - const char *status_id) -{ - GSList *list, *l; - PurpleBuddy *buddy; - PurplePresence *presence; - PurpleStatus *status; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - g_return_if_fail(status_id != NULL); - g_return_if_fail(purple_account_is_connected(account) || purple_account_is_connecting(account)); - - if((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - for(l = list; l != NULL; l = l->next) { - buddy = l->data; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_status(presence, status_id); - - if(NULL == status) - continue; - - if (purple_status_is_active(status)) { - purple_status_set_active(status, FALSE); - purple_buddy_update_status(buddy, status); - } - } - - g_slist_free(list); -} - -static void -do_prpl_change_account_status(PurpleAccount *account, - PurpleStatus *old_status, PurpleStatus *new_status) -{ - PurplePluginProtocolInfo *prpl_info; - - if (purple_status_is_online(new_status) && - purple_account_is_disconnected(account) && - purple_network_is_available()) - { - purple_account_connect(account); - return; - } - - if (!purple_status_is_online(new_status)) - { - if (!purple_account_is_disconnected(account)) - purple_account_disconnect(account); - /* Clear out the unsaved password if we switch to offline status */ - if (!purple_account_get_remember_password(account)) - purple_account_set_password(account, NULL, NULL, NULL); - - return; - } - - if (purple_account_is_connecting(account)) - /* - * We don't need to call the set_status PRPL function because - * the PRPL will take care of setting its status during the - * connection process. - */ - return; - - prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(account)); - - if (prpl_info == NULL) - return; - - if (!purple_account_is_disconnected(account) && prpl_info->set_status != NULL) - { - prpl_info->set_status(account, new_status); - } -} - -void -purple_prpl_change_account_status(PurpleAccount *account, - PurpleStatus *old_status, PurpleStatus *new_status) -{ - g_return_if_fail(account != NULL); - g_return_if_fail(new_status != NULL); - g_return_if_fail(!purple_status_is_exclusive(new_status) || old_status != NULL); - - do_prpl_change_account_status(account, old_status, new_status); - - purple_signal_emit(purple_accounts_get_handle(), "account-status-changed", - account, old_status, new_status); -} - -GList * -purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence) -{ - GList *statuses = NULL; - GList *l; - PurpleStatus *status; - - g_return_val_if_fail(account != NULL, NULL); - g_return_val_if_fail(presence != NULL, NULL); - - for (l = purple_account_get_status_types(account); l != NULL; l = l->next) - { - status = purple_status_new((PurpleStatusType *)l->data, presence); - statuses = g_list_prepend(statuses, status); - } - - statuses = g_list_reverse(statuses); - - return statuses; -} - -static void -purple_prpl_attention(PurpleConversation *conv, const char *who, - guint type, PurpleMessageFlags flags, time_t mtime) -{ - PurpleAccount *account = purple_conversation_get_account(conv); - purple_signal_emit(purple_conversations_get_handle(), - flags == PURPLE_MESSAGE_SEND ? "sent-attention" : "got-attention", - account, who, conv, type); -} - -void -purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code) -{ - PurpleAttentionType *attn; - PurpleMessageFlags flags; - PurplePluginProtocolInfo *prpl_info; - PurpleIMConversation *im; - gboolean (*send_attention)(PurpleConnection *, const char *, guint); - PurpleBuddy *buddy; - const char *alias; - gchar *description; - time_t mtime; - - g_return_if_fail(gc != NULL); - g_return_if_fail(who != NULL); - - prpl_info = purple_find_protocol_info(purple_account_get_protocol_id(purple_connection_get_account(gc))); - send_attention = prpl_info->send_attention; - g_return_if_fail(send_attention != NULL); - - mtime = time(NULL); - - attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code); - - if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL) - alias = purple_buddy_get_contact_alias(buddy); - else - alias = who; - - if (attn && purple_attention_type_get_outgoing_desc(attn)) { - description = g_strdup_printf(purple_attention_type_get_outgoing_desc(attn), alias); - } else { - description = g_strdup_printf(_("Requesting %s's attention..."), alias); - } - - flags = PURPLE_MESSAGE_SEND | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_SYSTEM; - - purple_debug_info("server", "serv_send_attention: sending '%s' to %s\n", - description, who); - - if (!send_attention(gc, who, type_code)) - return; - - im = purple_im_conversation_new(purple_connection_get_account(gc), who); - purple_conversation_write_message(PURPLE_CONVERSATION(im), NULL, description, flags, mtime); - purple_prpl_attention(PURPLE_CONVERSATION(im), who, type_code, PURPLE_MESSAGE_SEND, time(NULL)); - - g_free(description); -} - -static void -got_attention(PurpleConnection *gc, int id, const char *who, guint type_code) -{ - PurpleMessageFlags flags; - PurpleAttentionType *attn; - PurpleBuddy *buddy; - const char *alias; - gchar *description; - time_t mtime; - - mtime = time(NULL); - - attn = purple_get_attention_type_from_code(purple_connection_get_account(gc), type_code); - - /* PURPLE_MESSAGE_NOTIFY is for attention messages. */ - flags = PURPLE_MESSAGE_SYSTEM | PURPLE_MESSAGE_NOTIFY | PURPLE_MESSAGE_RECV; - - /* TODO: if (attn->icon_name) is non-null, use it to lookup an emoticon and display - * it next to the attention command. And if it is null, display a generic icon. */ - - if ((buddy = purple_blist_find_buddy(purple_connection_get_account(gc), who)) != NULL) - alias = purple_buddy_get_contact_alias(buddy); - else - alias = who; - - if (attn && purple_attention_type_get_incoming_desc(attn)) { - description = g_strdup_printf(purple_attention_type_get_incoming_desc(attn), alias); - } else { - description = g_strdup_printf(_("%s has requested your attention!"), alias); - } - - purple_debug_info("server", "got_attention: got '%s' from %s\n", - description, who); - - if (id == -1) - serv_got_im(gc, who, description, flags, mtime); - else - serv_got_chat_in(gc, id, who, flags, description, mtime); - - /* TODO: sounds (depending on PurpleAttentionType), shaking, etc. */ - - g_free(description); -} - -void -purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code) -{ - PurpleConversation *conv = NULL; - PurpleAccount *account = purple_connection_get_account(gc); - - got_attention(gc, -1, who, type_code); - conv = - purple_conversations_find_with_account(who, account); - if (conv) - purple_prpl_attention(conv, who, type_code, PURPLE_MESSAGE_RECV, - time(NULL)); -} - -void -purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code) -{ - got_attention(gc, id, who, type_code); -} - -gboolean -purple_prpl_initiate_media(PurpleAccount *account, - const char *who, - PurpleMediaSessionType type) -{ -#ifdef USE_VV - PurpleConnection *gc = NULL; - PurplePluginProtocolInfo *prpl_info = NULL; - - if (account) - gc = purple_account_get_connection(account); - if (gc) - prpl_info = purple_connection_get_protocol_info(gc); - - if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, initiate_media)) { - /* should check that the protocol supports this media type here? */ - return prpl_info->initiate_media(account, who, type); - } else -#endif - return FALSE; -} - -PurpleMediaCaps -purple_prpl_get_media_caps(PurpleAccount *account, const char *who) -{ -#ifdef USE_VV - PurpleConnection *gc = NULL; - PurplePluginProtocolInfo *prpl_info = NULL; - - if (account) - gc = purple_account_get_connection(account); - if (gc) - prpl_info = purple_connection_get_protocol_info(gc); - - if (prpl_info && PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl_info, - get_media_caps)) { - return prpl_info->get_media_caps(account, who); - } -#endif - return PURPLE_MEDIA_CAPS_NONE; -} - -void -purple_prpl_got_media_caps(PurpleAccount *account, const char *name) -{ -#ifdef USE_VV - GSList *list; - - g_return_if_fail(account != NULL); - g_return_if_fail(name != NULL); - - if ((list = purple_blist_find_buddies(account, name)) == NULL) - return; - - while (list) { - PurpleBuddy *buddy = list->data; - PurpleMediaCaps oldcaps = purple_buddy_get_media_caps(buddy); - PurpleMediaCaps newcaps = 0; - const gchar *bname = purple_buddy_get_name(buddy); - list = g_slist_delete_link(list, list); - - - newcaps = purple_prpl_get_media_caps(account, bname); - purple_buddy_set_media_caps(buddy, newcaps); - - if (oldcaps == newcaps) - continue; - - purple_signal_emit(purple_blist_get_handle(), - "buddy-caps-changed", buddy, - newcaps, oldcaps); - } -#endif -} - -PurpleProtocolAction * -purple_protocol_action_new(const char* label, - PurpleProtocolActionCallback callback) -{ - PurpleProtocolAction *action; - - g_return_val_if_fail(label != NULL && callback != NULL, NULL); - - action = g_new0(PurpleProtocolAction, 1); - - action->label = g_strdup(label); - action->callback = callback; - - return action; -} - -void -purple_protocol_action_free(PurpleProtocolAction *action) -{ - g_return_if_fail(action != NULL); - - g_free(action->label); - g_free(action); -} - -/************************************************************************** - * Protocols API - **************************************************************************/ -static void -purple_protocol_destroy(PurplePluginProtocolInfo *prpl_info) -{ - GList *accounts, *l; - - accounts = purple_accounts_get_all_active(); - for (l = accounts; l != NULL; l = l->next) { - PurpleAccount *account = PURPLE_ACCOUNT(l->data); - if (purple_account_is_disconnected(account)) - continue; - - if (purple_strequal(prpl_info->id, purple_account_get_protocol_id(account))) - purple_account_disconnect(account); - } - - g_list_free(accounts); - - while (prpl_info->user_splits) { - PurpleAccountUserSplit *split = prpl_info->user_splits->data; - purple_account_user_split_destroy(split); - prpl_info->user_splits = g_list_delete_link(prpl_info->user_splits, - prpl_info->user_splits); - } - - while (prpl_info->protocol_options) { - PurpleAccountOption *option = prpl_info->protocol_options->data; - purple_account_option_destroy(option); - prpl_info->protocol_options = - g_list_delete_link(prpl_info->protocol_options, - prpl_info->protocol_options); - } - - purple_request_close_with_handle(prpl_info); - purple_notify_close_with_handle(prpl_info); - - purple_signals_disconnect_by_handle(prpl_info); - purple_signals_unregister_by_instance(prpl_info); - - purple_prefs_disconnect_by_handle(prpl_info); -} - -PurplePluginProtocolInfo * -purple_find_protocol_info(const char *id) -{ - return g_hash_table_lookup(protocols, id); -} - -gboolean -purple_protocols_add(PurplePluginProtocolInfo *prpl_info) -{ - if (purple_find_protocol_info(prpl_info->id)) - return FALSE; - - g_hash_table_insert(protocols, g_strdup(prpl_info->id), prpl_info); - return TRUE; -} - -gboolean purple_protocols_remove(PurplePluginProtocolInfo *prpl_info) -{ - if (purple_find_protocol_info(prpl_info->id) == NULL) - return FALSE; - - g_hash_table_remove(protocols, prpl_info->id); - purple_protocol_destroy(prpl_info); - - return TRUE; -} - -GList * -purple_protocols_get_all(void) -{ - GList *ret = NULL; - PurplePluginProtocolInfo *prpl_info; - GHashTableIter iter; - - g_hash_table_iter_init(&iter, protocols); - while (g_hash_table_iter_next(&iter, NULL, (gpointer *)&prpl_info)) - ret = g_list_append(ret, prpl_info); - - return ret; -} - -/************************************************************************** - * Protocols Subsystem API - **************************************************************************/ -void -purple_protocols_init(void) -{ - protocols = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, - (GDestroyNotify)purple_protocol_destroy); -} - -void * -purple_protocols_get_handle(void) -{ - static int handle; - - return &handle; -} - -void -purple_protocols_uninit(void) -{ - g_hash_table_destroy(protocols); -} -
--- a/libpurple/prpl.h Sat Aug 17 23:20:39 2013 +0530 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1055 +0,0 @@ -/** - * @file prpl.h Protocol Plugin functions - * @ingroup core - */ - -/* 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 - */ - -/* this file should be all that prpls need to include. therefore, by including - * this file, they should get glib, proxy, purple_connection, prpl, etc. */ - -#ifndef _PURPLE_PRPL_H_ -#define _PURPLE_PRPL_H_ - -typedef struct _PurplePluginProtocolInfo PurplePluginProtocolInfo; - -typedef struct _PurpleProtocolAction PurpleProtocolAction; - -typedef void (*PurpleProtocolActionCallback)(PurpleProtocolAction *); - -/** Represents "nudges" and "buzzes" that you may send to a buddy to attract - * their attention (or vice-versa). - */ -typedef struct _PurpleAttentionType PurpleAttentionType; - -/**************************************************************************/ -/** @name Basic Protocol Information */ -/**************************************************************************/ - -typedef enum { - PURPLE_ICON_SCALE_DISPLAY = 0x01, /**< We scale the icon when we display it */ - PURPLE_ICON_SCALE_SEND = 0x02 /**< We scale the icon before we send it to the server */ -} PurpleIconScaleRules; - - -/** - * A description of a Buddy Icon specification. This tells Purple what kind of image file - * it should give this prpl, and what kind of image file it should expect back. - * Dimensions less than 1 should be ignored and the image not scaled. - */ -typedef struct _PurpleBuddyIconSpec PurpleBuddyIconSpec; - -/** - * A description of a file transfer thumbnail specification. - * This tells the UI if and what image formats the prpl support for file - * transfer thumbnails. - */ -typedef struct _PurpleThumbnailSpec PurpleThumbnailSpec; - -/** - * This \#define exists just to make it easier to fill out the buddy icon - * field in the prpl info struct for protocols that couldn't care less. - */ -#define NO_BUDDY_ICONS {NULL, 0, 0, 0, 0, 0, 0} - -#ifdef HAVE_UNISTD_H -#include <unistd.h> -#endif - -#include "buddylist.h" -#include "conversations.h" -#include "ft.h" -#include "imgstore.h" -#include "media.h" -#include "notify.h" -#include "proxy.h" -#include "roomlist.h" -#include "status.h" -#include "whiteboard.h" - - -/** @copydoc PurpleBuddyIconSpec */ -struct _PurpleBuddyIconSpec { - /** This is a comma-delimited list of image formats or @c NULL if icons - * are not supported. Neither the core nor the prpl will actually - * check to see if the data it's given matches this; it's entirely up - * to the UI to do what it wants - */ - char *format; - - int min_width; /**< Minimum width of this icon */ - int min_height; /**< Minimum height of this icon */ - int max_width; /**< Maximum width of this icon */ - int max_height; /**< Maximum height of this icon */ - size_t max_filesize; /**< Maximum size in bytes */ - PurpleIconScaleRules scale_rules; /**< How to stretch this icon */ -}; - -/** Represents an entry containing information that must be supplied by the - * user when joining a chat. - */ -struct proto_chat_entry { - const char *label; /**< User-friendly name of the entry */ - const char *identifier; /**< Used by the PRPL to identify the option */ - gboolean required; /**< True if it's required */ - gboolean is_int; /**< True if the entry expects an integer */ - int min; /**< Minimum value in case of integer */ - int max; /**< Maximum value in case of integer */ - gboolean secret; /**< True if the entry is secret (password) */ -}; - -/** - * Protocol options - * - * These should all be stuff that some plugins can do and others can't. - */ -typedef enum -{ - /** - * User names are unique to a chat and are not shared between rooms. - * - * XMPP lets you choose what name you want in chats, so it shouldn't - * be pulling the aliases from the buddy list for the chat list; - * it gets annoying. - */ - OPT_PROTO_UNIQUE_CHATNAME = 0x00000004, - - /** - * Chat rooms have topics. - * - * IRC and XMPP support this. - */ - OPT_PROTO_CHAT_TOPIC = 0x00000008, - - /** - * Don't require passwords for sign-in. - * - * Zephyr doesn't require passwords, so there's no - * need for a password prompt. - */ - OPT_PROTO_NO_PASSWORD = 0x00000010, - - /** - * Notify on new mail. - * - * MSN and Yahoo notify you when you have new mail. - */ - OPT_PROTO_MAIL_CHECK = 0x00000020, - - /** - * Images in IMs. - * - * Oscar lets you send images in direct IMs. - */ - OPT_PROTO_IM_IMAGE = 0x00000040, - - /** - * Allow passwords to be optional. - * - * Passwords in IRC are optional, and are needed for certain - * functionality. - */ - OPT_PROTO_PASSWORD_OPTIONAL = 0x00000080, - - /** - * Allows font size to be specified in sane point size - * - * Probably just XMPP and Y!M - */ - OPT_PROTO_USE_POINTSIZE = 0x00000100, - - /** - * Set the Register button active even when the username has not - * been specified. - * - * Gadu-Gadu doesn't need a username to register new account (because - * usernames are assigned by the server). - */ - OPT_PROTO_REGISTER_NOSCREENNAME = 0x00000200, - - /** - * Indicates that slash commands are native to this protocol. - * Used as a hint that unknown commands should not be sent as messages. - */ - OPT_PROTO_SLASH_COMMANDS_NATIVE = 0x00000400, - - /** - * Indicates that this protocol supports sending a user-supplied message - * along with an invitation. - */ - OPT_PROTO_INVITE_MESSAGE = 0x00000800, - - /** - * Indicates that this protocol supports sending a user-supplied message - * along with an authorization acceptance. - */ - OPT_PROTO_AUTHORIZATION_GRANTED_MESSAGE = 0x00001000, - - /** - * Indicates that this protocol supports sending a user-supplied message - * along with an authorization denial. - */ - OPT_PROTO_AUTHORIZATION_DENIED_MESSAGE = 0x00002000 - -} PurpleProtocolOptions; - -/** - * Represents an action that the protocol can perform. This shows up in the - * Accounts menu, under a submenu with the name of the account. - */ -struct _PurpleProtocolAction { - char *label; - PurpleProtocolActionCallback callback; - PurpleConnection *connection; - gpointer user_data; -}; - -/** - * A protocol plugin information structure. - * - * Every protocol plugin initializes this structure. It is the gateway - * between purple and the protocol plugin. Many of these callbacks can be - * NULL. If a callback must be implemented, it has a comment indicating so. - */ -struct _PurplePluginProtocolInfo -{ - const char *id; - const char *name; - - /** - * The size of the PurplePluginProtocolInfo. This should always be sizeof(PurplePluginProtocolInfo). - * This allows adding more functions to this struct without requiring a major version bump. - */ - unsigned long struct_size; - - /* NOTE: - * If more functions are added, they should accessed using the following syntax: - * - * if (PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, new_function)) - * prpl->new_function(...); - * - * instead of - * - * if (prpl->new_function != NULL) - * prpl->new_function(...); - * - * The PURPLE_PROTOCOL_PLUGIN_HAS_FUNC macro can be used for the older member - * functions (e.g. login, send_im etc.) too. - */ - - PurpleProtocolOptions options; /**< Protocol options. */ - - GList *user_splits; /**< A GList of PurpleAccountUserSplit */ - GList *protocol_options; /**< A GList of PurpleAccountOption */ - - PurpleBuddyIconSpec icon_spec; /**< The icon spec. */ - - /** - * Callback that returns the actions the protocol can perform - */ - GList *(*get_actions)(PurpleConnection *); - - /** - * Returns the base icon name for the given buddy and account. - * If buddy is NULL and the account is non-NULL, it will return the - * name to use for the account's icon. If both are NULL, it will - * return the name to use for the protocol's icon. - * - * This must be implemented. - */ - const char *(*list_icon)(PurpleAccount *account, PurpleBuddy *buddy); - - /** - * Fills the four char**'s with string identifiers for "emblems" - * that the UI will interpret and display as relevant - */ - const char *(*list_emblem)(PurpleBuddy *buddy); - - /** - * Gets a short string representing this buddy's status. This will - * be shown on the buddy list. - */ - char *(*status_text)(PurpleBuddy *buddy); - - /** - * Allows the prpl to add text to a buddy's tooltip. - */ - void (*tooltip_text)(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full); - - /** - * Returns a list of #PurpleStatusType which exist for this account; - * this must be implemented, and must add at least the offline and - * online states. - */ - GList *(*status_types)(PurpleAccount *account); - - /** - * Returns a list of #PurpleMenuAction structs, which represent extra - * actions to be shown in (for example) the right-click menu for @a - * node. - */ - GList *(*blist_node_menu)(PurpleBlistNode *node); - - /** - * Returns a list of #proto_chat_entry structs, which represent - * information required by the PRPL to join a chat. libpurple will - * call join_chat along with the information filled by the user. - * - * @return A list of #proto_chat_entry structs - */ - GList *(*chat_info)(PurpleConnection *); - - /** - * Returns a hashtable which maps #proto_chat_entry struct identifiers - * to default options as strings based on chat_name. The resulting - * hashtable should be created with g_hash_table_new_full(g_str_hash, - * g_str_equal, NULL, g_free);. Use #get_chat_name if you instead need - * to extract a chat name from a hashtable. - * - * @param chat_name The chat name to be turned into components - * @return Hashtable containing the information extracted from chat_name - */ - GHashTable *(*chat_info_defaults)(PurpleConnection *, const char *chat_name); - - /* All the server-related functions */ - - /** This must be implemented. */ - void (*login)(PurpleAccount *); - - /** This must be implemented. */ - void (*close)(PurpleConnection *); - - /** - * This PRPL function should return a positive value on success. - * If the message is too big to be sent, return -E2BIG. If - * the account is not connected, return -ENOTCONN. If the - * PRPL is unable to send the message for another reason, return - * some other negative value. You can use one of the valid - * errno values, or just big something. If the message should - * not be echoed to the conversation window, return 0. - */ - int (*send_im)(PurpleConnection *, const char *who, - const char *message, - PurpleMessageFlags flags); - - void (*set_info)(PurpleConnection *, const char *info); - - /** - * @return If this protocol requires the PURPLE_IM_TYPING message to - * be sent repeatedly to signify that the user is still - * typing, then the PRPL should return the number of - * seconds to wait before sending a subsequent notification. - * Otherwise the PRPL should return 0. - */ - unsigned int (*send_typing)(PurpleConnection *, const char *name, PurpleIMTypingState state); - - /** - * Should arrange for purple_notify_userinfo() to be called with - * @a who's user info. - */ - void (*get_info)(PurpleConnection *, const char *who); - void (*set_status)(PurpleAccount *account, PurpleStatus *status); - - void (*set_idle)(PurpleConnection *, int idletime); - void (*change_passwd)(PurpleConnection *, const char *old_pass, - const char *new_pass); - - /** - * Add a buddy to a group on the server. - * - * This PRPL function may be called in situations in which the buddy is - * already in the specified group. If the protocol supports - * authorization and the user is not already authorized to see the - * status of \a buddy, \a add_buddy should request authorization. - * - * If authorization is required, then use the supplied invite message. - */ - void (*add_buddy)(PurpleConnection *pc, PurpleBuddy *buddy, PurpleGroup *group, const char *message); - void (*add_buddies)(PurpleConnection *pc, GList *buddies, GList *groups, const char *message); - void (*remove_buddy)(PurpleConnection *, PurpleBuddy *buddy, PurpleGroup *group); - void (*remove_buddies)(PurpleConnection *, GList *buddies, GList *groups); - void (*add_permit)(PurpleConnection *, const char *name); - void (*add_deny)(PurpleConnection *, const char *name); - void (*rem_permit)(PurpleConnection *, const char *name); - void (*rem_deny)(PurpleConnection *, const char *name); - void (*set_permit_deny)(PurpleConnection *); - - /** - * Called when the user requests joining a chat. Should arrange for - * #serv_got_joined_chat to be called. - * - * @param components A hashtable containing information required to - * join the chat as described by the entries returned - * by #chat_info. It may also be called when accepting - * an invitation, in which case this matches the - * data parameter passed to #serv_got_chat_invite. - */ - void (*join_chat)(PurpleConnection *, GHashTable *components); - - /** - * Called when the user refuses a chat invitation. - * - * @param components A hashtable containing information required to - * join the chat as passed to #serv_got_chat_invite. - */ - void (*reject_chat)(PurpleConnection *, GHashTable *components); - - /** - * Returns a chat name based on the information in components. Use - * #chat_info_defaults if you instead need to generate a hashtable - * from a chat name. - * - * @param components A hashtable containing information about the chat. - */ - char *(*get_chat_name)(GHashTable *components); - - /** - * Invite a user to join a chat. - * - * @param id The id of the chat to invite the user to. - * @param message A message displayed to the user when the invitation - * is received. - * @param who The name of the user to send the invation to. - */ - void (*chat_invite)(PurpleConnection *, int id, - const char *message, const char *who); - /** - * Called when the user requests leaving a chat. - * - * @param id The id of the chat to leave - */ - void (*chat_leave)(PurpleConnection *, int id); - - /** - * Send a whisper to a user in a chat. - * - * @param id The id of the chat. - * @param who The name of the user to send the whisper to. - * @param message The message of the whisper. - */ - void (*chat_whisper)(PurpleConnection *, int id, - const char *who, const char *message); - - /** - * Send a message to a chat. - * This PRPL function should return a positive value on success. - * If the message is too big to be sent, return -E2BIG. If - * the account is not connected, return -ENOTCONN. If the - * PRPL is unable to send the message for another reason, return - * some other negative value. You can use one of the valid - * errno values, or just big something. - * - * @param id The id of the chat to send the message to. - * @param message The message to send to the chat. - * @param flags A bitwise OR of #PurpleMessageFlags representing - * message flags. - * @return A positive number or 0 in case of success, - * a negative error number in case of failure. - */ - int (*chat_send)(PurpleConnection *, int id, const char *message, PurpleMessageFlags flags); - - /** If implemented, this will be called regularly for this prpl's - * active connections. You'd want to do this if you need to repeatedly - * send some kind of keepalive packet to the server to avoid being - * disconnected. ("Regularly" is defined by - * <code>KEEPALIVE_INTERVAL</code> in <tt>libpurple/connection.c</tt>.) - */ - void (*keepalive)(PurpleConnection *); - - /** new user registration */ - void (*register_user)(PurpleAccount *); - - /** - * @deprecated Use #PurplePluginProtocolInfo.get_info instead. - */ - void (*get_cb_info)(PurpleConnection *, int, const char *who); - - /** save/store buddy's alias on server list/roster */ - void (*alias_buddy)(PurpleConnection *, const char *who, - const char *alias); - - /** change a buddy's group on a server list/roster */ - void (*group_buddy)(PurpleConnection *, const char *who, - const char *old_group, const char *new_group); - - /** rename a group on a server list/roster */ - void (*rename_group)(PurpleConnection *, const char *old_name, - PurpleGroup *group, GList *moved_buddies); - - void (*buddy_free)(PurpleBuddy *); - - void (*convo_closed)(PurpleConnection *, const char *who); - - /** - * Convert the username @a who to its canonical form. Also checks for - * validity. - * - * For example, AIM treats "fOo BaR" and "foobar" as the same user; this - * function should return the same normalized string for both of those. - * On the other hand, both of these are invalid for protocols with - * number-based usernames, so function should return NULL in such case. - * - * @param account The account the username is related to. Can - * be NULL. - * @param who The username to convert. - * @return Normalized username, or NULL, if it's invalid. - */ - const char *(*normalize)(const PurpleAccount *account, const char *who); - - /** - * Set the buddy icon for the given connection to @a img. The prpl - * does NOT own a reference to @a img; if it needs one, it must - * #purple_imgstore_ref(@a img) itself. - */ - void (*set_buddy_icon)(PurpleConnection *, PurpleStoredImage *img); - - void (*remove_group)(PurpleConnection *gc, PurpleGroup *group); - - /** Gets the real name of a participant in a chat. For example, on - * XMPP this turns a chat room nick <tt>foo</tt> into - * <tt>room\@server/foo</tt> - * @param gc the connection on which the room is. - * @param id the ID of the chat room. - * @param who the nickname of the chat participant. - * @return the real name of the participant. This string must be - * freed by the caller. - */ - char *(*get_cb_real_name)(PurpleConnection *gc, int id, const char *who); - - void (*set_chat_topic)(PurpleConnection *gc, int id, const char *topic); - - PurpleChat *(*find_blist_chat)(PurpleAccount *account, const char *name); - - /* room listing prpl callbacks */ - PurpleRoomlist *(*roomlist_get_list)(PurpleConnection *gc); - void (*roomlist_cancel)(PurpleRoomlist *list); - void (*roomlist_expand_category)(PurpleRoomlist *list, PurpleRoomlistRoom *category); - - /* file transfer callbacks */ - gboolean (*can_receive_file)(PurpleConnection *, const char *who); - void (*send_file)(PurpleConnection *, const char *who, const char *filename); - PurpleXfer *(*new_xfer)(PurpleConnection *, const char *who); - - /** Checks whether offline messages to @a buddy are supported. - * @return @c TRUE if @a buddy can be sent messages while they are - * offline, or @c FALSE if not. - */ - gboolean (*offline_message)(const PurpleBuddy *buddy); - - PurpleWhiteboardPrplOps *whiteboard_prpl_ops; - - /** For use in plugins that may understand the underlying protocol */ - int (*send_raw)(PurpleConnection *gc, const char *buf, int len); - - /* room list serialize */ - char *(*roomlist_room_serialize)(PurpleRoomlistRoom *room); - - /** Remove the user from the server. The account can either be - * connected or disconnected. After the removal is finished, the - * connection will stay open and has to be closed! - */ - /* This is here rather than next to register_user for API compatibility - * reasons. - */ - void (*unregister_user)(PurpleAccount *, PurpleAccountUnregistrationCb cb, void *user_data); - - /* Attention API for sending & receiving zaps/nudges/buzzes etc. */ - gboolean (*send_attention)(PurpleConnection *gc, const char *username, guint type); - GList *(*get_attention_types)(PurpleAccount *acct); - - /** This allows protocols to specify additional strings to be used for - * various purposes. The idea is to stuff a bunch of strings in this hash - * table instead of expanding the struct for every addition. This hash - * table is allocated every call and MUST be unrefed by the caller. - * - * @param account The account to specify. This can be NULL. - * @return The protocol's string hash table. The hash table should be - * destroyed by the caller when it's no longer needed. - */ - GHashTable *(*get_account_text_table)(PurpleAccount *account); - - /** - * Initiate a media session with the given contact. - * - * @param account The account to initiate the media session on. - * @param who The remote user to initiate the session with. - * @param type The type of media session to initiate. - * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created) - */ - gboolean (*initiate_media)(PurpleAccount *account, const char *who, - PurpleMediaSessionType type); - - /** - * Checks to see if the given contact supports the given type of media session. - * - * @param account The account the contact is on. - * @param who The remote user to check for media capability with. - * @return The media caps the contact supports. - */ - PurpleMediaCaps (*get_media_caps)(PurpleAccount *account, - const char *who); - - /** - * Returns an array of "PurpleMood"s, with the last one having - * "mood" set to @c NULL. - */ - PurpleMood *(*get_moods)(PurpleAccount *account); - - /** - * Set the user's "friendly name" (or alias or nickname or - * whatever term you want to call it) on the server. The - * protocol plugin should call success_cb or failure_cb - * *asynchronously* (if it knows immediately that the set will fail, - * call one of the callbacks from an idle/0-second timeout) depending - * on if the nickname is set successfully. - * - * @param gc The connection for which to set an alias - * @param alias The new server-side alias/nickname for this account, - * or NULL to unset the alias/nickname (or return it to - * a protocol-specific "default"). - * @param success_cb Callback to be called if the public alias is set - * @param failure_cb Callback to be called if setting the public alias - * fails - * @see purple_account_set_public_alias - */ - void (*set_public_alias)(PurpleConnection *gc, const char *alias, - PurpleSetPublicAliasSuccessCallback success_cb, - PurpleSetPublicAliasFailureCallback failure_cb); - /** - * Retrieve the user's "friendly name" as set on the server. - * The protocol plugin should call success_cb or failure_cb - * *asynchronously* (even if it knows immediately that the get will fail, - * call one of the callbacks from an idle/0-second timeout) depending - * on if the nickname is retrieved. - * - * @param gc The connection for which to retireve the alias - * @param success_cb Callback to be called with the retrieved alias - * @param failure_cb Callback to be called if the prpl is unable to - * retrieve the alias - * @see purple_account_get_public_alias - */ - void (*get_public_alias)(PurpleConnection *gc, - PurpleGetPublicAliasSuccessCallback success_cb, - PurpleGetPublicAliasFailureCallback failure_cb); -}; - -#define PURPLE_PROTOCOL_PLUGIN_HAS_FUNC(prpl, member) \ - (G_STRUCT_OFFSET(PurplePluginProtocolInfo, member) < prpl->struct_size && \ - prpl->member != NULL) - -G_BEGIN_DECLS - -/**************************************************************************/ -/** @name Attention Type API */ -/**************************************************************************/ -/*@{*/ - -/** - * Creates a new #PurpleAttentionType object and sets its mandatory parameters. - * - * @param ulname A non-localized string that can be used by UIs in need of such - * non-localized strings. This should be the same as @a name, - * without localization. - * @param name A localized string that the UI may display for the event. This - * should be the same string as @a ulname, with localization. - * @param inc_desc A localized description shown when the event is received. - * @param out_desc A localized description shown when the event is sent. - * - * @return A pointer to the new object. - */ -PurpleAttentionType *purple_attention_type_new(const char *ulname, const char *name, - const char *inc_desc, const char *out_desc); - -/** - * Sets the displayed name of the attention-demanding event. - * - * @param type The attention type. - * @param name The localized name that will be displayed by UIs. This should be - * the same string given as the unlocalized name, but with - * localization. - */ -void purple_attention_type_set_name(PurpleAttentionType *type, const char *name); - -/** - * Sets the description of the attention-demanding event shown in conversations - * when the event is received. - * - * @param type The attention type. - * @param desc The localized description for incoming events. - */ -void purple_attention_type_set_incoming_desc(PurpleAttentionType *type, const char *desc); - -/** - * Sets the description of the attention-demanding event shown in conversations - * when the event is sent. - * - * @param type The attention type. - * @param desc The localized description for outgoing events. - */ -void purple_attention_type_set_outgoing_desc(PurpleAttentionType *type, const char *desc); - -/** - * Sets the name of the icon to display for the attention event; this is optional. - * - * @param type The attention type. - * @param name The icon's name. - * @note Icons are optional for attention events. - */ -void purple_attention_type_set_icon_name(PurpleAttentionType *type, const char *name); - -/** - * Sets the unlocalized name of the attention event; some UIs may need this, - * thus it is required. - * - * @param type The attention type. - * @param ulname The unlocalized name. This should be the same string given as - * the localized name, but without localization. - */ -void purple_attention_type_set_unlocalized_name(PurpleAttentionType *type, const char *ulname); - -/** - * Get the attention type's name as displayed by the UI. - * - * @param type The attention type. - * - * @return The name. - */ -const char *purple_attention_type_get_name(const PurpleAttentionType *type); - -/** - * Get the attention type's description shown when the event is received. - * - * @param type The attention type. - * @return The description. - */ -const char *purple_attention_type_get_incoming_desc(const PurpleAttentionType *type); - -/** - * Get the attention type's description shown when the event is sent. - * - * @param type The attention type. - * @return The description. - */ -const char *purple_attention_type_get_outgoing_desc(const PurpleAttentionType *type); - -/** - * Get the attention type's icon name. - * - * @param type The attention type. - * @return The icon name or @c NULL if unset/empty. - * @note Icons are optional for attention events. - */ -const char *purple_attention_type_get_icon_name(const PurpleAttentionType *type); - -/** - * Get the attention type's unlocalized name; this is useful for some UIs. - * - * @param type The attention type - * @return The unlocalized name. - */ -const char *purple_attention_type_get_unlocalized_name(const PurpleAttentionType *type); - -/*@}*/ - -/**************************************************************************/ -/** @name Protocol Plugin API */ -/**************************************************************************/ -/*@{*/ - -/** - * Notifies Purple that our account's idle state and time have changed. - * - * This is meant to be called from protocol plugins. - * - * @param account The account. - * @param idle The user's idle state. - * @param idle_time The user's idle time. - */ -void purple_prpl_got_account_idle(PurpleAccount *account, gboolean idle, - time_t idle_time); - -/** - * Notifies Purple of our account's log-in time. - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param login_time The user's log-in time. - */ -void purple_prpl_got_account_login_time(PurpleAccount *account, time_t login_time); - -/** - * Notifies Purple that our account's status has changed. - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param status_id The status ID. - * @param ... A NULL-terminated list of attribute IDs and values, - * beginning with the value for @a attr_id. - */ -void purple_prpl_got_account_status(PurpleAccount *account, - const char *status_id, ...) G_GNUC_NULL_TERMINATED; - -/** - * Notifies Purple that our account's actions have changed. This is only - * called after the initial connection. Emits the account-actions-changed - * signal. - * - * This is meant to be called from protocol plugins. - * - * @param account The account. - * - * @see account-actions-changed - */ -void purple_prpl_got_account_actions(PurpleAccount *account); - -/** - * Notifies Purple that a buddy's idle state and time have changed. - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param name The name of the buddy. - * @param idle The user's idle state. - * @param idle_time The user's idle time. This is the time at - * which the user became idle, in seconds since - * the epoch. If the PRPL does not know this value - * then it should pass 0. - */ -void purple_prpl_got_user_idle(PurpleAccount *account, const char *name, - gboolean idle, time_t idle_time); - -/** - * Notifies Purple of a buddy's log-in time. - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param name The name of the buddy. - * @param login_time The user's log-in time. - */ -void purple_prpl_got_user_login_time(PurpleAccount *account, const char *name, - time_t login_time); - -/** - * Notifies Purple that a buddy's status has been activated. - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param name The name of the buddy. - * @param status_id The status ID. - * @param ... A NULL-terminated list of attribute IDs and values, - * beginning with the value for @a attr_id. - */ -void purple_prpl_got_user_status(PurpleAccount *account, const char *name, - const char *status_id, ...) G_GNUC_NULL_TERMINATED; - -/** - * Notifies libpurple that a buddy's status has been deactivated - * - * This is meant to be called from protocol plugins. - * - * @param account The account the user is on. - * @param name The name of the buddy. - * @param status_id The status ID. - */ -void purple_prpl_got_user_status_deactive(PurpleAccount *account, const char *name, - const char *status_id); - -/** - * Informs the server that our account's status changed. - * - * @param account The account the user is on. - * @param old_status The previous status. - * @param new_status The status that was activated, or deactivated - * (in the case of independent statuses). - */ -void purple_prpl_change_account_status(PurpleAccount *account, - PurpleStatus *old_status, - PurpleStatus *new_status); - -/** - * Retrieves the list of stock status types from a prpl. - * - * @param account The account the user is on. - * @param presence The presence for which we're going to get statuses - * - * @return List of statuses - */ -GList *purple_prpl_get_statuses(PurpleAccount *account, PurplePresence *presence); - -/** - * Send an attention request message. - * - * @param gc The connection to send the message on. - * @param who Whose attention to request. - * @param type_code An index into the prpl's attention_types list determining the type - * of the attention request command to send. 0 if prpl only defines one - * (for example, Yahoo and MSN), but some protocols define more (MySpaceIM). - * - * Note that you can't send arbitrary PurpleAttentionType's, because there is - * only a fixed set of attention commands. - */ -void purple_prpl_send_attention(PurpleConnection *gc, const char *who, guint type_code); - -/** - * Process an incoming attention message. - * - * @param gc The connection that received the attention message. - * @param who Who requested your attention. - * @param type_code An index into the prpl's attention_types list determining the type - * of the attention request command to send. - */ -void purple_prpl_got_attention(PurpleConnection *gc, const char *who, guint type_code); - -/** - * Process an incoming attention message in a chat. - * - * @param gc The connection that received the attention message. - * @param id The chat id. - * @param who Who requested your attention. - * @param type_code An index into the prpl's attention_types list determining the type - * of the attention request command to send. - */ -void purple_prpl_got_attention_in_chat(PurpleConnection *gc, int id, const char *who, guint type_code); - -/** - * Determines if the contact supports the given media session type. - * - * @param account The account the user is on. - * @param who The name of the contact to check capabilities for. - * - * @return The media caps the contact supports. - */ -PurpleMediaCaps purple_prpl_get_media_caps(PurpleAccount *account, - const char *who); - -/** - * Initiates a media session with the given contact. - * - * @param account The account the user is on. - * @param who The name of the contact to start a session with. - * @param type The type of media session to start. - * - * @return TRUE if the call succeeded else FALSE. (Doesn't imply the media session or stream will be successfully created) - */ -gboolean purple_prpl_initiate_media(PurpleAccount *account, - const char *who, - PurpleMediaSessionType type); - -/** - * Signals that the prpl received capabilities for the given contact. - * - * This function is intended to be used only by prpls. - * - * @param account The account the user is on. - * @param who The name of the contact for which capabilities have been received. - */ -void purple_prpl_got_media_caps(PurpleAccount *account, const char *who); - -/** TODO A sanity check is needed - * Allocates and returns a new PurpleProtocolAction. Use this to add actions in - * a list in the get_actions function of the protocol. - * - * @param label The description of the action to show to the user. - * @param callback The callback to call when the user selects this action. - */ -PurpleProtocolAction *purple_protocol_action_new(const char* label, - PurpleProtocolActionCallback callback); - -/** TODO A sanity check is needed - * Frees a PurpleProtocolAction - * - * @param action The PurpleProtocolAction to free. - */ -void purple_protocol_action_free(PurpleProtocolAction *action); - -/**************************************************************************/ -/** @name Protocols API */ -/**************************************************************************/ -/*@{*/ - -/** - * Finds a protocol plugin info structure by ID. - * - * @param id The protocol's ID. - */ -PurplePluginProtocolInfo *purple_find_protocol_info(const char *id); - -/** TODO A sanity check is needed - * Adds a protocol to the list of protocols. - * - * @param prpl_info The protocol to add. - * - * @return TRUE if the protocol was added, else FALSE. - */ -gboolean purple_protocols_add(PurplePluginProtocolInfo *prpl_info); - -/** TODO A sanity check is needed - * Removes a protocol from the list of protocols. This will disconnect all - * connected accounts using this protocol, and free the protocol's user splits - * and protocol options. - * - * @param prpl_info The protocol to remove. - * - * @return TRUE if the protocol was removed, else FALSE. - */ -gboolean purple_protocols_remove(PurplePluginProtocolInfo *prpl_info); - -/** TODO A sanity check is needed - * Returns a list of all loaded protocols. - * - * @constreturn A list of all loaded protocols. - */ -GList *purple_protocols_get_all(void); - -/*@}*/ - -/**************************************************************************/ -/** @name Protocols Subsytem API */ -/**************************************************************************/ -/*@{*/ - -/** - * Initializes the protocols subsystem. - */ -void purple_protocols_init(void); - -/** TODO Make protocols use this handle, instead of plugins handle - * Returns the protocols subsystem handle. - * - * @return The protocols subsystem handle. - */ -void *purple_protocols_get_handle(void); - -/** - * Uninitializes the protocols subsystem. - */ -void purple_protocols_uninit(void); - -/*@}*/ - -G_END_DECLS - -#endif /* _PRPL_H_ */
--- a/libpurple/server.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/server.c Sat Aug 17 23:27:20 2013 +0530 @@ -30,7 +30,7 @@ #include "log.h" #include "notify.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "signals.h" #include "server.h"
--- a/libpurple/server.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/server.h Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "accounts.h" #include "conversations.h" -#include "prpl.h" +#include "protocol.h" G_BEGIN_DECLS
--- a/libpurple/util.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/util.c Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "core.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "prefs.h" #include "util.h"
--- a/libpurple/util.h Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/util.h Sat Aug 17 23:27:20 2013 +0530 @@ -50,7 +50,7 @@ #include "signals.h" #include "xmlnode.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" typedef char *(*PurpleInfoFieldFormatCallback)(const char *field, size_t len);
--- a/libpurple/whiteboard.c Sat Aug 17 23:20:39 2013 +0530 +++ b/libpurple/whiteboard.c Sat Aug 17 23:27:20 2013 +0530 @@ -23,7 +23,7 @@ #include "internal.h" #include "whiteboard.h" -#include "prpl.h" +#include "protocol.h" /** * A PurpleWhiteboard
--- a/pidgin/gtkaccount.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkaccount.c Sat Aug 17 23:27:20 2013 +0530 @@ -34,7 +34,7 @@ #include "notify.h" #include "plugins.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "savedstatuses.h" #include "signals.h"
--- a/pidgin/gtkblist.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkblist.c Sat Aug 17 23:27:20 2013 +0530 @@ -32,7 +32,7 @@ #include "core.h" #include "debug.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "prefs.h" #include "plugins.h" #include "request.h"
--- a/pidgin/gtkconv.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkconv.c Sat Aug 17 23:27:20 2013 +0530 @@ -44,7 +44,7 @@ #include "log.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "theme-loader.h" #include "theme-manager.h" @@ -8868,7 +8868,7 @@ #include "imgstore.h" #include "log.h" #include "notify.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "util.h"
--- a/pidgin/gtkdialogs.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkdialogs.c Sat Aug 17 23:27:20 2013 +0530 @@ -32,7 +32,7 @@ #include "debug.h" #include "notify.h" #include "plugins.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "util.h" #include "core.h"
--- a/pidgin/gtkft.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkft.c Sat Aug 17 23:27:20 2013 +0530 @@ -29,7 +29,7 @@ #include "debug.h" #include "notify.h" #include "ft.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" #include "gtkft.h"
--- a/pidgin/gtkmain.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkmain.c Sat Aug 17 23:27:20 2013 +0530 @@ -35,7 +35,7 @@ #include "network.h" #include "notify.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "pounce.h" #include "sound.h" #include "status.h"
--- a/pidgin/gtkpounce.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkpounce.c Sat Aug 17 23:27:20 2013 +0530 @@ -30,7 +30,7 @@ #include "account.h" #include "conversation.h" #include "debug.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "server.h" #include "sound.h"
--- a/pidgin/gtkprefs.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkprefs.c Sat Aug 17 23:27:20 2013 +0530 @@ -34,7 +34,7 @@ #include "notify.h" #include "prefs.h" #include "proxy.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "savedstatuses.h" #include "sound.h"
--- a/pidgin/gtkthemes.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkthemes.c Sat Aug 17 23:27:20 2013 +0530 @@ -25,7 +25,7 @@ #include "conversation.h" #include "debug.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" #include "gtkconv.h"
--- a/pidgin/gtkutils.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkutils.c Sat Aug 17 23:27:20 2013 +0530 @@ -49,7 +49,7 @@ #include "imgstore.h" #include "notify.h" #include "prefs.h" -#include "prpl.h" +#include "protocol.h" #include "request.h" #include "signals.h" #include "sound.h"
--- a/pidgin/gtkutils.h Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/gtkutils.h Sat Aug 17 23:27:20 2013 +0530 @@ -28,7 +28,7 @@ #include "gtkconv.h" #include "pidgin.h" -#include "prpl.h" +#include "protocol.h" #include "util.h" typedef enum
--- a/pidgin/plugins/raw.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/plugins/raw.c Sat Aug 17 23:27:20 2013 +0530 @@ -26,7 +26,7 @@ #include "conversation.h" #include "debug.h" -#include "prpl.h" +#include "protocol.h" #include "version.h" #include "gtkplugin.h"
--- a/pidgin/plugins/ticker/ticker.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/plugins/ticker/ticker.c Sat Aug 17 23:27:20 2013 +0530 @@ -30,7 +30,7 @@ #include "buddylist.h" #include "conversation.h" #include "debug.h" -#include "prpl.h" +#include "protocol.h" #include "signals.h" #include "version.h"
--- a/pidgin/plugins/xmppconsole.c Sat Aug 17 23:20:39 2013 +0530 +++ b/pidgin/plugins/xmppconsole.c Sat Aug 17 23:27:20 2013 +0530 @@ -22,7 +22,7 @@ #include "internal.h" #include "gtkplugin.h" #include "version.h" -#include "prpl.h" +#include "protocol.h" #include "xmlnode.h" #include "gtkimhtml.h"