[rygel] core: All configs allow disabling of UPnP



commit 54c4270f402776fcf99e83b0681bad098674e0f0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Wed Jan 12 16:37:09 2011 +0200

    core: All configs allow disabling of UPnP
    
    Add option to disable UPnP to all configuration sources.

 src/rygel/rygel-cmdline-config.vala     |   10 ++++++++--
 src/rygel/rygel-environment-config.vala |    4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index b7f64c2..e5b1f6a 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -35,6 +35,7 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
     private static string iface;
     private static int port;
 
+    private static bool no_upnp;
     private static bool no_transcoding;
     private static bool no_mp3_trans;
     private static bool no_mp2ts_trans;
@@ -98,6 +99,8 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
           "Set plugin titles", "PluginName:TITLE" },
         { "plugin-option", 'o', 0, OptionArg.STRING_ARRAY, ref plugin_options,
           "Set plugin options", "PluginName:OPTION:VALUE1[,VALUE2,..]" },
+        { "disable-upnp", 'P', 0, OptionArg.NONE, ref no_upnp,
+          "Disable UPnP (streaming-only)", null },
         { null }
 	};
 
@@ -125,9 +128,12 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
 		}
     }
 
-    // Why would someone lauch rygel to kill itself?
     public bool get_upnp_enabled () throws GLib.Error {
-        throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+        if (!no_upnp) {
+            throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+        } else {
+            return false;
+        }
     }
 
     public string get_interface () throws GLib.Error {
diff --git a/src/rygel/rygel-environment-config.vala b/src/rygel/rygel-environment-config.vala
index 20866bd..273c110 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -33,6 +33,7 @@ internal class Rygel.EnvironmentConfig : GLib.Object, Configuration {
     private static string ENABLED_KEY = "ENABLED";
     private static string INTERFACE_ENV = RYGEL_PREFIX + "_IFACE";
     private static string PORT_ENV = RYGEL_PREFIX + "_PORT";
+    private static string DISABLE_UPNP_ENV = RYGEL_PREFIX + "_DISABLE_UPNP";
     private static string TRANSCODING_ENV = RYGEL_PREFIX + "_TRANSCODING";
     private static string MP3_TRANSCODING_ENV = RYGEL_PREFIX + "_MP3_TRANS";
     private static string LPCM_TRANSCODING_ENV = RYGEL_PREFIX + "_LPCM_TRANS";
@@ -54,9 +55,8 @@ internal class Rygel.EnvironmentConfig : GLib.Object, Configuration {
         return config;
     }
 
-    // This config doesn't make sense in this context.
     public bool get_upnp_enabled () throws GLib.Error {
-        throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+        return !this.get_bool_variable (DISABLE_UPNP_ENV);
     }
 
     public string get_interface () throws GLib.Error {



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