changeset 27657:f3809e302ec7

merge of '50e2f2c66f304a73c2a9ef4d912be5e3f2ed39a5' and '73a88ac85b97264c19b9a9966270eecd310b6bff'
author Elliott Sales de Andrade <qulogic@pidgin.im>
date Tue, 21 Jul 2009 06:16:43 +0000
parents 8e31eec7b621 (diff) 7e473a437c7f (current diff)
children 29e1cc634466
files pidgin/pixmaps/dialogs/64/scalable/auth.svg pidgin/pixmaps/dialogs/64/scalable/cool.svg pidgin/pixmaps/dialogs/64/scalable/dialog.svg pidgin/pixmaps/dialogs/64/scalable/error.svg pidgin/pixmaps/dialogs/64/scalable/info.svg pidgin/pixmaps/dialogs/64/scalable/mail.svg pidgin/pixmaps/dialogs/64/scalable/question.svg pidgin/pixmaps/dialogs/64/scalable/warning.svg pidgin/pixmaps/emblems/16/scalable/aol-client.svg pidgin/pixmaps/emblems/16/scalable/birthday.svg pidgin/pixmaps/emblems/16/scalable/blocked.svg pidgin/pixmaps/emblems/16/scalable/bot.svg pidgin/pixmaps/emblems/16/scalable/external.svg pidgin/pixmaps/emblems/16/scalable/female.svg pidgin/pixmaps/emblems/16/scalable/free-for-chat.svg pidgin/pixmaps/emblems/16/scalable/game.svg pidgin/pixmaps/emblems/16/scalable/male.svg pidgin/pixmaps/emblems/16/scalable/mobile.svg pidgin/pixmaps/emblems/16/scalable/music.svg pidgin/pixmaps/emblems/16/scalable/not-authorized.svg pidgin/pixmaps/emblems/16/scalable/qq-member.svg pidgin/pixmaps/emblems/16/scalable/secure.svg pidgin/pixmaps/emblems/16/scalable/unavailable.svg pidgin/pixmaps/emblems/16/scalable/video.svg pidgin/pixmaps/emblems/16/scalable/voice.svg pidgin/pixmaps/icons/hicolor/48x48/apps/scalable/pidgin.svg pidgin/pixmaps/protocols/48/scalable/aim.svg pidgin/pixmaps/protocols/48/scalable/bonjour.svg pidgin/pixmaps/protocols/48/scalable/gadu-gadu.svg pidgin/pixmaps/protocols/48/scalable/google-talk.svg pidgin/pixmaps/protocols/48/scalable/icq.svg pidgin/pixmaps/protocols/48/scalable/irc.svg pidgin/pixmaps/protocols/48/scalable/jabber.svg pidgin/pixmaps/protocols/48/scalable/meanwhile.svg pidgin/pixmaps/protocols/48/scalable/msn.svg pidgin/pixmaps/protocols/48/scalable/novell.svg pidgin/pixmaps/protocols/48/scalable/qq.svg pidgin/pixmaps/protocols/48/scalable/silc.svg pidgin/pixmaps/protocols/48/scalable/simple.svg pidgin/pixmaps/protocols/48/scalable/yahoo.svg pidgin/pixmaps/protocols/48/scalable/zephyr.svg
diffstat 3 files changed, 39 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/msn/httpconn.c	Tue Jul 21 04:25:59 2009 +0000
+++ b/libpurple/protocols/msn/httpconn.c	Tue Jul 21 06:16:43 2009 +0000
@@ -293,7 +293,7 @@
 		purple_debug_error("msn", "HTTP: servconn %03d read error, "
 			"len: %" G_GSSIZE_FORMAT ", errno: %d, error: %s\n",
 			servconn->num, len, error, g_strerror(errno));
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ, NULL);
 
 		return;
 	}
@@ -309,7 +309,7 @@
 	{
 		/* Either we must wait for more input, or something went wrong */
 		if (error)
-			msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ);
+			msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ, NULL);
 
 		return;
 	}
@@ -317,7 +317,7 @@
 	if (error)
 	{
 		purple_debug_error("msn", "HTTP: Special error\n");
-		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ);
+		msn_servconn_got_error(servconn, MSN_SERVCONN_ERROR_READ, NULL);
 
 		return;
 	}
@@ -368,7 +368,7 @@
 			return;
 
 		/* Error! */
-		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_WRITE);
+		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_WRITE, NULL);
 		return;
 	}
 
@@ -394,7 +394,7 @@
 
 	if ((res <= 0) && ((errno != EAGAIN) && (errno != EWOULDBLOCK)))
 	{
-		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_WRITE);
+		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_WRITE, NULL);
 		return FALSE;
 	}
 
@@ -672,7 +672,7 @@
 	{
 		purple_debug_error("msn", "HTTP: Connection error: %s\n",
 		                   error_message ? error_message : "(null)");
-		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_CONNECT);
+		msn_servconn_got_error(httpconn->servconn, MSN_SERVCONN_ERROR_CONNECT, error_message);
 	}
 }
 
--- a/libpurple/protocols/msn/servconn.c	Tue Jul 21 04:25:59 2009 +0000
+++ b/libpurple/protocols/msn/servconn.c	Tue Jul 21 06:16:43 2009 +0000
@@ -123,38 +123,35 @@
  **************************************************************************/
 
 void
-msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error)
+msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error,
+                       const char *reason)
 {
-	char *tmp;
-	const char *reason;
+	MsnSession *session = servconn->session;
+	MsnServConnType type = servconn->type;
 
 	const char *names[] = { "Notification", "Switchboard" };
 	const char *name;
 
-	name = names[servconn->type];
+	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",
 					 name, servconn->host, reason);
-	tmp = g_strdup_printf(_("Connection error from %s server:\n%s"),
-						  name, reason);
 
-	if (servconn->type == MSN_SERVCONN_NS)
-	{
-		msn_session_set_error(servconn->session, MSN_ERROR_SERVCONN, tmp);
-	}
-	else if (servconn->type == MSN_SERVCONN_SB)
+	if (type == MSN_SERVCONN_SB)
 	{
 		MsnSwitchBoard *swboard;
 		swboard = servconn->cmdproc->data;
@@ -162,9 +159,16 @@
 			swboard->error = MSN_SB_ERROR_CONNECTION;
 	}
 
+	/* servconn->disconnect_cb may destroy servconn, so don't use it again */
 	msn_servconn_disconnect(servconn);
 
-	g_free(tmp);
+	if (type == MSN_SERVCONN_NS)
+	{
+		char *tmp = g_strdup_printf(_("Connection error from %s server:\n%s"),
+		                            name, reason);
+		msn_session_set_error(session, MSN_ERROR_SERVCONN, tmp);
+		g_free(tmp);
+	}
 }
 
 /**************************************************************************
@@ -194,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);
 	}
 }
 
@@ -310,7 +314,7 @@
 
 	if (servconn->connected && servconn->timeout_sec) {
 		servconn->timeout_handle = purple_timeout_add_seconds(
-			servconn->timeout_sec, servconn_idle_timeout_cb, servconn);
+			servconn->timeout_sec, (GSourceFunc)servconn_idle_timeout_cb, servconn);
 	}
 }
 
@@ -342,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;
 	}
 
@@ -399,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);
@@ -425,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;
 	}
--- a/libpurple/protocols/msn/servconn.h	Tue Jul 21 04:25:59 2009 +0000
+++ b/libpurple/protocols/msn/servconn.h	Tue Jul 21 06:16:43 2009 +0000
@@ -170,7 +170,8 @@
  * @param servconn The servconn.
  * @param error The error that happened.
  */
-void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error);
+void msn_servconn_got_error(MsnServConn *servconn, MsnServConnError error,
+                            const char *reason);
 
 /**
  * Process the data in servconn->rx_buf.  This is called after reading