From 2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df Mon Sep 17 00:00:00 2001 From: Guillaume Desmottes Date: Mon, 11 Jan 2010 15:59:45 +0000 Subject: listen for the "account-validity-changed" so new account are added to the dispatcher (#605689) --- libempathy/empathy-dispatcher.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'libempathy') diff --git a/libempathy/empathy-dispatcher.c b/libempathy/empathy-dispatcher.c index 6337f5c50..7c0068ba6 100644 --- a/libempathy/empathy-dispatcher.c +++ b/libempathy/empathy-dispatcher.c @@ -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, -- cgit v1.2.3