[rygel] core: Configuration option for plugin path



commit cd9f7397d66c272c151a7e5c3e36261a9d46896c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Mar 4 19:52:37 2010 +0200

    core: Configuration option for plugin path
    
    It should be possible to specify plugin path through all configuration
    sources.

 src/rygel/rygel-cmdline-config.vala     |   12 ++++++++++++
 src/rygel/rygel-configuration.vala      |    2 ++
 src/rygel/rygel-environment-config.vala |    5 +++++
 src/rygel/rygel-meta-config.vala        |   19 +++++++++++++++++++
 src/rygel/rygel-plugin-loader.vala      |   10 +++++++++-
 src/rygel/rygel-user-config.vala        |    5 +++++
 6 files changed, 52 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index 17c9a83..3148ad3 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -44,6 +44,8 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
 
     private static LogLevel log_level = LogLevel.INVALID;
 
+    private static string plugin_path;
+
     private static bool version;
 
     [CCode (array_length = false, array_null_terminated = true)]
@@ -81,6 +83,8 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
         { "log-level", 'g', 0, OptionArg.INT, ref log_level,
           "Log level. 1=critical,2=error,3=warning,4=message/info,5=debug",
           "N" },
+        { "plugin-path", 'u', 0, OptionArg.STRING, ref plugin_path,
+          "Plugin Path", "PLUGIN_PATH" },
         { "disable-plugin", 'd', 0, OptionArg.STRING_ARRAY,
           ref disabled_plugins,
           "Disable plugin", "PluginName" },
@@ -180,6 +184,14 @@ public class Rygel.CmdlineConfig : GLib.Object, Configuration {
         return log_level;
     }
 
+    public string get_plugin_path () throws GLib.Error {
+        if (plugin_path == null) {
+            throw new ConfigurationError.NO_VALUE_SET ("No value available");
+        }
+
+        return plugin_path;
+    }
+
     public bool get_enabled (string section) throws GLib.Error {
         var disabled = false;
         foreach (var plugin in disabled_plugins) {
diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala
index a27a7ab..1669e2c 100644
--- a/src/rygel/rygel-configuration.vala
+++ b/src/rygel/rygel-configuration.vala
@@ -51,6 +51,8 @@ public interface Rygel.Configuration : GLib.Object {
 
     public abstract LogLevel get_log_level () throws GLib.Error;
 
+    public abstract string get_plugin_path () throws GLib.Error;
+
     public abstract bool get_enabled (string section) throws GLib.Error;
 
     public abstract string get_title (string section) throws GLib.Error;
diff --git a/src/rygel/rygel-environment-config.vala b/src/rygel/rygel-environment-config.vala
index 80de37e..da09e16 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -40,6 +40,7 @@ public class Rygel.EnvironmentConfig : GLib.Object, Configuration {
     private static string MP2TS_TRANSCODING_ENV = RYGEL_PREFIX + "_MP2TS_TRANS";
     private static string WMV_TRANSCODING_ENV = RYGEL_PREFIX + "_WMV_TRANS";
     private static string LOG_LEVEL_ENV = RYGEL_PREFIX + "_LOG";
+    private static string PLUGIN_PATH_ENV = RYGEL_PREFIX + "_PLUGIN_PATH";
 
     // Our singleton
     private static EnvironmentConfig config;
@@ -91,6 +92,10 @@ public class Rygel.EnvironmentConfig : GLib.Object, Configuration {
                                                 LogLevel.DEBUG);
     }
 
+    public string get_plugin_path () throws GLib.Error {
+        return this.get_string_variable (PLUGIN_PATH_ENV);
+    }
+
     public bool get_enabled (string section) throws GLib.Error {
         return get_bool (section, ENABLED_KEY);
     }
diff --git a/src/rygel/rygel-meta-config.vala b/src/rygel/rygel-meta-config.vala
index 748c303..d9c9e8b 100644
--- a/src/rygel/rygel-meta-config.vala
+++ b/src/rygel/rygel-meta-config.vala
@@ -230,6 +230,25 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
         return val;
     }
 
+    public string get_plugin_path () throws GLib.Error {
+        string val = null;
+        bool unavailable = true;
+
+        foreach (var config in this.configs) {
+            try {
+                val = config.get_plugin_path ();
+                unavailable = false;
+                break;
+            } catch (GLib.Error err) {}
+        }
+
+        if (unavailable) {
+            throw new ConfigurationError.NO_VALUE_SET ("No value available");
+        }
+
+        return val;
+    }
+
     public bool get_enabled (string section) throws GLib.Error {
         bool val = true;
         bool unavailable = true;
diff --git a/src/rygel/rygel-plugin-loader.vala b/src/rygel/rygel-plugin-loader.vala
index f010126..9ae3d07 100644
--- a/src/rygel/rygel-plugin-loader.vala
+++ b/src/rygel/rygel-plugin-loader.vala
@@ -47,7 +47,15 @@ public class Rygel.PluginLoader : Object {
     public void load_plugins () {
         assert (Module.supported());
 
-        File dir = File.new_for_path (BuildConfig.PLUGIN_DIR);
+        string path;
+        try {
+            var config = MetaConfig.get_default ();
+            path = config.get_plugin_path ();
+        } catch (Error error) {
+            path = BuildConfig.PLUGIN_DIR;
+        }
+
+        File dir = File.new_for_path (path);
         assert (dir != null && is_dir (dir));
 
         this.load_modules_from_dir.begin (dir);
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 9b16179..331828d 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -41,6 +41,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                                                     "enable-lpcm-transcoder";
     protected static const string WMV_TRANSCODER_KEY = "enable-wmv-transcoder";
     protected static const string LOG_LEVEL_KEY = "log-level";
+    protected static const string PLUGIN_PATH_KEY = "plugin-path";
 
     private const string DBUS_SERVICE = "org.freedesktop.DBus";
     private const string DBUS_PATH = "/org/freedesktop/DBus";
@@ -138,6 +139,10 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
                                         LogLevel.DEBUG);
     }
 
+    public string get_plugin_path () throws GLib.Error {
+        return this.get_string ("general", PLUGIN_PATH_KEY);
+    }
+
     public static UserConfig get_default () throws Error {
         if (config == null) {
             config = new UserConfig ();



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