[rygel] media-export: Option to disable virtual folders



commit 9c1585a98bc3db271ec8a54402d39ed994fc00a9
Author: Jens Georg <mail jensge org>
Date:   Tue Feb 12 14:48:22 2013 +0100

    media-export: Option to disable virtual folders

 data/rygel.conf                                    |    1 +
 doc/man/rygel.conf.xml                             |    8 ++++++++
 .../rygel-media-export-media-cache.vala            |    9 +++++++++
 .../rygel-media-export-root-container.vala         |   20 +++++++++++++++++++-
 4 files changed, 37 insertions(+), 1 deletions(-)
---
diff --git a/data/rygel.conf b/data/rygel.conf
index e9214ec..610e657 100644
--- a/data/rygel.conf
+++ b/data/rygel.conf
@@ -110,6 +110,7 @@ title= REALNAME@'s media
 uris= MUSIC@;@VIDEOS@;@PICTURES@
 extract-metadata=true
 monitor-changes=true
+virtual-folders=true
 
 [Playbin]
 enabled=true
diff --git a/doc/man/rygel.conf.xml b/doc/man/rygel.conf.xml
index 69d12eb..30b4c45 100644
--- a/doc/man/rygel.conf.xml
+++ b/doc/man/rygel.conf.xml
@@ -357,6 +357,14 @@ man(1), man(7), http://www.tldp.org/HOWTO/Man-Page/
           <para>Set to <userinput>false</userinput> if you don&apos;t want to have new files picked up 
automatically by &dhpackage;.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <option>virtual-folders</option>
+        </term>
+        <listitem>
+          <para>Set to <userinput>false</userinput> if you don&apos;t need the virtual folder 
hierarchy.</para>
+        </listitem>
+      </varlistentry>
     </variablelist>
   </refsect1>
   <refsect1>
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala 
b/src/plugins/media-export/rygel-media-export-media-cache.vala
index bfccc3d..13cc5de 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -510,6 +510,15 @@ public class Rygel.MediaExport.MediaCache : Object {
         }
     }
 
+    public void drop_virtual_folders () {
+        try {
+            this.db.exec ("DELETE FROM object WHERE " +
+                          "upnp_id LIKE 'virtual-parent:%'");
+        } catch (DatabaseError error) {
+            warning ("Failed to drop virtual folders: %s", error.message);
+        }
+    }
+
     // Private functions
     private void get_exists_cache () throws DatabaseError {
         this.exists_cache = new HashMap<string, ExistsCacheEntry?> ();
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala 
b/src/plugins/media-export/rygel-media-export-root-container.vala
index a8e8d92..1cd62d2 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -458,10 +458,18 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
     }
 
     private void on_setting_changed (string section, string key) {
-        if (section != "MediaExport" || key != "uris") {
+        if (section != Plugin.NAME) {
             return;
         }
 
+        if (key == "uris") {
+            this.handle_uri_config_change ();
+        } else if (key == "virtual-folders") {
+            this.handle_virtual_folder_change ();
+        }
+    }
+
+    private void handle_uri_config_change () {
         var uris = this.get_shared_uris ();
         // Calculate added uris
         var new_uris = new ArrayList<File>
@@ -549,6 +557,16 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
      * saving them in the cache.
      */
     private void add_default_virtual_folders () {
+        var virtual_folders = true;
+        var config = MetaConfig.get_default ();
+        try {
+            virtual_folders = config.get_bool (Plugin.NAME, "virtual-folders");
+        } catch (Error error) { }
+
+        if (!virtual_folders) {
+            return;
+        }
+
         try {
             this.add_virtual_containers_for_class (_("Music"),
                                                    Rygel.MusicItem.UPNP_CLASS,


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