summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2016-11-03 15:25:49 +0100
committerFlorian Müllner <fmuellner@gnome.org>2018-02-21 19:01:38 +0100
commit6b76d2821ab1ac99b555806919e76219592ec473 (patch)
tree8c77ae7a5247c4299faff97996432fc501dc9662
parent6f280547cb774a71a3fd2a2841bb81ed1b942efc (diff)
downloadgnome-shell-wip/fmuellner/libnm-plugin-loading.tar.gz
networkAgent: Use libnm for plugin loadingwip/fmuellner/libnm-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
-rw-r--r--js/ui/components/networkAgent.js68
1 files 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;