Mercurial > pidgin
changeset 24524:2b6847646817
Use ContactEmail to add federated buddies to the AddressBook. Those on Yahoo
get Messenger2 type, and the others get Messenger3. I don't know the difference
between them, but I'm going by empirical evidence (from many debug logs). I
also don't know what the Capability field is, but I set it to 0 for now. This
works in my limited testing with one Yahoo buddy.
References #6755.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Mon, 08 Dec 2008 00:47:55 +0000 |
parents | 77873bca18bb |
children | 98afd76647bd |
files | libpurple/protocols/msn/contact.c libpurple/protocols/msn/contact.h |
diffstat | 2 files changed, 44 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c Mon Dec 08 00:18:45 2008 +0000 +++ b/libpurple/protocols/msn/contact.c Mon Dec 08 00:47:55 2008 +0000 @@ -1007,6 +1007,7 @@ void msn_add_contact(MsnSession *session, MsnCallbackState *state, const char *passport) { + MsnUser *user; gchar *body = NULL; gchar *contact_xml = NULL; @@ -1024,7 +1025,21 @@ purple_debug_info("msn", "Adding contact %s to contact list\n", passport); - contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport); + user = msn_userlist_find_user(session->userlist, passport); + if (user == NULL) { + purple_debug_warning("msn", "Unable to retrieve user %s from the userlist!\n", passport); + return; /* guess this never happened! */ + } + + if (user->networkid != MSN_NETWORK_PASSPORT) { + contact_xml = g_strdup_printf(MSN_CONTACT_EMAIL_XML, + user->networkid == MSN_NETWORK_YAHOO ? + "Messenger2" : + "Messenger3", + passport, 0); + } else { + contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport); + } body = g_strdup_printf(MSN_ADD_CONTACT_TEMPLATE, contact_xml); state->body = xmlnode_from_str(body, -1); @@ -1155,8 +1170,14 @@ return; /* guess this never happened! */ } - if (user != NULL && user->uid != NULL) { + if (user->uid != NULL) { contact_xml = g_strdup_printf(MSN_CONTACT_ID_XML, user->uid); + } else if (user->networkid != MSN_NETWORK_PASSPORT) { + contact_xml = g_strdup_printf(MSN_CONTACT_EMAIL_XML, + user->networkid == MSN_NETWORK_YAHOO ? + "Messenger2" : + "Messenger3", + passport, 0); } else { contact_xml = g_strdup_printf(MSN_CONTACT_XML, passport); }
--- a/libpurple/protocols/msn/contact.h Mon Dec 08 00:18:45 2008 +0000 +++ b/libpurple/protocols/msn/contact.h Mon Dec 08 00:47:55 2008 +0000 @@ -211,6 +211,27 @@ "</contactInfo>"\ "</Contact>" +#define MSN_CONTACT_ID_XML \ + "<Contact>"\ + "<contactId>%s</contactId>"\ + "</Contact>" + +#define MSN_CONTACT_EMAIL_XML \ + "<Contact>"\ + "<contactInfo>"\ + "<emails>"\ + "<ContactEmail>"\ + "<contactEmailType>%s</contactEmailType>"\ + "<email>%s</email>"\ + "<isMessengerEnabled>true</isMessengerEnabled>"\ + "<Capability>%d</Capability>"\ + "<MessengerEnabledExternally>false</MessengerEnabledExternally>"\ + "<propertiesChanged/>"\ + "</ContactEmail>"\ + "</emails>"\ + "</contactInfo>"\ + "</Contact>" + #define MSN_ADD_CONTACT_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\ "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""\ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\""\ @@ -275,7 +296,6 @@ /* Delete a contact from the Contact List */ #define MSN_CONTACT_DEL_SOAP_ACTION "http://www.msn.com/webservices/AddressBook/ABContactDelete" -#define MSN_CONTACT_ID_XML "<Contact><contactId>%s</contactId></Contact>" #define MSN_DEL_CONTACT_TEMPLATE "<?xml version=\"1.0\" encoding=\"utf-8\"?>"\ "<soap:Envelope"\ " xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\""\