[rygel] server: Get ServiceResetToken from RootContainer



commit c13ecc2775bb04b14b8f8cda50b9edcfbf3b0246
Author: Jens Georg <jensg openismus com>
Date:   Thu Dec 6 14:02:51 2012 +0100

    server: Get ServiceResetToken from RootContainer
    
    https://bugzilla.gnome.org/show_bug.cgi?id=689134

 src/librygel-server/rygel-content-directory.vala   |   12 ++++++++++-
 src/librygel-server/rygel-trackable-container.vala |   22 ++++++++++++++++++++
 2 files changed, 33 insertions(+), 1 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala b/src/librygel-server/rygel-content-directory.vala
index 6de630e..93ae102 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -116,7 +116,12 @@ internal class Rygel.ContentDirectory: Service {
             "http://www.upnp.org/schemas/av/avs-v1-20060531.xsd\";>" +
             "</Features>";
 
-        this.service_reset_token = UUID.get ();
+        if (this.root_container is TrackableContainer) {
+            var trackable = this.root_container as TrackableContainer;
+            this.service_reset_token = trackable.get_service_reset_token ();
+        } else {
+            this.service_reset_token = UUID.get ();
+        }
 
         this.action_invoked["Browse"].connect (this.browse_cb);
         this.action_invoked["Search"].connect (this.search_cb);
@@ -609,6 +614,11 @@ internal class Rygel.ContentDirectory: Service {
         var plugin = this.root_device.resource_factory as MediaServerPlugin;
         plugin.active = false;
         this.service_reset_token = UUID.get ();
+        if (this.root_container is TrackableContainer) {
+            var trackable = this.root_container as TrackableContainer;
+            trackable.set_service_reset_token (this.service_reset_token);
+        }
+
         var expression = new RelationalExpression ();
         expression.operand1 = "upnp:objectUpdateID";
         expression.operand2 = "true";
diff --git a/src/librygel-server/rygel-trackable-container.vala b/src/librygel-server/rygel-trackable-container.vala
index 952d7a4..dbd6371 100644
--- a/src/librygel-server/rygel-trackable-container.vala
+++ b/src/librygel-server/rygel-trackable-container.vala
@@ -64,6 +64,28 @@ public interface Rygel.TrackableContainer : Rygel.MediaContainer {
         this.updated ();
     }
 
+    /**
+     * Used to query the (persisted) service reset token from the plug-in.
+     *
+     * If a plugin implements PLUGIN_CAPABILITIES_TRACK_CHANGES, it should
+     * persist the ServiceResetToken. To do this override this virtual
+     * function in the root container implementation and provide the persisted
+     * version.
+     */
+    public virtual string get_service_reset_token () {
+        return UUID.get ();
+    }
+
+    /**
+     * Set a new service reset token.
+     *
+     * If the service reset procedure has to be performed, the content
+     * directory service will set the new service reset token.
+     *
+     * @param token the new service reset token.
+     */
+    public virtual void set_service_reset_token (string token) {}
+
     private void thaw_events () {
         // Forward events.
     }



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]