changeset 23537:8fd6a97b9c67

Apparently, when the token expires, OIM requests get a detail/RequiredAuthPolicy element instead of a q0:BadContextToken faultcode. References #4875.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Sat, 21 Jun 2008 06:11:29 +0000
parents f3922a72eb02
children c5891c8d0c28
files libpurple/protocols/msn/oim.c
diffstat 1 files changed, 17 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/oim.c	Fri Jun 20 05:41:39 2008 +0000
+++ b/libpurple/protocols/msn/oim.c	Sat Jun 21 06:11:29 2008 +0000
@@ -135,15 +135,15 @@
 	gpointer req_data)
 {
 	MsnOimRequestData *data = (MsnOimRequestData *)req_data;
-	xmlnode *xml;
-	xmlnode *faultcode;
-	gchar *faultcode_str;
+	xmlnode *fault = NULL;
+	xmlnode *faultcode = NULL;
 
-	xml = response->xml;
-	faultcode = xmlnode_get_child(xml, "Body/Fault/faultcode");
+	fault = xmlnode_get_child(response->xml, "Body/Fault");
+	if (fault)
+		faultcode = xmlnode_get_child(fault, "faultcode");
 
-	if (faultcode != NULL) {
-		faultcode_str = xmlnode_get_data(faultcode);
+	if (faultcode) {
+		gchar *faultcode_str = xmlnode_get_data(faultcode);
 
 		if (faultcode_str && g_str_equal(faultcode_str, "q0:BadContextToken")) {
 			purple_debug_error("msnp15", "OIM Request Error, Updating token now.");
@@ -152,6 +152,16 @@
 				(GSourceFunc)msn_oim_request_helper, data);
 			g_free(faultcode_str);
 			return;
+
+		} else if (faultcode_str && g_str_equal(faultcode_str, "q0:AuthenticationFailed")) {
+			if (xmlnode_get_child(fault, "detail/RequiredAuthPolicy") != NULL) {
+				purple_debug_error("msnp15", "OIM Request Error, Updating token now.");
+				msn_nexus_update_token(data->oim->session->nexus,
+					data->send ? MSN_AUTH_LIVE_SECURE : MSN_AUTH_MESSENGER_WEB,
+					(GSourceFunc)msn_oim_request_helper, data);
+				g_free(faultcode_str);
+				return;
+			}
 		}
 		g_free(faultcode_str);
 	}