[tracker-miners/wip/carlosg/dbus-api-changes: 27/29] tracker-index: Make service autoclose if there's no watched files
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/dbus-api-changes: 27/29] tracker-index: Make service autoclose if there's no watched files
- Date: Sat, 1 Aug 2020 11:55:02 +0000 (UTC)
commit 05d6240c828db565441b6e3783eec66d87752e4e
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Jun 21 10:55:07 2020 +0200
tracker-index: Make service autoclose if there's no watched files
This service is unnecessary if there's no current requests, we can
close it and trust on DBus autostart to handle future requests.
src/tracker-control/tracker-main.c | 9 +++++++++
src/tracker-control/tracker-miner-files-index.c | 17 +++++++++++++++++
2 files changed, 26 insertions(+)
---
diff --git a/src/tracker-control/tracker-main.c b/src/tracker-control/tracker-main.c
index 67153d8be..095c73ba4 100644
--- a/src/tracker-control/tracker-main.c
+++ b/src/tracker-control/tracker-main.c
@@ -103,6 +103,13 @@ initialize_signal_handler (void)
#endif /* G_OS_WIN32 */
}
+static void
+files_index_close_cb (GMainLoop *main_loop)
+{
+ g_debug ("No further watched folders, closing");
+ g_main_loop_quit (main_loop);
+}
+
int
main (gint argc, gchar *argv[])
{
@@ -153,6 +160,8 @@ main (gint argc, gchar *argv[])
main_loop = g_main_loop_new (NULL, FALSE);
index = tracker_miner_files_index_new ();
+ g_signal_connect (index, "close",
+ G_CALLBACK (files_index_close_cb), main_loop);
/* Request DBus name */
if (!tracker_dbus_request_name (connection,
diff --git a/src/tracker-control/tracker-miner-files-index.c b/src/tracker-control/tracker-miner-files-index.c
index fce427692..27fd0e505 100644
--- a/src/tracker-control/tracker-miner-files-index.c
+++ b/src/tracker-control/tracker-miner-files-index.c
@@ -50,6 +50,13 @@ enum {
PROP_FILES_MINER
};
+enum {
+ CLOSE,
+ N_SIGNALS
+};
+
+static guint signals[N_SIGNALS] = { 0 };
+
#define TRACKER_MINER_FILES_INDEX_GET_PRIVATE(o) (tracker_miner_files_index_get_instance_private
(TRACKER_MINER_FILES_INDEX (o)))
static void index_finalize (GObject *object);
@@ -95,6 +102,13 @@ tracker_miner_files_index_class_init (TrackerMinerFilesIndexClass *klass)
object_class = G_OBJECT_CLASS (klass);
object_class->finalize = index_finalize;
+
+ signals[CLOSE] =
+ g_signal_new ("close",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST, 0,
+ NULL, NULL, NULL,
+ G_TYPE_NONE, 0);
}
static void
@@ -185,6 +199,9 @@ peer_listener_unwatch_file (TrackerMinerFilesPeerListener *listener,
}
update_indexed_files (index);
+
+ if (priv->indexed_files->len == 0)
+ g_signal_emit (index, signals[CLOSE], 0);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]