]> git.0d.be Git - empathy.git/commitdiff
Track accounts created and destroyed from GOA
authorDanielle Madeley <danielle.madeley@collabora.co.uk>
Tue, 14 Jun 2011 17:37:30 +0000 (18:37 +0100)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Tue, 6 Sep 2011 05:37:07 +0000 (07:37 +0200)
goa-mc-plugin/mcp-account-manager-goa.c

index b0b86c58bcd1f748089021641bc6874665ac570c..5a20495328600b298cb806067cdc17f0906b1b23 100644 (file)
@@ -209,6 +209,32 @@ mcp_account_manager_goa_init (McpAccountManagerGoa *self)
   goa_client_new (NULL, _goa_client_new_cb, self);
 }
 
+static void
+_account_added_cb (GoaClient *client,
+    GoaObject *object,
+    McpAccountManagerGoa *self)
+{
+      GoaAccount *account = goa_object_peek_account (object);
+
+      _new_account (self, account);
+}
+
+static void
+_account_removed_cb (GoaClient *client,
+    GoaObject *object,
+    McpAccountManagerGoa *self)
+{
+  GoaAccount *account = goa_object_peek_account (object);
+  char *name = get_tp_account_name (account);
+
+  if (self->priv->ready)
+    g_signal_emit_by_name (self, "deleted", name);
+
+  g_hash_table_remove (self->priv->accounts, name);
+
+  g_free (name);
+}
+
 
 static void
 _goa_client_new_cb (GObject *obj,
@@ -232,14 +258,18 @@ _goa_client_new_cb (GObject *obj,
 
   for (ptr = accounts; ptr != NULL; ptr = ptr->next)
     {
-      GoaAccount *account = goa_object_get_account (ptr->data);
+      GoaAccount *account = goa_object_peek_account (ptr->data);
 
       _new_account (self, account);
     }
 
   g_list_free_full (accounts, g_object_unref);
 
-  /* FIXME: track accounts created/destroyed */
+  g_signal_connect (self->priv->client, "account-added",
+      G_CALLBACK (_account_added_cb), self);
+  g_signal_connect (self->priv->client, "account-removed",
+      G_CALLBACK (_account_removed_cb), self);
+  /* FIXME: do we need to support account-changed ? */
 }