changeset 30677:e9c6be9e0ddf

When adding users to an MSN chat, don't add them again if the same passport is in the conversation. That is, ignore people logged in at more than one location.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Mon, 14 Dec 2009 23:44:51 +0000
parents 43cf75e21702
children 17ee21b062f9
files libpurple/protocols/msn/switchboard.c
diffstat 1 files changed, 16 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/switchboard.c	Mon Dec 14 07:15:24 2009 +0000
+++ b/libpurple/protocols/msn/switchboard.c	Mon Dec 14 23:44:51 2009 +0000
@@ -222,13 +222,28 @@
 {
 	MsnCmdProc *cmdproc;
 	PurpleAccount *account;
+	char *semicolon;
+	char *passport;
 
 	g_return_if_fail(swboard != NULL);
 
 	cmdproc = swboard->cmdproc;
 	account = cmdproc->session->account;
 
-	swboard->users = g_list_prepend(swboard->users, g_strdup(user));
+	semicolon = strchr(user, ';');
+	/* We don't really care about the machine ID. */
+	if (semicolon)
+		passport = g_strndup(user, semicolon - user);
+	else
+		passport = g_strdup(user);
+
+	/* Don't add multiple endpoints to the conversation. */
+	if (g_list_find_custom(swboard->users, passport, (GCompareFunc)strcmp)) {
+		g_free(passport);
+		return;
+	}
+
+	swboard->users = g_list_prepend(swboard->users, passport);
 	swboard->current_users++;
 	swboard->empty = FALSE;