core: ContentDirectory keeps a list of active imports
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 18 Feb 2010 14:54:58 +0000 (16:54 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Thu, 18 Feb 2010 17:49:20 +0000 (19:49 +0200)
src/rygel/rygel-content-directory.vala

index 8718c8d..902bb97 100644 (file)
@@ -57,6 +57,8 @@ public class Rygel.ContentDirectory: Service {
     public MediaContainer root_container;
     private ArrayList<MediaContainer> updated_containers;
 
+    private ArrayList<ImportResource> active_imports;
+
     private bool clear_updated_containers;
     private uint update_notify_id;
 
@@ -84,6 +86,7 @@ public class Rygel.ContentDirectory: Service {
         }
 
         this.updated_containers =  new ArrayList<MediaContainer> ();
+        this.active_imports = new ArrayList<ImportResource> ();
 
         this.root_container.container_updated += on_container_updated;
 
@@ -161,9 +164,22 @@ public class Rygel.ContentDirectory: Service {
                                              owned ServiceAction action) {
         var import = new ImportResource (this, action);
 
+        import.completed += this.on_import_completed;
+        this.active_imports.add (import);
+
         import.run.begin ();
     }
 
+    private void on_import_completed (ImportResource import) {
+        // According to CDS specs (v3 section 2.4.17), we must not immediately
+        // remove the import from out memory
+        Timeout.add_seconds (30, () => {
+                this.active_imports.remove (import);
+
+                return false;
+        });
+    }
+
     /* GetSystemUpdateID action implementation */
     private void get_system_update_id_cb (ContentDirectory    content_dir,
                                           owned ServiceAction action) {