summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-05-19 11:17:46 +0200
committerThomas Haller <thaller@redhat.com>2016-05-19 13:12:02 +0200
commit964baa0e3301617ed70b7d16145cb90d8a2f7f1f (patch)
tree21dcb517cf7b58f144cd8a10ab50b3ad53404755
parent7c209b2a7d84a1b7188d5e7aa9fb664bbb5c97aa (diff)
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. (cherry picked from commit d0f01aa2c26f7a3e34d80477ccc4989b1571a6d4)
-rw-r--r--clients/common/nm-vpn-helpers.c34
1 files changed, 29 insertions, 5 deletions
diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c
index 324f0aae32..8c7280558c 100644
--- a/clients/common/nm-vpn-helpers.c
+++ b/clients/common/nm-vpn-helpers.c
@@ -40,6 +40,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);
@@ -52,13 +53,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;
}