summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVivek Dasmohapatra <vivek@collabora.co.uk>2010-09-14 13:57:30 +0100
committerVivek Dasmohapatra <vivek@collabora.co.uk>2010-09-14 13:57:30 +0100
commit50d0d448c136987956c73a86269faba22d0fa9b0 (patch)
tree1dbff68e0eeaa6ce32f257e8b2a493820b2c0039
parent54404bcf80722c6a875cdeabc851ade29d59ef80 (diff)
downloadtelepathy-mission-control-50d0d448c136987956c73a86269faba22d0fa9b0.tar.gz
Reverse the decision about which layer does escaping/unescaping
We now do the escaping/unescaping in the plugin-account layer (McdStorage interface), while the storage plugins just accept whatever they're given.
-rw-r--r--src/mcd-account-manager-default.c10
-rw-r--r--src/plugin-account.c31
-rw-r--r--test/twisted/mcp-account-diversion.c6
3 files changed, 26 insertions, 21 deletions
diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c
index 2c130954..7cfdd2aa 100644
--- a/src/mcd-account-manager-default.c
+++ b/src/mcd-account-manager-default.c
@@ -409,7 +409,7 @@ _set (const McpAccountStorage *self,
if (mcp_account_manager_parameter_is_secret (am, account, key))
g_key_file_set_value (amd->secrets, account, key, val);
else
- g_key_file_set_string (amd->keyfile, account, key, val);
+ g_key_file_set_value (amd->keyfile, account, key, val);
/* if we removed the account before, it now exists again, so... */
g_hash_table_remove (amd->removed_accounts, account);
@@ -418,7 +418,7 @@ _set (const McpAccountStorage *self,
g_key_file_remove_key (amd->removed, account, key, NULL);
#else
- g_key_file_set_string (amd->keyfile, account, key, val);
+ g_key_file_set_value (amd->keyfile, account, key, val);
#endif
@@ -443,9 +443,9 @@ _get (const McpAccountStorage *self,
/* fall back to public source if secret was not in keyring */
if (v == NULL)
- v = g_key_file_get_string (amd->keyfile, account, key, NULL);
+ v = g_key_file_get_value (amd->keyfile, account, key, NULL);
#else
- v = g_key_file_get_string (amd->keyfile, account, key, NULL);
+ v = g_key_file_get_value (amd->keyfile, account, key, NULL);
#endif
if (v == NULL)
@@ -465,7 +465,7 @@ _get (const McpAccountStorage *self,
for (i = 0; i < n; i++)
{
- gchar *v = g_key_file_get_string (amd->keyfile, account, keys[i], NULL);
+ gchar *v = g_key_file_get_value (amd->keyfile, account, keys[i], NULL);
if (v != NULL)
mcp_account_manager_set_value (am, account, keys[i], v);
diff --git a/src/plugin-account.c b/src/plugin-account.c
index 26d459ca..d278b8e1 100644
--- a/src/plugin-account.c
+++ b/src/plugin-account.c
@@ -422,7 +422,7 @@ _storage_dup_string (McdStorage *storage,
gchar *value = NULL;
McdPluginAccountManager *self = MCD_PLUGIN_ACCOUNT_MANAGER (storage);
- value = g_key_file_get_value (self->keyfile, account, key, NULL);
+ value = g_key_file_get_string (self->keyfile, account, key, NULL);
return value;
}
@@ -455,7 +455,7 @@ _storage_dup_value (McdStorage *storage,
switch (type)
{
case G_TYPE_STRING:
- v_string = g_key_file_get_value (keyfile, account, key, error);
+ v_string = g_key_file_get_string (keyfile, account, key, error);
value = tp_g_value_slice_new_take_string (v_string);
break;
@@ -521,7 +521,7 @@ _storage_dup_value (McdStorage *storage,
}
else if (type == DBUS_TYPE_G_OBJECT_PATH)
{
- v_string = g_key_file_get_value (keyfile, account, key, error);
+ v_string = g_key_file_get_string (keyfile, account, key, error);
if (!tp_dbus_check_valid_object_path (v_string, NULL))
{
@@ -571,12 +571,17 @@ _storage_get_integer (McdStorage *storage,
static void
update_storage (McdPluginAccountManager *self,
const gchar *account,
- const gchar *key,
- const gchar *val)
+ const gchar *key)
{
GList *store;
gboolean done = FALSE;
McpAccountManager *ma = MCP_ACCOUNT_MANAGER (self);
+ gchar *val = NULL;
+
+ /* 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: */
+ val = g_key_file_get_value (self->keyfile, account, key, NULL);
/* we're deleting, which is unconditional, no need to check if anyone *
* claims this setting for themselves */
@@ -611,12 +616,12 @@ _storage_set_string (McdStorage *storage,
{
McdPluginAccountManager *self = MCD_PLUGIN_ACCOUNT_MANAGER (storage);
gboolean updated = FALSE;
- gchar *old = g_key_file_get_value (self->keyfile, account, key, NULL);
+ gchar *old = g_key_file_get_string (self->keyfile, account, key, NULL);
if (val == NULL)
g_key_file_remove_key (self->keyfile, account, key, NULL);
else
- g_key_file_set_value (self->keyfile, account, key, val);
+ g_key_file_set_string (self->keyfile, account, key, val);
if (tp_strdiff (old, val))
{
@@ -627,7 +632,7 @@ _storage_set_string (McdStorage *storage,
mcp_account_manager_parameter_make_secret (ma, account, key);
}
- update_storage (self, account, key, val);
+ update_storage (self, account, key);
updated = TRUE;
}
@@ -654,7 +659,7 @@ _storage_set_value (McdStorage *storage,
gchar dbuf[G_ASCII_DTOSTR_BUF_SIZE] = { 0 };
gchar *buf = NULL;
const gchar *cbuf = NULL;
- gchar *old = g_key_file_get_value (self->keyfile, name, key, NULL);
+ gchar *old = g_key_file_get_string (self->keyfile, name, key, NULL);
switch (G_VALUE_TYPE (value))
{
@@ -703,11 +708,11 @@ _storage_set_value (McdStorage *storage,
(const gchar **)strings,
g_strv_length (strings));
- new = g_key_file_get_value (self->keyfile, name, key, NULL);
+ new = g_key_file_get_string (self->keyfile, name, key, NULL);
if (tp_strdiff (old, new))
{
- update_storage (self, name, key, new);
+ update_storage (self, name, key);
updated = TRUE;
}
@@ -732,7 +737,7 @@ _storage_set_value (McdStorage *storage,
{
if (tp_strdiff (old, cbuf))
{
- g_key_file_set_value (self->keyfile, name, key, cbuf);
+ g_key_file_set_string (self->keyfile, name, key, cbuf);
if (secret)
{
@@ -741,7 +746,7 @@ _storage_set_value (McdStorage *storage,
mcp_account_manager_parameter_make_secret (ma, name, key);
}
- update_storage (self, name, key, cbuf);
+ update_storage (self, name, key);
updated = TRUE;
}
}
diff --git a/test/twisted/mcp-account-diversion.c b/test/twisted/mcp-account-diversion.c
index 67d6a688..011f6e4b 100644
--- a/test/twisted/mcp-account-diversion.c
+++ b/test/twisted/mcp-account-diversion.c
@@ -118,7 +118,7 @@ _set (const McpAccountStorage *self,
AccountDiversionPlugin *adp = ACCOUNT_DIVERSION_PLUGIN (self);
adp->save = TRUE;
- g_key_file_set_string (adp->keyfile, account, key, val);
+ g_key_file_set_value (adp->keyfile, account, key, val);
return TRUE;
}
@@ -133,7 +133,7 @@ _get (const McpAccountStorage *self,
if (key != NULL)
{
- gchar *v = g_key_file_get_string (adp->keyfile, account, key, NULL);
+ gchar *v = g_key_file_get_value (adp->keyfile, account, key, NULL);
if (v == NULL)
return FALSE;
@@ -152,7 +152,7 @@ _get (const McpAccountStorage *self,
for (i = 0; i < n; i++)
{
- gchar *v = g_key_file_get_string (adp->keyfile, account, keys[i], NULL);
+ gchar *v = g_key_file_get_value (adp->keyfile, account, keys[i], NULL);
if (v != NULL)
mcp_account_manager_set_value (am, account, keys[i], v);