# HG changeset patch # User Stu Tomlinson # Date 1124644462 0 # Node ID 95fa774d216d4c8f37b7da156daafaf46b6926f0 # Parent d3b567926e8fbf20efdbd2d5f458a85183a3986f [gaim-migrate @ 13525] Kill off the conversation closed notices Fix for setting the ACK id on slpmsg ACKs which might improve things for other clients (see bug #1222320) Clean up some debugging stuff Add support for sending and receiving Nudges (Based on patch #1169352) Add an account action to go direct to a Hotmail Inbox committer: Tailor Script diff -r d3b567926e8f -r 95fa774d216d COPYRIGHT --- a/COPYRIGHT Sun Aug 21 17:01:43 2005 +0000 +++ b/COPYRIGHT Sun Aug 21 17:14:22 2005 +0000 @@ -12,6 +12,7 @@ Levi Bard Kevin Barry Derek Battams +Martin Bayard Curtis Beattie Dave Bell Igor Belyi @@ -32,6 +33,7 @@ Jeremy Brooks Philip Brown Sean Burke +Julien Cegarra Cerulean Studios, LLC Jonathan Champ Ka-Hing Cheung diff -r d3b567926e8f -r 95fa774d216d ChangeLog --- a/ChangeLog Sun Aug 21 17:01:43 2005 +0000 +++ b/ChangeLog Sun Aug 21 17:14:22 2005 +0000 @@ -48,6 +48,9 @@ authorization. * Conversation buffer scrollback limited to avoid large memory usage in active conversations. + * Added support for sending (with the /nudge command) and reciving MSN + "nudges" (Julien Cegarra, Martin Bayard) + * Added an account action to open your Hotmail inbox from MSN Bug fixes: * People using input methods can now use Enter again. diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/msg.c --- a/src/protocols/msn/msg.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/msg.c Sun Aug 21 17:14:22 2005 +0000 @@ -154,6 +154,20 @@ return msg; } +MsnMessage * +msn_message_new_nudge(void) +{ + MsnMessage *msg; + + msg = msn_message_new(MSN_MSG_NUDGE); + msn_message_set_content_type(msg, "text/x-msnmsgr-datacast\r\n"); + msn_message_set_flag(msg, 'N'); + msn_message_set_attr(msg,"ID","1\r\n"); + //msn_message_set_bin_data(msg, "\r\n\r\n", 4); + + return msg; +} + void msn_message_parse_slp_body(MsnMessage *msg, const char *body, size_t len) { diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/msg.h --- a/src/protocols/msn/msg.h Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/msg.h Sun Aug 21 17:14:22 2005 +0000 @@ -50,7 +50,8 @@ MSN_MSG_TEXT, MSN_MSG_TYPING, MSN_MSG_CAPS, - MSN_MSG_SLP + MSN_MSG_SLP, + MSN_MSG_NUDGE } MsnMsgType; @@ -138,6 +139,18 @@ */ MsnMessage *msn_message_new_msnslp(void); +/** + * Creates a new nudge message. + * + * @return A new nudge message. + */ +MsnMessage *msn_message_new_nudge(void); + +/** + * Creates a new plain message. + * + * @return A new plain message. + */ MsnMessage *msn_message_new_plain(const char *message); /** diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/msn.c --- a/src/protocols/msn/msn.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/msn.c Sun Aug 21 17:14:22 2005 +0000 @@ -34,6 +34,7 @@ #include "session.h" #include "state.h" #include "utils.h" +#include "cmds.h" #include "prpl.h" #include "util.h" #include "version.h" @@ -91,6 +92,30 @@ return buf; } +static GaimCmdRet +msn_cmd_nudge(GaimConversation *conv, const gchar *cmd, gchar **args, gchar **error, void *data) +{ + GaimAccount *account = gaim_conversation_get_account(conv); + GaimConnection *gc = gaim_account_get_connection(account); + const char *username = gaim_account_get_username(account); + MsnMessage *msg; + MsnSession *session; + MsnSwitchBoard *swboard; + + msg = msn_message_new_nudge(); + session = gc->proto_data; + swboard = msn_session_get_swboard(session, gaim_conversation_get_name(conv), MSN_SB_FLAG_IM); + + if (session == NULL || swboard == NULL) + return GAIM_CMD_RET_FAILED; + + msn_switchboard_send_msg(swboard, msg, TRUE); + + gaim_conversation_write(conv, NULL, _("You have just sent a Nudge!"), GAIM_MESSAGE_SYSTEM, time(NULL)); + + return GAIM_CMD_RET_OK; +} + static void msn_act_id(GaimConnection *gc, const char *entry) { @@ -290,6 +315,25 @@ } static void +msn_show_hotmail_inbox(GaimPluginAction *action) +{ + GaimConnection *gc; + MsnSession *session; + + gc = (GaimConnection *) action->context; + session = gc->proto_data; + + if (session->passport_info.file == NULL) + { + gaim_notify_error(gc, NULL, + _("This Hotmail account may not be active."), NULL); + return; + } + + gaim_notify_uri(gc, session->passport_info.file); +} + +static void show_send_to_mobile_cb(GaimBlistNode *node, gpointer ignored) { GaimBuddy *buddy; @@ -564,6 +608,10 @@ static GList * msn_actions(GaimPlugin *plugin, gpointer context) { + GaimConnection *gc = (GaimConnection *)context; + GaimAccount *account; + const char *user; + GList *m = NULL; GaimPluginAction *act; @@ -595,6 +643,17 @@ msn_show_set_mobile_pages); m = g_list_append(m, act); + account = gaim_connection_get_account(gc); + user = msn_normalize(account, gaim_account_get_username(account)); + + if (strstr(user, "@hotmail.com") != NULL) + { + m = g_list_append(m, NULL); + act = gaim_plugin_action_new(_("Open Hotmail Inbox"), + msn_show_hotmail_inbox); + m = g_list_append(m, act); + } + return m; } @@ -1931,6 +1990,11 @@ prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option); + gaim_cmd_register("nudge", "", GAIM_CMD_P_PRPL, + GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_PRPL_ONLY, + "prpl-msn", msn_cmd_nudge, + _("nudge: nudge a contact to get their attention"), NULL); + gaim_prefs_remove("/plugins/prpl/msn"); } diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/msn.h --- a/src/protocols/msn/msn.h Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/msn.h Sun Aug 21 17:14:22 2005 +0000 @@ -32,6 +32,9 @@ /* #define MSN_DEBUG_SLP_VERBOSE 1 */ /* #define MSN_DEBUG_SLP_FILES 1 */ +/* #define MSN_DEBUG_NS 1 */ +/* #define MSN_DEBUG_SB 1 */ + #include "internal.h" #include "account.h" @@ -88,29 +91,32 @@ typedef enum { - MSN_CLIENT_CAP_WIN_MOBILE = 0x001, - MSN_CLIENT_CAP_UNKNOWN_1 = 0x002, - MSN_CLIENT_CAP_VIEW_INK = 0x004, - MSN_CLIENT_CAP_SEND_INK = 0x008, - MSN_CLIENT_CAP_VIDEO_CHAT = 0x010, - MSN_CLIENT_CAP_BASE = 0x020, - MSN_CLIENT_CAP_MSNMOBILE = 0x040, - MSN_CLIENT_CAP_MSNDIRECT = 0x080, - MSN_CLIENT_CAP_WEBMSGR = 0x100 + MSN_CLIENT_CAP_WIN_MOBILE = 0x0001, + MSN_CLIENT_CAP_UNKNOWN_1 = 0x0002, + MSN_CLIENT_CAP_VIEW_INK = 0x0004, + MSN_CLIENT_CAP_SEND_INK = 0x0008, + MSN_CLIENT_CAP_VIDEO_CHAT = 0x0010, + MSN_CLIENT_CAP_BASE = 0x0020, + MSN_CLIENT_CAP_MSNMOBILE = 0x0040, + MSN_CLIENT_CAP_MSNDIRECT = 0x0080, + MSN_CLIENT_CAP_WEBMSGR = 0x0100, + MSN_CLIENT_CAP_DIRECTIM = 0x4000, + MSN_CLIENT_CAP_WINKRCV = 0x8000 } MsnClientCaps; typedef enum { MSN_CLIENT_VER_5_0 = 0x00, - MSN_CLIENT_VER_6_0 = 0x10, - MSN_CLIENT_VER_6_1 = 0x20, - MSN_CLIENT_VER_6_2 = 0x30, - MSN_CLIENT_VER_7_0 = 0x40 + MSN_CLIENT_VER_6_0 = 0x10, /* MSNC1 */ + MSN_CLIENT_VER_6_1 = 0x20, /* MSNC2 */ + MSN_CLIENT_VER_6_2 = 0x30, /* MSNC3 */ + MSN_CLIENT_VER_7_0 = 0x40, /* MSNC4 */ + MSN_CLIENT_VER_7_5 = 0x50 /* MSNC5 */ } MsnClientVerId; -#define MSN_CLIENT_ID_VERSION MSN_CLIENT_VER_6_0 +#define MSN_CLIENT_ID_VERSION MSN_CLIENT_VER_7_0 #define MSN_CLIENT_ID_RESERVED_1 0x00 #define MSN_CLIENT_ID_RESERVED_2 0x00 #define MSN_CLIENT_ID_CAPABILITIES MSN_CLIENT_CAP_BASE diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/notification.c --- a/src/protocols/msn/notification.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/notification.c Sun Aug 21 17:14:22 2005 +0000 @@ -367,7 +367,9 @@ msg = msn_message_new_from_cmd(cmdproc->session, cmd); msn_message_parse_payload(msg, payload, len); - /* msn_message_show_readable(msg, "Notification", TRUE); */ +#ifdef MSN_DEBUG_NS + msn_message_show_readable(msg, "Notification", TRUE); +#endif msn_cmdproc_process_msg(cmdproc, msg); @@ -1177,9 +1179,6 @@ /* This isn't an official message. */ return; - if (!gaim_account_get_check_mail(session->account)) - return; - if (session->passport_info.file == NULL) { MsnTransaction *trans; @@ -1191,6 +1190,9 @@ return; } + if (!gaim_account_get_check_mail(session->account)) + return; + table = msn_message_get_hashtable_from_body(msg); unread = g_hash_table_lookup(table, "Inbox-Unread"); @@ -1230,9 +1232,6 @@ /* This isn't an official message. */ return; - if (!gaim_account_get_check_mail(session->account)) - return; - if (session->passport_info.file == NULL) { MsnTransaction *trans; @@ -1244,6 +1243,9 @@ return; } + if (!gaim_account_get_check_mail(session->account)) + return; + table = msn_message_get_hashtable_from_body(msg); from = subject = NULL; diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/slplink.c --- a/src/protocols/msn/slplink.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/slplink.c Sun Aug 21 17:14:22 2005 +0000 @@ -384,6 +384,7 @@ msg->msnslp_header.session_id = slpmsg->session_id; msg->msnslp_header.ack_id = slpmsg->ack_id; msg->msnslp_header.ack_size = slpmsg->ack_size; + msg->msnslp_header.ack_sub_id = slpmsg->ack_sub_id; } else if (slpmsg->flags == 0x20 || slpmsg->flags == 0x1000030) { @@ -671,7 +672,7 @@ gsize size = 0; MsnContextHeader header; gchar *u8 = NULL; - guchar *base, *n; + guchar *base, *n, *ret; gunichar2 *uni = NULL; glong currentChar = 0; glong uni_len = 0; @@ -717,7 +718,9 @@ n += 4; g_free(uni); - return gaim_base64_encode(base, len); + ret = gaim_base64_encode(base, len); + g_free(base); + return ret; } void diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/slpmsg.c --- a/src/protocols/msn/slpmsg.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/slpmsg.c Sun Aug 21 17:14:22 2005 +0000 @@ -121,7 +121,7 @@ } #ifdef MSN_DEBUG_SLP -const void +void msn_slpmsg_show(MsnMessage *msg) { const char *info; diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/slpmsg.h --- a/src/protocols/msn/slpmsg.h Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/slpmsg.h Sun Aug 21 17:14:22 2005 +0000 @@ -99,7 +99,7 @@ const char *content); #ifdef MSN_DEBUG_SLP -const void msn_slpmsg_show(MsnMessage *msg); +void msn_slpmsg_show(MsnMessage *msg); #endif #endif /* _MSN_SLPMSG_H_ */ diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/switchboard.c --- a/src/protocols/msn/switchboard.c Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/switchboard.c Sun Aug 21 17:14:22 2005 +0000 @@ -29,8 +29,6 @@ #include "error.h" -/* #define MSN_DEBUG_SWBOARD */ - static MsnTable *cbs_table; static void msg_error_helper(MsnCmdProc *cmdproc, MsnMessage *msg, @@ -72,7 +70,7 @@ MsnMessage *msg; GList *l; -#ifdef MSN_DEBUG_SWBOARD +#ifdef MSN_DEBUG_SB gaim_debug_info("msn", "switchboard_destroy: swboard(%p)\n", swboard); #endif @@ -527,7 +525,9 @@ payload = msn_message_gen_payload(msg, &payload_len); - /* msn_message_show_readable(msg, "SB SEND", FALSE); */ +#ifdef MSN_DEBUG_SB + msn_message_show_readable(msg, "SB SEND", FALSE); +#endif trans = msn_transaction_new(cmdproc, "MSG", "%c %d", msn_message_get_flag(msg), payload_len); @@ -641,19 +641,8 @@ swboard = cmdproc->data; user = cmd->params[0]; -#if 0 - if (!(swboard->flag & MSN_SB_FLAG_IM)) - { - /* TODO: This is a helper switchboard. It would be better if - * swboard->conv is NULL, but it isn't. */ - /* Umm? I think swboard->conv is NULL for all helper switchboards now? */ - msn_switchboard_destroy(swboard); - return; - } -#else - if (!(swboard->flag & MSN_SB_FLAG_IM)) + if (!(swboard->flag & MSN_SB_FLAG_IM) && (swboard->conv != NULL)) gaim_debug_error("msn_switchboard", "bye_cmd: helper bug\n"); -#endif if (swboard->conv == NULL) { @@ -672,28 +661,6 @@ else { /* This is a switchboard used for a im session */ - - if (cmd->param_count == 1) - { - char *username, *str; - GaimAccount *account; - GaimBuddy *b; - - account = cmdproc->session->account; - - if ((b = gaim_find_buddy(account, user)) != NULL) - username = g_markup_escape_text(gaim_buddy_get_alias(b), -1); - else - username = g_markup_escape_text(user, -1); - - str = g_strdup_printf(_("%s has closed the conversation window."), - username); - - g_free(username); - msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); - g_free(str); - } - msn_switchboard_destroy(swboard); } } @@ -749,7 +716,9 @@ msg = msn_message_new_from_cmd(cmdproc->session, cmd); msn_message_parse_payload(msg, payload, len); - /* msn_message_show_readable(msg, "SB RECV", FALSE); */ +#ifdef MSN_DEBUG_SB + msn_message_show_readable(msg, "SB RECV", FALSE); +#endif if (msg->remote_user != NULL) g_free (msg->remote_user); @@ -962,6 +931,30 @@ #endif } +void +nudge_msg(MsnCmdProc *cmdproc, MsnMessage *msg) +{ + MsnSwitchBoard *swboard; + char *username, *str; + GaimAccount *account; + GaimBuddy *buddy; + const char *user; + + swboard = cmdproc->data; + account = cmdproc->session->account; + user = msg->remote_user; + + if ((buddy = gaim_find_buddy(account, user)) != NULL) + username = g_markup_escape_text(gaim_buddy_get_alias(buddy), -1); + else + username = g_markup_escape_text(user, -1); + + str = g_strdup_printf(_("%s just sent you a Nudge!"), username); + g_free(username); + msn_switchboard_report_user(swboard, GAIM_MESSAGE_SYSTEM, str); + g_free(str); +} + /************************************************************************** * Connect stuff **************************************************************************/ @@ -1240,6 +1233,8 @@ msn_p2p_msg); msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", msn_emoticon_msg); + msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast", + nudge_msg); #if 0 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", msn_invite_msg); diff -r d3b567926e8f -r 95fa774d216d src/protocols/msn/switchboard.h --- a/src/protocols/msn/switchboard.h Sun Aug 21 17:01:43 2005 +0000 +++ b/src/protocols/msn/switchboard.h Sun Aug 21 17:14:22 2005 +0000 @@ -265,6 +265,14 @@ void msn_emoticon_msg(MsnCmdProc *cmdproc, MsnMessage *msg); /** + * Processes nudge messages. + * + * @param cmdproc The command processor. + * @param msg The message. + */ +void msn_nudge_msg(MsnCmdProc *cmdproc, MsnMessage *msg); + +/** * Processes INVITE messages. * * @param cmdproc The command processor.