changeset 19740:23258253c7a0

[gaim-migrate @ 16546] can login sucessfully Other's can see the online status Can chat with gaim. Some bug exist! will crash Some Problem existed on group management committed by MaYuan<mayuan2006@gmail.com> committer: Ethan Blanton <elb@pidgin.im>
author Ma Yuan <mayuan2006@gmail.com>
date Sun, 23 Jul 2006 09:19:12 +0000
parents 852b32710df0
children b99512bd6d85
files src/protocols/msn/cmdproc.c src/protocols/msn/command.c src/protocols/msn/contact.c src/protocols/msn/group.h src/protocols/msn/msn.c src/protocols/msn/msn.h src/protocols/msn/nexus.c src/protocols/msn/notification.c src/protocols/msn/notification.h src/protocols/msn/session.c src/protocols/msn/session.h src/protocols/msn/state.c src/protocols/msn/state.h src/protocols/msn/userlist.c
diffstat 14 files changed, 239 insertions(+), 123 deletions(-) [+]
line wrap: on
line diff
--- a/src/protocols/msn/cmdproc.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/cmdproc.c	Sun Jul 23 09:19:12 2006 +0000
@@ -89,8 +89,7 @@
 
 	tmp = (incoming) ? 'S' : 'C';
 
-	if ((show[len - 1] == '\n') && (show[len - 2] == '\r'))
-	{
+	if ((show[len - 1] == '\n') && (show[len - 2] == '\r')){
 		show[len - 2] = '\0';
 	}
 
@@ -134,7 +133,7 @@
 	}
 
 	msn_servconn_write(servconn, data, len);
-	gaim_debug_info("<<","%s",data);
+	gaim_debug_info("<<","%s\n",data);
 
 	g_free(data);
 }
--- a/src/protocols/msn/command.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/command.c	Sun Jul 23 09:19:12 2006 +0000
@@ -46,6 +46,7 @@
 {
 	if( (!strcmp(str,"ADL")) ||
 		(!strcmp(str,"GCF")) ||
+		(!strcmp(str,"SG")) ||
 		(!strcmp(str,"MSG")) ||
 		(!strcmp(str,"RML")) ||
 		(!strcmp(str,"UBX")) ||
@@ -62,11 +63,13 @@
 int msn_get_payload_position(char *str)
 {
 	/*because MSG has "MSG hotmail hotmail [payload length]"*/
-	if(!(strcmp(str,"MSG"))){
+	if(!(strcmp(str,"MSG"))|| (!strcmp(str,"UBX")) ){
 		return 2;
 	}
+
 	return 1;
 }
+
 /*
  * set command Payload length
  */
@@ -76,11 +79,14 @@
 	char * param;
 
 	if(msn_check_payload_cmd(cmd->command)){
+		param = cmd->params[msn_get_payload_position(cmd->command)];
+#if 0
 		if(!(strcmp(cmd->command,"MSG"))){
 			param = cmd->params[2];
 		}else{
 			param = cmd->params[1];
 		}
+#endif
 		cmd->payload_len = is_num(param) ? atoi(param) : 0;
 	}else{
 		cmd->payload_len = 0;
--- a/src/protocols/msn/contact.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/contact.c	Sun Jul 23 09:19:12 2006 +0000
@@ -90,10 +90,8 @@
 		return MSN_LIST_AL_OP;
 	}else if(!strcmp(role,"Block")){
 		return MSN_LIST_BL_OP;
-	}else if(!strcmp(role,"Reverse")){
-		return MSN_LIST_RL_OP;
-	}else if(!strcmp(role,"Forward")){
-		return MSN_LIST_FL_OP;
+//	}else if(!strcmp(role,"Reverse")){
+//		return MSN_LIST_RL_OP;
 	}
 	return 0;
 }
@@ -120,7 +118,7 @@
 	xmlnode *membershipnode,*members,*member,*passportNode,*role;
 
 	session = contact->session;
-	gaim_debug_misc("xml","parse contact list:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len);
+//	gaim_debug_misc("xml","parse contact list:{%s}\nsize:%d\n",contact->soapconn->body,contact->soapconn->body_len);
 	node = 	xmlnode_from_str(contact->soapconn->body, contact->soapconn->body_len);
 //	node = 	xmlnode_from_str(contact->soapconn->body, -1);
 
@@ -144,22 +142,33 @@
 	for(membershipnode = xmlnode_get_child(memberships, "Membership"); membershipnode;
 					membershipnode = xmlnode_get_next_twin(membershipnode)){
 		role = xmlnode_get_child(membershipnode,"MemberRole");
-	//	gaim_debug_misc("memberrole","role:%s\n",xmlnode_get_data(role));
 		list_op = msn_get_memberrole(xmlnode_get_data(role));
 		gaim_debug_misc("memberrole","role:%s,list_op:%d\n",xmlnode_get_data(role),list_op);
 		members = xmlnode_get_child(membershipnode,"Members");
 		for(member = xmlnode_get_child(members, "Member"); member;
 				member = xmlnode_get_next_twin(member)){
-			passportNode = xmlnode_get_child(member,"PassportName");
-			passport = xmlnode_get_data(passportNode);
-			gaim_debug_misc("Passport","name:%s\n",passport);
-			user = msn_userlist_find_user(session->userlist, passport);
-			if (user == NULL){
-				user = msn_user_new(session->userlist, passport, "");
-				msn_userlist_add_user(session->userlist, user);
+			xmlnode * typeNode;
+			char * type;
+
+			gaim_debug_misc("MaYuan","type:%s\n",xmlnode_get_attrib(member,"type"));
+			if(!g_strcasecmp(xmlnode_get_attrib(member,"type"),"PassportMember")){
+				passportNode = xmlnode_get_child(member,"PassportName");
+				passport = xmlnode_get_data(passportNode);
+				typeNode = xmlnode_get_child(member,"Type");
+				type = xmlnode_get_data(typeNode);
+				gaim_debug_misc("Passport","name:%s,type:%s\n",passport,type);
+				user = msn_userlist_find_user(session->userlist, passport);
+				if (user == NULL){
+					user = msn_user_new(session->userlist, passport, "");
+					msn_userlist_add_user(session->userlist, user);
+				}
+//				user->list_op |= list_op;
+				msn_got_lst_user(session, user, list_op, NULL);
 			}
-//			user->list_op |= list_op;
-			msn_got_lst_user(session, user, list_op, NULL);
+			if(!g_strcasecmp(xmlnode_get_attrib(member,"type"),"PhoneMember")){
+			}
+			if(!g_strcasecmp(xmlnode_get_attrib(member,"type"),"EmailMember")){
+			}
 		}
 	}
 
@@ -255,7 +264,15 @@
 	for(contactNode = xmlnode_get_child(contacts, "Contact"); contactNode;
 				contactNode = xmlnode_get_next_twin(contactNode)){
 		MsnUser *user;
+		xmlnode *messengerEnableNode;
 		char *passport,*Name,*uid,*type;
+		char *messengerEnable;
+
+		messengerEnableNode = xmlnode_get_child(contactNode,"isMessengerEnabled");
+		messengerEnable = xmlnode_get_data(messengerEnableNode);
+		if(!g_strcasecmp(messengerEnable,"false")){
+			continue;
+		}
 
 		contactId= xmlnode_get_child(contactNode,"contactId");
 		uid = xmlnode_get_data(contactId);
@@ -265,6 +282,10 @@
 		type = xmlnode_get_data(contactType);
 
 		passportName = xmlnode_get_child(contactInfo,"passportName");
+		if(passportName == NULL){
+			/*TODO: add it to the none-instant Messenger group and recognize as email Membership*/
+			continue;
+		}
 		passport = xmlnode_get_data(passportName);
 
 		displayName = xmlnode_get_child(contactInfo,"displayName");
@@ -282,19 +303,40 @@
 		}
 		msn_user_set_uid(user,uid);
 		msn_user_set_type(user,msn_get_user_type(type));
+		user->list_op |= 1;
 
 		groupIds = xmlnode_get_child(contactInfo,"groupIds");
 		if(groupIds){
 			for(guid = xmlnode_get_child(groupIds, "guid");guid;
 							guid = xmlnode_get_next_twin(guid)){
-				char * group_id;
+				char *group_id;
 
 				group_id = xmlnode_get_data(guid);
 				msn_user_add_group_id(user,group_id);
 				gaim_debug_misc("contact","guid:%s\n",group_id);
 			}
 		}else{
+			char *name,*group_id;
+
+			name = g_strdup(MSN_INDIVIDUALS_GROUP_NAME);
+			group_id = g_strdup(MSN_INDIVIDUALS_GROUP_ID);
+
+			msn_user_add_group_id(user,group_id);
+			msn_group_new(session->userlist, group_id, name);
+
+			if (group_id == NULL)
+					/* Group of ungroupped buddies */
+					continue;
+
+			if ((gaim_find_group(name)) == NULL){
+					GaimGroup *g = gaim_group_new(name);
+					gaim_blist_add_group(g, NULL);
+			}
+
 			gaim_debug_misc("contact","guid is NULL\n");
+			g_free(name);
+			g_free(group_id);
+
 		}
 	}
 
@@ -304,6 +346,7 @@
 	msn_soap_free_read_buf(contact->soapconn);
 
 	dump_adl_cmd(session);
+	msn_set_psm(session);
 	msn_session_finish_login(session);
 }
 
--- a/src/protocols/msn/group.h	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/group.h	Sun Jul 23 09:19:12 2006 +0000
@@ -40,6 +40,9 @@
 #define MSN_GROUP_IDS	"<guid>9e57e654-59f0-44d1-aedc-0a7500b7e51f</guid>"
 #define MSN_DELETE_GROUP_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\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"><soap:Header><ABApplicationHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ApplicationId>09607671-1C32-421F-A6A6-CBFAA51AB5F4</ApplicationId><IsMigration>false</IsMigration><PartnerScenario>Timer</PartnerScenario></ABApplicationHeader><ABAuthHeader xmlns=\"http://www.msn.com/webservices/AddressBook\"><ManagedGroupRequest>false</ManagedGroupRequest></ABAuthHeader></soap:Header><soap:Body><ABGroupDelete xmlns=\"http://www.msn.com/webservices/AddressBook\"><abId>00000000-0000-0000-0000-000000000000</abId><groupFilter><groupIds>%s</groupIds></groupFilter></ABGroupDelete></soap:Body></soap:Envelope>"
 
+#define MSN_INDIVIDUALS_GROUP_ID	"0"
+#define MSN_INDIVIDUALS_GROUP_NAME	"Other Contacts"
+
 /**
  * A group.
  */
--- a/src/protocols/msn/msn.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/msn.c	Sun Jul 23 09:19:12 2006 +0000
@@ -1116,12 +1116,9 @@
 	cmdproc = session->notification->cmdproc;
 
 	if (account->perm_deny == GAIM_PRIVACY_ALLOW_ALL ||
-		account->perm_deny == GAIM_PRIVACY_DENY_USERS)
-	{
+		account->perm_deny == GAIM_PRIVACY_DENY_USERS){
 		msn_cmdproc_send(cmdproc, "BLP", "%s", "AL");
-	}
-	else
-	{
+	}else{
 		msn_cmdproc_send(cmdproc, "BLP", "%s", "BL");
 	}
 }
@@ -1261,7 +1258,7 @@
 {
 	MsnSession *session;
 	MsnCmdProc *cmdproc;
-	int old_gid;
+	const char *old_gid;
 	const char *enc_new_group_name;
 
 	session = gc->proto_data;
@@ -1270,13 +1267,12 @@
 
 	old_gid = msn_userlist_find_group_id(session->userlist, old_name);
 
-	if (old_gid >= 0)
-	{
+	if (old_gid != NULL){
+		/*find a Group*/
 		msn_cmdproc_send(cmdproc, "REG", "%d %s 0", old_gid,
 						 enc_new_group_name);
-	}
-	else
-	{
+	}else{
+		/*not found*/
 		msn_cmdproc_send(cmdproc, "ADG", "%s 0", enc_new_group_name);
 	}
 }
@@ -1332,13 +1328,13 @@
 {
 	MsnSession *session;
 	MsnCmdProc *cmdproc;
-	int group_id;
+	const char *group_id;
 
 	session = gc->proto_data;
 	cmdproc = session->notification->cmdproc;
 
-	if ((group_id = msn_userlist_find_group_id(session->userlist, group->name)) >= 0)
-	{
+	group_id = msn_userlist_find_group_id(session->userlist, group->name);
+	if (group_id != NULL){
 		msn_cmdproc_send(cmdproc, "RMG", "%d", group_id);
 	}
 }
@@ -1354,20 +1350,17 @@
 	b = gaim_find_buddy(gaim_connection_get_account(info_data->gc),
 						info_data->name);
 
-	if (b)
-	{
+	if (b){
 		GString *str = g_string_new("");
 		char *tmp;
 
-		if (b->alias && b->alias[0])
-		{
+		if (b->alias && b->alias[0]){
 			char *aliastext = g_markup_escape_text(b->alias, -1);
 			g_string_append_printf(s, _("<b>Alias:</b> %s<br>"), aliastext);
 			g_free(aliastext);
 		}
 
-		if (b->server_alias)
-		{
+		if (b->server_alias){
 			char *nicktext = g_markup_escape_text(b->server_alias, -1);
 			g_string_append_printf(s, _("<b>%s:</b> "), _("Nickname"));
 			g_string_append_printf(s, "<font sml=\"msn\">%s</font><br>",
@@ -1976,7 +1969,7 @@
 	msn_add_deny,			/* add_deny */
 	msn_rem_permit,			/* rem_permit */
 	msn_rem_deny,			/* rem_deny */
-	msn_set_permit_deny,		/* set_permit_deny */
+	msn_set_permit_deny,	/* set_permit_deny */
 	NULL,					/* join_chat */
 	NULL,					/* reject chat invite */
 	NULL,					/* get_chat_name */
--- a/src/protocols/msn/msn.h	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/msn.h	Sun Jul 23 09:19:12 2006 +0000
@@ -66,6 +66,9 @@
 #define WLM_SERVER			"muser.messenger.hotmail.com"
 #define WLM_PORT			1863
 #define WLM_PROT_VER		13
+/*This MSNP14 Support chat with Yahoo Messenger*/
+#define WLM_YAHOO_PROT_VER	14
+
 #define WLM_MAX_PROTOCOL	14
 #define WLM_MIN_PROTOCOL	13
 
--- a/src/protocols/msn/nexus.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/nexus.c	Sun Jul 23 09:19:12 2006 +0000
@@ -90,7 +90,7 @@
 	session = nexus->session;
 	g_return_if_fail(session != NULL);
 
-	gaim_debug_misc("msn", "TWN Server Reply: {%s}\n", soapconn->read_buf);
+//	gaim_debug_misc("msn", "TWN Server Reply: {%s}\n", soapconn->read_buf);
 
 	if (strstr(soapconn->read_buf, "HTTP/1.1 302") != NULL){
 		/* Redirect. */
@@ -263,7 +263,7 @@
 					soapconn->login_path,soapconn->login_host,strlen(tail));
 
 	request_str = g_strdup_printf("%s%s", head,tail);
-	gaim_debug_misc("msn", "TWN Sending: {%s}\n", request_str);
+//	gaim_debug_misc("msn", "TWN Sending: {%s}\n", request_str);
 
 	g_free(head);
 	g_free(tail);
--- a/src/protocols/msn/notification.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/notification.c	Sun Jul 23 09:19:12 2006 +0000
@@ -113,10 +113,11 @@
 
 	vers = g_strjoinv(" ", a);
 
-	if (session->login_step == MSN_LOGIN_STEP_START)
+	if (session->login_step == MSN_LOGIN_STEP_START){
 		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE);
-	else
+	}else{
 		msn_session_set_login_step(session, MSN_LOGIN_STEP_HANDSHAKE2);
+	}
 
 	msn_cmdproc_send(cmdproc, "VER", "%s", vers);
 
@@ -244,10 +245,13 @@
 		elems = g_strsplit(cmd->params[3], ",", 0);
 
 		for (cur = elems; *cur != NULL; cur++){
-				tokens = g_strsplit(*cur, "=", 2);
+			tokens = g_strsplit(*cur, "=", 2);
+//			gaim_debug_info("MaYuan","challenge %p,key:%s,value:%s\n",
+//								session->nexus->challenge_data,tokens[0],tokens[1]);
+			if(tokens[0]&&tokens[1])
 				g_hash_table_insert(session->nexus->challenge_data, tokens[0], tokens[1]);
-				/* Don't free each of the tokens, only the array. */
-				g_free(tokens);
+			/* Don't free each of the tokens, only the array. */
+			g_free(tokens);
 		}
 
 		g_strfreev(elems);
@@ -296,9 +300,9 @@
 
 	g_snprintf(proto_str, sizeof(proto_str), "MSNP%d", session->protocol_ver);
 
-	for (i = 1; i < cmd->param_count; i++){
-//		gaim_debug_info("MaYuan","%s\,proto_str:%s\n",cmd->params[i],proto_str);
-		if (!strcmp(cmd->params[i], proto_str))	{
+	for (i = 1; i < cmd->param_count -1; i++){
+		gaim_debug_info("MaYuan","%s\,proto_str:%s\n",cmd->params[i],proto_str);
+		if (strcmp(cmd->params[i], proto_str) >= 0)	{
 			protocol_supported = TRUE;
 			break;
 		}
@@ -313,6 +317,8 @@
 	/*
 	 * Windows Live Messenger 8.0 
 	 * Notice :CVR String discriminate!
+	 * reference of http://www.microsoft.com/globaldev/reference/oslocversion.mspx
+	 * to see the Local ID
 	 */
 	msn_cmdproc_send(cmdproc, "CVR",
 //					 "0x0409 winnt 5.1 i386 MSG80BETA 8.0.0689 msmsgs %s",
@@ -416,7 +422,7 @@
 #else
 	msn_handle_chl(cmd->params[1], buf);
 #endif
-	gaim_debug_info("MaYuan","<<challenge:{%s}:{%s}\n",cmd->params[1],buf);
+//	gaim_debug_info("MaYuan","<<challenge:{%s}:{%s}\n",cmd->params[1],buf);
 	trans = msn_transaction_new(cmdproc, "QRY", "%s 32", MSNP13_WLM_PRODUCT_ID);
 
 	msn_transaction_set_payload(trans, buf, 32);
@@ -438,7 +444,7 @@
 	xmlnode *adl_node,*d_node,*c_node;
 	char **tokens;
 	char *email,*domain;
-	char * payload,*attr;
+	char *payload;
 	char *list_op,*type;
 	int payload_len;
 
@@ -459,6 +465,7 @@
 
 		/*find a domain node*/
 		for(d_node = xmlnode_get_child(adl_node,"d"); d_node; d_node = xmlnode_get_next_twin(d_node)){
+			const char * attr = NULL;
 			gaim_debug_info("MaYuan","d_node:%s\n",d_node->name);
 			attr = xmlnode_get_attrib(d_node,"n");
 			if(attr == NULL){
@@ -482,11 +489,12 @@
 		list_op = g_strdup_printf("%d",user->list_op);
 		gaim_debug_info("MaYuan","list_op:%d\n",user->list_op);
 		xmlnode_set_attrib(c_node,"l",list_op);
-#if 1
+#if 0
 		type = g_strdup_printf("%d",user->type);
 		xmlnode_set_attrib(c_node,"t",type);
 #else
-		xmlnode_set_attrib(c_node,"t","1");
+		type = g_strdup_printf("1");
+		xmlnode_set_attrib(c_node,"t",type);
 #endif
 		xmlnode_insert_child(d_node, c_node);
 
@@ -494,7 +502,7 @@
 		g_free(type);
 	}
 
-	payload = xmlnode_to_str(adl_node,payload_len);
+	payload = xmlnode_to_str(adl_node,&payload_len);
 
 	gaim_debug_info("MaYuan","ADL{%s}\n",payload);
 	trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload));
@@ -505,9 +513,15 @@
 }
 
 static void
+blp_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
+{
+	gaim_debug_info("MaYuan","Process BLP\n");
+}
+
+static void
 adl_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
 {
-	
+	gaim_debug_info("MaYuan","Process ADL\n");
 }
 
 static void
@@ -766,8 +780,7 @@
 
 	if (session->protocol_ver >= 9){
 		if (cmd->param_count == 5){
-			msnobj =
-				msn_object_new_from_string(gaim_url_decode(cmd->params[4]));
+			msnobj = msn_object_new_from_string(gaim_url_decode(cmd->params[4]));
 			msn_user_set_object(user, msnobj);
 		}else{
 			msn_user_set_object(user, NULL);
@@ -1203,6 +1216,7 @@
 		return;
 	}
 	/*get the payload content*/
+	gaim_debug_info("MaYuan","GCF{%s}\n",cmd->payload);
 }
 
 static void
@@ -1215,6 +1229,18 @@
 	/*get the payload content*/
 }
 
+static void
+ubx_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
+{
+	gaim_debug_info("MaYuan","UBX... \n");
+}
+
+static void
+uux_cmd(MsnCmdProc *cmdproc, MsnCommand *cmd)
+{
+	gaim_debug_info("MaYuan","UUX... \n");
+}
+
 /**************************************************************************
  * Message Types
  **************************************************************************/
@@ -1438,38 +1464,31 @@
 void
 msn_notification_add_buddy(MsnNotification *notification, const char *list,
 						   const char *who, const char *store_name,
-						   int group_id)
+						   const char *group_id)
 {
 	MsnCmdProc *cmdproc;
 	cmdproc = notification->servconn->cmdproc;
 
-	if (group_id < 0 && !strcmp(list, "FL"))
-		group_id = 0;
+	if (group_id != NULL && !strcmp(list, "FL"))
 
-	if (group_id >= 0)
-	{
+	if (group_id >= 0){
 		msn_cmdproc_send(cmdproc, "ADD", "%s %s %s %d",
 						 list, who, store_name, group_id);
-	}
-	else
-	{
+	}else{
 		msn_cmdproc_send(cmdproc, "ADD", "%s %s %s", list, who, store_name);
 	}
 }
 
 void
 msn_notification_rem_buddy(MsnNotification *notification, const char *list,
-						   const char *who, int group_id)
+						   const char *who, const char *group_id)
 {
 	MsnCmdProc *cmdproc;
 	cmdproc = notification->servconn->cmdproc;
 
-	if (group_id >= 0)
-	{
+	if (group_id != NULL){
 		msn_cmdproc_send(cmdproc, "REM", "%s %s %d", list, who, group_id);
-	}
-	else
-	{
+	}else{
 		msn_cmdproc_send(cmdproc, "REM", "%s %s", list, who);
 	}
 }
@@ -1489,7 +1508,7 @@
 	msn_table_add_cmd(cbs_table, "CHG", "CHG", NULL);
 	msn_table_add_cmd(cbs_table, "CHG", "ILN", iln_cmd);
 	msn_table_add_cmd(cbs_table, "ADD", "ADD", add_cmd);
-	msn_table_add_cmd(cbs_table, "ADD", "ILN", iln_cmd);
+	msn_table_add_cmd(cbs_table, "ADL", "ILN", iln_cmd);
 	msn_table_add_cmd(cbs_table, "REM", "REM", rem_cmd);
 	msn_table_add_cmd(cbs_table, "USR", "USR", usr_cmd);
 	msn_table_add_cmd(cbs_table, "USR", "XFR", xfr_cmd);
@@ -1499,8 +1518,8 @@
 	msn_table_add_cmd(cbs_table, "VER", "VER", ver_cmd);
 	msn_table_add_cmd(cbs_table, "REA", "REA", rea_cmd);
 	msn_table_add_cmd(cbs_table, "PRP", "PRP", prp_cmd);
-	/* msn_table_add_cmd(cbs_table, "BLP", "BLP", blp_cmd); */
-	msn_table_add_cmd(cbs_table, "BLP", "BLP", NULL);
+	msn_table_add_cmd(cbs_table, "BLP", "BLP", blp_cmd);
+//	msn_table_add_cmd(cbs_table, "BLP", "BLP", NULL);
 	msn_table_add_cmd(cbs_table, "REG", "REG", reg_cmd);
 	msn_table_add_cmd(cbs_table, "ADG", "ADG", adg_cmd);
 	msn_table_add_cmd(cbs_table, "RMG", "RMG", rmg_cmd);
@@ -1515,7 +1534,7 @@
 
 	msn_table_add_cmd(cbs_table, NULL, "CHL", chl_cmd);
 	msn_table_add_cmd(cbs_table, NULL, "REM", rem_cmd);
-	msn_table_add_cmd(cbs_table, NULL, "ADD", add_cmd);
+	msn_table_add_cmd(cbs_table, NULL, "ADL", adl_cmd);
 
 	msn_table_add_cmd(cbs_table, NULL, "QRY", NULL);
 	msn_table_add_cmd(cbs_table, NULL, "QNG", NULL);
@@ -1525,6 +1544,9 @@
 	msn_table_add_cmd(cbs_table, NULL, "OUT", out_cmd);
 	msn_table_add_cmd(cbs_table, NULL, "RNG", rng_cmd);
 
+	msn_table_add_cmd(cbs_table, NULL, "UBX", ubx_cmd);
+	msn_table_add_cmd(cbs_table, NULL, "UUX", uux_cmd);
+
 	msn_table_add_cmd(cbs_table, NULL, "URL", url_cmd);
 
 	msn_table_add_cmd(cbs_table, "fallback", "XFR", xfr_cmd);
--- a/src/protocols/msn/notification.h	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/notification.h	Sun Jul 23 09:19:12 2006 +0000
@@ -54,10 +54,10 @@
 
 void msn_notification_add_buddy(MsnNotification *notification,
 								const char *list, const char *who,
-								const char *store_name, int group_id);
+								const char *store_name, const char *group_id);
 void msn_notification_rem_buddy(MsnNotification *notification,
 								const char *list, const char *who,
-								int group_id);
+								const char *group_id);
 MsnNotification *msn_notification_new(MsnSession *session);
 void msn_notification_destroy(MsnNotification *notification);
 gboolean msn_notification_connect(MsnNotification *notification,
--- a/src/protocols/msn/session.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/session.c	Sun Jul 23 09:19:12 2006 +0000
@@ -43,6 +43,8 @@
 	session->user = msn_user_new(session->userlist,
 								 gaim_account_get_username(account), NULL);
 
+	/*if you want to chat with Yahoo Messenger*/
+	//session->protocol_ver = WLM_YAHOO_PROT_VER;
 	session->protocol_ver = WLM_PROT_VER;
 	session->conv_seq = 1;
 
@@ -250,22 +252,22 @@
 					MsnUser *remote_user;
 					gboolean found = FALSE;
 
+					gaim_debug_info("MaYuan","buddy name:%s,group name:%s\n",b->name,group_name);
 					remote_user = msn_userlist_find_user(session->userlist, b->name);
 
 					if ((remote_user != NULL) && (remote_user->list_op & MSN_LIST_FL_OP)){
-						int group_id;
+						char *group_id;
 						GList *l;
 
 						group_id = msn_userlist_find_group_id(remote_user->userlist,
 								group_name);
 
 						for (l = remote_user->group_ids; l != NULL; l = l->next){
-							if (group_id == GPOINTER_TO_INT(l->data)){
+							if (!g_strcasecmp(group_id ,l->data)){
 								found = TRUE;
 								break;
 							}
 						}
-
 					}
 
 					if (!found){
--- a/src/protocols/msn/session.h	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/session.h	Sun Jul 23 09:19:12 2006 +0000
@@ -107,6 +107,9 @@
 
 	int conv_seq; /**< The current conversation sequence number. */
 
+	/*psm info*/
+	char *psm;
+
 	struct
 	{
 		/*t and p, get via USR TWN*/
--- a/src/protocols/msn/state.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/state.c	Sun Jul 23 09:19:12 2006 +0000
@@ -38,6 +38,62 @@
 	N_("Available")
 };
 
+char *
+msn_build_psm(char * psmstr,char *mediastr,char * guidstr)
+{
+	xmlnode *dataNode,*psmNode,*mediaNode,*guidNode;
+	char *result;
+	int length;
+
+	dataNode = xmlnode_new("Data");
+
+	psmNode = xmlnode_new("PSM");
+	if(psmstr != NULL){
+		xmlnode_insert_data(psmNode,psmstr,strlen(psmstr));
+	}
+	xmlnode_insert_child(dataNode,psmNode);
+
+//"<CurrentMedia>\0Music\01\0{0} - {1}\0 Song Title\0Song Artist\0Song Album\0\0</CurrentMedia>\
+<CurrentMedia>\0Games\01\0Playing {0}\0Game Name\0</CurrentMedia>\
+<CurrentMedia>\0Office\01\0Office Message\0Office App Name\0</CurrentMedia>"
+
+	mediaNode = xmlnode_new("CurrentMedia");
+	if(mediastr != NULL){
+		xmlnode_insert_data(psmNode,mediastr,strlen(mediastr));
+	}
+	xmlnode_insert_child(dataNode,mediaNode);
+
+	guidNode = xmlnode_new("MachineGuid");
+	if(guidstr != NULL){
+		xmlnode_insert_data(guidNode,guidstr,strlen(guidstr));
+	}
+	xmlnode_insert_child(dataNode,guidNode);
+
+	result = xmlnode_to_str(dataNode,&length);
+	return result;
+}
+
+void
+msn_set_psm(MsnSession *session)
+{
+	MsnCmdProc *cmdproc;
+	MsnTransaction *trans;
+	char *payload;
+
+	cmdproc = session->notification->cmdproc;
+	/*prepare PSM info*/
+	if(session->psm){
+		g_free(session->psm);
+	}
+	session ->psm = g_strdup(msn_build_psm("Hello",NULL,NULL));
+	payload = session->psm;
+
+	gaim_debug_info("MaYuan","UUX{%s}\n",payload);
+	trans = msn_transaction_new(cmdproc, "UUX","%d",strlen(payload));
+	msn_transaction_set_payload(trans, payload, strlen(payload));
+	msn_cmdproc_send_trans(cmdproc, trans);
+}
+
 void
 msn_change_status(MsnSession *session)
 {
@@ -62,13 +118,10 @@
 
 	msnobj = msn_user_get_object(user);
 
-	if (msnobj == NULL)
-	{
+	if (msnobj == NULL){
 		msn_cmdproc_send(cmdproc, "CHG", "%s %d", state_text,
 						 MSN_CLIENT_ID);
-	}
-	else
-	{
+	}else{
 		char *msnobj_str;
 
 		msnobj_str = msn_object_to_string(msnobj);
--- a/src/protocols/msn/state.h	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/state.h	Sun Jul 23 09:19:12 2006 +0000
@@ -59,6 +59,8 @@
 
 const char *msn_state_get_text(MsnAwayType state);
 
+void msn_set_psm(MsnSession *session);
+
 MsnAwayType msn_state_from_account(GaimAccount *account);
 
 #endif /* _MSN_STATE_H_ */
--- a/src/protocols/msn/userlist.c	Mon Jul 17 12:22:37 2006 +0000
+++ b/src/protocols/msn/userlist.c	Sun Jul 23 09:19:12 2006 +0000
@@ -187,7 +187,7 @@
 					  const char *old_group_name, const char *new_group_name)
 {
 	MsnCmdProc *cmdproc;
-	MsnTransaction *trans;
+//	MsnTransaction *trans;
 	MsnMoveBuddy *data;
 
 	cmdproc = userlist->session->notification->cmdproc;
@@ -300,29 +300,19 @@
 
 	passport = msn_user_get_passport(user);
 
-	if (list_id == MSN_LIST_FL)
-	{
+	if (list_id == MSN_LIST_FL){
 		/* TODO: When is the user totally removed? */
-		if (group_id >= 0)
-		{
+		if (group_id != NULL){
 			msn_user_remove_group_id(user, group_id);
 			return;
-		}
-		else
-		{
+		}else{
 			/* session->sync->fl_users_count--; */
 		}
-	}
-	else if (list_id == MSN_LIST_AL)
-	{
+	}else if (list_id == MSN_LIST_AL){
 		gaim_privacy_permit_remove(account, passport, TRUE);
-	}
-	else if (list_id == MSN_LIST_BL)
-	{
+	}else if (list_id == MSN_LIST_BL){
 		gaim_privacy_deny_remove(account, passport, TRUE);
-	}
-	else if (list_id == MSN_LIST_RL)
-	{
+	}else if (list_id == MSN_LIST_RL){
 		GaimConversation *convo;
 
 		gaim_debug_info("msn",
@@ -347,11 +337,9 @@
 	user->list_op &= ~(1 << list_id);
 	/* gaim_user_remove_list_id (user, list_id); */
 
-	if (user->list_op == 0)
-	{
+	if (user->list_op == 0){
 		gaim_debug_info("msn", "Buddy '%s' shall be deleted?.\n",
 						passport);
-
 	}
 }
 
@@ -370,13 +358,11 @@
 	passport = msn_user_get_passport(user);
 	store = msn_user_get_store_name(user);
 
-	if (list_op & MSN_LIST_FL_OP)
-	{
+	if (list_op & MSN_LIST_FL_OP){
 		GSList *c;
-		for (c = group_ids; c != NULL; c = g_slist_next(c))
-		{
-			int group_id;
-			group_id = GPOINTER_TO_INT(c->data);
+		for (c = group_ids; c != NULL; c = g_slist_next(c))	{
+			char *group_id;
+			group_id = c->data;
 			msn_user_add_group_id(user, group_id);
 		}
 
@@ -485,7 +471,7 @@
 
 		g_return_val_if_fail(user->passport != NULL, NULL);
 
-		if (!strcmp(passport, user->passport))
+		if (!g_strcasecmp(passport, user->passport))
 			return user;
 	}
 
@@ -515,7 +501,7 @@
 	for (l = userlist->groups; l != NULL; l = l->next){
 		MsnGroup *group = l->data;
 
-		if (!strcmp(group->id,id))
+		if (!g_strcasecmp(group->id,id))
 			return group;
 	}
 
@@ -548,10 +534,11 @@
 
 	group = msn_userlist_find_group_with_name(userlist, group_name);
 
-	if (group != NULL)
+	if (group != NULL){
 		return msn_group_get_id(group);
-	else
+	}else{
 		return NULL;
+	}
 }
 
 const char *
@@ -599,7 +586,7 @@
 					   const char *who, int list_id, const char *group_name)
 {
 	MsnUser *user;
-	char *group_id;
+	const char *group_id;
 	const char *list;
 
 	user = msn_userlist_find_user(userlist, who);
@@ -635,11 +622,11 @@
 					   const char *group_name)
 {
 	MsnUser *user;
-	int group_id;
+	const char *group_id;
 	const char *list;
 	const char *store_name;
 
-	group_id = -1;
+	group_id = NULL;
 
 	if (!gaim_email_is_valid(who)){
 		/* only notify the user about problems adding to the friends list
@@ -658,7 +645,7 @@
 	if (group_name != NULL){
 		group_id = msn_userlist_find_group_id(userlist, group_name);
 
-		if (group_id < 0){
+		if (group_id == NULL){
 			/* Whoa, we must add that group first. */
 			msn_request_add_group(userlist, who, NULL, group_name);
 			return;
@@ -687,11 +674,11 @@
 msn_userlist_move_buddy(MsnUserList *userlist, const char *who,
 						const char *old_group_name, const char *new_group_name)
 {
-	int new_group_id;
+	const char *new_group_id;
 
 	new_group_id = msn_userlist_find_group_id(userlist, new_group_name);
 
-	if (new_group_id < 0){
+	if (new_group_id == NULL){
 		msn_request_add_group(userlist, who, old_group_name, new_group_name);
 		return;
 	}