[Pkg-telepathy-commits] [telepathy-mission-control-6] 191/280: McdStorage: when acting on one account, only store it in its plugin

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:22 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit 1e1ba5f4fef9ee83411d55e376f0f5fec0a6e892
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Thu Nov 14 16:51:37 2013 +0000

    McdStorage: when acting on one account, only store it in its plugin
    
    Bug: https://bugs.freedesktop.org/show_bug.cgi?id=27727
---
 src/mcd-storage.c | 68 +++++++++++++++++++++++++++++++++----------------------
 1 file changed, 41 insertions(+), 27 deletions(-)

diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index dffc498..07d07f3 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -1245,13 +1245,14 @@ update_storage (McdStorage *self,
     const gchar *key,
     GVariant *variant)
 {
-  GList *store;
   McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
   gboolean updated = FALSE;
+  McpAccountStorage *plugin;
 
-  for (store = stores; store != NULL; store = g_list_next (store))
+  plugin = g_hash_table_lookup (self->accounts, account);
+
+  if (plugin != NULL)
     {
-      McpAccountStorage *plugin = store->data;
       const gchar *pn = mcp_account_storage_name (plugin);
       McpAccountStorageSetResult res;
 
@@ -1268,8 +1269,6 @@ update_storage (McdStorage *self,
             DEBUG ("MCP:%s -> store %s %s.%s", pn,
                 parameter ? "parameter" : "attribute", account, key);
             updated = TRUE;
-            /* set it to NULL in all lower-priority stores */
-            variant = NULL;
             break;
 
           case MCP_ACCOUNT_STORAGE_SET_RESULT_FAILED:
@@ -1286,6 +1285,10 @@ update_storage (McdStorage *self,
             g_warn_if_reached ();
         }
     }
+  else
+    {
+      g_assert_not_reached ();
+    }
 
   return updated;
 }
@@ -1809,24 +1812,29 @@ void
 mcd_storage_delete_account (McdStorage *self,
     const gchar *account)
 {
-  GList *store;
   McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
+  McpAccountStorage *plugin;
 
   g_return_if_fail (MCD_IS_STORAGE (self));
   g_return_if_fail (account != NULL);
 
-  g_hash_table_remove (self->accounts, account);
+  plugin = g_hash_table_lookup (self->accounts, account);
 
-  for (store = stores; store != NULL; store = g_list_next (store))
+  if (plugin == NULL)
     {
-      McpAccountStorage *plugin = store->data;
-
-      /* FIXME: when we know which plugin owns the account, we can stop
-       * ignoring the error (if any), and make this method async
-       * in order to pass the error up to McdAccount */
-      mcp_account_storage_delete_async (plugin, ma, account,
-          delete_cb, g_strdup (account));
+      /* we wanted no account, we got no account, I call that success! */
+      return;
     }
+
+  g_object_ref (plugin);
+  g_hash_table_remove (self->accounts, account);
+
+  /* FIXME: stop ignoring the error (if any), and make this method async
+   * in order to pass the error up to McdAccount */
+  mcp_account_storage_delete_async (plugin, ma, account,
+      delete_cb, g_strdup (account));
+
+  g_object_unref (plugin);
 }
 
 /*
@@ -1842,24 +1850,30 @@ mcd_storage_commit (McdStorage *self, const gchar *account)
 {
   GList *store;
   McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
+  McpAccountStorage *plugin;
+  const gchar *pname;
 
   g_return_if_fail (MCD_IS_STORAGE (self));
 
+  if (account != NULL)
+    {
+      plugin = g_hash_table_lookup (self->accounts, account);
+      g_return_val_if_fail (plugin != NULL, FALSE);
+
+      pname = mcp_account_storage_name (plugin);
+
+      DEBUG ("flushing plugin %s %s to long term storage", pname, account);
+      mcp_account_storage_commit (plugin, ma, account);
+      return;
+    }
+
   for (store = stores; store != NULL; store = g_list_next (store))
     {
-      McpAccountStorage *plugin = store->data;
-      const gchar *pname = mcp_account_storage_name (plugin);
+      plugin = store->data;
+      pname = mcp_account_storage_name (plugin);
 
-      if (account != NULL)
-        {
-          DEBUG ("flushing plugin %s %s to long term storage", pname, account);
-          mcp_account_storage_commit (plugin, ma, account);
-        }
-      else
-        {
-          DEBUG ("flushing plugin %s to long term storage", pname);
-          mcp_account_storage_commit (plugin, ma, NULL);
-        }
+      DEBUG ("flushing plugin %s to long term storage", pname);
+      mcp_account_storage_commit (plugin, ma, NULL);
     }
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list