]> git.0d.be Git - empathy.git/commitdiff
idle: wait for the account manager to be ready before setting initial state
authorJonny Lamb <jonny.lamb@collabora.co.uk>
Thu, 17 Sep 2009 22:43:00 +0000 (23:43 +0100)
committerJonny Lamb <jonny.lamb@collabora.co.uk>
Thu, 17 Sep 2009 22:55:12 +0000 (23:55 +0100)
Also, if we can get the global presence from the account manager
straight away (in _init), then don't bother signalling the
change. Otherwise, do signal the initial setting so things like the
presence chooser and status icon will be updated with the initial
presence.

Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
libempathy/empathy-idle.c

index b8c7784d704605ef5020dd704782dbf888c4cc64..64ec37001d55285eb00eb827a40078e056c015eb 100644 (file)
@@ -409,6 +409,27 @@ empathy_idle_class_init (EmpathyIdleClass *klass)
        g_type_class_add_private (object_class, sizeof (EmpathyIdlePriv));
 }
 
+static void
+account_manager_ready_cb (EmpathyAccountManager *account_manager,
+                         GParamSpec *pspec,
+                         EmpathyIdle *idle)
+{
+       EmpathyIdlePriv *priv;
+       TpConnectionPresenceType state;
+       gchar *status, *status_message;
+
+       priv = GET_PRIV (idle);
+
+       state = empathy_account_manager_get_global_presence (priv->manager,
+               &status, &status_message);
+
+       idle_presence_changed_cb (account_manager, state, status,
+               status_message, idle);
+
+       g_free (status);
+       g_free (status_message);
+}
+
 static void
 empathy_idle_init (EmpathyIdle *idle)
 {
@@ -419,8 +440,14 @@ empathy_idle_init (EmpathyIdle *idle)
        priv->is_idle = FALSE;
 
        priv->manager = empathy_account_manager_dup_singleton ();
-       priv->state = empathy_account_manager_get_global_presence (priv->manager,
-               NULL, &priv->status);
+
+       if (empathy_account_manager_is_ready (priv->manager)) {
+               priv->state = empathy_account_manager_get_global_presence (priv->manager,
+                       NULL, &priv->status);
+       } else {
+               g_signal_connect (priv->manager, "notify::ready",
+                       G_CALLBACK (account_manager_ready_cb), idle);
+       }
 
 
        g_signal_connect (priv->manager, "global-presence-changed",