[rygel/wip/gobject: 31/35] core, server: Move module loading to GObject-style
- From: Krzesimir Nowak <krnowak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/gobject: 31/35] core, server: Move module loading to GObject-style
- Date: Tue, 15 Jan 2013 14:16:23 +0000 (UTC)
commit 4ff4d5bae2fcffc5e6a8cf3db546870c98a31ab1
Author: Jens Georg <jensg openismus com>
Date: Thu Dec 6 22:54:50 2012 +0100
core,server: Move module loading to GObject-style
src/librygel-core/rygel-plugin-loader.vala | 23 +++++++++++++----
.../rygel-recursive-module-loader.vala | 8 ++++-
src/librygel-server/rygel-engine-loader.vala | 25 +++++++++++++++----
3 files changed, 42 insertions(+), 14 deletions(-)
---
diff --git a/src/librygel-core/rygel-plugin-loader.vala b/src/librygel-core/rygel-plugin-loader.vala
index d9bd596..36544fa 100644
--- a/src/librygel-core/rygel-plugin-loader.vala
+++ b/src/librygel-core/rygel-plugin-loader.vala
@@ -52,14 +52,15 @@ public class Rygel.PluginLoader : RecursiveModuleLoader {
public signal void plugin_available (Plugin plugin);
public PluginLoader () {
- var path = BuildConfig.PLUGIN_DIR;
- try {
- var config = MetaConfig.get_default ();
- path = config.get_plugin_path ();
- } catch (Error error) { }
+ Object (base_path: get_config_path ());
+ }
- base (path);
+ public override void constructed () {
+ base.constructed ();
+ if (this.base_path == null) {
+ this.base_path = get_config_path ();
+ }
this.plugin_hash = new HashMap<string,Plugin> ();
this.loaded_modules = new HashSet<string> ();
}
@@ -137,4 +138,14 @@ public class Rygel.PluginLoader : RecursiveModuleLoader {
return true;
}
+
+ private static string get_config_path () {
+ var path = BuildConfig.PLUGIN_DIR;
+ try {
+ var config = MetaConfig.get_default ();
+ path = config.get_plugin_path ();
+ } catch (Error error) { }
+
+ return path;
+ }
}
diff --git a/src/librygel-core/rygel-recursive-module-loader.vala b/src/librygel-core/rygel-recursive-module-loader.vala
index f2ec0e2..7a12ae8 100644
--- a/src/librygel-core/rygel-recursive-module-loader.vala
+++ b/src/librygel-core/rygel-recursive-module-loader.vala
@@ -36,9 +36,10 @@ public abstract class Rygel.RecursiveModuleLoader : Object {
FileAttribute.STANDARD_CONTENT_TYPE;
private delegate void FolderHandler (File folder);
- private string base_path;
private bool done;
+ public string base_path { construct set; get; }
+
/**
* Create a recursive module loader for a given path.
*
@@ -48,7 +49,10 @@ public abstract class Rygel.RecursiveModuleLoader : Object {
* @param path base path of the loader.
*/
public RecursiveModuleLoader (string path) {
- this.base_path = path;
+ Object (base_path : path);
+ }
+
+ public override void constructed () {
this.done = false;
}
diff --git a/src/librygel-server/rygel-engine-loader.vala b/src/librygel-server/rygel-engine-loader.vala
index 50f34bc..784882a 100644
--- a/src/librygel-server/rygel-engine-loader.vala
+++ b/src/librygel-server/rygel-engine-loader.vala
@@ -29,15 +29,18 @@ internal class Rygel.EngineLoader : RecursiveModuleLoader {
private string engine_name;
public EngineLoader () {
- var path = BuildConfig.ENGINE_DIR;
- var config = MetaConfig.get_default ();
- try {
- path = config.get_engine_path ();
- } catch (Error error) { }
+ Object (base_path : get_config ());
+ }
- base (path);
+ public override void constructed () {
+ base.constructed ();
+
+ if (this.base_path == null) {
+ this.base_path = get_config ();
+ }
try {
+ var config = MetaConfig.get_default ();
this.engine_name = config.get_media_engine ();
debug ("Looking for specific engine named '%s",
this.engine_name);
@@ -94,4 +97,14 @@ internal class Rygel.EngineLoader : RecursiveModuleLoader {
return false;
}
+
+ private static string get_config () {
+ var path = BuildConfig.ENGINE_DIR;
+ var config = MetaConfig.get_default ();
+ try {
+ path = config.get_engine_path ();
+ } catch (Error error) { }
+
+ return path;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]