Commit bd3ce694 authored by Carlos Garnacho's avatar Carlos Garnacho

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.
parent 27bd462d
Pipeline #217592 passed with stages
in 8 minutes and 37 seconds
......@@ -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,
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment