Mercurial > pidgin.yaz
changeset 20112:1b420901ca3b
Move prpl-irc to purple_connection_error_reason.
author | Will Thompson <will.thompson@collabora.co.uk> |
---|---|
date | Tue, 18 Sep 2007 21:56:56 +0000 |
parents | b5ccce9a88a1 |
children | 1cbda8e2b913 |
files | libpurple/protocols/irc/irc.c libpurple/protocols/irc/msgs.c libpurple/protocols/irc/parse.c |
diffstat | 3 files changed, 45 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- 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) 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 @@ /* 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ { 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 @@ /* 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 @@ 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; }
--- 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 @@ } 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.")); } }
--- 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 @@ 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 @@ * 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); 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; }