telepathy-mission-control: McdStorage: implement get_string, get_boolean, get_integer in terms of get_value

Simon McVittie smcv at kemper.freedesktop.org
Thu Oct 4 08:19:47 PDT 2012


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

Author: Simon McVittie <simon.mcvittie at collabora.co.uk>
Date:   Wed Sep  5 14:21:30 2012 +0100

McdStorage: implement get_string, get_boolean, get_integer in terms of get_value

---

 src/mcd-storage.c |   33 ++++++++++++++++++++++++++++-----
 1 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/src/mcd-storage.c b/src/mcd-storage.c
index 21b9725..ef02375 100644
--- a/src/mcd-storage.c
+++ b/src/mcd-storage.c
@@ -486,14 +486,21 @@ mcd_storage_dup_string (McdStorage *self,
     const gchar *account,
     const gchar *key)
 {
-  gchar *value = NULL;
+  GValue tmp = G_VALUE_INIT;
+  gchar *ret;
 
   g_return_val_if_fail (MCD_IS_STORAGE (self), NULL);
   g_return_val_if_fail (account != NULL, NULL);
+  g_return_val_if_fail (key != NULL, NULL);
 
-  value = g_key_file_get_string (self->keyfile, account, key, NULL);
+  g_value_init (&tmp, G_TYPE_STRING);
 
-  return value;
+  if (!mcd_storage_get_value (self, account, key, &tmp, NULL))
+    return NULL;
+
+  ret = g_value_dup_string (&tmp);
+  g_value_unset (&tmp);
+  return ret;
 }
 
 /*
@@ -778,10 +785,18 @@ mcd_storage_get_boolean (McdStorage *self,
     const gchar *account,
     const gchar *key)
 {
+  GValue tmp = G_VALUE_INIT;
+
   g_return_val_if_fail (MCD_IS_STORAGE (self), FALSE);
   g_return_val_if_fail (account != NULL, FALSE);
+  g_return_val_if_fail (key != NULL, FALSE);
+
+  g_value_init (&tmp, G_TYPE_BOOLEAN);
 
-  return g_key_file_get_boolean (self->keyfile, account, key, NULL);
+  if (!mcd_storage_get_value (self, account, key, &tmp, NULL))
+    return FALSE;
+
+  return g_value_get_boolean (&tmp);
 }
 
 /*
@@ -797,10 +812,18 @@ mcd_storage_get_integer (McdStorage *self,
     const gchar *account,
     const gchar *key)
 {
+  GValue tmp = G_VALUE_INIT;
+
   g_return_val_if_fail (MCD_IS_STORAGE (self), 0);
   g_return_val_if_fail (account != NULL, 0);
+  g_return_val_if_fail (key != NULL, 0);
+
+  g_value_init (&tmp, G_TYPE_INT);
+
+  if (!mcd_storage_get_value (self, account, key, &tmp, NULL))
+    return FALSE;
 
-  return g_key_file_get_integer (self->keyfile, account, key, NULL);
+  return g_value_get_int (&tmp);
 }
 
 static void



More information about the telepathy-commits mailing list