pidgin/pidgin

Add some custom connection errors

22 months ago, Gary Kramlich
6b13615303cc
Parents 70c7466f850b
Children 979c8cc3413a
Add some custom connection errors

These were added for the rare occasion where a connection error doesn't fit in
to the ones we already have, like in the case of the Demo protocol plugin where
we use this for testing.

Testing Done:
Triggered both connection errors via the demo protocol plugin and verified that the temporary error did reconnect.

Reviewed at https://reviews.imfreedom.org/r/1549/
--- a/libpurple/connection.c Fri Jul 29 01:48:49 2022 -0500
+++ b/libpurple/connection.c Fri Jul 29 01:51:31 2022 -0500
@@ -531,6 +531,7 @@
switch (reason) {
case PURPLE_CONNECTION_ERROR_NETWORK_ERROR:
case PURPLE_CONNECTION_ERROR_ENCRYPTION_ERROR:
+ case PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY:
return FALSE;
case PURPLE_CONNECTION_ERROR_INVALID_USERNAME:
case PURPLE_CONNECTION_ERROR_AUTHENTICATION_FAILED:
@@ -538,7 +539,6 @@
case PURPLE_CONNECTION_ERROR_NO_SSL_SUPPORT:
case PURPLE_CONNECTION_ERROR_NAME_IN_USE:
case PURPLE_CONNECTION_ERROR_INVALID_SETTINGS:
- case PURPLE_CONNECTION_ERROR_OTHER_ERROR:
case PURPLE_CONNECTION_ERROR_CERT_NOT_PROVIDED:
case PURPLE_CONNECTION_ERROR_CERT_UNTRUSTED:
case PURPLE_CONNECTION_ERROR_CERT_EXPIRED:
@@ -547,6 +547,8 @@
case PURPLE_CONNECTION_ERROR_CERT_FINGERPRINT_MISMATCH:
case PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED:
case PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR:
+ case PURPLE_CONNECTION_ERROR_CUSTOM_FATAL:
+ case PURPLE_CONNECTION_ERROR_OTHER_ERROR:
return TRUE;
default:
g_return_val_if_reached(TRUE);
--- a/libpurple/connection.h Fri Jul 29 01:48:49 2022 -0500
+++ b/libpurple/connection.h Fri Jul 29 01:51:31 2022 -0500
@@ -187,11 +187,14 @@
PURPLE_CONNECTION_ERROR_CERT_SELF_SIGNED = 14,
PURPLE_CONNECTION_ERROR_CERT_OTHER_ERROR = 15,
+ PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY = 16,
+ PURPLE_CONNECTION_ERROR_CUSTOM_FATAL = 17,
+
/* purple_connection_error() in connection.c uses the fact that
* this is the last member of the enum when sanity-checking; if other
* reasons are added after it, the check must be updated.
*/
- PURPLE_CONNECTION_ERROR_OTHER_ERROR = 16
+ PURPLE_CONNECTION_ERROR_OTHER_ERROR = 18
} PurpleConnectionError;
/**
--- a/libpurple/protocols/demo/purpledemoprotocolactions.c Fri Jul 29 01:48:49 2022 -0500
+++ b/libpurple/protocols/demo/purpledemoprotocolactions.c Fri Jul 29 01:51:31 2022 -0500
@@ -35,6 +35,7 @@
static gboolean
purple_demo_protocol_failure_tick(gpointer data,
+ PurpleConnectionError error_code,
const gchar *tick_str,
const gchar *tick_plural_str,
const gchar *disconnect_str)
@@ -61,8 +62,7 @@
}
message = g_strdup_printf(_(disconnect_str), REAPER_BUDDY_NAME);
- purple_connection_error(connection, PURPLE_CONNECTION_ERROR_OTHER_ERROR,
- message);
+ purple_connection_error(connection, error_code, message);
g_free(message);
return G_SOURCE_REMOVE;
@@ -71,6 +71,7 @@
static gboolean
purple_demo_protocol_fatal_failure_cb(gpointer data) {
return purple_demo_protocol_failure_tick(data,
+ PURPLE_CONNECTION_ERROR_CUSTOM_FATAL,
FATAL_TICK_STR,
FATAL_TICK_PLURAL_STR,
FATAL_DISCONNECT_STR);
@@ -79,6 +80,7 @@
static gboolean
purple_demo_protocol_temporary_failure_cb(gpointer data) {
return purple_demo_protocol_failure_tick(data,
+ PURPLE_CONNECTION_ERROR_CUSTOM_TEMPORARY,
TEMPORARY_TICK_STR,
TEMPORARY_TICK_PLURAL_STR,
TEMPORARY_DISCONNECT_STR);