[rygel] media-export: Implement MediaContainer.add_item()
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Implement MediaContainer.add_item()
- Date: Wed, 17 Feb 2010 13:41:50 +0000 (UTC)
commit a271a6ce4ec708a3f4bc8aace80220350f994c25
Author: Jens Georg <mail jensge org>
Date: Mon Feb 8 11:10:52 2010 +0100
media-export: Implement MediaContainer.add_item()
MediaExport now has it's own implementation of MediaContainer that is
specifically meant for adding a complete add_item() implementation to
MediaDBContainer.
src/plugins/media-export/Makefile.am | 1 +
.../rygel-media-export-object-factory.vala | 6 +++
.../rygel-media-export-writable-container.vala | 41 ++++++++++++++++++++
3 files changed, 48 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index aec8ee7..e19f78b 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -22,6 +22,7 @@ librygel_media_export_la_SOURCES = rygel-media-export-plugin.vala \
rygel-media-export-recursive-file-monitor.vala \
rygel-media-export-harvester.vala \
rygel-media-export-item.vala \
+ rygel-media-export-writable-container.vala \
rygel-media-export-object-factory.vala
librygel_media_export_la_VALAFLAGS = --vapidir=$(top_srcdir)/src/rygel \
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 9fd3d02..4ccaf70 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -21,4 +21,10 @@
*/
internal class Rygel.MediaExportObjectFactory : MediaDBObjectFactory {
+ public override MediaContainer get_container (MediaDB media_db,
+ string id,
+ string title,
+ uint child_count) {
+ return new MediaExportWritableContainer (media_db, id, title);
+ }
}
diff --git a/src/plugins/media-export/rygel-media-export-writable-container.vala b/src/plugins/media-export/rygel-media-export-writable-container.vala
new file mode 100644
index 0000000..8d62603
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-writable-container.vala
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2010 Jens Georg <mail jensge org>.
+ * Copyright (C) 2010 Nokia Corporation.
+ *
+ * Author: Jens Georg <mail jensge org>
+ * Zeeshan Ali (Khattak) <zeeshan ali nokia com>
+ * <zeeshanak gnome 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.
+ */
+internal class Rygel.MediaExportWritableContainer : MediaDBContainer {
+ public MediaExportWritableContainer (MediaDB media_db,
+ string id,
+ string title) {
+ base (media_db, id, title);
+ }
+
+ public override async void add_item (MediaItem item,
+ Cancellable? cancellable)
+ throws Error {
+ yield base.add_item (item, cancellable);
+
+ item.parent = this;
+ item.id = Checksum.compute_for_string (ChecksumType.MD5, item.uris[0]);
+ this.media_db.save_item (item);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]