Enable user to choose if she wants to (dis)allowing media object upload.
private static bool no_lpcm_trans;
private static bool no_wmv_trans;
+ private static bool disallow_upload;
+
private static LogLevel log_level = LogLevel.INVALID;
private static string plugin_path;
"Disable Linear PCM transcoder", null },
{ "disable-wmv-transcoder", 'w', 0, OptionArg.NONE, ref no_wmv_trans,
"Disable WMV transcoder", null },
+ { "disallow-upload", 'U', 0, OptionArg.NONE,
+ ref disallow_upload, "Disallow upload", null },
{ "log-level", 'g', 0, OptionArg.INT, ref log_level,
"Log level. 1=critical,2=error,3=warning,4=message/info,5=debug",
"N" },
}
}
+ public bool get_allow_upload () throws GLib.Error {
+ if (!disallow_upload) {
+ 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"));
public abstract bool get_wmv_transcoder () throws GLib.Error;
+ public abstract bool get_allow_upload () throws GLib.Error;
+
public abstract LogLevel get_log_level () throws GLib.Error;
public abstract string get_plugin_path () throws GLib.Error;
private static string LPCM_TRANSCODING_ENV = RYGEL_PREFIX + "_LPCM_TRANS";
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 LOG_LEVEL_ENV = RYGEL_PREFIX + "_LOG";
private static string PLUGIN_PATH_ENV = RYGEL_PREFIX + "_PLUGIN_PATH";
return this.get_bool_variable (LPCM_TRANSCODING_ENV);
}
+ public bool get_allow_upload () throws GLib.Error {
+ return this.get_bool_variable (ALLOW_UPLOAD_ENV);
+ }
+
public LogLevel get_log_level () throws GLib.Error {
return (LogLevel) this.get_int_variable (LOG_LEVEL_ENV,
LogLevel.CRITICAL,
internal override OCMFlags ocm_flags {
get {
- if (this is WritableContainer && this.uris.size > 0) {
- return OCMFlags.UPLOAD |
- OCMFlags.DESTROYABLE |
- OCMFlags.UPLOAD_DESTROYABLE;
- } else {
+ if (!(this is WritableContainer) || this.uris.size == 0) {
return OCMFlags.NONE;
}
+
+ var flags = OCMFlags.DESTROYABLE;
+
+ var allow_upload = true;
+ var config = MetaConfig.get_default ();
+ try {
+ allow_upload = config.get_allow_upload ();
+ } catch (Error error) {}
+
+ if (allow_upload) {
+ flags |= OCMFlags.UPLOAD | OCMFlags.UPLOAD_DESTROYABLE;
+ }
+
+ return flags;
}
}
return val;
}
+ public bool get_allow_upload () throws GLib.Error {
+ bool val = true;
+ bool unavailable = true;
+
+ foreach (var config in this.configs) {
+ try {
+ val = config.get_allow_upload ();
+ 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;
public static const string MP2TS_TRANSCODER_KEY = "enable-mp2ts-transcoder";
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 LOG_LEVEL_KEY = "log-level";
public static const string PLUGIN_PATH_KEY = "plugin-path";
this.set_bool ("general", WMV_TRANSCODER_KEY, value);
}
+ public bool get_allow_upload () throws GLib.Error {
+ return this.get_bool ("general", ALLOW_UPLOAD_KEY);
+ }
+
+ public void set_allow_upload (bool value) throws GLib.Error {
+ this.set_bool ("general", ALLOW_UPLOAD_KEY, value);
+ }
+
public LogLevel get_log_level () throws GLib.Error {
return (LogLevel) this.get_int ("general",
LOG_LEVEL_KEY,