im.pidgin.cpw.resiak.disconnectreason: 621d694cb1d0ce64dd8ff8a6d109259aec863d7a

resiak at soc.pidgin.im resiak at soc.pidgin.im
Wed Oct 3 13:56:46 EDT 2007


revision:            621d694cb1d0ce64dd8ff8a6d109259aec863d7a
date:                2007-09-18T21:56:56
author:              resiak at soc.pidgin.im
branch:              im.pidgin.cpw.resiak.disconnectreason
changelog:
Move prpl-irc to purple_connection_error_reason.

manifest:
format_version "1"

new_manifest [a8ed3883dd7db23b1285b0fb6e8b87fddf54c644]

old_revision [932ff42758b6814e0d807f107ec4735680ffb0c5]

patch "libpurple/protocols/irc/irc.c"
 from [b094fcd656e74fcc74b8e0f7526d0023ee4ce543]
   to [27eec5dc0da175c99eddd5930521143de03f4b51]

patch "libpurple/protocols/irc/msgs.c"
 from [268c9f7531ccf78e0a77c5145df952510fe4cfc3]
   to [ae0e4426ebe605791ef7124149f0dd77ce06d31d]

patch "libpurple/protocols/irc/parse.c"
 from [1c8c93675ef3a48f0f86ed3415727d83154cd766]
   to [e8b34e334a19e2056a9814208d697d541f3420f3]
-------------- next part --------------
#
#
# patch "libpurple/protocols/irc/irc.c"
#  from [b094fcd656e74fcc74b8e0f7526d0023ee4ce543]
#    to [27eec5dc0da175c99eddd5930521143de03f4b51]
# 
# patch "libpurple/protocols/irc/msgs.c"
#  from [268c9f7531ccf78e0a77c5145df952510fe4cfc3]
#    to [ae0e4426ebe605791ef7124149f0dd77ce06d31d]
# 
# patch "libpurple/protocols/irc/parse.c"
#  from [1c8c93675ef3a48f0f86ed3415727d83154cd766]
#    to [e8b34e334a19e2056a9814208d697d541f3420f3]
#
============================================================
--- libpurple/protocols/irc/irc.c	b094fcd656e74fcc74b8e0f7526d0023ee4ce543
+++ libpurple/protocols/irc/irc.c	27eec5dc0da175c99eddd5930521143de03f4b51
@@ -123,8 +123,9 @@ irc_send_cb(gpointer data, gint source, 
 	if (ret < 0 && errno == EAGAIN)
 		return;
 	else if (ret <= 0) {
-		purple_connection_error(purple_account_get_connection(irc->account),
-			      _("Server has disconnected"));
+		PurpleConnection *gc = purple_account_get_connection(irc->account);
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Server has disconnected"));
 		return;
 	}
 
@@ -161,8 +162,9 @@ int irc_send(struct irc_conn *irc, const
 	/* purple_debug(PURPLE_DEBUG_MISC, "irc", "sent%s: %s",
 		irc->gsc ? " (ssl)" : "", tosend); */
 	if (ret <= 0 && errno != EAGAIN) {
-		purple_connection_error(purple_account_get_connection(irc->account),
-				      _("Server has disconnected"));
+		PurpleConnection *gc = purple_account_get_connection(irc->account);
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Server has disconnected"));
 	} else if (ret < buflen) {
 		if (ret < 0)
 			ret = 0;
@@ -295,7 +297,8 @@ static void irc_login(PurpleAccount *acc
 	gc->flags |= PURPLE_CONNECTION_NO_NEWLINES;
 
 	if (strpbrk(username, " \t\v\r\n") != NULL) {
-		purple_connection_error(gc, _("IRC nicks may not contain whitespace"));
+		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_USERNAME,
+			_("IRC nicks may not contain whitespace"));
 		return;
 	}
 
@@ -324,7 +327,8 @@ static void irc_login(PurpleAccount *acc
 					purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
 					irc_login_cb_ssl, irc_ssl_connect_failure, gc);
 		} else {
-			purple_connection_error(gc, _("SSL support unavailable"));
+			purple_connection_error_reason (gc, PURPLE_REASON_ENCRYPTION_ERROR,
+				_("SSL support unavailable"));
 			return;
 		}
 	}
@@ -335,7 +339,8 @@ static void irc_login(PurpleAccount *acc
 				 purple_account_get_int(account, "port", IRC_DEFAULT_PORT),
 				 irc_login_cb, gc) == NULL)
 		{
-			purple_connection_error(gc, _("Couldn't create socket"));
+			purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+				_("Couldn't create socket"));
 			return;
 		}
 	}
@@ -418,7 +423,8 @@ static void irc_login_cb(gpointer data, 
 	struct irc_conn *irc = gc->proto_data;
 
 	if (source < 0) {
-		purple_connection_error(gc, _("Couldn't connect to host"));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Couldn't connect to host"));
 		return;
 	}
 
@@ -435,10 +441,25 @@ irc_ssl_connect_failure(PurpleSslConnect
 {
 	PurpleConnection *gc = data;
 	struct irc_conn *irc = gc->proto_data;
+	PurpleDisconnectReason reason;
 
 	irc->gsc = NULL;
 
-	purple_connection_error(gc, purple_ssl_strerror(error));
+	switch (error) {
+		case PURPLE_SSL_HANDSHAKE_FAILED:
+		case PURPLE_SSL_CONNECT_FAILED:
+			reason = PURPLE_REASON_ENCRYPTION_ERROR;
+			break;
+		case PURPLE_SSL_CERTIFICATE_INVALID:
+			/* TODO: maybe PURPLE_SSL_* should be more specific? */
+			reason = PURPLE_REASON_CERT_OTHER_ERROR;
+			break;
+		default:
+			g_assert_not_reached ();
+			reason = PURPLE_REASON_ENCRYPTION_ERROR;
+	}
+
+	purple_connection_error_reason (gc, reason, purple_ssl_strerror(error));
 }
 
 static void irc_close(PurpleConnection *gc)
@@ -606,10 +627,12 @@ static void irc_input_cb_ssl(gpointer da
 		/* Try again later */
 		return;
 	} else if (len < 0) {
-		purple_connection_error(gc, _("Read error"));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Read error"));
 		return;
 	} else if (len == 0) {
-		purple_connection_error(gc, _("Server has disconnected"));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Server has disconnected"));
 		return;
 	}
 
@@ -631,10 +654,12 @@ static void irc_input_cb(gpointer data, 
 	if (len < 0 && errno == EAGAIN) {
 		return;
 	} else if (len < 0) {
-		purple_connection_error(gc, _("Read error"));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Read error"));
 		return;
 	} else if (len == 0) {
-		purple_connection_error(gc, _("Server has disconnected"));
+		purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR,
+			_("Server has disconnected"));
 		return;
 	}
 
============================================================
--- libpurple/protocols/irc/msgs.c	268c9f7531ccf78e0a77c5145df952510fe4cfc3
+++ libpurple/protocols/irc/msgs.c	ae0e4426ebe605791ef7124149f0dd77ce06d31d
@@ -911,8 +911,8 @@ void irc_msg_badnick(struct irc_conn *ir
 
 	} else {
 		gc->wants_to_die = TRUE;
-		purple_connection_error(purple_account_get_connection(irc->account),
-				      _("Your selected account name was rejected by the server.  It probably contains invalid characters."));
+		purple_connection_error_reason (gc, PURPLE_REASON_INVALID_USERNAME,
+				  _("Your selected account name was rejected by the server.  It probably contains invalid characters."));
 	}
 }
 
============================================================
--- libpurple/protocols/irc/parse.c	1c8c93675ef3a48f0f86ed3415727d83154cd766
+++ libpurple/protocols/irc/parse.c	e8b34e334a19e2056a9814208d697d541f3420f3
@@ -557,6 +557,7 @@ void irc_parse_msg(struct irc_conn *irc,
 	struct _irc_msg *msgent;
 	char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg;
 	guint i;
+	PurpleConnection *gc = purple_account_get_connection(irc->account);
 
 	irc->recv_time = time(NULL);
 
@@ -565,7 +566,7 @@ void irc_parse_msg(struct irc_conn *irc,
 	 * TODO: It should be passed as an array of bytes and a length
 	 * instead of a null terminated string.
 	 */
-	purple_signal_emit(_irc_plugin, "irc-receiving-text", purple_account_get_connection(irc->account), &input);
+	purple_signal_emit(_irc_plugin, "irc-receiving-text", gc, &input);
 	
 	if (!strncmp(input, "PING ", 5)) {
 		msg = irc_format(irc, "vv", "PONG", input + 5);
@@ -575,10 +576,11 @@ void irc_parse_msg(struct irc_conn *irc,
 	} else if (!strncmp(input, "ERROR ", 6)) {
 		if (g_utf8_validate(input, -1, NULL)) {
 			char *tmp = g_strdup_printf("%s\n%s", _("Disconnected."), input);
-			purple_connection_error(purple_account_get_connection(irc->account), tmp);
+			purple_connection_error_reason (gc, PURPLE_REASON_OTHER_ERROR, tmp);
 			g_free(tmp);
 		} else
-			purple_connection_error(purple_account_get_connection(irc->account), _("Disconnected."));
+			purple_connection_error_reason (gc,
+				PURPLE_REASON_OTHER_ERROR, _("Disconnected."));
 		return;
 	}
 


More information about the Commits mailing list