diff libpurple/protocols/msn/servconn.c @ 27979:8e31eec7b621

Propagate connect errors from the MSN proxy callback to the servconn error handling function so that the real proxy error is displayed instead of a generic "Connect Error". Fixes #8280.
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 21 Jul 2009 04:31:27 +0000
parents 97ba0d9e6e54
children 33856dfb5cbf
line wrap: on
line diff
--- a/libpurple/protocols/msn/servconn.c	Tue Jul 21 03:57:20 2009 +0000
+++ b/libpurple/protocols/msn/servconn.c	Tue Jul 21 04:31:27 2009 +0000
@@ -123,27 +123,29 @@
  **************************************************************************/
 
 void
-msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error)
+msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error,
+                       const char *reason)
 {
 	MsnSession *session = servconn->session;
 	MsnServConnType type = servconn->type;
-	const char *reason;
 
 	const char *names[] = { "Notification", "Switchboard" };
 	const char *name;
 
 	name = names[type];
 
-	switch (error)
-	{
-		case MSN_SERVCONN_ERROR_CONNECT:
-			reason = _("Unable to connect"); break;
-		case MSN_SERVCONN_ERROR_WRITE:
-			reason = _("Writing error"); break;
-		case MSN_SERVCONN_ERROR_READ:
-			reason = _("Reading error"); break;
-		default:
-			reason = _("Unknown error"); break;
+	if (reason == NULL) {
+		switch (error)
+		{
+			case MSN_SERVCONN_ERROR_CONNECT:
+				reason = _("Unable to connect"); break;
+			case MSN_SERVCONN_ERROR_WRITE:
+				reason = _("Writing error"); break;
+			case MSN_SERVCONN_ERROR_READ:
+				reason = _("Reading error"); break;
+			default:
+				reason = _("Unknown error"); break;
+		}
 	}
 
 	purple_debug_error("msn", "Connection error from %s server (%s): %s\n",
@@ -196,7 +198,7 @@
 	else
 	{
 		purple_debug_error("msn", "Connection error: %s\n", error_message);
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_CONNECT);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_CONNECT, error_message);
 	}
 }
 
@@ -344,7 +346,7 @@
 	if (ret < 0 && errno == EAGAIN)
 		return;
 	else if (ret <= 0) {
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_WRITE);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_WRITE, NULL);
 		return;
 	}
 
@@ -401,7 +403,7 @@
 
 	if (ret == -1)
 	{
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_WRITE);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_WRITE, NULL);
 	}
 
 	servconn_timeout_renew(servconn);
@@ -427,7 +429,7 @@
 		purple_debug_error("msn", "servconn %03d read error, "
 			"len: %" G_GSSIZE_FORMAT ", errno: %d, error: %s\n",
 			servconn->num, len, errno, g_strerror(errno));
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ, NULL);
 
 		return;
 	}