diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2013-11-12 16:00:31 +0000 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2014-01-29 19:28:29 +0000 |
commit | 65e376653dfea9d1b3712f8429b657f9d4338386 (patch) | |
tree | f74fb3d7dcdb2cc0e8b8d7ed095a073c40e237ba /tests/twisted | |
parent | 21ab80884868a065772297d31f8ce8ba0d30bb7b (diff) |
Remove mcp_account_storage_set()
_set_attribute() and _set_parameter() are now mandatory for writable
storage plugins.
Note that most of the keyfile escaping code is still needed to help
plugins to read their old keyfile values.
[adjusted to apply earlier in the branch; left in the code that
detects whether mcd_storage_set_parameter() is a no-op for an
escaped parameter; took out mcp_account_storage_emit_created
documentation fix -smcv]
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71384
Signed-off-by: Simon McVittie <simon.mcvittie@collabora.co.uk>
Diffstat (limited to 'tests/twisted')
-rw-r--r-- | tests/twisted/dbus-account-plugin.c | 13 | ||||
-rw-r--r-- | tests/twisted/mcp-account-diversion.c | 48 |
2 files changed, 41 insertions, 20 deletions
diff --git a/tests/twisted/dbus-account-plugin.c b/tests/twisted/dbus-account-plugin.c index 0e94b9b3..016417a1 100644 --- a/tests/twisted/dbus-account-plugin.c +++ b/tests/twisted/dbus-account-plugin.c @@ -1087,18 +1087,6 @@ test_dbus_account_plugin_get (const McpAccountStorage *storage, } static gboolean -test_dbus_account_plugin_set (const McpAccountStorage *storage, - const McpAccountManager *am, - const gchar *account_name, - const gchar *key, - const gchar *value) -{ - /* Now that we implement set_attribute and set_parameter, this no longer - * needs a real implementation. */ - return FALSE; -} - -static gboolean test_dbus_account_plugin_set_attribute (McpAccountStorage *storage, McpAccountManager *am, const gchar *account_name, @@ -1585,7 +1573,6 @@ account_storage_iface_init (McpAccountStorageIface *iface) iface->priority = MCP_ACCOUNT_STORAGE_PLUGIN_PRIO_NORMAL + 100; iface->get = test_dbus_account_plugin_get; - iface->set = test_dbus_account_plugin_set; iface->set_attribute = test_dbus_account_plugin_set_attribute; iface->set_parameter = test_dbus_account_plugin_set_parameter; iface->list = test_dbus_account_plugin_list; diff --git a/tests/twisted/mcp-account-diversion.c b/tests/twisted/mcp-account-diversion.c index e36b1ac5..44fd4e3a 100644 --- a/tests/twisted/mcp-account-diversion.c +++ b/tests/twisted/mcp-account-diversion.c @@ -112,24 +112,57 @@ _create_config (void) } static gboolean -_set (const McpAccountStorage *self, - const McpAccountManager *am, - const gchar *account, - const gchar *key, - const gchar *val) +_set (McpAccountStorage *self, + McpAccountManager *am, + const gchar *account, + const gchar *key, + GVariant *val, + McpParameterFlags flags) { AccountDiversionPlugin *adp = ACCOUNT_DIVERSION_PLUGIN (self); + gchar *val_str; if (g_str_has_prefix (account, DONT_DIVERT)) return FALSE; adp->save = TRUE; - g_key_file_set_value (adp->keyfile, account, key, val); + + val_str = mcp_account_manager_escape_variant_for_keyfile (am, val); + g_key_file_set_value (adp->keyfile, account, key, val_str); + g_free (val_str); return TRUE; } static gboolean +_set_attribute (McpAccountStorage *self, + McpAccountManager *am, + const gchar *account, + const gchar *attribute, + GVariant *val, + McpAttributeFlags flags) +{ + return _set (self, am, account, attribute, val, flags); +} + +static gboolean +_set_parameter (McpAccountStorage *self, + McpAccountManager *am, + const gchar *account, + const gchar *parameter, + GVariant *val, + McpParameterFlags flags) +{ + gchar *param = g_strdup_printf ("param-%s", parameter); + gboolean ret; + + ret = _set (self, am, account, param, val, flags); + g_free (param); + + return ret; +} + +static gboolean _get (const McpAccountStorage *self, const McpAccountManager *am, const gchar *account, @@ -268,7 +301,8 @@ account_storage_iface_init (McpAccountStorageIface *iface, iface->priority = PLUGIN_PRIORITY; iface->get = _get; - iface->set = _set; + iface->set_attribute = _set_attribute; + iface->set_parameter = _set_parameter; iface->delete = _delete; iface->commit = _commit; iface->list = _list; |