[gnome-shell/wip/fmuellner/libnm-plugin-loading: 63/63] networkAgent: Use libnm for plugin loading
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/fmuellner/libnm-plugin-loading: 63/63] networkAgent: Use libnm for plugin loading
- Date: Fri, 13 Apr 2018 14:05:39 +0000 (UTC)
commit 71515a8a11897f49191162e98aac2ee7414065a0
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Nov 3 15:25:49 2016 +0100
networkAgent: Use libnm for plugin loading
After the networking code has been ported to libnm, we can use its
API for loading VPN plugins instead of rolling our own ...
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/39
js/ui/components/networkAgent.js | 68 ++++++++++++----------------------------
1 file changed, 20 insertions(+), 48 deletions(-)
---
diff --git a/js/ui/components/networkAgent.js b/js/ui/components/networkAgent.js
index c51e53eba..75f420373 100644
--- a/js/ui/components/networkAgent.js
+++ b/js/ui/components/networkAgent.js
@@ -765,57 +765,29 @@ var NetworkAgent = new Lang.Class({
this._vpnCacheBuilt = true;
this._vpnBinaries = { };
- try {
- let fileEnum = this._pluginDir.enumerate_children('standard::name', Gio.FileQueryInfoFlags.NONE,
null);
- let info;
+ NM.VpnPluginInfo.list_load().forEach(plugin => {
+ let service = plugin.get_service();
+ let fileName = plugin.get_auth_dialog();
+ let supportsHints = plugin.supports_hints();
+ let externalUIMode = false;
+
+ let prop = plugin.lookup_property('GNOME', 'supports-external-ui-mode');
+ if (prop) {
+ prop = prop.trim().toLowerCase();
+ externalUIMode = ['true', 'yes', 'on', '1'].includes(prop);
+ }
- while ((info = fileEnum.next_file(null))) {
- let name = info.get_name();
- if (name.substr(-5) != '.name')
- continue;
+ if (GLib.file_test(fileName, GLib.FileTest.IS_EXECUTABLE)) {
+ let binary = { fileName, externalUIMode, supportsHints };
+ this._vpnBinaries[service] = binary;
- try {
- let keyfile = new GLib.KeyFile();
- keyfile.load_from_file(this._pluginDir.get_child(name).get_path(),
GLib.KeyFileFlags.NONE);
- let service = keyfile.get_string('VPN Connection', 'service');
- let binary = keyfile.get_string('GNOME', 'auth-dialog');
- let externalUIMode = false;
- let hints = false;
-
- try {
- externalUIMode = keyfile.get_boolean('GNOME', 'supports-external-ui-mode');
- } catch(e) { } // ignore errors if key does not exist
-
- try {
- hints = keyfile.get_boolean('GNOME', 'supports-hints');
- } catch(e) { } // ignore errors if key does not exist
-
- let path = binary;
- if (!GLib.path_is_absolute(path)) {
- path = GLib.build_filenamev([Config.LIBEXECDIR, path]);
- }
-
- if (GLib.file_test(path, GLib.FileTest.IS_EXECUTABLE)) {
- this._vpnBinaries[service] = { fileName: path, externalUIMode: externalUIMode,
supportsHints: hints };
- try {
- let aliases = keyfile.get_string_list('VPN Connection', 'aliases');
-
- for (let alias of aliases) {
- this._vpnBinaries[alias] = { fileName: path, externalUIMode: externalUIMode,
supportsHints: hints };
- }
- } catch(e) { } // ignore errors if key does not exist
- } else {
- throw new Error('VPN plugin at %s is not executable'.format(path));
- }
- } catch(e) {
- log('Error \'%s\' while processing VPN keyfile \'%s\''.
- format(e.message, this._pluginDir.get_child(name).get_path()));
- continue;
- }
+ plugin.get_aliases().forEach(alias => {
+ this._vpnBinaries[alias] = binary;
+ });
+ } else {
+ log('VPN plugin at %s is not executable'.format(fileName));
}
- } catch(e) {
- logError(e, 'error while enumerating VPN auth helpers');
- }
+ });
}
});
var Component = NetworkAgent;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]