[tracker-miners/wip/carlosg/extraction-fixes: 3/3] tracker-miner-fs: Forward tracker-extract status as its own
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/extraction-fixes: 3/3] tracker-miner-fs: Forward tracker-extract status as its own
- Date: Wed, 30 Sep 2020 18:13:18 +0000 (UTC)
commit bd3ce694d78eb99a4bf1a583fa415f25d3ca9859
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Sep 30 18:17:23 2020 +0200
tracker-miner-fs: Forward tracker-extract status as its own
The tracker-extract service is no longer deemed a "miner", but its
status is relevant to "tracker3 status" and "tracker3 daemon -f".
As tracker-extract is really an "implementation detail", proxy this
status via tracker-miner-fs, so these tools don't mislead if only
tracker-extract is active.
src/miners/fs/tracker-extract-watchdog.c | 52 ++++++++++++++++++++++++++++++++
src/miners/fs/tracker-miner-files.c | 18 +++++++++++
2 files changed, 70 insertions(+)
---
diff --git a/src/miners/fs/tracker-extract-watchdog.c b/src/miners/fs/tracker-extract-watchdog.c
index 7d05d8608..41e12a51c 100644
--- a/src/miners/fs/tracker-extract-watchdog.c
+++ b/src/miners/fs/tracker-extract-watchdog.c
@@ -25,6 +25,7 @@
#include <libtracker-miner/tracker-miner.h>
enum {
+ STATUS,
LOST,
N_SIGNALS
};
@@ -33,8 +34,10 @@ static guint signals[N_SIGNALS] = { 0, };
struct _TrackerExtractWatchdog {
GObject parent_class;
+ GDBusConnection *conn;
gchar *domain;
guint extractor_watchdog_id;
+ guint progress_signal_id;
gboolean initializing;
};
@@ -46,12 +49,39 @@ G_DEFINE_TYPE (TrackerExtractWatchdog, tracker_extract_watchdog, G_TYPE_OBJECT)
static void
extract_watchdog_stop (TrackerExtractWatchdog *watchdog)
{
+ if (watchdog->conn && watchdog->progress_signal_id) {
+ g_dbus_connection_signal_unsubscribe (watchdog->conn,
+ watchdog->progress_signal_id);
+ watchdog->progress_signal_id = 0;
+ watchdog->conn = NULL;
+ }
+
if (watchdog->extractor_watchdog_id) {
g_bus_unwatch_name (watchdog->extractor_watchdog_id);
watchdog->extractor_watchdog_id = 0;
}
}
+static void
+on_extract_progress_cb (GDBusConnection *conn,
+ const gchar *sender_name,
+ const gchar *object_path,
+ const gchar *interface_name,
+ const gchar *signal_name,
+ GVariant *parameters,
+ gpointer user_data)
+{
+ TrackerExtractWatchdog *watchdog = user_data;
+ const gchar *status;
+ gdouble progress;
+ gint32 remaining;
+
+ g_variant_get (parameters, "(&sdi)",
+ &status, &progress, &remaining);
+ g_signal_emit (watchdog, signals[STATUS], 0,
+ status, progress, (gint) remaining);
+}
+
static void
extract_watchdog_name_appeared (GDBusConnection *conn,
const gchar *name,
@@ -62,6 +92,19 @@ extract_watchdog_name_appeared (GDBusConnection *conn,
if (watchdog->initializing)
watchdog->initializing = FALSE;
+
+ watchdog->conn = conn;
+ watchdog->progress_signal_id =
+ g_dbus_connection_signal_subscribe (watchdog->conn,
+ "org.freedesktop.Tracker3.Miner.Extract",
+ "org.freedesktop.Tracker3.Miner",
+ "Progress",
+ "/org/freedesktop/Tracker3/Miner/Extract",
+ NULL,
+ G_DBUS_SIGNAL_FLAGS_NONE,
+ on_extract_progress_cb,
+ watchdog,
+ NULL);
}
static void
@@ -89,6 +132,7 @@ extract_watchdog_name_vanished (GDBusConnection *conn,
return;
}
+ g_signal_emit (watchdog, signals[STATUS], 0, "Idle", 1.0, 0);
g_signal_emit (watchdog, signals[LOST], 0);
}
@@ -139,6 +183,14 @@ tracker_extract_watchdog_class_init (TrackerExtractWatchdogClass *klass)
object_class->finalize = tracker_extract_watchdog_finalize;
+ signals[STATUS] = g_signal_new ("status",
+ G_OBJECT_CLASS_TYPE (object_class),
+ G_SIGNAL_RUN_LAST,
+ 0, NULL, NULL, NULL,
+ G_TYPE_NONE, 3,
+ G_TYPE_STRING,
+ G_TYPE_DOUBLE,
+ G_TYPE_INT);
signals[LOST] = g_signal_new ("lost",
G_OBJECT_CLASS_TYPE (object_class),
G_SIGNAL_RUN_LAST,
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index 49171ffcd..bb6289912 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -304,6 +304,22 @@ on_extractor_lost (TrackerExtractWatchdog *watchdog,
g_timeout_add_seconds (1, extractor_lost_timeout_cb, mf);
}
+static void
+on_extractor_status (TrackerExtractWatchdog *watchdog,
+ const gchar *status,
+ gdouble progress,
+ gint remaining,
+ TrackerMinerFiles *mf)
+{
+ if (!tracker_miner_is_paused (TRACKER_MINER (mf))) {
+ g_object_set (mf,
+ "status", status,
+ "progress", progress,
+ "remaining-time", remaining,
+ NULL);
+ }
+}
+
static void
tracker_miner_files_init (TrackerMinerFiles *mf)
{
@@ -646,6 +662,8 @@ miner_files_initable_init (GInitable *initable,
mf->private->extract_watchdog = tracker_extract_watchdog_new (domain_name);
g_signal_connect (mf->private->extract_watchdog, "lost",
G_CALLBACK (on_extractor_lost), mf);
+ g_signal_connect (mf->private->extract_watchdog, "status",
+ G_CALLBACK (on_extractor_status), mf);
g_free (domain_name);
return TRUE;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]