[tracker/wip/carlosg/bus-connection-methods: 2/4] libtracker-sparql: Refactor code in bus connection
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/bus-connection-methods: 2/4] libtracker-sparql: Refactor code in bus connection
- Date: Sun, 4 Apr 2021 11:55:07 +0000 (UTC)
commit 0dd0f50f311e79095c96ca747c3ea51eddf654f7
Author: Carlos Garnacho <carlosg gnome org>
Date: Wed Mar 24 12:14:07 2021 +0100
libtracker-sparql: Refactor code in bus connection
Make a static perform_update_array() method, used so far in
the update_array_async() implementation. This will be useful to
push updates from outside the TrackerBusConnection.
src/libtracker-sparql/bus/tracker-bus.vala | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/libtracker-sparql/bus/tracker-bus.vala b/src/libtracker-sparql/bus/tracker-bus.vala
index 6bd12a4ef..5ba41d4e3 100644
--- a/src/libtracker-sparql/bus/tracker-bus.vala
+++ b/src/libtracker-sparql/bus/tracker-bus.vala
@@ -194,7 +194,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
return new Bus.Statement (bus, dbus_name, object_path, sparql);
}
- void send_update (string method, UnixInputStream input, Cancellable? cancellable, AsyncReadyCallback?
callback) throws GLib.Error, GLib.IOError {
+ static void send_update (DBusConnection bus, string dbus_name, string object_path, string method,
UnixInputStream input, Cancellable? cancellable, AsyncReadyCallback? callback) throws GLib.Error,
GLib.IOError {
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)));
@@ -226,7 +226,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
// send D-Bus request
AsyncResult dbus_res = null;
bool sent_update = false;
- send_update ("Update", input, cancellable, (o, res) => {
+ send_update (bus, dbus_name, object_path, "Update", input, cancellable, (o, res) => {
dbus_res = res;
if (sent_update) {
update_async.callback ();
@@ -250,7 +250,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
handle_error_reply (reply);
}
- public async override bool update_array_async (string[] sparql, Cancellable? cancellable = null)
throws Sparql.Error, GLib.Error, GLib.IOError, DBusError {
+ public static async bool perform_update_array (DBusConnection bus, string dbus_name, string
object_path, string[] sparql, Cancellable? cancellable) throws GLib.IOError, GLib.Error {
UnixInputStream input;
UnixOutputStream output;
pipe (out input, out output);
@@ -258,10 +258,10 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
// send D-Bus request
AsyncResult dbus_res = null;
bool sent_update = false;
- send_update ("UpdateArray", input, cancellable, (o, res) => {
+ send_update (bus, dbus_name, object_path, "UpdateArray", input, cancellable, (o, res) => {
dbus_res = res;
if (sent_update) {
- update_array_async.callback ();
+ perform_update_array.callback ();
}
});
@@ -287,6 +287,10 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
return true;
}
+ public async override bool update_array_async (string[] sparql, Cancellable? cancellable = null)
throws Sparql.Error, GLib.Error, GLib.IOError, DBusError {
+ return yield perform_update_array (bus, dbus_name, object_path, sparql, cancellable);
+ }
+
public override GLib.Variant? update_blank (string sparql, Cancellable? cancellable = null) throws
Sparql.Error, GLib.Error, GLib.IOError, DBusError {
// use separate main context for sync operation
var context = new MainContext ();
@@ -310,7 +314,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
// send D-Bus request
AsyncResult dbus_res = null;
bool sent_update = false;
- send_update ("UpdateBlank", input, cancellable, (o, res) => {
+ send_update (bus, dbus_name, object_path, "UpdateBlank", input, cancellable, (o, res) => {
dbus_res = res;
if (sent_update) {
update_blank_async.callback ();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]