pidgin/pidgin

Parents c66637c918bb
Children c4077237fc03
Add PurpleAccount::error property and remove "account-error-changed" and "account-status-changing" signals.

Also sorted the account signal changes in ChangeLog.API.

The account-error-changed signal is easily replaced by the notify signal for the
new property, and account-status_changing wasn't used by anything.

Testing Done:
Used the account actions of the demo protocol plugin to disconnect the account without issue.

Reviewed at https://reviews.imfreedom.org/r/2036/
--- a/ChangeLog.API Sat Nov 05 01:06:18 2022 -0500
+++ b/ChangeLog.API Sat Nov 05 02:33:47 2022 -0500
@@ -327,21 +327,24 @@
* _PurpleSslConnection
* _XMLNodeType
* account-added signal. Use PurpleAccountManager::added instead.
+ * account-alias-changed signal
+ * account-authorization-denied, account-authorization-granted,
+ account-authorization-requested,
+ account-authorization-requested-with-message signals
+ * account-connecting signal
+ * account-connection-error signal
* account-created signal. Use PurpleAccountManager::added instead.
* account-destroying signal. Use PurpleAccountManager::removed instead.
* account-disabled signal. Use
PurpleAccountManager::account-changed::enabled instead.
* account-enabled signal. Use
PurpleAccountManager::account-changed::enabled instead.
- * account-alias-changed signal
- * account-authorization-denied, account-authorization-granted,
- account-authorization-requested,
- account-authorization-requested-with-message signals
- * account-connecting signal
- * account-connection-error signal
+ * account-error-changed signal. Use
+ PurpleAccountManager::account-changed::error instead.
* account-removed signal. Use PurpleAccountManager::removed
instead.
* account-setting-info, account-set-info signals
+ * account-status-changing signal.
* file-recv-accept, file-recv-cancel, file-recv-complete,
file-recv-start, file-send-accept, file-send-cancel,
file-send-complete, file-send-start signals. Use
--- a/doc/reference/libpurple/signals_account.md Sat Nov 05 01:06:18 2022 -0500
+++ b/doc/reference/libpurple/signals_account.md Sat Nov 05 02:33:47 2022 -0500
@@ -7,7 +7,6 @@
* [account-status-changed](#account-status-changed)
* [account-actions-changed](#account-actions-changed)
-* [account-error-changed](#account-error-changed)
* [account-signed-on](#account-signed-on)
* [account-signed-off](#account-signed-off)
@@ -94,33 +93,6 @@
----
-#### account-error-changed
-
-```c
-void user_function(PurpleAccount *account,
- const PurpleConnectionErrorInfo *old_error,
- const PurpleConnectionErrorInfo *current_error,
- gpointer user_data);
-```
-
-Emitted when `account`'s error changes. You should not call purple_account_clear_current_error() while this signal is being emitted.
-
-**Parameters:**
-
-**account**
-: The account whose error has changed.
-
-**old_error**
-: The account's previous error, or `NULL` if it had no error. After this signal is emitted, `old_error` is not guaranteed to be a valid pointer.
-
-**new_error**
-: The account's new error, or `NULL` if it has no error. If not `NULL`, `new_error` will remain a valid until pointer just after the next time this signal is emitted for this `account`. See `purple_account_get_current_error()`.
-
-**user_data**
-: User data set when the signal handler was connected.
-
-----
-
#### account-signed-on
```c
--- a/libpurple/account.c Sat Nov 05 01:06:18 2022 -0500
+++ b/libpurple/account.c Sat Nov 05 02:33:47 2022 -0500
@@ -127,6 +127,7 @@
PROP_BUDDY_ICON_PATH,
PROP_REMEMBER_PASSWORD,
PROP_PROXY_INFO,
+ PROP_ERROR,
PROP_LAST
};
@@ -508,16 +509,16 @@
_purple_account_set_current_error(PurpleAccount *account,
PurpleConnectionErrorInfo *new_err)
{
- PurpleConnectionErrorInfo *old_err;
PurpleNotificationManager *manager = NULL;
g_return_if_fail(PURPLE_IS_ACCOUNT(account));
- old_err = account->current_error;
-
- if(new_err == old_err)
+ if(new_err == account->current_error) {
return;
-
+ }
+
+ g_clear_pointer(&account->current_error,
+ purple_connection_error_info_free);
account->current_error = new_err;
manager = purple_notification_manager_get_default();
@@ -535,12 +536,9 @@
purple_notification_manager_add(manager, account->error_notification);
}
- purple_signal_emit(purple_accounts_get_handle(),
- "account-error-changed",
- account, old_err, new_err);
+ g_object_notify_by_pspec(G_OBJECT(account), properties[PROP_ERROR]);
+
purple_accounts_schedule_save();
-
- g_clear_pointer(&old_err, purple_connection_error_info_free);
}
/******************************************************************************
@@ -1042,6 +1040,20 @@
PURPLE_TYPE_PROXY_INFO,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+ /**
+ * PurpleAccount:error:
+ *
+ * The [type@GLib.Error] of the account. This is set when an account enters
+ * an error state and is cleared when a connection attempt is made.
+ *
+ * Since: 3.0.0
+ */
+ properties[PROP_ERROR] = g_param_spec_boxed(
+ "error", "error",
+ "The connection error info of the account",
+ PURPLE_TYPE_CONNECTION_ERROR_INFO,
+ G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
+
g_object_class_install_properties(obj_class, PROP_LAST, properties);
}
--- a/libpurple/accounts.c Sat Nov 05 01:06:18 2022 -0500
+++ b/libpurple/accounts.c Sat Nov 05 02:33:47 2022 -0500
@@ -680,11 +680,6 @@
void *handle = purple_accounts_get_handle();
void *conn_handle = purple_connections_get_handle();
- purple_signal_register(handle, "account-status-changing",
- purple_marshal_VOID__POINTER_POINTER_POINTER,
- G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
- PURPLE_TYPE_STATUS, PURPLE_TYPE_STATUS);
-
purple_signal_register(handle, "account-status-changed",
purple_marshal_VOID__POINTER_POINTER_POINTER,
G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
@@ -694,12 +689,6 @@
purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
PURPLE_TYPE_ACCOUNT);
- purple_signal_register(handle, "account-error-changed",
- purple_marshal_VOID__POINTER_POINTER_POINTER,
- G_TYPE_NONE, 3, PURPLE_TYPE_ACCOUNT,
- PURPLE_TYPE_CONNECTION_ERROR_INFO,
- PURPLE_TYPE_CONNECTION_ERROR_INFO);
-
purple_signal_register(handle, "account-signed-on",
purple_marshal_VOID__POINTER, G_TYPE_NONE, 1,
PURPLE_TYPE_ACCOUNT);
--- a/libpurple/protocols.c Sat Nov 05 01:06:18 2022 -0500
+++ b/libpurple/protocols.c Sat Nov 05 02:33:47 2022 -0500
@@ -362,9 +362,6 @@
g_return_if_fail(new_status != NULL);
g_return_if_fail(!purple_status_is_exclusive(new_status) || old_status != NULL);
- purple_signal_emit(purple_accounts_get_handle(), "account-status-changing",
- account, old_status, new_status);
-
do_protocol_change_account_status(account, old_status, new_status);
purple_signal_emit(purple_accounts_get_handle(), "account-status-changed",