telepathy-mission-control: Make sure to not delete() nor commit() and account deleted from storage

Xavier Claessens xclaesse at kemper.freedesktop.org
Mon Nov 11 08:01:15 PST 2013


Module: telepathy-mission-control
Branch: master
Commit: 6ebcb0f048fcf0107c6d7deb99a7f4717467561a
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=6ebcb0f048fcf0107c6d7deb99a7f4717467561a

Author: Xavier Claessens <xavier.claessens at collabora.co.uk>
Date:   Fri Nov  8 17:12:06 2013 -0500

Make sure to not delete() nor commit() and account deleted from storage

If it is the storage plugin informing MC that the account has been
deleted, we can assume that the storage will already take care of
removing all information.

---

 mission-control-plugins/account-storage.c |    5 ++++-
 src/mcd-account-manager.c                 |    2 +-
 src/mcd-account.c                         |    5 +++--
 src/mcd-storage.c                         |    7 +++++--
 src/mcd-storage.h                         |    6 +++++-
 5 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/mission-control-plugins/account-storage.c b/mission-control-plugins/account-storage.c
index a5b89f0..dd478d8 100644
--- a/mission-control-plugins/account-storage.c
+++ b/mission-control-plugins/account-storage.c
@@ -261,8 +261,11 @@ class_init (gpointer klass,
    * Emitted if an external entity deletes an account
    * in the backend the emitting plugin handles.
    *
-   * Should not be fired until mcp_account_storage_ready() has been called
+   * Should not be fired until mcp_account_storage_ready() has been called.
    *
+   * mcp_account_storage_commit() and mcp_account_storage_delete() won't be
+   * called for this account, it is assumed that the storage backend already
+   * deleted all the related information.
    */
   signals[DELETED] = g_signal_new ("deleted",
       type, G_SIGNAL_RUN_LAST, 0, NULL, NULL,
diff --git a/src/mcd-account-manager.c b/src/mcd-account-manager.c
index 822058a..8495d44 100644
--- a/src/mcd-account-manager.c
+++ b/src/mcd-account-manager.c
@@ -569,7 +569,7 @@ on_account_removed (McdAccount *account, McdAccountManager *account_manager)
     name = mcd_account_get_unique_name (account);
     g_hash_table_remove (priv->accounts, name);
 
-    mcd_storage_delete_account (storage, name);
+    mcd_storage_delete_account (storage, name, MCD_DBUS_PROP_SET_FLAG_NONE);
     mcd_account_manager_write_conf_async (account_manager, account, NULL,
                                           NULL);
 }
diff --git a/src/mcd-account.c b/src/mcd-account.c
index 752e926..12e1513 100644
--- a/src/mcd-account.c
+++ b/src/mcd-account.c
@@ -733,7 +733,7 @@ mcd_account_delete (McdAccount *account,
         return;
     }
 
-    mcd_storage_delete_account (priv->storage, name);
+    mcd_storage_delete_account (priv->storage, name, flags);
 
     data_dir_str = get_old_account_data_path (priv);
 
@@ -760,7 +760,8 @@ mcd_account_delete (McdAccount *account,
         g_free (data_dir_str);
     }
 
-    mcd_storage_commit (priv->storage, name);
+    if ((flags & MCD_DBUS_PROP_SET_FLAG_ALREADY_IN_STORAGE) == 0)
+      mcd_storage_commit (priv->storage, name);
 
     if (callback != NULL)
         callback (account, NULL, user_data);
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 37b1c26..f83f1b4 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -1971,7 +1971,8 @@ mcd_storage_create_account (McdStorage *self,
  */
 void
 mcd_storage_delete_account (McdStorage *self,
-    const gchar *account)
+    const gchar *account,
+    McdDBusPropSetFlags flags)
 {
   McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
   McdStorageAccount *sa;
@@ -1982,7 +1983,9 @@ mcd_storage_delete_account (McdStorage *self,
   sa = lookup_account (self, account);
   g_return_if_fail (sa != NULL);
 
-  mcp_account_storage_delete (sa->storage, ma, account, NULL);
+  if ((flags & MCD_DBUS_PROP_SET_FLAG_ALREADY_IN_STORAGE) == 0)
+    mcp_account_storage_delete (sa->storage, ma, account, NULL);
+
   g_hash_table_remove (self->accounts, account);
 }
 
diff --git a/src/mcd-storage.h b/src/mcd-storage.h
index eb2ce36..0ea52eb 100644
--- a/src/mcd-storage.h
+++ b/src/mcd-storage.h
@@ -22,6 +22,8 @@
 #include <glib-object.h>
 #include <mission-control-plugins/mission-control-plugins.h>
 
+#include <src/mcd-dbusprop.h>
+
 #ifndef MCD_STORAGE_H
 #define MCD_STORAGE_H
 
@@ -97,7 +99,9 @@ gchar *mcd_storage_create_account (McdStorage *storage,
     const gchar *identification,
     GError **error);
 
-void mcd_storage_delete_account (McdStorage *storage, const gchar *account);
+void mcd_storage_delete_account (McdStorage *storage,
+    const gchar *account,
+    McdDBusPropSetFlags flags);
 
 void mcd_storage_commit (McdStorage *storage, const gchar *account);
 



More information about the telepathy-commits mailing list