[rygel/wip/create-reference: 6/11] wip: Implement playlistContainer in media-export
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/create-reference: 6/11] wip: Implement playlistContainer in media-export
- Date: Wed, 6 Mar 2013 16:20:14 +0000 (UTC)
commit 32594dbeeabc177213dddf59b9555f73f112ad57
Author: Jens Georg <jensg openismus com>
Date: Thu Feb 28 15:00:43 2013 +0100
wip: Implement playlistContainer in media-export
src/librygel-server/rygel-media-object.vala | 2 +-
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 +++++---
5 files changed, 85 insertions(+), 10 deletions(-)
---
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/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 0f384a3..7bba83d 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 7a2944e..f9978c8 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,13 @@ 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 {
+ if (item.id == null && item.ref_id != null) {
+ warning ("=> CreateReference not supported");
+ throw new WriteableContainerError.NOT_IMPLEMENTED ("Not supported");
+ }
item.parent = this;
var file = File.new_for_uri (item.uris[0]);
// TODO: Mark as place-holder. Make this proper some time.
@@ -69,9 +74,9 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
this.media_db.make_object_guarded (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:
@@ -89,15 +94,16 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
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]