pidgin: bebaa683: another patch from Maiku that "Properly ...

khc at pidgin.im khc at pidgin.im
Thu Mar 27 02:37:42 EDT 2008


-----------------------------------------------------------------
Revision: bebaa6838815195a5c97614f4aaf7e0f13ef2da7
Ancestor: 83dcf4e58b35065eac18aea599a66d165135124a
Author: khc at pidgin.im
Date: 2008-03-27T06:32:31
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/bebaa6838815195a5c97614f4aaf7e0f13ef2da7

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

ChangeLog: 

another patch from Maiku that "Properly identifies users you have the mobile
number for as mobile" from the addressbook. I don't use this stuff, so
please test.

References #2359

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/contact.c	2e49ff88c5f1633912487a21cbf0df32a341d617
+++ libpurple/protocols/msn/contact.c	43f70cc48eab5838f5813a6a673c6b1b613c25e7
@@ -464,12 +464,64 @@ msn_parse_addressbook_groups(MsnContact 
 	}
 }
 
+static gboolean
+msn_parse_addressbook_mobile(xmlnode *contactInfo, char **inout_mobile_number)
+{
+	xmlnode *phones;
+	char *mobile_number = NULL;
+	gboolean mobile = FALSE;
+
+	*inout_mobile_number = NULL;
+
+	if ((phones = xmlnode_get_child(contactInfo, "phones"))) {
+		xmlnode *contact_phone;
+		char *phone_type = NULL;
+
+		for (contact_phone = xmlnode_get_child(phones, "ContactPhone");
+			 contact_phone;
+			 contact_phone = xmlnode_get_next_twin(contact_phone)) {
+			xmlnode *contact_phone_type;
+
+			if (!(contact_phone_type =
+					xmlnode_get_child(contact_phone, "contactPhoneType")))
+				continue;
+
+			phone_type = xmlnode_get_data(contact_phone_type);
+
+			if (phone_type && !strcmp(phone_type, "ContactPhoneMobile")) {
+				xmlnode *number;
+					
+				if ((number = xmlnode_get_child(contact_phone, "number"))) {
+					xmlnode *messenger_enabled;
+					char *is_messenger_enabled = NULL;
+
+					mobile_number = xmlnode_get_data(number);
+
+					if (mobile_number &&
+						(messenger_enabled = xmlnode_get_child(contact_phone, "isMessengerEnabled")) 
+						&& (is_messenger_enabled = xmlnode_get_data(messenger_enabled)) 
+						&& !strcmp(is_messenger_enabled, "true"))
+						mobile = TRUE;
+
+					g_free(is_messenger_enabled);
+				}
+			}
+
+			g_free(phone_type);
+		}
+	}
+
+	*inout_mobile_number = mobile_number;
+	return mobile;
+}
+
 static void
 msn_parse_addressbook_contacts(MsnContact *contact, xmlnode *node)
 {
 	MsnSession *session = contact->session;
 	xmlnode *contactNode;
-	char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL;
+	char *passport = NULL, *Name = NULL, *uid = NULL, *type = NULL, *mobile_number = NULL;
+	gboolean mobile = FALSE;
 
 	for(contactNode = xmlnode_get_child(node, "Contact"); contactNode;
 				contactNode = xmlnode_get_next_twin(contactNode)) {
@@ -486,7 +538,8 @@ msn_parse_addressbook_contacts(MsnContac
 		g_free(Name);
 		g_free(uid);
 		g_free(type);
-		passport = Name = uid = type = NULL;
+		passport = Name = uid = type = mobile_number = NULL;
+		mobile = FALSE;
 
 		uid = xmlnode_get_data(contactId);
 		type = xmlnode_get_data(contactType);
@@ -554,12 +607,16 @@ msn_parse_addressbook_contacts(MsnContac
 		else
 			Name = g_strdup(passport);
 
-		purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s}\n",
-						passport, uid ? uid : "(null)", Name ? Name : "(null)");
+		mobile = msn_parse_addressbook_mobile(contactInfo, &mobile_number);
 
+		purple_debug_misc("MsnAB","passport:{%s} uid:{%s} display:{%s} mobile:{%s} mobile number:{%s}\n",
+			passport, uid ? uid : "(null)", Name ? Name : "(null)",
+			mobile ? "true" : "false", mobile_number ? mobile_number : "(null)");
+
 		user = msn_userlist_find_add_user(session->userlist, passport, Name);
 		msn_user_set_uid(user, uid);
 		msn_user_set_type(user, usertype);
+		msn_user_set_mobile_phone(user, mobile_number);
 
 		groupIds = xmlnode_get_child(contactInfo, "groupIds");
 		if (groupIds) {
@@ -577,6 +634,13 @@ msn_parse_addressbook_contacts(MsnContac
 		}
 
 		msn_got_lst_user(session, user, MSN_LIST_FL_OP, NULL);
+
+		if(mobile && user)
+		{
+			user->mobile = TRUE;
+			purple_prpl_got_user_status(session->account, user->passport, "mobile", NULL);
+			purple_prpl_got_user_status(session->account, user->passport, "available", NULL);
+		}
 	}
 
 	g_free(passport);


More information about the Commits mailing list