[tracker/wip/carlosg/portal: 136/141] libtracker-bus: Explicitly close sandbox sessions on connection close



commit c54b898ba8b19c601f597f7f5b0982944d7d87ad
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jan 24 16:01:54 2020 +0100

    libtracker-bus: Explicitly close sandbox sessions on connection close

 src/libtracker-bus/tracker-bus.vala | 12 ++++++++++++
 1 file changed, 12 insertions(+)
---
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 445b955bf..51e1d8b0a 100644
--- a/src/libtracker-bus/tracker-bus.vala
+++ b/src/libtracker-bus/tracker-bus.vala
@@ -21,6 +21,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
        DBusConnection bus;
        string dbus_name;
        string object_path;
+       bool sandboxed;
 
        private const string DBUS_PEER_IFACE = "org.freedesktop.DBus.Peer";
 
@@ -34,6 +35,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
 
        public Connection (string dbus_name, string object_path, DBusConnection? dbus_connection) throws 
Sparql.Error, IOError, DBusError, GLib.Error {
                Object ();
+               this.sandboxed = false;
                this.bus = dbus_connection;
 
                // ensure that error domain is registered with GDBus
@@ -65,6 +67,7 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
 
                                this.dbus_name = PORTAL_NAME;
                                this.object_path = object_path;
+                               this.sandboxed = true;
                        } else {
                                throw e;
                        }
@@ -308,6 +311,15 @@ public class Tracker.Bus.Connection : Tracker.Sparql.Connection {
        }
 
        public override void close () {
+               if (this.sandboxed) {
+                       var message = new DBusMessage.method_call (PORTAL_NAME, PORTAL_PATH, PORTAL_IFACE, 
"CloseSession");
+                       message.set_body (new Variant ("(o)", this.object_path));
+
+                       try {
+                               this.bus.send_message (message, 0, null);
+                       } catch (GLib.Error e) {
+                       }
+               }
        }
 
        public async override bool close_async () throws GLib.IOError {


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