diff options
author | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-16 01:19:31 +0800 |
---|---|---|
committer | Sjoerd Simons <sjoerd.simons@collabora.co.uk> | 2009-07-16 19:41:49 +0800 |
commit | 7cded0b0190dac119d3e7bb6882b2a2a93293db8 (patch) | |
tree | cc632260fc5b750f17699723b57de58463527f20 | |
parent | 17b571acbdbe5219c9b7c468006dda616cb7bb0a (diff) | |
download | gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar.gz gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar.bz2 gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar.lz gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar.xz gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.tar.zst gsoc2013-empathy-7cded0b0190dac119d3e7bb6882b2a2a93293db8.zip |
Add a concept of ready to the account manager
-rw-r--r-- | libempathy/empathy-account-manager.c | 74 | ||||
-rw-r--r-- | libempathy/empathy-account-manager.h | 2 |
2 files changed, 74 insertions, 2 deletions
diff --git a/libempathy/empathy-account-manager.c b/libempathy/empathy-account-manager.c index dc15651cb..ed24e0623 100644 --- a/libempathy/empathy-account-manager.c +++ b/libempathy/empathy-account-manager.c @@ -44,6 +44,7 @@ typedef struct { int connected; int connecting; gboolean dispose_run; + gboolean ready; TpProxySignalConnection *proxy_signal; TpAccountManager *tp_manager; TpDBusDaemon *dbus; @@ -68,6 +69,10 @@ enum { LAST_SIGNAL }; +enum { + PROP_READY = 1, +}; + static guint signals[LAST_SIGNAL]; static EmpathyAccountManager *manager_singleton = NULL; @@ -216,6 +221,32 @@ signal: } static void +empathy_account_manager_check_ready (EmpathyAccountManager *manager) +{ + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + GHashTableIter iter; + gpointer value; + + if (priv->ready) + return; + + g_hash_table_iter_init (&iter, priv->accounts); + while (g_hash_table_iter_next (&iter, NULL, &value)) + { + EmpathyAccount *account = EMPATHY_ACCOUNT (value); + gboolean ready; + + g_object_get (account, "ready", &ready, NULL); + + if (!ready) + return; + } + + priv->ready = TRUE; + g_object_notify (G_OBJECT (manager), "ready"); +} + +static void emp_account_ready_cb (GObject *obj, GParamSpec *spec, gpointer user_data) { EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (user_data); @@ -240,6 +271,8 @@ emp_account_ready_cb (GObject *obj, GParamSpec *spec, gpointer user_data) g_signal_connect (account, "presence-changed", G_CALLBACK (emp_account_presence_changed_cb), manager); + + empathy_account_manager_check_ready (manager); } static void @@ -263,7 +296,6 @@ account_manager_got_all_cb (TpProxy *proxy, accounts = tp_asv_get_boxed (properties, "ValidAccounts", EMPATHY_ARRAY_TYPE_OBJECT); - for (i = 0; i < accounts->len; i++) { EmpathyAccount *account; @@ -275,6 +307,8 @@ account_manager_got_all_cb (TpProxy *proxy, g_signal_connect (account, "notify::ready", G_CALLBACK (emp_account_ready_cb), manager); } + + empathy_account_manager_check_ready (manager); } static void @@ -392,6 +426,26 @@ do_constructor (GType type, } static void +do_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + EmpathyAccountManager *manager = EMPATHY_ACCOUNT_MANAGER (object); + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + + switch (prop_id) + { + case PROP_READY: + g_value_set_boolean (value, priv->ready); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) { GObjectClass *oclass = G_OBJECT_CLASS (klass); @@ -399,6 +453,14 @@ empathy_account_manager_class_init (EmpathyAccountManagerClass *klass) oclass->finalize = do_finalize; oclass->dispose = do_dispose; oclass->constructor = do_constructor; + oclass->get_property = do_get_property; + + g_object_class_install_property (oclass, PROP_READY, + g_param_spec_boolean ("ready", + "Ready", + "Whether the initial state dump from the account manager is finished", + FALSE, + G_PARAM_STATIC_STRINGS | G_PARAM_READABLE)); signals[ACCOUNT_CREATED] = g_signal_new ("account-created", @@ -506,6 +568,15 @@ empathy_account_manager_create (EmpathyAccountManager *manager, return NULL; } + +gboolean +empathy_account_manager_is_ready (EmpathyAccountManager *manager) +{ + EmpathyAccountManagerPriv *priv = GET_PRIV (manager); + + return priv->ready; +} + int empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager) { @@ -689,4 +760,3 @@ empathy_account_manager_get_global_presence ( return priv->global_presence; } - diff --git a/libempathy/empathy-account-manager.h b/libempathy/empathy-account-manager.h index bbf091997..e77f5017e 100644 --- a/libempathy/empathy-account-manager.h +++ b/libempathy/empathy-account-manager.h @@ -58,6 +58,8 @@ EmpathyAccount * empathy_account_manager_create ( const gchar *protocol, const gchar *display_name); +gboolean empathy_account_manager_is_ready (EmpathyAccountManager *manager); + int empathy_account_manager_get_connected_accounts (EmpathyAccountManager *manager); int empathy_account_manager_get_connecting_accounts |