[NetworkManager-fortisslvpn] properties: use nm_fortisslvpn_properties_validate()
- From: Lubomir Rintel <lkundrak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [NetworkManager-fortisslvpn] properties: use nm_fortisslvpn_properties_validate()
- Date: Wed, 20 Mar 2019 12:17:52 +0000 (UTC)
commit 3d146740156857e3cd2d88806511a5c9ab952875
Author: Lubomir Rintel <lkundrak v3 sk>
Date: Wed Mar 20 13:08:36 2019 +0100
properties: use nm_fortisslvpn_properties_validate()
The same property validation code as service uses.
Makefile.am | 4 +++-
properties/nm-fortisslvpn-editor.c | 31 +++++--------------------------
2 files changed, 8 insertions(+), 27 deletions(-)
---
diff --git a/Makefile.am b/Makefile.am
index 689c7c0..0bde080 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -124,7 +124,9 @@ editor_sources = \
properties/resources.c \
properties/resources.h \
properties/nm-fortisslvpn-editor.c \
- properties/nm-fortisslvpn-editor.h
+ properties/nm-fortisslvpn-editor.h \
+ shared/nm-fortissl-properties.c \
+ shared/nm-fortissl-properties.h
properties_cppflags = \
-DLOCALEDIR=\"$(datadir)/locale\" \
diff --git a/properties/nm-fortisslvpn-editor.c b/properties/nm-fortisslvpn-editor.c
index 3a344c8..efce2c6 100644
--- a/properties/nm-fortisslvpn-editor.c
+++ b/properties/nm-fortisslvpn-editor.c
@@ -22,6 +22,7 @@
#include "nm-default.h"
#include "nm-fortisslvpn-editor.h"
+#include "nm-fortissl-properties.h"
#include <netinet/in.h>
#include <arpa/inet.h>
@@ -53,26 +54,6 @@ G_DEFINE_TYPE_EXTENDED (FortisslvpnEditor, fortisslvpn_editor, G_TYPE_OBJECT, 0,
/*****************************************************************************/
-static gboolean
-check_validity (FortisslvpnEditor *self, GError **error)
-{
- FortisslvpnEditorPrivate *priv = FORTISSLVPN_EDITOR_GET_PRIVATE (self);
- GtkWidget *widget;
- const char *str;
-
- widget = GTK_WIDGET (gtk_builder_get_object (priv->builder, "gateway_entry"));
- str = gtk_entry_get_text (GTK_ENTRY (widget));
- if (!str || !strlen (str)) {
- g_set_error (error,
- NMV_EDITOR_PLUGIN_ERROR,
- NMV_EDITOR_PLUGIN_ERROR_INVALID_PROPERTY,
- NM_FORTISSLVPN_KEY_GATEWAY);
- return FALSE;
- }
-
- return TRUE;
-}
-
static void
stuff_changed_cb (GtkWidget *widget, gpointer user_data)
{
@@ -388,10 +369,6 @@ update_connection (NMVpnEditor *iface,
NMSettingVpn *s_vpn;
GtkWidget *widget;
const char *str;
- gboolean valid = FALSE;
-
- if (!check_validity (self, error))
- return FALSE;
s_vpn = NM_SETTING_VPN (nm_setting_vpn_new ());
g_object_set (s_vpn, NM_SETTING_VPN_SERVICE_TYPE, NM_DBUS_SERVICE_FORTISSLVPN, NULL);
@@ -441,10 +418,12 @@ update_connection (NMVpnEditor *iface,
/* Use OTP */
nm_setting_set_secret_flags (NM_SETTING (s_vpn), NM_FORTISSLVPN_KEY_OTP, priv->otp_flags, NULL);
+ if (!nm_fortisslvpn_properties_validate (s_vpn, error))
+ return FALSE;
+
nm_connection_add_setting (connection, NM_SETTING (s_vpn));
- valid = TRUE;
- return valid;
+ return TRUE;
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]