[rygel/wip/track-changes: 3/6] Add LastChange to ContentDirectory.
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/track-changes: 3/6] Add LastChange to ContentDirectory.
- Date: Tue, 9 Oct 2012 09:10:10 +0000 (UTC)
commit ee005828a4708961ef3570527e88c7d0b97e1d47
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Tue Sep 11 16:37:56 2012 +0200
Add LastChange to ContentDirectory.
src/librygel-server/rygel-content-directory.vala | 76 +++++++++++++++++++++-
1 files changed, 73 insertions(+), 3 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala b/src/librygel-server/rygel-content-directory.vala
index 67bee6a..0e337f0 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -69,6 +69,8 @@ internal class Rygel.ContentDirectory: Service {
public uint32 system_update_id;
+ private LastChange last_change;
+
public override void constructed () {
this.cancellable = new Cancellable ();
@@ -82,6 +84,8 @@ internal class Rygel.ContentDirectory: Service {
this.finished_imports = new ArrayList<ImportResource> ();
this.root_container.container_updated.connect (on_container_updated);
+ this.root_container.sub_tree_updates_finished.connect
+ (on_sub_tree_updates_finished);
this.feature_list =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
@@ -128,6 +132,9 @@ internal class Rygel.ContentDirectory: Service {
this.get_feature_list_cb);
this.query_variable["FeatureList"].connect (this.query_feature_list);
+ /* Connect LastChange related signals */
+ this.query_variable["LastChange"].connect (this.query_last_change);
+
this.http_server.run.begin ();
}
@@ -376,6 +383,7 @@ internal class Rygel.ContentDirectory: Service {
MediaObject object,
ObjectEventType event_type,
bool sub_tree_update) {
+ this.add_last_change_entry (object, event_type, sub_tree_update);
this.system_update_id++;
updated_container.update_id = this.system_update_id++;
@@ -388,9 +396,19 @@ internal class Rygel.ContentDirectory: Service {
this.updated_containers.remove (updated_container);
this.updated_containers.add (updated_container);
- if (this.update_notify_id == 0) {
- this.update_notify_id = Timeout.add (200, this.update_notify);
- }
+ this.ensure_timeout ();
+ }
+
+ private void on_sub_tree_updates_finished (MediaContainer root_container,
+ MediaObject sub_tree_root)
+ {
+ this.system_update_id++;
+
+ var entry = new LastChangeStDone (sub_tree_root.id,
+ this.system_update_id);
+
+ this.last_change.add_event (entry);
+ this.ensure_timeout ();
}
private bool update_notify () {
@@ -398,9 +416,11 @@ internal class Rygel.ContentDirectory: Service {
this.notify ("ContainerUpdateIDs", typeof (string), update_ids);
this.notify ("SystemUpdateID", typeof (uint32), this.system_update_id);
+ this.notify ("LastChange", typeof (string), this.last_change.get_log ());
this.clear_updated_containers = true;
this.update_notify_id = 0;
+ this.last_change.clear_on_new_event ();
return false;
}
@@ -465,4 +485,54 @@ internal class Rygel.ContentDirectory: Service {
return ret;
}
+
+ /* Query LastChange */
+ private void query_last_change (Service content_dir,
+ string variable,
+ ref GLib.Value value) {
+ value.init (typeof (string));
+ value.set_string (this.last_change.get_log ());
+ }
+
+ private void ensure_timeout ()
+ {
+ if (this.update_notify_id == 0) {
+ this.update_notify_id = Timeout.add (200, this.update_notify);
+ }
+ }
+
+ private void add_last_change_entry (MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update)
+ {
+ LastChangeEntry entry;
+
+ this.system_update_id++;
+ switch (event_type) {
+ case ObjectEventType.ADDED:
+ entry = new LastChangeObjAdd (object.id,
+ this.system_update_id,
+ sub_tree_update,
+ object.parent.id,
+ object.upnp_class);
+ break;
+
+ case ObjectEventType.MODIFIED:
+ entry = new LastChangeObjMod (object.id,
+ this.system_update_id,
+ sub_tree_update);
+ break;
+
+ case ObjectEventType.DELETED:
+ entry = new LastChangeObjDel (object.id,
+ this.system_update_id,
+ sub_tree_update);
+ break;
+
+ default:
+ assert_not_reached ();
+ }
+
+ this.last_change.add_event (entry);
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]