[rygel] core: Configuration for (dis)allowing deletion
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core: Configuration for (dis)allowing deletion
- Date: Wed, 10 Nov 2010 14:54:28 +0000 (UTC)
commit f4b379f5c4a56de3ca616c40a10da8a3c2a7c844
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Nov 9 19:49:41 2010 +0200
core: Configuration for (dis)allowing deletion
Enable user to choose if she wants to (dis)allowing media object deletion.
src/rygel/rygel-cmdline-config.vala | 11 +++++++++++
src/rygel/rygel-configuration.vala | 2 ++
src/rygel/rygel-environment-config.vala | 5 +++++
src/rygel/rygel-media-container.vala | 11 ++++++++++-
src/rygel/rygel-media-item.vala | 17 ++++++++++++++++-
src/rygel/rygel-meta-config.vala | 19 +++++++++++++++++++
src/rygel/rygel-user-config.vala | 9 +++++++++
7 files changed, 72 insertions(+), 2 deletions(-)
---
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index a4aeca9..b7f64c2 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -42,6 +42,7 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
private static bool no_wmv_trans;
private static bool disallow_upload;
+ private static bool disallow_deletion;
private static LogLevel log_level = LogLevel.INVALID;
@@ -83,6 +84,8 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
"Disable WMV transcoder", null },
{ "disallow-upload", 'U', 0, OptionArg.NONE,
ref disallow_upload, "Disallow upload", null },
+ { "disallow-deletion", 'D', 0, OptionArg.NONE,
+ ref disallow_deletion, "Disallow deletion", null },
{ "log-level", 'g', 0, OptionArg.INT, ref log_level,
"Log level. 1=critical,2=error,3=warning,4=message/info,5=debug",
"N" },
@@ -191,6 +194,14 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
}
}
+ public bool get_allow_deletion () throws GLib.Error {
+ if (!disallow_deletion) {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ } else {
+ return false;
+ }
+ }
+
public LogLevel get_log_level () throws GLib.Error {
if (this.log_level == LogLevel.INVALID) {
throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala
index 2d1f05e..4a24142 100644
--- a/src/rygel/rygel-configuration.vala
+++ b/src/rygel/rygel-configuration.vala
@@ -49,6 +49,8 @@ public interface Rygel.Configuration : GLib.Object {
public abstract bool get_allow_upload () throws GLib.Error;
+ public abstract bool get_allow_deletion () throws GLib.Error;
+
public abstract LogLevel get_log_level () throws GLib.Error;
public abstract string get_plugin_path () throws GLib.Error;
diff --git a/src/rygel/rygel-environment-config.vala b/src/rygel/rygel-environment-config.vala
index e24cb28..4f62abe 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -39,6 +39,7 @@ internal 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 ALLOW_UPLOAD_ENV = RYGEL_PREFIX + "_ALLOW_UPLOAD";
+ private static string ALLOW_DELETION_ENV = RYGEL_PREFIX + "_ALLOW_DELETION";
private static string LOG_LEVEL_ENV = RYGEL_PREFIX + "_LOG";
private static string PLUGIN_PATH_ENV = RYGEL_PREFIX + "_PLUGIN_PATH";
@@ -90,6 +91,10 @@ internal class Rygel.EnvironmentConfig : GLib.Object, Configuration {
return this.get_bool_variable (ALLOW_UPLOAD_ENV);
}
+ public bool get_allow_deletion () throws GLib.Error {
+ return this.get_bool_variable (ALLOW_DELETION_ENV);
+ }
+
public LogLevel get_log_level () throws GLib.Error {
return (LogLevel) this.get_int_variable (LOG_LEVEL_ENV,
LogLevel.CRITICAL,
diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala
index 788fdf9..b346f79 100644
--- a/src/rygel/rygel-media-container.vala
+++ b/src/rygel/rygel-media-container.vala
@@ -52,7 +52,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
return OCMFlags.NONE;
}
- var flags = OCMFlags.DESTROYABLE;
+ var flags = OCMFlags.NONE;
var allow_upload = true;
var config = MetaConfig.get_default ();
@@ -64,6 +64,15 @@ public abstract class Rygel.MediaContainer : MediaObject {
flags |= OCMFlags.UPLOAD | OCMFlags.UPLOAD_DESTROYABLE;
}
+ var allow_deletion = true;
+ try {
+ allow_deletion = config.get_allow_deletion ();
+ } catch (Error error) {}
+
+ if (allow_deletion) {
+ flags |= OCMFlags.DESTROYABLE;
+ }
+
return flags;
}
}
diff --git a/src/rygel/rygel-media-item.vala b/src/rygel/rygel-media-item.vala
index 2b1a1ff..cde0b56 100644
--- a/src/rygel/rygel-media-item.vala
+++ b/src/rygel/rygel-media-item.vala
@@ -59,7 +59,22 @@ public abstract class Rygel.MediaItem : MediaObject {
internal override OCMFlags ocm_flags {
get {
- return OCMFlags.DESTROYABLE;
+ if (this.place_holder) {
+ // Place-holder items are always destroyable.
+ return OCMFlags.DESTROYABLE;
+ }
+
+ var config = MetaConfig.get_default ();
+ var allow_deletion = true;
+ try {
+ allow_deletion = config.get_allow_deletion ();
+ } catch (Error error) {}
+
+ if (allow_deletion) {
+ return OCMFlags.DESTROYABLE;
+ } else {
+ return OCMFlags.NONE;
+ }
}
}
diff --git a/src/rygel/rygel-meta-config.vala b/src/rygel/rygel-meta-config.vala
index 50aeeae..fd39990 100644
--- a/src/rygel/rygel-meta-config.vala
+++ b/src/rygel/rygel-meta-config.vala
@@ -229,6 +229,25 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
return val;
}
+ public bool get_allow_deletion () throws GLib.Error {
+ bool val = true;
+ bool unavailable = true;
+
+ foreach (var config in this.configs) {
+ try {
+ val = config.get_allow_deletion ();
+ unavailable = false;
+ break;
+ } catch (GLib.Error err) {}
+ }
+
+ if (unavailable) {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ return val;
+ }
+
public LogLevel get_log_level () throws GLib.Error {
LogLevel val = LogLevel.DEFAULT;
bool unavailable = true;
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 545ab9d..d59d881 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -39,6 +39,7 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
public static const string LPCM_TRANSCODER_KEY = "enable-lpcm-transcoder";
public static const string WMV_TRANSCODER_KEY = "enable-wmv-transcoder";
public static const string ALLOW_UPLOAD_KEY = "allow-upload";
+ public static const string ALLOW_DELETION_KEY = "allow-deletion";
public static const string LOG_LEVEL_KEY = "log-level";
public static const string PLUGIN_PATH_KEY = "plugin-path";
@@ -132,6 +133,14 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
this.set_bool ("general", ALLOW_UPLOAD_KEY, value);
}
+ public bool get_allow_deletion () throws GLib.Error {
+ return this.get_bool ("general", ALLOW_DELETION_KEY);
+ }
+
+ public void set_allow_deletion (bool value) throws GLib.Error {
+ this.set_bool ("general", ALLOW_DELETION_KEY, value);
+ }
+
public LogLevel get_log_level () throws GLib.Error {
return (LogLevel) this.get_int ("general",
LOG_LEVEL_KEY,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]