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



commit 36c4d9b344f9d9623b11753a104c9a7f663fa2b3
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-sparql/bus/tracker-bus.vala | 13 +++++++++++++
 1 file changed, 13 insertions(+)
---
diff --git a/src/libtracker-sparql/bus/tracker-bus.vala b/src/libtracker-sparql/bus/tracker-bus.vala
index 13a6d9dec..fe16cd969 100644
--- a/src/libtracker-sparql/bus/tracker-bus.vala
+++ b/src/libtracker-sparql/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";
 
@@ -42,6 +43,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
@@ -73,6 +75,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;
                        }
@@ -324,9 +327,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]