cpw.qulogic.msnp16: f88709dd: Initial support for msnp16, based on pat...

qulogic at pidgin.im qulogic at pidgin.im
Mon Dec 14 02:29:50 EST 2009


-----------------------------------------------------------------
Revision: f88709dd4ccfa38136f3c8eb5575251494fa4aac
Ancestor: 07dc6851f4d16e9c89791c488bbc6d3b2bdb8ecf
Author: qulogic at pidgin.im
Date: 2009-12-01T22:13:30
Branch: im.pidgin.cpw.qulogic.msnp16
URL: http://d.pidgin.im/viewmtn/revision/info/f88709dd4ccfa38136f3c8eb5575251494fa4aac

Modified files:
        libpurple/protocols/msn/msn.h
        libpurple/protocols/msn/notification.c
        libpurple/protocols/msn/notification.h
        libpurple/protocols/msn/session.c
        libpurple/protocols/msn/session.h
        libpurple/protocols/msn/state.c
        libpurple/protocols/msn/switchboard.c

ChangeLog: 

Initial support for msnp16, based on patch by Masca.

References #8247.

-------------- next part --------------
============================================================
--- libpurple/protocols/msn/msn.h	7492677549e330de5d58d9dd313767941519f2ce
+++ libpurple/protocols/msn/msn.h	82c139e15f607da41aee54d6c45ac69ce592c9c6
@@ -52,9 +52,9 @@
 #define MSN_SERVER "messenger.hotmail.com"
 #define MSN_HTTPCONN_SERVER "gateway.messenger.hotmail.com"
 #define MSN_PORT 1863
-#define WLM_PROT_VER		15
+#define WLM_PROT_VER		16
 
-#define WLM_MAX_PROTOCOL	15
+#define WLM_MAX_PROTOCOL	16
 #define WLM_MIN_PROTOCOL	15
 
 #define MSN_TYPING_RECV_TIMEOUT 6
@@ -137,15 +137,14 @@ typedef enum
 
 } MsnClientVerId;
 
-#define MSN_CLIENT_ID_VERSION      MSN_CLIENT_VER_7_0
+#define MSN_CLIENT_ID_VERSION      MSN_CLIENT_VER_9_0
 #define MSN_CLIENT_ID_CAPABILITIES (MSN_CLIENT_CAP_PACKET|MSN_CLIENT_CAP_INK_GIF|MSN_CLIENT_CAP_VOICEIM)
+#define MSN_CLIENT_ID_EXT_CAPS     (0)
 
 #define MSN_CLIENT_ID \
 	((MSN_CLIENT_ID_VERSION    << 24) | \
 	 (MSN_CLIENT_ID_CAPABILITIES))
 
-#define MSN_CLIENT_EXT_ID 0
-
 gboolean msn_email_is_valid(const char *passport);
 void msn_act_id(PurpleConnection *gc, const char *entry);
 void msn_send_privacy(PurpleConnection *gc);
============================================================
--- libpurple/protocols/msn/notification.c	8cb5c39b4bf3d6b3aefeb12546c0d9905b369f6c
+++ libpurple/protocols/msn/notification.c	c6716a6eb10c255c1ddfc82e5507624e9d9b6837
@@ -161,7 +161,10 @@ msn_got_login_params(MsnSession *session
 
 	msn_session_set_login_step(session, MSN_LOGIN_STEP_AUTH_END);
 
-	msn_cmdproc_send(cmdproc, "USR", "SSO S %s %s", ticket, response);
+	if (session->protocol_ver >= 16)
+		msn_cmdproc_send(cmdproc, "USR", "SSO S %s %s %s", ticket, response, session->guid);
+	else
+		msn_cmdproc_send(cmdproc, "USR", "SSO S %s %s", ticket, response);
 }
 
 static void
@@ -1676,6 +1679,86 @@ uux_cmd(MsnCmdProc *cmdproc, MsnCommand 
 	cmd->payload_len = atoi(cmd->params[1]);
 }
 
+void
+msn_notification_send_uux(MsnSession *session, const char *payload)
+{
+	MsnTransaction *trans;
+	MsnCmdProc *cmdproc;
+	size_t len = strlen(payload);
+
+	cmdproc = session->notification->cmdproc;
+	purple_debug_misc("msn", "Sending UUX command with payload: %s\n", payload);
+	trans = msn_transaction_new(cmdproc, "UUX", "%" G_GSIZE_FORMAT, len);
+	msn_transaction_set_payload(trans, payload, len);
+	msn_cmdproc_send_trans(cmdproc, trans);
+}
+
+void msn_notification_send_uux_endpointdata(MsnSession *session)
+{
+	xmlnode *epDataNode;
+	xmlnode *capNode;
+	char *caps;
+	char *payload;
+	int length;
+
+	epDataNode = xmlnode_new("EndpointData");
+
+	capNode = xmlnode_new_child(epDataNode, "Capabilities");
+	caps = g_strdup_printf("%d:%02d", MSN_CLIENT_ID_CAPABILITIES, MSN_CLIENT_ID_EXT_CAPS);
+	xmlnode_insert_data(capNode, caps, -1);
+	g_free(caps);
+
+	payload = xmlnode_to_str(epDataNode, &length);
+
+	msn_notification_send_uux(session, payload);
+
+	xmlnode_free(epDataNode);
+	g_free(payload);
+}
+
+void msn_notification_send_uux_private_endpointdata(MsnSession *session)
+{
+	xmlnode *private;
+	xmlnode *epname;
+	xmlnode *idle;
+	xmlnode *client_type;
+	xmlnode *state;
+	char *payload;
+	int length;
+
+	private = xmlnode_new("PrivateEndPointData");
+
+	/* TODO: "Pidgin" is a temp EndPointName.. we must use hostid or some.*/
+	epname = xmlnode_new_child(private, "EpName");
+	xmlnode_insert_data(epname, "Pidgin", -1);
+
+	idle = xmlnode_new_child(private, "Idle");
+	xmlnode_insert_data(idle, "false", -1);
+
+	/* TODO: support different client types */
+	/* ClientType info (from amsn guys):
+		0: None
+		1: Computer
+		2: Website
+		3: Mobile / none
+		4: Xbox / phone /mobile
+		9: MsnGroup
+		32: Email member, currently Yahoo!
+	*/
+	client_type = xmlnode_new_child(private, "ClientType");
+	xmlnode_insert_data(client_type, "1", -1);
+
+	state = xmlnode_new_child(private, "State");
+	xmlnode_insert_data(state, msn_state_get_text(msn_state_from_account(session->account)), -1);
+
+	payload = xmlnode_to_str(private, &length);
+
+	msn_notification_send_uux(session, payload);
+
+	xmlnode_free(private);
+	g_free(payload);
+}
+
 /**************************************************************************
  * Message Types
  **************************************************************************/
============================================================
--- libpurple/protocols/msn/notification.h	efe0cdabd251a4338c91706bf251c3129e0bba70
+++ libpurple/protocols/msn/notification.h	b550588da37b9e73ba6766554ab245ee896f67a8
@@ -82,6 +82,12 @@ void msn_notification_dump_contact(MsnSe
 void msn_notification_disconnect(MsnNotification *notification);
 void msn_notification_dump_contact(MsnSession *session);
 
+void msn_notification_send_uux(MsnSession *session, const char *payload);
+
+void msn_notification_send_uux_endpointdata(MsnSession *session);
+
+void msn_notification_send_uux_private_endpointdata(MsnSession *session);
+
 /**
  * Closes a notification.
  *
============================================================
--- libpurple/protocols/msn/session.c	9c45d6773028eb5ac5adb35e17b2ed10dd9f92c6
+++ libpurple/protocols/msn/session.c	79b8c6f9e0afb00ed089b6891500ed83046ffc28
@@ -22,6 +22,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
  */
 #include "msn.h"
+#include "msnutils.h"
 #include "session.h"
 #include "notification.h"
 #include "oim.h"
@@ -47,6 +48,8 @@ msn_session_new(PurpleAccount *account)
 
 	session->protocol_ver = WLM_PROT_VER;
 
+	session->guid = rand_guid();
+
 	return session;
 }
 
@@ -90,6 +93,7 @@ msn_session_destroy(MsnSession *session)
 	msn_userlist_destroy(session->userlist);
 
 	g_free(session->psm);
+	g_free(session->guid);
 	g_free(session->abch_cachekey);
 #if 0
 	g_free(session->blocked_text);
@@ -448,6 +452,11 @@ msn_session_finish_login(MsnSession *ses
 		msn_session_sync_users(session);
 	}
 
+	if (session->protocol_ver >= 16) {
+		/* TODO: Send this when updating status instead? */
+		msn_notification_send_uux_endpointdata(session);
+		/*msn_notification_send_uux_private_endpointdata(session);*/
+	}
 	msn_change_status(session);
 }
 
============================================================
--- libpurple/protocols/msn/session.h	5589e6d7704692363db810d99c0f545997d66bc5
+++ libpurple/protocols/msn/session.h	5e36ad439f980cec43e0bada672a911021091bd1
@@ -126,6 +126,7 @@ struct _MsnSession
 
 	GHashTable *soap_table;
 	guint soap_cleanup_handle;
+	char *guid;
 };
 
 /**
============================================================
--- libpurple/protocols/msn/state.c	fafd08c40588a2ede758a1ce9521876e5fe2261c
+++ libpurple/protocols/msn/state.c	f65daa3592c8658318bb9216fb733d197446e24d
@@ -26,6 +26,7 @@
 #include "core.h"
 
 #include "msn.h"
+#include "notification.h"
 #include "state.h"
 
 static const char *away_text[] =
@@ -42,10 +43,6 @@ static const char *away_text[] =
 	N_("Available")
 };
 
-/* Local Function Prototype*/
-static char *msn_build_psm(const char *psmstr,const char *mediastr,
-						   const char *guidstr);
-
 /*
  * WLM media PSM info build prcedure
  *
@@ -55,7 +52,7 @@ static char *
  *	<CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>"
  */
 static char *
-msn_build_psm(const char *psmstr,const char *mediastr, const char *guidstr)
+msn_build_psm(const char *psmstr,const char *mediastr, const char *guidstr, guint protocol_ver)
 {
 	xmlnode *dataNode,*psmNode,*mediaNode,*guidNode;
 	char *result;
@@ -81,6 +78,12 @@ msn_build_psm(const char *psmstr,const c
 	}
 	xmlnode_insert_child(dataNode, guidNode);
 
+	if (protocol_ver >= 16) {
+		/* TODO: What is this for? */
+		xmlnode *ddpNode = xmlnode_new("DDP");
+		xmlnode_insert_child(dataNode, ddpNode);
+	}
+
 	result = xmlnode_to_str(dataNode, &length);
 	xmlnode_free(dataNode);
 	return result;
@@ -252,8 +255,6 @@ msn_set_psm(MsnSession *session)
 	PurpleAccount *account;
 	PurplePresence *presence;
 	PurpleStatus *status;
-	MsnCmdProc *cmdproc;
-	MsnTransaction *trans;
 	char *payload;
 	const char *statusline;
 	gchar *statusline_stripped, *media = NULL;
@@ -262,7 +263,6 @@ msn_set_psm(MsnSession *session)
 	g_return_if_fail(session->notification != NULL);
 
 	account = session->account;
-	cmdproc = session->notification->cmdproc;
 
 	/* Get the PSM string from Purple's Status Line */
 	presence = purple_account_get_presence(account);
@@ -273,14 +273,12 @@ msn_set_psm(MsnSession *session)
 	statusline_stripped = purple_markup_strip_html(statusline);
 	media = create_media_string(presence);
 	g_free(session->psm);
-	session->psm = msn_build_psm(statusline_stripped, media, NULL);
+	session->psm = msn_build_psm(statusline_stripped, media, session->protocol_ver >= 16 ? session->guid : NULL, session->protocol_ver);
 
 	payload = session->psm;
-	purple_debug_misc("msn", "Sending UUX command with payload: %s\n", payload);
-	trans = msn_transaction_new(cmdproc, "UUX", "%" G_GSIZE_FORMAT, strlen(payload));
-	msn_transaction_set_payload(trans, payload, strlen(payload));
-	msn_cmdproc_send_trans(cmdproc, trans);
 
+	msn_notification_send_uux(session, payload);
+
 	g_free(statusline_stripped);
 	g_free(media);
 }
@@ -327,11 +325,16 @@ msn_change_status(MsnSession *session)
 	if (!session->logged_in)
 		return;
 
+	msn_set_psm(session);
+
 	msnobj = msn_user_get_object(user);
 
 	if (msnobj == NULL)
 	{
-		msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, caps);
+		if (session->protocol_ver >= 16)
+			msn_cmdproc_send(cmdproc, "CHG", "%s %u:%02u 0", state_text, caps, MSN_CLIENT_ID_EXT_CAPS);
+		else
+			msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text, caps);
 	}
 	else
 	{
@@ -339,12 +342,15 @@ msn_change_status(MsnSession *session)
 
 		msnobj_str = msn_object_to_string(msnobj);
 
-		msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text,
-						 caps, purple_url_encode(msnobj_str));
+		if (session->protocol_ver >= 16)
+			msn_cmdproc_send(cmdproc, "CHG", "%s %u:%02u %s", state_text,
+							 caps, MSN_CLIENT_ID_EXT_CAPS, purple_url_encode(msnobj_str));
+		else
+			msn_cmdproc_send(cmdproc, "CHG", "%s %d %s", state_text,
+							 caps, purple_url_encode(msnobj_str));
 
 		g_free(msnobj_str);
 	}
-	msn_set_psm(session);
 }
 
 const char *
============================================================
--- libpurple/protocols/msn/switchboard.c	20fbf36b18d37e9079d46579a508c98a2a64d40f
+++ libpurple/protocols/msn/switchboard.c	d2682c0c6b52e4255298ac27a2d25545ddcbeb0d
@@ -949,6 +949,7 @@ connect_cb(MsnServConn *servconn)
 	MsnTransaction *trans;
 	MsnCmdProc *cmdproc;
 	PurpleAccount *account;
+	char *username;
 
 	cmdproc = servconn->cmdproc;
 	g_return_if_fail(cmdproc != NULL);
@@ -957,24 +958,33 @@ connect_cb(MsnServConn *servconn)
 	swboard = cmdproc->data;
 	g_return_if_fail(swboard != NULL);
 
+	if (servconn->session->protocol_ver >= 16)
+		username = g_strdup(purple_account_get_username(account));
+	else
+		username = g_strdup_printf("%s;{%s}",
+		                           purple_account_get_username(account),
+		                           servconn->session->guid);
+
 	if (msn_switchboard_is_invited(swboard))
 	{
 		swboard->empty = FALSE;
 
 		trans = msn_transaction_new(cmdproc, "ANS", "%s %s %s",
-									purple_account_get_username(account),
+									username,
 									swboard->auth_key, swboard->session_id);
 	}
 	else
 	{
 		trans = msn_transaction_new(cmdproc, "USR", "%s %s",
-									purple_account_get_username(account),
+									username,
 									swboard->auth_key);
 	}
 
 	msn_transaction_set_error_cb(trans, ans_usr_error);
 	msn_transaction_set_data(trans, swboard);
 	msn_cmdproc_send_trans(cmdproc, trans);
+
+	g_free(username);
 }
 
 static void


More information about the Commits mailing list