soc.2010.msn-tlc: 65ec814b: Switchboard->users is now a list of MsnU...

masca at cpw.pidgin.im masca at cpw.pidgin.im
Wed May 26 16:01:10 EDT 2010


-----------------------------------------------------------------
Revision: 65ec814b454bf8e5e79ae31c26f71759639e9256
Ancestor: 2e39e97e45f960fc8039e5afbf7a7ec13356dde4
Author: masca at cpw.pidgin.im
Date: 2010-05-25T22:06:03
Branch: im.pidgin.soc.2010.msn-tlc
URL: http://d.pidgin.im/viewmtn/revision/info/65ec814b454bf8e5e79ae31c26f71759639e9256

Modified files:
        libpurple/protocols/msn/switchboard.c

ChangeLog: 

Switchboard->users is now a list of MsnUsers which is a lot more useful and it is already allocated.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/switchboard.c	709fbfb0aa8102c7533e902ea6169b04555eb18d
+++ libpurple/protocols/msn/switchboard.c	77afa78738529806a5a9ec68c739f5cfc5b72dc3
@@ -25,6 +25,7 @@
 #include "prefs.h"
 #include "switchboard.h"
 #include "notification.h"
+#include "userlist.h"
 #include "msnutils.h"
 
 #include "error.h"
@@ -114,7 +115,6 @@ msn_switchboard_destroy(MsnSwitchBoard *
 	g_free(swboard->session_id);
 
 	for (; swboard->users; swboard->users = g_list_delete_link(swboard->users, swboard->users))
-		g_free(swboard->users->data);
 
 	session = swboard->session;
 	session->switches = g_list_remove(session->switches, swboard);
@@ -217,11 +217,23 @@ send_clientcaps(MsnSwitchBoard *swboard)
 	msn_message_destroy(msg);
 }
 
+static int
+user_passport_cmp(MsnUser *user, const char *passport)
+{
+	const char *pass;
+
+	pass = msn_user_get_passport(user);
+
+	return strcmp(pass, passport);
+}
+
 static void
 msn_switchboard_add_user(MsnSwitchBoard *swboard, const char *user)
 {
 	MsnCmdProc *cmdproc;
 	PurpleAccount *account;
+	MsnUserList *userlist;
+	MsnUser *msnuser;
 	char *semicolon;
 	char *passport;
 
@@ -237,8 +249,14 @@ msn_switchboard_add_user(MsnSwitchBoard 
 	else
 		passport = g_strdup(user);
 
+	userlist = swboard->session->userlist;
+	msnuser = msn_userlist_find_user(userlist, passport);
+
+	if (!msnuser)
+		purple_debug_error("msn","User %s is not on our list.\n", passport);
+
 	/* Don't add multiple endpoints to the conversation. */
-	if (g_list_find_custom(swboard->users, passport, (GCompareFunc)strcmp)) {
+	if (g_list_find_custom(swboard->users, passport, (GCompareFunc)user_passport_cmp)) {
 		g_free(passport);
 		return;
 	}
@@ -248,8 +266,10 @@ msn_switchboard_add_user(MsnSwitchBoard 
 		g_free(passport);
 		return;
 	}
+	
+	g_free(passport);
 
-	swboard->users = g_list_prepend(swboard->users, passport);
+	swboard->users = g_list_prepend(swboard->users, msnuser);
 	swboard->current_users++;
 	swboard->empty = FALSE;
 
@@ -267,7 +287,7 @@ msn_switchboard_add_user(MsnSwitchBoard 
 	if ((swboard->conv != NULL) &&
 		(purple_conversation_get_type(swboard->conv) == PURPLE_CONV_TYPE_CHAT))
 	{
-		purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), user, NULL,
+		purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv), msnuser->passport, NULL,
 								PURPLE_CBFLAGS_NONE, TRUE);
 		msn_servconn_set_idle_timeout(swboard->servconn, 0);
 	}
@@ -295,8 +315,9 @@ msn_switchboard_add_user(MsnSwitchBoard 
 			for (l = swboard->users; l != NULL; l = l->next)
 			{
 				const char *tmp_user;
+				user = l->data;
 
-				tmp_user = l->data;
+				tmp_user = msnuser->passport;
 
 				purple_conv_chat_add_user(PURPLE_CONV_CHAT(swboard->conv),
 										tmp_user, NULL, PURPLE_CBFLAGS_NONE, TRUE);
@@ -313,7 +334,7 @@ msn_switchboard_add_user(MsnSwitchBoard 
 	else if (swboard->conv == NULL)
 	{
 		swboard->conv = purple_find_conversation_with_account(PURPLE_CONV_TYPE_IM,
-															user, account);
+															msnuser->passport, account);
 	}
 	else
 	{


More information about the Commits mailing list