From c209d1b3764c03affed4b4a6bc3cde2280179bd2 Mon Sep 17 00:00:00 2001 From: xSmurf Date: Sat, 23 Sep 2017 03:31:33 +0000 Subject: [PATCH] gnome-shell fixed handling of multiple prompt requests... --- gnome-shell/firewall@subgraph.com/dialog.js | 9 +++- .../firewall@subgraph.com/extension.js | 41 +++++++++++-------- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/gnome-shell/firewall@subgraph.com/dialog.js b/gnome-shell/firewall@subgraph.com/dialog.js index ff20d48..87b2728 100644 --- a/gnome-shell/firewall@subgraph.com/dialog.js +++ b/gnome-shell/firewall@subgraph.com/dialog.js @@ -458,7 +458,8 @@ const PromptDialog = new Lang.Class({ Name: 'PromptDialog', Extends: ModalDialog.ModalDialog, - _init: function(invocation, pid_known, sandboxed, tlsguard) { + _init: function(invocation, pid_known, sandboxed, tlsguard, cbClose) { + this.cbClose = cbClose; this.parent({ styleClass: 'fw-prompt-dialog' }); this._invocation = invocation; this.header = new PromptDialogHeader(); @@ -491,11 +492,17 @@ const PromptDialog = new Lang.Class({ }, onAllow: function() { + if (this.cbClose !== undefined && this.cbClose !== null) { + this.cbClose(); + } this.close(); this.sendReturnValue(true); }, onDeny: function() { + if (this.cbClose !== undefined && this.cbClose !== null) { + this.cbClose(); + } this.close(); this.sendReturnValue(false); }, diff --git a/gnome-shell/firewall@subgraph.com/extension.js b/gnome-shell/firewall@subgraph.com/extension.js index ba6d822..3192e60 100644 --- a/gnome-shell/firewall@subgraph.com/extension.js +++ b/gnome-shell/firewall@subgraph.com/extension.js @@ -78,39 +78,48 @@ const FirewallPromptHandler = new Lang.Class({ this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(FirewallPromptInterface, this); this._dbusImpl.export(Gio.DBus.system, '/com/subgraph/FirewallPrompt'); Gio.bus_own_name_on_connection(Gio.DBus.system, 'com.subgraph.FirewallPrompt', Gio.BusNameOwnerFlags.REPLACE, null, null); - this._dialog = null; + this._dialogs = new Array(); }, destroy: function() { - this._closeDialog(); + this._closeDialogs(); this._dbusImpl.unexport(); }, - _closeDialog: function() { - if (this._dialog) { - this._dialog.close(); - this._dialog = null; + _closeDialogs: function() { + if (this._dialogs.length > 0) { + dialog = this._dialogs.shift(); + dialog.close(); } }, RequestPromptAsync: function(params, invocation) { let [app, icon, path, address, port, ip, origin, proto, uid, gid, user, group, pid, sandbox, tlsguard, optstring, expanded, expert, action] = params; -// this._closeDialog(); - this._dialog = new Dialog.PromptDialog(invocation, (pid >= 0), (sandbox != ""), tlsguard); - this._invocation = invocation; - this._dialog.update(app, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action); - this._dialog.open(); + let cbfn = function(self) { + return function() { return self.onCloseDialog(); } + }(this) + + let l = this._dialogs.push(new Dialog.PromptDialog(invocation, (pid >= 0), (sandbox != ""), tlsguard, cbfn)); + let dialog = this._dialogs[l-1] + dialog.update(app, icon, path, address, port, ip, origin, uid, gid, user, group, pid, proto, tlsguard, optstring, sandbox, expanded, expert, action); + if (this._dialogs.length == 1) { + dialog.open(); + } + }, + + onCloseDialog: function() { + this._dialogs.shift(); + if (this._dialogs.length > 0) { + this._dialogs[0].open(); + } }, CloseAsync: function(params, invocation) { - this._closeDialog(); + this._closeDialogs(); }, TestPrompt: function(params, invocation) { - this._closeDialog(); - this._dialog = new Dialog.PromptDialog(nil); - this._dialog.update("Firefox", "firefox", "/usr/bin/firefox-esr", "242.12.111.18", "443", "linux", "2342", "TCP", true, true); - this._dialog.open(); + this.RequestPromptAsync(["Firefox", "firefox", "/usr/bin/firefox-esr", "242.12.111.18", "443", "linux", "2342", "TCP", true, true], nil); } });