changeset 23523:31b5a1334e7e

Modifications to the MSN code for some stuff I'll be doing in later commits. * Rename MsnUserType to MsnNetwork, because it's a really a Network ID. Updated the list of networks based on msnpiki. * Updated list of Client capabilities based on ZoRoNaX' blog: http://zoronax.spaces.live.com/blog/cns!4A0B813054895814!156.entry * Save the clientid of contacts.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 15 Jun 2008 08:08:22 +0000
parents fd124c21ebb7
children ad565744246e
files libpurple/protocols/msn/contact.c libpurple/protocols/msn/msn.h libpurple/protocols/msn/notification.c libpurple/protocols/msn/user.c libpurple/protocols/msn/user.h
diffstat 5 files changed, 126 insertions(+), 61 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Sun Jun 15 06:55:21 2008 +0000
+++ b/libpurple/protocols/msn/contact.c	Sun Jun 15 08:08:22 2008 +0000
@@ -176,23 +176,26 @@
 	return 0;
 }
 
-/*get User Type*/
-static int
-msn_get_user_type(char *type)
+/* get Network */
+/* QuLogic: These names don't really refer to the MsnNetwork,
+ *          but I haven't yet written the code to properly use them.
+ */
+static MsnNetwork
+msn_get_network(char *type)
 {
 	g_return_val_if_fail(type != NULL, 0);
 
 	if (!strcmp(type,"Regular")) {
-		return MSN_USER_TYPE_PASSPORT;
+		return MSN_NETWORK_PASSPORT;
 	}
 	if (!strcmp(type,"Live")) {
-		return MSN_USER_TYPE_PASSPORT;
+		return MSN_NETWORK_PASSPORT;
 	}
 	if (!strcmp(type,"LivePending")) {
-		return MSN_USER_TYPE_PASSPORT;
+		return MSN_NETWORK_PASSPORT;
 	}
 
-	return MSN_USER_TYPE_UNKNOWN;
+	return MSN_NETWORK_UNKNOWN;
 }
 
 /* Create the AddressBook in the server, if we don't have one */
@@ -519,7 +522,7 @@
 		xmlnode *contactId, *contactInfo, *contactType, *passportName, *displayName, *guid, *groupIds, *messenger_user;
 		xmlnode *annotation;
 		MsnUser *user;
-		MsnUserType usertype;
+		MsnNetwork networkId;
 
 		if (!(contactId = xmlnode_get_child(contactNode,"contactId"))
 				|| !(contactInfo = xmlnode_get_child(contactNode, "contactInfo"))
@@ -560,7 +563,7 @@
 			g_free(is_messenger_user);
 		}
 
-		usertype = msn_get_user_type(type);
+		networkId = msn_get_network(type);
 		passportName = xmlnode_get_child(contactInfo, "passportName");
 		if (passportName == NULL) {
 			xmlnode *emailsNode, *contactEmailNode, *emailNode;
@@ -591,7 +594,7 @@
 				if(msnEnabled && !strcmp(msnEnabled, "true")) {
 					/*Messenger enabled, Get the Passport*/
 					purple_debug_info("MsnAB", "Yahoo User %s\n", passport ? passport : "(null)");
-					usertype = MSN_USER_TYPE_YAHOO;
+					networkId = MSN_NETWORK_YAHOO;
 					g_free(msnEnabled);
 					break;
 				} else {
@@ -630,7 +633,7 @@
 
 		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_network(user, networkId);
 		msn_user_set_mobile_phone(user, mobile_number);
 
 		groupIds = xmlnode_get_child(contactInfo, "groupIds");
--- a/libpurple/protocols/msn/msn.h	Sun Jun 15 06:55:21 2008 +0000
+++ b/libpurple/protocols/msn/msn.h	Sun Jun 15 08:08:22 2008 +0000
@@ -105,18 +105,25 @@
 
 typedef enum
 {
-	MSN_CLIENT_CAP_WIN_MOBILE = 0x00001,
-	MSN_CLIENT_CAP_UNKNOWN_1  = 0x00002,
-	MSN_CLIENT_CAP_INK_GIF    = 0x00004,
-	MSN_CLIENT_CAP_INK_ISF    = 0x00008,
-	MSN_CLIENT_CAP_VIDEO_CHAT = 0x00010,
-	MSN_CLIENT_CAP_BASE       = 0x00020,
-	MSN_CLIENT_CAP_MSNMOBILE  = 0x00040,
-	MSN_CLIENT_CAP_MSNDIRECT  = 0x00080,
-	MSN_CLIENT_CAP_WEBMSGR    = 0x00100,
-	MSN_CLIENT_CAP_DIRECTIM   = 0x04000,
-	MSN_CLIENT_CAP_WINKS      = 0x08000,
-	MSN_CLIENT_CAP_SEARCH     = 0x10000
+	MSN_CLIENT_CAP_WIN_MOBILE = 0x000001,
+	MSN_CLIENT_CAP_INK_GIF    = 0x000004,
+	MSN_CLIENT_CAP_INK_ISF    = 0x000008,
+	MSN_CLIENT_CAP_VIDEO_CHAT = 0x000010,
+	MSN_CLIENT_CAP_PACKET     = 0x000020,
+	MSN_CLIENT_CAP_MSNMOBILE  = 0x000040,
+	MSN_CLIENT_CAP_MSNDIRECT  = 0x000080,
+	MSN_CLIENT_CAP_WEBMSGR    = 0x000200,
+	MSN_CLIENT_CAP_TGW        = 0x000800,
+	MSN_CLIENT_CAP_SPACE      = 0x001000,
+	MSN_CLIENT_CAP_MCE        = 0x002000,
+	MSN_CLIENT_CAP_DIRECTIM   = 0x004000,
+	MSN_CLIENT_CAP_WINKS      = 0x008000,
+	MSN_CLIENT_CAP_SEARCH     = 0x010000,
+	MSN_CLIENT_CAP_BOT        = 0x020000,
+	MSN_CLIENT_CAP_VOICEIM    = 0x040000,
+	MSN_CLIENT_CAP_SCHANNEL   = 0x080000,
+	MSN_CLIENT_CAP_SIP_INVITE = 0x100000,
+	MSN_CLIENT_CAP_SDRIVE     = 0x400000
 
 } MsnClientCaps;
 
@@ -127,19 +134,18 @@
 	MSN_CLIENT_VER_6_1 = 0x20,	/* MSNC2 */
 	MSN_CLIENT_VER_6_2 = 0x30,	/* MSNC3 */
 	MSN_CLIENT_VER_7_0 = 0x40,	/* MSNC4 */
-	MSN_CLIENT_VER_7_5 = 0x50	/* MSNC5 */
+	MSN_CLIENT_VER_7_5 = 0x50,	/* MSNC5 */
+	MSN_CLIENT_VER_8_0 = 0x60,	/* MSNC6 */
+	MSN_CLIENT_VER_8_1 = 0x70,	/* MSNC7 */
+	MSN_CLIENT_VER_8_5 = 0x80	/* MSNC8 */
 
 } MsnClientVerId;
 
 #define MSN_CLIENT_ID_VERSION      MSN_CLIENT_VER_7_0
-#define MSN_CLIENT_ID_RESERVED_1   0x00
-#define MSN_CLIENT_ID_RESERVED_2   0x00
-#define MSN_CLIENT_ID_CAPABILITIES MSN_CLIENT_CAP_BASE
+#define MSN_CLIENT_ID_CAPABILITIES MSN_CLIENT_CAP_PACKET
 
 #define MSN_CLIENT_ID \
 	((MSN_CLIENT_ID_VERSION    << 24) | \
-	 (MSN_CLIENT_ID_RESERVED_1 << 16) | \
-	 (MSN_CLIENT_ID_RESERVED_2 <<  8) | \
 	 (MSN_CLIENT_ID_CAPABILITIES))
 
 void msn_act_id(PurpleConnection *gc, const char *entry);
--- a/libpurple/protocols/msn/notification.c	Sun Jun 15 06:55:21 2008 +0000
+++ b/libpurple/protocols/msn/notification.c	Sun Jun 15 08:08:22 2008 +0000
@@ -556,7 +556,7 @@
  **************************************************************************/
 /* add contact to xmlnode */
 static void
-msn_add_contact_xml(MsnSession *session, xmlnode *mlNode,const char *passport, MsnListOp list_op, MsnUserType type)
+msn_add_contact_xml(MsnSession *session, xmlnode *mlNode,const char *passport, MsnListOp list_op, MsnNetwork networkId)
 {
 	xmlnode *d_node,*c_node;
 	char **tokens;
@@ -565,7 +565,7 @@
 
 	g_return_if_fail(passport != NULL);
 
-	purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, type);
+	purple_debug_info("MSNP14","Passport: %s, type: %d\n", passport, networkId);
 	tokens = g_strsplit(passport, "@", 2);
 	email = tokens[0];
 	domain = tokens[1];
@@ -603,12 +603,12 @@
 	g_snprintf(fmt_str, sizeof(fmt_str), "%d", list_op);
 	xmlnode_set_attrib(c_node, "l", fmt_str);
 
-	if (type != MSN_USER_TYPE_UNKNOWN)
-		g_snprintf(fmt_str, sizeof(fmt_str), "%d", type);
+	if (networkId != MSN_NETWORK_UNKNOWN)
+		g_snprintf(fmt_str, sizeof(fmt_str), "%d", networkId);
 	else if (msn_user_is_yahoo(session->account, passport))
-		g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_USER_TYPE_YAHOO);
+		g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_NETWORK_YAHOO);
 	else
-		g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_USER_TYPE_PASSPORT);
+		g_snprintf(fmt_str, sizeof(fmt_str), "%d", MSN_NETWORK_PASSPORT);
 
 	/*mobile*/
 	//type_str = g_strdup_printf("4");
@@ -654,7 +654,7 @@
 			continue;
 
 		msn_add_contact_xml(session, adl_node, user->passport,
-			user->list_op & MSN_LIST_OP_MASK, user->type);
+			user->list_op & MSN_LIST_OP_MASK, user->networkid);
 
 		/* each ADL command may contain up to 150 contacts */
 		if (++adl_count % 150 == 0 || l->next == NULL) {
@@ -1019,7 +1019,7 @@
 	MsnUser *user;
 	MsnObject *msnobj;
 	unsigned long clientid;
-	int wlmclient;
+	int networkid;
 	const char *state, *passport, *friendly;
 
 	session = cmdproc->session;
@@ -1029,7 +1029,7 @@
 	state    = cmd->params[1];
 	passport = cmd->params[2];
 	/*if a contact is actually on the WLM part or the yahoo part*/
-	wlmclient = atoi(cmd->params[3]);
+	networkid = atoi(cmd->params[3]);
 	friendly = purple_url_decode(cmd->params[4]);
 
 	user = msn_userlist_find_user(session->userlist, passport);
@@ -1046,6 +1046,8 @@
 
 	clientid = strtoul(cmd->params[5], NULL, 10);
 	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+');
+	msn_user_set_clientid(user, clientid);
+	msn_user_set_network(user, networkid);
 
 	msn_user_set_state(user, state);
 	msn_user_update(user);
@@ -1127,7 +1129,7 @@
 	MsnUser *user;
 	MsnObject *msnobj;
 	unsigned long clientid;
-	int wlmclient;
+	int networkid;
 	const char *state, *passport, *friendly, *old_friendly;
 
 	session = cmdproc->session;
@@ -1136,7 +1138,7 @@
 
 	state    = cmd->params[0];
 	passport = cmd->params[1];
-	wlmclient = atoi(cmd->params[2]);
+	networkid = atoi(cmd->params[2]);
 	friendly = purple_url_decode(cmd->params[3]);
 
 	user = msn_userlist_find_user(session->userlist, passport);
@@ -1164,6 +1166,9 @@
 	clientid = strtoul(cmd->params[4], NULL, 10);
 	user->mobile = (clientid & MSN_CLIENT_CAP_MSNMOBILE) || (user->phone.mobile && user->phone.mobile[0] == '+');
 
+	msn_user_set_clientid(user, clientid);
+	msn_user_set_network(user, networkid);
+
 	msn_user_set_state(user, state);
 	msn_user_update(user);
 }
@@ -2038,7 +2043,7 @@
 	adl_node->child = NULL;
 
 	msn_add_contact_xml(notification->session, adl_node, who, list_op,
-						MSN_USER_TYPE_PASSPORT);
+						MSN_NETWORK_PASSPORT);
 
 	payload = xmlnode_to_str(adl_node,&payload_len);
 	xmlnode_free(adl_node);
@@ -2064,7 +2069,7 @@
 	rml_node = xmlnode_new("ml");
 	rml_node->child = NULL;
 
-	msn_add_contact_xml(notification->session, rml_node, who, list_op, MSN_USER_TYPE_PASSPORT);
+	msn_add_contact_xml(notification->session, rml_node, who, list_op, MSN_NETWORK_PASSPORT);
 
 	payload = xmlnode_to_str(rml_node, &payload_len);
 	xmlnode_free(rml_node);
--- a/libpurple/protocols/msn/user.c	Sun Jun 15 06:55:21 2008 +0000
+++ b/libpurple/protocols/msn/user.c	Sun Jun 15 08:08:22 2008 +0000
@@ -198,14 +198,6 @@
 }
 
 void
-msn_user_set_type(MsnUser *user, MsnUserType type)
-{
-	g_return_if_fail(user != NULL);
-
-	user->type = type;
-}
-
-void
 msn_user_set_op(MsnUser *user, int list_op)
 {
 	g_return_if_fail(user != NULL);
@@ -308,7 +300,7 @@
 
 	if ((session != NULL) && (user = msn_userlist_find_user(session->userlist, name)) != NULL)
 	{
-		return (user->type == MSN_USER_TYPE_YAHOO);
+		return (user->networkid == MSN_NETWORK_YAHOO);
 	}
 	return (strstr(name,"@yahoo.") != NULL);
 }
@@ -358,6 +350,22 @@
 }
 
 void
+msn_user_set_clientid(MsnUser *user, guint clientid)
+{
+	g_return_if_fail(user != NULL);
+
+	user->clientid = clientid;
+}
+
+void
+msn_user_set_network(MsnUser *user, MsnNetwork network)
+{
+	g_return_if_fail(user != NULL);
+
+	user->networkid = network;
+}
+
+void
 msn_user_set_object(MsnUser *user, MsnObject *obj)
 {
 	g_return_if_fail(user != NULL);
@@ -423,6 +431,14 @@
 	return user->phone.mobile;
 }
 
+guint
+msn_user_get_clientid(const MsnUser *user)
+{
+	g_return_val_if_fail(user != NULL, 0);
+
+	return user->clientid;
+}
+
 MsnObject *
 msn_user_get_object(const MsnUser *user)
 {
--- a/libpurple/protocols/msn/user.h	Sun Jun 15 06:55:21 2008 +0000
+++ b/libpurple/protocols/msn/user.h	Sun Jun 15 08:08:22 2008 +0000
@@ -33,14 +33,14 @@
 
 typedef enum
 {
-	MSN_USER_TYPE_UNKNOWN  = 0x00,
-	MSN_USER_TYPE_PASSPORT = 0x01,
-	MSN_USER_TYPE_UNKNOWN1 = 0x02,
-	MSN_USER_TYPE_MOBILE   = 0x04,
-	MSN_USER_TYPE_UNKNOWN2 = 0x08,
-	MSN_USER_TYPE_UNKNOWN3 = 0x10,
-	MSN_USER_TYPE_YAHOO    = 0x20
-} MsnUserType;
+	MSN_NETWORK_UNKNOWN      = 0x00,
+	MSN_NETWORK_PASSPORT     = 0x01,
+	MSN_NETWORK_COMMUNICATOR = 0x02,
+	MSN_NETWORK_MOBILE       = 0x04,
+	MSN_NETWORK_MNI          = 0x08,
+	MSN_NETWORK_SMTP         = 0x10,
+	MSN_NETWORK_YAHOO        = 0x20
+} MsnNetwork;
 
 /**
  * Current media.
@@ -87,7 +87,9 @@
 
 	GHashTable *clientcaps; /**< The client's capabilities.     */
 
-	MsnUserType type;       /**< The user type                  */
+	guint clientid;         /**< The client's ID                */
+
+	MsnNetwork networkid;   /**< The user's network             */
 
 	int list_op;            /**< Which lists the user is in     */
 
@@ -218,7 +220,22 @@
 void msn_user_set_work_phone(MsnUser *user, const char *number);
 
 void msn_user_set_uid(MsnUser *user, const char *uid);
-void msn_user_set_type(MsnUser *user, MsnUserType type);
+
+/**
+ * Sets the client id for a user.
+ *
+ * @param user     The user.
+ * @param clientid The client id.
+ */
+void msn_user_set_clientid(MsnUser *user, guint clientid);
+
+/**
+ * Sets the network id for a user.
+ *
+ * @param user    The user.
+ * @param network The network id.
+ */
+void msn_user_set_network(MsnUser *user, MsnNetwork network);
 
 /**
  * Sets the mobile phone number for a user.
@@ -291,6 +308,24 @@
 const char *msn_user_get_mobile_phone(const MsnUser *user);
 
 /**
+ * Returns the client id for a user.
+ *
+ * @param user    The user.
+ *
+ * @return The user's client id.
+ */
+guint msn_user_get_clientid(const MsnUser *user);
+
+/**
+ * Returns the network id for a user.
+ *
+ * @param user    The user.
+ *
+ * @return The user's network id.
+ */
+MsnNetwork msn_user_get_network(const MsnUser *user);
+
+/**
  * Returns the MSNObject for a user.
  *
  * @param user The user.