network-manager-applet r992 - in trunk: . src src/connection-editor src/gconf-helpers src/utils src/wireless-security
- From: dcbw svn gnome org
- To: svn-commits-list gnome org
- Subject: network-manager-applet r992 - in trunk: . src src/connection-editor src/gconf-helpers src/utils src/wireless-security
- Date: Thu, 30 Oct 2008 14:47:02 +0000 (UTC)
Author: dcbw
Date: Thu Oct 30 14:47:01 2008
New Revision: 992
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=992&view=rev
Log:
2008-10-30 Dan Williams <dcbw redhat com>
* src/applet-device-wifi.c
src/applet-dialogs.c
src/connection-editor/page-wireless-security.c
src/gconf-helpers/gconf-upgrade.c
src/utils/utils.c
src/wireless-dialog.c
src/wireless-security/wireless-security.c
src/wireless-security/ws-dynamic-wep.c
src/wireless-security/ws-leap.c
src/wireless-security/ws-wep-key.c
src/wireless-security/ws-wpa-eap.c
src/wireless-security/ws-wpa-psk.c
- Use wireless security setting accessors
Modified:
trunk/ChangeLog
trunk/src/applet-device-wifi.c
trunk/src/applet-dialogs.c
trunk/src/connection-editor/page-wireless-security.c
trunk/src/gconf-helpers/gconf-upgrade.c
trunk/src/utils/utils.c
trunk/src/wireless-dialog.c
trunk/src/wireless-security/wireless-security.c
trunk/src/wireless-security/ws-dynamic-wep.c
trunk/src/wireless-security/ws-leap.c
trunk/src/wireless-security/ws-wep-key.c
trunk/src/wireless-security/ws-wpa-eap.c
trunk/src/wireless-security/ws-wpa-psk.c
Modified: trunk/src/applet-device-wifi.c
==============================================================================
--- trunk/src/applet-device-wifi.c (original)
+++ trunk/src/applet-device-wifi.c Thu Oct 30 14:47:01 2008
@@ -172,28 +172,26 @@
return FALSE;
}
-static GSList *
-add_ciphers_from_flags (guint32 flags, gboolean pairwise)
+static void
+add_ciphers_from_flags (NMSettingWirelessSecurity *sec,
+ guint32 flags,
+ gboolean pairwise)
{
- GSList *ciphers = NULL;
-
if (pairwise) {
if (flags & NM_802_11_AP_SEC_PAIR_TKIP)
- ciphers = g_slist_append (ciphers, g_strdup ("tkip"));
+ nm_setting_wireless_security_add_pairwise (sec, "tkip");
if (flags & NM_802_11_AP_SEC_PAIR_CCMP)
- ciphers = g_slist_append (ciphers, g_strdup ("ccmp"));
+ nm_setting_wireless_security_add_pairwise (sec, "ccmp");
} else {
if (flags & NM_802_11_AP_SEC_GROUP_WEP40)
- ciphers = g_slist_append (ciphers, g_strdup ("wep40"));
+ nm_setting_wireless_security_add_group (sec, "wep40");
if (flags & NM_802_11_AP_SEC_GROUP_WEP104)
- ciphers = g_slist_append (ciphers, g_strdup ("wep104"));
+ nm_setting_wireless_security_add_group (sec, "wep104");
if (flags & NM_802_11_AP_SEC_GROUP_TKIP)
- ciphers = g_slist_append (ciphers, g_strdup ("tkip"));
+ nm_setting_wireless_security_add_group (sec, "tkip");
if (flags & NM_802_11_AP_SEC_GROUP_CCMP)
- ciphers = g_slist_append (ciphers, g_strdup ("ccmp"));
+ nm_setting_wireless_security_add_group (sec, "ccmp");
}
-
- return ciphers;
}
static NMSettingWirelessSecurity *
@@ -234,8 +232,10 @@
* elements, it must be LEAP or static/dynamic WEP.
*/
if ((wpa_flags == NM_802_11_AP_SEC_NONE) && (rsn_flags == NM_802_11_AP_SEC_NONE)) {
- sec->key_mgmt = g_strdup ("none");
- sec->wep_tx_keyidx = 0;
+ g_object_set (sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
+ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, 0,
+ NULL);
return sec;
}
/* Otherwise, the AP supports WPA or RSN, which is preferred */
@@ -244,8 +244,10 @@
* WPA/RSN information elements from a scan. Since Privacy was
* advertised, LEAP or static/dynamic WEP must be in use.
*/
- sec->key_mgmt = g_strdup ("none");
- sec->wep_tx_keyidx = 0;
+ g_object_set (sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
+ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, 0,
+ NULL);
return sec;
}
}
@@ -259,30 +261,30 @@
/* WPA2 PSK first */
if ( (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
&& (dev_caps & NM_WIFI_DEVICE_CAP_RSN)) {
- sec->key_mgmt = g_strdup ("wpa-psk");
- sec->proto = g_slist_append (sec->proto, g_strdup ("rsn"));
- sec->pairwise = add_ciphers_from_flags (rsn_flags, TRUE);
- sec->group = add_ciphers_from_flags (rsn_flags, FALSE);
+ g_object_set (sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
+ nm_setting_wireless_security_add_proto (sec, "rsn");
+ add_ciphers_from_flags (sec, rsn_flags, TRUE);
+ add_ciphers_from_flags (sec, rsn_flags, FALSE);
return sec;
}
/* WPA PSK */
if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_PSK)
&& (dev_caps & NM_WIFI_DEVICE_CAP_WPA)) {
- sec->key_mgmt = g_strdup ("wpa-psk");
- sec->proto = g_slist_append (sec->proto, g_strdup ("wpa"));
- sec->pairwise = add_ciphers_from_flags (wpa_flags, TRUE);
- sec->group = add_ciphers_from_flags (wpa_flags, FALSE);
+ g_object_set (sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
+ nm_setting_wireless_security_add_proto (sec, "wpa");
+ add_ciphers_from_flags (sec, wpa_flags, TRUE);
+ add_ciphers_from_flags (sec, wpa_flags, FALSE);
return sec;
}
/* WPA2 Enterprise */
if ( (rsn_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
&& (dev_caps & NM_WIFI_DEVICE_CAP_RSN)) {
- sec->key_mgmt = g_strdup ("wpa-eap");
- sec->proto = g_slist_append (sec->proto, g_strdup ("rsn"));
- sec->pairwise = add_ciphers_from_flags (rsn_flags, TRUE);
- sec->group = add_ciphers_from_flags (rsn_flags, FALSE);
+ g_object_set (sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
+ nm_setting_wireless_security_add_proto (sec, "rsn");
+ add_ciphers_from_flags (sec, rsn_flags, TRUE);
+ add_ciphers_from_flags (sec, rsn_flags, FALSE);
*s_8021x = NM_SETTING_802_1X (nm_setting_802_1x_new ());
(*s_8021x)->eap = g_slist_append ((*s_8021x)->eap, g_strdup ("ttls"));
@@ -293,10 +295,10 @@
/* WPA Enterprise */
if ( (wpa_flags & NM_802_11_AP_SEC_KEY_MGMT_802_1X)
&& (dev_caps & NM_WIFI_DEVICE_CAP_WPA)) {
- sec->key_mgmt = g_strdup ("wpa-eap");
- sec->proto = g_slist_append (sec->proto, g_strdup ("wpa"));
- sec->pairwise = add_ciphers_from_flags (wpa_flags, TRUE);
- sec->group = add_ciphers_from_flags (wpa_flags, FALSE);
+ g_object_set (sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
+ nm_setting_wireless_security_add_proto (sec, "wpa");
+ add_ciphers_from_flags (sec, wpa_flags, TRUE);
+ add_ciphers_from_flags (sec, wpa_flags, FALSE);
*s_8021x = NM_SETTING_802_1X (nm_setting_802_1x_new ());
(*s_8021x)->eap = g_slist_append ((*s_8021x)->eap, g_strdup ("ttls"));
@@ -1481,7 +1483,7 @@
NMSettingWirelessSecurity *s_wireless_sec;
NMDevice *device = NULL;
GHashTable *settings = NULL;
- const char *setting_name;
+ const char *setting_name, *key_mgmt, *auth_alg;
GError *error = NULL;
context = g_object_get_data (G_OBJECT (dialog), "dbus-context");
@@ -1552,10 +1554,11 @@
* beacons), and therefore defaults to requesting WEP secrets from the
* wireless-security setting, not the 802.1x setting.
*/
- if ( !strcmp (s_wireless_sec->key_mgmt, "ieee8021x")
- || !strcmp (s_wireless_sec->key_mgmt, "wpa-eap")) {
+ key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
+ if (!strcmp (key_mgmt, "ieee8021x") || !strcmp (key_mgmt, "wpa-eap")) {
/* LEAP secrets aren't in the 802.1x setting */
- if (!s_wireless_sec->auth_alg || strcmp (s_wireless_sec->auth_alg, "leap")) {
+ auth_alg = nm_setting_wireless_security_get_auth_alg (s_wireless_sec);
+ if (!auth_alg || strcmp (auth_alg, "leap")) {
NMSetting8021x *s_8021x;
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
Modified: trunk/src/applet-dialogs.c
==============================================================================
--- trunk/src/applet-dialogs.c (original)
+++ trunk/src/applet-dialogs.c Thu Oct 30 14:47:01 2008
@@ -76,12 +76,15 @@
char *phase2_str = NULL;
if (sec) {
- if (!strcmp (sec->key_mgmt, "ieee8021x")) {
- if (sec->auth_alg && !strcmp (sec->auth_alg, "leap"))
+ const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt (sec);
+ const char *auth_alg = nm_setting_wireless_security_get_auth_alg (sec);
+
+ if (!strcmp (key_mgmt, "ieee8021x")) {
+ if (auth_alg && !strcmp (auth_alg, "leap"))
str = g_string_new (_("LEAP"));
else
str = g_string_new (_("Dynamic WEP"));
- } else if (!strcmp (sec->key_mgmt, "wpa-eap"))
+ } else if (!strcmp (key_mgmt, "wpa-eap"))
str = g_string_new (_("WPA/WPA2"));
else
return NULL;
@@ -178,12 +181,13 @@
security = s_wireless ? nm_setting_wireless_get_security (s_wireless) : NULL;
if (security && !strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) && s_wireless_sec) {
+ const char *key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
- if (!strcmp (s_wireless_sec->key_mgmt, "none"))
+ if (!strcmp (key_mgmt, "none"))
label = g_strdup (_("WEP"));
- else if (!strcmp (s_wireless_sec->key_mgmt, "wpa-none"))
+ else if (!strcmp (key_mgmt, "wpa-none"))
label = g_strdup (_("WPA/WPA2"));
- else if (!strcmp (s_wireless_sec->key_mgmt, "wpa-psk"))
+ else if (!strcmp (key_mgmt, "wpa-psk"))
label = g_strdup (_("WPA/WPA2"));
else
label = get_eap_label (s_wireless_sec, s_8021x);
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 Thu Oct 30 14:47:01 2008
@@ -44,35 +44,52 @@
#define S_NAME_COLUMN 0
#define S_SEC_COLUMN 1
+static gboolean
+find_proto (NMSettingWirelessSecurity *sec, const char *item)
+{
+ guint32 i;
+
+ for (i = 0; i < nm_setting_wireless_security_get_num_protos (sec); i++) {
+ if (!strcmp (item, nm_setting_wireless_security_get_proto (sec, i)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
static NMUtilsSecurityType
get_default_type_for_security (NMSettingWirelessSecurity *sec)
{
+ const char *key_mgmt, *auth_alg;
+
g_return_val_if_fail (sec != NULL, NMU_SEC_NONE);
+ key_mgmt = nm_setting_wireless_security_get_key_mgmt (sec);
+ auth_alg = nm_setting_wireless_security_get_auth_alg (sec);
+
/* No IEEE 802.1x */
- if (!strcmp (sec->key_mgmt, "none"))
+ if (!strcmp (key_mgmt, "none"))
return NMU_SEC_STATIC_WEP;
- if (!strcmp (sec->key_mgmt, "ieee8021x")) {
- if (sec->auth_alg && !strcmp (sec->auth_alg, "leap"))
+ if (!strcmp (key_mgmt, "ieee8021x")) {
+ if (auth_alg && !strcmp (auth_alg, "leap"))
return NMU_SEC_LEAP;
return NMU_SEC_DYNAMIC_WEP;
}
- if ( !strcmp (sec->key_mgmt, "wpa-none")
- || !strcmp (sec->key_mgmt, "wpa-psk")) {
- if (sec->proto && !strcmp (sec->proto->data, "rsn"))
+ if ( !strcmp (key_mgmt, "wpa-none")
+ || !strcmp (key_mgmt, "wpa-psk")) {
+ if (find_proto (sec, "rsn"))
return NMU_SEC_WPA2_PSK;
- else if (sec->proto && !strcmp (sec->proto->data, "wpa"))
+ else if (find_proto (sec, "wpa"))
return NMU_SEC_WPA_PSK;
else
return NMU_SEC_WPA_PSK;
}
- if (!strcmp (sec->key_mgmt, "wpa-eap")) {
- if (sec->proto && !strcmp (sec->proto->data, "rsn"))
+ if (!strcmp (key_mgmt, "wpa-eap")) {
+ if (find_proto (sec, "rsn"))
return NMU_SEC_WPA2_ENTERPRISE;
- else if (sec->proto && !strcmp (sec->proto->data, "wpa"))
+ else if (find_proto (sec, "wpa"))
return NMU_SEC_WPA_ENTERPRISE;
else
return NMU_SEC_WPA_ENTERPRISE;
Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c (original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c Thu Oct 30 14:47:01 2008
@@ -70,16 +70,6 @@
#define NM_PHASE2_AUTH_MSCHAPV2 0x00030000
#define NM_PHASE2_AUTH_GTC 0x00040000
-static void
-free_slist (GSList *slist)
-{
- GSList *i;
-
- for (i = slist; i; i = i->next)
- g_free (i->data);
- g_slist_free (slist);
-}
-
struct flagnames {
const char * const name;
guint value;
@@ -141,7 +131,7 @@
}
if (ival) {
- free_slist (*value);
+ nm_utils_slist_free (*value, g_free);
g_warning ("Bad value '%d' for key '%s' on NM 0.6 connection %s", ival, key, network);
return FALSE;
}
@@ -179,10 +169,13 @@
if (!get_enum_helper (client, path, "wep_auth_algorithm", network, wep_auth_algorithms, &auth_alg))
return NULL;
- s_wireless_sec = (NMSettingWirelessSecurity *)nm_setting_wireless_security_new ();
- s_wireless_sec->key_mgmt = g_strdup ("none");
- s_wireless_sec->wep_tx_keyidx = 0;
- s_wireless_sec->auth_alg = auth_alg;
+ s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
+ g_object_set (s_wireless_sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
+ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, 0,
+ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, auth_alg,
+ NULL);
+ g_free (auth_alg);
return s_wireless_sec;
}
@@ -203,31 +196,24 @@
nm_gconf_read_0_6_wpa_settings (GConfClient *client,
const char *path, const char *network)
{
- NMSettingWirelessSecurity *s_wireless_sec;
- GSList *proto, *pairwise, *group;
- char *key_mgmt;
+ NMSettingWirelessSecurity *s_wireless_sec = NULL;
+ GSList *proto, *iter;
+ char *key_mgmt = NULL;
if (!get_bitfield_helper (client, path, "wpa_psk_wpa_version", network, wpa_versions, &proto))
return NULL;
- if (!get_enum_helper (client, path, "wpa_psk_key_mgt", network, wpa_key_mgmt, &key_mgmt)) {
- free_slist (proto);
- return NULL;
- }
+ if (!get_enum_helper (client, path, "wpa_psk_key_mgt", network, wpa_key_mgmt, &key_mgmt))
+ goto out;
- /* Allow all ciphers */
- pairwise = g_slist_prepend (NULL, "tkip");
- pairwise = g_slist_prepend (pairwise, "ccmp");
- group = g_slist_prepend (NULL, "wep40");
- group = g_slist_prepend (group, "wep104");
- group = g_slist_prepend (group, "tkip");
- group = g_slist_prepend (group, "ccmp");
-
- s_wireless_sec = (NMSettingWirelessSecurity *)nm_setting_wireless_security_new ();
- s_wireless_sec->key_mgmt = key_mgmt;
- s_wireless_sec->proto = proto;
- s_wireless_sec->pairwise = pairwise;
- s_wireless_sec->group = group;
+ s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt, NULL);
+ for (iter = proto; iter; iter = g_slist_next (iter))
+ nm_setting_wireless_security_add_proto (s_wireless_sec, (const char *) iter->data);
+
+out:
+ g_free (key_mgmt);
+ nm_utils_slist_free (proto, g_free);
return s_wireless_sec;
}
@@ -265,7 +251,7 @@
NMSetting8021x **s_8021x)
{
NMSettingWirelessSecurity *s_wireless_sec;
- GSList *eap = NULL, *key_type = NULL, *proto = NULL;
+ GSList *eap = NULL, *key_type = NULL, *proto = NULL, *iter;
char *phase2_type = NULL, *identity = NULL, *anon_identity = NULL;
if (!get_bitfield_helper (client, path, "wpa_eap_eap_method", network, eap_methods, &eap))
@@ -283,9 +269,16 @@
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
/* AFAICT, 0.6 reads this value from gconf, and then ignores it and always uses IW_AUTH_KEY_MGMT_802_1X */
- s_wireless_sec->key_mgmt = g_strdup ("ieee8021x"); /* FIXME? wpa-eap? */
- s_wireless_sec->proto = proto;
- s_wireless_sec->group = key_type; /* FIXME? */
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL); /* FIXME: wpa-eap? */
+
+ for (iter = proto; iter; iter = g_slist_next (iter))
+ nm_setting_wireless_security_add_proto (s_wireless_sec, (const char *) iter->data);
+ nm_utils_slist_free (proto, g_free);
+
+ /* FIXME: what's the right mapping here? */
+ for (iter = key_type; iter; iter = g_slist_next (iter))
+ nm_setting_wireless_security_add_group (s_wireless_sec, (const char *) iter->data);
+ nm_utils_slist_free (key_type, g_free);
*s_8021x = (NMSetting8021x *) nm_setting_802_1x_new ();
(*s_8021x)->eap = eap;
@@ -296,9 +289,9 @@
return s_wireless_sec;
fail:
- free_slist (proto);
- free_slist (eap);
- free_slist (key_type);
+ nm_utils_slist_free (proto, g_free);
+ nm_utils_slist_free (eap, g_free);
+ nm_utils_slist_free (key_type, g_free);
g_free (phase2_type);
g_free (identity);
g_free (anon_identity);
@@ -310,20 +303,23 @@
nm_gconf_read_0_6_leap_settings (GConfClient *client,
const char *path, const char *network)
{
- NMSettingWirelessSecurity *s_wireless_sec;
+ NMSettingWirelessSecurity *s_wireless_sec = NULL;
char *username = NULL, *key_mgmt = NULL;
if (!get_mandatory_string_helper (client, path, "leap_username", network, &username))
- return NULL;
- if (!get_mandatory_string_helper (client, path, "leap_key_mgmt", network, &key_mgmt)) {
- g_free (username);
- return NULL;
- }
+ goto out;
+ if (!get_mandatory_string_helper (client, path, "leap_key_mgmt", network, &key_mgmt))
+ goto out;
- s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
- s_wireless_sec->key_mgmt = key_mgmt;
- s_wireless_sec->leap_username = username;
+ s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_setting_wireless_security_new ());
+ g_object_set (s_wireless_sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, key_mgmt,
+ NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, username,
+ NULL);
+out:
+ g_free (username);
+ g_free (key_mgmt);
return s_wireless_sec;
}
@@ -388,7 +384,6 @@
for (iter = bssids; iter; iter = iter->next)
nm_setting_wireless_add_seen_bssid (s_wireless, (char *) iter->data);
-
nm_utils_slist_free (bssids, g_free);
if (we_cipher != NM_AUTH_TYPE_NONE) {
@@ -577,8 +572,8 @@
NM_SETTING_CONNECTION_ID, id,
NM_SETTING_CONNECTION_TYPE, NM_SETTING_VPN_SETTING_NAME,
NULL);
-
g_free (id);
+
id = nm_utils_uuid_generate ();
g_object_set (s_con, NM_SETTING_CONNECTION_UUID, id, NULL);
g_free (id);
@@ -593,7 +588,7 @@
else
g_warning ("unmatched service name %s\n", service_name);
- free_slist (vpn_data);
+ nm_utils_slist_free (vpn_data, g_free);
g_free (path);
g_free (network);
g_free (service_name);
@@ -642,7 +637,7 @@
g_object_unref (conn);
}
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
connections = gconf_client_all_dirs (client, GCONF_PATH_0_6_VPN_CONNECTIONS, NULL);
for (iter = connections; iter; iter = iter->next) {
@@ -652,7 +647,7 @@
g_object_unref (conn);
}
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -932,7 +927,7 @@
next:
g_free (uuid);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -990,7 +985,7 @@
next:
g_free (id);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1028,7 +1023,7 @@
next:
g_free (id);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1064,7 +1059,7 @@
NM_SETTING_IP4_CONFIG_SETTING_NAME,
IP4_KEY_IGNORE_DHCP_DNS);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1193,7 +1188,7 @@
g_slist_foreach (old_routes, (GFunc) g_free, NULL);
g_slist_free (old_routes);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1262,7 +1257,7 @@
/* delete old vpn-properties dir */
gconf_client_recursive_unset (client, path, 0, NULL);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1365,7 +1360,7 @@
new_type);
}
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1393,7 +1388,7 @@
g_free (uuid);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
@@ -1513,7 +1508,7 @@
g_free (old_id);
g_free (uuid);
}
- free_slist (connections);
+ nm_utils_slist_free (connections, g_free);
gconf_client_suggest_sync (client, NULL);
}
Modified: trunk/src/utils/utils.c
==============================================================================
--- trunk/src/utils/utils.c (original)
+++ trunk/src/utils/utils.c Thu Oct 30 14:47:01 2008
@@ -577,7 +577,7 @@
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
const GByteArray *setting_mac;
- const char *setting_security;
+ const char *setting_security, *key_mgmt;
guint32 wcaps;
NMAccessPoint *ap;
@@ -620,12 +620,14 @@
if (!s_wireless_sec)
return TRUE; /* all devices can do unencrypted networks */
+ key_mgmt = nm_setting_wireless_security_get_key_mgmt (s_wireless_sec);
+
/* All devices should support static WEP */
- if (!strcmp (s_wireless_sec->key_mgmt, "none"))
+ if (!strcmp (key_mgmt, "none"))
return TRUE;
/* All devices should support legacy LEAP and Dynamic WEP */
- if (!strcmp (s_wireless_sec->key_mgmt, "ieee8021x"))
+ if (!strcmp (key_mgmt, "ieee8021x"))
return TRUE;
/* Match security with device capabilities */
@@ -637,20 +639,20 @@
return FALSE;
/* Check for only RSN */
- if ( (g_slist_length (s_wireless_sec->proto) == 1)
- && !strcmp (s_wireless_sec->proto->data, "rsn")
+ if ( (nm_setting_wireless_security_get_num_protos (s_wireless_sec) == 1)
+ && !strcmp (nm_setting_wireless_security_get_proto (s_wireless_sec, 0), "rsn")
&& !(wcaps & NM_WIFI_DEVICE_CAP_RSN))
return FALSE;
/* Check for only pairwise CCMP */
- if ( (g_slist_length (s_wireless_sec->pairwise) == 1)
- && !strcmp (s_wireless_sec->pairwise->data, "ccmp")
+ if ( (nm_setting_wireless_security_get_num_pairwise (s_wireless_sec) == 1)
+ && !strcmp (nm_setting_wireless_security_get_pairwise (s_wireless_sec, 0), "ccmp")
&& !(wcaps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
return FALSE;
/* Check for only group CCMP */
- if ( (g_slist_length (s_wireless_sec->group) == 1)
- && !strcmp (s_wireless_sec->group->data, "ccmp")
+ if ( (nm_setting_wireless_security_get_num_groups (s_wireless_sec) == 1)
+ && !strcmp (nm_setting_wireless_security_get_group (s_wireless_sec, 0), "ccmp")
&& !(wcaps & NM_WIFI_DEVICE_CAP_CIPHER_CCMP))
return FALSE;
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Thu Oct 30 14:47:01 2008
@@ -630,42 +630,59 @@
return num_added > 0 ? TRUE : FALSE;
}
+static gboolean
+find_proto (NMSettingWirelessSecurity *sec, const char *item)
+{
+ guint32 i;
+
+ for (i = 0; i < nm_setting_wireless_security_get_num_protos (sec); i++) {
+ if (!strcmp (item, nm_setting_wireless_security_get_proto (sec, i)))
+ return TRUE;
+ }
+ return FALSE;
+}
+
static NMUtilsSecurityType
get_default_type_for_security (NMSettingWirelessSecurity *sec,
gboolean have_ap,
guint32 ap_flags,
guint32 dev_caps)
{
+ const char *key_mgmt, *auth_alg;
+
g_return_val_if_fail (sec != NULL, NMU_SEC_NONE);
+ key_mgmt = nm_setting_wireless_security_get_key_mgmt (sec);
+ auth_alg = nm_setting_wireless_security_get_auth_alg (sec);
+
/* No IEEE 802.1x */
- if (!strcmp (sec->key_mgmt, "none"))
+ if (!strcmp (key_mgmt, "none"))
return NMU_SEC_STATIC_WEP;
- if ( !strcmp (sec->key_mgmt, "ieee8021x")
+ if ( !strcmp (key_mgmt, "ieee8021x")
&& (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
- if (sec->auth_alg && !strcmp (sec->auth_alg, "leap"))
+ if (auth_alg && !strcmp (auth_alg, "leap"))
return NMU_SEC_LEAP;
return NMU_SEC_DYNAMIC_WEP;
}
- if ( !strcmp (sec->key_mgmt, "wpa-none")
- || !strcmp (sec->key_mgmt, "wpa-psk")) {
+ if ( !strcmp (key_mgmt, "wpa-none")
+ || !strcmp (key_mgmt, "wpa-psk")) {
if (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY)) {
- if (sec->proto && !strcmp (sec->proto->data, "rsn"))
+ if (find_proto (sec, "rsn"))
return NMU_SEC_WPA2_PSK;
- else if (sec->proto && !strcmp (sec->proto->data, "wpa"))
+ else if (find_proto (sec, "wpa"))
return NMU_SEC_WPA_PSK;
else
return NMU_SEC_WPA_PSK;
}
}
- if ( !strcmp (sec->key_mgmt, "wpa-eap")
+ if ( !strcmp (key_mgmt, "wpa-eap")
&& (!have_ap || (ap_flags & NM_802_11_AP_FLAGS_PRIVACY))) {
- if (sec->proto && !strcmp (sec->proto->data, "rsn"))
+ if (find_proto (sec, "rsn"))
return NMU_SEC_WPA2_ENTERPRISE;
- else if (sec->proto && !strcmp (sec->proto->data, "wpa"))
+ else if (find_proto (sec, "wpa"))
return NMU_SEC_WPA_ENTERPRISE;
else
return NMU_SEC_WPA_ENTERPRISE;
Modified: trunk/src/wireless-security/wireless-security.c
==============================================================================
--- trunk/src/wireless-security/wireless-security.c (original)
+++ trunk/src/wireless-security/wireless-security.c Thu Oct 30 14:47:01 2008
@@ -173,20 +173,9 @@
NM_TYPE_SETTING_WIRELESS_SECURITY));
g_assert (s_wireless_sec);
- /* Protocol */
- g_slist_foreach (s_wireless_sec->proto, (GFunc) g_free, NULL);
- g_slist_free (s_wireless_sec->proto);
- s_wireless_sec->proto = NULL;
-
- /* Pairwise cipher */
- g_slist_foreach (s_wireless_sec->pairwise, (GFunc) g_free, NULL);
- g_slist_free (s_wireless_sec->pairwise);
- s_wireless_sec->pairwise = NULL;
-
- /* Group cipher */
- g_slist_foreach (s_wireless_sec->group, (GFunc) g_free, NULL);
- g_slist_free (s_wireless_sec->group);
- s_wireless_sec->group = NULL;
+ nm_setting_wireless_security_clear_protos (s_wireless_sec);
+ nm_setting_wireless_security_clear_pairwise (s_wireless_sec);
+ nm_setting_wireless_security_clear_groups (s_wireless_sec);
}
void
Modified: trunk/src/wireless-security/ws-dynamic-wep.c
==============================================================================
--- trunk/src/wireless-security/ws-dynamic-wep.c (original)
+++ trunk/src/wireless-security/ws-dynamic-wep.c Thu Oct 30 14:47:01 2008
@@ -70,12 +70,12 @@
NM_TYPE_SETTING_WIRELESS_SECURITY));
g_assert (s_wireless_sec);
- s_wireless_sec->key_mgmt = g_strdup ("ieee8021x");
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x", NULL);
- s_wireless_sec->pairwise = g_slist_append (s_wireless_sec->pairwise, g_strdup ("wep40"));
- s_wireless_sec->pairwise = g_slist_append (s_wireless_sec->pairwise, g_strdup ("wep104"));
- s_wireless_sec->group = g_slist_append (s_wireless_sec->group, g_strdup ("wep40"));
- s_wireless_sec->group = g_slist_append (s_wireless_sec->group, g_strdup ("wep104"));
+ nm_setting_wireless_security_add_pairwise (s_wireless_sec, "wep40");
+ nm_setting_wireless_security_add_pairwise (s_wireless_sec, "wep104");
+ nm_setting_wireless_security_add_group (s_wireless_sec, "wep40");
+ nm_setting_wireless_security_add_group (s_wireless_sec, "wep104");
}
static void
Modified: trunk/src/wireless-security/ws-leap.c
==============================================================================
--- trunk/src/wireless-security/ws-leap.c (original)
+++ trunk/src/wireless-security/ws-leap.c Thu Oct 30 14:47:01 2008
@@ -88,6 +88,7 @@
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
GtkWidget *widget;
+ const char *leap_password = NULL, *leap_username = NULL;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
@@ -98,14 +99,18 @@
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- s_wireless_sec->key_mgmt = g_strdup ("ieee8021x");
- s_wireless_sec->auth_alg = g_strdup ("leap");
-
widget = glade_xml_get_widget (parent->xml, "leap_username_entry");
- s_wireless_sec->leap_username = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
+ leap_username = gtk_entry_get_text (GTK_ENTRY (widget));
widget = glade_xml_get_widget (parent->xml, "leap_password_entry");
- s_wireless_sec->leap_password = g_strdup (gtk_entry_get_text (GTK_ENTRY (widget)));
+ leap_password = gtk_entry_get_text (GTK_ENTRY (widget));
+
+ g_object_set (s_wireless_sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "ieee8021x",
+ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, "leap",
+ NM_SETTING_WIRELESS_SECURITY_LEAP_USERNAME, leap_username,
+ NM_SETTING_WIRELESS_SECURITY_LEAP_PASSWORD, leap_password,
+ NULL);
}
WirelessSecurityLEAP *
@@ -146,8 +151,11 @@
if (connection) {
wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
if (wsec) {
+ const char *auth_alg;
+
/* Ignore if wireless security doesn't specify LEAP */
- if (!wsec->auth_alg || strcmp (wsec->auth_alg, "leap"))
+ auth_alg = nm_setting_wireless_security_get_auth_alg (wsec);
+ if (!auth_alg || strcmp (auth_alg, "leap"))
wsec = NULL;
}
}
@@ -181,7 +189,7 @@
(GCallback) wireless_security_changed_cb,
sec);
if (wsec)
- gtk_entry_set_text (GTK_ENTRY (widget), wsec->leap_username);
+ gtk_entry_set_text (GTK_ENTRY (widget), nm_setting_wireless_security_get_leap_username (wsec));
widget = glade_xml_get_widget (xml, "show_checkbutton");
g_assert (widget);
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 Thu Oct 30 14:47:01 2008
@@ -188,8 +188,11 @@
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
nm_connection_add_setting (connection, (NMSetting *) s_wireless_sec);
- s_wireless_sec->key_mgmt = g_strdup ("none");
- s_wireless_sec->wep_tx_keyidx = sec->cur_index;
+ g_object_set (s_wireless_sec,
+ NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "none",
+ NM_SETTING_WIRELESS_SECURITY_WEP_TX_KEYIDX, sec->cur_index,
+ NM_SETTING_WIRELESS_SECURITY_AUTH_ALG, (auth_alg == 1) ? "shared" : "open",
+ NULL);
for (i = 0; i < 4; i++) {
int key_len = strlen (sec->keys[i]);
@@ -205,22 +208,9 @@
} else if (sec->type == WEP_KEY_TYPE_PASSPHRASE)
hashed = wep128_passphrase_hash (sec->keys[i]);
- if (i == 0)
- s_wireless_sec->wep_key0 = hashed;
- else if (i == 1)
- s_wireless_sec->wep_key1 = hashed;
- else if (i == 2)
- s_wireless_sec->wep_key2 = hashed;
- else if (i == 3)
- s_wireless_sec->wep_key3 = hashed;
- }
-
- if (auth_alg == 0)
- s_wireless_sec->auth_alg = g_strdup ("open");
- else if (auth_alg == 1)
- s_wireless_sec->auth_alg = g_strdup ("shared");
- else
- g_assert_not_reached ();
+ nm_setting_wireless_security_set_wep_key (s_wireless_sec, i, hashed);
+ g_free (hashed);
+ }
}
static void
@@ -340,7 +330,7 @@
if (connection) {
NMSettingWireless *s_wireless;
- const char *mode;
+ const char *mode, *auth_alg;
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL;
@@ -348,8 +338,11 @@
is_adhoc = TRUE;
s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
- if (s_wsec && s_wsec->auth_alg && !strcmp (s_wsec->auth_alg, "shared"))
- is_shared_key = TRUE;
+ if (s_wsec) {
+ auth_alg = nm_setting_wireless_security_get_auth_alg (s_wsec);
+ if (auth_alg && !strcmp (auth_alg, "shared"))
+ is_shared_key = TRUE;
+ }
}
g_signal_connect (G_OBJECT (widget), "changed",
@@ -365,7 +358,7 @@
widget = glade_xml_get_widget (xml, "key_index_combo");
if (connection && s_wsec)
- default_key_idx = s_wsec->wep_tx_keyidx;
+ default_key_idx = nm_setting_wireless_security_get_wep_tx_keyidx (s_wsec);
gtk_combo_box_set_active (GTK_COMBO_BOX (widget), default_key_idx);
sec->cur_index = default_key_idx;
Modified: trunk/src/wireless-security/ws-wpa-eap.c
==============================================================================
--- trunk/src/wireless-security/ws-wpa-eap.c (original)
+++ trunk/src/wireless-security/ws-wpa-eap.c Thu Oct 30 14:47:01 2008
@@ -70,7 +70,7 @@
NM_TYPE_SETTING_WIRELESS_SECURITY));
g_assert (s_wireless_sec);
- s_wireless_sec->key_mgmt = g_strdup ("wpa-eap");
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-eap", NULL);
}
static void
Modified: trunk/src/wireless-security/ws-wpa-psk.c
==============================================================================
--- trunk/src/wireless-security/ws-wpa-psk.c (original)
+++ trunk/src/wireless-security/ws-wpa-psk.c Thu Oct 30 14:47:01 2008
@@ -135,21 +135,22 @@
g_free (buf);
}
- wireless_security_clear_ciphers (connection);
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_PSK, hashed, NULL);
+ g_free (hashed);
- s_wireless_sec->psk = hashed;
+ wireless_security_clear_ciphers (connection);
if (is_adhoc) {
/* Ad-Hoc settings as specified by the supplicant */
- s_wireless_sec->key_mgmt = g_strdup ("wpa-none");
- s_wireless_sec->proto = g_slist_append (NULL, g_strdup ("wpa"));
- s_wireless_sec->pairwise = g_slist_append (NULL, g_strdup ("none"));
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-none", NULL);
+ nm_setting_wireless_security_add_proto (s_wireless_sec, "wpa");
+ nm_setting_wireless_security_add_pairwise (s_wireless_sec, "none");
/* Ad-hoc can only have _one_ group cipher... default to TKIP to be more
* compatible for now. Maybe we'll support selecting CCMP later.
*/
- s_wireless_sec->group = g_slist_append (NULL, g_strdup ("tkip"));
+ nm_setting_wireless_security_add_group (s_wireless_sec, "tkip");
} else {
- s_wireless_sec->key_mgmt = g_strdup ("wpa-psk");
+ g_object_set (s_wireless_sec, NM_SETTING_WIRELESS_SECURITY_KEY_MGMT, "wpa-psk", NULL);
/* Just leave ciphers and protocol empty, the supplicant will
* figure that out magically based on the AP IEs and card capabilities.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]