summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiří Klimeš <jklimes@redhat.com>2015-11-27 11:09:20 +0100
committerJiří Klimeš <jklimes@redhat.com>2015-12-12 17:37:30 +0100
commit6dd1e2673ece6e962f5bfc3065929963fa954c0c (patch)
tree3a63888339edabebbadfe548c7d6427aaf27c2c3
parentde86c23fbebd461d4264d39e3cc46594ad62c096 (diff)
downloadNetworkManager-6dd1e2673ece6e962f5bfc3065929963fa954c0c.tar.gz
clients: move vpn_get_secret_names() to nm-vpn-helpers
It should eventually move into libnm and ideally the data be obtained from VPN plugins. (No functional change, only moving the function).
-rw-r--r--clients/common/nm-secret-agent-simple.c50
-rw-r--r--clients/common/nm-vpn-helpers.c43
-rw-r--r--clients/common/nm-vpn-helpers.h7
-rw-r--r--clients/tui/Makefile.am2
4 files changed, 54 insertions, 48 deletions
diff --git a/clients/common/nm-secret-agent-simple.c b/clients/common/nm-secret-agent-simple.c
index 0fd61e21f6..6ef1078e7c 100644
--- a/clients/common/nm-secret-agent-simple.c
+++ b/clients/common/nm-secret-agent-simple.c
@@ -37,6 +37,7 @@
#include <nm-vpn-service-plugin.h>
#include "nm-default.h"
+#include "nm-vpn-helpers.h"
#include "nm-secret-agent-simple.h"
G_DEFINE_TYPE (NMSecretAgentSimple, nm_secret_agent_simple, NM_TYPE_SECRET_AGENT_OLD)
@@ -336,53 +337,6 @@ add_pppoe_secrets (NMSecretAgentSimpleRequest *request,
return TRUE;
}
-struct {
- const char *name;
- const char *ui_name;
-} typedef VpnPasswordName;
-
-static const VpnPasswordName *
-vpn_get_secret_names (const char *vpn_type)
-{
- const char *type;
- static VpnPasswordName generic_vpn_secrets[] = { {"password", N_("Password")}, {NULL, NULL} };
- static VpnPasswordName vpnc_secrets[] = { {"Xauth password", N_("Password")},
- {"IPSec secret", N_("Group password")},
- {NULL, NULL} };
- static VpnPasswordName swan_secrets[] = { {"xauthpassword", N_("Password")},
- {"pskvalue", N_("Group password")},
- {NULL, NULL} };
- static VpnPasswordName openconnect_secrets[] = { {"gateway", N_("Gateway")},
- {"cookie", N_("Cookie")},
- {"gwcert", N_("Gateway certificate hash")},
- {NULL, NULL} };
-
- if (!vpn_type)
- return NULL;
-
- if (g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE))
- type = vpn_type + strlen (NM_DBUS_INTERFACE) + 1;
- else
- type = vpn_type;
-
- if ( !g_strcmp0 (type, "openvpn")
- || !g_strcmp0 (type, "pptp")
- || !g_strcmp0 (type, "iodine")
- || !g_strcmp0 (type, "ssh")
- || !g_strcmp0 (type, "l2tp")
- || !g_strcmp0 (type, "fortisslvpn"))
- return generic_vpn_secrets;
- else if (!g_strcmp0 (type, "vpnc"))
- return vpnc_secrets;
- else if ( !g_strcmp0 (type, "openswan")
- || !g_strcmp0 (type, "libreswan")
- || !g_strcmp0 (type, "strongswan"))
- return swan_secrets;
- else if (!g_strcmp0 (type, "openconnect"))
- return openconnect_secrets;
- return NULL;
-}
-
static NMSettingSecretFlags
get_vpn_secret_flags (NMSettingVpn *s_vpn, const char *secret_name)
{
@@ -448,7 +402,7 @@ add_vpn_secrets (NMSecretAgentSimpleRequest *request,
*msg = g_strdup (tmp);
/* Now add what client thinks might be required, because hints may be empty or incomplete */
- p = secret_names = vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn));
+ p = secret_names = nm_vpn_get_secret_names (nm_setting_vpn_get_service_type (s_vpn));
while (p && p->name) {
add_vpn_secret_helper (secrets, s_vpn, p->name, _(p->ui_name));
p++;
diff --git a/clients/common/nm-vpn-helpers.c b/clients/common/nm-vpn-helpers.c
index 276df2b95c..e38af25a14 100644
--- a/clients/common/nm-vpn-helpers.c
+++ b/clients/common/nm-vpn-helpers.c
@@ -94,3 +94,46 @@ nm_vpn_supports_ipv6 (NMConnection *connection)
capabilities = nm_vpn_editor_plugin_get_capabilities (plugin);
return NM_FLAGS_HAS (capabilities, NM_VPN_EDITOR_PLUGIN_CAPABILITY_IPV6);
}
+
+const VpnPasswordName *
+nm_vpn_get_secret_names (const char *vpn_type)
+{
+ const char *type;
+ static VpnPasswordName generic_vpn_secrets[] = { {"password", N_("Password")}, {NULL, NULL} };
+ static VpnPasswordName vpnc_secrets[] = { {"Xauth password", N_("Password")},
+ {"IPSec secret", N_("Group password")},
+ {NULL, NULL} };
+ static VpnPasswordName swan_secrets[] = { {"xauthpassword", N_("Password")},
+ {"pskvalue", N_("Group password")},
+ {NULL, NULL} };
+ static VpnPasswordName openconnect_secrets[] = { {"gateway", N_("Gateway")},
+ {"cookie", N_("Cookie")},
+ {"gwcert", N_("Gateway certificate hash")},
+ {NULL, NULL} };
+
+ if (!vpn_type)
+ return NULL;
+
+ if (g_str_has_prefix (vpn_type, NM_DBUS_INTERFACE))
+ type = vpn_type + strlen (NM_DBUS_INTERFACE) + 1;
+ else
+ type = vpn_type;
+
+ if ( !g_strcmp0 (type, "openvpn")
+ || !g_strcmp0 (type, "pptp")
+ || !g_strcmp0 (type, "iodine")
+ || !g_strcmp0 (type, "ssh")
+ || !g_strcmp0 (type, "l2tp")
+ || !g_strcmp0 (type, "fortisslvpn"))
+ return generic_vpn_secrets;
+ else if (!g_strcmp0 (type, "vpnc"))
+ return vpnc_secrets;
+ else if ( !g_strcmp0 (type, "openswan")
+ || !g_strcmp0 (type, "libreswan")
+ || !g_strcmp0 (type, "strongswan"))
+ return swan_secrets;
+ else if (!g_strcmp0 (type, "openconnect"))
+ return openconnect_secrets;
+ return NULL;
+}
+
diff --git a/clients/common/nm-vpn-helpers.h b/clients/common/nm-vpn-helpers.h
index 9a2ff7b100..2ca2ecb828 100644
--- a/clients/common/nm-vpn-helpers.h
+++ b/clients/common/nm-vpn-helpers.h
@@ -23,10 +23,17 @@
#include "nm-default.h"
+struct {
+ const char *name;
+ const char *ui_name;
+} typedef VpnPasswordName;
+
GSList *nm_vpn_get_plugins (void);
NMVpnEditorPlugin *nm_vpn_get_plugin_by_service (const char *service, GError **error);
gboolean nm_vpn_supports_ipv6 (NMConnection *connection);
+const VpnPasswordName * nm_vpn_get_secret_names (const char *vpn_type);
+
#endif /* __NM_VPN_HELPERS_H__ */
diff --git a/clients/tui/Makefile.am b/clients/tui/Makefile.am
index f6d93be2b4..305f08b25d 100644
--- a/clients/tui/Makefile.am
+++ b/clients/tui/Makefile.am
@@ -116,6 +116,8 @@ nmtui_SOURCES = \
nmt-widget-list.h \
$(srcdir)/../common/nm-secret-agent-simple.c \
$(srcdir)/../common/nm-secret-agent-simple.h \
+ $(srcdir)/../common/nm-vpn-helpers.c \
+ $(srcdir)/../common/nm-vpn-helpers.h \
$(NULL)
nmtui_LDADD = \