# HG changeset patch # User Sadrul Habib Chowdhury # Date 1241029162 0 # Node ID 1cf0b4f71d16a4d39d1d9df0b9945b76edc1deae # Parent f1efe664bd7bc96342ce858982b1e82ee1069287 *** Plucked rev 0257ab6e (wabz@pidgin.im): Set PURPLE_MESSAGE_RECV before receiving-im-msg. Also set it when receiving chat messages. *** Plucked rev eed05980 (wabz@pidgin.im): Set _MESSAGE_{RECV,SEND} properly when receiving chat messages. Thanks Sadrul! *** Plucked rev ec236422 (sadrul@pidgin.im): Chat's nick is normalized. So normalize before comparing with it. Also, remove an extra normalization operation. diff -r f1efe664bd7b -r 1cf0b4f71d16 libpurple/conversation.c --- a/libpurple/conversation.c Wed Apr 29 00:52:08 2009 +0000 +++ b/libpurple/conversation.c Wed Apr 29 18:19:22 2009 +0000 @@ -1477,11 +1477,11 @@ return; if (!(flags & PURPLE_MESSAGE_WHISPER)) { - char *str; - - str = g_strdup(purple_normalize(account, who)); - - if (!strcmp(str, purple_normalize(account, chat->nick))) { + const char *str; + + str = purple_normalize(account, who); + + if (purple_strequal(str, chat->nick)) { flags |= PURPLE_MESSAGE_SEND; } else { flags |= PURPLE_MESSAGE_RECV; @@ -1489,8 +1489,6 @@ if (purple_utf8_has_word(message, chat->nick)) flags |= PURPLE_MESSAGE_NICK; } - - g_free(str); } /* Pass this on to either the ops structure or the default write func. */ diff -r f1efe664bd7b -r 1cf0b4f71d16 libpurple/server.c --- a/libpurple/server.c Wed Apr 29 00:52:08 2009 +0000 +++ b/libpurple/server.c Wed Apr 29 18:19:22 2009 +0000 @@ -583,6 +583,11 @@ account = purple_connection_get_account(gc); + /* + * XXX: Should we be setting this here, or relying on prpls to set it? + */ + flags |= PURPLE_MESSAGE_RECV; + if (PURPLE_PLUGIN_PROTOCOL_INFO(purple_connection_get_prpl(gc))->set_permit_deny == NULL) { /* protocol does not support privacy, handle it ourselves */ if (!purple_privacy_check(account, who)) { @@ -626,11 +631,6 @@ if (conv == NULL) conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, name, gc->account); - /* - * XXX: Should we be setting this here, or relying on prpls to set it? - */ - flags |= PURPLE_MESSAGE_RECV; - if (conv == NULL) conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, name); @@ -935,6 +935,15 @@ if (!conv) return; + /* Did I send the message? */ + if (purple_strequal(purple_conv_chat_get_nick(chat), + purple_normalize(purple_conversation_get_account(conv), who))) { + flags |= PURPLE_MESSAGE_SEND; + flags &= ~PURPLE_MESSAGE_RECV; /* Just in case some prpl sets it! */ + } else { + flags |= PURPLE_MESSAGE_RECV; + } + /* * Make copies of the message and the sender in case plugins want * to free these strings and replace them with a modifed version.