telepathy-mission-control: McdStorage: include flagging-as-secret in update_storage()
Simon McVittie
smcv at kemper.freedesktop.org
Thu Oct 4 08:19:46 PDT 2012
Module: telepathy-mission-control
Branch: master
Commit: a04220ab092e417f451d8ce55839d60469238ed1
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=a04220ab092e417f451d8ce55839d60469238ed1
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Wed Sep 5 10:02:27 2012 +0100
McdStorage: include flagging-as-secret in update_storage()
This guarantees that we don't forget to flag things as secret, and also
avoids unnecessary indirection through the McpAccountManager vtable.
---
src/mcd-storage.c | 40 +++++++++++++++++++++-------------------
1 files changed, 21 insertions(+), 19 deletions(-)
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 0ab1ff2..4b199d0 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -203,15 +203,27 @@ is_secret (const McpAccountManager *ma,
}
static void
-make_secret (const McpAccountManager *ma,
+mcd_storage_make_secret (McdStorage *self,
const gchar *account,
const gchar *key)
{
- McdStorage *self = MCD_STORAGE (ma);
+ g_return_if_fail (MCD_IS_STORAGE (self));
+ g_return_if_fail (account != NULL);
+ g_return_if_fail (key != NULL);
+
DEBUG ("flagging %s.%s as secret", account, key);
+
g_key_file_set_boolean (self->secrets, account, key, TRUE);
}
+static void
+make_secret (const McpAccountManager *ma,
+ const gchar *account,
+ const gchar *key)
+{
+ mcd_storage_make_secret (MCD_STORAGE (ma), account, key);
+}
+
static gchar *
unique_name (const McpAccountManager *ma,
const gchar *manager,
@@ -726,13 +738,17 @@ mcd_storage_get_integer (McdStorage *self,
static void
update_storage (McdStorage *self,
const gchar *account,
- const gchar *key)
+ const gchar *key,
+ gboolean secret)
{
GList *store;
gboolean done = FALSE;
McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
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: */
@@ -803,14 +819,7 @@ mcd_storage_set_string (McdStorage *self,
if (tp_strdiff (old, val))
{
- if (secret)
- {
- McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
-
- mcp_account_manager_parameter_make_secret (ma, account, key);
- }
-
- update_storage (self, account, key);
+ update_storage (self, account, key, secret);
updated = TRUE;
}
@@ -935,14 +944,7 @@ mcd_storage_set_value (McdStorage *self,
if (tp_strdiff (old, new))
{
- if (secret)
- {
- McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
-
- mcp_account_manager_parameter_make_secret (ma, name, key);
- }
-
- update_storage (self, name, key);
+ update_storage (self, name, key, secret);
updated = TRUE;
}
More information about the telepathy-commits
mailing list