Mercurial > pidgin.yaz
diff libpurple/protocols/msn/msn.c @ 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 | 926ccb104da0 |
children | ebe2d2e71223 44b4e8bd759b 1754155051a4 315151da0dc6 7f8cf35fc99b |
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 };