[rygel/wip/track-changes: 34/34] WIP



commit 1c762d3d93349a6b8690a86c9a4af6a19a5c5789
Author: Jens Georg <jensg openismus com>
Date:   Tue Dec 11 21:08:14 2012 +0100

    WIP

 src/librygel-server/rygel-content-directory.vala   |   22 ++++++++------
 .../media-export/rygel-media-export-harvester.vala |    6 +++-
 .../rygel-media-export-root-container.vala         |   30 ++++++++++++++++++++
 3 files changed, 48 insertions(+), 10 deletions(-)
---
diff --git a/src/librygel-server/rygel-content-directory.vala b/src/librygel-server/rygel-content-directory.vala
index 3834b6b..97c25e1 100644
--- a/src/librygel-server/rygel-content-directory.vala
+++ b/src/librygel-server/rygel-content-directory.vala
@@ -96,6 +96,19 @@ internal class Rygel.ContentDirectory: Service {
         this.active_imports = new ArrayList<ImportResource> ();
         this.finished_imports = new ArrayList<ImportResource> ();
 
+        if (this.root_container is TrackableContainer) {
+            var trackable = this.root_container as TrackableContainer;
+            this.service_reset_token = trackable.get_service_reset_token ();
+            this.system_update_id = trackable.get_system_update_id ();
+            debug ("==========================================\n" +
+                   "SystemUpdateID: %u\n" +
+                   "==========================================\n",
+                   this.system_update_id);
+        } else {
+            this.service_reset_token = UUID.get ();
+            this.system_update_id = 0;
+        }
+
         this.root_container.container_updated.connect (on_container_updated);
         this.root_container.sub_tree_updates_finished.connect
                                         (on_sub_tree_updates_finished);
@@ -116,15 +129,6 @@ internal class Rygel.ContentDirectory: Service {
             "http://www.upnp.org/schemas/av/avs-v1-20060531.xsd\";>" +
             "</Features>";
 
-        if (this.root_container is TrackableContainer) {
-            var trackable = this.root_container as TrackableContainer;
-            this.service_reset_token = trackable.get_service_reset_token ();
-            this.system_update_id = trackable.get_system_update_id ();
-        } else {
-            this.service_reset_token = UUID.get ();
-            this.system_update_id = 0;
-        }
-
         this.action_invoked["Browse"].connect (this.browse_cb);
         this.action_invoked["Search"].connect (this.search_cb);
         this.action_invoked["CreateObject"].connect (this.create_object_cb);
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index dac9a75..82624ee 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -218,7 +218,11 @@ internal class Rygel.MediaExport.Harvester : GLib.Object {
                 parent = object.parent;
                 if (parent is TrackableContainer) {
                     var container = parent as TrackableContainer;
-                    container.remove_child_tracked.begin (object);
+                    container.remove_child_tracked.begin (object, () => {
+                        try {
+                            cache.save_container (container);
+                        } catch (Error error) { }
+                    });
                 }
                 if (parent == null) {
                     break;
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 23b5188..9f76a40 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -352,7 +352,28 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
         var db = MediaCache.get_default ();
 
         base (db, "0", _("@REALNAME@'s media"));
+    }
+
+    private bool initialized = false;
+
+    public override uint32 get_system_update_id () {
+        var id = base.get_system_update_id ();
+        Idle.add (() => {
+            try {
+                this.init ();
+            } catch (Error error) { }
+
+            return false;
+        });
+
+        return id;
+    }
 
+    private void init () throws Error {
+        if (this.initialized)
+            return;
+
+        this.initialized = true;
         this.cancellable = new Cancellable ();
 
         try {
@@ -403,6 +424,9 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
         }
 
         this.updated ();
+        try {
+            this.media_db.save_container (this);
+        } catch (Error error) { }
     }
 
     private void on_initial_harvesting_done () {
@@ -410,10 +434,16 @@ public class Rygel.MediaExport.RootContainer : TrackableDbContainer {
         this.media_db.debug_statistics ();
         this.add_default_virtual_folders ();
         this.updated ();
+        try {
+            this.media_db.save_container (this);
+        } catch (Error error) { }
 
         this.filesystem_container.container_updated.connect( () => {
             this.add_default_virtual_folders ();
             this.updated ();
+            try {
+                this.media_db.save_container (this);
+            } catch (Error error) { }
         });
     }
 



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