[network-manager-applet/th/validation-error-bgo754832: 10/13] fixup! c-e: forward the validation error to print more sensible error message to stdout
- From: Thomas Haller <thaller src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [network-manager-applet/th/validation-error-bgo754832: 10/13] fixup! c-e: forward the validation error to print more sensible error message to stdout
- Date: Fri, 11 Sep 2015 12:14:55 +0000 (UTC)
commit edf22ca69c8e82a9bd1ca4ef08111e27fb771941
Author: Thomas Haller <thaller redhat com>
Date: Fri Sep 11 09:19:55 2015 +0200
fixup! c-e: forward the validation error to print more sensible error message to stdout
src/connection-editor/ce-page.c | 21 ++++++++++++++++++++-
src/connection-editor/ce-page.h | 1 +
src/connection-editor/page-bond.c | 7 ++-----
src/connection-editor/page-vlan.c | 9 +++------
4 files changed, 26 insertions(+), 12 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 4818be9..2a2cf51 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -219,7 +219,6 @@ ce_page_mac_entry_valid (GtkEntry *entry, int type, const char *property_name, G
{
const char *mac;
- g_return_val_if_fail (entry != NULL, FALSE);
g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
mac = gtk_entry_get_text (entry);
@@ -243,6 +242,26 @@ ce_page_mac_entry_valid (GtkEntry *entry, int type, const char *property_name, G
return TRUE;
}
+gboolean
+ce_page_interface_name_valid (const char *iface, const char *property_name, GError **error)
+{
+ if (iface && *iface) {
+ if (!nm_utils_iface_valid_name (iface)) {
+ if (property_name) {
+ g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC,
+ _("invalid interface-name for %s (%s)"),
+ property_name, iface);
+ } else {
+ g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC,
+ _("invalid interface-name (%s)"),
+ iface);
+ }
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
static char **
_get_device_list (CEPage *self,
GType device_type,
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index 8857ef2..2c11514 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -115,6 +115,7 @@ void ce_page_setup_device_combo (CEPage *self,
const char *mac_property,
gboolean ifname_first);
gboolean ce_page_mac_entry_valid (GtkEntry *entry, int type, const char *property_name, GError **error);
+gboolean ce_page_interface_name_valid (const char *iface, const char *property_name, GError **error);
gboolean ce_page_device_entry_get (GtkEntry *entry, int type,
char **ifname, char **mac,
const char *device_name,
diff --git a/src/connection-editor/page-bond.c b/src/connection-editor/page-bond.c
index 3def2a7..9d3b789 100644
--- a/src/connection-editor/page-bond.c
+++ b/src/connection-editor/page-bond.c
@@ -558,16 +558,13 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
{
CEPageBond *self = CE_PAGE_BOND (page);
CEPageBondPrivate *priv = CE_PAGE_BOND_GET_PRIVATE (self);
- const char *primary;
if (!CE_PAGE_CLASS (ce_page_bond_parent_class)->ce_page_validate_v (page, connection, error))
return FALSE;
- primary = gtk_entry_get_text (priv->primary);
- if (primary && *primary && !nm_utils_iface_valid_name (primary)) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid primary (not a valid
ifname)"));
+ if (!ce_page_interface_name_valid (gtk_entry_get_text (priv->primary),
+ _("primary"), error))
return FALSE;
- }
ui_to_setting (self);
return nm_setting_verify (NM_SETTING (priv->setting), connection, error);
diff --git a/src/connection-editor/page-vlan.c b/src/connection-editor/page-vlan.c
index d051b15..5df091c 100644
--- a/src/connection-editor/page-vlan.c
+++ b/src/connection-editor/page-vlan.c
@@ -722,16 +722,13 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
char *parent_iface;
if (gtk_combo_box_get_active (GTK_COMBO_BOX (priv->parent)) == -1) {
- gboolean valid;
-
parent = gtk_entry_get_text (priv->parent_entry);
parent_iface = g_strndup (parent, strcspn (parent, " "));
- valid = nm_utils_iface_valid_name (parent_iface);
- g_free (parent_iface);
- if (!valid) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid vlan parent
ifname"));
+ if (!ce_page_interface_name_valid (parent_iface, _("vlan parent"), error)) {
+ g_free (parent_iface);
return FALSE;
}
+ g_free (parent_iface);
}
if (!ce_page_mac_entry_valid (priv->cloned_mac, ARPHRD_ETHER, _("cloned MAC"), error))
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]