aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-01-11 23:59:45 +0800
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-01-12 00:04:47 +0800
commit2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df (patch)
treecb3c702f71fb3d7ffb4ce6560a85862f7782703b
parentefa437ce79b0df44f5595c6006a355a209b3608f (diff)
downloadgsoc2013-empathy-2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df.tar.gz
gsoc2013-empathy-2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df.tar.zst
gsoc2013-empathy-2de6e5e0bb4d5d6c68fc44bd4ac7e6c1949364df.zip
listen for the "account-validity-changed" so new account are added to the dispatcher (#605689)
-rw-r--r--libempathy/empathy-dispatcher.c35
1 files changed, 35 insertions, 0 deletions
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
@@ -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,