[tracker/wip/carlosg/serialize-api: 30/36] libtracker-sparql: Handle statement serialization in D-Bus endpoints
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/serialize-api: 30/36] libtracker-sparql: Handle statement serialization in D-Bus endpoints
- Date: Mon, 10 Jan 2022 10:58:36 +0000 (UTC)
commit 5879dc66236dad979a0966a8b78538387bef68eb
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Nov 27 14:13:42 2021 +0100
libtracker-sparql: Handle statement serialization in D-Bus endpoints
Use the direct connection underneath to create an statement for serialization
if there are query arguments.
src/libtracker-sparql/tracker-endpoint-dbus.c | 64 ++++++++++++++++++++++++---
1 file changed, 57 insertions(+), 7 deletions(-)
---
diff --git a/src/libtracker-sparql/tracker-endpoint-dbus.c b/src/libtracker-sparql/tracker-endpoint-dbus.c
index ea654aaec..47ea7ca86 100644
--- a/src/libtracker-sparql/tracker-endpoint-dbus.c
+++ b/src/libtracker-sparql/tracker-endpoint-dbus.c
@@ -532,6 +532,35 @@ splice_rdf_cb (GObject *object,
query_request_free (request);
}
+static void
+stmt_serialize_cb (GObject *object,
+ GAsyncResult *res,
+ gpointer user_data)
+{
+ QueryRequest *request = user_data;
+ GInputStream *istream;
+ GError *error = NULL;
+
+ istream = tracker_sparql_statement_serialize_finish (TRACKER_SPARQL_STATEMENT (object),
+ res, &error);
+ if (!istream) {
+ g_dbus_method_invocation_return_gerror (request->invocation, error);
+ g_error_free (error);
+ query_request_free (request);
+ return;
+ }
+
+ g_dbus_method_invocation_return_value (request->invocation, NULL);
+ g_output_stream_splice_async (G_OUTPUT_STREAM (request->data_stream),
+ istream,
+ G_OUTPUT_STREAM_SPLICE_CLOSE_SOURCE |
+ G_OUTPUT_STREAM_SPLICE_CLOSE_TARGET,
+ G_PRIORITY_DEFAULT,
+ request->global_cancellable,
+ splice_rdf_cb,
+ request);
+}
+
static void
serialize_cb (GObject *object,
GAsyncResult *res,
@@ -790,7 +819,6 @@ endpoint_dbus_iface_method_call (GDBusConnection *connection,
return;
}
- /* FIXME: arguments is currently unused */
g_variant_get (parameters, "(shia{sv})", &query, &handle, &format, &arguments);
if (fd_list)
@@ -808,12 +836,34 @@ endpoint_dbus_iface_method_call (GDBusConnection *connection,
query);
request = query_request_new (endpoint_dbus, invocation, fd);
- tracker_sparql_connection_serialize_async (conn,
- format,
- query,
- request->cancellable,
- serialize_cb,
- request);
+
+ if (arguments) {
+ TrackerSparqlStatement *stmt;
+
+ stmt = create_statement (conn, query, arguments,
+ request->cancellable,
+ &error);
+ if (stmt) {
+ tracker_sparql_statement_serialize_async (stmt,
+ format,
+ request->cancellable,
+ stmt_serialize_cb,
+ request);
+ /* Statements are single use here... */
+ g_object_unref (stmt);
+ } else {
+ query_request_free (request);
+ g_dbus_method_invocation_return_gerror (invocation,
+ error);
+ }
+ } else {
+ tracker_sparql_connection_serialize_async (conn,
+ format,
+ query,
+ request->cancellable,
+ serialize_cb,
+ request);
+ }
}
g_free (query);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]