tracker: Handle updates in CategoryAllContainer
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 12 Nov 2010 15:51:53 +0000 (17:51 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 12 Nov 2010 15:55:50 +0000 (17:55 +0200)
Handle graph updates in CategoryAllContainer instead of MetadataValues. In
CategoryAllContainer we can easily know if the update affect the container or
not, which is not true for MetadataValues and we end-up launching a lot of
redundant Tracker queries and network traffic.

src/plugins/tracker/rygel-tracker-category-all-container.vala
src/plugins/tracker/rygel-tracker-metadata-values.vala

index 63db5db..6950f5c 100644 (file)
@@ -62,6 +62,8 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
                      item_factory.upload_dir,
                      error.message);
         }
+
+        this.resources.graph_updated.connect (this.on_graph_updated);
     }
 
     public async void add_item (MediaItem item, Cancellable? cancellable)
@@ -70,9 +72,6 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
 
         item.id = this.create_child_id_for_urn (urn);
         item.parent = this;
-
-        this.child_count++;
-        this.updated ();
     }
 
     public async void remove_item (string id, Cancellable? cancellable)
@@ -82,9 +81,17 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
         var urn = this.get_item_info (id, out parent_id);
 
         yield this.remove_entry_from_store (urn);
+    }
+
+    private void on_graph_updated (string  class_name,
+                                   Event[] deletes,
+                                   Event[] inserts) {
+        var our_suffix = this.item_factory.category.replace (":", "#");
+        if (!class_name.has_suffix (our_suffix)) {
+            return;
+        }
 
-        this.child_count--;
-        this.updated ();
+        this.get_children_count.begin ();
     }
 
     private async string create_entry_in_store (MediaItem item) throws Error {
index 52d8a23..bf8733f 100644 (file)
@@ -64,8 +64,6 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
         }
 
         this.fetch_metadata_values.begin ();
-
-        this.resources.graph_updated.connect (this.on_graph_updated);
     }
 
     private async void fetch_metadata_values () {
@@ -189,17 +187,6 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
                                              RESOURCES_PATH);
     }
 
-    private void on_graph_updated (string  class_name,
-                                   Event[] deletes,
-                                   Event[] inserts) {
-        var our_suffix = this.item_factory.category.replace (":", "#");
-        if (!class_name.has_suffix (our_suffix)) {
-            return;
-        }
-
-        this.fetch_metadata_values.begin ();
-    }
-
     private bool is_child_id_unique (string child_id) {
         var unique = true;