Mercurial > pidgin.yaz
diff libpurple/protocols/irc/irc.c @ 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 | 44b4e8bd759b |
children | 1cbda8e2b913 |
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; }