pidgin.2.5.6: 83340fde: *** Plucked rev 0257ab6e (wabz at pidgin.im...

sadrul at pidgin.im sadrul at pidgin.im
Wed Apr 29 14:36:33 EDT 2009


-----------------------------------------------------------------
Revision: 83340fde0be7982cbf3d7355bc5cea7c1d3fd716
Ancestor: cd2388dc848c465e4e825ed604676d8e52494b06
Author: sadrul at pidgin.im
Date: 2009-04-29T18:19:22
Branch: im.pidgin.pidgin.2.5.6
URL: http://d.pidgin.im/viewmtn/revision/info/83340fde0be7982cbf3d7355bc5cea7c1d3fd716

Modified files:
        libpurple/conversation.c libpurple/server.c

ChangeLog: 

*** Plucked rev 0257ab6e (wabz at pidgin.im):
Set PURPLE_MESSAGE_RECV before receiving-im-msg. Also set it when receiving chat messages.

*** Plucked rev eed05980 (wabz at pidgin.im):
Set _MESSAGE_{RECV,SEND} properly when receiving chat messages. Thanks Sadrul!

*** Plucked rev ec236422 (sadrul at pidgin.im):
Chat's nick is normalized. So normalize before comparing with it.
Also, remove an extra normalization operation.


-------------- next part --------------
============================================================
--- libpurple/conversation.c	8bf92ab20e821ea58a9289a59e18d1ba2faff1e5
+++ libpurple/conversation.c	37b1bf080cdcf55182ef8a6c2fa193a7c9c21f50
@@ -1477,11 +1477,11 @@ purple_conv_chat_write(PurpleConvChat *c
 		return;
 
 	if (!(flags & PURPLE_MESSAGE_WHISPER)) {
-		char *str;
+		const char *str;
 
-		str = g_strdup(purple_normalize(account, who));
+		str = purple_normalize(account, who);
 
-		if (!strcmp(str, purple_normalize(account, chat->nick))) {
+		if (purple_strequal(str, chat->nick)) {
 			flags |= PURPLE_MESSAGE_SEND;
 		} else {
 			flags |= PURPLE_MESSAGE_RECV;
@@ -1489,8 +1489,6 @@ purple_conv_chat_write(PurpleConvChat *c
 			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. */
============================================================
--- libpurple/server.c	220d6ae72c784eab7d626b35d56bf996ee66a3cb
+++ libpurple/server.c	d919c981289873aeaa9478fd08465462d3cfaee2
@@ -583,6 +583,11 @@ void serv_got_im(PurpleConnection *gc, c
 
 	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 @@ void serv_got_im(PurpleConnection *gc, c
 	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 @@ void serv_got_chat_in(PurpleConnection *
 	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.


More information about the Commits mailing list