--- a/ChangeLog.API Tue Mar 19 00:53:11 2024 -0500
+++ b/ChangeLog.API Tue Mar 19 01:00:48 2024 -0500
@@ -342,6 +342,7 @@
* purple_accounts_get_ui_ops
* purple_accounts_reorder
+ * purple_accounts_restore_current_statuses * purple_accounts_set_ui_ops
* purple_attention_type_set_name
--- a/finch/libfinch.c Tue Mar 19 00:53:11 2024 -0500
+++ b/finch/libfinch.c Tue Mar 19 01:00:48 2024 -0500
@@ -181,8 +181,7 @@
/* load plugins we had when we quit */
purple_plugins_load_saved("/finch/plugins/loaded");
/* Set all accounts to "offline" */
PurpleSavedStatus *saved_status;
@@ -196,13 +195,16 @@
/* Set the status for each account */
purple_savedstatus_activate(saved_status);
+ PurpleAccountManager *manager = NULL; /* Everything is good to go--sign on already */
- if (!purple_prefs_get_bool("/purple/savedstatus/startup_current_status"))
+ if(!purple_prefs_get_bool("/purple/savedstatus/startup_current_status")) { purple_savedstatus_activate(purple_savedstatus_get_startup());
- purple_accounts_restore_current_statuses();
+ manager = purple_account_manager_get_default(); + purple_account_manager_set_online(manager, TRUE); --- a/libpurple/accounts.c Tue Mar 19 00:53:11 2024 -0500
+++ b/libpurple/accounts.c Tue Mar 19 01:00:48 2024 -0500
@@ -43,7 +43,10 @@
G_GNUC_UNUSED gpointer data)
- purple_accounts_restore_current_statuses();
+ PurpleAccountManager *manager = NULL; + manager = purple_account_manager_get_default(); + purple_account_manager_set_online(manager, TRUE); @@ -573,36 +576,6 @@
-purple_accounts_restore_current_status(PurpleAccount *account,
- G_GNUC_UNUSED gpointer data) {
- gboolean enabled = FALSE, online = FALSE;
- enabled = purple_account_get_enabled(account);
- online = purple_presence_is_online(purple_account_get_presence(account));
- if(enabled && online) {
- purple_account_connect(account);
-purple_accounts_restore_current_statuses(void) {
- PurpleAccountManager *manager = NULL;
- /* If we're not connected to the Internet right now, we bail on this */
- if (!purple_network_is_available()) {
- g_warning("Network not connected; skipping reconnect");
- manager = purple_account_manager_get_default();
- purple_account_manager_foreach(manager,
- purple_accounts_restore_current_status,
purple_accounts_get_handle(void)
--- a/libpurple/accounts.h Tue Mar 19 00:53:11 2024 -0500
+++ b/libpurple/accounts.h Tue Mar 19 01:00:48 2024 -0500
@@ -51,22 +51,6 @@
void purple_accounts_delete(PurpleAccount *account);
- * purple_accounts_restore_current_statuses:
- * This is called by the core after all subsystems and what
- * not have been initialized. It sets all enabled accounts
- * to their startup status by signing them on, setting them
- * You probably shouldn't call this unless you really know
-void purple_accounts_restore_current_statuses(void);
/**************************************************************************/
/**************************************************************************/
--- a/libpurple/purpleaccountmanager.c Tue Mar 19 00:53:11 2024 -0500
+++ b/libpurple/purpleaccountmanager.c Tue Mar 19 01:00:48 2024 -0500
@@ -28,6 +28,13 @@
#include "purpleaccount.h"
+static GParamSpec *properties[N_PROPERTIES] = {NULL, }; @@ -41,6 +48,7 @@
struct _PurpleAccountManager {
@@ -142,7 +150,41 @@
+purple_account_manager_get_property(GObject *obj, guint param_id, + GValue *value, GParamSpec *pspec) + PurpleAccountManager *manager = PURPLE_ACCOUNT_MANAGER(obj); + g_value_set_boolean(value, purple_account_manager_get_online(manager)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); +purple_account_manager_set_property(GObject *obj, guint param_id, + const GValue *value, GParamSpec *pspec) + PurpleAccountManager *manager = PURPLE_ACCOUNT_MANAGER(obj); + purple_account_manager_set_online(manager, g_value_get_boolean(value)); + G_OBJECT_WARN_INVALID_PROPERTY_ID(obj, param_id, pspec); purple_account_manager_init(PurpleAccountManager *manager) {
+ manager->online = FALSE; manager->accounts = g_ptr_array_new_full(0, (GDestroyNotify)g_object_unref);
@@ -151,6 +193,33 @@
GObjectClass *obj_class = G_OBJECT_CLASS(klass);
obj_class->finalize = purple_account_manager_finalize;
+ obj_class->get_property = purple_account_manager_get_property; + obj_class->set_property = purple_account_manager_set_property; + * PurpleAccountManager:online: + * Controls whether or not accounts that the manager knows about should be + * While this is set to %TRUE, any account added via + * [method@AccountManager.add] that has [property@Account:enabled] set to + * %TRUE, will automatically have [method@Account.connect] called on it. + * When this property changes, all accounts that the manager knows about + * with [property@Account:enabled] set to %TRUE will have + * [method@Account.connect] or [method@Account.disconnect] called on them + * to keep their state synchronized. + properties[PROP_ONLINE] = g_param_spec_boolean( + "Whether or not known accounts are online or offline.", + G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS); + g_object_class_install_properties(obj_class, N_PROPERTIES, properties); * PurpleAccountManager::added:
@@ -370,6 +439,10 @@
g_signal_emit(manager, signals[SIG_ADDED], 0, account);
g_list_model_items_changed(G_LIST_MODEL(manager), 0, 0, 1);
+ purple_account_connect(account); @@ -596,3 +669,56 @@
+purple_account_manager_get_online(PurpleAccountManager *manager) { + g_return_val_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager), FALSE); + return manager->online; +purple_account_manager_set_online(PurpleAccountManager *manager, + g_return_if_fail(PURPLE_IS_ACCOUNT_MANAGER(manager)); + if(manager->online == online) { + manager->online = online; + for(guint index = 0; index < manager->accounts->len; index++) { + PurpleAccount *account = g_ptr_array_index(manager->accounts, index); + PurplePresence *presence = NULL; + gboolean enabled = FALSE; + gboolean online = FALSE; + enabled = purple_account_get_enabled(account); + if(!purple_account_is_connected(account) && + !purple_account_is_connecting(account)) + presence = purple_account_get_presence(account); + online = purple_presence_is_online(presence); + purple_account_connect(account); + if(!purple_account_is_disconnected(account) && + !purple_account_is_disconnecting(account)) + purple_account_disconnect(account); + g_object_notify_by_pspec(G_OBJECT(manager), properties[PROP_ONLINE]); --- a/libpurple/purpleaccountmanager.h Tue Mar 19 00:53:11 2024 -0500
+++ b/libpurple/purpleaccountmanager.h Tue Mar 19 01:00:48 2024 -0500
@@ -222,6 +222,32 @@
void purple_account_manager_foreach(PurpleAccountManager *manager, PurpleAccountManagerForeachFunc callback, gpointer data);
+ * purple_account_manager_get_online: + * @manager: The instance. + * Gets whether or not new accounts should automatically have + * [method@Account.connect] called for them. + * Returns: %TRUE if @manager is online, otherwise %FALSE. +gboolean purple_account_manager_get_online(PurpleAccountManager *manager); + * purple_account_manager_set_online: + * @manager: The instance. + * Sets whether or not new accounts should automatically have + * [method@Account.connect] called for them. +void purple_account_manager_set_online(PurpleAccountManager *manager, gboolean online); #endif /* PURPLE_ACCOUNT_MANAGER_H */
--- a/pidgin/pidginapplication.c Tue Mar 19 00:53:11 2024 -0500
+++ b/pidgin/pidginapplication.c Tue Mar 19 01:00:48 2024 -0500
@@ -863,6 +863,8 @@
pidgin_debug_window_show();
+ manager = purple_account_manager_get_default(); /* Set all accounts to "offline" */
PurpleSavedStatus *saved_status;
@@ -884,10 +886,9 @@
purple_savedstatus_activate(purple_savedstatus_get_startup());
- purple_accounts_restore_current_statuses();
+ purple_account_manager_set_online(manager, TRUE); - manager = purple_account_manager_get_default();
active_accounts = purple_account_manager_get_enabled(manager);
if(active_accounts == NULL) {
g_action_group_activate_action(G_ACTION_GROUP(application),