[rygel] media-export: Allow reference creation everywhere
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Allow reference creation everywhere
- Date: Tue, 25 Jun 2013 11:49:32 +0000 (UTC)
commit 30d7757a150b2e5922da87194ec22c8fb01dc9a0
Author: Jens Georg <jensg openismus com>
Date: Tue Jun 18 15:40:26 2013 +0200
media-export: Allow reference creation everywhere
https://bugzilla.gnome.org/show_bug.cgi?id=702083
.../rygel-media-export-media-cache.vala | 22 ++++++++++++++
.../rygel-media-export-playlist-container.vala | 30 ++++----------------
.../rygel-media-export-writable-db-container.vala | 10 ++++--
3 files changed, 34 insertions(+), 28 deletions(-)
---
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 d98218b..987d11d 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -525,6 +525,28 @@ public class Rygel.MediaExport.MediaCache : Object {
}
}
+ public string create_reference (MediaObject object, MediaContainer parent)
+ throws Error {
+ if (object is MediaContainer) {
+ var msg = _("Cannot create references to containers");
+
+ throw new MediaCacheError.GENERAL_ERROR (msg);
+ }
+
+ object.parent = parent;
+
+ // If the original is already a ref_id, point to the original item as
+ // we should not daisy-chain reference items.
+ if (object.ref_id == null) {
+ object.ref_id = object.id;
+ }
+ object.id = UUID.get ();
+
+ this.save_item (object as MediaItem);
+
+ return object.id;
+ }
+
// Private functions
private bool is_object_guarded (string id) {
try {
diff --git a/src/plugins/media-export/rygel-media-export-playlist-container.vala
b/src/plugins/media-export/rygel-media-export-playlist-container.vala
index d243ec1..6b9f725 100644
--- a/src/plugins/media-export/rygel-media-export-playlist-container.vala
+++ b/src/plugins/media-export/rygel-media-export-playlist-container.vala
@@ -50,30 +50,6 @@ internal class Rygel.MediaExport.PlaylistContainer : DBContainer,
this.uris.add (PlaylistContainer.URI);
}
- public async string add_reference (Rygel.MediaObject object,
- Cancellable? cancellable)
- throws Error {
- if (object is MediaContainer) {
- throw new WritableContainerError.NOT_IMPLEMENTED
- ("Cannot create references to containers");
- }
-
- object.parent = this;
-
- // If the original is already a ref_id, point to the original item as
- // we should not daisy-chain reference items.
- if (object.ref_id == null) {
- object.ref_id = object.id;
- }
- object.id = UUID.get ();
-
- var cache = MediaCache.get_default ();
- cache.save_item (object as MediaItem);
-
- return object.id;
- }
-
-
public async void add_item (Rygel.MediaItem item,
Cancellable? cancellable)
throws Error {
@@ -82,6 +58,12 @@ internal class Rygel.MediaExport.PlaylistContainer : DBContainer,
this.id);
}
+ public virtual async string add_reference (MediaObject object,
+ Cancellable? cancellable)
+ throws Error {
+ return MediaCache.get_default ().create_reference (object, this);
+ }
+
public async void remove_item (string id,
Cancellable? cancellable)
throws Error {
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 3725456..6676032 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
@@ -59,10 +59,6 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
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 WritableContainerError.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.
@@ -74,6 +70,12 @@ internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
this.media_db.make_object_guarded (item);
}
+ public virtual async string add_reference (MediaObject object,
+ Cancellable? cancellable)
+ throws Error {
+ return MediaCache.get_default ().create_reference (object, this);
+ }
+
public virtual async void add_container (MediaContainer container,
Cancellable? cancellable)
throws Error {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]