diff options
author | Thomas Haller <thaller@redhat.com> | 2016-05-19 11:17:46 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2016-05-19 12:52:59 +0200 |
commit | d0f01aa2c26f7a3e34d80477ccc4989b1571a6d4 (patch) | |
tree | 393d7d21843868e48f0ac3cf6fdc0fb19650e823 /clients | |
parent | 41976e30690d36cc3998c5025ac70c8cbaa8f897 (diff) | |
download | NetworkManager-d0f01aa2c26f7a3e34d80477ccc4989b1571a6d4.tar.gz |
clients,cli: show better error message when failing to load VPN plugin
VPN plugins are often not installed or they might be legacy-only.
In both cases we should show a better error message about the
failure reason.
Diffstat (limited to 'clients')
-rw-r--r-- | clients/common/nm-vpn-helpers.c | 34 |
1 files changed, 29 insertions, 5 deletions
diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c index 5b71c578ad..43ac4b2e61 100644 --- a/clients/common/nm-vpn-helpers.c +++ b/clients/common/nm-vpn-helpers.c @@ -39,6 +39,7 @@ nm_vpn_lookup_plugin (const char *name, const char *service, GError **error) { NMVpnEditorPlugin *plugin = NULL; NMVpnPluginInfo *plugin_info; + gs_free_error GError *local = NULL; g_return_val_if_fail (!service ^ !name, NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); @@ -51,13 +52,36 @@ nm_vpn_lookup_plugin (const char *name, const char *service, GError **error) else plugin_info = nm_vpn_plugin_info_list_find_by_name (plugins, name); - if (plugin_info) { - plugin = nm_vpn_plugin_info_get_editor_plugin (plugin_info); - if (!plugin) - plugin = nm_vpn_plugin_info_load_editor_plugin (plugin_info, error); - } else + if (!plugin_info) { g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, _("unknown VPN plugin \"%s\""), service ?: name); + return NULL; + } + plugin = nm_vpn_plugin_info_get_editor_plugin (plugin_info); + if (!plugin) + plugin = nm_vpn_plugin_info_load_editor_plugin (plugin_info, &local); + + if (!plugin) { + if ( !nm_vpn_plugin_info_get_plugin (plugin_info) + && nm_vpn_plugin_info_lookup_property (plugin_info, NM_VPN_PLUGIN_INFO_KF_GROUP_GNOME, "properties")) { + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("cannot cannot load legacy-only VPN plugin \"%s\" for \"%s\""), + nm_vpn_plugin_info_get_name (plugin_info), + nm_vpn_plugin_info_get_filename (plugin_info)); + } else if (g_error_matches (local, G_FILE_ERROR, G_FILE_ERROR_NOENT)) { + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("cannot load VPN plugin \"%s\" due to missing \"%s\". Missing client plugin?"), + nm_vpn_plugin_info_get_name (plugin_info), + nm_vpn_plugin_info_get_plugin (plugin_info)); + } else { + g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED, + _("failed to load VPN plugin \"%s\": %s"), + nm_vpn_plugin_info_get_name (plugin_info), + local->message); + } + return NULL; + } + return plugin; } |