summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-28 16:30:07 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2014-01-29 19:28:34 +0000
commit08ade738693e685d7de271792f605ebbc8af03df (patch)
tree698fba9bd671caa3ed2b25bcf68fc186febbf4b6
parent70272b8fd90c65700bd0f6a8d7a4cc3849d42e21 (diff)
McdAccountManagerDefault: opportunistically save parameters' types
-rw-r--r--src/mcd-account-manager-default.c23
-rw-r--r--tests/twisted/account-storage/load-keyfiles.py8
2 files changed, 10 insertions, 21 deletions
diff --git a/src/mcd-account-manager-default.c b/src/mcd-account-manager-default.c
index b79b6bba..e9f2bf20 100644
--- a/src/mcd-account-manager-default.c
+++ b/src/mcd-account-manager-default.c
@@ -203,27 +203,16 @@ set_parameter (McpAccountStorage *self,
old = g_hash_table_lookup (sa->parameters, parameter);
- if (old == NULL)
- {
- /* it might still be in untyped_parameters? */
- const gchar *escaped = g_hash_table_lookup (sa->untyped_parameters,
- parameter);
- gchar *new = mcp_account_manager_escape_variant_for_keyfile (
- am, val);
-
- if (!tp_strdiff (escaped, new))
- {
- g_free (new);
- return MCP_ACCOUNT_STORAGE_SET_RESULT_UNCHANGED;
- }
-
- g_free (new);
- }
- else if (g_variant_equal (old, val))
+ if (old != NULL && g_variant_equal (old, val))
{
return MCP_ACCOUNT_STORAGE_SET_RESULT_UNCHANGED;
}
+ /* We haven't checked whether it's in untyped_parameters with the
+ * same value - but if it is, we want to migrate it to parameters
+ * anyway (in order to record its type), so treat it as having
+ * actually changed. */
+
g_hash_table_remove (sa->untyped_parameters, parameter);
g_hash_table_insert (sa->parameters, g_strdup (parameter),
g_variant_ref (val));
diff --git a/tests/twisted/account-storage/load-keyfiles.py b/tests/twisted/account-storage/load-keyfiles.py
index 35280db2..1f4cd986 100644
--- a/tests/twisted/account-storage/load-keyfiles.py
+++ b/tests/twisted/account-storage/load-keyfiles.py
@@ -82,10 +82,10 @@ def test(q, bus, mc):
'protocol': <'fakeprotocol'>,
'DisplayName': <'Account in a low-priority location'>,
'AutomaticPresence': <(uint32 2, 'available', '')>,
-'KeyFileParameters': <{
- 'account': 'dontdivertlow@example.com',
- 'password': 'password_in_variant_file',
- 'snakes': '42'
+'Parameters': <{
+ 'account': <'dontdivertlow@example.com'>,
+ 'password': <'password_in_variant_file'>,
+ 'snakes': <uint32 42>
}>
}
""")