networkAgent: Make searching VPN binaries asynchronous
Doing blocking IO in a graphical UI is bad, doing it in the compositor is much much worse. So even if handling VPN requests is a relatively rare event, doing it asynchronously is better. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2386
This commit is contained in:
parent
c5dd9a9341
commit
0a50b6ea01
@ -4,13 +4,15 @@
|
|||||||
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
|
const { Clutter, Gio, GLib, GObject, NM, Pango, Shell, St } = imports.gi;
|
||||||
const Signals = imports.signals;
|
const Signals = imports.signals;
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
|
||||||
const Dialog = imports.ui.dialog;
|
const Dialog = imports.ui.dialog;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const MessageTray = imports.ui.messageTray;
|
const MessageTray = imports.ui.messageTray;
|
||||||
const ModalDialog = imports.ui.modalDialog;
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
const ShellEntry = imports.ui.shellEntry;
|
const ShellEntry = imports.ui.shellEntry;
|
||||||
|
|
||||||
|
Gio._promisify(Shell.NetworkAgent.prototype,
|
||||||
|
'search_vpn_plugin', 'search_vpn_plugin_finish');
|
||||||
|
|
||||||
const VPN_UI_GROUP = 'VPN Plugin UI';
|
const VPN_UI_GROUP = 'VPN Plugin UI';
|
||||||
|
|
||||||
var NetworkSecretDialog = GObject.registerClass(
|
var NetworkSecretDialog = GObject.registerClass(
|
||||||
@ -761,11 +763,11 @@ var NetworkAgent = class {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_vpnRequest(requestId, connection, hints, flags) {
|
async _vpnRequest(requestId, connection, hints, flags) {
|
||||||
let vpnSetting = connection.get_setting_vpn();
|
let vpnSetting = connection.get_setting_vpn();
|
||||||
let serviceType = vpnSetting.service_type;
|
let serviceType = vpnSetting.service_type;
|
||||||
|
|
||||||
let binary = this._findAuthBinary(serviceType);
|
let binary = await this._findAuthBinary(serviceType);
|
||||||
if (!binary) {
|
if (!binary) {
|
||||||
log('Invalid VPN service type (cannot find authentication binary)');
|
log('Invalid VPN service type (cannot find authentication binary)');
|
||||||
|
|
||||||
@ -781,11 +783,15 @@ var NetworkAgent = class {
|
|||||||
this._vpnRequests[requestId] = vpnRequest;
|
this._vpnRequests[requestId] = vpnRequest;
|
||||||
}
|
}
|
||||||
|
|
||||||
_findAuthBinary(serviceType) {
|
async _findAuthBinary(serviceType) {
|
||||||
const plugin = NM.VpnPluginInfo.new_search_file(null, serviceType);
|
let plugin;
|
||||||
|
|
||||||
if (plugin === null)
|
try {
|
||||||
|
plugin = await this._native.search_vpn_plugin(serviceType);
|
||||||
|
} catch (e) {
|
||||||
|
logError(e);
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const fileName = plugin.get_auth_dialog();
|
const fileName = plugin.get_auth_dialog();
|
||||||
if (!GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
|
if (!GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user