From 08ade738693e685d7de271792f605ebbc8af03df Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 28 Jan 2014 16:30:07 +0000 Subject: McdAccountManagerDefault: opportunistically save parameters' types --- src/mcd-account-manager-default.c | 23 ++++++----------------- tests/twisted/account-storage/load-keyfiles.py | 8 ++++---- 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': }> } """) -- cgit v1.2.3