diff libpurple/protocols/msn/contact.c @ 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 692c34bf98d8
children 98afd76647bd
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);
 	}