If the MSN user is in the userlist already, then check whether we know the

Sun, 14 Dec 2008 05:24:32 +0000

author
Elliott Sales de Andrade <qulogic@pidgin.im>
date
Sun, 14 Dec 2008 05:24:32 +0000
changeset 25156
af3e232e2463
parent 25155
f69512d24633
child 25157
c63edcfab96e

If the MSN user is in the userlist already, then check whether we know the
network before adding them. If it's unknown (because the buddy's in the AB
or privacy lists only), then request network with an FQY.

References #3322.
References #6755.

libpurple/protocols/msn/msn.c file | annotate | diff | comparison | revisions
libpurple/protocols/msn/userlist.c file | annotate | diff | comparison | revisions
--- a/libpurple/protocols/msn/msn.c	Sun Dec 14 05:22:52 2008 +0000
+++ b/libpurple/protocols/msn/msn.c	Sun Dec 14 05:24:32 2008 +0000
@@ -1418,6 +1418,7 @@
 	MsnSession *session;
 	MsnUserList *userlist;
 	const char *who;
+	MsnUser *user;
 
 	session = gc->proto_data;
 	userlist = session->userlist;
@@ -1446,9 +1447,10 @@
 	/* XXX - Would group ever be NULL here?  I don't think so...
 	 * shx: Yes it should; MSN handles non-grouped buddies, and this is only
 	 * internal. */
-	if (msn_userlist_find_user(userlist, who) != NULL) {
-		/* We already know this buddy. This function takes care of users
-		   already in the list and stuff... */
+	user = msn_userlist_find_user(userlist, who);
+	if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) {
+		/* We already know this buddy and their network. This function knows
+		   what to do with users already in the list and stuff... */
 		msn_userlist_add_buddy(userlist, who, group ? group->name : NULL);
 	} else {
 		/* We need to check the network for this buddy first */
--- a/libpurple/protocols/msn/userlist.c	Sun Dec 14 05:22:52 2008 +0000
+++ b/libpurple/protocols/msn/userlist.c	Sun Dec 14 05:24:32 2008 +0000
@@ -775,6 +775,7 @@
                                /*MsnNetwork*/ int network)
 {
 	MsnUser *user = NULL;
+	MsnUser *user2;
 	GList *l;
 	char *group;
 
@@ -793,13 +794,18 @@
 		return;
 	}
 
-	/* Bit of a hack, but by adding to userlist now, the rest of the code
-	 * will know what network to use.
-	 */
+	group = msn_user_remove_pending_group(user);
+
+	user2 = msn_userlist_find_user(userlist, who);
+	if (user2 != NULL) {
+		/* User already in userlist, so just update it. */
+		msn_user_destroy(user);
+		user = user2;
+	} else {
+		msn_userlist_add_user(userlist, user);
+	}
+
 	msn_user_set_network(user, network);
-	msn_userlist_add_user(userlist, user);
-
-	group = msn_user_remove_pending_group(user);
 	msn_userlist_add_buddy(userlist, who, group);
 	g_free(group);
 }

mercurial