[rygel] tracker: Switch Tracker queries from Dbus to Sparql.



commit a7469d83782818c369167c971bbbe764a384de8b
Author: Luis de Bethencourt <luis debethencourt com>
Date:   Tue Mar 27 12:24:50 2012 +0100

    tracker: Switch Tracker queries from Dbus to Sparql.

 src/plugins/tracker/Makefile.am                    |    1 +
 .../rygel-tracker-category-all-container.vala      |   37 ++++----
 .../tracker/rygel-tracker-cleanup-query.vala       |   11 ++-
 .../tracker/rygel-tracker-deletion-query.vala      |   10 ++-
 .../tracker/rygel-tracker-insertion-query.vala     |   36 ++++++--
 .../tracker/rygel-tracker-item-factory.vala        |    3 +-
 .../tracker/rygel-tracker-metadata-values.vala     |   96 ++++++++++----------
 .../tracker/rygel-tracker-music-item-factory.vala  |    3 +-
 .../tracker/rygel-tracker-plugin-factory.vala      |   11 ++-
 src/plugins/tracker/rygel-tracker-query.vala       |   11 ++-
 .../tracker/rygel-tracker-search-container.vala    |   60 +++++--------
 .../tracker/rygel-tracker-selection-query.vala     |   14 ++-
 .../tracker/rygel-tracker-sparql-connection.vala   |   38 ++++++++
 .../tracker/rygel-tracker-video-item-factory.vala  |    3 +-
 14 files changed, 198 insertions(+), 136 deletions(-)
---
diff --git a/src/plugins/tracker/Makefile.am b/src/plugins/tracker/Makefile.am
index 68029dd..4d7537e 100644
--- a/src/plugins/tracker/Makefile.am
+++ b/src/plugins/tracker/Makefile.am
@@ -40,6 +40,7 @@ librygel_tracker_la_SOURCES = \
 	rygel-tracker-music-item-factory.vala \
 	rygel-tracker-picture-item-factory.vala \
 	rygel-tracker-plugin.vala \
+	rygel-tracker-sparql-connection.vala \
 	rygel-tracker-interfaces.vala
 
 librygel_tracker_la_VALAFLAGS = --pkg posix \
diff --git a/src/plugins/tracker/rygel-tracker-category-all-container.vala b/src/plugins/tracker/rygel-tracker-category-all-container.vala
index 55b1156..defee80 100644
--- a/src/plugins/tracker/rygel-tracker-category-all-container.vala
+++ b/src/plugins/tracker/rygel-tracker-category-all-container.vala
@@ -1,9 +1,10 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008-2010 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -23,6 +24,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * A search container that contains all the items in a category.
@@ -37,7 +39,7 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
     public ArrayList<string> create_classes { get; set; }
     public ArrayList<string> search_classes { get; set; }
 
-    private ResourcesIface resources;
+    private Sparql.Connection resources;
 
     public CategoryAllContainer (CategoryContainer parent) {
         base ("All" + parent.id, parent, "All", parent.item_factory);
@@ -47,13 +49,9 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
         this.search_classes = new ArrayList<string> ();
 
         try {
-            this.resources = Bus.get_proxy_sync
-                                        (BusType.SESSION,
-                                         TRACKER_SERVICE,
-                                         RESOURCES_PATH,
-                                         DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
-        } catch (IOError io_error) {
-            critical (_("Failed to create D-Bus proxies: %s"),
+            this.resources = Connection.get ();
+        } catch (Error io_error) {
+            critical (_("Failed to create a Tracker connection:: %s"),
                       io_error.message);
         }
 
@@ -66,14 +64,19 @@ public class Rygel.Tracker.CategoryAllContainer : SearchContainer,
                      error.message);
         }
 
-        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);
+        try {
+            var connection = Bus.get_sync (BusType.SESSION);
+            connection.signal_subscribe (TRACKER_SERVICE,
+                                         TRACKER_SERVICE + ".Resources",
+                                         "GraphUpdated",
+                                         RESOURCES_PATH,
+                                         this.item_factory.category_iri,
+                                         DBusSignalFlags.NONE,
+                                         this.on_graph_updated);
+        } catch (Error error) {
+            critical (_("Could not subscribe to tracker signals: %s"),
+                      error.message);
+        }
 
         var cleanup_query = new CleanupQuery (this.item_factory.category);
         cleanup_query.execute (this.resources);
diff --git a/src/plugins/tracker/rygel-tracker-cleanup-query.vala b/src/plugins/tracker/rygel-tracker-cleanup-query.vala
index 460876e..6fd2190 100644
--- a/src/plugins/tracker/rygel-tracker-cleanup-query.vala
+++ b/src/plugins/tracker/rygel-tracker-cleanup-query.vala
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 Nokia Corporation.
+ * Copyright (C) 2011-2012 Nokia Corporation.
  *
  * Author: Jens Georg <jensg openismus com>
  *
@@ -21,6 +21,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * Represents Tracker SPARQL Deletion query
@@ -37,13 +38,15 @@ public class Rygel.Tracker.CleanupQuery : Query {
         this.category = category;
     }
 
-    public override async void execute (ResourcesIface resources)
-                                        throws IOError, DBusError {
+    public override async void execute (Sparql.Connection resources)
+                                        throws IOError,
+                                               Sparql.Error,
+                                               DBusError {
         var str = this.to_string ();
 
         debug ("Executing SPARQL query: %s", str);
 
-        yield resources.sparql_update (str);
+        yield resources.update_async (str);
     }
 
     public override string to_string () {
diff --git a/src/plugins/tracker/rygel-tracker-deletion-query.vala b/src/plugins/tracker/rygel-tracker-deletion-query.vala
index b3c2165..97256a0 100644
--- a/src/plugins/tracker/rygel-tracker-deletion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-deletion-query.vala
@@ -1,7 +1,8 @@
 /*
- * Copyright (C) 2010 Nokia Corporation.
+ * Copyright (C) 2010-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali <zeenix gmail com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -21,6 +22,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * Represents Tracker SPARQL Deletion query
@@ -37,13 +39,13 @@ public class Rygel.Tracker.DeletionQuery : Query {
         this.id = id;
     }
 
-    public override async void execute (ResourcesIface resources)
-                                        throws IOError, DBusError {
+    public override async void execute (Sparql.Connection resources)
+                                        throws IOError, Sparql.Error, DBusError {
         var str = this.to_string ();
 
         debug ("Executing SPARQL query: %s", str);
 
-        yield resources.sparql_update (str);
+        yield resources.update_async (str);
 
         debug ("Deleted item '%s' from Tracker store", this.id);
     }
diff --git a/src/plugins/tracker/rygel-tracker-insertion-query.vala b/src/plugins/tracker/rygel-tracker-insertion-query.vala
index 61f95ff..71d35e4 100644
--- a/src/plugins/tracker/rygel-tracker-insertion-query.vala
+++ b/src/plugins/tracker/rygel-tracker-insertion-query.vala
@@ -1,7 +1,8 @@
 /*
- * Copyright (C) 2010 Nokia Corporation.
+ * Copyright (C) 2010-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali <zeenix gmail com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -21,6 +22,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * Represents Tracker SPARQL Insertion query
@@ -116,22 +118,40 @@ public class Rygel.Tracker.InsertionQuery : Query {
         this.uri = item.uris[0];
     }
 
-    public override async void execute (ResourcesIface resources)
-                                        throws IOError, DBusError {
+    public override async void execute (Sparql.Connection resources)
+                                        throws IOError,
+                                        Sparql.Error,
+                                        DBusError {
         var str = this.to_string ();
 
         debug ("Executing SPARQL query: %s", str);
 
-        var result = yield resources.sparql_update_blank (str);
+        Variant v = yield resources.update_blank_async (str);
+        VariantIter iter1, iter2, iter3;
+        string key = null;
+
+        iter1 = v.iterator ();
+        while (iter1.next ("aa{ss}", out iter2)) {
+            while (iter2.next ("a{ss}", out iter3)) {
+                while (iter3.next ("{ss}", out key, out this.id)) {
+                    break;
+                }
+            }
+        }
 
         // Item already existed
-        if (result[0,0] == null || result[0,0].lookup (TEMP_ID) == null)  {
-            var ids = yield resources.sparql_query
+        if (this.id == null)  {
+            var cursor = yield resources.query_async
                                         (this.get_resource_id_query ());
 
-            this.id = ids[0,0];
+            try {
+                while (cursor.next ()) {
+                    this.id = cursor.get_string (0);
+                    break;
+                }
+            } catch (Error error) {
+            }
         } else {
-            this.id = result[0,0].lookup (TEMP_ID);
             var file = File.new_for_uri (this.uri);
             if (file.is_native () &&
                 file.query_exists ()) {
diff --git a/src/plugins/tracker/rygel-tracker-item-factory.vala b/src/plugins/tracker/rygel-tracker-item-factory.vala
index fd00cfe..97a2f61 100644
--- a/src/plugins/tracker/rygel-tracker-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-item-factory.vala
@@ -1,10 +1,11 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  * Copyright (C) 2010 MediaNet Inh.
  *
  * Authors: Zeeshan Ali <zeenix gmail com>
  *          Sunil Mohan Adapa <sunil medhas org>
+ *          Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
diff --git a/src/plugins/tracker/rygel-tracker-metadata-values.vala b/src/plugins/tracker/rygel-tracker-metadata-values.vala
index 6b80bf6..7bcabc8 100644
--- a/src/plugins/tracker/rygel-tracker-metadata-values.vala
+++ b/src/plugins/tracker/rygel-tracker-metadata-values.vala
@@ -1,8 +1,9 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali <zeenix gmail com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -23,6 +24,7 @@
 
 using GUPnP;
 using Gee;
+using Tracker;
 
 /**
  * Container listing possible values of a particuler Tracker metadata key.
@@ -42,7 +44,7 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
 
     private string child_class;
 
-    private ResourcesIface resources;
+    private Sparql.Connection resources;
 
     public MetadataValues (string         id,
                            MediaContainer parent,
@@ -58,8 +60,8 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
 
         try {
             this.create_proxies ();
-        } catch (IOError error) {
-            critical (_("Failed to connect to session bus: %s"), error.message);
+        } catch (Error error) {
+            critical (_("Failed to create Tracker connection: %s"), error.message);
 
             return;
         }
@@ -114,6 +116,45 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
 
         try {
             yield query.execute (this.resources);
+
+            while (query.result.next ()) {
+                string value = query.result.get_string (0);
+
+                if (value == "") {
+                    continue;
+                }
+
+                var title = this.create_title_for_value (value);
+                if (title == null) {
+                    continue;
+                }
+
+                var id = this.create_id_for_title (title);
+                if (id == null || !this.is_child_id_unique (id)) {
+                    continue;
+                }
+
+                // The child container can use the same triplets we used in our
+                // query.
+                var child_triplets = new QueryTriplets.clone (triplets);
+
+                // However we constrain the object of our last triplet.
+                var filters = new ArrayList<string> ();
+                var filter = this.create_filter (child_triplets.last ().obj, value);
+                filters.add (filter);
+
+                var container = new SearchContainer (id,
+                                                     this,
+                                                     title,
+                                                     this.item_factory,
+                                                     child_triplets,
+                                                     filters);
+                if (this.child_class != null) {
+                    container.upnp_class = child_class;
+                }
+
+                this.add_child_container (container);
+            }
         } catch (Error error) {
             critical (_("Error getting all values for '%s': %s"),
                       string.joinv (" -> ", this.key_chain),
@@ -123,45 +164,6 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
             return;
         }
 
-        /* Iterate through all the values */
-        for (i = 0; i < query.result.length[0]; i++) {
-            string value = query.result[i, 0];
-
-            if (value == "") {
-                continue;
-            }
-
-            var title = this.create_title_for_value (value);
-            if (title == null) {
-                continue;
-            }
-
-            var id = this.create_id_for_title (title);
-            if (id == null || !this.is_child_id_unique (id)) {
-                continue;
-            }
-
-            // The child container can use the same triplets we used in our
-            // query.
-            var child_triplets = new QueryTriplets.clone (triplets);
-
-            // However we constrain the object of our last triplet.
-            var filters = new ArrayList<string> ();
-            var filter = this.create_filter (child_triplets.last ().obj, value);
-            filters.add (filter);
-
-            var container = new SearchContainer (id,
-                                                 this,
-                                                 title,
-                                                 this.item_factory,
-                                                 child_triplets,
-                                                 filters);
-            if (this.child_class != null) {
-                container.upnp_class = child_class;
-            }
-
-            this.add_child_container (container);
-        }
 
         this.updated ();
         this.update_in_progress = false;
@@ -193,12 +195,8 @@ public abstract class Rygel.Tracker.MetadataValues : Rygel.SimpleContainer {
         return id.has_prefix (this.id + ":");
     }
 
-    private void create_proxies () throws IOError {
-        this.resources = Bus.get_proxy_sync
-                                        (BusType.SESSION,
-                                         TRACKER_SERVICE,
-                                         RESOURCES_PATH,
-                                         DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
+    private void create_proxies () throws Error {
+        this.resources = Connection.get ();
     }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-music-item-factory.vala b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
index c78f6c0..e2e1fc5 100644
--- a/src/plugins/tracker/rygel-tracker-music-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-music-item-factory.vala
@@ -1,10 +1,11 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  * Copyright (C) 2010 MediaNet Inh.
  *
  * Authors: Zeeshan Ali <zeenix gmail com>
  *          Sunil Mohan Adapa <sunil medhas org>
+ *          Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
diff --git a/src/plugins/tracker/rygel-tracker-plugin-factory.vala b/src/plugins/tracker/rygel-tracker-plugin-factory.vala
index 86206cf..1c17779 100644
--- a/src/plugins/tracker/rygel-tracker-plugin-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-plugin-factory.vala
@@ -1,9 +1,10 @@
 /*
  * Copyright (C) 2009 Zeeshan Ali (Khattak) <zeeshanak gnome org>.
- * Copyright (C) 2009 Nokia Corporation.
+ * Copyright (C) 2009-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
  *                               <zeeshan ali nokia com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -25,18 +26,18 @@
 using Rygel;
 using Gee;
 
-private Tracker.PluginFactory plugin_factory;
+private Rygel.Tracker.PluginFactory plugin_factory;
 
 public void module_init (PluginLoader loader) {
-    if (loader.plugin_disabled (Tracker.Plugin.NAME)) {
+    if (loader.plugin_disabled (Rygel.Tracker.Plugin.NAME)) {
         message ("Plugin '%s' disabled by user, ignoring..",
-                 Tracker.Plugin.NAME);
+                 Rygel.Tracker.Plugin.NAME);
 
         return;
     }
 
     try {
-        plugin_factory = new Tracker.PluginFactory (loader);
+        plugin_factory = new Rygel.Tracker.PluginFactory (loader);
     } catch (Error err) {
         warning (_("Failed to start Tracker service: %s. Plugin disabled."),
                  err.message);
diff --git a/src/plugins/tracker/rygel-tracker-query.vala b/src/plugins/tracker/rygel-tracker-query.vala
index 5499963..06fc678 100644
--- a/src/plugins/tracker/rygel-tracker-query.vala
+++ b/src/plugins/tracker/rygel-tracker-query.vala
@@ -1,8 +1,10 @@
 /*
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  *
  * Authors: Zeeshan Ali <zeenix gmail com>
  *          Ivan Frade <ivan frade nokia com>
+ *          Jens Georg <jensg openismus com>
+ *          Luis de Bethencourt <luisbg collabora com>
  *
  * This file is part of Rygel.
  *
@@ -22,6 +24,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * Represents Tracker SPARQL query
@@ -33,8 +36,10 @@ public abstract class Rygel.Tracker.Query {
         this.triplets = triplets;
     }
 
-    public abstract async void execute (ResourcesIface resources)
-                                        throws IOError, DBusError;
+    public abstract async void execute (Sparql.Connection resources)
+                                        throws IOError,
+                                               Sparql.Error,
+                                               DBusError;
 
     // Deriving classes should override this method and complete it by
     // adding the first part of the query
diff --git a/src/plugins/tracker/rygel-tracker-search-container.vala b/src/plugins/tracker/rygel-tracker-search-container.vala
index 0213cc9..c3eaf02 100644
--- a/src/plugins/tracker/rygel-tracker-search-container.vala
+++ b/src/plugins/tracker/rygel-tracker-search-container.vala
@@ -1,10 +1,11 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  * Copyright (C) 2010 MediaNet Inh.
  *
  * Authors: Zeeshan Ali <zeenix gmail com>
  *          Sunil Mohan Adapa <sunil medhas org>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -25,21 +26,19 @@
 
 using GUPnP;
 using Gee;
+using Tracker;
 
 /**
  * A container listing a Tracker search result.
  */
 public class Rygel.Tracker.SearchContainer : SimpleContainer {
     /* class-wide constants */
-    private const string TRACKER_SERVICE = "org.freedesktop.Tracker1";
-    private const string RESOURCES_PATH = "/org/freedesktop/Tracker1/Resources";
-
     private const string MODIFIED_PROPERTY = "nfo:fileLastModified";
 
     public SelectionQuery query;
     public ItemFactory item_factory;
 
-    private ResourcesIface resources;
+    private Sparql.Connection resources;
 
     private static HashMap<string, uint> update_id_hash;
 
@@ -98,15 +97,11 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
                                          order_by);
 
         try {
-            this.resources = Bus.get_proxy_sync
-                                        (BusType.SESSION,
-                                         TRACKER_SERVICE,
-                                         RESOURCES_PATH,
-                                         DBusProxyFlags.DO_NOT_LOAD_PROPERTIES);
+            this.resources = Connection.get ();
 
             this.get_children_count.begin ();
-        } catch (IOError error) {
-            critical (_("Failed to connect to session bus: %s"), error.message);
+        } catch (Error error) {
+            critical (_("Failed to get Tracker connection: %s"), error.message);
         }
     }
 
@@ -139,14 +134,20 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
         var query = this.create_query (expression as RelationalExpression,
                                        (int) offset,
                                        (int) max_count);
+
         if (query != null) {
             yield query.execute (this.resources);
 
             /* Iterate through all items */
-            for (uint i = 0; i < query.result.length[0]; i++) {
-                var id = this.create_child_id_for_urn (query.result[i, 0]);
-                var uri = query.result[i, 1];
-                string[] metadata = this.slice_strvv_tail (query.result, i, 1);
+            while (yield query.result.next_async ()) {
+                var id = this.create_child_id_for_urn
+                                        (query.result.get_string (0));
+                var uri = query.result.get_string (1);
+
+                string[] metadata = new string[0];
+                for (int i = 1; i < query.result.n_columns; ++i) {
+                    metadata += query.result.get_string (i);
+                }
 
                 var item = this.item_factory.create (id, uri, this, metadata);
                 results.add (item);
@@ -215,8 +216,11 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
 
             yield query.execute (this.resources);
 
-            this.child_count = int.parse (query.result[0,0]);
-            this.updated ();
+            if (query.result.next ()) {
+                this.child_count = int.parse (query.result.get_string (0));
+                this.updated ();
+            }
+
         } catch (GLib.Error error) {
             critical (_("Error getting item count under category '%s': %s"),
                       this.item_factory.category,
@@ -323,25 +327,5 @@ public class Rygel.Tracker.SearchContainer : SimpleContainer {
 
         return filter;
     }
-
-    /**
-     * Chops the tail of a particular row in a 2-dimensional string array.
-     *
-     * param strvv the 2-dimenstional string array to chop the tail of.
-     * param row the row whose tail needs to be chopped off.
-     * param index index of the first element in the tail.
-     *
-     * FIXME: Stop using it once vala supports array slicing syntax for
-     *        multi-dimentional arrays.
-     */
-    private string[] slice_strvv_tail (string[,] strvv, uint row, uint index) {
-        var slice = new string[strvv.length[1] - index];
-
-        for (var i = 0; i < slice.length; i++) {
-            slice[i] = strvv[row, i + index];
-        }
-
-        return slice;
-    }
 }
 
diff --git a/src/plugins/tracker/rygel-tracker-selection-query.vala b/src/plugins/tracker/rygel-tracker-selection-query.vala
index 5598ac1..9c7fb96 100644
--- a/src/plugins/tracker/rygel-tracker-selection-query.vala
+++ b/src/plugins/tracker/rygel-tracker-selection-query.vala
@@ -1,7 +1,8 @@
 /*
- * Copyright (C) 2010 Nokia Corporation.
+ * Copyright (C) 2010-2012 Nokia Corporation.
  *
  * Author: Zeeshan Ali <zeenix gmail com>
+ *         Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *
@@ -21,6 +22,7 @@
  */
 
 using Gee;
+using Tracker;
 
 /**
  * Represents Tracker SPARQL Selection query
@@ -46,7 +48,7 @@ public class Rygel.Tracker.SelectionQuery : Query {
     public int offset;
     public int max_count;
 
-    public string[,] result;
+    public Sparql.Cursor result;
 
     public SelectionQuery (ArrayList<string>  variables,
                            QueryTriplets      triplets,
@@ -77,13 +79,15 @@ public class Rygel.Tracker.SelectionQuery : Query {
               query.max_count);
     }
 
-    public override async void execute (ResourcesIface resources)
-                                        throws IOError, DBusError {
+    public override async void execute (Sparql.Connection resources)
+                                        throws IOError,
+                                               Sparql.Error,
+                                               DBusError {
         var str = this.to_string ();
 
         debug ("Executing SPARQL query: %s", str);
 
-        result = yield resources.sparql_query (str);
+        result = yield resources.query_async (str);
     }
 
     public override string to_string () {
diff --git a/src/plugins/tracker/rygel-tracker-sparql-connection.vala b/src/plugins/tracker/rygel-tracker-sparql-connection.vala
new file mode 100644
index 0000000..cb7d972
--- /dev/null
+++ b/src/plugins/tracker/rygel-tracker-sparql-connection.vala
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2008-2011 Nokia Corporation.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *         Jens Georg <jensg openismus com>
+ *         Luis de Bethencourt <luisbg collabora com>
+ *
+ * This file is part of Rygel.
+ *
+ * Rygel is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * Rygel is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+using Tracker;
+
+namespace Rygel.Tracker.Connection {
+    private static Sparql.Connection connection;
+
+    public static Sparql.Connection get () throws Error {
+        stdout.printf ("Sparql connection\n");
+        if (unlikely (connection == null)) {
+            connection = Sparql.Connection.get ();
+        }
+
+        return connection;
+    }
+}
diff --git a/src/plugins/tracker/rygel-tracker-video-item-factory.vala b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
index f4f2555..6ef06b0 100644
--- a/src/plugins/tracker/rygel-tracker-video-item-factory.vala
+++ b/src/plugins/tracker/rygel-tracker-video-item-factory.vala
@@ -1,10 +1,11 @@
 /*
  * Copyright (C) 2008 Zeeshan Ali <zeenix gmail com>.
- * Copyright (C) 2008 Nokia Corporation.
+ * Copyright (C) 2008-2012 Nokia Corporation.
  * Copyright (C) 2010 MediaNet Inh.
  *
  * Authors: Zeeshan Ali <zeenix gmail com>
  *          Sunil Mohan Adapa <sunil medhas org>
+ *          Jens Georg <jensg openismus com>
  *
  * This file is part of Rygel.
  *



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