pidgin: a1b27d59: Use ContactEmail to add federated buddie...

qulogic at pidgin.im qulogic at pidgin.im
Wed Dec 10 01:56:31 EST 2008


-----------------------------------------------------------------
Revision: a1b27d590ef43926850de80dae575e8353524fde
Ancestor: 504bd11eb0160511a68c8c123ce55505fe843669
Author: qulogic at pidgin.im
Date: 2008-12-08T00:47:55
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/a1b27d590ef43926850de80dae575e8353524fde

Modified files:
        libpurple/protocols/msn/contact.c
        libpurple/protocols/msn/contact.h

ChangeLog: 

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.

Comments: 

References #3322.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c	cc55867c07da8a09252f00bb8797522909d7f148
+++ libpurple/protocols/msn/contact.c	7d77d0e5de5bc91263633aa5b35eb80a82cdbaa6
@@ -1007,6 +1007,7 @@ msn_add_contact(MsnSession *session, Msn
 void
 msn_add_contact(MsnSession *session, MsnCallbackState *state, const char *passport)
 {
+	MsnUser *user;
 	gchar *body = NULL;
 	gchar *contact_xml = NULL;
 
@@ -1024,7 +1025,21 @@ msn_add_contact(MsnSession *session, Msn
 
 	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 @@ msn_add_contact_to_group(MsnSession *ses
 		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);
 	}
============================================================
--- libpurple/protocols/msn/contact.h	06369855eb76da5d6f4ff8efc716b99285ede558
+++ libpurple/protocols/msn/contact.h	496abe6aeaafc86a8a1c41a740da61534388e1e5
@@ -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/\""\


More information about the Commits mailing list