[rygel] core,tracker,media-export: Add MediaContainer.set_uri()



commit 97a40e1f7e9351ab942d9db85aea557a5ee0bc82
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Mon Jun 21 17:10:47 2010 +0300

    core,tracker,media-export: Add MediaContainer.set_uri()
    
    API for setting URI and (optionally) create_classes. This also implies
    that we now allow only one URI per container. If create_classes are not
    provided, we assume ALL main item classes.

 .../rygel-media-export-dummy-container.vala        |    2 +-
 .../rygel-tracker-category-all-container.vala      |    5 +++-
 src/rygel/rygel-media-container.vala               |   24 ++++++++++++++++++-
 3 files changed, 27 insertions(+), 4 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-dummy-container.vala b/src/plugins/media-export/rygel-media-export-dummy-container.vala
index 8510393..e4d28c3 100644
--- a/src/plugins/media-export/rygel-media-export-dummy-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dummy-container.vala
@@ -32,7 +32,7 @@ internal class Rygel.MediaExport.DummyContainer : NullContainer {
         this.child_count = 0;
         this.parent_ref = parent;
         this.file = file;
-        this.uris.add (file.get_uri ());
+        this.set_uri (file.get_uri ());
         this.seen_children = new ArrayList<string> (str_equal);
     }
 
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index ce0900b..87d5408 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -33,7 +33,10 @@ public class Rygel.TrackerCategoryAllContainer : Rygel.TrackerSearchContainer {
 
         try {
             var uri = Filename.to_uri (item_factory.upload_dir, null);
-            this.uris.add (uri);
+            var create_classes = new ArrayList<string> ();
+
+            create_classes.add (item_factory.upnp_class);
+            this.set_uri (uri, create_classes);
         } catch (ConvertError error) {
             warning (_("Failed to construct URI for folder '%s': %s"),
                      item_factory.upload_dir,
diff --git a/src/rygel/rygel-media-container.vala b/src/rygel/rygel-media-container.vala
index 3bb9c0d..f47d50b 100644
--- a/src/rygel/rygel-media-container.vala
+++ b/src/rygel/rygel-media-container.vala
@@ -53,10 +53,9 @@ public abstract class Rygel.MediaContainer : MediaObject {
         this.child_count = child_count;
         this.update_id = 0;
         this.upnp_class = "object.container.storageFolder";
+        this.create_classes = new ArrayList<string> ();
 
         this.container_updated.connect (on_container_updated);
-
-        this.create_classes = new ArrayList<string> ();
     }
 
     public MediaContainer.root (string title,
@@ -240,6 +239,27 @@ public abstract class Rygel.MediaContainer : MediaObject {
         this.container_updated (this);
     }
 
+    /**
+     * Sets the URI of this container and optionally the create_classes.
+     *
+     * @param uri the URI to set.
+     * @param create_classes list of item classes.
+     */
+    public void set_uri (string uri, ArrayList<string>? create_classes = null) {
+        this.uris.clear ();
+        this.uris.add (uri);
+
+        this.create_classes.clear ();
+
+        if (create_classes != null) {
+            this.create_classes.add_all (create_classes);
+        } else {
+            this.create_classes.add (MediaItem.IMAGE_CLASS);
+            this.create_classes.add (MediaItem.VIDEO_CLASS);
+            this.create_classes.add (MediaItem.AUDIO_CLASS);
+        }
+    }
+
     private async Gee.List<MediaObject> search_in_children (
                                         SearchExpression      expression,
                                         Gee.List<MediaObject> children,



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