rygel r612 - trunk/src/rygel
- From: zeeshanak svn gnome org
- To: svn-commits-list gnome org
- Subject: rygel r612 - trunk/src/rygel
- Date: Mon, 16 Feb 2009 17:33:23 +0000 (UTC)
Author: zeeshanak
Date: Mon Feb 16 17:33:23 2009
New Revision: 612
URL: http://svn.gnome.org/viewvc/rygel?rev=612&view=rev
Log:
Implement notification of container updates.
All plugins need to do to notify clients of changes in a container,
let's say 'some_container' is to call 'some_container.updated()'.
Modified:
trunk/src/rygel/rygel-content-directory.vala
Modified: trunk/src/rygel/rygel-content-directory.vala
==============================================================================
--- trunk/src/rygel/rygel-content-directory.vala (original)
+++ trunk/src/rygel/rygel-content-directory.vala Mon Feb 16 17:33:23 2009
@@ -53,6 +53,9 @@
public MediaContainer root_container;
private ArrayList<MediaContainer> updated_containers;
+ private bool clear_updated_containers;
+ private uint update_notify_id;
+
private ArrayList<Browse> browses;
public uint32 system_update_id;
@@ -68,6 +71,8 @@
this.browses = new ArrayList<Browse> ();
this.updated_containers = new ArrayList<MediaContainer> ();
+ this.root_container.container_updated += on_container_updated;
+
this.feature_list =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Features xmlns=\"urn:schemas-upnp-org:av:avs\" " +
@@ -219,5 +224,46 @@
return update_ids;
}
+
+ /**
+ * handler for container_updated signal on root_container. We don't
+ * immediately send the notification for changes but schedule the
+ * notification after 0.2 seconds. Also we don't clear the updated
+ * container list immediately after notification but rather in this
+ * function. Please refer to ContentDirectory version 2 specs for details
+ * on why we do all this the way we do.
+ *
+ * @param root_container the root_container
+ * @param updated_container the container that just got updated
+ */
+ private void on_container_updated (MediaContainer root_container,
+ MediaContainer updated_container) {
+ this.system_update_id++;
+
+ if (this.clear_updated_containers) {
+ this.updated_containers.clear ();
+ this.clear_updated_containers = false;
+ }
+
+ // UPnP specs dicate we make sure only last update be evented
+ 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);
+ }
+ }
+
+ private bool update_notify () {
+ var update_ids = this.create_container_update_ids ();
+
+ this.notify ("ContainerUpdateIDs", typeof (string), update_ids);
+ this.notify ("SystemUpdateID", typeof (uint32), this.system_update_id);
+
+ this.clear_updated_containers = true;
+ this.update_notify_id = 0;
+
+ return false;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]