# HG changeset patch # User Will Thompson # Date 1190043051 0 # Node ID 143c6f34c6eb2572fbcd2eac0f0e3d02bd5c346b # Parent 95b2b7a39585dbf61ab4942a85ce6fb0061c9248 Create purple_connection_reason_is_fatal, which is basically a replacement for checking PurpleConnection.wants_to_die. diff -r 95b2b7a39585 -r 143c6f34c6eb libpurple/connection.c --- a/libpurple/connection.c Mon Sep 17 15:23:29 2007 +0000 +++ b/libpurple/connection.c Mon Sep 17 15:30:51 2007 +0000 @@ -524,6 +524,34 @@ purple_connection_get_account(gc)); } +gboolean +purple_connection_reason_is_fatal (PurpleDisconnectReason reason) +{ + switch (reason) + { + case PURPLE_REASON_NONE_SPECIFIED: + case PURPLE_REASON_NETWORK_ERROR: + return FALSE; + case PURPLE_REASON_REQUESTED: + case PURPLE_REASON_AUTHENTICATION_FAILED: + case PURPLE_REASON_ENCRYPTION_ERROR: + case PURPLE_REASON_NAME_IN_USE: + case PURPLE_REASON_CERT_NOT_PROVIDED: + case PURPLE_REASON_CERT_UNTRUSTED: + case PURPLE_REASON_CERT_EXPIRED: + case PURPLE_REASON_CERT_NOT_ACTIVATED: + case PURPLE_REASON_CERT_HOSTNAME_MISMATCH: + case PURPLE_REASON_CERT_FINGERPRINT_MISMATCH: + case PURPLE_REASON_CERT_SELF_SIGNED: + case PURPLE_REASON_CERT_OTHER_ERROR: + case PURPLE_REASON_OTHER_ERROR: + return TRUE; + default: + g_assert_not_reached (); + return TRUE; + } +} + void purple_connections_disconnect_all(void) { diff -r 95b2b7a39585 -r 143c6f34c6eb libpurple/connection.h --- a/libpurple/connection.h Mon Sep 17 15:23:29 2007 +0000 +++ b/libpurple/connection.h Mon Sep 17 15:30:51 2007 +0000 @@ -372,6 +372,26 @@ PurpleDisconnectReason reason, const char *description); +/** + * Reports whether a disconnection reason is fatal (in which case the account + * should probably not be automatically reconnected) or transient (so + * auto-reconnection is a good idea. + * For instance, #PURPLE_REASON_NETWORK_ERROR is a temporary + * error, which might be caused by losing the network connection, so + * @a purple_connection_reason_is_fatal(PURPLE_REASON_NETWORK_ERROR) is + * @a FALSE. On the other hand, #PURPLE_REASON_AUTHENTICATION_FAILED probably + * indicates a misconfiguration of the account which needs the user to go fix + * it up, so @a + * purple_connection_reason_is_fatal(PURPLE_REASON_AUTHENTICATION_FAILED) + * is @a TRUE. + * + * (This function is meant to replace checking PurpleConnection.wants_to_die.) + * + * @return @a TRUE iff automatic reconnection is a bad idea. + */ +gboolean +purple_connection_reason_is_fatal (PurpleDisconnectReason reason); + /*@}*/ /**************************************************************************/