[rygel] core,doc,tracker: Add option for upload folders
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] core,doc,tracker: Add option for upload folders
- Date: Fri, 1 Jul 2011 18:18:09 +0000 (UTC)
commit 989d16e62b57051b6441950f0a107ad368513b3f
Author: Jens Georg <mail jensge org>
Date: Fri Jul 1 14:35:50 2011 +0200
core,doc,tracker: Add option for upload folders
data/rygel.conf | 12 +++++
doc/man/rygel.conf.xml | 24 +++++++++++
.../tracker/rygel-tracker-music-item-factory.vala | 12 ++++--
.../rygel-tracker-picture-item-factory.vala | 12 ++++--
.../tracker/rygel-tracker-video-item-factory.vala | 12 ++++--
src/rygel/rygel-cmdline-config.vala | 12 +++++
src/rygel/rygel-configuration.vala | 6 +++
src/rygel/rygel-environment-config.vala | 12 +++++
src/rygel/rygel-meta-config.vala | 44 ++++++++++++++++++++
src/rygel/rygel-user-config.vala | 19 ++++++++
10 files changed, 153 insertions(+), 12 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index bf26771..42614d7 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -26,6 +26,18 @@ enable-mp2ts-transcoder=true
# Set it to 'false' if you want to disable WMV transcoding support.
enable-wmv-transcoder=true
+# Where video files should be saved if allow-upload is true.
+# Defaults to @VIDEOS@, the standard videos folder (typically ${HOME}/Videos).
+video-upload-folder= VIDEOS@
+
+# Where music files should be saved if allow-upload is true
+# Defaults to @MUSIC@, the standard music folder (typically ${HOME}/Music).
+music-upload-folder= MUSIC@
+
+# Where picture files should be saved if allow-upload is true
+# Defaults to @PICTURES@, the standard picture folder (typically ${HOME}/Pictures).
+picture-upload-folder= PICTURES@
+
# The network interface to attach rygel to. You can also use network IP or even
# ESSID for wireless networks if you are using NetworkManager. Leave it blank
# for dynamic configuration.
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index c76b88b..1d70260 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -219,6 +219,30 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
<para>Allow remote media file deletion via UPnP.</para>
</listitem>
</varlistentry>
+ <varlistentry>
+ <term>
+ <option>video-upload-folder</option>
+ </term>
+ <listitem>
+ <para>If <option>allow-upload</option> is <userinput>true</userinput>, use this folder to store uploaded videos. It defaults to <userinput>@VIDEOS@</userinput> which expands to the default directory for video files (usually <filename><envar>$HOME</envar>/Videos</filename>).</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>music-upload-folder</option>
+ </term>
+ <listitem>
+ <para>If <option>allow-upload</option> is <userinput>true</userinput>, use this folder to store uploaded music files. It defaults to <userinput>@MUSIC@</userinput> which expands to the default directory for music files (usually <filename><envar>$HOME</envar>/Music</filename>).</para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
+ <term>
+ <option>picture-upload-folder</option>
+ </term>
+ <listitem>
+ <para>If <option>allow-upload</option> is <userinput>true</userinput>, use this folder to store uploaded pictures. It defaults to <userinput>@PICTURES@</userinput> which expands to the default directory for picture files (usually <filename><envar>$HOME</envar>/Pictures</filename>).</para>
+ </listitem>
+ </varlistentry>
</variablelist>
<para>Sections for plugins are denoted with <option>[PluginName]</option>
and can contain options specific to a plugin (see below) as well these common options:
diff --git a/src/plugins/tracker/rygel-tracker-music-item-factory.vala b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
index 89a1e9b..59bbcf9 100644
--- a/src/plugins/tracker/rygel-tracker-music-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
@@ -48,10 +48,14 @@ public class Rygel.Tracker.MusicItemFactory : ItemFactory {
"temp/nmm#MusicPiece";
public MusicItemFactory () {
- base (CATEGORY,
- CATEGORY_IRI,
- MusicItem.UPNP_CLASS,
- Environment.get_user_special_dir (UserDirectory.MUSIC));
+ var upload_folder = Environment.get_user_special_dir
+ (UserDirectory.MUSIC);
+ try {
+ var config = MetaConfig.get_default ();
+ upload_folder = config.get_music_upload_folder ();
+ } catch (Error error) {};
+
+ base (CATEGORY, CATEGORY_IRI, MusicItem.UPNP_CLASS, upload_folder);
// These must be the same order as enum MusicMetadata
this.properties.add ("res duration");
diff --git a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
index a3ba3af..76ac41f 100644
--- a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
@@ -41,10 +41,14 @@ public class Rygel.Tracker.PictureItemFactory : ItemFactory {
"temp/nmm#Photo";
public PictureItemFactory () {
- base (CATEGORY,
- CATEGORY_IRI,
- PhotoItem.UPNP_CLASS,
- Environment.get_user_special_dir (UserDirectory.PICTURES));
+ var upload_folder = Environment.get_user_special_dir
+ (UserDirectory.PICTURES);
+ try {
+ var config = MetaConfig.get_default ();
+ upload_folder = config.get_picture_upload_folder ();
+ } catch (Error error) {};
+
+ base (CATEGORY, CATEGORY_IRI, PhotoItem.UPNP_CLASS, upload_folder);
// These must be in the same order as enum PictureMetadata
this.properties.add ("height");
diff --git a/src/plugins/tracker/rygel-tracker-video-item-factory.vala b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
index dcc2d00..0e5a8e5 100644
--- a/src/plugins/tracker/rygel-tracker-video-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
@@ -42,10 +42,14 @@ public class Rygel.Tracker.VideoItemFactory : ItemFactory {
"temp/nmm#Video";
public VideoItemFactory () {
- base (CATEGORY,
- CATEGORY_IRI,
- VideoItem.UPNP_CLASS,
- Environment.get_user_special_dir (UserDirectory.VIDEOS));
+ var upload_folder = Environment.get_user_special_dir
+ (UserDirectory.VIDEOS);
+ try {
+ var config = MetaConfig.get_default ();
+ upload_folder = config.get_video_upload_folder ();
+ } catch (Error error) {};
+
+ base (CATEGORY, CATEGORY_IRI, VideoItem.UPNP_CLASS, upload_folder);
// These must be in the same order as enum VideoMetadata
this.properties.add ("height");
diff --git a/src/rygel/rygel-cmdline-config.vala b/src/rygel/rygel-cmdline-config.vala
index 64fab87..372c933 100644
--- a/src/rygel/rygel-cmdline-config.vala
+++ b/src/rygel/rygel-cmdline-config.vala
@@ -284,6 +284,18 @@ internal class Rygel.CmdlineConfig : GLib.Object, Configuration {
return config_file;
}
+ public string get_video_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ public string get_music_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ public string get_picture_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
// Dynamic options
// FIXME: How to handle them?
public string get_string (string section,
diff --git a/src/rygel/rygel-configuration.vala b/src/rygel/rygel-configuration.vala
index b67d732..9f59d7c 100644
--- a/src/rygel/rygel-configuration.vala
+++ b/src/rygel/rygel-configuration.vala
@@ -55,6 +55,12 @@ public interface Rygel.Configuration : GLib.Object {
public abstract string get_plugin_path () throws GLib.Error;
+ public abstract string get_video_upload_folder () throws GLib.Error;
+
+ public abstract string get_music_upload_folder () throws GLib.Error;
+
+ public abstract string get_picture_upload_folder () 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 5d59de7..e9695aa 100644
--- a/src/rygel/rygel-environment-config.vala
+++ b/src/rygel/rygel-environment-config.vala
@@ -105,6 +105,18 @@ internal class Rygel.EnvironmentConfig : GLib.Object, Configuration {
return this.get_string_variable (PLUGIN_PATH_ENV);
}
+ public string get_video_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ public string get_music_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
+ public string get_picture_upload_folder () throws GLib.Error {
+ throw new ConfigurationError.NO_VALUE_SET (_("No value available"));
+ }
+
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 ac6c828..507f9d3 100644
--- a/src/rygel/rygel-meta-config.vala
+++ b/src/rygel/rygel-meta-config.vala
@@ -295,6 +295,50 @@ public class Rygel.MetaConfig : GLib.Object, Configuration {
return val;
}
+ public string get_video_upload_folder () throws GLib.Error {
+ unowned string default = Environment.get_user_special_dir
+ (UserDirectory.VIDEOS);
+ var value = default;
+
+ foreach (var config in this.configs) {
+ try {
+ value = config.get_video_upload_folder ();
+ } catch (GLib.Error err) { }
+ }
+
+ return value.replace ("@VIDEOS@", default);
+ }
+
+ public string get_music_upload_folder () throws GLib.Error {
+ unowned string default = Environment.get_user_special_dir
+ (UserDirectory.MUSIC);
+
+ var value = default;
+
+ foreach (var config in this.configs) {
+ try {
+ value = config.get_music_upload_folder ();
+ } catch (GLib.Error err) {};
+ }
+
+ return value.replace ("@MUSIC@", default);
+ }
+
+ public string get_picture_upload_folder () throws GLib.Error {
+ unowned string default = Environment.get_user_special_dir
+ (UserDirectory.PICTURES);
+ var value = default;
+
+ foreach (var config in this.configs) {
+ try {
+ value = config.get_picture_upload_folder ();
+ } catch (GLib.Error err) {};
+ }
+
+ return value.replace ("@PICTURES@", default);
+ }
+
+
public bool get_enabled (string section) throws GLib.Error {
bool val = true;
bool unavailable = true;
diff --git a/src/rygel/rygel-user-config.vala b/src/rygel/rygel-user-config.vala
index 9e04850..db5ffc5 100644
--- a/src/rygel/rygel-user-config.vala
+++ b/src/rygel/rygel-user-config.vala
@@ -43,6 +43,13 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
public static const string ALLOW_DELETION_KEY = "allow-deletion";
public static const string LOG_LEVELS_KEY = "log-level";
public static const string PLUGIN_PATH_KEY = "plugin-path";
+ public static const string UPLOAD_FOLDER_KEY = "upload-folder";
+ public static const string VIDEO_UPLOAD_DIR_PATH_KEY =
+ "video-" + UPLOAD_FOLDER_KEY;
+ public static const string MUSIC_UPLOAD_DIR_PATH_KEY =
+ "music-" + UPLOAD_FOLDER_KEY;
+ public static const string PICTURE_UPLOAD_DIR_PATH_KEY =
+ "picture-" + UPLOAD_FOLDER_KEY;
// Our singleton
private static UserConfig config;
@@ -98,6 +105,18 @@ public class Rygel.UserConfig : GLib.Object, Configuration {
return this.get_string ("general", PLUGIN_PATH_KEY);
}
+ public string get_video_upload_folder () throws GLib.Error {
+ return this.get_string ("general", VIDEO_UPLOAD_DIR_PATH_KEY);
+ }
+
+ public string get_music_upload_folder () throws GLib.Error {
+ return this.get_string ("general", MUSIC_UPLOAD_DIR_PATH_KEY);
+ }
+
+ public string get_picture_upload_folder () throws GLib.Error {
+ return this.get_string ("general", PICTURE_UPLOAD_DIR_PATH_KEY);
+ }
+
public static UserConfig get_default () throws Error {
if (config == null) {
var path = Path.build_filename
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]