--- a/libpurple/protocols/irc/irc.c Tue Sep 18 21:37:36 2007 +0000
+++ b/libpurple/protocols/irc/irc.c Tue Sep 18 21:56:56 2007 +0000
@@ -123,8 +123,9 @@
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")); @@ -161,8 +162,9 @@
/* 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) {
@@ -295,7 +297,8 @@
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")); @@ -324,7 +327,8 @@
purple_account_get_int(account, "port", IRC_DEFAULT_SSL_PORT),
irc_login_cb_ssl, irc_ssl_connect_failure, gc);
- purple_connection_error(gc, _("SSL support unavailable"));
+ purple_connection_error_reason (gc, PURPLE_REASON_ENCRYPTION_ERROR, + _("SSL support unavailable")); @@ -335,7 +339,8 @@
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")); @@ -418,7 +423,8 @@
struct irc_conn *irc = gc->proto_data;
- purple_connection_error(gc, _("Couldn't connect to host"));
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, + _("Couldn't connect to host")); @@ -435,10 +441,25 @@
PurpleConnection *gc = data;
struct irc_conn *irc = gc->proto_data;
+ PurpleDisconnectReason reason; - purple_connection_error(gc, purple_ssl_strerror(error));
+ case PURPLE_SSL_HANDSHAKE_FAILED: + case PURPLE_SSL_CONNECT_FAILED: + reason = PURPLE_REASON_ENCRYPTION_ERROR; + case PURPLE_SSL_CERTIFICATE_INVALID: + /* TODO: maybe PURPLE_SSL_* should be more specific? */ + reason = PURPLE_REASON_CERT_OTHER_ERROR; + 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 @@
- purple_connection_error(gc, _("Read error"));
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, - purple_connection_error(gc, _("Server has disconnected"));
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, + _("Server has disconnected")); @@ -631,10 +654,12 @@
if (len < 0 && errno == EAGAIN) {
- purple_connection_error(gc, _("Read error"));
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, - purple_connection_error(gc, _("Server has disconnected"));
+ purple_connection_error_reason (gc, PURPLE_REASON_NETWORK_ERROR, + _("Server has disconnected")); --- a/libpurple/protocols/irc/msgs.c Tue Sep 18 21:37:36 2007 +0000
+++ b/libpurple/protocols/irc/msgs.c Tue Sep 18 21:56:56 2007 +0000
@@ -911,8 +911,8 @@
- 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.")); --- a/libpurple/protocols/irc/parse.c Tue Sep 18 21:37:36 2007 +0000
+++ b/libpurple/protocols/irc/parse.c Tue Sep 18 21:56:56 2007 +0000
@@ -557,6 +557,7 @@
char *cur, *end, *tmp, *from, *msgname, *fmt, **args, *msg;
+ PurpleConnection *gc = purple_account_get_connection(irc->account); irc->recv_time = time(NULL);
@@ -565,7 +566,7 @@
* 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 @@
} 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); - purple_connection_error(purple_account_get_connection(irc->account), _("Disconnected."));
+ purple_connection_error_reason (gc, + PURPLE_REASON_OTHER_ERROR, _("Disconnected."));