network-manager-applet r861 - in trunk: . src src/connection-editor src/wireless-security
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r861 - in trunk: . src src/connection-editor src/wireless-security
- Date: Wed, 20 Aug 2008 21:41:18 +0000 (UTC)
Author: dcbw
Date: Wed Aug 20 21:41:17 2008
New Revision: 861
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=861&view=rev
Log:
2008-08-20 Dan Williams <dcbw redhat com>
* src/wireless-security/ws-wep-key.c
src/wireless-security/ws-wep-key.h
- Combine ASCII and Hex key types, becuase we can automatically
differentiate between the two
- Default to Hex/ASCII key type because apparently too many people have
trouble with the concept of WEP passphrases
* src/wireless-dialog.c
src/connection-editor/page-wireless-security.c
- Combine ASCII and Hex key types
Modified:
trunk/ChangeLog
trunk/src/connection-editor/page-wireless-security.c
trunk/src/wireless-dialog.c
trunk/src/wireless-security/ws-wep-key.c
trunk/src/wireless-security/ws-wep-key.h
Modified: trunk/src/connection-editor/page-wireless-security.c
==============================================================================
--- trunk/src/connection-editor/page-wireless-security.c (original)
+++ trunk/src/connection-editor/page-wireless-security.c Wed Aug 20 21:41:17 2008
@@ -247,34 +247,25 @@
if (nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, FALSE, is_adhoc, 0, 0, 0)) {
WirelessSecurityWEPKey *ws_wep;
- WEPKeyType default_wep_type = WEP_KEY_TYPE_PASSPHRASE;
+ WEPKeyType default_wep_type = WEP_KEY_TYPE_KEY;
if (default_type == NMU_SEC_STATIC_WEP)
default_wep_type = ws_wep_guess_key_type (connection, connection_id);
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, FALSE);
- if (ws_wep) {
- add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 128-bit Passphrase"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_PASSPHRASE))
- active = item;
- item++;
- }
-
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_HEX, FALSE);
+ ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_KEY, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 40/128-bit Hexadecimal"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_HEX))
+ &iter, _("WEP 40/128-bit Key"));
+ if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_KEY))
active = item;
item++;
}
- ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_ASCII, FALSE);
+ ws_wep = ws_wep_key_new (glade_file, connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, FALSE);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 40/128-bit ASCII"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_ASCII))
+ &iter, _("WEP 128-bit Passphrase"));
+ if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_PASSPHRASE))
active = item;
item++;
}
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Wed Aug 20 21:41:17 2008
@@ -741,34 +741,25 @@
if ( nm_utils_security_valid (NMU_SEC_STATIC_WEP, dev_caps, !!priv->ap, is_adhoc, ap_flags, ap_wpa, ap_rsn)
&& ((!ap_wpa && !ap_rsn) || !(dev_caps & (NM_WIFI_DEVICE_CAP_WPA | NM_WIFI_DEVICE_CAP_RSN)))) {
WirelessSecurityWEPKey *ws_wep;
- WEPKeyType default_wep_type = WEP_KEY_TYPE_PASSPHRASE;
+ WEPKeyType default_wep_type = WEP_KEY_TYPE_KEY;
if (default_type == NMU_SEC_STATIC_WEP)
default_wep_type = ws_wep_guess_key_type (priv->connection, connection_id);
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, priv->adhoc_create);
- if (ws_wep) {
- add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 128-bit Passphrase"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_PASSPHRASE))
- active = item;
- item++;
- }
-
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_HEX, priv->adhoc_create);
+ ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_KEY, priv->adhoc_create);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 40/128-bit Hexadecimal"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_HEX))
+ &iter, _("WEP 40/128-bit Key"));
+ if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_KEY))
active = item;
item++;
}
- ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_ASCII, priv->adhoc_create);
+ ws_wep = ws_wep_key_new (priv->glade_file, priv->connection, connection_id, WEP_KEY_TYPE_PASSPHRASE, priv->adhoc_create);
if (ws_wep) {
add_security_item (self, WIRELESS_SECURITY (ws_wep), sec_model,
- &iter, _("WEP 40/128-bit ASCII"));
- if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_ASCII))
+ &iter, _("WEP 128-bit Passphrase"));
+ if ((active < 0) && (default_type == NMU_SEC_STATIC_WEP) && (default_wep_type == WEP_KEY_TYPE_PASSPHRASE))
active = item;
item++;
}
Modified: trunk/src/wireless-security/ws-wep-key.c
==============================================================================
--- trunk/src/wireless-security/ws-wep-key.c (original)
+++ trunk/src/wireless-security/ws-wep-key.c Wed Aug 20 21:41:17 2008
@@ -96,24 +96,25 @@
g_assert (entry);
key = gtk_entry_get_text (GTK_ENTRY (entry));
- if (sec->type == WEP_KEY_TYPE_HEX) {
- if (!key || ((strlen (key) != 10) && (strlen (key) != 26)))
- return FALSE;
+ if (!key)
+ return FALSE;
- for (i = 0; i < strlen (key); i++) {
- if (!isxdigit (key[i]))
- return FALSE;
- }
- } else if (sec->type == WEP_KEY_TYPE_ASCII) {
- if (!key || ((strlen (key) != 5) && (strlen (key) != 13)))
+ if (sec->type == WEP_KEY_TYPE_KEY) {
+ if ((strlen (key) == 10) || (strlen (key) == 26)) {
+ for (i = 0; i < strlen (key); i++) {
+ if (!isxdigit (key[i]))
+ return FALSE;
+ }
+ } else if ((strlen (key) == 5) || (strlen (key) == 13)) {
+ for (i = 0; i < strlen (key); i++) {
+ if (!isascii (key[i]))
+ return FALSE;
+ }
+ } else {
return FALSE;
-
- for (i = 0; i < strlen (key); i++) {
- if (!isascii (key[i]))
- return FALSE;
}
} else if (sec->type == WEP_KEY_TYPE_PASSPHRASE) {
- if (!key || !strlen (key) || (strlen (key) > 64))
+ if (!strlen (key) || (strlen (key) > 64))
return FALSE;
}
@@ -198,11 +199,12 @@
if (!key_len)
continue;
- if (sec->type == WEP_KEY_TYPE_HEX)
- hashed = g_strdup (sec->keys[i]);
- else if (sec->type == WEP_KEY_TYPE_ASCII)
- hashed = utils_bin2hexstr (sec->keys[i], key_len, key_len * 2);
- else if (sec->type == WEP_KEY_TYPE_PASSPHRASE)
+ if (sec->type == WEP_KEY_TYPE_KEY) {
+ if ((key_len == 10) || (key_len == 26))
+ hashed = g_strdup (sec->keys[i]);
+ else if ((key_len == 5) || (key_len == 13))
+ hashed = utils_bin2hexstr (sec->keys[i], key_len, key_len * 2);
+ } else if (sec->type == WEP_KEY_TYPE_PASSPHRASE)
hashed = wep128_passphrase_hash (sec->keys[i]);
if (i == 0)
@@ -235,14 +237,9 @@
int i, count = 0;
gchar *result = g_new (gchar, length);
- if (sec->type == WEP_KEY_TYPE_HEX) {
- for (i = 0; i < length; i++) {
- if (isxdigit(text[i]))
- result[count++] = text[i];
- }
- } else if (sec->type == WEP_KEY_TYPE_ASCII) {
+ if (sec->type == WEP_KEY_TYPE_KEY) {
for (i = 0; i < length; i++) {
- if (isascii(text[i]))
+ if (isxdigit(text[i]) || isascii(text[i]))
result[count++] = text[i];
}
} else if (sec->type == WEP_KEY_TYPE_PASSPHRASE) {
@@ -362,10 +359,8 @@
g_signal_connect (G_OBJECT (widget), "insert-text",
(GCallback) wep_entry_filter_cb,
sec);
- if (sec->type == WEP_KEY_TYPE_HEX)
+ if (sec->type == WEP_KEY_TYPE_KEY)
gtk_entry_set_max_length (GTK_ENTRY (widget), 26);
- else if (sec->type == WEP_KEY_TYPE_ASCII)
- gtk_entry_set_max_length (GTK_ENTRY (widget), 13);
else if (sec->type == WEP_KEY_TYPE_PASSPHRASE)
gtk_entry_set_max_length (GTK_ENTRY (widget), 64);
@@ -422,8 +417,9 @@
int i;
if (!key || !len)
- return WEP_KEY_TYPE_PASSPHRASE;
+ return WEP_KEY_TYPE_KEY;
+ /* Hex key */
if ((len == 10) || (len == 26)) {
gboolean hex = TRUE;
@@ -434,9 +430,10 @@
}
}
if (hex)
- return WEP_KEY_TYPE_HEX;
+ return WEP_KEY_TYPE_KEY;
}
+ /* ASCII key */
if ((len == 5) || (len == 13)) {
gboolean ascii = TRUE;
@@ -447,7 +444,7 @@
}
}
if (ascii)
- return WEP_KEY_TYPE_ASCII;
+ return WEP_KEY_TYPE_KEY;
}
return WEP_KEY_TYPE_PASSPHRASE;
@@ -459,12 +456,12 @@
GHashTable *secrets;
GError *error = NULL;
GValue *value;
- WEPKeyType key_type = WEP_KEY_TYPE_PASSPHRASE;
+ WEPKeyType key_type = WEP_KEY_TYPE_KEY;
if (!connection)
- return WEP_KEY_TYPE_PASSPHRASE;
+ return WEP_KEY_TYPE_KEY;
- g_return_val_if_fail (connection_id != NULL, WEP_KEY_TYPE_PASSPHRASE);
+ g_return_val_if_fail (connection_id != NULL, WEP_KEY_TYPE_KEY);
secrets = nm_gconf_get_keyring_items (connection, connection_id,
NM_SETTING_WIRELESS_SECURITY_SETTING_NAME,
@@ -473,7 +470,7 @@
if (!secrets || (g_hash_table_size (secrets) == 0)) {
if (error)
g_error_free (error);
- return WEP_KEY_TYPE_PASSPHRASE;
+ return WEP_KEY_TYPE_KEY;
}
value = g_hash_table_lookup (secrets, NM_SETTING_WIRELESS_SECURITY_WEP_KEY0);
Modified: trunk/src/wireless-security/ws-wep-key.h
==============================================================================
--- trunk/src/wireless-security/ws-wep-key.h (original)
+++ trunk/src/wireless-security/ws-wep-key.h Wed Aug 20 21:41:17 2008
@@ -23,9 +23,8 @@
#define WS_WEP_KEY_H
typedef enum {
- WEP_KEY_TYPE_HEX = 0,
- WEP_KEY_TYPE_ASCII = 1,
- WEP_KEY_TYPE_PASSPHRASE = 2,
+ WEP_KEY_TYPE_KEY = 0,
+ WEP_KEY_TYPE_PASSPHRASE = 1,
} WEPKeyType;
typedef struct {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]