changeset 20393:40a04930b233

The second msn-p13-merge-head.diff.gz from SF Patch #162854 from Ka-Hing Cheung. "A little late, but here is a version that should remember your friendly name. Also has a fix for a crasher when MSN sends you back: <faultstring>Need to do full sync. Can't sync deltas Client has too old a copy for us to do a delta sync</faultstring> In this case, I make gaim re-request the full contact list/address book. I haven't look too deeply into the reverse list problem, but I think the solution would involve caching the reverse list, which may require extending the privacy api."
author Richard Laager <rlaager@wiktel.com>
date Sun, 15 Apr 2007 03:02:48 +0000
parents 9ba7dee775e1
children 4a099e4d0d09 bb940f08c820 6ac7e33fdabf
files libgaim/protocols/msn/contact.c libgaim/protocols/msn/contact.h libgaim/protocols/msn/msn.c libgaim/protocols/msn/msn.h libgaim/protocols/msn/notification.c libgaim/protocols/msn/soap.h
diffstat 6 files changed, 75 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
--- a/libgaim/protocols/msn/contact.c	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/contact.c	Sun Apr 15 03:02:48 2007 +0000
@@ -33,8 +33,6 @@
 /*define This to debug the Contact Server*/
 #undef  MSN_CONTACT_SOAP_DEBUG
 
-void msn_contact_connect_init(MsnSoapConn *soapconn);
-
 /*new a contact*/
 MsnContact *
 msn_contact_new(MsnSession *session)
@@ -144,6 +142,17 @@
 	body = xmlnode_get_child(node,"Body");
 	gaim_debug_misc("MSNCL","body{%p},name:%s\n",body,body->name);
 	response = xmlnode_get_child(body,"FindMembershipResponse");
+
+	if (response == NULL) {
+		/* we may get a response if our cache data is too old:
+		 *
+		 * <faultstring>Need to do full sync. Can't sync deltas Client
+		 * has too old a copy for us to do a delta sync</faultstring>
+		 */
+		msn_get_contact_list(contact, NULL);
+		return;
+	}
+
 	gaim_debug_misc("MSNCL","response{%p},name:%s\n",response,response->name);
 	result =xmlnode_get_child(response,"FindMembershipResult");
 	if(result == NULL){
@@ -263,7 +272,7 @@
 	}else{
 		update_str = g_strdup("");
 	}
-	body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE,update_str);
+	body = g_strdup_printf(MSN_GET_CONTACT_TEMPLATE, update_str);
 	soap_request = msn_soap_request_new(MSN_CONTACT_SERVER,
 					MSN_GET_CONTACT_POST_URL,MSN_GET_CONTACT_SOAP_ACTION,
 					body,
@@ -274,7 +283,7 @@
 	g_free(body);
 }
 
-static void
+static gboolean
 msn_parse_addressbook(MsnContact * contact)
 {
 	MsnSession * session;
@@ -290,17 +299,22 @@
 
 	if(node == NULL){
 		gaim_debug_misc("xml","parse from str err!\n");
-		return;
+		return FALSE;
 	}
 	gaim_debug_misc("xml","node{%p},name:%s,child:%s,last:%s\n",node,node->name,node->child->name,node->lastchild->name);
 	body = xmlnode_get_child(node,"Body");
 	gaim_debug_misc("xml","body{%p},name:%s\n",body,body->name);
 	response = xmlnode_get_child(body,"ABFindAllResponse");
+
+	if (response == NULL) {
+		return FALSE;
+	}
+
 	gaim_debug_misc("xml","response{%p},name:%s\n",response,response->name);
 	result =xmlnode_get_child(response,"ABFindAllResult");
 	if(result == NULL){
 		gaim_debug_misc("MSNAB","receive no address book update\n");
-		return;
+		return TRUE;
 	}
 	gaim_debug_misc("xml","result{%p},name:%s\n",result,result->name);
 
@@ -480,6 +494,7 @@
 
 	xmlnode_free(node);
 	msn_soap_free_read_buf(contact->soapconn);
+	return TRUE;
 }
 
 static void
@@ -495,11 +510,13 @@
 	g_return_if_fail(session != NULL);
 
 //	gaim_debug_misc("msn", "soap contact server Reply: {%s}\n", soapconn->read_buf);
-	msn_parse_addressbook(contact);
-
-	msn_notification_dump_contact(session);
-	msn_set_psm(session);
-	msn_session_finish_login(session);
+	if (msn_parse_addressbook(contact)) {
+		msn_notification_dump_contact(session);
+		msn_set_psm(session);
+		msn_session_finish_login(session);
+	} else {
+		msn_get_address_book(contact, NULL, NULL);
+	}
 
 	/*free the read buffer*/
 	msn_soap_free_read_buf(soapconn);
--- a/libgaim/protocols/msn/contact.h	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/contact.h	Sun Apr 15 03:02:48 2007 +0000
@@ -197,6 +197,7 @@
 #define MSN_GROUP_DEL_SOAP_ACTION	"http://www.msn.com/webservices/AddressBook/ABGroupDelete"
 #define MSN_GROUP_DEL_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><guid>%s</guid></groupIds></groupFilter></ABGroupDelete></soap:Body></soap:Envelope>"
 
+
 typedef struct _MsnContact MsnContact;
 
 struct _MsnContact
@@ -229,6 +230,7 @@
 void msn_block_contact(MsnContact *contact,const char* membership_id);
 void msn_unblock_contact(MsnContact *contact,const char* passport);
 
+void msn_contact_connect_init(MsnSoapConn *soapconn);
 
 #endif/* _MSN_CMDPROC_H_*/
 
--- a/libgaim/protocols/msn/msn.c	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/msn.c	Sun Apr 15 03:02:48 2007 +0000
@@ -113,7 +113,7 @@
 	return GAIM_CMD_RET_OK;
 }
 
-static void
+void
 msn_act_id(GaimConnection *gc, const char *entry)
 {
 	MsnCmdProc *cmdproc;
@@ -121,6 +121,9 @@
 	GaimAccount *account;
 	const char *alias;
 
+	char *soapbody;
+	MsnSoapReq *soap_request;
+
 	session = gc->proto_data;
 	cmdproc = session->notification->cmdproc;
 	account = gaim_connection_get_account(gc);
@@ -137,12 +140,27 @@
 		return;
 	}
 
-	if (*alias != '\0') {
-		msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias);
-	} else {
-		msn_cmdproc_send(cmdproc, "PRP", "MFN %s",
-						 gaim_url_encode(gaim_account_get_username(account)));
+	if (*alias == '\0') {
+		alias = gaim_url_encode(gaim_account_get_username(account));
 	}
+
+	msn_cmdproc_send(cmdproc, "PRP", "MFN %s", alias);
+
+	soapbody = g_strdup_printf(MSN_CONTACT_UPDATE_TEMPLATE, alias);
+	/*build SOAP and POST it*/
+	soap_request = msn_soap_request_new(MSN_CONTACT_SERVER,
+										MSN_ADDRESS_BOOK_POST_URL,
+										MSN_CONTACT_UPDATE_SOAP_ACTION,
+										soapbody,
+										NULL,
+										NULL);
+
+	session->contact->soapconn->read_cb = NULL;
+	msn_soap_post(session->contact->soapconn,
+				  soap_request,
+				  msn_contact_connect_init);
+
+	g_free(soapbody);
 }
 
 static void
@@ -431,14 +449,12 @@
 	session = gc->proto_data;
 
 	xfer = gaim_xfer_new(gc->account, GAIM_XFER_SEND, who);
-	if (xfer)
-	{
-		slplink = msn_session_get_slplink(session, who);
+
+	slplink = msn_session_get_slplink(session, who);
 
-		xfer->data = slplink;
+	xfer->data = slplink;
 
-		gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init);
-	}
+	gaim_xfer_set_init_fnc(xfer, t_msn_xfer_init);
 
 	return xfer;
 }
--- a/libgaim/protocols/msn/msn.h	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/msn.h	Sun Apr 15 03:02:48 2007 +0000
@@ -141,4 +141,7 @@
 	 (MSN_CLIENT_ID_RESERVED_2 <<  8) | \
 	 (MSN_CLIENT_ID_CAPABILITIES))
 
+void msn_act_id(GaimConnection *gc, const char *entry);
+
+
 #endif /* _MSN_H_ */
--- a/libgaim/protocols/msn/notification.c	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/notification.c	Sun Apr 15 03:02:48 2007 +0000
@@ -626,18 +626,9 @@
 }
 
 static void
-msn_notification_post_adl(MsnCmdProc *cmdproc,char *payload, int payload_len)
+msn_notification_post_adl(MsnCmdProc *cmdproc, char *payload, int payload_len)
 {
 	MsnTransaction *trans;
-	const char *display_name;
-	const char *friendly;
-
-	display_name = gaim_connection_get_display_name(cmdproc->session->account->gc);
-	if (display_name) {
-		friendly = gaim_url_encode(display_name);
-		msn_cmdproc_send(cmdproc, "PRP", "MFN %s", friendly);
-	}
-
 
 	gaim_debug_info("MaYuan","Send ADL{%s}\n",payload);
 	trans = msn_transaction_new(cmdproc, "ADL","%d",strlen(payload));
@@ -655,6 +646,7 @@
 	xmlnode *adl_node;
 	char *payload;
 	int payload_len;
+	const char *display_name;
 
 	userlist = session->userlist;
 	adl_node = xmlnode_new("ml");
@@ -671,6 +663,13 @@
 	xmlnode_free(adl_node);
 
 	msn_notification_post_adl(session->notification->cmdproc,payload,payload_len);
+
+	display_name = gaim_connection_get_display_name(session->account->gc);
+	if (display_name && strcmp(display_name,
+							   gaim_account_get_username(session->account))) {
+		msn_act_id(session->account->gc, display_name);
+	}
+
 }
 
 /*Post FQY to NS,Inform add a Yahoo User*/
--- a/libgaim/protocols/msn/soap.h	Sun Apr 15 03:01:41 2007 +0000
+++ b/libgaim/protocols/msn/soap.h	Sun Apr 15 03:02:48 2007 +0000
@@ -106,10 +106,11 @@
 
 /*Function Prototype*/
 /*Soap Request Function */
-MsnSoapReq *
-msn_soap_request_new(const char *host,const char *post_url,const char *soap_action,
-				const char *body,
-				GaimInputFunction read_cb,GaimInputFunction written_cb);
+MsnSoapReq *msn_soap_request_new(const char *host, const char *post_url,
+								 const char *soap_action, const char *body,
+								 GaimInputFunction read_cb,
+								 GaimInputFunction written_cb);
+
 void msn_soap_request_free(MsnSoapReq *request);
 void msn_soap_post_request(MsnSoapConn *soapconn,MsnSoapReq *request);
 void msn_soap_post_head_request(MsnSoapConn *soapconn);