[network-manager-applet/th/validation-error-bgo754832: 9/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: 9/13] fixup! c-e: forward the validation error to print more sensible error message to stdout
- Date: Fri, 11 Sep 2015 08:22:08 +0000 (UTC)
commit 8a501724a298c124b723982fa09125d46455bac5
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 | 14 ++++++++++++--
src/connection-editor/ce-page.h | 4 +++-
src/connection-editor/page-ethernet.c | 6 ++----
src/connection-editor/page-infiniband.c | 6 ++----
src/connection-editor/page-wifi.c | 6 ++----
5 files changed, 21 insertions(+), 15 deletions(-)
---
diff --git a/src/connection-editor/ce-page.c b/src/connection-editor/ce-page.c
index 05ae043..4818be9 100644
--- a/src/connection-editor/ce-page.c
+++ b/src/connection-editor/ce-page.c
@@ -395,16 +395,19 @@ ce_page_setup_device_combo (CEPage *self,
}
gboolean
-ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac)
+ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac, const char *device_name,
GError **error)
{
char *first, *second;
const char *ifname_tmp = NULL, *mac_tmp = NULL;
gboolean valid = TRUE;
+ const char *str;
g_return_val_if_fail (entry != NULL, FALSE);
g_return_val_if_fail (GTK_IS_ENTRY (entry), FALSE);
- valid = _device_entry_parse (gtk_entry_get_text (entry), &first, &second);
+ str = gtk_entry_get_text (entry);
+
+ valid = _device_entry_parse (str, &first, &second);
if (first) {
if (nm_utils_hwaddr_valid (first, nm_utils_hwaddr_len (type)))
@@ -437,6 +440,13 @@ ce_page_device_entry_get (GtkEntry *entry, int type, char **ifname, char **mac)
g_free (first);
g_free (second);
+ if (!valid) {
+ g_set_error (error, NMA_ERROR, NMA_ERROR_GENERIC,
+ _("invalid %s (%s)"),
+ device_name ? device_name : _("device"),
+ str);
+ }
+
return valid;
}
diff --git a/src/connection-editor/ce-page.h b/src/connection-editor/ce-page.h
index f927e1c..8857ef2 100644
--- a/src/connection-editor/ce-page.h
+++ b/src/connection-editor/ce-page.h
@@ -116,7 +116,9 @@ void ce_page_setup_device_combo (CEPage *self,
gboolean ifname_first);
gboolean ce_page_mac_entry_valid (GtkEntry *entry, int type, const char *property_name, GError **error);
gboolean ce_page_device_entry_get (GtkEntry *entry, int type,
- char **ifname, char **mac);
+ char **ifname, char **mac,
+ const char *device_name,
+ GError **error);
void ce_page_changed (CEPage *self);
diff --git a/src/connection-editor/page-ethernet.c b/src/connection-editor/page-ethernet.c
index 750f4f3..d52e00c 100644
--- a/src/connection-editor/page-ethernet.c
+++ b/src/connection-editor/page-ethernet.c
@@ -304,7 +304,7 @@ ui_to_setting (CEPageEthernet *self)
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry)
- ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac);
+ ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac, NULL, NULL);
cloned_mac = gtk_entry_get_text (priv->cloned_mac);
g_object_set (s_con,
@@ -333,10 +333,8 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry) {
- if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL)) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("input: invalid device"));
+ if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL, _("Ethernet
device"), error))
return FALSE;
- }
}
if (!ce_page_mac_entry_valid (priv->cloned_mac, ARPHRD_ETHER, _("cloned MAC"), error))
diff --git a/src/connection-editor/page-infiniband.c b/src/connection-editor/page-infiniband.c
index 4d2479a..09c9b8f 100644
--- a/src/connection-editor/page-infiniband.c
+++ b/src/connection-editor/page-infiniband.c
@@ -190,7 +190,7 @@ ui_to_setting (CEPageInfiniband *self)
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry)
- ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, &ifname, &device_mac);
+ ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, &ifname, &device_mac, NULL,
NULL);
g_object_set (s_con,
NM_SETTING_CONNECTION_INTERFACE_NAME, ifname,
@@ -214,10 +214,8 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry) {
- if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, NULL, NULL)) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid infiniband
device"));
+ if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_INFINIBAND, NULL, NULL,
_("infiniband device"), error))
return FALSE;
- }
}
ui_to_setting (self);
diff --git a/src/connection-editor/page-wifi.c b/src/connection-editor/page-wifi.c
index faa2f15..b0455ff 100644
--- a/src/connection-editor/page-wifi.c
+++ b/src/connection-editor/page-wifi.c
@@ -529,7 +529,7 @@ ui_to_setting (CEPageWifi *self)
bssid = gtk_entry_get_text (GTK_ENTRY (entry));
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry)
- ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac);
+ ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, &ifname, &device_mac, NULL, NULL);
cloned_mac = gtk_entry_get_text (priv->cloned_mac);
g_object_set (s_con,
@@ -569,10 +569,8 @@ ce_page_validate_v (CEPage *page, NMConnection *connection, GError **error)
entry = gtk_bin_get_child (GTK_BIN (priv->device_combo));
if (entry) {
- if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL)) {
- g_set_error_literal (error, NMA_ERROR, NMA_ERROR_GENERIC, _("invalid device"));
+ if (!ce_page_device_entry_get (GTK_ENTRY (entry), ARPHRD_ETHER, NULL, NULL, _("Wi-Fi
device"), error))
return FALSE;
- }
}
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]