[polari/wip/fmuellner/tracker: 18/18] logManager: Try to start chatlog miner if not running



commit 0535faad398de4dff46b8964ac6a711e486aa616
Author: Florian Müllner <fmuellner gnome org>
Date:   Thu Jul 28 02:41:31 2016 +0200

    logManager: Try to start chatlog miner if not running

 configure.ac      |    1 +
 src/logManager.js |   35 +++++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index c9665be..7707f77 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,7 @@ AX_CHECK_GIRS_GJS([Secret], [1])
 AX_CHECK_GIRS_GJS([Soup], [2.4])
 AX_CHECK_GIRS_GJS([TelepathyGLib], [0.12])
 AX_CHECK_GIRS_GJS([Tracker], [1.0])
+AX_CHECK_GIRS_GJS([TrackerControl], [1.0])
 
 AC_PROG_LN_S
 
diff --git a/src/logManager.js b/src/logManager.js
index 6ceaa2f..9ccf148 100644
--- a/src/logManager.js
+++ b/src/logManager.js
@@ -1,8 +1,12 @@
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 const Tracker = imports.gi.Tracker;
+const TrackerControl = imports.gi.TrackerControl;
 const Tp = imports.gi.TelepathyGLib;
 
+const CHATLOG_MINER_NAME = Tracker.DBUS_SERVICE + '.Miner.Chatlog';
+const CHATLOG_MINER_PATH = '/' + CHATLOG_MINER_NAME.replace('.', '/', 'g');
+
 let _logManager = null;
 
 function getDefault() {
@@ -195,9 +199,40 @@ const _LogManager = new Lang.Class({
     Name: 'LogManager',
 
     _init: function() {
+        this._ensureChatlogMiner();
         this._connection = Tracker.SparqlConnection.get(null);
     },
 
+    _ensureChatlogMiner: function() {
+        let running = false;
+        try {
+            let manager = TrackerControl.MinerManager.new_full(false);
+            [running,] = manager.get_status(CHATLOG_MINER_NAME);
+        } catch(e) {
+            debug('Unable to create MinerManager: ' + e.message);
+        }
+
+        if (running) {
+            debug('Detected running chatlog miner.');
+            return;
+        }
+
+       let flags = Gio.DBusProxyFlags.DO_NOT_LOAD_PROPERTIES |
+                   Gio.DBusProxyFlags.DO_NOT_CONNECT_SIGNALS;
+       Gio.DBusProxy.new_for_bus(Gio.BusType.SESSION, flags, null,
+                                 CHATLOG_MINER_NAME, CHATLOG_MINER_PATH,
+                                 Tracker.DBUS_SERVICE + '.Miner',
+                                 null, (o, res) => {
+           let miner = null;
+           try {
+               miner = Gio.DBusProxy.new_for_bus_finish(res);
+               debug('Started chatlog miner.');
+           } catch(e) {
+               log('Failed to start chatlog miner: ' + e.message);
+           }
+       });
+    },
+
     query: function(sparql, cancellable, callback) {
         let query = new GenericQuery(this._connection);
         query.run(sparql, cancellable, callback);


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