[rygel/wip/track-changes: 25/34] WIP
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/track-changes: 25/34] WIP
- Date: Tue, 11 Dec 2012 20:10:03 +0000 (UTC)
commit e0b0fd57715ecc64b4ff2fc1e265c5b8e1687b8c
Author: Jens Georg <jensg openismus com>
Date: Thu Dec 6 16:55:07 2012 +0100
WIP
src/plugins/media-export/Makefile.am | 3 +-
.../rygel-media-export-object-factory.vala | 2 +-
.../rygel-media-export-root-container.vala | 24 +-------
.../rygel-media-export-trackable-db-container.vala | 60 ++++++++++++++++++++
.../rygel-media-export-writable-db-container.vala | 10 ++-
5 files changed, 72 insertions(+), 27 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 013f42c..c7b394e 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -1,4 +1,4 @@
-include ../../../common.am
+include $(top_srcdir)/common.am
plugin_LTLIBRARIES = librygel-media-export.la
@@ -40,6 +40,7 @@ librygel_media_export_la_SOURCES = \
rygel-media-export-video-item.vala \
rygel-media-export-photo-item.vala \
rygel-media-export-playlist-item.vala \
+ rygel-media-export-trackable-db-container.vala \
rygel-media-export-collate.c
librygel_media_export_la_VALAFLAGS = \
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 3773bb4..a56c154 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -56,7 +56,7 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
}
if (uri == null) {
- return new DBContainer (media_db, id, title);
+ return new TrackableDbContainer (media_db, id, title);
}
return new WritableDbContainer (media_db, id, title);
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index 8bcbcfb..23b5188 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -40,8 +40,7 @@ const Rygel.MediaExport.FolderDefinition[] VIRTUAL_FOLDERS_MUSIC = {
/**
* Represents the root container.
*/
-public class Rygel.MediaExport.RootContainer : Rygel.TrackableContainer,
- Rygel.MediaExport.DBContainer {
+public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
private DBusService service;
private Harvester harvester;
private Cancellable cancellable;
@@ -191,14 +190,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.TrackableContainer,
}
}
- // TrackableContainer overrides
- public string get_service_reset_token () {
- return this.media_db.get_reset_token ();
- }
-
- public void set_service_reset_token (string token) {
- this.media_db.save_reset_token (token);
- }
+ // Private methods
private ArrayList<File> get_shared_uris () {
ArrayList<string> uris;
@@ -375,7 +367,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.TrackableContainer,
} catch (Error error) { } // do nothing
try {
- this.filesystem_container = new DBContainer
+ this.filesystem_container = new TrackableDbContainer
(media_db,
FILESYSTEM_FOLDER_ID,
_(FILESYSTEM_FOLDER_NAME));
@@ -491,14 +483,4 @@ public class Rygel.MediaExport.RootContainer : Rygel.TrackableContainer,
container.updated ();
}
}
-
- public async void add_child (MediaObject object) {
- // TODO: Implement
- assert_not_reached ();
- }
-
- public async void remove_child (MediaObject object) {
- // TODO: Implement
- assert_not_reached ();
- }
}
diff --git a/src/plugins/media-export/rygel-media-export-trackable-db-container.vala b/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
new file mode 100644
index 0000000..dd6ee28
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus com>
+ *
+ * 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;
+
+public class Rygel.MediaExport.TrackableDbContainer : TrackableContainer,
+ DBContainer {
+ public TrackableDbContainer (MediaCache cache, string id, string title) {
+ base (cache, id, title);
+ }
+
+ public async void add_child (MediaObject object) {
+ try {
+ if (object is MediaItem) {
+ this.media_db.save_item (object as MediaItem);
+ } else if (object is MediaContainer) {
+ this.media_db.save_container (object as MediaContainer);
+ } else {
+ assert_not_reached ();
+ }
+ } catch (Error error) {
+ warning ("Failed to add object: %s", error.message);
+ }
+ }
+
+ public async void remove_child (MediaObject object) {
+ try {
+ this.media_db.remove_object (object);
+ } catch (Error error) {
+ warning ("Failed to remove object: %s", error.message);
+ }
+ }
+
+ // TrackableContainer overrides
+ public virtual string get_service_reset_token () {
+ return this.media_db.get_reset_token ();
+ }
+
+ public virtual void set_service_reset_token (string token) {
+ this.media_db.save_reset_token (token);
+ }
+}
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 20746f0..2d16967 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
@@ -21,8 +21,8 @@
*/
using Gee;
-internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
- Rygel.WritableContainer {
+internal class Rygel.MediaExport.WritableDbContainer : TrackableDbContainer,
+ Rygel.WritableContainer {
public ArrayList<string> create_classes { get; set; }
public WritableDbContainer (MediaCache media_db, string id, string title) {
@@ -46,11 +46,13 @@ internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
item.modified = int64.MAX;
}
item.id = MediaCache.get_id (file);
- this.media_db.save_item (item);
+ yield this.add_child_tracked (item);
}
public async void remove_item (string id, Cancellable? cancellable)
throws Error {
- this.media_db.remove_by_id (id);
+ var object = this.media_db.get_object (id);
+
+ yield this.remove_child_tracked (object);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]