[rygel] tracker: Implement find_object() in 2 containers



commit 8c2e51ad20ab9dd508b00f40881988c672f423a0
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Thu Aug 12 17:36:13 2010 +0300

    tracker: Implement find_object() in 2 containers
    
    To speed-up the searches for particular objects, this patch adds
    find_object() implementation to MetadataValues and SearchContainer.

 .../tracker/rygel-tracker-metadata-values.vala     |   14 ++++++++++++++
 .../tracker/rygel-tracker-search-container.vala    |   14 ++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
---
diff --git a/src/plugins/tracker/rygel-tracker-metadata-values.vala b/src/plugins/tracker/rygel-tracker-metadata-values.vala
index fe1a5a8..5328b1a 100644
--- a/src/plugins/tracker/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker/rygel-tracker-metadata-values.vala
@@ -178,6 +178,16 @@ public class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
         this.updated ();
     }
 
+    public override async MediaObject? find_object (string       id,
+                                                    Cancellable? cancellable)
+                                                    throws GLib.Error {
+        if (this.is_our_child (id)) {
+            return yield base.find_object (id, cancellable);
+        } else {
+            return null;
+        }
+    }
+
     private string default_id_func (string value) {
         return this.id + ":" + value;
     }
@@ -190,6 +200,10 @@ public class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
         return variable + " = \"" + value + "\"";
     }
 
+    private bool is_our_child (string id) {
+        return id.has_prefix (this.id + ":");
+    }
+
     private void create_proxies () throws DBus.Error {
         DBus.Connection connection = DBus.Bus.get (DBus.BusType.SESSION);
 
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 4c462cb..15a6547 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -152,10 +152,24 @@ public class Rygel.Tracker.SearchContainer : Rygel.MediaContainer {
         return results;
     }
 
+    public override async MediaObject? find_object (string       id,
+                                                    Cancellable? cancellable)
+                                                    throws GLib.Error {
+        if (this.is_our_child (id)) {
+            return yield base.find_object (id, cancellable);
+        } else {
+            return null;
+        }
+    }
+
     public string create_child_id_for_urn (string urn) {
         return this.id + ":" + urn;
     }
 
+    private bool is_our_child (string id) {
+        return id.has_prefix (this.id + ":");
+    }
+
     private async void get_children_count () {
         try {
             var query = new SelectionQuery.clone (this.query);



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