[rygel] core,ui: Explicit initialization of MetaConfig
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,ui: Explicit initialization of MetaConfig
- Date: Tue, 3 Jul 2012 07:56:05 +0000 (UTC)
commit d8f464a9463b500f94eea73ec24cff2a3b7e6db7
Author: Jens Georg <mail jensge org>
Date: Thu Jun 14 12:22:43 2012 +0200
core,ui: Explicit initialization of MetaConfig
If clients use librygel-core, they should not react to Rygel's
configuration, environment variables and commandline options.
src/rygel/rygel-main.vala | 3 +++
src/rygel/rygel-meta-config.vala | 26 +++++++++++++++++++-------
src/ui/rygel-preferences-dialog.vala | 3 +++
3 files changed, 25 insertions(+), 7 deletions(-)
---
diff --git a/src/rygel/rygel-main.vala b/src/rygel/rygel-main.vala
index bf3b991..cedee0e 100644
--- a/src/rygel/rygel-main.vala
+++ b/src/rygel/rygel-main.vala
@@ -1,8 +1,10 @@
/*
* Copyright (C) 2008 Nokia Corporation.
* Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2012 Openismus GmbH.
*
* Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ * Jens Georg <jensg openismus com>
*
* This file is part of Rygel.
*
@@ -255,6 +257,7 @@ internal class Rygel.Main : Object {
try {
// Parse commandline options
CmdlineConfig.parse_args (ref args);
+ MetaConfig.register_default_configurations ();
main = new Main ();
service = new DBusService (main);
diff --git a/src/rygel/rygel-meta-config.vala b/src/rygel/rygel-meta-config.vala
index 762c036..869755a 100644
--- a/src/rygel/rygel-meta-config.vala
+++ b/src/rygel/rygel-meta-config.vala
@@ -1,9 +1,11 @@
/*
* Copyright (C) 2008,2009 Nokia Corporation.
* Copyright (C) 2008,2009 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
+ * Copyright (C) 2012 Openismus GmbH.
*
* Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
* <zeeshan ali nokia com>
+ * Jens Georg <jensg openismus com>
*
* This file is part of Rygel.
*
@@ -35,9 +37,13 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
// Our singleton
private static MetaConfig meta_config;
- private ArrayList<Configuration> configs;
+ private static ArrayList<Configuration> configs;
public static MetaConfig get_default () {
+ if (MetaConfig.configs == null) {
+ MetaConfig.configs = new ArrayList<Configuration> ();
+ }
+
if (meta_config == null) {
meta_config = new MetaConfig ();
}
@@ -45,22 +51,28 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
return meta_config;
}
- public MetaConfig () {
- this.configs = new ArrayList<Configuration> ();
+ public static void register_configuration (Configuration config) {
+ if (MetaConfig.configs == null) {
+ MetaConfig.configs = new ArrayList<Configuration> ();
+ }
+ configs.add (config);
+ }
+
+ public static void register_default_configurations () {
var cmdline_config = CmdlineConfig.get_default ();
- this.configs.add (cmdline_config);
- this.configs.add (EnvironmentConfig.get_default ());
+ MetaConfig.register_configuration (cmdline_config);
+ MetaConfig.register_configuration (EnvironmentConfig.get_default ());
try {
var config_file = cmdline_config.get_config_file ();
var user_config = new UserConfig (config_file);
- this.configs.add (user_config);
+ MetaConfig.register_configuration (user_config);
} catch (Error error) {
try {
var user_config = UserConfig.get_default ();
- this.configs.add (user_config);
+ MetaConfig.register_configuration (user_config);
} catch (Error err) {
warning (_("Failed to load user configuration: %s"), err.message);
}
diff --git a/src/ui/rygel-preferences-dialog.vala b/src/ui/rygel-preferences-dialog.vala
index 6eb8bc0..c80dcd3 100644
--- a/src/ui/rygel-preferences-dialog.vala
+++ b/src/ui/rygel-preferences-dialog.vala
@@ -1,8 +1,10 @@
/*
* Copyright (C) 2009 Nokia Corporation.
+ * Copyright (C) 2012 Openismus GmbH.
*
* Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
* <zeeshan ali nokia com>
+ * Jens Georg <jensg openismus com>
*
* This file is part of Rygel.
*
@@ -84,6 +86,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
Gtk.init (ref args);
try {
+ MetaConfig.register_default_configurations ();
var dialog = new PreferencesDialog ();
dialog.run ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]