[empathy] listen for the "account-validity-changed" so new account are added to the dispatcher (#605689)



commit 2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Mon Jan 11 15:59:45 2010 +0000

    listen for the "account-validity-changed" so new account are added to the dispatcher (#605689)

 libempathy/empathy-dispatcher.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c
index 6337f5c..7c0068b 100644
--- a/libempathy/empathy-dispatcher.c
+++ b/libempathy/empathy-dispatcher.c
@@ -1198,6 +1198,37 @@ account_manager_prepared_cb (GObject *source_object,
 }
 
 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)
 {
   EmpathyDispatcherPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (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,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]