pidgin: 4731f8a2: oscar: Try to make the error message mor...

sadrul at pidgin.im sadrul at pidgin.im
Wed Jan 27 16:30:57 EST 2010


-----------------------------------------------------------------
Revision: 4731f8a20970f0d2d92f214bd9975a5dd0459271
Ancestor: 854542f039f2bb3b33baac2899a32c291a39a1f6
Author: sadrul at pidgin.im
Date: 2010-01-27T21:24:15
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/4731f8a20970f0d2d92f214bd9975a5dd0459271

Modified files:
        libpurple/protocols/oscar/clientlogin.c

ChangeLog: 

oscar: Try to make the error message more verbose.

-------------- next part --------------
============================================================
--- libpurple/protocols/oscar/clientlogin.c	14d26f541e61784257be952a66b141fbfef7ab8a
+++ libpurple/protocols/oscar/clientlogin.c	4ea8f551f91a8fd94dc0b22d888bc0ca107849c7
@@ -62,6 +62,26 @@ static const char *get_client_key(OscarD
 			DEFAULT_CLIENT_KEY);
 }
 
+static gchar *generate_error_message(xmlnode *resp, const char *url)
+{
+	xmlnode *text;
+	gchar *err = NULL;
+	gchar *details = NULL;
+
+	if (resp && (text = xmlnode_get_child(resp, "statusText"))) {
+		details = xmlnode_get_data(text);
+	}
+
+	if (details && *details) {
+		err = g_strdup_printf(_("Received unexpected response from %s: %s"), url, details);
+	} else {
+		err = g_strdup_printf(_("Received unexpected response from %s"), url);
+	}
+
+	g_free(details);
+	return err;
+}
+
 /**
  * @return A null-terminated base64 encoded version of the HMAC
  *         calculated using the given key and data.
@@ -121,7 +141,7 @@ static gboolean parse_start_oscar_sessio
 		purple_debug_error("oscar", "startOSCARSession could not parse "
 				"response as XML: %s\n", response);
 		/* Note to translators: %s in this string is a URL */
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_START_OSCAR_SESSION);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -144,7 +164,7 @@ static gboolean parse_start_oscar_sessio
 		char *msg;
 		purple_debug_error("oscar", "startOSCARSession response was "
 				"missing statusCode: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_START_OSCAR_SESSION);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -169,7 +189,7 @@ static gboolean parse_start_oscar_sessio
 					  "longer."));
 		else {
 			char *msg;
-			msg = g_strdup_printf(_("Received unexpected response from %s"),
+			msg = generate_error_message(response_node,
 					URL_START_OSCAR_SESSION);
 			purple_connection_error_reason(gc,
 					PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
@@ -190,7 +210,7 @@ static gboolean parse_start_oscar_sessio
 		char *msg;
 		purple_debug_error("oscar", "startOSCARSession response was missing "
 				"something: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_START_OSCAR_SESSION);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -213,7 +233,7 @@ static gboolean parse_start_oscar_sessio
 		char *msg;
 		purple_debug_error("oscar", "startOSCARSession response was missing "
 				"something: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_START_OSCAR_SESSION);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -340,7 +360,7 @@ static gboolean parse_client_login_respo
 		char *msg;
 		purple_debug_error("oscar", "clientLogin could not parse "
 				"response as XML: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_CLIENT_LOGIN);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -364,7 +384,7 @@ static gboolean parse_client_login_respo
 		char *msg;
 		purple_debug_error("oscar", "clientLogin response was "
 				"missing statusCode: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_CLIENT_LOGIN);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -399,7 +419,7 @@ static gboolean parse_client_login_respo
 					_("AOL does not allow your screen name to authenticate here"));
 		} else {
 			char *msg;
-			msg = g_strdup_printf(_("Received unexpected response from %s"),
+			msg = generate_error_message(response_node,
 					URL_CLIENT_LOGIN);
 			purple_connection_error_reason(gc,
 					PURPLE_CONNECTION_ERROR_OTHER_ERROR, msg);
@@ -418,7 +438,7 @@ static gboolean parse_client_login_respo
 		char *msg;
 		purple_debug_error("oscar", "clientLogin response was missing "
 				"something: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_CLIENT_LOGIN);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);
@@ -436,7 +456,7 @@ static gboolean parse_client_login_respo
 		char *msg;
 		purple_debug_error("oscar", "clientLogin response was missing "
 				"something: %s\n", response);
-		msg = g_strdup_printf(_("Received unexpected response from %s"),
+		msg = generate_error_message(response_node,
 				URL_CLIENT_LOGIN);
 		purple_connection_error_reason(gc,
 				PURPLE_CONNECTION_ERROR_NETWORK_ERROR, msg);


More information about the Commits mailing list