[rygel/wip/sync: 1/2] wip: Add tracking to media-export
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/sync: 1/2] wip: Add tracking to media-export
- Date: Wed, 24 Oct 2012 10:27:11 +0000 (UTC)
commit b199950caa64838228ae79772024d546456183b2
Author: Jens Georg <jensg openismus com>
Date: Wed Oct 24 10:45:25 2012 +0200
wip: Add tracking to media-export
src/plugins/media-export/Makefile.am | 1 +
.../rygel-media-export-harvesting-task.vala | 6 +--
.../media-export/rygel-media-export-plugin.vala | 3 +-
.../rygel-media-export-root-container.vala | 32 ++++++-------
.../rygel-media-export-trackable-db-container.vala | 46 ++++++++++++++++++++
.../rygel-media-export-writable-db-container.vala | 10 +++-
6 files changed, 72 insertions(+), 26 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 3294d1f..eccfd73 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -15,6 +15,7 @@ librygel_media_export_la_SOURCES = \
rygel-media-export-database-cursor.vala \
rygel-media-export-sqlite-wrapper.vala \
rygel-media-export-db-container.vala \
+ rygel-media-export-trackable-db-container.vala \
rygel-media-export-sql-factory.vala \
rygel-media-export-media-cache.vala \
rygel-media-export-sql-operator.vala \
diff --git a/src/plugins/media-export/rygel-media-export-harvesting-task.vala b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
index a0fdb67..dbd34b4 100644
--- a/src/plugins/media-export/rygel-media-export-harvesting-task.vala
+++ b/src/plugins/media-export/rygel-media-export-harvesting-task.vala
@@ -309,11 +309,7 @@ public class Rygel.MediaExport.HarvestingTask : Rygel.StateMachine,
if (item != null) {
item.parent_ref = this.containers.peek_head ();
- try {
- this.cache.save_item (item);
- } catch (Error error) {
- // Ignore it for now
- }
+ (item as UpdatableObject).commit.begin ();
}
this.files.poll ();
diff --git a/src/plugins/media-export/rygel-media-export-plugin.vala b/src/plugins/media-export/rygel-media-export-plugin.vala
index 42df8b3..d56ec42 100644
--- a/src/plugins/media-export/rygel-media-export-plugin.vala
+++ b/src/plugins/media-export/rygel-media-export-plugin.vala
@@ -108,6 +108,7 @@ public class Rygel.MediaExport.Plugin : Rygel.MediaServerPlugin {
base (RootContainer.get_instance (),
NAME,
null,
- PluginCapabilities.UPLOAD);
+ PluginCapabilities.UPLOAD |
+ PluginCapabilities.TRACK_CHANGES);
}
}
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 e39e2c1..b6d79bc 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -40,7 +40,7 @@ const Rygel.MediaExport.FolderDefinition[] virtual_folders_music = {
/**
* Represents the root container.
*/
-public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
+public class Rygel.MediaExport.RootContainer : TrackableDBContainer {
private DBusService service;
private Harvester harvester;
private Cancellable cancellable;
@@ -366,14 +366,13 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
this.media_db.save_container (this);
} catch (Error error) { } // do nothing
- try {
- this.filesystem_container = new DBContainer
- (media_db,
- FILESYSTEM_FOLDER_ID,
- _(FILESYSTEM_FOLDER_NAME));
- this.filesystem_container.parent = this;
- this.media_db.save_container (this.filesystem_container);
- } catch (Error error) { }
+ this.filesystem_container = new TrackableDBContainer
+ (media_db,
+ FILESYSTEM_FOLDER_ID,
+ _(FILESYSTEM_FOLDER_NAME));
+ this.filesystem_container.parent = this;
+ //this.media_db.save_container (this.filesystem_container);
+ this.add_child_tracked.begin (this.filesystem_container);
ArrayList<string> ids;
try {
@@ -395,21 +394,20 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
foreach (var id in ids) {
debug ("ID %s no longer in config; deleting...", id);
- try {
- this.media_db.remove_by_id (id);
- } catch (DatabaseError error) {
- warning (_("Failed to remove entry: %s"), error.message);
- }
+ var container = new NullContainer ();
+ container.parent = this;
+ container.id = id;
+ this.remove_child_tracked.begin (container);
}
- this.updated ();
+ //this.updated ();
}
private void on_initial_harvesting_done () {
this.harvester.disconnect (this.harvester_signal_id);
this.media_db.debug_statistics ();
this.add_default_virtual_folders ();
- this.updated ();
+ //this.updated ();
this.filesystem_container.container_updated.connect( () => {
this.add_default_virtual_folders ();
@@ -478,7 +476,7 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
if (this.media_db.get_child_count (container.id) == 0) {
this.media_db.remove_by_id (container.id);
} else {
- container.updated ();
+ this.updated (container, ObjectEventType.ADDED);
}
}
}
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..8eed065
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-trackable-db-container.vala
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+public class Rygel.MediaExport.TrackableDBContainer : DBContainer,
+ Rygel.TrackableContainer {
+ public TrackableDBContainer (MediaCache media_db,
+ string id,
+ string title) {
+ base (media_db, id, title);
+ }
+
+ public async void add_child (MediaObject object) {
+ try {
+ if (object is MediaContainer) {
+ this.media_db.save_container (object as MediaContainer);
+ } else {
+ this.media_db.save_item (object as MediaItem);
+ }
+ } catch (Error error) { }
+ }
+
+ public async void remove_child (MediaObject object) {
+ try {
+ this.media_db.remove_by_id (object.id);
+ } catch (Error 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 f3c3073..f37c170 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,7 +21,7 @@
*/
using Gee;
-internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
+internal class Rygel.MediaExport.WritableDbContainer : TrackableDBContainer,
Rygel.WritableContainer {
public ArrayList<string> create_classes { get; set; }
@@ -45,11 +45,15 @@ internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
item.modified = int64.MAX;
}
item.id = MediaCache.get_id (file);
- this.media_db.save_item (item);
+ this.add_child_tracked.begin (item);
}
public async void remove_item (string id, Cancellable? cancellable)
throws Error {
- this.media_db.remove_by_id (id);
+ var container = new NullContainer ();
+ container.parent = this;
+ container.id = id;
+
+ this.remove_child_tracked.begin (container);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]