[rygel] media-export: Only on-disk container are writable
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Only on-disk container are writable
- Date: Sun, 28 Nov 2010 19:38:11 +0000 (UTC)
commit 8e163ab06c635283bc7be362117879a0d0ced40f
Author: Jens Georg <mail jensge org>
Date: Sat Nov 27 20:45:02 2010 +0100
media-export: Only on-disk container are writable
Special containers like "Filesystem" or the query folders should not be
marked writable.
src/plugins/media-export/Makefile.am | 3 +-
.../rygel-media-export-db-container.vala | 23 +---------
.../rygel-media-export-media-cache.vala | 4 +-
.../rygel-media-export-object-factory.vala | 13 ++++-
.../rygel-media-export-writable-db-container.vala | 50 ++++++++++++++++++++
5 files changed, 65 insertions(+), 28 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index bec6b8b..feed6d2 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -38,7 +38,8 @@ librygel_media_export_la_SOURCES = rygel-media-export-plugin.vala \
rygel-media-export-harvesting-task.vala \
rygel-media-export-item.vala \
rygel-media-export-jpeg-writer.vala \
- rygel-media-export-object-factory.vala
+ rygel-media-export-object-factory.vala \
+ rygel-media-export-writable-db-container.vala
librygel_media_export_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
--pkg rygel-1.0 \
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index 4357573..37ca44e 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -22,21 +22,12 @@
using GUPnP;
using Gee;
-public class Rygel.MediaExport.DBContainer : MediaContainer, WritableContainer {
+public class Rygel.MediaExport.DBContainer : MediaContainer {
protected MediaCache media_db;
- public ArrayList<string> create_classes { get; set; }
-
public DBContainer (MediaCache media_db, string id, string title) {
base (id, null, title, 0);
- this.create_classes = new ArrayList<string> ();
- this.create_classes.add (ImageItem.UPNP_CLASS);
- this.create_classes.add (PhotoItem.UPNP_CLASS);
- this.create_classes.add (VideoItem.UPNP_CLASS);
- this.create_classes.add (AudioItem.UPNP_CLASS);
- this.create_classes.add (MusicItem.UPNP_CLASS);
-
this.media_db = media_db;
this.container_updated.connect (on_db_container_updated);
this.on_db_container_updated (this, this);
@@ -95,16 +86,4 @@ public class Rygel.MediaExport.DBContainer : MediaContainer, WritableContainer {
throws Error {
return this.media_db.get_object (id);
}
-
- public async void add_item (Rygel.MediaItem item, Cancellable? cancellable)
- throws Error {
- item.parent = this;
- item.id = MediaCache.get_id (File.new_for_uri (item.uris[0]));
- this.media_db.save_item (item);
- }
-
- public async void remove_item (string id, Cancellable? cancellable)
- throws Error {
- this.media_db.remove_by_id (id);
- }
}
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 5dca27c..8b3e063 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -531,10 +531,10 @@ public class Rygel.MediaExport.MediaCache : Object {
switch (statement.column_int (DetailColumn.TYPE)) {
case 0:
// this is a container
- object = factory.get_container (this, object_id, title, 0);
+ var uri = statement.column_text (DetailColumn.URI);
+ object = factory.get_container (this, object_id, title, 0, uri);
var container = object as MediaContainer;
- var uri = statement.column_text (DetailColumn.URI);
if (uri != null) {
container.uris.add (uri);
}
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 ce34bd4..e7fce2a 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -31,7 +31,8 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
public virtual DBContainer get_container (MediaCache media_db,
string id,
string title,
- uint child_count) {
+ uint child_count,
+ string? uri) {
if (id == "0") {
try {
return RootContainer.get_instance () as DBContainer;
@@ -39,11 +40,17 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
// Must not fail - plugin is disabled if this fails
assert_not_reached ();
}
- } else if (id.has_prefix (QueryContainer.PREFIX)) {
+ }
+
+ if (id.has_prefix (QueryContainer.PREFIX)) {
return new QueryContainer (media_db, id, title);
- } else {
+ }
+
+ if (uri == null) {
return new DBContainer (media_db, id, title);
}
+
+ return new WritableDbContainer (media_db, id, title);
}
/**
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
new file mode 100644
index 0000000..061d54d
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ *
+ * Author: Jens Georg <mail jensge org>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+using Gee;
+
+internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
+ Rygel.WritableContainer {
+ public ArrayList<string> create_classes { get; set; }
+
+ public WritableDbContainer (MediaCache media_db, string id, string title) {
+ base (media_db, id, title);
+
+ this.create_classes = new ArrayList<string> ();
+ this.create_classes.add (ImageItem.UPNP_CLASS);
+ this.create_classes.add (PhotoItem.UPNP_CLASS);
+ this.create_classes.add (VideoItem.UPNP_CLASS);
+ this.create_classes.add (AudioItem.UPNP_CLASS);
+ this.create_classes.add (MusicItem.UPNP_CLASS);
+ }
+
+ public async void add_item (Rygel.MediaItem item, Cancellable? cancellable)
+ throws Error {
+ item.parent = this;
+ item.id = MediaCache.get_id (File.new_for_uri (item.uris[0]));
+ this.media_db.save_item (item);
+ }
+
+ public async void remove_item (string id, Cancellable? cancellable)
+ throws Error {
+ this.media_db.remove_by_id (id);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]