[gnome-online-accounts/wip/rishi/templates: 7/8] utils: Add goa_utils_keyfile_get_boolean
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts/wip/rishi/templates: 7/8] utils: Add goa_utils_keyfile_get_boolean
- Date: Tue, 13 Sep 2016 16:51:20 +0000 (UTC)
commit 84ddfb4ef9258301cf6011def985996414ba385d
Author: Debarshi Ray <debarshir gnome org>
Date: Thu Sep 1 20:19:43 2016 +0200
utils: Add goa_utils_keyfile_get_boolean
This is a wrapper around g_key_file_get_boolean that ignores
(G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND) errors and logs a
WARNING about anything else. It will be useful when we add support for
templates.
https://bugzilla.gnome.org/show_bug.cgi?id=771366
src/goabackend/goautils.c | 26 ++++++++++++++++++++++++++
src/goabackend/goautils.h | 2 ++
2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/goabackend/goautils.c b/src/goabackend/goautils.c
index 7e0584b..0688750 100644
--- a/src/goabackend/goautils.c
+++ b/src/goabackend/goautils.c
@@ -628,6 +628,32 @@ goa_utils_keyfile_copy_group (GKeyFile *src_key_file,
return ret_val;
}
+gboolean
+goa_utils_keyfile_get_boolean (GKeyFile *key_file, const gchar *group_name, const gchar *key)
+{
+ GError *error;
+ gboolean ret;
+
+ error = NULL;
+ ret = g_key_file_get_boolean (key_file, group_name, key, &error);
+ if (error != NULL)
+ {
+ if (!g_error_matches (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_KEY_NOT_FOUND))
+ {
+ g_warning ("Error reading key %s from group %s in keyfile: %s (%s, %d)",
+ key,
+ group_name,
+ error->message,
+ g_quark_to_string (error->domain),
+ error->code);
+ }
+
+ g_error_free (error);
+ }
+
+ return ret;
+}
+
void
goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key)
{
diff --git a/src/goabackend/goautils.h b/src/goabackend/goautils.h
index 5c7ac18..372b53d 100644
--- a/src/goabackend/goautils.h
+++ b/src/goabackend/goautils.h
@@ -93,6 +93,8 @@ gboolean goa_utils_keyfile_copy_group (GKeyFile *src_key_file,
GKeyFile *dest_key_file,
const gchar *dest_group_name);
+gboolean goa_utils_keyfile_get_boolean (GKeyFile *key_file, const gchar *group_name, const gchar
*key);
+
void goa_utils_keyfile_remove_key (GoaAccount *account, const gchar *key);
void goa_utils_keyfile_set_boolean (GoaAccount *account, const gchar *key, gboolean value);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]