Mercurial > pidgin.yaz
changeset 29664:e841bad196e0
A little manual merge...
author | Marcus Lundblad <ml@update.uu.se> |
---|---|
date | Fri, 06 Feb 2009 23:19:27 +0000 |
parents | af5c36fe8d6f |
children | 385473abc18b |
files | libpurple/protocols/msn/msg.c libpurple/protocols/msn/msg.h libpurple/protocols/msn/switchboard.c |
diffstat | 3 files changed, 188 insertions(+), 160 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c Tue Jan 13 18:39:52 2009 +0000 +++ b/libpurple/protocols/msn/msg.c Fri Feb 06 23:19:27 2009 +0000 @@ -23,6 +23,7 @@ */ #include "msn.h" #include "msg.h" +#include "msnutils.h" MsnMessage * msn_message_new(MsnMsgType type) @@ -79,7 +80,7 @@ msg->ref_count++; #ifdef MSN_DEBUG_MSG - purple_debug_info("msn", "message ref (%p)[%d]\n", msg, msg->ref_count); + purple_debug_info("msn", "message ref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count); #endif return msg; @@ -94,7 +95,7 @@ msg->ref_count--; #ifdef MSN_DEBUG_MSG - purple_debug_info("msn", "message unref (%p)[%d]\n", msg, msg->ref_count); + purple_debug_info("msn", "message unref (%p)[%" G_GSIZE_FORMAT "]\n", msg, msg->ref_count); #endif if (msg->ref_count == 0) @@ -804,3 +805,175 @@ g_string_free(str, TRUE); } + +/************************************************************************** + * Message Handlers + **************************************************************************/ +void +msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) +{ + PurpleConnection *gc; + const char *body; + char *body_str; + char *body_enc; + char *body_final; + size_t body_len; + const char *passport; + const char *value; + + gc = cmdproc->session->account->gc; + + body = msn_message_get_bin_data(msg, &body_len); + body_str = g_strndup(body, body_len); + body_enc = g_markup_escape_text(body_str, -1); + g_free(body_str); + + passport = msg->remote_user; + + if (!strcmp(passport, "messenger@microsoft.com") && + strstr(body, "immediate security update")) + { + return; + } + +#if 0 + if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) + { + purple_debug_misc("msn", "User-Agent = '%s'\n", value); + } +#endif + + if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) + { + char *pre, *post; + + msn_parse_format(value, &pre, &post); + + body_final = g_strdup_printf("%s%s%s", pre ? pre : "", + body_enc ? body_enc : "", post ? post : ""); + + g_free(pre); + g_free(post); + g_free(body_enc); + } + else + { + body_final = body_enc; + } + + if (cmdproc->servconn->type == MSN_SERVCONN_SB) { + MsnSwitchBoard *swboard = cmdproc->data; + + swboard->flag |= MSN_SB_FLAG_IM; + + if (swboard->current_users > 1 || + ((swboard->conv != NULL) && + purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) + { + /* If current_users is always ok as it should then there is no need to + * check if this is a chat. */ + if (swboard->current_users <= 1) + purple_debug_misc("msn", "plain_msg: current_users(%d)\n", + swboard->current_users); + + serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, + time(NULL)); + if (swboard->conv == NULL) + { + swboard->conv = purple_find_chat(gc, swboard->chat_id); + swboard->flag |= MSN_SB_FLAG_IM; + } + } + else + { + serv_got_im(gc, passport, body_final, 0, time(NULL)); + if (swboard->conv == NULL) + { + swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, + passport, purple_connection_get_account(gc)); + swboard->flag |= MSN_SB_FLAG_IM; + } + } + + } else { + serv_got_im(gc, passport, body_final, 0, time(NULL)); + } + + g_free(body_final); +} + +void +msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) +{ + PurpleConnection *gc; + char *passport; + + gc = cmdproc->session->account->gc; + passport = msg->remote_user; + + if (msn_message_get_attr(msg, "TypingUser") == NULL) + return; + + if (cmdproc->servconn->type == MSN_SERVCONN_SB) { + MsnSwitchBoard *swboard = cmdproc->data; + + if (swboard->current_users == 1) + { + serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, + PURPLE_TYPING); + } + + } else { + serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, + PURPLE_TYPING); + } +} + +void +msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg) +{ + GHashTable *body; + const char *id; + body = msn_message_get_hashtable_from_body(msg); + + id = g_hash_table_lookup(body, "ID"); + + if (!strcmp(id, "1")) { + /* Nudge */ + PurpleAccount *account; + const char *user; + + account = cmdproc->session->account; + user = msg->remote_user; + + if (cmdproc->servconn->type == MSN_SERVCONN_SB) { + MsnSwitchBoard *swboard = cmdproc->data; + if (swboard->current_users > 1 || + ((swboard->conv != NULL) && + purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) + purple_prpl_got_attention_in_chat(account->gc, swboard->chat_id, user, MSN_NUDGE); + + else + purple_prpl_got_attention(account->gc, user, MSN_NUDGE); + + purple_conversation_attention(swboard->conv, user, MSN_NUDGE, + PURPLE_MESSAGE_SEND, time(NULL)); + } else { + purple_prpl_got_attention(account->gc, user, MSN_NUDGE); + } + } else if (!strcmp(id, "2")) { + /* Wink */ + + } else if (!strcmp(id, "3")) { + /* Voiceclip */ + + } else if (!strcmp(id, "4")) { + /* Action */ + + } else { + purple_debug_warning("msn", "Got unknown datacast with ID %s.\n", id); + } + + g_hash_table_destroy(body); +} +
--- a/libpurple/protocols/msn/msg.h Tue Jan 13 18:39:52 2009 +0000 +++ b/libpurple/protocols/msn/msg.h Fri Feb 06 23:19:27 2009 +0000 @@ -109,6 +109,8 @@ char *charset; char *body; gsize body_len; + guint total_chunks; /**< How many chunks in this multi-part message */ + guint received_chunks; /**< How many chunks we've received so far */ MsnSlpHeader msnslp_header; MsnSlpFooter msnslp_footer; @@ -337,4 +339,10 @@ char *msn_message_to_string(MsnMessage *msg); +void msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg); + +void msn_control_msg(MsnCmdProc *cmdproc, MsnMessage *msg); + +void msn_datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg); + #endif /* _MSN_MSG_H_ */
--- a/libpurple/protocols/msn/switchboard.c Tue Jan 13 18:39:52 2009 +0000 +++ b/libpurple/protocols/msn/switchboard.c Fri Feb 06 23:19:27 2009 +0000 @@ -799,7 +799,7 @@ msn_cmdproc_process_msg(cmdproc, msg); - msn_message_destroy(msg); + msn_message_unref(msg); } static void @@ -887,113 +887,6 @@ * Message Handlers **************************************************************************/ static void -plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) -{ - PurpleConnection *gc; - MsnSwitchBoard *swboard; - const char *body; - char *body_str; - char *body_enc; - char *body_final; - size_t body_len; - const char *passport; - const char *value; - - gc = cmdproc->session->account->gc; - swboard = cmdproc->data; - - body = msn_message_get_bin_data(msg, &body_len); - body_str = g_strndup(body, body_len); - body_enc = g_markup_escape_text(body_str, -1); - g_free(body_str); - - passport = msg->remote_user; - - if (!strcmp(passport, "messenger@microsoft.com") && - strstr(body, "immediate security update")) - { - return; - } - -#if 0 - if ((value = msn_message_get_attr(msg, "User-Agent")) != NULL) - { - purple_debug_misc("msn", "User-Agent = '%s'\n", value); - } -#endif - - if ((value = msn_message_get_attr(msg, "X-MMS-IM-Format")) != NULL) - { - char *pre, *post; - - msn_parse_format(value, &pre, &post); - - body_final = g_strdup_printf("%s%s%s", pre ? pre : "", - body_enc ? body_enc : "", post ? post : ""); - - g_free(pre); - g_free(post); - g_free(body_enc); - } - else - { - body_final = body_enc; - } - - swboard->flag |= MSN_SB_FLAG_IM; - - if (swboard->current_users > 1 || - ((swboard->conv != NULL) && - purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) - { - /* If current_users is always ok as it should then there is no need to - * check if this is a chat. */ - if (swboard->current_users <= 1) - purple_debug_misc("msn", "plain_msg: current_users(%d)\n", - swboard->current_users); - - serv_got_chat_in(gc, swboard->chat_id, passport, 0, body_final, - time(NULL)); - if (swboard->conv == NULL) - { - swboard->conv = purple_find_chat(gc, swboard->chat_id); - swboard->flag |= MSN_SB_FLAG_IM; - } - } - else - { - serv_got_im(gc, passport, body_final, 0, time(NULL)); - if (swboard->conv == NULL) - { - swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, - passport, purple_connection_get_account(gc)); - swboard->flag |= MSN_SB_FLAG_IM; - } - } - - g_free(body_final); -} - -static void -control_msg(MsnCmdProc *cmdproc, MsnMessage *msg) -{ - PurpleConnection *gc; - MsnSwitchBoard *swboard; - char *passport; - - gc = cmdproc->session->account->gc; - swboard = cmdproc->data; - passport = msg->remote_user; - - if (swboard->current_users == 1 && - msn_message_get_attr(msg, "TypingUser") != NULL) - { - serv_got_typing(gc, passport, MSN_TYPING_RECV_TIMEOUT, - PURPLE_TYPING); - } -} - -static void clientcaps_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { #if 0 @@ -1012,52 +905,6 @@ #endif } -static void -datacast_msg(MsnCmdProc *cmdproc, MsnMessage *msg) -{ - GHashTable *body; - const char *id; - body = msn_message_get_hashtable_from_body(msg); - - id = g_hash_table_lookup(body, "ID"); - - if (!strcmp(id, "1")) { - /* Nudge */ - MsnSwitchBoard *swboard; - PurpleAccount *account; - const char *user; - - swboard = cmdproc->data; - account = cmdproc->session->account; - user = msg->remote_user; - - if (swboard->current_users > 1 || - ((swboard->conv != NULL) && - purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT)) - purple_prpl_got_attention_in_chat(account->gc, swboard->chat_id, user, MSN_NUDGE); - - else - purple_prpl_got_attention(account->gc, user, MSN_NUDGE); - - purple_conversation_attention(swboard->conv, user, 0, - PURPLE_MESSAGE_RECV, time(NULL)); - - } else if (!strcmp(id, "2")) { - /* Wink */ - - } else if (!strcmp(id, "3")) { - /* Voiceclip */ - - } else if (!strcmp(id, "4")) { - /* Action */ - - } else { - purple_debug_warning("msn", "Got unknown datacast with ID %s.\n", id); - } - - g_hash_table_destroy(body); -} - /************************************************************************** * Connect stuff **************************************************************************/ @@ -1375,9 +1222,9 @@ /* Register the message type callbacks. */ msn_table_add_msg_type(cbs_table, "text/plain", - plain_msg); + msn_plain_msg); msn_table_add_msg_type(cbs_table, "text/x-msmsgscontrol", - control_msg); + msn_control_msg); msn_table_add_msg_type(cbs_table, "text/x-clientcaps", clientcaps_msg); msn_table_add_msg_type(cbs_table, "text/x-clientinfo", @@ -1387,9 +1234,9 @@ msn_table_add_msg_type(cbs_table, "text/x-mms-emoticon", msn_emoticon_msg); msn_table_add_msg_type(cbs_table, "text/x-mms-animemoticon", - msn_emoticon_msg); + msn_emoticon_msg); msn_table_add_msg_type(cbs_table, "text/x-msnmsgr-datacast", - datacast_msg); + msn_datacast_msg); #if 0 msn_table_add_msg_type(cbs_table, "text/x-msmmsginvite", msn_invite_msg);