tracker: Complete RDF query when needed
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Wed, 11 Nov 2009 22:45:52 +0000 (00:45 +0200)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Mon, 16 Nov 2009 14:22:54 +0000 (16:22 +0200)
This is so that we can insert more conditions into the query if/when
needed.

src/plugins/tracker/rygel-tracker-metadata-values.vala
src/plugins/tracker/rygel-tracker-search-container.vala

index d492daa..a8fceb2 100644 (file)
@@ -35,12 +35,10 @@ public class Rygel.TrackerMetadataValues : Rygel.SimpleContainer {
 
     private const string SERVICE = "Files";
     private const string QUERY_CONDITION =
-        "<rdfq:Condition>\n" +
-                "<rdfq:equals>\n" +
-                    "<rdfq:Property name=\"%s\" />\n" +
-                    "<rdf:String>%s</rdf:String>\n" +
-                "</rdfq:equals>\n" +
-        "</rdfq:Condition>";
+                                        "<rdfq:equals>\n" +
+                                            "<rdfq:Property name=\"%s\" />\n" +
+                                            "<rdf:String>%s</rdf:String>\n" +
+                                        "</rdfq:equals>\n";
 
     public TrackerMetadataIface metadata;
 
index ed9ff1f..c4cf361 100644 (file)
@@ -73,13 +73,23 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
             // We are performing actual search (though an optimized one) to get
             // the hitcount rather than GetHitCount because GetHitCount only
             // allows us to get hit count for Text searches.
+            string query;
+
+            if (this.query_condition != "") {
+                query = "<rdfq:Condition>\n" +
+                            this.query_condition +
+                        "</rdfq:Condition>";
+            } else {
+                query = "";
+            }
+
             var search_result = yield this.search_proxy.query (
                                         0,
                                         this.service,
                                         new string[0],
                                         "",
                                         this.keywords,
-                                        this.query_condition,
+                                        query,
                                         false,
                                         new string[0],
                                         false,
@@ -104,13 +114,23 @@ public class Rygel.TrackerSearchContainer : Rygel.MediaContainer {
                                         throws GLib.Error {
         string[] keys = TrackerItem.get_metadata_keys ();
 
+        string query;
+
+        if (this.query_condition != "") {
+            query = "<rdfq:Condition>\n" +
+                        this.query_condition +
+                    "</rdfq:Condition>";
+        } else {
+            query = "";
+        }
+
         var search_result = yield this.search_proxy.query (
                                         0,
                                         this.service,
                                         keys,
                                         "",
                                         this.keywords,
-                                        this.query_condition,
+                                        query,
                                         false,
                                         new string[0],
                                         false,