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




commit bc950a1988a69dbb32264f284687ee939335de9d
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           | 32 ++++++++++++++++++++++++--------
 src/query.js                 |  4 ++--
 3 files changed, 35 insertions(+), 34 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..7d7493d4 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"> \
@@ -160,6 +161,11 @@ var Application = new Lang.Class({
         }
     },
 
+    _isSandboxed: function() {
+       file = Gio.File.new_for_path("/.flatpak-info");
+       return file.query_exists(null);
+    },
+
     vfunc_startup: function() {
         this.parent();
         String.prototype.format = Format.format;
@@ -185,6 +191,24 @@ var Application = new Lang.Class({
             return;
         }
 
+       if (this._isSandboxed()) {
+           // if the daemon is not available, run our own copy (for the sandboxed case)
+           trackerMinerService = this.get_application_id() + '.Tracker3.Miner.Files';
+       } else {
+           // use global tracker daemon
+           let busConn = Tracker.SparqlConnection.bus_new('org.freedesktop.Tracker3.Miner.Files',
+                                                          null, Gio.DBus.session);
+           trackerMinerService = 'org.freedesktop.Tracker3.Miner.Files';
+
+           try {
+               this._minerControl = TrackerMinerFilesControl();
+               
this._minerControl.IndexLocationRemote(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS),
+                                                      ['tracker:Documents'], []);
+           } catch (e) {
+               logError(e, 'Unable to connect to the tracker extractor');
+           }
+       }
+
         connectionQueue = new TrackerController.TrackerConnectionQueue();
         changeMonitor = new ChangeMonitor.TrackerChangeMonitor();
 
@@ -222,14 +246,6 @@ var Application = new Lang.Class({
         notificationManager = new Notifications.NotificationManager();
         this._mainWindow = new MainWindow.MainWindow(this);
         this._mainWindow.connect('destroy', Lang.bind(this, this._onWindowDestroy));
-
-        try {
-            this._minerControl = TrackerMinerFilesControl();
-            
this._minerControl.IndexLocationRemote(GLib.get_user_special_dir(GLib.UserDirectory.DIRECTORY_DOCUMENTS),
-                                                   ['tracker:Documents'], []);
-        } catch (e) {
-            logError(e, 'Unable to connect to the tracker extractor');
-        }
     },
 
     vfunc_handle_local_options: function(options) {
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]