[tracker/wip/carlosg/serialize-api: 31/36] libtracker-sparql: Implement statement serialization in D-Bus connections




commit 05eeaf70062c58165283b6fca74014a2ba531a32
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Nov 27 14:31:31 2021 +0100

    libtracker-sparql: Implement statement serialization in D-Bus connections
    
    Delegate the serialization onto the endpoint, as it is done with the
    TrackerSparqlConnection counterpart.

 src/libtracker-sparql/bus/tracker-bus-statement.vala | 4 ++++
 src/libtracker-sparql/bus/tracker-bus.vala           | 8 ++++++--
 src/libtracker-sparql/tracker-sparql.vapi            | 1 +
 3 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-sparql/bus/tracker-bus-statement.vala 
b/src/libtracker-sparql/bus/tracker-bus-statement.vala
index 39af7c766..bafe75aaa 100644
--- a/src/libtracker-sparql/bus/tracker-bus-statement.vala
+++ b/src/libtracker-sparql/bus/tracker-bus-statement.vala
@@ -93,4 +93,8 @@ public class Tracker.Bus.Statement : Tracker.Sparql.Statement {
        public async override Sparql.Cursor execute_async (GLib.Cancellable? cancellable) throws 
Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError {
                return yield Tracker.Bus.Connection.perform_query_call (bus, dbus_name, object_path, query, 
get_arguments (), cancellable);
        }
+
+       public async override GLib.InputStream serialize_async (RdfFormat format, GLib.Cancellable? 
cancellable) throws Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError {
+               return yield Tracker.Bus.Connection.perform_serialize (bus, dbus_name, object_path, format, 
query, get_arguments (), cancellable);
+       }
 }
diff --git a/src/libtracker-sparql/bus/tracker-bus.vala b/src/libtracker-sparql/bus/tracker-bus.vala
index 05db6b7a9..c2b9354fb 100644
--- a/src/libtracker-sparql/bus/tracker-bus.vala
+++ b/src/libtracker-sparql/bus/tracker-bus.vala
@@ -392,14 +392,14 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
                return batch;
        }
 
-       public async override GLib.InputStream serialize_async (RdfFormat format, string sparql, 
GLib.Cancellable? cancellable = null) throws Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError {
+       public static async GLib.InputStream perform_serialize (DBusConnection bus, string dbus_name, string 
object_path, RdfFormat format, string sparql, VariantBuilder? arguments, Cancellable? cancellable) throws 
GLib.IOError, GLib.Error {
                UnixInputStream input;
                UnixOutputStream output;
                pipe (out input, out output);
 
                var message = new DBusMessage.method_call (dbus_name, object_path, ENDPOINT_IFACE, 
"Serialize");
                var fd_list = new UnixFDList ();
-               message.set_body (new Variant ("(shia{sv})", sparql, fd_list.append (output.fd), format, 
null));
+               message.set_body (new Variant ("(shia{sv})", sparql, fd_list.append (output.fd), format, 
arguments));
                message.set_unix_fd_list (fd_list);
 
                var reply = yield bus.send_message_with_reply (message, DBusSendMessageFlags.NONE, int.MAX, 
null, cancellable);
@@ -407,4 +407,8 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
 
                return input;
        }
+
+       public async override GLib.InputStream serialize_async (RdfFormat format, string sparql, 
GLib.Cancellable? cancellable = null) throws Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError {
+               return yield perform_serialize (bus, dbus_name, object_path, format, sparql, null, 
cancellable);
+       }
 }
diff --git a/src/libtracker-sparql/tracker-sparql.vapi b/src/libtracker-sparql/tracker-sparql.vapi
index 79252618a..ef759e23f 100644
--- a/src/libtracker-sparql/tracker-sparql.vapi
+++ b/src/libtracker-sparql/tracker-sparql.vapi
@@ -125,6 +125,7 @@ namespace Tracker {
 
                public abstract Cursor execute (GLib.Cancellable? cancellable) throws Sparql.Error, 
GLib.Error, GLib.IOError, GLib.DBusError;
                public async abstract Cursor execute_async (GLib.Cancellable? cancellable) throws 
Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError;
+               public async abstract GLib.InputStream serialize_async (RdfFormat format, GLib.Cancellable? 
cancellable) throws Sparql.Error, GLib.Error, GLib.IOError, GLib.DBusError;
        }
 
        [CCode (cheader_filename = "libtracker-sparql/tracker-sparql.h")]


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