mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-24 18:00:25 +01:00
clients: lookup VPN plugins either by "name" or "service"
... not constructing a "service" by prepending a D-Bus prefix to "name" (urgh).
(cherry picked from commit 0225c4567b)
This commit is contained in:
parent
981e5f6716
commit
be9e068654
3 changed files with 12 additions and 13 deletions
|
|
@ -10690,7 +10690,7 @@ do_connection_import (NmCli *nmc, gboolean temporary, int argc, char **argv)
|
|||
}
|
||||
|
||||
/* Import VPN configuration */
|
||||
plugin = nm_vpn_get_plugin_by_service (type, &error);
|
||||
plugin = nm_vpn_lookup_plugin (type, NULL, &error);
|
||||
if (!plugin) {
|
||||
g_string_printf (nmc->return_text, _("Error: failed to load VPN plugin: %s."),
|
||||
error->message);
|
||||
|
|
@ -10797,7 +10797,7 @@ do_connection_export (NmCli *nmc, int argc, char **argv)
|
|||
type = nm_setting_vpn_get_service_type (nm_connection_get_setting_vpn (connection));
|
||||
|
||||
/* Export VPN configuration */
|
||||
plugin = nm_vpn_get_plugin_by_service (type, &error);
|
||||
plugin = nm_vpn_lookup_plugin (type, NULL, &error);
|
||||
if (!plugin) {
|
||||
g_string_printf (nmc->return_text, _("Error: failed to load VPN plugin: %s."),
|
||||
error->message);
|
||||
|
|
|
|||
|
|
@ -36,30 +36,29 @@ static gboolean plugins_loaded;
|
|||
static GSList *plugins = NULL;
|
||||
|
||||
NMVpnEditorPlugin *
|
||||
nm_vpn_get_plugin_by_service (const char *service, GError **error)
|
||||
nm_vpn_lookup_plugin (const char *name, const char *service, GError **error)
|
||||
{
|
||||
NMVpnEditorPlugin *plugin = NULL;
|
||||
NMVpnPluginInfo *plugin_info;
|
||||
char *type = NULL;
|
||||
|
||||
g_return_val_if_fail (service != NULL, NULL);
|
||||
g_return_val_if_fail (!service ^ !name, NULL);
|
||||
g_return_val_if_fail (error == NULL || *error == NULL, NULL);
|
||||
|
||||
if (G_UNLIKELY (!plugins_loaded))
|
||||
nm_vpn_get_plugins ();
|
||||
|
||||
if (!g_str_has_prefix (service, NM_DBUS_INTERFACE))
|
||||
service = type = g_strdup_printf ("%s.%s", NM_DBUS_INTERFACE, service);
|
||||
if (service)
|
||||
plugin_info = nm_vpn_plugin_info_list_find_by_service (plugins, service);
|
||||
else
|
||||
plugin_info = nm_vpn_plugin_info_list_find_by_name (plugins, name);
|
||||
|
||||
plugin_info = nm_vpn_plugin_info_list_find_by_service (plugins, service);
|
||||
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
|
||||
g_set_error_literal (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED,
|
||||
_("could not get VPN plugin info"));
|
||||
g_free (type);
|
||||
g_set_error (error, NM_VPN_PLUGIN_ERROR, NM_VPN_PLUGIN_ERROR_FAILED,
|
||||
_("unknown VPN plugin \"%s\""), service ?: name);
|
||||
return plugin;
|
||||
}
|
||||
|
||||
|
|
@ -87,7 +86,7 @@ nm_vpn_supports_ipv6 (NMConnection *connection)
|
|||
service_type = nm_setting_vpn_get_service_type (s_vpn);
|
||||
g_return_val_if_fail (service_type != NULL, FALSE);
|
||||
|
||||
plugin = nm_vpn_get_plugin_by_service (service_type, NULL);
|
||||
plugin = nm_vpn_lookup_plugin (NULL, service_type, NULL);
|
||||
g_return_val_if_fail (plugin != NULL, FALSE);
|
||||
|
||||
capabilities = nm_vpn_editor_plugin_get_capabilities (plugin);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ struct {
|
|||
|
||||
GSList *nm_vpn_get_plugins (void);
|
||||
|
||||
NMVpnEditorPlugin *nm_vpn_get_plugin_by_service (const char *service, GError **error);
|
||||
NMVpnEditorPlugin *nm_vpn_lookup_plugin (const char *name, const char *service, GError **error);
|
||||
|
||||
gboolean nm_vpn_supports_ipv6 (NMConnection *connection);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue