changeset 20067:143c6f34c6eb

Create purple_connection_reason_is_fatal, which is basically a replacement for checking PurpleConnection.wants_to_die.
author Will Thompson <will.thompson@collabora.co.uk>
date Mon, 17 Sep 2007 15:30:51 +0000
parents 95b2b7a39585
children affc480cc570
files libpurple/connection.c libpurple/connection.h
diffstat 2 files changed, 48 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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)
 {
--- 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);
+
 /*@}*/
 
 /**************************************************************************/