changeset 25458:b1080a1a2cb0

Save and use the CacheKey for ABCH SOAP requests. Fixes #8080.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sun, 15 Feb 2009 21:15:39 +0000
parents 3f6dbc414357
children 9487c9b7a01f
files libpurple/protocols/msn/contact.c libpurple/protocols/msn/session.c libpurple/protocols/msn/session.h
diffstat 3 files changed, 27 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/contact.c	Sun Feb 15 21:14:06 2009 +0000
+++ b/libpurple/protocols/msn/contact.c	Sun Feb 15 21:15:39 2009 +0000
@@ -198,6 +198,8 @@
 	MsnCallbackState *state = data;
 	xmlnode *fault;
 	char *faultcode_str;
+	xmlnode *cachekey;
+	char *changed;
 
 	if (resp == NULL) {
 		purple_debug_error("msn",
@@ -206,6 +208,21 @@
 		return;
 	}
 
+ 	/* Update CacheKey if necessary */
+ 	cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKeyChanged");
+ 	if (cachekey != NULL) {
+ 		changed = xmlnode_get_data(cachekey);
+ 		if (changed && !strcmp(changed, "true")) {
+ 			cachekey = xmlnode_get_child(resp->xml, "Header/ServiceHeader/CacheKey");
+ 			g_free(state->session->abch_cachekey);
+ 			state->session->abch_cachekey = xmlnode_get_data(cachekey);
+ 			purple_debug_info("msn", "Updated CacheKey for %s to '%s'.\n",
+ 			                  purple_account_get_username(state->session->account),
+ 			                  state->session->abch_cachekey);
+ 		}
+ 		g_free(changed);
+ 	}
+
 	fault = xmlnode_get_child(resp->xml, "Body/Fault");
 
 	if (fault == NULL) {
@@ -247,6 +264,14 @@
 static gboolean
 msn_contact_request(MsnCallbackState *state)
 {
+	xmlnode *cachekey = xmlnode_get_child(state->body,
+	                                      "Header/ABApplicationHeader/CacheKey");
+	if (cachekey != NULL)
+		xmlnode_free(cachekey);
+	if (state->session->abch_cachekey != NULL) {
+		cachekey = xmlnode_new_child(xmlnode_get_child(state->body, "Header/ABApplicationHeader"), "CacheKey");
+		xmlnode_insert_data(cachekey, state->session->abch_cachekey, -1);
+	}
 	if (state->token == NULL)
 		state->token = xmlnode_get_child(state->body,
 			"Header/ABAuthHeader/TicketToken");
--- a/libpurple/protocols/msn/session.c	Sun Feb 15 21:14:06 2009 +0000
+++ b/libpurple/protocols/msn/session.c	Sun Feb 15 21:15:39 2009 +0000
@@ -90,7 +90,7 @@
 	msn_userlist_destroy(session->userlist);
 
 	g_free(session->psm);
-
+	g_free(session->abch_cachekey);
 #if 0
 	g_free(session->blocked_text);
 #endif
--- a/libpurple/protocols/msn/session.h	Sun Feb 15 21:14:06 2009 +0000
+++ b/libpurple/protocols/msn/session.h	Sun Feb 15 21:15:39 2009 +0000
@@ -98,6 +98,7 @@
 	MsnOim          *oim;
 	MsnSync         *sync;
 	MsnUserList     *userlist;
+	char            *abch_cachekey;
 
 	int servconns_count; /**< The count of server connections. */
 	GList *switches; /**< The list of all the switchboards. */