pidgin: bc63343e: Hopefully fixes #13298, the bug about no...

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Feb 28 03:32:39 EST 2011


----------------------------------------------------------------------
Revision: bc63343ea80150622360ff3bdbf293a8d12eb670
Parent:   a43b4cbedbecdd778fcc46ab93b13b1c8f0a326b
Author:   markdoliner at pidgin.im
Date:     02/28/11 03:26:40
Branch:   im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/bc63343ea80150622360ff3bdbf293a8d12eb670

Changelog: 

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.

Changes against parent a43b4cbedbecdd778fcc46ab93b13b1c8f0a326b

  patched  ChangeLog
  patched  libpurple/protocols/msn/msn.c

-------------- next part --------------
============================================================
--- ChangeLog	2706a132221761c93ae5652b0df72cb6665d516c
+++ ChangeLog	76d0f35cdbe7b53069f1111fed3a3fd80ddd4ec4
@@ -8,6 +8,10 @@ version 2.7.11 (??/??/????):
 	* 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)
============================================================
--- libpurple/protocols/msn/msn.c	80cf4a20bb82ff87d5c4266485f7677b84e6062f
+++ libpurple/protocols/msn/msn.c	dac8506f87416677fd1d5c6f8cbcc67246e6112e
@@ -1751,39 +1751,33 @@ add_pending_buddy(MsnSession *session,
                   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 @@ finish_auth_request(MsnAddReqData *data,
 
 	/* 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 @@ finish_auth_request(MsnAddReqData *data,
 		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);


More information about the Commits mailing list