[rygel/wip/create-reference: 3/3] wip



commit e784a2e2d5fda1f5f4958e033ec5c83766079fdc
Author: Jens Georg <jensg openismus com>
Date:   Wed Feb 27 15:00:53 2013 +0100

    wip

 src/librygel-server/Makefile.am                    |    2 +-
 src/librygel-server/rygel-media-container.vala     |    3 +
 src/librygel-server/rygel-media-object.vala        |    2 +-
 src/librygel-server/rygel-object-creator.vala      |    3 +
 src/plugins/media-export/Makefile.am               |    1 +
 .../rygel-media-export-object-factory.vala         |    4 +
 ...rygel-media-export-playlist-root-container.vala |   64 ++++++++++++++++++++
 .../rygel-media-export-writable-db-container.vala  |   24 ++++----
 8 files changed, 90 insertions(+), 13 deletions(-)
---
diff --git a/src/librygel-server/Makefile.am b/src/librygel-server/Makefile.am
index c284ed7..fcf0a78 100644
--- a/src/librygel-server/Makefile.am
+++ b/src/librygel-server/Makefile.am
@@ -16,7 +16,7 @@ librygel_server_2_0_la_VALAFLAGS = \
        -H rygel-server.h --library=rygel-server-2.0 \
        $(LIBRYGEL_SERVER_DEPS_VALAFLAGS) \
        $(RYGEL_COMMON_LIBRYGEL_CORE_VALAFLAGS) \
-       $(RYGEL_COMMON_VALAFLAGS)
+       $(RYGEL_COMMON_VALAFLAGS) -g
 
 librygel_server_2_0_la_CFLAGS = \
        $(LIBRYGEL_SERVER_DEPS_CFLAGS) \
diff --git a/src/librygel-server/rygel-media-container.vala b/src/librygel-server/rygel-media-container.vala
index 99094da..9a8f0d1 100644
--- a/src/librygel-server/rygel-media-container.vala
+++ b/src/librygel-server/rygel-media-container.vala
@@ -119,6 +119,9 @@ public abstract class Rygel.MediaContainer : MediaObject {
 
     internal override OCMFlags ocm_flags {
         get {
+            debug ("=> Checking OCM flags for %s %s",
+                   (this is WritableContainer).to_string (),
+                   (this.uris.size == 0).to_string ());
             if (!(this is WritableContainer) || this.uris.size == 0) {
                 return OCMFlags.NONE;
             }
diff --git a/src/librygel-server/rygel-media-object.vala b/src/librygel-server/rygel-media-object.vala
index 6b3953a..7f488f8 100644
--- a/src/librygel-server/rygel-media-object.vala
+++ b/src/librygel-server/rygel-media-object.vala
@@ -266,7 +266,7 @@ public abstract class Rygel.MediaObject : GLib.Object {
     private async bool check_writable (File file, Cancellable? cancellable)
                                        throws Error {
         if (!file.is_native ()) {
-            return false;
+            return true;
         }
 
         try {
diff --git a/src/librygel-server/rygel-object-creator.vala b/src/librygel-server/rygel-object-creator.vala
index d230e96..1f4f9e0 100644
--- a/src/librygel-server/rygel-object-creator.vala
+++ b/src/librygel-server/rygel-object-creator.vala
@@ -353,6 +353,9 @@ internal class Rygel.ObjectCreator: GLib.Object, Rygel.StateMachine {
                                         (_("No such object"));
         } else if (!(OCMFlags.UPLOAD in media_object.ocm_flags) ||
                    !(media_object is WritableContainer)) {
+            debug ("=> %s %s", (OCMFlags.UPLOAD in
+                        media_object.ocm_flags).to_string (),
+                    (media_object is WritableContainer).to_string ());
             throw new ContentDirectoryError.RESTRICTED_PARENT
                                         (_("Object creation in %s not allowed"),
                                          media_object.id);
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index b59010e..e78d8e5 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -28,6 +28,7 @@ librygel_media_export_la_SOURCES = \
        rygel-media-export-jpeg-writer.vala \
        rygel-media-export-object-factory.vala \
        rygel-media-export-writable-db-container.vala \
+       rygel-media-export-playlist-root-container.vala \
        rygel-media-export-music-item.vala \
        rygel-media-export-video-item.vala \
        rygel-media-export-photo-item.vala \
diff --git a/src/plugins/media-export/rygel-media-export-object-factory.vala 
b/src/plugins/media-export/rygel-media-export-object-factory.vala
index 1b62107..fb9cbf9 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -50,6 +50,10 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
             return factory.create_from_hashed_id (id, title);
         }
 
+        if (id.has_prefix ("virtual-parent:" + Rygel.PlaylistItem.UPNP_CLASS)) {
+            return new PlaylistRootContainer (id, title);
+        }
+
         // Return a suitable container for the top-level virtual folders.
         // This corresponds to the short-lived NullContainers that
         // we used to save these in the database.
diff --git a/src/plugins/media-export/rygel-media-export-playlist-root-container.vala 
b/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
new file mode 100644
index 0000000..ef0cb39
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-playlist-root-container.vala
@@ -0,0 +1,64 @@
+using Gee;
+
+internal class Rygel.MediaExport.PlaylistRootContainer : Rygel.WritableContainer,
+                                                         DBContainer {
+    public ArrayList<string> create_classes { get; set; }
+
+    public PlaylistRootContainer (string id, string title) {
+        Object (id : id,
+                title : title,
+                parent : null,
+                child_count : 0);
+    }
+
+    public override void constructed () {
+        base.constructed ();
+
+        // We don't support adding real folders here, just playlist container
+        this.create_classes = new ArrayList<string> ();
+        this.create_classes.add (Rygel.MediaContainer.PLAYLIST);
+
+        this.uris.add ("rygel://playlist-root");
+
+        debug ("=> Updated create_classes");
+    }
+
+    public async void add_item (Rygel.MediaItem item,
+                                         Cancellable?    cancellable)
+                                         throws Error {
+        // FIXME: Add translation
+        throw new WriteableContainerError.NOT_IMPLEMENTED
+                                        ("Can't create items here");
+    }
+
+    public async void remove_item (string id,
+                                            Cancellable?    cancellable)
+                                            throws Error {
+        // FIXME: Add translation
+        throw new WriteableContainerError.NOT_IMPLEMENTED
+                                        ("Can't create items here");
+    }
+
+    public async void add_container (Rygel.MediaContainer container,
+                                              Cancellable?         cancellable)
+                                              throws Error {
+        if (container.upnp_class != Rygel.MediaContainer.PLAYLIST) {
+            warning ("===========> Foo! %s %s", container.upnp_class,
+                     Rygel.MediaContainer.PLAYLIST);
+            throw new WriteableContainerError.NOT_IMPLEMENTED
+                                        ("upnp:class not supported");
+        }
+
+        // FIXME: Do something here :)
+        assert_not_reached ();
+    }
+
+    public async void remove_container (string id,
+                                                 Cancellable?    cancellable)
+                                                 throws Error {
+        // FIXME: Add translation
+        throw new WriteableContainerError.NOT_IMPLEMENTED
+                                        ("Can't create items here");
+    }
+
+ }
diff --git a/src/plugins/media-export/rygel-media-export-writable-db-container.vala 
b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
index 82231e8..083e9c3 100644
--- a/src/plugins/media-export/rygel-media-export-writable-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
@@ -56,8 +56,9 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
         this.create_classes.add (Rygel.MediaContainer.STORAGE_FOLDER);
     }
 
-    public async void add_item (Rygel.MediaItem item, Cancellable? cancellable)
-                                throws Error {
+    public virtual async void add_item (Rygel.MediaItem item,
+                                        Cancellable? cancellable)
+                                        throws Error {
         item.parent = this;
         var file = File.new_for_uri (item.uris[0]);
         // TODO: Mark as place-holder. Make this proper some time.
@@ -68,9 +69,9 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
         yield this.add_child_tracked (item);
     }
 
-    public async void add_container (MediaContainer container,
-                                     Cancellable?   cancellable) 
-                                     throws Error {
+    public virtual async void add_container (MediaContainer container,
+                                             Cancellable?   cancellable) 
+                                             throws Error {
         container.parent = this;
         switch (container.upnp_class) {
         case MediaContainer.STORAGE_FOLDER:
@@ -80,22 +81,23 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
             }
             break;
         default:
-            throw new ContentDirectoryError.BAD_METADATA
+            throw new WriteableContainerError.NOT_IMPLEMENTED
                                         ("upnp:class not supported");
-            break;
+        }
 
         yield this.add_child_tracked (container);
     }
 
-    public async void remove_item (string id, Cancellable? cancellable)
-                                   throws Error {
+    public virtual async void remove_item (string id, Cancellable? cancellable)
+                                           throws Error {
         var object = this.media_db.get_object (id);
 
         yield this.remove_child_tracked (object);
     }
 
-    public async void remove_container (string id, Cancellable? cancellable)
-                                        throws Error {
+    public virtual async void remove_container (string id,
+                                                Cancellable? cancellable)
+                                                throws Error {
         throw new WriteableContainerError.NOT_IMPLEMENTED ("Not supported");
     }
 


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