network: Make broken configuration entries red
When a configuration setting is wrong, set the entry or file chooser that contains the incorrect information to be surrounded by red. This makes it easier for users to find where the error was made that disallows them to click the "Apply" button. https://bugzilla.gnome.org/show_bug.cgi?id=734446
This commit is contained in:
parent
d107518404
commit
62db29b387
16 changed files with 202 additions and 25 deletions
|
@ -31,7 +31,9 @@ libconnection_editor_la_SOURCES = \
|
|||
vpn-helpers.h \
|
||||
vpn-helpers.c \
|
||||
firewall-helpers.h \
|
||||
firewall-helpers.c
|
||||
firewall-helpers.c \
|
||||
ui-helpers.h \
|
||||
ui-helpers.c
|
||||
|
||||
libconnection_editor_la_CPPFLAGS = \
|
||||
$(PANEL_CFLAGS) \
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "firewall-helpers.h"
|
||||
#include "ce-page-ethernet.h"
|
||||
#include "ui-helpers.h"
|
||||
|
||||
G_DEFINE_TYPE (CEPageEthernet, ce_page_ethernet, CE_TYPE_PAGE)
|
||||
|
||||
|
@ -167,17 +168,23 @@ validate (CEPage *page,
|
|||
entry = gtk_bin_get_child (GTK_BIN (self->device_mac));
|
||||
if (entry) {
|
||||
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
|
||||
if (invalid)
|
||||
if (invalid) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
if (ignore)
|
||||
g_byte_array_free (ignore, TRUE);
|
||||
widget_unset_error (entry);
|
||||
}
|
||||
|
||||
ignore = ce_page_entry_to_mac (self->cloned_mac, ARPHRD_ETHER, &invalid);
|
||||
if (invalid)
|
||||
if (invalid) {
|
||||
widget_set_error (GTK_WIDGET (self->cloned_mac));
|
||||
return FALSE;
|
||||
}
|
||||
if (ignore)
|
||||
g_byte_array_free (ignore, TRUE);
|
||||
widget_unset_error (GTK_WIDGET (self->cloned_mac));
|
||||
|
||||
ui_to_setting (self);
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "shell/list-box-helper.h"
|
||||
#include "ce-page-ip4.h"
|
||||
#include "ui-helpers.h"
|
||||
#include <nm-utils.h>
|
||||
|
||||
G_DEFINE_TYPE (CEPageIP4, ce_page_ip4, CE_TYPE_PAGE)
|
||||
|
@ -726,21 +727,29 @@ ui_to_setting (CEPageIP4 *page)
|
|||
|
||||
if (!*text_address && !*text_netmask && !*text_gateway) {
|
||||
/* ignore empty rows */
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "network"));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inet_pton (AF_INET, text_address, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
if (!parse_netmask (text_netmask, &prefix)) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "network"));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "network"));
|
||||
|
||||
if (text_gateway && *text_gateway && inet_pton (AF_INET, text_gateway, &tmp_gateway) <= 0) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
|
||||
addr = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 3);
|
||||
g_array_append_val (addr, tmp_addr.s_addr);
|
||||
|
@ -773,12 +782,15 @@ ui_to_setting (CEPageIP4 *page)
|
|||
text = gtk_entry_get_text (entry);
|
||||
if (!*text) {
|
||||
/* ignore empty rows */
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inet_pton (AF_INET, text, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
g_array_append_val (dns_servers, tmp_addr.s_addr);
|
||||
}
|
||||
|
@ -813,17 +825,24 @@ ui_to_setting (CEPageIP4 *page)
|
|||
}
|
||||
|
||||
if (inet_pton (AF_INET, text_address, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
address = tmp_addr.s_addr;
|
||||
|
||||
if (!parse_netmask (text_netmask, &netmask)) {
|
||||
widget_set_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "netmask")));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "netmask")));
|
||||
|
||||
if (inet_pton (AF_INET, text_gateway, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway")));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "gateway")));
|
||||
gateway = tmp_addr.s_addr;
|
||||
|
||||
metric = 0;
|
||||
|
@ -831,9 +850,11 @@ ui_to_setting (CEPageIP4 *page)
|
|||
errno = 0;
|
||||
metric = strtoul (text_metric, NULL, 10);
|
||||
if (errno) {
|
||||
widget_set_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "metric")));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (g_object_get_data (G_OBJECT (row), "metric")));
|
||||
|
||||
route = g_array_sized_new (FALSE, TRUE, sizeof (guint32), 4);
|
||||
g_array_append_val (route, address);
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
#include "shell/list-box-helper.h"
|
||||
#include "ce-page-ip6.h"
|
||||
#include "ui-helpers.h"
|
||||
#include <nm-utils.h>
|
||||
|
||||
G_DEFINE_TYPE (CEPageIP6, ce_page_ip6, CE_TYPE_PAGE)
|
||||
|
@ -704,25 +705,34 @@ ui_to_setting (CEPageIP6 *page)
|
|||
|
||||
if (!*text_address && !*text_prefix && !*text_gateway) {
|
||||
/* ignore empty rows */
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inet_pton (AF_INET6, text_address, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
prefix = strtoul (text_prefix, &end, 10);
|
||||
if (!end || *end || prefix == 0 || prefix > 128) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
|
||||
if (text_gateway && *text_gateway) {
|
||||
if (inet_pton (AF_INET6, text_gateway, &tmp_gateway) <= 0) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
goto out;
|
||||
}
|
||||
if (!IN6_IS_ADDR_UNSPECIFIED (&tmp_gateway))
|
||||
have_gateway = TRUE;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
|
||||
addr = nm_ip6_address_new ();
|
||||
nm_ip6_address_set_address (addr, &tmp_addr);
|
||||
|
@ -748,12 +758,15 @@ ui_to_setting (CEPageIP6 *page)
|
|||
text = gtk_entry_get_text (entry);
|
||||
if (!*text) {
|
||||
/* ignore empty rows */
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inet_pton (AF_INET6, text, &tmp_addr) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
nm_setting_ip6_config_add_dns (page->setting, &tmp_addr);
|
||||
}
|
||||
|
@ -784,30 +797,42 @@ ui_to_setting (CEPageIP6 *page)
|
|||
|
||||
if (!*text_address && !*text_prefix && !*text_gateway && !*text_metric) {
|
||||
/* ignore empty rows */
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "metric"));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (inet_pton (AF_INET6, text_address, &dest) <= 0) {
|
||||
widget_set_error (GTK_WIDGET (entry));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (GTK_WIDGET (entry));
|
||||
|
||||
prefix = strtoul (text_prefix, &end, 10);
|
||||
if (!end || *end || prefix == 0 || prefix > 128) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "prefix"));
|
||||
|
||||
if (inet_pton (AF_INET6, text_gateway, &gateway) <= 0) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
goto out;
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "gateway"));
|
||||
|
||||
metric = 0;
|
||||
if (*text_metric) {
|
||||
errno = 0;
|
||||
metric = strtoul (text_metric, NULL, 10);
|
||||
if (errno) {
|
||||
widget_set_error (g_object_get_data (G_OBJECT (row), "metric"));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
widget_unset_error (g_object_get_data (G_OBJECT (row), "metric"));
|
||||
|
||||
route = nm_ip6_route_new ();
|
||||
nm_ip6_route_set_dest (route, &dest);
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
|
||||
#include "firewall-helpers.h"
|
||||
#include "ce-page-wifi.h"
|
||||
#include "ui-helpers.h"
|
||||
|
||||
G_DEFINE_TYPE (CEPageWifi, ce_page_wifi, CE_TYPE_PAGE)
|
||||
|
||||
|
@ -194,25 +195,33 @@ validate (CEPage *page,
|
|||
|
||||
entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_bssid")));
|
||||
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
|
||||
if (invalid)
|
||||
if (invalid) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
if (ignore)
|
||||
g_byte_array_free (ignore, TRUE);
|
||||
widget_unset_error (entry);
|
||||
|
||||
entry = gtk_bin_get_child (GTK_BIN (gtk_builder_get_object (page->builder, "combo_mac")));
|
||||
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
|
||||
if (invalid)
|
||||
if (invalid) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
if (ignore)
|
||||
g_byte_array_free (ignore, TRUE);
|
||||
widget_unset_error (entry);
|
||||
|
||||
entry = GTK_WIDGET (gtk_builder_get_object (page->builder, "entry_cloned_mac"));
|
||||
ignore = ce_page_entry_to_mac (GTK_ENTRY (entry), ARPHRD_ETHER, &invalid);
|
||||
if (invalid)
|
||||
if (invalid) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
if (ignore)
|
||||
g_byte_array_free (ignore, TRUE);
|
||||
|
||||
widget_unset_error (entry);
|
||||
|
||||
ui_to_setting (CE_PAGE_WIFI (page));
|
||||
|
||||
|
|
38
panels/network/connection-editor/ui-helpers.c
Normal file
38
panels/network/connection-editor/ui-helpers.c
Normal file
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ui-helpers.h"
|
||||
|
||||
void
|
||||
widget_set_error (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
gtk_style_context_add_class (gtk_widget_get_style_context (widget), "error");
|
||||
}
|
||||
|
||||
void
|
||||
widget_unset_error (GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
gtk_style_context_remove_class (gtk_widget_get_style_context (widget), "error");
|
||||
}
|
27
panels/network/connection-editor/ui-helpers.h
Normal file
27
panels/network/connection-editor/ui-helpers.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along
|
||||
* with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* (C) Copyright 2014 Red Hat, Inc.
|
||||
*/
|
||||
|
||||
#ifndef _UI_HELPERS_H_
|
||||
#define _UI_HELPERS_H_
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
void widget_set_error (GtkWidget *widget);
|
||||
void widget_unset_error (GtkWidget *widget);
|
||||
|
||||
#endif /* _UI_HELPERS_H_ */
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "eap-method.h"
|
||||
#include "wireless-security.h"
|
||||
#include "helpers.h"
|
||||
|
||||
#define I_NAME_COLUMN 0
|
||||
#define I_METHOD_COLUMN 1
|
||||
|
@ -69,8 +70,11 @@ validate (EAPMethod *parent)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_pac_file_button"));
|
||||
g_assert (widget);
|
||||
file = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (widget));
|
||||
if (!provisioning && !file)
|
||||
if (!provisioning && !file) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_fast_inner_auth_combo"));
|
||||
g_assert (widget);
|
||||
|
|
|
@ -56,14 +56,20 @@ validate (EAPMethod *parent)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_username_entry"));
|
||||
g_assert (widget);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_leap_password_entry"));
|
||||
g_assert (widget);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -59,20 +59,28 @@ validate (EAPMethod *parent)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_username_entry"));
|
||||
g_assert (widget);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
/* Check if the password should always be requested */
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_password_always_ask"));
|
||||
g_assert (widget);
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
|
||||
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget))) {
|
||||
widget_unset_error (GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry")));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_simple_password_entry"));
|
||||
g_assert (widget);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -63,8 +63,11 @@ validate (EAPMethod *parent)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_identity_entry"));
|
||||
g_assert (widget);
|
||||
identity = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!identity || !strlen (identity))
|
||||
if (!identity || !strlen (identity)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
if (!eap_method_validate_filepicker (parent->builder, "eap_tls_ca_cert_button", TYPE_CA_CERT, NULL, NULL))
|
||||
return FALSE;
|
||||
|
@ -72,8 +75,11 @@ validate (EAPMethod *parent)
|
|||
widget = GTK_WIDGET (gtk_builder_get_object (parent->builder, "eap_tls_private_key_password_entry"));
|
||||
g_assert (widget);
|
||||
password = gtk_entry_get_text (GTK_ENTRY (widget));
|
||||
if (!password || !strlen (password))
|
||||
if (!password || !strlen (password)) {
|
||||
widget_set_error (widget);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (widget);
|
||||
|
||||
if (!eap_method_validate_filepicker (parent->builder,
|
||||
"eap_tls_private_key_button",
|
||||
|
|
|
@ -48,4 +48,3 @@ helper_fill_secret_entry (NMConnection *connection,
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,5 +36,8 @@ void helper_fill_secret_entry (NMConnection *connection,
|
|||
GType setting_type,
|
||||
HelperSecretFunc func);
|
||||
|
||||
extern void widget_set_error (GtkWidget *widget);
|
||||
extern void widget_unset_error (GtkWidget *widget);
|
||||
|
||||
#endif /* _HELPERS_H_ */
|
||||
|
||||
|
|
|
@ -53,14 +53,20 @@ validate (WirelessSecurity *parent, const GByteArray *ssid)
|
|||
entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_username_entry"));
|
||||
g_assert (entry);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (entry);
|
||||
|
||||
entry = GTK_WIDGET (gtk_builder_get_object (parent->builder, "leap_password_entry"));
|
||||
g_assert (entry);
|
||||
text = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!text || !strlen (text))
|
||||
if (!text || !strlen (text)) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (entry);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -98,27 +98,37 @@ validate (WirelessSecurity *parent, const GByteArray *ssid)
|
|||
g_assert (entry);
|
||||
|
||||
key = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
if (!key)
|
||||
if (!key) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (sec->type == NM_WEP_KEY_TYPE_KEY) {
|
||||
if ((strlen (key) == 10) || (strlen (key) == 26)) {
|
||||
for (i = 0; i < strlen (key); i++) {
|
||||
if (!isxdigit (key[i]))
|
||||
if (!isxdigit (key[i])) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
} else if ((strlen (key) == 5) || (strlen (key) == 13)) {
|
||||
for (i = 0; i < strlen (key); i++) {
|
||||
if (!isascii (key[i]))
|
||||
if (!isascii (key[i])) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
} else if (sec->type == NM_WEP_KEY_TYPE_PASSPHRASE) {
|
||||
if (!strlen (key) || (strlen (key) > 64))
|
||||
if (!strlen (key) || (strlen (key) > 64)) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
widget_unset_error (entry);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -59,16 +59,22 @@ validate (WirelessSecurity *parent, const GByteArray *ssid)
|
|||
|
||||
key = gtk_entry_get_text (GTK_ENTRY (entry));
|
||||
len = strlen (key);
|
||||
if ((len < 8) || (len > 64))
|
||||
if ((len < 8) || (len > 64)) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
widget_unset_error (entry);
|
||||
|
||||
if (len == 64) {
|
||||
/* Hex PSK */
|
||||
for (i = 0; i < len; i++) {
|
||||
if (!isxdigit (key[i]))
|
||||
if (!isxdigit (key[i])) {
|
||||
widget_set_error (entry);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
widget_unset_error (entry);
|
||||
|
||||
/* passphrase can be between 8 and 63 characters inclusive */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue