[gnome-online-accounts] daemon: Refactor code to get ID from group name into a function
- From: Debarshi Ray <debarshir src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-online-accounts] daemon: Refactor code to get ID from group name into a function
- Date: Mon, 9 May 2016 17:03:34 +0000 (UTC)
commit b60b68a93b11fc56c9856751fe3811e6cfb691d3
Author: Debarshi Ray <debarshir gnome org>
Date: Fri May 6 19:00:32 2016 +0200
daemon: Refactor code to get ID from group name into a function
https://bugzilla.gnome.org/show_bug.cgi?id=688041
src/daemon/goadaemon.c | 14 ++++++++++++--
1 files changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/daemon/goadaemon.c b/src/daemon/goadaemon.c
index 5ff22db..b9f9993 100644
--- a/src/daemon/goadaemon.c
+++ b/src/daemon/goadaemon.c
@@ -362,6 +362,13 @@ diff_sorted_lists (GList *list1,
/* ---------------------------------------------------------------------------------------------------- */
+static const gchar *
+group_to_id (const gchar *group)
+{
+ g_return_val_if_fail (g_str_has_prefix (group, "Account "), NULL);
+ return group + sizeof "Account " - 1;
+}
+
static gchar *
object_path_to_group (const gchar *object_path)
{
@@ -618,11 +625,14 @@ process_config_entries (GoaDaemon *self,
g_hash_table_iter_init (&iter, group_name_to_key_file_data);
while (g_hash_table_iter_next (&iter, (gpointer*) &group, (gpointer*) &key_file_data))
{
+ const gchar *id;
gchar *object_path;
+ id = group_to_id (group);
+
/* create and validate object path */
- object_path = g_strdup_printf ("/org/gnome/OnlineAccounts/Accounts/%s", group + sizeof "Account " - 1);
- if (strstr (group + sizeof "Account " - 1, "/") != NULL || !g_variant_is_object_path (object_path))
+ object_path = g_strdup_printf ("/org/gnome/OnlineAccounts/Accounts/%s", id);
+ if (strstr (id, "/") != NULL || !g_variant_is_object_path (object_path))
{
g_warning ("`%s' is not a valid account identifier", group);
g_free (object_path);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]