[tracker-miners/wip/carlosg/tracker-3.0-api-breaks: 26/40] tracker-miner-fs: Propagate domain through TrackerMinerFiles



commit d088cb4cbaa60ea521bb15278dedf19be6611c7b
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Dec 31 02:20:32 2019 +0100

    tracker-miner-fs: Propagate domain through TrackerMinerFiles
    
    Set it as a property, so it can be fetched from the tracker-extract
    watchdog.

 src/miners/fs/tracker-extract-watchdog.c | 24 +++++++++++++++---------
 src/miners/fs/tracker-extract-watchdog.h |  2 +-
 src/miners/fs/tracker-main.c             |  3 ++-
 src/miners/fs/tracker-miner-files.c      | 23 +++++++++++++++++++++--
 src/miners/fs/tracker-miner-files.h      |  1 +
 5 files changed, 40 insertions(+), 13 deletions(-)
---
diff --git a/src/miners/fs/tracker-extract-watchdog.c b/src/miners/fs/tracker-extract-watchdog.c
index 81166b921..21d069776 100644
--- a/src/miners/fs/tracker-extract-watchdog.c
+++ b/src/miners/fs/tracker-extract-watchdog.c
@@ -33,6 +33,7 @@ static guint signals[N_SIGNALS] = { 0, };
 
 struct _TrackerExtractWatchdog {
        GObject parent_class;
+       gchar *domain;
        guint extractor_watchdog_id;
        gboolean initializing;
 };
@@ -95,13 +96,12 @@ static void
 extract_watchdog_start (TrackerExtractWatchdog *watchdog,
                        gboolean                autostart)
 {
-       gchar *domain_name, *tracker_extract_dbus_name;
+       const gchar *domain_name = watchdog->domain;
+       gchar *tracker_extract_dbus_name;
 
        g_debug ("Setting up watch on tracker-extract (autostart: %s)",
                 autostart ? "yes" : "no");
 
-       domain_name = tracker_sparql_connection_get_domain ();
-
        if (domain_name == NULL) {
                tracker_extract_dbus_name = g_strdup (TRACKER_MINER_DBUS_NAME_PREFIX "Extract");
        } else {
@@ -119,7 +119,6 @@ extract_watchdog_start (TrackerExtractWatchdog *watchdog,
                                  watchdog, NULL);
 
        g_free (tracker_extract_dbus_name);
-       g_free (domain_name);
 }
 
 static void
@@ -128,6 +127,7 @@ tracker_extract_watchdog_finalize (GObject *object)
        TrackerExtractWatchdog *watchdog = TRACKER_EXTRACT_WATCHDOG (object);
 
        extract_watchdog_stop (watchdog);
+       g_free (watchdog->domain);
 
        G_OBJECT_CLASS (tracker_extract_watchdog_parent_class)->finalize (object);
 }
@@ -149,15 +149,21 @@ tracker_extract_watchdog_class_init (TrackerExtractWatchdogClass *klass)
 static void
 tracker_extract_watchdog_init (TrackerExtractWatchdog *watchdog)
 {
-       watchdog->initializing = TRUE;
-       extract_watchdog_start (watchdog, FALSE);
 }
 
 TrackerExtractWatchdog *
-tracker_extract_watchdog_new (void)
+tracker_extract_watchdog_new (const gchar *domain)
 {
-       return g_object_new (TRACKER_TYPE_EXTRACT_WATCHDOG,
-                            NULL);
+       TrackerExtractWatchdog *watchdog;
+
+       watchdog = g_object_new (TRACKER_TYPE_EXTRACT_WATCHDOG,
+                                NULL);
+
+       watchdog->initializing = TRUE;
+       watchdog->domain = g_strdup (domain);
+       extract_watchdog_start (watchdog, FALSE);
+
+       return watchdog;
 }
 
 void
diff --git a/src/miners/fs/tracker-extract-watchdog.h b/src/miners/fs/tracker-extract-watchdog.h
index 28c2b637e..906ad0d36 100644
--- a/src/miners/fs/tracker-extract-watchdog.h
+++ b/src/miners/fs/tracker-extract-watchdog.h
@@ -31,7 +31,7 @@ G_DECLARE_FINAL_TYPE (TrackerExtractWatchdog,
                      TRACKER, EXTRACT_WATCHDOG,
                      GObject)
 
-TrackerExtractWatchdog * tracker_extract_watchdog_new (void);
+TrackerExtractWatchdog * tracker_extract_watchdog_new (const gchar *domain);
 
 void tracker_extract_watchdog_ensure_started (TrackerExtractWatchdog *watchdog);
 
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index 67bf6a7fe..d284d232d 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -918,7 +918,8 @@ main (gint argc, gchar *argv[])
        }
 
        /* Create new TrackerMinerFiles object */
-       miner_files = tracker_miner_files_new (sparql_conn, config, &error);
+       miner_files = tracker_miner_files_new (sparql_conn, config,
+                                              domain_ontology_name, &error);
        if (!miner_files) {
                g_critical ("Couldn't create new Files miner: '%s'",
                            error ? error->message : "unknown error");
diff --git a/src/miners/fs/tracker-miner-files.c b/src/miners/fs/tracker-miner-files.c
index f32e69bf2..a9b53c3d7 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -84,6 +84,8 @@ struct TrackerMinerFilesPrivate {
        GSList *index_recursive_directories;
        GSList *index_single_directories;
 
+       gchar *domain;
+
        guint disk_space_check_id;
        gboolean disk_space_pause;
 
@@ -132,7 +134,8 @@ enum {
 
 enum {
        PROP_0,
-       PROP_CONFIG
+       PROP_CONFIG,
+       PROP_DOMAIN,
 };
 
 enum {
@@ -385,6 +388,13 @@ tracker_miner_files_class_init (TrackerMinerFilesClass *klass)
                                                              "Config",
                                                              TRACKER_TYPE_CONFIG,
                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS));
+       g_object_class_install_property (object_class,
+                                        PROP_DOMAIN,
+                                        g_param_spec_string ("domain",
+                                                             "Domain",
+                                                             "Domain",
+                                                             NULL,
+                                                             G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | 
G_PARAM_STATIC_STRINGS));
 
        miner_files_error_quark = g_quark_from_static_string ("TrackerMinerFiles");
 }
@@ -814,7 +824,7 @@ miner_files_initable_init (GInitable     *initable,
 
        disk_space_check_start (mf);
 
-       mf->private->extract_watchdog = tracker_extract_watchdog_new ();
+       mf->private->extract_watchdog = tracker_extract_watchdog_new (mf->private->domain);
        g_signal_connect (mf->private->extract_watchdog, "lost",
                          G_CALLBACK (on_extractor_lost), mf);
 
@@ -837,6 +847,9 @@ miner_files_set_property (GObject      *object,
        case PROP_CONFIG:
                priv->config = g_value_dup_object (value);
                break;
+       case PROP_DOMAIN:
+               priv->domain = g_value_dup_string (value);
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;
@@ -857,6 +870,9 @@ miner_files_get_property (GObject    *object,
        case PROP_CONFIG:
                g_value_set_object (value, priv->config);
                break;
+       case PROP_DOMAIN:
+               g_value_set_string (value, priv->domain);
+               break;
        default:
                G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
                break;
@@ -875,6 +891,7 @@ miner_files_finalize (GObject *object)
        g_cancellable_cancel (priv->extract_check_cancellable);
        g_object_unref (priv->extract_check_cancellable);
        g_free (priv->extract_check_query);
+       g_free (priv->domain);
 
        if (priv->grace_period_timeout_id != 0) {
                g_source_remove (priv->grace_period_timeout_id);
@@ -2915,6 +2932,7 @@ miner_files_move_file (TrackerMinerFS *fs,
 TrackerMiner *
 tracker_miner_files_new (TrackerSparqlConnection  *connection,
                          TrackerConfig            *config,
+                         const gchar              *domain,
                          GError                  **error)
 {
        return g_initable_new (TRACKER_TYPE_MINER_FILES,
@@ -2923,6 +2941,7 @@ tracker_miner_files_new (TrackerSparqlConnection  *connection,
                               "connection", connection,
                               "root", NULL,
                               "config", config,
+                              "domain", domain,
                               "processing-pool-wait-limit", 10,
                               "processing-pool-ready-limit", 100,
                               NULL);
diff --git a/src/miners/fs/tracker-miner-files.h b/src/miners/fs/tracker-miner-files.h
index 62f77289d..648c025cd 100644
--- a/src/miners/fs/tracker-miner-files.h
+++ b/src/miners/fs/tracker-miner-files.h
@@ -50,6 +50,7 @@ GType         tracker_miner_files_get_type                 (void) G_GNUC_CONST;
 
 TrackerMiner *tracker_miner_files_new                      (TrackerSparqlConnection  *connection,
                                                             TrackerConfig            *config,
+                                                            const gchar              *domain,
                                                             GError                  **error);
 
 /* Convenience functions for --eligible tracker-miner-fs cmdline */


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