[gnome-books/wip/carlosg/tracker3] flatpak: Update reference to use Tracker3




commit b79968daf192c7461cefb597eb2cea664c85070d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Jan 26 14:18:53 2021 +0100

    flatpak: Update reference to use Tracker3
    
    Use the Tracker3 policy to specify the accessed graph, drop
    the builtin tracker copy, and change tracker-miners build parameters
    so we can run our own internal copy.
    
    In code, first check whether there is access to the stock miner,
    then attempt this internal miner. This is a fallback for systems that
    do not have tracker3 installed.

 flatpak/org.gnome.Books.json | 33 +++++++++------------------------
 src/application.js           | 11 +++++++++++
 src/query.js                 |  4 ++--
 3 files changed, 22 insertions(+), 26 deletions(-)
---
diff --git a/flatpak/org.gnome.Books.json b/flatpak/org.gnome.Books.json
index 46ec24db..73ab1a1e 100644
--- a/flatpak/org.gnome.Books.json
+++ b/flatpak/org.gnome.Books.json
@@ -17,10 +17,8 @@
         "--filesystem=xdg-documents:ro", "--filesystem=xdg-download:ro",
         /* Needs to talk to the network: */
         "--share=network",
-        /* Tracker D-Bus access */
-        "--talk-name=org.freedesktop.Tracker1",
-        "--talk-name=org.freedesktop.Tracker1.Miner.Extract",
-        "--env=TRACKER_SPARQL_BACKEND=bus",
+        /* Tracker3 graph access */
+        "--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:Documents",
         /* For the WebP loader */
         "--env=GDK_PIXBUF_MODULE_FILE=/app/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache",
         /* Needed for dconf to work */
@@ -106,18 +104,6 @@
                 }
             ]
         },
-        {
-            "name": "tracker",
-            "buildsystem": "meson",
-            "cleanup": [ "/bin", "/etc", "/lib/systemd", "/libexec", "/share/dbus-1/services" ],
-            "config-opts": [ "--default-library=shared", "-Dbash-completion=no", "-Ddocs=false", 
"-Dsystemd_user_services=no" ],
-            "sources": [
-                {
-                    "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/tracker.git";
-                }
-            ]
-        },
         {
             "name": "intltool",
             "cleanup": [ "*" ],
@@ -132,15 +118,14 @@
         {
             "name": "tracker-miners",
             "buildsystem": "meson",
-            "cleanup": [ "/bin", "/etc", "/lib/systemd", "/libexec" ],
-            "config-opts": [ "--default-library=shared",
-                             "-Dminer_apps=false",
-                             "-Dminer_rss=false",
-                             "-Dextract=false",
-                             "-Dgeneric_media_extractor=none",
-                             "-Dwriteback=false",
+            "config-opts": [ "-Ddefault_index_single_directories=&DOWNLOADS",
+                             "-Ddefault_index_recursive_directories=&DOCUMENTS",
+                             "-Ddomain_prefix=org.gnome.Books",
+                             "-Dman=false",
                              "-Dminer_fs=true",
-                             "-Ddbus_services=/app/share/dbus-1/services/" ],
+                             "-Dminer_fs_cache_location=$XDG_CACHE_HOME/org.gnome.Books/miner/files",
+                             "-Dminer_rss=false",
+                             "-Dsystemd_user_services=false" ],
             "sources": [
                 {
                     "type": "git",
diff --git a/src/application.js b/src/application.js
index c3ebf933..39a52584 100644
--- a/src/application.js
+++ b/src/application.js
@@ -68,6 +68,7 @@ var sourceManager = null;
 var trackerCollectionsController = null;
 var trackerDocumentsController = null;
 var trackerSearchController = null;
+var trackerMinerService = null;
 
 const TrackerMinerFilesIndexIface = '<node> \
 <interface name="org.freedesktop.Tracker3.Miner.Files.Index"> \
@@ -185,6 +186,16 @@ var Application = new Lang.Class({
             return;
         }
 
+       // test access to global tracker daemon
+       try {
+           let busConn = Tracker.SparqlConnection.bus_new('org.freedesktop.Tracker3.Miner.Files',
+                                                          null, Gio.DBus.session);
+           trackerMinerService = 'org.freedesktop.Tracker3.Miner.Files';
+       } catch (e) {
+           // if the daemon is not available, run our own copy (for the sandboxed case)
+           trackerMinerService = this.get_application_id() + '.Tracker3.Miner.Files';
+       }
+
         connectionQueue = new TrackerController.TrackerConnectionQueue();
         changeMonitor = new ChangeMonitor.TrackerChangeMonitor();
 
diff --git a/src/query.js b/src/query.js
index fa7c5ca1..4fc94b6b 100644
--- a/src/query.js
+++ b/src/query.js
@@ -212,7 +212,7 @@ var QueryBuilder = new Lang.Class({
                 tailSparql;
         } else {
             sparql +=
-                'SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> {' +
+                'SERVICE <dbus:' + this._context.trackerMinerService + '> {' +
                 '  GRAPH tracker:Documents { ' +
                 '    SELECT DISTINCT ?urn ' +
                 selectClauses +
@@ -249,7 +249,7 @@ var QueryBuilder = new Lang.Class({
                this._buildWhere(true, flags);
        } else {
            sparql = 'SELECT ?c {' +
-               '  SERVICE <dbus:org.freedesktop.Tracker3.Miner.Files> { ' +
+               '  SERVICE <dbus:' + this._context.trackerMinerService + '> { ' +
                '    SELECT DISTINCT COUNT(?urn) AS ?c ' +
                this._buildWhere(true, flags) +
                '  }' +


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