telepathy-mission-control: mcp_account_manager_escape_variant_for_keyfile: add to plugin API
Simon McVittie
smcv at kemper.freedesktop.org
Wed Feb 13 06:23:50 PST 2013
Module: telepathy-mission-control
Branch: master
Commit: fb470a3a8bde4e2bf07cf93722daa016a6344c2c
URL: http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=fb470a3a8bde4e2bf07cf93722daa016a6344c2c
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date: Wed Sep 12 13:19:57 2012 +0100
mcp_account_manager_escape_variant_for_keyfile: add to plugin API
---
mission-control-plugins/account.c | 30 ++++++++++++++++++++++++++++++
mission-control-plugins/account.h | 4 ++++
mission-control-plugins/implementation.h | 3 +++
src/mcd-storage.c | 8 ++++++++
4 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/mission-control-plugins/account.c b/mission-control-plugins/account.c
index 931ed62..32f6033 100644
--- a/mission-control-plugins/account.c
+++ b/mission-control-plugins/account.c
@@ -267,6 +267,36 @@ mcp_account_manager_escape_value_for_keyfile (const McpAccountManager *mcpa,
}
/**
+ * mcp_account_manager_escape_variant_for_keyfile:
+ * @mcpa: a #McpAccountManager
+ * @variant: a #GVariant with a supported #GVariantType
+ *
+ * Escape @variant so it could be passed to g_key_file_set_value().
+ * For instance, escaping the boolean value TRUE returns "true",
+ * and escaping the string value containing one space returns "\s".
+ *
+ * It is a programming error to use an unsupported type.
+ * The supported types are currently %G_VARIANT_TYPE_STRING,
+ * %G_VARIANT_TYPE_BOOLEAN, %G_VARIANT_TYPE_INT32, %G_VARIANT_TYPE_UINT32,
+ * %G_VARIANT_TYPE_INT64, %G_VARIANT_TYPE_UINT64, %G_VARIANT_TYPE_BYTE,
+ * %G_VARIANT_TYPE_STRING_ARRAY, %G_VARIANT_TYPE_OBJECT_PATH and
+ * %G_VARIANT_TYPE_OBJECT_PATH_ARRAY.
+ *
+ * Returns: (transfer full): the escaped form of @variant
+ */
+gchar *
+mcp_account_manager_escape_variant_for_keyfile (const McpAccountManager *mcpa,
+ GVariant *variant)
+{
+ McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
+
+ g_return_val_if_fail (iface != NULL, NULL);
+ g_return_val_if_fail (iface->escape_variant_for_keyfile != NULL, NULL);
+
+ return iface->escape_variant_for_keyfile (mcpa, variant);
+}
+
+/**
* mcp_account_manager_unescape_value_from_keyfile:
* @mcpa: a #McpAccountManager
* @escaped: an escaped string as returned by g_key_file_get_value()
diff --git a/mission-control-plugins/account.h b/mission-control-plugins/account.h
index 05f3005..4536ab1 100644
--- a/mission-control-plugins/account.h
+++ b/mission-control-plugins/account.h
@@ -74,6 +74,10 @@ gchar *mcp_account_manager_escape_value_for_keyfile (
const McpAccountManager *mcpa,
const GValue *value);
+gchar *mcp_account_manager_escape_variant_for_keyfile (
+ const McpAccountManager *mcpa,
+ GVariant *variant);
+
gboolean mcp_account_manager_unescape_value_from_keyfile (
const McpAccountManager *mcpa,
const gchar *escaped,
diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h
index 6cbf7a9..eb85720 100644
--- a/mission-control-plugins/implementation.h
+++ b/mission-control-plugins/implementation.h
@@ -116,6 +116,9 @@ struct _McpAccountManagerIface {
gboolean (* init_value_for_attribute) (const McpAccountManager *mcpa,
GValue *value,
const gchar *attribute);
+
+ gchar * (* escape_variant_for_keyfile) (const McpAccountManager *mcpa,
+ GVariant *variant);
};
G_END_DECLS
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 0117f6e..6b5e5e6 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -1568,6 +1568,13 @@ mcd_keyfile_escape_value (const GValue *value)
return ret;
}
+static gchar *
+mcpa_escape_variant_for_keyfile (const McpAccountManager *unused G_GNUC_UNUSED,
+ GVariant *variant)
+{
+ return mcd_keyfile_escape_variant (variant);
+}
+
/*
* mcd_keyfile_set_value:
* @keyfile: a keyfile
@@ -1936,6 +1943,7 @@ plugin_iface_init (McpAccountManagerIface *iface,
iface->unique_name = unique_name;
iface->list_keys = list_keys;
iface->escape_value_for_keyfile = mcpa_escape_value_for_keyfile;
+ iface->escape_variant_for_keyfile = mcpa_escape_variant_for_keyfile;
iface->unescape_value_from_keyfile = mcpa_unescape_value_from_keyfile;
iface->init_value_for_attribute = mcpa_init_value_for_attribute;
}
More information about the telepathy-commits
mailing list