[gnome-documents/wip/carlosg/tracker3: 21/22] flatpak: Update reference to use Tracker3




commit f2721143344fbb0f1836a70a0efbaa7c246ae8dc
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jan 22 18:00:55 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.Documents.json | 35 ++++++++++-------------------------
 src/application.js               | 11 +++++++++++
 src/query.js                     |  4 ++--
 3 files changed, 23 insertions(+), 27 deletions(-)
---
diff --git a/flatpak/org.gnome.Documents.json b/flatpak/org.gnome.Documents.json
index 5c2e3116..325d1e73 100644
--- a/flatpak/org.gnome.Documents.json
+++ b/flatpak/org.gnome.Documents.json
@@ -17,9 +17,8 @@
         /* Needs to talk to the network: */
         "--share=network",
         "--talk-name=org.gnome.Mutter.DisplayConfig",
-        /* Tracker access */
-        "--talk-name=org.freedesktop.Tracker1",
-        "--talk-name=org.freedesktop.Tracker1.Miner.Extract",
+        /* Tracker3 graph access */
+        "--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:Documents",
         /* Needed for dconf to work */
         "--filesystem=xdg-run/dconf", "--filesystem=~/.config/dconf:ro",
         "--talk-name=ca.desrt.dconf", "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
@@ -157,35 +156,21 @@
                 }
             ]
         },
-        {
-            "name": "tracker",
-            "buildsystem": "meson",
-            "cleanup": [ "/bin", "/etc", "/lib/systemd", "/libexec", "/share/dbus-1/services" ],
-            "config-opts": [ "--default-library=shared", "-Dbash-completion=no", "-Ddocs=false" ],
-            "sources": [
-                {
-                    "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/tracker.git";,
-                    "branch": "tracker-2.3"
-                }
-            ]
-        },
         {
             "name": "tracker-miners",
             "buildsystem": "meson",
-            "cleanup": [ "/bin", "/etc", "/lib/systemd", "/libexec" ],
-            "config-opts": [ "--default-library=shared",
-                             "-Dminer_apps=false",
+            "config-opts": [ "-Ddefault_index_single_directories=&DOWNLOADS",
+                             "-Ddefault_index_recursive_directories=&DOCUMENTS",
+                             "-Ddomain_prefix=org.gnome.Documents",
+                             "-Dman=false",
+                             "-Dminer_fs=true",
+                             "-Dminer_fs_cache_location=$XDG_CACHE_HOME/org.gnome.Documents/miner/files",
                              "-Dminer_rss=false",
-                             "-Dextract=false",
-                             "-Dgeneric_media_extractor=none",
-                             "-Dwriteback=false",
-                             "-Dminer_fs=true" ],
+                             "-Dsystemd_user_services=false" ],
             "sources": [
                 {
                     "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git";,
-                    "branch": "tracker-miners-2.3"
+                    "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git";
                 }
             ]
         },
diff --git a/src/application.js b/src/application.js
index 73cd2da1..1fa75b79 100644
--- a/src/application.js
+++ b/src/application.js
@@ -70,6 +70,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"> \
@@ -347,6 +348,16 @@ var Application = GObject.registerClass({
             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';
+        }
+
         try {
             goaClient = Goa.Client.new_sync(null);
         } catch (e) {
diff --git a/src/query.js b/src/query.js
index 4f5142ea..ef90754e 100644
--- a/src/query.js
+++ b/src/query.js
@@ -205,7 +205,7 @@ var QueryBuilder = class QueryBuilder {
                 selectClauses +
                 whereSparql;
         } else {
-           let services = ['org.freedesktop.Tracker3.Miner.Files'];
+           let services = [this._context.trackerMinerService];
            let serviceQueries = [];
 
             if (this._context.sourceManager.hasProviderType('google'))
@@ -260,7 +260,7 @@ var QueryBuilder = class QueryBuilder {
            sparql = 'SELECT DISTINCT COUNT(?urn) AS ?c ' +
                this._buildWhere(true, flags);
        } else {
-           let services = ['org.freedesktop.Tracker3.Miner.Files'];
+           let services = [this._context.trackerMinerService];
            let countQueries = [];
 
             if (this._context.sourceManager.hasProviderType('google'))


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