[rygel-grilo] Allow user to use a different config file
- From: Juan A. Suarez Romero <jasuarez src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel-grilo] Allow user to use a different config file
- Date: Wed, 21 Apr 2010 17:51:47 +0000 (UTC)
commit 08dfe503c728fa9b1b7a1a017a818da1ba71b0b3
Author: Juan A. Suarez Romero <jasuarez igalia com>
Date: Wed Apr 21 19:51:01 2010 +0200
Allow user to use a different config file
Add a '-c/--config-file' option so user can choose a specific configuration
file.
src/rygel-grilo.c | 45 +++++++++++++++++++++++++++++----------------
1 files changed, 29 insertions(+), 16 deletions(-)
---
diff --git a/src/rygel-grilo.c b/src/rygel-grilo.c
index d40e01d..ea7e7a3 100644
--- a/src/rygel-grilo.c
+++ b/src/rygel-grilo.c
@@ -38,10 +38,15 @@
static GList *providers_names = NULL;
static GrlPluginRegistry *registry = NULL;
-static gchar **args;
static gboolean dups;
+static gchar **args = NULL;
+static gchar *conffile = NULL;
static GOptionEntry entries[] = {
+ { "config-file", 'c', 0,
+ G_OPTION_ARG_STRING, &conffile,
+ "Use this config file",
+ NULL },
{ "allow-duplicates", 'D', 0,
G_OPTION_ARG_NONE, &dups,
"Allow more than one provider with same name",
@@ -558,6 +563,7 @@ load_config ()
GError *error = NULL;
GKeyFile *keyfile;
GrlConfig *config;
+ gboolean load_success;
gchar **key;
gchar **keys;
gchar **plugin;
@@ -567,27 +573,34 @@ load_config ()
keyfile = g_key_file_new ();
- 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);
-
- if (!g_key_file_load_from_dirs (keyfile,
- RYGEL_GRILO_CONFIG_FILE,
- (const gchar **) search_paths,
- NULL,
- G_KEY_FILE_NONE,
- &error)) {
+ /* Try first user defined config file */
+ if (conffile){
+ load_success = g_key_file_load_from_file (keyfile,
+ conffile,
+ G_KEY_FILE_NONE,
+ &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);
+ }
+
+ if (!load_success) {
g_warning ("Unable to load configuration. %s", error->message);
g_error_free (error);
g_key_file_free (keyfile);
- g_strfreev (search_paths);
return;
}
- g_strfreev (search_paths);
-
/* Look up for defined plugins */
plugins = g_key_file_get_groups (keyfile, NULL);
for (plugin = plugins; *plugin; plugin++) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]