changeset 20132:b4ac690a2225

Add disconnection reasons to yahoo
author Will Thompson <will.thompson@collabora.co.uk>
date Wed, 03 Oct 2007 17:44:29 +0000
parents 885320299776
children f3cfcbbac3d8
files libpurple/protocols/yahoo/yahoo.c libpurple/protocols/yahoo/yahoo_packet.c
diffstat 2 files changed, 29 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/yahoo/yahoo.c	Wed Oct 03 17:23:02 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo.c	Wed Oct 03 17:44:29 2007 +0000
@@ -202,7 +202,8 @@
 
 	if (pkt->service == YAHOO_SERVICE_LOGOFF && pkt->status == -1) {
 		gc->wants_to_die = TRUE;
-		purple_connection_error(gc, _("You have signed on from another location."));
+		purple_connection_error_reason(gc, PURPLE_REASON_NAME_IN_USE,
+			_("You have signed on from another location."));
 		return;
 	}
 
@@ -2135,7 +2136,7 @@
 		fullmsg = g_strdup(msg);
 
 	gc->wants_to_die = TRUE;
-	purple_connection_error(gc, fullmsg);
+	purple_connection_error_reason(gc, PURPLE_REASON_AUTHENTICATION_FAILED, fullmsg);
 	g_free(msg);
 	g_free(fullmsg);
 }
@@ -2459,11 +2460,12 @@
 
 		tmp = g_strdup_printf(_("Lost connection with server:\n%s"),
 				strerror(errno));
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	} else if (len == 0) {
-		purple_connection_error(gc, _("Server closed the connection."));
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+				_("Server closed the connection."));
 		return;
 	}
 
@@ -2554,7 +2556,7 @@
 		gchar *tmp;
 		tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
 				error_message);
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	}
@@ -2586,7 +2588,7 @@
 		gchar *tmp;
 		tmp = g_strdup_printf(_("Could not establish a connection with the server:\n%s"),
 				error_message);
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	}
@@ -2626,11 +2628,12 @@
 
 		tmp = g_strdup_printf(_("Lost connection with server:\n%s"),
 				strerror(errno));
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	} else if (len == 0) {
-		purple_connection_error(gc, _("Server closed the connection."));
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Server closed the connection."));
 		return;
 	}
 
@@ -2645,7 +2648,8 @@
 
 	if ((strncmp(buf, "HTTP/1.0 302", strlen("HTTP/1.0 302")) &&
 			  strncmp(buf, "HTTP/1.1 302", strlen("HTTP/1.1 302")))) {
-		purple_connection_error(gc, _("Received unexpected HTTP response from server."));
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Received unexpected HTTP response from server."));
 		return;
 	}
 
@@ -2667,9 +2671,10 @@
 	yd->rxlen = 0;
 	/* Now we have our cookies to login with.  I'll go get the milk. */
 	if (purple_proxy_connect(gc, account, "wcs2.msg.dcn.yahoo.com",
-			       purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
-			       yahoo_got_web_connected, gc) == NULL) {
-		purple_connection_error(gc, _("Connection problem"));
+	                         purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
+	                         yahoo_got_web_connected, gc) == NULL) {
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+		                               _("Connection problem"));
 		return;
 	}
 }
@@ -2697,7 +2702,7 @@
 		gc->inpa = 0;
 		tmp = g_strdup_printf(_("Lost connection with %s:\n%s"),
 				"login.yahoo.com:80", strerror(errno));
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	}
@@ -2722,7 +2727,7 @@
 		gchar *tmp;
 		tmp = g_strdup_printf(_("Could not establish a connection with %s:\n%s"),
 				"login.yahoo.com:80", error_message);
-		purple_connection_error(gc, tmp);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR, tmp);
 		g_free(tmp);
 		return;
 	}
@@ -2806,7 +2811,8 @@
 
 	if (error_message != NULL)
 	{
-		purple_connection_error(gc, error_message);
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+		                               error_message);
 		return;
 	}
 
@@ -2855,7 +2861,8 @@
 	g_hash_table_destroy(hash);
 	yd->auth = g_string_free(url, FALSE);
 	if (purple_proxy_connect(gc, account, "login.yahoo.com", 80, yahoo_got_cookies, gc) == NULL) {
-		purple_connection_error(gc, _("Connection problem"));
+		purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+		                               _("Connection problem"));
 		return;
 	}
 
@@ -2958,7 +2965,8 @@
 		                       purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
 		                       yahoo_got_connected, gc) == NULL)
 		{
-			purple_connection_error(gc, _("Connection problem"));
+			purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+			                               _("Connection problem"));
 			return;
 		}
 	} else {
@@ -2968,7 +2976,8 @@
 		                       purple_account_get_int(account, "port", YAHOO_PAGER_PORT),
 		                       yahoo_got_connected, gc) == NULL)
 		{
-			purple_connection_error(gc, _("Connection problem"));
+			purple_connection_error_reason(gc, PURPLE_REASON_NETWORK_ERROR,
+			                               _("Connection problem"));
 			return;
 		}
 	}
--- a/libpurple/protocols/yahoo/yahoo_packet.c	Wed Oct 03 17:23:02 2007 +0000
+++ b/libpurple/protocols/yahoo/yahoo_packet.c	Wed Oct 03 17:44:29 2007 +0000
@@ -304,7 +304,8 @@
 		return;
 	else if (ret < 0) {
 		/* TODO: what to do here - do we really have to disconnect? */
-		purple_connection_error(yd->gc, _("Write Error"));
+		purple_connection_error_reason(yd->gc, PURPLE_REASON_NETWORK_ERROR,
+		                               _("Write Error"));
 		return;
 	}