[tracker/wip/carlosg/tracker-3.0-api-breaks: 56/100] libtracker-sparql: Allow specifying object path on DBus SPARQL connections
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/tracker-3.0-api-breaks: 56/100] libtracker-sparql: Allow specifying object path on DBus SPARQL connections
- Date: Mon, 17 Feb 2020 18:13:31 +0000 (UTC)
commit 02cf62f759332bcd19676779bd0a4abcfc96e90d
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Dec 31 15:47:16 2019 +0100
libtracker-sparql: Allow specifying object path on DBus SPARQL connections
This may be useful for endpoints eg. implemented via application plugins,
as a single dbus path can't be relied otherwise. We still look up for
the /org/freedesktop/Tracker1/Endpoint object path by default.
docs/reference/libtracker-sparql/examples/readonly-example.c | 2 +-
docs/reference/libtracker-sparql/examples/writeonly-example.c | 2 +-
.../examples/writeonly-with-blank-nodes-example.c | 2 +-
src/libtracker-bus/tracker-bus.vala | 9 +++++----
src/libtracker-data/tracker-vtab-service.c | 2 +-
src/libtracker-sparql-backend/tracker-backend.vala | 11 +++++++++--
src/libtracker-sparql/tracker-connection.vala | 2 +-
src/tracker/tracker-info.c | 8 ++++----
src/tracker/tracker-sparql.c | 2 +-
tests/functional-tests/ipc/test-bus-query-cancellation.c | 2 +-
tests/libtracker-sparql/tracker-fd-test.c | 2 +-
utils/mtp/mtp-dummy.c | 2 +-
utils/tracker-resdump/tracker-resdump.vala | 2 +-
13 files changed, 28 insertions(+), 20 deletions(-)
---
diff --git a/docs/reference/libtracker-sparql/examples/readonly-example.c
b/docs/reference/libtracker-sparql/examples/readonly-example.c
index 024d0b4b2..d65c61aa2 100644
--- a/docs/reference/libtracker-sparql/examples/readonly-example.c
+++ b/docs/reference/libtracker-sparql/examples/readonly-example.c
@@ -7,7 +7,7 @@ int main (int argc, const char **argv)
TrackerSparqlCursor *cursor;
const gchar *query = "SELECT nie:url(?u) WHERE { ?u a nfo:FileDataObject }";
- connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1", NULL, &error);
+ connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1", NULL, NULL, &error);
if (!connection) {
g_printerr ("Couldn't obtain a connection to the Tracker store: %s",
error ? error->message : "unknown error");
diff --git a/docs/reference/libtracker-sparql/examples/writeonly-example.c
b/docs/reference/libtracker-sparql/examples/writeonly-example.c
index 06a7e9186..7a7cd7e67 100644
--- a/docs/reference/libtracker-sparql/examples/writeonly-example.c
+++ b/docs/reference/libtracker-sparql/examples/writeonly-example.c
@@ -16,7 +16,7 @@ int main (int argc, const char **argv)
"FILTER (!bound(?tag)) "
"}";
- connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1", NULL, &error);
+ connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1", NULL, NULL, &error);
if (!connection) {
g_printerr ("Couldn't obtain a connection to the Tracker store: %s",
error ? error->message : "unknown error");
diff --git a/docs/reference/libtracker-sparql/examples/writeonly-with-blank-nodes-example.c
b/docs/reference/libtracker-sparql/examples/writeonly-with-blank-nodes-example.c
index b6091af52..5d180cdec 100644
--- a/docs/reference/libtracker-sparql/examples/writeonly-with-blank-nodes-example.c
+++ b/docs/reference/libtracker-sparql/examples/writeonly-with-blank-nodes-example.c
@@ -8,7 +8,7 @@ int main (int argc, const char **argv)
const gchar *query =
"INSERT { _:foo a nie:InformationElement } WHERE { ?x a rdfs:Class }";
- connection = tracker_sparql_connection_bus_new (NULL, &error);
+ connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1", NULL, NULL, &error);
if (!connection) {
g_printerr ("Couldn't obtain a connection to the Tracker store: %s",
error ? error->message : "unknown error");
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 72279a7ef..b2d1fba82 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -20,13 +20,14 @@
public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
DBusConnection bus;
string dbus_name;
+ string object_path;
- private const string ENDPOINT_PATH = "/org/freedesktop/Tracker1/Endpoint";
private const string ENDPOINT_IFACE = "org.freedesktop.Tracker1.Endpoint";
- public Connection (string dbus_name, DBusConnection? dbus_connection) throws Sparql.Error, IOError,
DBusError, GLib.Error {
+ public Connection (string dbus_name, string object_path, DBusConnection? dbus_connection) throws
Sparql.Error, IOError, DBusError, GLib.Error {
this.dbus_name = dbus_name;
this.bus = dbus_connection;
+ this.object_path = object_path;
// ensure that error domain is registered with GDBus
new Sparql.Error.INTERNAL ("");
@@ -56,7 +57,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
}
void send_query (string sparql, UnixOutputStream output, Cancellable? cancellable,
AsyncReadyCallback? callback) throws GLib.IOError, GLib.Error {
- var message = new DBusMessage.method_call (dbus_name, ENDPOINT_PATH, ENDPOINT_IFACE, "Query");
+ var message = new DBusMessage.method_call (dbus_name, object_path, ENDPOINT_IFACE, "Query");
var fd_list = new UnixFDList ();
message.set_body (new Variant ("(sh)", sparql, fd_list.append (output.fd)));
message.set_unix_fd_list (fd_list);
@@ -118,7 +119,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
}
void send_update (string method, UnixInputStream input, Cancellable? cancellable, AsyncReadyCallback?
callback) throws GLib.Error, GLib.IOError {
- var message = new DBusMessage.method_call (dbus_name, ENDPOINT_PATH, ENDPOINT_IFACE, method);
+ var message = new DBusMessage.method_call (dbus_name, object_path, ENDPOINT_IFACE, method);
var fd_list = new UnixFDList ();
message.set_body (new Variant ("(h)", fd_list.append (input.fd)));
message.set_unix_fd_list (fd_list);
diff --git a/src/libtracker-data/tracker-vtab-service.c b/src/libtracker-data/tracker-vtab-service.c
index 5f93711cb..cb800da2c 100644
--- a/src/libtracker-data/tracker-vtab-service.c
+++ b/src/libtracker-data/tracker-vtab-service.c
@@ -230,7 +230,7 @@ service_filter (sqlite3_vtab_cursor *vtab_cursor,
if (g_strcmp0 (uri_scheme, "dbus") == 0) {
const gchar *bus_name = &cursor->service[strlen (uri_scheme) + 1];
- cursor->conn = tracker_sparql_connection_bus_new (bus_name, NULL, &error);
+ cursor->conn = tracker_sparql_connection_bus_new (bus_name, NULL, NULL, &error);
if (!cursor->conn)
goto fail;
} else if (g_strcmp0 (uri_scheme, "http") == 0) {
diff --git a/src/libtracker-sparql-backend/tracker-backend.vala
b/src/libtracker-sparql-backend/tracker-backend.vala
index 05d5de54c..34e95bd6a 100644
--- a/src/libtracker-sparql-backend/tracker-backend.vala
+++ b/src/libtracker-sparql-backend/tracker-backend.vala
@@ -21,14 +21,21 @@ public static Tracker.Sparql.Connection tracker_sparql_connection_remote_new (st
return new Tracker.Remote.Connection (url_base);
}
-public static Tracker.Sparql.Connection tracker_sparql_connection_bus_new (string service, DBusConnection?
conn) throws Tracker.Sparql.Error, IOError, DBusError, GLib.Error {
+public static Tracker.Sparql.Connection tracker_sparql_connection_bus_new (string service, string?
object_path, DBusConnection? conn) throws Tracker.Sparql.Error, IOError, DBusError, GLib.Error {
GLib.DBusConnection dbus_conn;
+ string path;
+
if (conn != null)
dbus_conn = conn;
else
dbus_conn = GLib.Bus.get_sync (GLib.BusType.SESSION, null);
- return new Tracker.Bus.Connection (service, dbus_conn);
+ if (object_path != null)
+ path = object_path;
+ else
+ path = "/org/freedesktop/Tracker1/Endpoint";
+
+ return new Tracker.Bus.Connection (service, path, dbus_conn);
}
public static Tracker.Sparql.Connection tracker_sparql_connection_new (Tracker.Sparql.ConnectionFlags flags,
File store, File? ontology, Cancellable? cancellable = null) throws GLib.Error, Tracker.Sparql.Error, IOError
{
diff --git a/src/libtracker-sparql/tracker-connection.vala b/src/libtracker-sparql/tracker-connection.vala
index 44b27264e..e55506b28 100644
--- a/src/libtracker-sparql/tracker-connection.vala
+++ b/src/libtracker-sparql/tracker-connection.vala
@@ -155,7 +155,7 @@ public abstract class Tracker.Sparql.Connection : Object {
*/
public extern async static new Connection new_async (Tracker.Sparql.ConnectionFlags flags, File
store, File? ontology, Cancellable? cancellable = null) throws Sparql.Error, IOError;
- public extern static new Connection bus_new (string service_name, DBusConnection? dbus_connection =
null) throws Sparql.Error, IOError, DBusError, GLib.Error;
+ public extern static new Connection bus_new (string service_name, string? object_path,
DBusConnection? dbus_connection = null) throws Sparql.Error, IOError, DBusError, GLib.Error;
/**
* tracker_sparql_connection_query:
diff --git a/src/tracker/tracker-info.c b/src/tracker/tracker-info.c
index 784f67901..7c94cc90b 100644
--- a/src/tracker/tracker-info.c
+++ b/src/tracker/tracker-info.c
@@ -284,13 +284,13 @@ create_connection (GError **error)
if (!dbus_conn)
return NULL;
- return tracker_sparql_connection_bus_new (dbus_service, dbus_conn, error);
+ return tracker_sparql_connection_bus_new (dbus_service, NULL, dbus_conn, error);
} else if (remote_service && !database_path && !dbus_service) {
return tracker_sparql_connection_remote_new (remote_service);
} else {
- /* TRANSLATORS: Those are commandline arguments */
- g_printerr (_("Specify one --database, --dbus-service or --remote-service option"));
- exit (EXIT_FAILURE);
+ /* Default to tracker-miner-fs service */
+ return tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1.Miner.Files",
+ NULL, NULL, error);
}
}
diff --git a/src/tracker/tracker-sparql.c b/src/tracker/tracker-sparql.c
index 849f2e48d..94923deed 100644
--- a/src/tracker/tracker-sparql.c
+++ b/src/tracker/tracker-sparql.c
@@ -182,7 +182,7 @@ create_connection (GError **error)
if (!dbus_conn)
return NULL;
- return tracker_sparql_connection_bus_new (dbus_service, dbus_conn, error);
+ return tracker_sparql_connection_bus_new (dbus_service, NULL, dbus_conn, error);
} else if (remote_service && !database_path && !dbus_service) {
return tracker_sparql_connection_remote_new (remote_service);
} else {
diff --git a/tests/functional-tests/ipc/test-bus-query-cancellation.c
b/tests/functional-tests/ipc/test-bus-query-cancellation.c
index 44388b88d..795887961 100644
--- a/tests/functional-tests/ipc/test-bus-query-cancellation.c
+++ b/tests/functional-tests/ipc/test-bus-query-cancellation.c
@@ -93,7 +93,7 @@ create_dbus_connection (GError **error)
g_usleep (100);
dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
- dbus_conn, error);
+ NULL, dbus_conn, error);
return dbus;
}
diff --git a/tests/libtracker-sparql/tracker-fd-test.c b/tests/libtracker-sparql/tracker-fd-test.c
index 2d3c260ca..fd96037c4 100644
--- a/tests/libtracker-sparql/tracker-fd-test.c
+++ b/tests/libtracker-sparql/tracker-fd-test.c
@@ -766,7 +766,7 @@ create_dbus_connection (GError **error)
g_usleep (100);
dbus = tracker_sparql_connection_bus_new (g_dbus_connection_get_unique_name (dbus_conn),
- dbus_conn, error);
+ NULL, dbus_conn, error);
return dbus;
}
diff --git a/utils/mtp/mtp-dummy.c b/utils/mtp/mtp-dummy.c
index 5d99ef406..570f5313f 100644
--- a/utils/mtp/mtp-dummy.c
+++ b/utils/mtp/mtp-dummy.c
@@ -287,7 +287,7 @@ context_init (gint argc,
/* Get connection */
connection = tracker_sparql_connection_bus_new ("org.freedesktop.Tracker1",
- NULL, &error);
+ NULL, NULL, &error);
if (!connection) {
/* Some error happened performing the query, not good */
g_error ("Couldn't get sparql connection: %s",
diff --git a/utils/tracker-resdump/tracker-resdump.vala b/utils/tracker-resdump/tracker-resdump.vala
index 2a6ea6c36..e6bbb43d0 100644
--- a/utils/tracker-resdump/tracker-resdump.vala
+++ b/utils/tracker-resdump/tracker-resdump.vala
@@ -103,7 +103,7 @@ static int main(string[] args)
}
try {
- conn = Connection.bus_new("org.freedesktop.Tracker1");
+ conn = Connection.bus_new("org.freedesktop.Tracker1", null);
} catch (GLib.Error e) {
critical("Couldn't connect to Tracker: %s", e.message);
return 1;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]