telepathy-mission-control: Give account storage plugins a way to find out the GType for an attribute

Simon McVittie smcv at kemper.freedesktop.org
Wed Feb 13 06:18:21 PST 2013


Module: telepathy-mission-control
Branch: master
Commit: 7cf22355325f32bcf9898cfeb253390ed6624923
URL:    http://cgit.freedesktop.org/telepathy/telepathy-mission-control/commit/?id=7cf22355325f32bcf9898cfeb253390ed6624923

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Mon Sep 10 18:30:11 2012 +0100

Give account storage plugins a way to find out the GType for an attribute

---

 mission-control-plugins/account.c        |   25 +++++++++++++++++++++++++
 mission-control-plugins/account.h        |    5 +++++
 mission-control-plugins/implementation.h |    4 ++++
 src/mcd-storage.c                        |    9 +++++++++
 4 files changed, 43 insertions(+), 0 deletions(-)

diff --git a/mission-control-plugins/account.c b/mission-control-plugins/account.c
index 63892ed..931ed62 100644
--- a/mission-control-plugins/account.c
+++ b/mission-control-plugins/account.c
@@ -296,3 +296,28 @@ mcp_account_manager_unescape_value_from_keyfile (const McpAccountManager *mcpa,
 
   return iface->unescape_value_from_keyfile (mcpa, escaped, value, error);
 }
+
+/**
+ * mcp_account_manager_init_value_for_attribute:
+ * @mcpa: a #McpAccountManager
+ * @value: a zero-filled value to initialize
+ * @attribute: a supported Mission Control attribute
+ *
+ * If @attribute is a known Mission Control attribute, initialize @value
+ * with an appropriate type for @attribute and return %TRUE. Otherwise,
+ * return %FALSE.
+ *
+ * Returns: %TRUE if @value was initialized
+ */
+gboolean
+mcp_account_manager_init_value_for_attribute (const McpAccountManager *mcpa,
+    GValue *value,
+    const gchar *attribute)
+{
+  McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
+
+  g_return_val_if_fail (iface != NULL, FALSE);
+  g_return_val_if_fail (iface->init_value_for_attribute != NULL, FALSE);
+
+  return iface->init_value_for_attribute (mcpa, value, attribute);
+}
diff --git a/mission-control-plugins/account.h b/mission-control-plugins/account.h
index 7f670fd..05f3005 100644
--- a/mission-control-plugins/account.h
+++ b/mission-control-plugins/account.h
@@ -80,6 +80,11 @@ gboolean mcp_account_manager_unescape_value_from_keyfile (
     GValue *value,
     GError **error);
 
+gboolean mcp_account_manager_init_value_for_attribute (
+    const McpAccountManager *mcpa,
+    GValue *value,
+    const gchar *attribute);
+
 G_END_DECLS
 
 #endif
diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h
index 2924f44..6cbf7a9 100644
--- a/mission-control-plugins/implementation.h
+++ b/mission-control-plugins/implementation.h
@@ -112,6 +112,10 @@ struct _McpAccountManagerIface {
       const gchar *escaped,
       GValue *value,
       GError **error);
+
+  gboolean (* init_value_for_attribute) (const McpAccountManager *mcpa,
+      GValue *value,
+      const gchar *attribute);
 };
 
 G_END_DECLS
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index c63a791..693d358 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -391,6 +391,14 @@ mcd_storage_init_value_for_attribute (GValue *value,
   return FALSE;
 }
 
+static gboolean
+mcpa_init_value_for_attribute (const McpAccountManager *mcpa,
+    GValue *value,
+    const gchar *attribute)
+{
+  return mcd_storage_init_value_for_attribute (value, attribute);
+}
+
 static void
 set_value (const McpAccountManager *ma,
     const gchar *account,
@@ -1929,6 +1937,7 @@ plugin_iface_init (McpAccountManagerIface *iface,
   iface->list_keys = list_keys;
   iface->escape_value_for_keyfile = mcpa_escape_value_for_keyfile;
   iface->unescape_value_from_keyfile = mcpa_unescape_value_from_keyfile;
+  iface->init_value_for_attribute = mcpa_init_value_for_attribute;
 }
 
 gboolean



More information about the telepathy-commits mailing list