[gnome-boxes/3.38.1-backports: 1/3] media-manager: Port to Tracker 3




commit 960ded9e0ee9fce9684d9348b7dbecbc11b0ac50
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sun Jun 14 22:54:19 2020 +0200

    media-manager: Port to Tracker 3
    
    The SparqlConnection constructor API changed, since Boxes does
    purely readonly use of Tracker, it's most convenient to use the bus
    connection here.
    
    Also specify the tracker:Software graph for queries, as ISO image data
    will be written to it.
    
    As all versions of tracker 3.x are guaranteed to have the osinfo:language,
    we don't need the fallback queries either.

 src/media-manager.vala     |  3 ++-
 src/meson.build            |  2 +-
 src/tracker-iso-query.vala | 18 +++++-------------
 3 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 79b198c3..c5648240 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -226,7 +226,8 @@ private MediaManager () {
         os_db = new OSDatabase ();
         os_db.load.begin ();
         try {
-            connection = Sparql.Connection.get ();
+            connection = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files",
+                                                    null, null);
         } catch (GLib.Error error) {
             critical ("Error connecting to Tracker: %s", error.message);
         }
diff --git a/src/meson.build b/src/meson.build
index 028750c5..f38d7d80 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -144,7 +144,7 @@ dependencies = [
   dependency ('libvirt-gobject-1.0', version: '>= 3.0.0'),
   dependency ('libxml-2.0', version: '>= 2.7.8'),
   dependency ('spice-client-gtk-3.0', version: '>= 0.32'),
-  dependency ('tracker-sparql-2.0'),
+  dependency ('tracker-sparql-3.0'),
   dependency ('vte-2.91', version: '>= 0.40.2'),
   dependency ('webkit2gtk-4.0', version: '>= 2.26.0'),
   dependency ('libhandy-0.0', version: '>= 0.0.11'),
diff --git a/src/tracker-iso-query.vala b/src/tracker-iso-query.vala
index ba920644..276e880e 100644
--- a/src/tracker-iso-query.vala
+++ b/src/tracker-iso-query.vala
@@ -3,21 +3,15 @@
 using Tracker;
 
 private class Boxes.TrackerISOQuery {
-    private const string LANG_QUERY = "ASK { osinfo:language a 
<http://www.w3.org/1999/02/22-rdf-syntax-ns#Property> }";
-    private const string ISO_QUERY = "SELECT nie:url(?iso)   nie:title(?iso)\n" +
-                                     "       osinfo:id(?iso) osinfo:mediaId(?iso)\n" +
+    private const string ISO_QUERY = "SELECT nie:isStoredAs(?iso)   nie:title(?iso)\n" +
+                                     "       osinfo:id(?iso) osinfo:mediaId(?iso) osinfo:language(?iso)\n" +
+                                     "FROM tracker:Software " +
                                      "{ ?iso nfo:isBootable true }";
-    private const string ISO_QUERY_LANG = "SELECT nie:url(?iso)   nie:title(?iso)\n" +
-                                          "       osinfo:id(?iso) osinfo:mediaId(?iso) 
osinfo:language(?iso)\n" +
-                                          "{ ?iso nfo:isBootable true }";
 
     private Sparql.Cursor cursor;
 
     public async TrackerISOQuery (Sparql.Connection connection) throws GLib.Error {
         var iso_query = ISO_QUERY;
-        var cursor = yield connection.query_async (LANG_QUERY);
-        if ((yield cursor.next_async ()) && cursor.get_boolean (0))
-            iso_query = ISO_QUERY_LANG;
         debug ("Tracker SPARQL query: %s", iso_query);
 
         this.cursor = yield connection.query_async (iso_query);
@@ -48,11 +42,9 @@ public async bool fetch_next_iso_data (out string   path,
         title = cursor.get_string (1);
         os_id = cursor.get_string (2);
         media_id = cursor.get_string (3);
-        if (cursor.n_columns > 4) {
-            var languages = cursor.get_string (4);
+        var languages = cursor.get_string (4);
 
-            lang_list = (languages != null)? languages.split (",") : new string[]{};
-        }
+        lang_list = (languages != null)? languages.split (",") : new string[]{};
 
         return true;
     }


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