[rygel] tracker: Use D-Bus filtering for GraphUpdated



commit 4de77be77bc96ef2305e7ed8249085292b352e2f
Author: Jens Georg <mail jensge org>
Date:   Wed May 4 19:32:23 2011 +0200

    tracker: Use D-Bus filtering for GraphUpdated
    
    Don't let tracker wake us for each and everything that happens in the
    store and use server-side filtering for the IRIs we are really
    interested in.

 .../rygel-tracker-category-all-container.vala      |   23 ++++++++++++-------
 src/plugins/tracker/rygel-tracker-interfaces.vala  |    4 ---
 .../tracker/rygel-tracker-item-factory.vala        |    3 ++
 .../tracker/rygel-tracker-music-item-factory.vala  |    3 ++
 .../rygel-tracker-picture-item-factory.vala        |    3 ++
 .../tracker/rygel-tracker-video-item-factory.vala  |    3 ++
 6 files changed, 26 insertions(+), 13 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index 952b33e..f3e64a1 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -66,7 +66,14 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
                      error.message);
         }
 
-        this.resources.graph_updated.connect (this.on_graph_updated);
+        unowned DBusConnection connection = this.resources.get_connection ();
+        connection.signal_subscribe (TRACKER_SERVICE,
+                                     TRACKER_SERVICE + ".Resources",
+                                     "GraphUpdated",
+                                     RESOURCES_PATH,
+                                     this.item_factory.category_iri,
+                                     DBusSignalFlags.NONE,
+                                     this.on_graph_updated);
     }
 
     public async void add_item (MediaItem item, Cancellable? cancellable)
@@ -99,14 +106,12 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
                                          cancellable);
     }
 
-    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;
-        }
-
+    private void on_graph_updated (DBusConnection connection,
+                                   string         sender,
+                                   string         object_path,
+                                   string         interface_name,
+                                   string         signal_path,
+                                   Variant        parameters) {
         this.get_children_count.begin ();
     }
 
diff --git a/src/plugins/tracker/rygel-tracker-interfaces.vala b/src/plugins/tracker/rygel-tracker-interfaces.vala
index 0ef9745..dee6e23 100644
--- a/src/plugins/tracker/rygel-tracker-interfaces.vala
+++ b/src/plugins/tracker/rygel-tracker-interfaces.vala
@@ -40,8 +40,4 @@ public interface Rygel.Tracker.ResourcesIface: DBusProxy {
     public abstract async void sparql_update (string query) throws IOError;
     public abstract async HashTable<string,string>[,] sparql_update_blank
                                         (string query) throws IOError;
-
-    public signal void graph_updated (string  class_name,
-                                      Event[] deletes,
-                                      Event[] inserts);
 }
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala b/src/plugins/tracker/rygel-tracker-item-factory.vala
index ef08624..e6f7283 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -44,6 +44,7 @@ public abstract class Rygel.Tracker.ItemFactory {
     }
 
     public string category;
+    public string category_iri;
     public string upnp_class;
     public string upload_dir;
 
@@ -52,9 +53,11 @@ public abstract class Rygel.Tracker.ItemFactory {
     private DLNADiscoverer discoverer;
 
     public ItemFactory (string  category,
+                        string  category_iri,
                         string  upnp_class,
                         string? upload_dir) {
         this.category = category;
+        this.category_iri = category_iri;
         this.upnp_class = upnp_class;
         this.upload_dir = upload_dir;
 
diff --git a/src/plugins/tracker/rygel-tracker-music-item-factory.vala b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
index 47a7f92..89a1e9b 100644
--- a/src/plugins/tracker/rygel-tracker-music-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
@@ -44,9 +44,12 @@ public class Rygel.Tracker.MusicItemFactory : ItemFactory {
     }
 
     private const string CATEGORY = "nmm:MusicPiece";
+    private const string CATEGORY_IRI = "http://www.tracker-project.org/"; +
+                                        "temp/nmm#MusicPiece";
 
     public MusicItemFactory () {
         base (CATEGORY,
+              CATEGORY_IRI,
               MusicItem.UPNP_CLASS,
               Environment.get_user_special_dir (UserDirectory.MUSIC));
 
diff --git a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
index 737e641..a3ba3af 100644
--- a/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-picture-item-factory.vala
@@ -37,9 +37,12 @@ public class Rygel.Tracker.PictureItemFactory : ItemFactory {
     }
 
     private const string CATEGORY = "nmm:Photo";
+    private const string CATEGORY_IRI = "http://www.tracker-project.org/"; +
+                                        "temp/nmm#Photo";
 
     public PictureItemFactory () {
         base (CATEGORY,
+              CATEGORY_IRI,
               PhotoItem.UPNP_CLASS,
               Environment.get_user_special_dir (UserDirectory.PICTURES));
 
diff --git a/src/plugins/tracker/rygel-tracker-video-item-factory.vala b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
index 05399fb..dcc2d00 100644
--- a/src/plugins/tracker/rygel-tracker-video-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
@@ -38,9 +38,12 @@ public class Rygel.Tracker.VideoItemFactory : ItemFactory {
     }
 
     private const string CATEGORY = "nmm:Video";
+    private const string CATEGORY_IRI = "http://www.tracker-project.org/"; +
+                                        "temp/nmm#Video";
 
     public VideoItemFactory () {
         base (CATEGORY,
+              CATEGORY_IRI,
               VideoItem.UPNP_CLASS,
               Environment.get_user_special_dir (UserDirectory.VIDEOS));
 



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