[tracker-miners/wip/carlosg/tracker-3.0-api-breaks: 34/57] tracker-miner-fs: Use private connection, and export endpoint



commit 6c0477de65059e55e417795ce341c691714911b7
Author: Carlos Garnacho <carlosg gnome org>
Date:   Tue Dec 24 13:54:33 2019 +0100

    tracker-miner-fs: Use private connection, and export endpoint
    
    As tracker-extract is a tandem with it, make it look for the
    tracker-miner-fs endpoint in order to issue updates.

 src/miners/fs/tracker-main.c                    | 46 ++++++++++++++++++++++++-
 src/miners/fs/tracker-miner-files.c             |  6 ++--
 src/miners/fs/tracker-miner-files.h             |  5 +--
 src/tracker-extract/tracker-extract-decorator.c |  8 +++--
 src/tracker-extract/tracker-extract-decorator.h |  7 ++--
 src/tracker-extract/tracker-main.c              | 14 +++++++-
 6 files changed, 74 insertions(+), 12 deletions(-)
---
diff --git a/src/miners/fs/tracker-main.c b/src/miners/fs/tracker-main.c
index a42d03555..3f35d0725 100644
--- a/src/miners/fs/tracker-main.c
+++ b/src/miners/fs/tracker-main.c
@@ -759,6 +759,35 @@ on_domain_vanished (GDBusConnection *connection,
        g_main_loop_quit (loop);
 }
 
+static gboolean
+setup_connection_and_endpoint (TrackerDomainOntology    *domain,
+                               GDBusConnection          *connection,
+                               TrackerSparqlConnection **sparql_conn,
+                               TrackerEndpointDBus     **endpoint,
+                               GError                  **error)
+{
+       GFile *store;
+
+       store = tracker_domain_ontology_get_cache (domain);
+       *sparql_conn = tracker_sparql_connection_new (TRACKER_SPARQL_CONNECTION_FLAGS_NONE,
+                                                     store,
+                                                     NULL,
+                                                     NULL,
+                                                     error);
+       if (!*sparql_conn)
+               return FALSE;
+
+       *endpoint = tracker_endpoint_dbus_new (*sparql_conn,
+                                              connection,
+                                              NULL,
+                                              NULL,
+                                              error);
+       if (!*endpoint)
+               return FALSE;
+
+       return TRUE;
+}
+
 int
 main (gint argc, gchar *argv[])
 {
@@ -773,6 +802,8 @@ main (gint argc, gchar *argv[])
        gboolean store_available;
        TrackerMinerProxy *proxy;
        GDBusConnection *connection;
+       TrackerSparqlConnection *sparql_conn;
+       TrackerEndpointDBus *endpoint;
        TrackerDomainOntology *domain_ontology;
        gchar *domain_name, *dbus_name;
 
@@ -875,8 +906,21 @@ main (gint argc, gchar *argv[])
                   no_daemon ? "No" : "Yes",
                   no_daemon ? "(forced by command line)" : "");
 
+       if (!setup_connection_and_endpoint (domain_ontology,
+                                           connection,
+                                           &sparql_conn,
+                                           &endpoint,
+                                           &error)) {
+
+               g_critical ("Could not create store/endpoint: %s",
+                           error->message);
+               g_error_free (error);
+
+               return EXIT_FAILURE;
+       }
+
        /* Create new TrackerMinerFiles object */
-       miner_files = tracker_miner_files_new (config, &error);
+       miner_files = tracker_miner_files_new (sparql_conn, config, &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 630f28b0b..f32e69bf2 100644
--- a/src/miners/fs/tracker-miner-files.c
+++ b/src/miners/fs/tracker-miner-files.c
@@ -2913,12 +2913,14 @@ miner_files_move_file (TrackerMinerFS *fs,
 }
 
 TrackerMiner *
-tracker_miner_files_new (TrackerConfig  *config,
-                         GError        **error)
+tracker_miner_files_new (TrackerSparqlConnection  *connection,
+                         TrackerConfig            *config,
+                         GError                  **error)
 {
        return g_initable_new (TRACKER_TYPE_MINER_FILES,
                               NULL,
                               error,
+                              "connection", connection,
                               "root", NULL,
                               "config", config,
                               "processing-pool-wait-limit", 10,
diff --git a/src/miners/fs/tracker-miner-files.h b/src/miners/fs/tracker-miner-files.h
index c67140774..62f77289d 100644
--- a/src/miners/fs/tracker-miner-files.h
+++ b/src/miners/fs/tracker-miner-files.h
@@ -48,8 +48,9 @@ struct TrackerMinerFilesClass {
 
 GType         tracker_miner_files_get_type                 (void) G_GNUC_CONST;
 
-TrackerMiner *tracker_miner_files_new                      (TrackerConfig  *config,
-                                                            GError        **error);
+TrackerMiner *tracker_miner_files_new                      (TrackerSparqlConnection  *connection,
+                                                            TrackerConfig            *config,
+                                                            GError                  **error);
 
 /* Convenience functions for --eligible tracker-miner-fs cmdline */
 gboolean      tracker_miner_files_check_file               (GFile             *file,
diff --git a/src/tracker-extract/tracker-extract-decorator.c b/src/tracker-extract/tracker-extract-decorator.c
index c9a18fae9..ce87b7f1c 100644
--- a/src/tracker-extract/tracker-extract-decorator.c
+++ b/src/tracker-extract/tracker-extract-decorator.c
@@ -684,12 +684,14 @@ tracker_extract_decorator_initable_iface_init (GInitableIface *iface)
 }
 
 TrackerDecorator *
-tracker_extract_decorator_new (TrackerExtract  *extract,
-                               GCancellable    *cancellable,
-                               GError         **error)
+tracker_extract_decorator_new (TrackerSparqlConnection  *connection,
+                               TrackerExtract           *extract,
+                               GCancellable             *cancellable,
+                               GError                  **error)
 {
        return g_initable_new (TRACKER_TYPE_EXTRACT_DECORATOR,
                               cancellable, error,
+                              "connection", connection,
                               "data-source", TRACKER_EXTRACT_DATA_SOURCE,
                               "class-names", supported_classes,
                               "extractor", extract,
diff --git a/src/tracker-extract/tracker-extract-decorator.h b/src/tracker-extract/tracker-extract-decorator.h
index 748bce608..8cbf74891 100644
--- a/src/tracker-extract/tracker-extract-decorator.h
+++ b/src/tracker-extract/tracker-extract-decorator.h
@@ -47,9 +47,10 @@ struct TrackerExtractDecoratorClass {
 
 GType              tracker_extract_decorator_get_type (void) G_GNUC_CONST;
 
-TrackerDecorator * tracker_extract_decorator_new      (TrackerExtract  *extractor,
-                                                      GCancellable    *cancellable,
-                                                      GError         **error);
+TrackerDecorator * tracker_extract_decorator_new (TrackerSparqlConnection  *connection,
+                                                  TrackerExtract           *extractor,
+                                                  GCancellable             *cancellable,
+                                                  GError                  **error);
 
 G_END_DECLS
 
diff --git a/src/tracker-extract/tracker-main.c b/src/tracker-extract/tracker-main.c
index 7d5443d37..ac8a2bd80 100644
--- a/src/tracker-extract/tracker-main.c
+++ b/src/tracker-extract/tracker-main.c
@@ -315,6 +315,7 @@ main (int argc, char *argv[])
        GMainLoop *my_main_loop;
        GDBusConnection *connection;
        TrackerMinerProxy *proxy;
+       TrackerSparqlConnection *sparql_connection;
        TrackerDomainOntology *domain_ontology;
        gchar *domain_name, *dbus_name;
 
@@ -414,7 +415,18 @@ main (int argc, char *argv[])
 
        tracker_module_manager_load_modules ();
 
-       decorator = tracker_extract_decorator_new (extract, NULL, &error);
+       dbus_name = tracker_domain_ontology_get_domain (domain_ontology, "Files");
+       sparql_connection = tracker_sparql_connection_bus_new (dbus_name,
+                                                              NULL, &error);
+
+       if (error) {
+               g_critical ("Could not connect to filesystem miner endpoint: %s",
+                           error->message);
+               g_error_free (error);
+               return EXIT_FAILURE;
+       }
+
+       decorator = tracker_extract_decorator_new (sparql_connection, extract, NULL, &error);
 
        if (error) {
                g_critical ("Could not start decorator: %s\n", error->message);


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