gobjectification: 1d66e90f: Fixed the accounts initialization. purpl...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Tue Aug 10 09:12:26 EDT 2010
----------------------------------------------------------------------
Revision: 1d66e90f6c60ff6cac628cc5fbd0b4e764848cb6
Parent: 9d0c21345e0089f64bc3579cdfabb4a09fecc71f
Author: gillux at soc.pidgin.im
Date: 08/10/10 08:49:39
Branch: im.pidgin.gobjectification
URL: http://d.pidgin.im/viewmtn/revision/info/1d66e90f6c60ff6cac628cc5fbd0b4e764848cb6
Changelog:
Fixed the accounts initialization. purple_account_init() now creates the
PurpleAccount gobjects, needed by others subsystems'initialization such as
blist.c or status.c. Then at the end of purple's initialization, the new
purple_accounts_activate() connects the enabled accounts.
Changes against parent 9d0c21345e0089f64bc3579cdfabb4a09fecc71f
patched libpurple/account.c
patched libpurple/accountlist.c
patched libpurple/accountlist.h
patched libpurple/core.c
-------------- next part --------------
============================================================
--- libpurple/core.c a3794f934664d7c44e575533700f73e45e1a9333
+++ libpurple/core.c bf7029818d2657d2ac94939b8a5e3bb0b7113388
@@ -185,7 +185,7 @@ purple_core_init(const char *ui)
/* The UI may have registered some theme types, so refresh them */
purple_theme_manager_refresh();
- purple_accounts_load();
+ purple_accounts_activate();
return TRUE;
}
============================================================
--- libpurple/account.c d2d7d7baddeb9a7df1992ac1cd2c9576d29e7ebf
+++ libpurple/account.c 59866a7cd413765192417473f2bda4a88edbdf51
@@ -1486,11 +1486,6 @@ purple_account_set_enabled(PurpleAccount
if ((gc != NULL) && (gc->wants_to_die == TRUE))
return;
#endif
-
- if (value && purple_presence_is_online(priv->presence))
- purple_account_connect(account);
- else if (!value && !purple_account_is_disconnected(account))
- purple_account_disconnect(account);
}
void
============================================================
--- libpurple/accountlist.c 14ee885a53cce0d7d9bff7c97091565f4f2d9379
+++ libpurple/accountlist.c df2072e0b055985656a2edf0b6f021c0ad2ee011
@@ -40,6 +40,7 @@ static struct {
gpointer n_handler;
gpointer d_handler;
+ gpointer enabled_handler;
} global;
static void
@@ -547,17 +548,13 @@ purple_accounts_init(void)
void
purple_accounts_init(void)
{
+ xmlnode *node, *child;
+
global.n_handler = purple_g_signal_connect(PURPLE_TYPE_ACCOUNT, "new",
G_CALLBACK(account_new_cb), NULL);
global.d_handler = purple_g_signal_connect(PURPLE_TYPE_ACCOUNT, "destroying",
G_CALLBACK(account_destroyed_cb), NULL);
-}
-void
-purple_accounts_load()
-{
- xmlnode *node, *child;
-
global.accounts_loaded = TRUE;
node = purple_util_read_xml_from_file("accounts.xml", _("accounts"));
@@ -574,6 +571,46 @@ purple_accounts_load()
_purple_buddy_icons_account_loaded_cb();
}
+/**
+ * A callback that aims to be called when an account is enabled or disabled.
+ * When we want the enabling of an account to connect it, we connect this
+ * callback to the "enable-changed" signal. We don't want this unless all the
+ * core subsystems are initialized.
+ * @see purple_accounts_activate()
+ */
+static void
+account_enabled_cb(PurpleAccount *account)
+{
+ PurplePresence *presence = purple_account_get_presence(account);
+ gboolean enabled = purple_account_get_enabled(account);
+
+ if (enabled && purple_presence_is_online(presence))
+ purple_account_connect(account);
+ else if (!enabled && !purple_account_is_disconnected(account))
+ purple_account_disconnect(account);
+}
+
+void
+purple_accounts_activate(void)
+{
+ GList *accounts = purple_accounts_all();
+
+ if (!global.enabled_handler)
+ global.enabled_handler = purple_g_signal_connect(PURPLE_TYPE_ACCOUNT,
+ "enable-changed", G_CALLBACK(account_enabled_cb), NULL);
+
+ /* Make the enabled accounts to connect, as if we ran
+ * purple_account_set_enabled(). */
+ while (accounts != NULL) {
+ PurpleAccount *account = accounts->data;
+
+ if (purple_account_get_enabled(account))
+ account_enabled_cb(account);
+
+ accounts = accounts->next;
+ }
+}
+
GList *
purple_accounts_all(void)
{
@@ -660,8 +697,10 @@ purple_accounts_uninit(void)
{
purple_g_signal_disconnect(global.n_handler);
purple_g_signal_disconnect(global.d_handler);
+ purple_g_signal_disconnect(global.enabled_handler);
global.n_handler = NULL;
global.d_handler = NULL;
+ global.enabled_handler = NULL;
}
============================================================
--- libpurple/accountlist.h d8a21627ffd59f76644de009353e09aca8a294a9
+++ libpurple/accountlist.h 5cb48138e5d48d6e9025cb943ed1798e386d2304
@@ -44,7 +44,12 @@ void purple_accounts_uninit(void);
*/
void purple_accounts_uninit(void);
-void purple_accounts_load(void);
+/**
+ * Connects the enabled accounts. This is used by purple in the account
+ * initialization process, if you want to enable an account use
+ * purple_account_set_enabled().
+ */
+void purple_accounts_activate(void);
/**
* Returns a list of all accounts.
More information about the Commits
mailing list