pidgin: b1b60077: A patch from Jaywalker to better handle ...

rlaager at pidgin.im rlaager at pidgin.im
Thu Nov 13 14:00:32 EST 2008


-----------------------------------------------------------------
Revision: b1b60077658bb1e01f71e81175786a8e7c3c4916
Ancestor: 62f32465bf3fc9e633905a7a7dabceef2925769e
Author: rlaager at pidgin.im
Date: 2008-11-13T18:55:04
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/b1b60077658bb1e01f71e81175786a8e7c3c4916

Modified files:
        libpurple/protocols/myspace/myspace.c
        libpurple/protocols/myspace/myspace.h

ChangeLog: 

A patch from Jaywalker to better handle conversations by user ID vs.
username.
Fixes #4631

-------------- next part --------------
============================================================
--- libpurple/protocols/myspace/myspace.c	03f4a618f1c34ff94295a3978bf42fa5a9def896
+++ libpurple/protocols/myspace/myspace.c	45fe3e71cd0fa71085e489b32dcf2fe040bfb4b6
@@ -680,20 +680,34 @@ msim_incoming_im(MsimSession *session, M
 msim_incoming_im(MsimSession *session, MsimMessage *msg)
 {
 	gchar *username, *msg_msim_markup, *msg_purple_markup;
+	gchar *userid;
 	time_t time_received;
+	PurpleConversation *conv;
 
 	g_return_val_if_fail(MSIM_SESSION_VALID(session), FALSE);
 	g_return_val_if_fail(msg != NULL, FALSE);
 
 	username = msim_msg_get_string(msg, "_username");
+	/* I know this isn't really a string... but we need it to be one for
+	 * purple_find_conversation_with_account(). */
+	userid = msim_msg_get_string(msg, "f");
 	g_return_val_if_fail(username != NULL, FALSE);
 
+	purple_debug_info("msim_incoming_im", "UserID is %s", userid);
+
 	if (msim_is_userid(username)) {
 		purple_debug_info("msim", "Ignoring message from spambot (%s) on account %s\n",
 				username, purple_account_get_username(session->account));
 		g_free(username);
 		return FALSE;
 	}
+	
+	/* See if a conversation with their UID already exists...*/
+	conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM, userid, session->account);
+	if (conv) {
+		/* Since the conversation exists... We need to normalize it */
+		purple_conversation_set_name(conv, username);
+	}
 
 	msg_msim_markup = msim_msg_get_string(msg, "msg");
 	g_return_val_if_fail(msg_msim_markup != NULL, FALSE);
@@ -703,6 +717,7 @@ msim_incoming_im(MsimSession *session, M
 
 	time_received = msim_msg_get_integer(msg, "date");
 	if (!time_received) {
+		purple_debug_info("msim_incoming_im", "date in message not set.\n");
 		time_received = time(NULL);
 	}
 
============================================================
--- libpurple/protocols/myspace/myspace.h	b562edaec50b976c20cdfe642b92f5560e438a96
+++ libpurple/protocols/myspace/myspace.h	86d4edf3416ff5dd1ae529612b743df7b558b2e1
@@ -48,6 +48,7 @@
 #include "request.h"    /* For dialogs used in setting the username */
 #include "xmlnode.h"
 #include "core.h"
+#include "conversation.h" /* For late normalization */
 
 /* MySpaceIM includes */
 #include "persist.h"


More information about the Commits mailing list