Mercurial > pidgin
changeset 25399:8ee34225cfd9
Make message handlers more generic and able to work when used by the
notification server as well as the switchboard. I assume that messages from
the notification server count as 1-on-1 chats (what else could they be?).
References #7676.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sun, 01 Feb 2009 09:06:34 +0000 |
parents | ea98810d89c5 |
children | a214dc3807f8 |
files | libpurple/protocols/msn/msg.c |
diffstat | 1 files changed, 56 insertions(+), 39 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/msg.c Sun Feb 01 08:25:57 2009 +0000 +++ b/libpurple/protocols/msn/msg.c Sun Feb 01 09:06:34 2009 +0000 @@ -813,7 +813,6 @@ msn_plain_msg(MsnCmdProc *cmdproc, MsnMessage *msg) { PurpleConnection *gc; - MsnSwitchBoard *swboard; const char *body; char *body_str; char *body_enc; @@ -823,7 +822,6 @@ 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); @@ -863,35 +861,42 @@ body_final = body_enc; } - swboard->flag |= MSN_SB_FLAG_IM; + 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); + 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; + 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 - { + 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)); - 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); @@ -901,16 +906,24 @@ msn_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) - { + 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); } @@ -927,21 +940,25 @@ 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); + 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 + else + purple_prpl_got_attention(account->gc, user, MSN_NUDGE); + + } else { purple_prpl_got_attention(account->gc, user, MSN_NUDGE); + } } else if (!strcmp(id, "2")) { /* Wink */