summaryrefslogtreecommitdiff
path: root/finch
diff options
context:
space:
mode:
authorElliott Sales de Andrade <quantum.analyst@gmail.com>2022-10-09 01:48:50 -0500
committerElliott Sales de Andrade <quantum.analyst@gmail.com>2022-10-09 01:48:50 -0500
commit981d5a8578f5083d347ce2b78d1fd296e7a1d7e3 (patch)
tree5fa87baf0ca592abd9dbf6f0711b746202be55f6 /finch
parent247dbf5382d2bc32c4d06903ce42588c6619c11b (diff)
downloadpidgin-981d5a8578f5083d347ce2b78d1fd296e7a1d7e3.tar.gz
Use PurpleAccountManager added/removed signals
Testing Done: Opened Pidgin and made sure there were no warnings about objects not existing in time for the new signal connections. Opened XMPP console and saw that the drop down updated when an XMPP account was added/removed. Reviewed at https://reviews.imfreedom.org/r/1913/
Diffstat (limited to 'finch')
-rw-r--r--finch/gntaccount.c31
-rw-r--r--finch/gntconn.c23
2 files changed, 27 insertions, 27 deletions
diff --git a/finch/gntaccount.c b/finch/gntaccount.c
index db14311220..2e2363b6d0 100644
--- a/finch/gntaccount.c
+++ b/finch/gntaccount.c
@@ -255,9 +255,9 @@ save_account_cb(AccountEditDialog *dialog)
}
}
- /* In case of a new account, the 'Accounts' window is updated from the account-added
- * callback. In case of changes in an existing account, we need to explicitly do it
- * here.
+ /* In case of a new account, the 'Accounts' window is updated from the
+ * 'added' callback. In case of changes in an existing account, we need to
+ * explicitly do it here.
*/
if (dialog->account != NULL && accounts.window) {
gnt_tree_change_text(GNT_TREE(accounts.tree), dialog->account,
@@ -861,7 +861,8 @@ finch_accounts_get_handle(void)
}
static void
-account_added_callback(PurpleAccount *account)
+account_added_callback(G_GNUC_UNUSED PurpleAccountManager *manager,
+ PurpleAccount *account, G_GNUC_UNUSED gpointer data)
{
if (accounts.window == NULL)
return;
@@ -870,7 +871,8 @@ account_added_callback(PurpleAccount *account)
}
static void
-account_removed_callback(PurpleAccount *account)
+account_removed_callback(G_GNUC_UNUSED PurpleAccountManager *manager,
+ PurpleAccount *account, G_GNUC_UNUSED gpointer data)
{
if (accounts.window == NULL)
return;
@@ -890,22 +892,23 @@ account_abled_cb(PurpleAccount *account, gpointer user_data)
void finch_accounts_init()
{
PurpleAccountManager *manager = NULL;
+ gpointer account_handle = NULL;
GList *iter;
- purple_signal_connect(purple_accounts_get_handle(), "account-added",
- finch_accounts_get_handle(), G_CALLBACK(account_added_callback),
- NULL);
- purple_signal_connect(purple_accounts_get_handle(), "account-removed",
- finch_accounts_get_handle(), G_CALLBACK(account_removed_callback),
- NULL);
- purple_signal_connect(purple_accounts_get_handle(), "account-disabled",
+ manager = purple_account_manager_get_default();
+ account_handle = purple_accounts_get_handle();
+
+ g_signal_connect(manager, "added", G_CALLBACK(account_added_callback),
+ NULL);
+ g_signal_connect(manager, "removed", G_CALLBACK(account_removed_callback),
+ NULL);
+ purple_signal_connect(account_handle, "account-disabled",
finch_accounts_get_handle(),
G_CALLBACK(account_abled_cb), GINT_TO_POINTER(FALSE));
- purple_signal_connect(purple_accounts_get_handle(), "account-enabled",
+ purple_signal_connect(account_handle, "account-enabled",
finch_accounts_get_handle(),
G_CALLBACK(account_abled_cb), GINT_TO_POINTER(TRUE));
- manager = purple_account_manager_get_default();
iter = purple_account_manager_get_all(manager);
if (iter) {
for (; iter; iter = iter->next) {
diff --git a/finch/gntconn.c b/finch/gntconn.c
index 52992ae40b..76ce20d5db 100644
--- a/finch/gntconn.c
+++ b/finch/gntconn.c
@@ -108,19 +108,12 @@ finch_connection_report_disconnect(PurpleConnection *gc, PurpleConnectionError r
}
static void
-account_removed_cb(PurpleAccount *account, gpointer user_data)
+account_removed_cb(G_GNUC_UNUSED PurpleAccountManager *manager,
+ PurpleAccount *account, G_GNUC_UNUSED gpointer data)
{
g_hash_table_remove(hash, account);
}
-static void *
-finch_connection_get_handle(void)
-{
- static int handle;
-
- return &handle;
-}
-
static PurpleConnectionUiOps ops = {
.report_disconnect = finch_connection_report_disconnect,
};
@@ -132,17 +125,21 @@ PurpleConnectionUiOps *finch_connections_get_ui_ops()
void finch_connections_init()
{
+ PurpleAccountManager *manager = purple_account_manager_get_default();
+
hash = g_hash_table_new_full(
g_direct_hash, g_direct_equal,
NULL, free_auto_recon);
- purple_signal_connect(purple_accounts_get_handle(), "account-removed",
- finch_connection_get_handle(),
- G_CALLBACK(account_removed_cb), NULL);
+ g_signal_connect(manager, "removed", G_CALLBACK(account_removed_cb), NULL);
}
void finch_connections_uninit()
{
- purple_signals_disconnect_by_handle(finch_connection_get_handle());
+ PurpleAccountManager *manager = purple_account_manager_get_default();
+
+ g_signal_handlers_disconnect_by_func(manager,
+ G_CALLBACK(account_removed_cb), NULL);
+
g_hash_table_destroy(hash);
}