changeset 31263:8fc25b77295a

Hopefully fixes #13298, the bug about not being able to add MSN buddies. Here's what I think is happening: 1. Before we add the buddy we issue an FQY request to ask the server what network the username is for (either normal MSN or Yahoo) 2. When we get the response we add the buddy to our buddy list with the network ID given to us by the server 3. For some reason the server is now returning a network ID of 0 ("unknown") instead of 1 ("normal MSN") for normal passport buddies, and we bail out when we encounter this. QuLogic thinks the server used to return 1 in this case. My change is to just not bail out if the FQY response has network ID 0. Instead of treat 0 as 1 and continue with the add. It looks like our SOAP request to add the buddy to our address book will fail a big further down the road if the buddy doesn't exist--so we're still protecting against that.
author Mark Doliner <mark@kingant.net>
date Mon, 28 Feb 2011 08:26:40 +0000
parents feb50c34ec46
children 169ebed69ef0
files ChangeLog libpurple/protocols/msn/msn.c
diffstat 2 files changed, 30 insertions(+), 27 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Feb 28 07:12:27 2011 +0000
+++ b/ChangeLog	Mon Feb 28 08:26:40 2011 +0000
@@ -8,6 +8,10 @@
 	* Fix a bug where some buddies from your buddy list might not show up.
 	  Affected non-English ICQ users the most. (#13386)
 
+	MSN:
+	* Fix bug that prevented added buddies to your buddy list in certain
+	  circumstances.  (#13298)
+
 	XMPP:
 	* Fix building on platforms with an older glib (inadvertantly broken in
 	  2.7.10).  (#13329)
--- a/libpurple/protocols/msn/msn.c	Mon Feb 28 07:12:27 2011 +0000
+++ b/libpurple/protocols/msn/msn.c	Mon Feb 28 08:26:40 2011 +0000
@@ -1751,39 +1751,33 @@
                   MsnUser *user)
 {
 	char *group;
+	MsnUserList *userlist;
+	MsnUser *user2;
 
 	g_return_if_fail(user != NULL);
 
+	if (network == MSN_NETWORK_UNKNOWN) {
+		purple_debug_error("msn", "Network in FQY response was unknown.  "
+				"Assuming %s is a passport user and adding anyway.\n", who);
+		network = MSN_NETWORK_PASSPORT;
+	}
+
 	group = msn_user_remove_pending_group(user);
 
-	if (network != MSN_NETWORK_UNKNOWN) {
-		MsnUserList *userlist = session->userlist;
-		MsnUser *user2 = msn_userlist_find_user(userlist, who);
-		if (user2 != NULL) {
-			/* User already in userlist, so just update it. */
-			msn_user_unref(user);
-			user = user2;
-		} else {
-			msn_userlist_add_user(userlist, user);
-			msn_user_unref(user);
-		}
-
-		msn_user_set_network(user, network);
-		msn_userlist_add_buddy(userlist, who, group);
-	}
-	else
-	{
-		PurpleBuddy * buddy = purple_find_buddy(session->account, who);
-		gchar *buf;
-		buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid.  Usernames must be valid email addresses."), who);
-		if (!purple_conv_present_error(who, session->account, buf))
-			purple_notify_error(purple_account_get_connection(session->account), NULL, _("Unable to Add"), buf);
-		g_free(buf);
-
-		/* Remove from local list */
-		purple_blist_remove_buddy(buddy);
+	userlist = session->userlist;
+	user2 = msn_userlist_find_user(userlist, who);
+	if (user2 != NULL) {
+		/* User already in userlist, so just update it. */
+		msn_user_unref(user);
+		user = user2;
+	} else {
+		msn_userlist_add_user(userlist, user);
 		msn_user_unref(user);
 	}
+
+	msn_user_set_network(user, network);
+	msn_userlist_add_buddy(userlist, who, group);
+
 	g_free(group);
 }
 
@@ -1820,7 +1814,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. */
+	 * internal.
+	 * KingAnt: But PurpleBuddys must always exist inside PurpleGroups, so
+	 * won't group always be non-NULL here?
+	 */
 	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
@@ -1839,6 +1836,8 @@
 		fqy = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>",
 		                      tokens[1],
 		                      tokens[0]);
+		/* TODO: I think user will leak if we disconnect before receiving
+		         a response to this FQY request */
 		msn_notification_send_fqy(session, fqy, strlen(fqy),
 		                          (MsnFqyCb)add_pending_buddy, user);
 		g_free(fqy);