]> git.0d.be Git - empathy.git/commitdiff
listen for the "account-validity-changed" so new account are added to the dispatcher...
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 11 Jan 2010 15:59:45 +0000 (15:59 +0000)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Mon, 11 Jan 2010 16:04:47 +0000 (16:04 +0000)
libempathy/empathy-dispatcher.c

index 6337f5c50b772bc06499d574b404b401d8003377..7c0068ba6c7319174049d90dc009693023c8f606 100644 (file)
@@ -1197,6 +1197,37 @@ account_manager_prepared_cb (GObject *source_object,
   g_list_free (accounts);
 }
 
+static void
+account_prepare_cb (GObject *source_object,
+    GAsyncResult *result,
+    gpointer user_data)
+{
+  EmpathyDispatcher *self = user_data;
+  TpAccount *account = TP_ACCOUNT (source_object);
+  GError *error = NULL;
+
+  if (!tp_account_prepare_finish (account, result, &error))
+    {
+      DEBUG ("Failed to prepare account: %s", error->message);
+      g_error_free (error);
+      return;
+    }
+
+  connect_account (self, account);
+}
+
+static void
+account_validity_changed_cb (TpAccountManager *manager,
+    TpAccount *account,
+    gboolean valid,
+    gpointer user_data)
+{
+  if (!valid)
+    return;
+
+  tp_account_prepare_async (account, NULL, account_prepare_cb, user_data);
+}
+
 static void
 empathy_dispatcher_init (EmpathyDispatcher *self)
 {
@@ -1217,6 +1248,10 @@ empathy_dispatcher_init (EmpathyDispatcher *self)
   tp_account_manager_prepare_async (priv->account_manager, NULL,
       account_manager_prepared_cb, self);
 
+  empathy_signal_connect_weak (priv->account_manager,
+      "account-validity-changed", G_CALLBACK (account_validity_changed_cb),
+      G_OBJECT (self));
+
   priv->request_channel_class_async_ids = g_hash_table_new (g_direct_hash,
     g_direct_equal);
   priv->status_changed_handlers = g_hash_table_new (g_direct_hash,