[rygel-grilo] Use Grilo functions to load configuration from file



commit 36c819f0e881d1a6f47f224ea92a3fe12493d5a3
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date:   Thu Mar 3 19:27:21 2011 +0000

    Use Grilo functions to load configuration from file
    
    Get rid of our own custom function.

 configure.ac      |    2 +-
 src/rygel-grilo.c |   61 +++++++++++-----------------------------------------
 2 files changed, 14 insertions(+), 49 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fc767db..27e0148 100644
--- a/configure.ac
+++ b/configure.ac
@@ -73,7 +73,7 @@ PKG_CHECK_MODULES(DEPS, 		\
 AC_SUBST(DEPS_CFLAGS)
 AC_SUBST(DEPS_LIBS)
 
-PKG_CHECK_MODULES(GRL_DEP, grilo-${GRL_API_VERSION} >= 0.1.6)
+PKG_CHECK_MODULES(GRL_DEP, grilo-${GRL_API_VERSION} >= 0.1.7)
 
 AC_SUBST(GRL_DEP_CFLAGS)
 AC_SUBST(GRL_DEP_LIBS)
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index 3259ddf..567fbaf 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -886,66 +886,31 @@ static void
 load_config ()
 {
   GError *error = NULL;
-  GKeyFile *keyfile;
-  GrlConfig *config;
   gboolean load_success;
-  gchar **key;
-  gchar **keys;
-  gchar **plugin;
-  gchar **plugins;
-  gchar **search_paths;
-  gchar *value;
-
-  keyfile = g_key_file_new ();
+  gchar *config_file;
 
   /* Try first user defined config file */
   if (conffile){
-    load_success = g_key_file_load_from_file (keyfile,
-                                              conffile,
-                                              G_KEY_FILE_NONE,
-                                              &error);
+    load_success = grl_plugin_registry_add_config_from_file (registry,
+                                                             conffile,
+                                                             &error);
   } else {
-    search_paths = g_new0 (gchar *, 3);
-    search_paths[0] = g_build_filename (g_get_user_config_dir (),
-                                        "rygel-grilo",
-                                        NULL);
-    search_paths[1] = g_strdup (SYSCONFDIR);
-    load_success = g_key_file_load_from_dirs (keyfile,
-                                              RYGEL_GRILO_CONFIG_FILE,
-                                              (const gchar **) search_paths,
-                                              NULL,
-                                              G_KEY_FILE_NONE,
-                                              &error);
-    g_strfreev (search_paths);
+    config_file = g_build_filename (g_get_user_config_dir (),
+                                    "rygel-grilo",
+                                    RYGEL_GRILO_CONFIG_FILE,
+                                    NULL);
+    load_success = grl_plugin_registry_add_config_from_file (registry,
+                                                             config_file,
+                                                             &error);
+    g_free (config_file);
   }
 
   if (!load_success) {
     g_warning ("Unable to load configuration. %s", error->message);
     g_error_free (error);
-    g_key_file_free (keyfile);
-    return;
-  }
-
-  /* Look up for defined plugins */
-  plugins = g_key_file_get_groups (keyfile, NULL);
-  for (plugin = plugins; *plugin; plugin++) {
-    config = grl_config_new (*plugin, NULL);
-
-    /* Look up for keys in this plugin */
-    keys = g_key_file_get_keys (keyfile, *plugin, NULL, NULL);
-    for (key = keys; *key; key++) {
-      value = g_key_file_get_string (keyfile, *plugin, *key, NULL);
-      if (value) {
-        grl_config_set_string (config, *key, value);
-        g_free (value);
-      }
-    }
-    grl_plugin_registry_add_config (registry, config, NULL);
-    g_strfreev (keys);
   }
 
-  g_strfreev (plugins);
-  g_key_file_free (keyfile);
+  return;
 }
 
 /* Main program */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]