Mercurial > pidgin
changeset 19465:d9d9283680a4
In MSN prpl, use attention API. Can be disabled by undefining
MSN_USE_ATTENTION_API. Also update Yahoo prpl to use a common
idiom in the attention_types function that MSN also uses.
author | Jeffrey Connelly <jaconnel@calpoly.edu> |
---|---|
date | Mon, 27 Aug 2007 06:58:54 +0000 |
parents | ca45543c11a3 |
children | 11c727b19201 |
files | libpurple/protocols/msn/msn.c libpurple/protocols/msn/msn.h libpurple/protocols/msn/switchboard.c libpurple/protocols/yahoo/yahoo.c |
diffstat | 4 files changed, 66 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msn.c Mon Aug 27 06:08:14 2007 +0000 +++ b/libpurple/protocols/msn/msn.c Mon Aug 27 06:58:54 2007 +0000 @@ -100,25 +100,62 @@ return buf; } -static PurpleCmdRet -msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) +static gboolean +msn_send_attention(PurpleConnection *gc, const char *username, guint type) { - PurpleAccount *account = purple_conversation_get_account(conv); - PurpleConnection *gc = purple_account_get_connection(account); MsnMessage *msg; MsnSession *session; MsnSwitchBoard *swboard; msg = msn_message_new_nudge(); session = gc->proto_data; - swboard = msn_session_get_swboard(session, purple_conversation_get_name(conv), MSN_SB_FLAG_IM); + swboard = msn_session_get_swboard(session, username, MSN_SB_FLAG_IM); if (swboard == NULL) - return PURPLE_CMD_RET_FAILED; + return FALSE; msn_switchboard_send_msg(swboard, msg, TRUE); + return TRUE; +} + +#ifdef MSN_USE_ATTENTION_API +static GList * +msn_attention_types(PurpleAccount *account) +{ + PurpleAttentionType *attn; + static GList *list = NULL; + + if (!list) { + attn = g_new0(PurpleAttentionType, 1); + attn->name = _("nudge"); + attn->incoming_description = _("nudged"); + attn->outgoing_description = _("Nudging"); + list = g_list_append(list, attn); + } + + return list; +} +#endif + + +static PurpleCmdRet +msn_cmd_nudge(PurpleConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) +{ + PurpleAccount *account = purple_conversation_get_account(conv); + PurpleConnection *gc = purple_account_get_connection(account); + const gchar *username; + + username = purple_conversation_get_name(conv); + +#ifdef MSN_USE_ATTENTION_API + serv_send_attention(gc, username, MSN_NUDGE); +#else + if (!msn_send_attention(gc, username, MSN_NUDGE)) + return PURPLE_CMD_RET_FAILED; + purple_conversation_write(conv, NULL, _("You have just sent a Nudge!"), PURPLE_MESSAGE_SYSTEM, time(NULL)); +#endif return PURPLE_CMD_RET_OK; } @@ -2102,9 +2139,14 @@ NULL, /* send_raw */ NULL, /* roomlist_room_serialize */ +#ifdef MSN_USE_ATTENTION_API + msn_send_attention, /* send_attention */ + msn_attention_types, /* attention_types */ +#else /* padding */ NULL, NULL, +#endif NULL, NULL };
--- a/libpurple/protocols/msn/msn.h Mon Aug 27 06:08:14 2007 +0000 +++ b/libpurple/protocols/msn/msn.h Mon Aug 27 06:58:54 2007 +0000 @@ -79,6 +79,10 @@ "Client-Name: Purple/" VERSION "\r\n" \ "Chat-Logging: Y\r\n" +/* Index into attention_types */ +#define MSN_NUDGE 0 + +#define MSN_USE_ATTENTION_API typedef enum {
--- a/libpurple/protocols/msn/switchboard.c Mon Aug 27 06:08:14 2007 +0000 +++ b/libpurple/protocols/msn/switchboard.c Mon Aug 27 06:58:54 2007 +0000 @@ -951,6 +951,8 @@ PurpleBuddy *buddy; const char *user; + str = NULL; + swboard = cmdproc->data; account = cmdproc->session->account; user = msg->remote_user; @@ -960,9 +962,13 @@ else username = g_markup_escape_text(user, -1); +#ifdef MSN_USE_ATTENTION_API + serv_got_attention(account->gc, buddy->name, MSN_NUDGE); +#else str = g_strdup_printf(_("%s just sent you a Nudge!"), username); + msn_switchboard_report_user(swboard, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, str); +#endif g_free(username); - msn_switchboard_report_user(swboard, PURPLE_MESSAGE_SYSTEM|PURPLE_MESSAGE_NOTIFY, str); g_free(str); }
--- a/libpurple/protocols/yahoo/yahoo.c Mon Aug 27 06:08:14 2007 +0000 +++ b/libpurple/protocols/yahoo/yahoo.c Mon Aug 27 06:58:54 2007 +0000 @@ -4106,17 +4106,16 @@ GList *yahoo_attention_types(PurpleAccount *account) { PurpleAttentionType *attn; - static GList *list; - static gboolean init = FALSE; - - if (!init) { + static GList *list = NULL; + + if (!list) { /* Yahoo only supports one attention command: the 'buzz'. */ /* This is index number YAHOO_BUZZ. */ attn = g_new0(PurpleAttentionType, 1); - attn->name = "buzz"; - attn->incoming_description = "buzzed"; - attn->outgoing_description = "Buzzing"; - list = g_list_append(NULL, attn); + attn->name = _("buzz"); + attn->incoming_description = _("buzzed"); + attn->outgoing_description = _("Buzzing"); + list = g_list_append(list, attn); } return list;