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



commit 83571447006ea99b280ae6ea6b5bebe42125010d
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 | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/libtracker-bus/tracker-bus.vala b/src/libtracker-bus/tracker-bus.vala
index 3c6ae18d6..2b8f8c001 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;
                        }
@@ -316,9 +319,19 @@ 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 {
+               this.close ();
                return true;
        }
 }


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