[Pkg-telepathy-commits] [telepathy-mission-control-6] 126/280: Revert "Remove unused code"

Simon McVittie smcv at debian.org
Thu Mar 27 20:07:13 UTC 2014


This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian
in repository telepathy-mission-control-6.

commit ff48fd06ff3984f7324354db78bda7d9818c731d
Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Tue Nov 12 15:37:19 2013 +0000

    Revert "Remove unused code"
    
    This reverts commit 8171d9e5bc8d4f47a36844afab0a6063b1958004.
---
 mission-control-plugins/account.c        | 109 +++++++++++++++++++++++++++++++
 mission-control-plugins/account.h        |  19 ++++++
 mission-control-plugins/implementation.h |  16 +++++
 src/mcd-storage.c                        |  76 +++++++++++++++++++++
 4 files changed, 220 insertions(+)

diff --git a/mission-control-plugins/account.c b/mission-control-plugins/account.c
index c9859d7..493a34c 100644
--- a/mission-control-plugins/account.c
+++ b/mission-control-plugins/account.c
@@ -191,6 +191,31 @@ mcp_account_manager_list_keys (const McpAccountManager *mcpa,
 }
 
 /**
+ * mcp_account_manager_get_value:
+ * @mcpa: an #McpAccountManager instance
+ * @account: the unique name of an account
+ * @key: the setting whose value we wish to fetch: either an attribute
+ *  like "DisplayName", or "param-" plus a parameter like "account"
+ *
+ * Fetch a copy of the current value of an account setting held by
+ * the account manager.
+ *
+ * Returns: (transfer full): the value of @key
+ */
+gchar *
+mcp_account_manager_get_value (const McpAccountManager *mcpa,
+    const gchar *account,
+    const gchar *key)
+{
+  McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
+
+  g_return_val_if_fail (iface != NULL, NULL);
+  g_return_val_if_fail (iface->set_value != NULL, NULL);
+
+  return iface->get_value (mcpa, account, key);
+}
+
+/**
  * mcp_account_manager_get_unique_name:
  * @mcpa: an #McpAccountManager instance
  * @manager: the name of the manager
@@ -267,6 +292,34 @@ mcp_account_manager_identify_account_finish (McpAccountManager *mcpa,
 }
 
 /**
+ * mcp_account_manager_escape_value_from_keyfile:
+ * @mcpa: a #McpAccountManager
+ * @value: a value with a supported #GType
+ *
+ * Escape @value 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_TYPE_STRING, %G_TYPE_BOOLEAN,
+ * %G_TYPE_INT, %G_TYPE_UINT, %G_TYPE_INT64, %G_TYPE_UINT64, %G_TYPE_UCHAR,
+ * %G_TYPE_STRV, %DBUS_TYPE_G_OBJECT_PATH and %TP_ARRAY_TYPE_OBJECT_PATH_LIST.
+ *
+ * Returns: the escaped form of @value
+ */
+gchar *
+mcp_account_manager_escape_value_for_keyfile (const McpAccountManager *mcpa,
+    const GValue *value)
+{
+  McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
+
+  g_return_val_if_fail (iface != NULL, NULL);
+  g_return_val_if_fail (iface->escape_value_for_keyfile != NULL, NULL);
+
+  return iface->escape_value_for_keyfile (mcpa, value);
+}
+
+/**
  * mcp_account_manager_escape_variant_for_keyfile:
  * @mcpa: a #McpAccountManager
  * @variant: a #GVariant with a supported #GVariantType
@@ -295,3 +348,59 @@ mcp_account_manager_escape_variant_for_keyfile (const McpAccountManager *mcpa,
 
   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()
+ * @value: a value to populate, with a supported #GType
+ * @error: used to raise an error if %FALSE is returned
+ *
+ * Attempt to interpret @escaped as a value of @value's type.
+ * If successful, put it in @value and return %TRUE.
+ *
+ * It is a programming error to try to escape an unsupported type.
+ * The supported types are currently %G_TYPE_STRING, %G_TYPE_BOOLEAN,
+ * %G_TYPE_INT, %G_TYPE_UINT, %G_TYPE_INT64, %G_TYPE_UINT64, %G_TYPE_UCHAR,
+ * %G_TYPE_STRV, %DBUS_TYPE_G_OBJECT_PATH and %TP_ARRAY_TYPE_OBJECT_PATH_LIST.
+ *
+ * Returns: %TRUE if @value was filled in
+ */
+gboolean
+mcp_account_manager_unescape_value_from_keyfile (const McpAccountManager *mcpa,
+    const gchar *escaped,
+    GValue *value,
+    GError **error)
+{
+  McpAccountManagerIface *iface = MCP_ACCOUNT_MANAGER_GET_IFACE (mcpa);
+
+  g_return_val_if_fail (iface != NULL, FALSE);
+  g_return_val_if_fail (iface->unescape_value_from_keyfile != NULL, FALSE);
+
+  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 4356b3c..c283ef9 100644
--- a/mission-control-plugins/account.h
+++ b/mission-control-plugins/account.h
@@ -62,6 +62,10 @@ void mcp_account_manager_set_parameter (const McpAccountManager *mcpa,
     GVariant *value,
     McpParameterFlags flags);
 
+gchar * mcp_account_manager_get_value (const McpAccountManager *mcpa,
+    const gchar *account,
+    const gchar *key);
+
 gchar * mcp_account_manager_get_unique_name (McpAccountManager *mcpa,
     const gchar *manager,
     const gchar *protocol,
@@ -70,10 +74,25 @@ gchar * mcp_account_manager_get_unique_name (McpAccountManager *mcpa,
 GStrv mcp_account_manager_list_keys (const McpAccountManager *mcpa,
     const gchar *account);
 
+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,
+    GValue *value,
+    GError **error);
+
+gboolean mcp_account_manager_init_value_for_attribute (
+    const McpAccountManager *mcpa,
+    GValue *value,
+    const gchar *attribute);
+
 void mcp_account_manager_identify_account_async (McpAccountManager *mcpa,
     const gchar *manager,
     const gchar *protocol,
diff --git a/mission-control-plugins/implementation.h b/mission-control-plugins/implementation.h
index 9d44b3b..9cc04b4 100644
--- a/mission-control-plugins/implementation.h
+++ b/mission-control-plugins/implementation.h
@@ -82,6 +82,10 @@ struct _McpAccountManagerIface {
       const gchar *key,
       const gchar *value);
 
+  gchar * (*get_value) (const McpAccountManager *ma,
+      const gchar *acct,
+      const gchar *key);
+
   gchar * (* unique_name) (const McpAccountManager *ma,
       const gchar *manager,
       const gchar *protocol,
@@ -90,6 +94,18 @@ struct _McpAccountManagerIface {
   GStrv (* list_keys) (const McpAccountManager *ma,
       const gchar *acct);
 
+  gchar * (* escape_value_for_keyfile) (const McpAccountManager *mcpa,
+      const GValue *value);
+
+  gboolean (* unescape_value_from_keyfile) (const McpAccountManager *mcpa,
+      const gchar *escaped,
+      GValue *value,
+      GError **error);
+
+  gboolean (* init_value_for_attribute) (const McpAccountManager *mcpa,
+      GValue *value,
+      const gchar *attribute);
+
   gchar * (* escape_variant_for_keyfile) (const McpAccountManager *mcpa,
       GVariant *variant);
 
diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 37b1c26..7fc7254 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -224,6 +224,54 @@ lookup_account (McdStorage *self,
   return g_hash_table_lookup (self->accounts, account);
 }
 
+static gchar *
+get_value (const McpAccountManager *ma,
+    const gchar *account,
+    const gchar *key)
+{
+  McdStorage *self = MCD_STORAGE (ma);
+  McdStorageAccount *sa = lookup_account (self, account);
+  GVariant *variant;
+  gchar *ret;
+
+  if (sa == NULL)
+    return NULL;
+
+  if (g_str_has_prefix (key, "param-"))
+    {
+      variant = g_hash_table_lookup (sa->parameters, key + 6);
+
+      if (variant != NULL)
+        {
+          ret = mcd_keyfile_escape_variant (variant);
+          g_variant_unref (variant);
+          return ret;
+        }
+      else
+        {
+          /* OK, we don't have it as a variant. How about the keyfile-escaped
+           * version? */
+          return g_strdup (g_hash_table_lookup (sa->escaped_parameters,
+                key + 6));
+        }
+    }
+  else
+    {
+      variant = g_hash_table_lookup (sa->attributes, key);
+
+      if (variant != NULL)
+        {
+          ret = mcd_keyfile_escape_variant (variant);
+          g_variant_unref (variant);
+          return ret;
+        }
+      else
+        {
+          return NULL;
+        }
+    }
+}
+
 static struct {
     const gchar *type;
     const gchar *name;
@@ -331,6 +379,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
 mcpa_set_attribute (const McpAccountManager *ma,
     const gchar *account,
@@ -936,6 +992,15 @@ mcd_storage_get_parameter (McdStorage *self,
   return mcd_keyfile_unescape_value (escaped, value, error);
 }
 
+static gboolean
+mcpa_unescape_value_from_keyfile (const McpAccountManager *unused G_GNUC_UNUSED,
+    const gchar *escaped,
+    GValue *value,
+    GError **error)
+{
+  return mcd_keyfile_unescape_value (escaped, value, error);
+}
+
 /*
  * @escaped: a keyfile-escaped string
  * @value: a #GValue initialized with a supported #GType
@@ -1627,6 +1692,13 @@ mcd_storage_set_parameter (McdStorage *self,
   return updated;
 }
 
+static gchar *
+mcpa_escape_value_for_keyfile (const McpAccountManager *unused G_GNUC_UNUSED,
+    const GValue *value)
+{
+  return mcd_keyfile_escape_value (value);
+}
+
 /*
  * @value: a populated #GValue of a supported #GType
  *
@@ -2084,6 +2156,7 @@ plugin_iface_init (McpAccountManagerIface *iface,
 {
   DEBUG ();
 
+  iface->get_value = get_value;
   iface->set_value = set_value;
   iface->set_attribute = mcpa_set_attribute;
   iface->set_parameter = mcpa_set_parameter;
@@ -2091,7 +2164,10 @@ plugin_iface_init (McpAccountManagerIface *iface,
   iface->identify_account_async = identify_account_async;
   iface->identify_account_finish = identify_account_finish;
   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;
 }
 
 void

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-telepathy/telepathy-mission-control-6.git



More information about the Pkg-telepathy-commits mailing list