telepathy-mission-control: McdStorage: in update_storage, take the escaped value as a parameter

Simon McVittie smcv at kemper.freedesktop.org
Wed Feb 13 06:18:21 PST 2013


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

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Sep 10 18:21:33 2012 +0100

McdStorage: in update_storage, take the escaped value as a parameter

This saves looking it up again.

Signed-off-by: Simon McVittie <simon.mcvittie at collabora.co.uk>

---

 src/mcd-storage.c |   26 +++++++++++---------------
 1 files changed, 11 insertions(+), 15 deletions(-)

diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 9f5d2b2..2ca63fb 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -1086,27 +1086,19 @@ static void
 update_storage (McdStorage *self,
     const gchar *account,
     const gchar *key,
+    const gchar *escaped,
     gboolean secret)
 {
   GList *store;
   gboolean done = FALSE;
   McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
-  const gchar *val = NULL;
 
   if (secret)
     mcd_storage_make_secret (self, account, key);
 
-  /* don't unescape the value here, we're flushing it to storage         *
-   * everywhere else should handle escaping on the way in and unescaping *
-   * on the way out of the keyfile, but not here:                        */
-  if (g_str_has_prefix (key, "param-"))
-    val = mcd_storage_get_escaped_parameter (self, account, key + 6);
-  else
-    val = mcd_storage_get_escaped_attribute (self, account, key);
-
   /* we're deleting, which is unconditional, no need to check if anyone *
    * claims this setting for themselves                                 */
-  if (val == NULL)
+  if (escaped == NULL)
     done = TRUE;
 
   for (store = stores; store != NULL; store = g_list_next (store))
@@ -1121,7 +1113,7 @@ update_storage (McdStorage *self,
         }
       else
         {
-          done = mcp_account_storage_set (plugin, ma, account, key, val);
+          done = mcp_account_storage_set (plugin, ma, account, key, escaped);
           DEBUG ("MCP:%s -> %s %s.%s",
               pn, done ? "store" : "ignore", account, key);
         }
@@ -1214,9 +1206,11 @@ mcd_storage_set_attribute (McdStorage *self,
       if (escaped == NULL)
         g_hash_table_remove (sa->attributes, attribute);
       else
-        g_hash_table_insert (sa->attributes, g_strdup (attribute), escaped);
+        g_hash_table_insert (sa->attributes, g_strdup (attribute),
+            g_strdup (escaped));
 
-      update_storage (self, account, attribute, FALSE);
+      update_storage (self, account, attribute, escaped, FALSE);
+      g_free (escaped);
       return TRUE;
     }
   else
@@ -1270,10 +1264,12 @@ mcd_storage_set_parameter (McdStorage *self,
       if (escaped == NULL)
         g_hash_table_remove (sa->parameters, parameter);
       else
-        g_hash_table_insert (sa->parameters, g_strdup (parameter), escaped);
+        g_hash_table_insert (sa->parameters, g_strdup (parameter),
+            g_strdup (escaped));
 
       g_snprintf (key, sizeof (key), "param-%s", parameter);
-      update_storage (self, account, key, secret);
+      update_storage (self, account, key, escaped, secret);
+      g_free (escaped);
       return TRUE;
     }
   else



More information about the telepathy-commits mailing list