[rygel/wip/track-changes: 3/18] WIP: Changed MediaContainer's updated() and container_updated signal.
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/track-changes: 3/18] WIP: Changed MediaContainer's updated() and container_updated signal.
- Date: Mon, 22 Oct 2012 08:46:54 +0000 (UTC)
commit 39e64ad269b53220d0b492e568186e459a4a87c4
Author: Krzesimir Nowak <qdlacz gmail com>
Date: Tue Sep 11 16:34:57 2012 +0200
WIP: Changed MediaContainer's updated() and container_updated signal.
src/librygel-server/rygel-content-directory.vala | 6 ++-
src/librygel-server/rygel-media-container.vala | 54 +++++++++++++++++---
src/librygel-server/rygel-media-server-plugin.vala | 5 ++-
src/librygel-server/rygel-simple-container.vala | 10 +++-
4 files changed, 62 insertions(+), 13 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala b/src/librygel-server/rygel-content-directory.vala
index e68b710..8f12562 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -373,8 +373,12 @@ internal class Rygel.ContentDirectory: Service {
* @param updated_container the container that just got updated
*/
private void on_container_updated (MediaContainer root_container,
- MediaContainer updated_container) {
+ MediaContainer updated_container,
+ MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update) {
this.system_update_id++;
+ updated_container.update_id = this.system_update_id++;
if (this.clear_updated_containers) {
this.updated_containers.clear ();
diff --git a/src/librygel-server/rygel-media-container.vala b/src/librygel-server/rygel-media-container.vala
index 47ff14e..cee27d4 100644
--- a/src/librygel-server/rygel-media-container.vala
+++ b/src/librygel-server/rygel-media-container.vala
@@ -27,6 +27,12 @@
using GUPnP;
using Gee;
+public enum Rygel.ObjectEventType {
+ ADDED = 0,
+ MODIFIED = 1,
+ DELETED = 2
+}
+
/**
* This is a container (folder) for media items and child containers.
*
@@ -54,11 +60,29 @@ public abstract class Rygel.MediaContainer : MediaObject {
/**
* The container_updated signal is emitted if a child container under the
- * tree of this container has been updated.
+ * tree of this container has been updated. object is set to
+ * the MediaObject being the source of container update. Note that
+ * it may be even set to container itself.
*
* @param container The child container that has been updated.
+ * @param object the object that got changed.
+ * @param event_type describes what actually happened to object.
+ * @param sub_tree_update whether the modification is part of
+ * sub-tree update.
+ */
+ public signal void container_updated (MediaContainer container,
+ MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update);
+
+ /**
+ * sub_tree_updates_finished signal is emitted when all of
+ * sub-tree operations are finished.
+ *
+ * @param sub_tree_root - root of a sub-tree where all operations
+ * were performed.
*/
- public signal void container_updated (MediaContainer container);
+ public signal void sub_tree_updates_finished (MediaObject sub_tree_root);
public int child_count;
public uint32 update_id;
@@ -110,6 +134,7 @@ public abstract class Rygel.MediaContainer : MediaObject {
this.upnp_class = STORAGE_FOLDER;
this.container_updated.connect (on_container_updated);
+ this.sub_tree_updates_finished.connect (on_sub_tree_updates_finished);
}
public MediaContainer.root (string title,
@@ -152,11 +177,11 @@ public abstract class Rygel.MediaContainer : MediaObject {
* for this container, if items under it are removed or added, if
* there are metadata changes to items under it, etc.
*/
- public void updated () {
- this.update_id++;
-
+ public void updated (MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update) {
// Emit the signal that will start the bump-up process for this event.
- this.container_updated (this);
+ this.container_updated (this, object, event_type, sub_tree_update);
}
internal override DIDLLiteObject serialize (DIDLLiteWriter writer,
@@ -205,9 +230,22 @@ public abstract class Rygel.MediaContainer : MediaObject {
* @param updated_container the container that just got updated
*/
private void on_container_updated (MediaContainer container,
- MediaContainer updated_container) {
+ MediaContainer updated_container,
+ MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update) {
+ if (this.parent != null) {
+ this.parent.container_updated (updated_container,
+ object,
+ event_type,
+ sub_tree_update);
+ }
+ }
+
+ private void on_sub_tree_updates_finished (MediaContainer container,
+ MediaObject sub_tree_root) {
if (this.parent != null) {
- this.parent.container_updated (updated_container);
+ this.parent.sub_tree_updates_finished (sub_tree_root);
}
}
}
diff --git a/src/librygel-server/rygel-media-server-plugin.vala b/src/librygel-server/rygel-media-server-plugin.vala
index cbea507..5d34268 100644
--- a/src/librygel-server/rygel-media-server-plugin.vala
+++ b/src/librygel-server/rygel-media-server-plugin.vala
@@ -87,7 +87,10 @@ public abstract class Rygel.MediaServerPlugin : Rygel.Plugin {
}
private void on_container_updated (MediaContainer root_container,
- MediaContainer updated) {
+ MediaContainer updated,
+ MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update) {
if (updated != root_container || updated.child_count == 0) {
return;
}
diff --git a/src/librygel-server/rygel-simple-container.vala b/src/librygel-server/rygel-simple-container.vala
index 13a10fb..7f52510 100644
--- a/src/librygel-server/rygel-simple-container.vala
+++ b/src/librygel-server/rygel-simple-container.vala
@@ -127,6 +127,7 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer,
* from the container.
*/
public void clear () {
+ // TODO: this will have to emit sub-tree events of object being deleted.
this.children.clear ();
this.child_count = 0;
@@ -257,7 +258,10 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer,
}
private void on_container_updated (MediaContainer source,
- MediaContainer updated) {
+ MediaContainer updated,
+ MediaObject object,
+ ObjectEventType event_type,
+ bool sub_tree_update) {
if (updated.child_count > 0) {
if (!(updated in this.empty_children)) {
return;
@@ -267,7 +271,7 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer,
this.add_child (updated);
- this.updated ();
+ this.updated (updated, ObjectEventType.ADDED, false);
debug ("Container '%s' now non-empty, added it to hierarchy now.",
updated.id);
@@ -279,7 +283,7 @@ public class Rygel.SimpleContainer : Rygel.MediaContainer,
this.remove_child (updated);
this.empty_children.add (updated);
- this.updated ();
+ this.updated (updated, ObjectEventType.DELETED, false);
debug ("Container '%s' now empty, removing it from hierarchy now.",
updated.id);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]