[tracker-miners/wip/carlosg/tracker-3.0-api-breaks: 16/40] rss: Use private connection and endpoint
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/carlosg/tracker-3.0-api-breaks: 16/40] rss: Use private connection and endpoint
- Date: Mon, 17 Feb 2020 12:25:44 +0000 (UTC)
commit d018f0f76be253f05ed0e329ea7199f3e4c60267
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Dec 24 13:35:52 2019 +0100
rss: Use private connection and endpoint
This makes the RSS miner write to its own private triple store,
while allowing users to interact with it through the endpoint
interface.
src/miners/rss/tracker-main.c | 48 +++++++++++++++++++++++++++++++++++++-
src/miners/rss/tracker-miner-rss.c | 4 +++-
src/miners/rss/tracker-miner-rss.h | 3 ++-
3 files changed, 52 insertions(+), 3 deletions(-)
---
diff --git a/src/miners/rss/tracker-main.c b/src/miners/rss/tracker-main.c
index 864cc4d8d..d5f0cebc0 100644
--- a/src/miners/rss/tracker-main.c
+++ b/src/miners/rss/tracker-main.c
@@ -68,6 +68,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 (int argc, char **argv)
{
@@ -77,6 +106,8 @@ main (int argc, char **argv)
TrackerMinerRSS *miner;
GError *error = NULL;
GDBusConnection *connection;
+ TrackerSparqlConnection *sparql_conn;
+ TrackerEndpointDBus *endpoint;
TrackerMinerProxy *proxy;
TrackerDomainOntology *domain_ontology;
gchar *domain_name, *dbus_name;
@@ -188,7 +219,20 @@ main (int argc, char **argv)
return EXIT_FAILURE;
}
- miner = tracker_miner_rss_new (&error);
+ 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;
+ }
+
+ miner = tracker_miner_rss_new (sparql_conn, &error);
if (!miner) {
g_critical ("Could not create new RSS miner: '%s', exiting...\n",
error ? error->message : "unknown error");
@@ -235,6 +279,8 @@ main (int argc, char **argv)
tracker_log_shutdown ();
g_main_loop_unref (loop);
+ g_object_unref (sparql_conn);
+ g_object_unref (endpoint);
g_object_unref (miner);
g_object_unref (connection);
g_object_unref (proxy);
diff --git a/src/miners/rss/tracker-miner-rss.c b/src/miners/rss/tracker-miner-rss.c
index a32fcc7da..e3a783e4c 100644
--- a/src/miners/rss/tracker-miner-rss.c
+++ b/src/miners/rss/tracker-miner-rss.c
@@ -1227,10 +1227,12 @@ miner_resumed (TrackerMiner *miner)
}
TrackerMinerRSS *
-tracker_miner_rss_new (GError **error)
+tracker_miner_rss_new (TrackerSparqlConnection *connection,
+ GError **error)
{
return g_initable_new (TRACKER_TYPE_MINER_RSS,
NULL,
error,
+ "connection", connection,
NULL);
}
diff --git a/src/miners/rss/tracker-miner-rss.h b/src/miners/rss/tracker-miner-rss.h
index 2271ec9da..6978db121 100644
--- a/src/miners/rss/tracker-miner-rss.h
+++ b/src/miners/rss/tracker-miner-rss.h
@@ -46,7 +46,8 @@ struct _TrackerMinerRSSClass {
};
GType tracker_miner_rss_get_type (void) G_GNUC_CONST;
-TrackerMinerRSS *tracker_miner_rss_new (GError **error);
+TrackerMinerRSS *tracker_miner_rss_new (TrackerSparqlConnection *conn,
+ GError **error);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]