Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/msn.c @ 31712: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 | db330f8c1a8c |
comparison
equal
deleted
inserted
replaced
31711:feb50c34ec46 | 31712:8fc25b77295a |
---|---|
1749 const char *who, | 1749 const char *who, |
1750 MsnNetwork network, | 1750 MsnNetwork network, |
1751 MsnUser *user) | 1751 MsnUser *user) |
1752 { | 1752 { |
1753 char *group; | 1753 char *group; |
1754 MsnUserList *userlist; | |
1755 MsnUser *user2; | |
1754 | 1756 |
1755 g_return_if_fail(user != NULL); | 1757 g_return_if_fail(user != NULL); |
1756 | 1758 |
1759 if (network == MSN_NETWORK_UNKNOWN) { | |
1760 purple_debug_error("msn", "Network in FQY response was unknown. " | |
1761 "Assuming %s is a passport user and adding anyway.\n", who); | |
1762 network = MSN_NETWORK_PASSPORT; | |
1763 } | |
1764 | |
1757 group = msn_user_remove_pending_group(user); | 1765 group = msn_user_remove_pending_group(user); |
1758 | 1766 |
1759 if (network != MSN_NETWORK_UNKNOWN) { | 1767 userlist = session->userlist; |
1760 MsnUserList *userlist = session->userlist; | 1768 user2 = msn_userlist_find_user(userlist, who); |
1761 MsnUser *user2 = msn_userlist_find_user(userlist, who); | 1769 if (user2 != NULL) { |
1762 if (user2 != NULL) { | 1770 /* User already in userlist, so just update it. */ |
1763 /* User already in userlist, so just update it. */ | |
1764 msn_user_unref(user); | |
1765 user = user2; | |
1766 } else { | |
1767 msn_userlist_add_user(userlist, user); | |
1768 msn_user_unref(user); | |
1769 } | |
1770 | |
1771 msn_user_set_network(user, network); | |
1772 msn_userlist_add_buddy(userlist, who, group); | |
1773 } | |
1774 else | |
1775 { | |
1776 PurpleBuddy * buddy = purple_find_buddy(session->account, who); | |
1777 gchar *buf; | |
1778 buf = g_strdup_printf(_("Unable to add the buddy %s because the username is invalid. Usernames must be valid email addresses."), who); | |
1779 if (!purple_conv_present_error(who, session->account, buf)) | |
1780 purple_notify_error(purple_account_get_connection(session->account), NULL, _("Unable to Add"), buf); | |
1781 g_free(buf); | |
1782 | |
1783 /* Remove from local list */ | |
1784 purple_blist_remove_buddy(buddy); | |
1785 msn_user_unref(user); | 1771 msn_user_unref(user); |
1786 } | 1772 user = user2; |
1773 } else { | |
1774 msn_userlist_add_user(userlist, user); | |
1775 msn_user_unref(user); | |
1776 } | |
1777 | |
1778 msn_user_set_network(user, network); | |
1779 msn_userlist_add_buddy(userlist, who, group); | |
1780 | |
1787 g_free(group); | 1781 g_free(group); |
1788 } | 1782 } |
1789 | 1783 |
1790 static void | 1784 static void |
1791 finish_auth_request(MsnAddReqData *data, char *msg) | 1785 finish_auth_request(MsnAddReqData *data, char *msg) |
1818 return; | 1812 return; |
1819 } | 1813 } |
1820 | 1814 |
1821 /* XXX - Would group ever be NULL here? I don't think so... | 1815 /* XXX - Would group ever be NULL here? I don't think so... |
1822 * shx: Yes it should; MSN handles non-grouped buddies, and this is only | 1816 * shx: Yes it should; MSN handles non-grouped buddies, and this is only |
1823 * internal. */ | 1817 * internal. |
1818 * KingAnt: But PurpleBuddys must always exist inside PurpleGroups, so | |
1819 * won't group always be non-NULL here? | |
1820 */ | |
1824 user = msn_userlist_find_user(userlist, who); | 1821 user = msn_userlist_find_user(userlist, who); |
1825 if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) { | 1822 if ((user != NULL) && (user->networkid != MSN_NETWORK_UNKNOWN)) { |
1826 /* We already know this buddy and their network. This function knows | 1823 /* We already know this buddy and their network. This function knows |
1827 what to do with users already in the list and stuff... */ | 1824 what to do with users already in the list and stuff... */ |
1828 msn_user_set_invite_message(user, msg); | 1825 msn_user_set_invite_message(user, msg); |
1837 msn_user_set_network(user, MSN_NETWORK_UNKNOWN); | 1834 msn_user_set_network(user, MSN_NETWORK_UNKNOWN); |
1838 tokens = g_strsplit(who, "@", 2); | 1835 tokens = g_strsplit(who, "@", 2); |
1839 fqy = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>", | 1836 fqy = g_strdup_printf("<ml><d n=\"%s\"><c n=\"%s\"/></d></ml>", |
1840 tokens[1], | 1837 tokens[1], |
1841 tokens[0]); | 1838 tokens[0]); |
1839 /* TODO: I think user will leak if we disconnect before receiving | |
1840 a response to this FQY request */ | |
1842 msn_notification_send_fqy(session, fqy, strlen(fqy), | 1841 msn_notification_send_fqy(session, fqy, strlen(fqy), |
1843 (MsnFqyCb)add_pending_buddy, user); | 1842 (MsnFqyCb)add_pending_buddy, user); |
1844 g_free(fqy); | 1843 g_free(fqy); |
1845 g_strfreev(tokens); | 1844 g_strfreev(tokens); |
1846 } | 1845 } |