[gnome-online-accounts] tplinker: check for GOA accounts with no corresponding Telepathy account



commit 63f62bebd1f28ee91170e83561116bb1d07f71fc
Author: Marco Barisione <marco barisione collabora co uk>
Date:   Thu Jul 18 16:40:50 2013 +0100

    tplinker: check for GOA accounts with no corresponding Telepathy account
    
    A Telepathy account could be deleted while goa-daemon is not running, so
    we need to check for that and delete the GOA account too.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=696267

 src/daemon/goatpaccountlinker.c |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)
---
diff --git a/src/daemon/goatpaccountlinker.c b/src/daemon/goatpaccountlinker.c
index e2a8a1a..665931d 100644
--- a/src/daemon/goatpaccountlinker.c
+++ b/src/daemon/goatpaccountlinker.c
@@ -329,6 +329,8 @@ start_if_ready (GoaTpAccountLinker *self)
   GList *goa_accounts = NULL;
   GList *tp_accounts = NULL;
   GList *l = NULL;
+  GHashTableIter iter;
+  gpointer key, value;
 
   if (priv->goa_client == NULL ||
       priv->account_manager == NULL ||
@@ -362,6 +364,25 @@ start_if_ready (GoaTpAccountLinker *self)
       G_CALLBACK (tp_account_validity_changed_cb), self, 0);
   g_signal_connect_object (priv->account_manager, "account-removed",
       G_CALLBACK (tp_account_removed_cb), self, 0);
+
+  /* Now we check if any Telepathy account was deleted while goa-daemon
+   * was not running. */
+  g_hash_table_iter_init (&iter, priv->goa_accounts);
+  while (g_hash_table_iter_next (&iter, &key, &value))
+    {
+      const gchar *id = key;
+      GoaObject *goa_object = value;
+
+      if (!g_hash_table_lookup (priv->tp_accounts, id))
+        {
+          goa_warning ("The Telepathy account %s was removed while the daemon "
+              "was not running, removing the corresponding GOA account", id);
+          goa_account_call_remove (goa_object_peek_account (goa_object),
+              NULL, /* cancellable */
+              goa_account_removed_by_us_cb,
+              NULL); /* user data */
+        }
+    }
 }
 
 static void


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