network-manager-applet r987 - 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 r987 - in trunk: . src src/connection-editor src/gconf-helpers src/utils src/wireless-security
- Date: Tue, 28 Oct 2008 19:27:31 +0000 (UTC)
Author: dcbw
Date: Tue Oct 28 19:27:31 2008
New Revision: 987
URL: http://svn.gnome.org/viewvc/network-manager-applet?rev=987&view=rev
Log:
2008-10-28 Dan Williams <dcbw redhat com>
Patch from Tambet Ingo <tambet gmail com>
* src/applet-device-wifi.c
src/applet-dialogs.c
src/connection-editor/page-wireless-security.c
src/connection-editor/page-wireless.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-leap.c
src/wireless-security/ws-wep-key.c
src/wireless-security/ws-wpa-psk.c
- Use wireless 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/connection-editor/page-wireless.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-leap.c
trunk/src/wireless-security/ws-wep-key.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 Tue Oct 28 19:27:31 2008
@@ -338,14 +338,13 @@
s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
ap_ssid = nm_access_point_get_ssid (info->ap);
- s_wireless->ssid = g_byte_array_sized_new (ap_ssid->len);
- g_byte_array_append (s_wireless->ssid, ap_ssid->data, ap_ssid->len);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, ap_ssid, NULL);
mode = nm_access_point_get_mode (info->ap);
if (mode == NM_802_11_MODE_ADHOC)
- s_wireless->mode = g_strdup ("adhoc");
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "adhoc", NULL);
else if (mode == NM_802_11_MODE_INFRA)
- s_wireless->mode = g_strdup ("infrastructure");
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "infrastructure", NULL);
else
g_assert_not_reached ();
@@ -354,9 +353,8 @@
if (!supported) {
g_object_unref (s_wireless);
goto out;
- } else if (s_wireless_sec) {
- s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
- }
+ } else if (s_wireless_sec)
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
connection = nm_connection_new ();
nm_connection_add_setting (connection, NM_SETTING (s_wireless));
@@ -742,10 +740,6 @@
{
NMConnection *connection;
NMSettingWireless *s_wireless;
- gboolean found = FALSE;
- gboolean added = FALSE;
- char *lower_bssid;
- GSList *iter;
const char *bssid;
connection = nm_exported_connection_get_connection (NM_EXPORTED_CONNECTION (gconf_connection));
@@ -759,29 +753,7 @@
if (!bssid || !utils_ether_addr_valid (ether_aton (bssid)))
return FALSE;
- lower_bssid = g_ascii_strdown (bssid, -1);
- if (!lower_bssid)
- return FALSE;
-
- for (iter = s_wireless->seen_bssids; iter; iter = g_slist_next (iter)) {
- char *lower_seen_bssid = g_ascii_strdown (iter->data, -1);
-
- if (!strcmp (lower_seen_bssid, lower_bssid)) {
- found = TRUE;
- g_free (lower_seen_bssid);
- break;
- }
- g_free (lower_seen_bssid);
- }
-
- /* Add this AP's BSSID to the seen-BSSIDs list */
- if (!found) {
- s_wireless->seen_bssids = g_slist_prepend (s_wireless->seen_bssids,
- g_strdup (lower_bssid));
- added = TRUE;
- }
- g_free (lower_bssid);
- return added;
+ return nm_setting_wireless_add_seen_bssid (s_wireless, bssid);
}
static void
@@ -814,7 +786,7 @@
return;
ssid = nm_access_point_get_ssid (new);
- if (!ssid || !nm_utils_same_ssid (s_wireless->ssid, ssid, TRUE))
+ if (!ssid || !nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), ssid, TRUE))
return;
if (add_seen_bssid (gconf_connection, new))
@@ -1404,15 +1376,20 @@
if (!id) {
NMSettingWireless *s_wireless;
+ const GByteArray *ssid;
+ const char *mode;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
- id = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
+ ssid = nm_setting_wireless_get_ssid (s_wireless);
+
+ id = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
g_object_set (s_con, NM_SETTING_CONNECTION_ID, id, NULL);
g_free (id);
// FIXME: don't autoconnect until the connection is successful at least once
/* Don't autoconnect adhoc networks by default for now */
- if (!s_wireless->mode || !strcmp (s_wireless->mode, "infrastructure"))
+ mode = nm_setting_wireless_get_mode (s_wireless);
+ if (!mode || !strcmp (mode, "infrastructure"))
g_object_set (s_con, NM_SETTING_CONNECTION_AUTOCONNECT, TRUE, NULL);
}
Modified: trunk/src/applet-dialogs.c
==============================================================================
--- trunk/src/applet-dialogs.c (original)
+++ trunk/src/applet-dialogs.c Tue Oct 28 19:27:31 2008
@@ -169,15 +169,15 @@
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x;
+ const char *security;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
s_wireless_sec = (NMSettingWirelessSecurity *) nm_connection_get_setting (connection,
NM_TYPE_SETTING_WIRELESS_SECURITY);
s_8021x = (NMSetting8021x *) nm_connection_get_setting (connection, NM_TYPE_SETTING_802_1X);
- if (s_wireless
- && s_wireless->security
- && !strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME)
- && s_wireless_sec) {
+ security = s_wireless ? nm_setting_wireless_get_security (s_wireless) : NULL;
+
+ if (security && !strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME) && s_wireless_sec) {
if (!strcmp (s_wireless_sec->key_mgmt, "none"))
label = g_strdup (_("WEP"));
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 Tue Oct 28 19:27:31 2008
@@ -175,6 +175,8 @@
gboolean is_adhoc = FALSE;
GtkListStore *sec_model;
GtkTreeIter iter;
+ const char *mode;
+ const char *security;
guint32 dev_caps = 0;
NMUtilsSecurityType default_type = NMU_SEC_NONE;
int active = -1;
@@ -220,12 +222,15 @@
| NM_WIFI_DEVICE_CAP_WPA
| NM_WIFI_DEVICE_CAP_RSN;
- if (s_wireless->mode && !strcmp (s_wireless->mode, "adhoc"))
+ mode = nm_setting_wireless_get_mode (s_wireless);
+ if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection,
NM_TYPE_SETTING_WIRELESS_SECURITY));
- if (!s_wireless->security || strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
+
+ security = nm_setting_wireless_get_security (s_wireless);
+ if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
s_wireless_sec = NULL;
if (s_wireless_sec)
default_type = get_default_type_for_security (s_wireless_sec);
@@ -371,9 +376,11 @@
sec = wireless_security_combo_get_active (self);
if (sec) {
- if (s_wireless->ssid) {
+ const GByteArray *ssid = nm_setting_wireless_get_ssid (s_wireless);
+
+ if (ssid) {
/* FIXME: get failed property and error out of wireless security objects */
- valid = wireless_security_validate (sec, s_wireless->ssid);
+ valid = wireless_security_validate (sec, ssid);
if (valid)
wireless_security_fill_connection (sec, connection);
else
@@ -382,8 +389,7 @@
g_set_error (error, 0, 0, "Missing SSID");
} else {
/* No security, unencrypted */
- g_free (s_wireless->security);
- s_wireless->security = NULL;
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL);
valid = TRUE;
}
Modified: trunk/src/connection-editor/page-wireless.c
==============================================================================
--- trunk/src/connection-editor/page-wireless.c (original)
+++ trunk/src/connection-editor/page-wireless.c Tue Oct 28 19:27:31 2008
@@ -206,6 +206,9 @@
{
CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
NMSettingWireless *setting = priv->setting;
+ const GByteArray *ssid = NULL;
+ const char *mode = NULL;
+ const char *band = NULL;
int band_idx = 0;
int rate_def;
int tx_power_def;
@@ -230,8 +233,14 @@
GINT_TO_POINTER (mtu_def));
g_signal_connect_swapped (priv->mtu, "value-changed", G_CALLBACK (ce_page_changed), self);
- if (setting->ssid)
- utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) setting->ssid->data, setting->ssid->len);
+ g_object_get (setting,
+ NM_SETTING_WIRELESS_SSID, &ssid,
+ NM_SETTING_WIRELESS_MODE, &mode,
+ NM_SETTING_WIRELESS_BAND, &band,
+ NULL);
+
+ if (ssid)
+ utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
else
utf8_ssid = g_strdup ("");
gtk_entry_set_text (priv->ssid, utf8_ssid);
@@ -240,7 +249,7 @@
/* Default to Infrastructure */
gtk_combo_box_set_active (priv->mode, 0);
- if (setting->mode && !strcmp (setting->mode, "adhoc"))
+ if (mode && !strcmp (mode, "adhoc"))
gtk_combo_box_set_active (priv->mode, 1);
g_signal_connect_swapped (priv->mode, "changed", G_CALLBACK (ce_page_changed), self);
@@ -252,11 +261,11 @@
self);
gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), FALSE);
- if (setting->band) {
- if (!strcmp (setting->band ? setting->band : "", "a")) {
+ if (band) {
+ if (!strcmp (band ? band : "", "a")) {
band_idx = 1;
gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
- } else if (!strcmp (setting->band ? setting->band : "", "bg")) {
+ } else if (!strcmp (band ? band : "", "bg")) {
band_idx = 2;
gtk_widget_set_sensitive (GTK_WIDGET (priv->channel), TRUE);
}
@@ -269,21 +278,21 @@
/* Update the channel _after_ the band has been set so that it gets
* the right values */
- priv->last_channel = setting->channel;
- gtk_spin_button_set_value (priv->channel, (gdouble) setting->channel);
+ priv->last_channel = nm_setting_wireless_get_channel (setting);
+ gtk_spin_button_set_value (priv->channel, (gdouble) priv->last_channel);
g_signal_connect_swapped (priv->channel, "value-changed", G_CALLBACK (ce_page_changed), self);
/* BSSID */
- ce_page_mac_to_entry (setting->bssid, priv->bssid);
+ ce_page_mac_to_entry (nm_setting_wireless_get_bssid (setting), priv->bssid);
g_signal_connect_swapped (priv->bssid, "changed", G_CALLBACK (ce_page_changed), self);
/* MAC address */
- ce_page_mac_to_entry (setting->mac_address, priv->mac);
+ ce_page_mac_to_entry (nm_setting_wireless_get_mac_address (setting), priv->mac);
g_signal_connect_swapped (priv->mac, "changed", G_CALLBACK (ce_page_changed), self);
- gtk_spin_button_set_value (priv->rate, (gdouble) setting->rate);
- gtk_spin_button_set_value (priv->tx_power, (gdouble) setting->tx_power);
- gtk_spin_button_set_value (priv->mtu, (gdouble) setting->mtu);
+ gtk_spin_button_set_value (priv->rate, (gdouble) nm_setting_wireless_get_rate (setting));
+ gtk_spin_button_set_value (priv->tx_power, (gdouble) nm_setting_wireless_get_tx_power (setting));
+ gtk_spin_button_set_value (priv->mtu, (gdouble) nm_setting_wireless_get_mtu (setting));
}
CEPageWireless *
@@ -429,7 +438,7 @@
{
CEPageWireless *self = CE_PAGE_WIRELESS (page);
CEPageWirelessPrivate *priv = CE_PAGE_WIRELESS_GET_PRIVATE (self);
- char *security;
+ const char *security;
gboolean success;
gboolean invalid = FALSE;
GByteArray *ignore;
@@ -445,11 +454,11 @@
ui_to_setting (self);
/* A hack to not check the wireless security here */
- security = priv->setting->security;
- priv->setting->security = NULL;
+ security = nm_setting_wireless_get_security (priv->setting);
+ g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, NULL, NULL);
success = nm_setting_verify (NM_SETTING (priv->setting), NULL, error);
- priv->setting->security = security;
+ g_object_set (priv->setting, NM_SETTING_WIRELESS_SEC, security, NULL);
return success;
}
Modified: trunk/src/gconf-helpers/gconf-upgrade.c
==============================================================================
--- trunk/src/gconf-helpers/gconf-upgrade.c (original)
+++ trunk/src/gconf-helpers/gconf-upgrade.c Tue Oct 28 19:27:31 2008
@@ -336,9 +336,11 @@
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
NMSetting8021x *s_8021x = NULL;
+ GByteArray *ssid;
char *path, *network, *essid = NULL;
char *s;
int timestamp, we_cipher;
+ GSList *iter;
GSList *bssids = NULL;
char *private_key_path = NULL, *client_cert_path = NULL, *ca_cert_path = NULL;
@@ -374,14 +376,23 @@
g_free (s);
s_wireless = (NMSettingWireless *)nm_setting_wireless_new ();
- s_wireless->ssid = g_byte_array_new ();
- g_byte_array_append (s_wireless->ssid, (unsigned char *)essid, strlen (essid));
+
+ ssid = g_byte_array_new ();
+ g_byte_array_append (ssid, (unsigned char *)essid, strlen (essid));
g_free (essid);
- s_wireless->mode = g_strdup ("infrastructure");
- s_wireless->seen_bssids = bssids;
+ g_object_set (s_wireless,
+ NM_SETTING_WIRELESS_SSID, ssid,
+ NM_SETTING_WIRELESS_MODE, "infrastructure",
+ NULL);
+ g_byte_array_free (ssid, TRUE);
+
+ 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) {
- s_wireless->security = g_strdup ("802-11-wireless-security");
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
switch (we_cipher) {
case NM_AUTH_TYPE_WEP40:
Modified: trunk/src/utils/utils.c
==============================================================================
--- trunk/src/utils/utils.c (original)
+++ trunk/src/utils/utils.c Tue Oct 28 19:27:31 2008
@@ -461,8 +461,10 @@
{
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
- const GByteArray *ssid;
- NM80211Mode mode;
+ const GByteArray *setting_bssid;
+ const char *setting_mode;
+ const char *setting_band;
+ NM80211Mode ap_mode;
guint32 freq;
g_return_val_if_fail (NM_IS_ACCESS_POINT (ap), FALSE);
@@ -472,35 +474,37 @@
if (s_wireless == NULL)
return FALSE;
- ssid = nm_access_point_get_ssid (ap);
- if (!nm_utils_same_ssid (s_wireless->ssid, ssid, TRUE))
+ if (!nm_utils_same_ssid (nm_setting_wireless_get_ssid (s_wireless), nm_access_point_get_ssid (ap), TRUE))
return FALSE;
- if (s_wireless->bssid) {
+ setting_bssid = nm_setting_wireless_get_bssid (s_wireless);
+ if (setting_bssid) {
struct ether_addr ap_addr;
if (ether_aton_r (nm_access_point_get_hw_address (ap), &ap_addr)) {
- if (memcmp (s_wireless->bssid->data, &ap_addr, ETH_ALEN))
+ if (memcmp (setting_bssid->data, &ap_addr, ETH_ALEN))
return FALSE;
}
}
- mode = nm_access_point_get_mode (ap);
- if (s_wireless->mode) {
- if ( !strcmp (s_wireless->mode, "infrastructure")
- && (mode != NM_802_11_MODE_INFRA))
+ ap_mode = nm_access_point_get_mode (ap);
+ setting_mode = nm_setting_wireless_get_mode (s_wireless);
+ if (setting_mode) {
+ if ( !strcmp (setting_mode, "infrastructure")
+ && (ap_mode != NM_802_11_MODE_INFRA))
return FALSE;
- if ( !strcmp (s_wireless->mode, "adhoc")
- && (mode != NM_802_11_MODE_ADHOC))
+ if ( !strcmp (setting_mode, "adhoc")
+ && (ap_mode != NM_802_11_MODE_ADHOC))
return FALSE;
}
freq = nm_access_point_get_frequency (ap);
- if (s_wireless->band) {
- if (!strcmp (s_wireless->band, "a")) {
+ setting_band = nm_setting_wireless_get_band (s_wireless);
+ if (setting_band) {
+ if (!strcmp (setting_band, "a")) {
if (freq < 5170 || freq > 5825)
return FALSE;
- } else if (!strcmp (s_wireless->band, "bg")) {
+ } else if (!strcmp (setting_band, "bg")) {
if (freq < 2412 || freq > 2472)
return FALSE;
}
@@ -572,6 +576,8 @@
NMDeviceWifi *wdev = NM_DEVICE_WIFI (device);
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
+ const GByteArray *setting_mac;
+ const char *setting_security;
guint32 wcaps;
NMAccessPoint *ap;
@@ -582,7 +588,8 @@
g_return_val_if_fail (s_wireless != NULL, FALSE);
/* Match MAC address */
- if (s_wireless->mac_address) {
+ setting_mac = nm_setting_wireless_get_mac_address (s_wireless);
+ if (setting_mac) {
const char *str_mac;
struct ether_addr *bin_mac;
@@ -592,7 +599,7 @@
bin_mac = ether_aton (str_mac);
g_return_val_if_fail (bin_mac != NULL, FALSE);
- if (memcmp (bin_mac->ether_addr_octet, s_wireless->mac_address->data, ETH_ALEN))
+ if (memcmp (bin_mac->ether_addr_octet, setting_mac->data, ETH_ALEN))
return FALSE;
}
@@ -605,7 +612,8 @@
return FALSE;
}
- if (!s_wireless->security || strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
+ setting_security = nm_setting_wireless_get_security (s_wireless);
+ if (!setting_security || strcmp (setting_security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
return TRUE; /* all devices can do unencrypted networks */
s_wireless_sec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
Modified: trunk/src/wireless-dialog.c
==============================================================================
--- trunk/src/wireless-dialog.c (original)
+++ trunk/src/wireless-dialog.c Tue Oct 28 19:27:31 2008
@@ -235,7 +235,7 @@
NMSettingWireless *s_wireless;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- ssid = s_wireless->ssid;
+ ssid = (GByteArray *) nm_setting_wireless_get_ssid (s_wireless);
free_ssid = FALSE;
} else {
ssid = validate_dialog_ssid (self);
@@ -311,8 +311,11 @@
widget = glade_xml_get_widget (priv->xml, "network_name_entry");
if (priv->connection) {
+ const GByteArray *ssid;
+
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
- utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
+ ssid = nm_setting_wireless_get_ssid (s_wireless);
+ utf8_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
gtk_entry_set_text (GTK_ENTRY (widget), utf8_ssid);
g_free (utf8_ssid);
} else {
@@ -420,6 +423,8 @@
NMConnection *candidate = NM_CONNECTION (iter->data);
NMSettingWireless *s_wireless;
const char *connection_type;
+ const char *mode;
+ const GByteArray *setting_mac;
s_con = NM_SETTING_CONNECTION (nm_connection_get_setting (candidate, NM_TYPE_SETTING_CONNECTION));
connection_type = s_con ? nm_setting_connection_get_connection_type (s_con) : NULL;
@@ -442,12 +447,14 @@
continue;
/* Ignore non-Ad-Hoc connections too */
- if (!s_wireless->mode || strcmp (s_wireless->mode, "adhoc"))
+ mode = nm_setting_wireless_get_mode (s_wireless);
+ if (!mode || strcmp (mode, "adhoc"))
continue;
}
/* Ignore connections that don't apply to the selected device */
- if (s_wireless->mac_address) {
+ setting_mac = nm_setting_wireless_get_mac_address (s_wireless);
+ if (setting_mac) {
const char *hw_addr;
hw_addr = nm_device_wifi_get_hw_address (NM_DEVICE_WIFI (priv->device));
@@ -455,7 +462,7 @@
struct ether_addr *ether;
ether = ether_aton (hw_addr);
- if (ether && memcmp (s_wireless->mac_address->data, ether->ether_addr_octet, ETH_ALEN))
+ if (ether && memcmp (setting_mac->data, ether->ether_addr_octet, ETH_ALEN))
continue;
}
}
@@ -714,13 +721,20 @@
}
if (priv->connection) {
+ const char *mode;
+ const char *security;
+
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
- if (s_wireless && s_wireless->mode && !strcmp (s_wireless->mode, "adhoc"))
+
+ mode = nm_setting_wireless_get_mode (s_wireless);
+ if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (priv->connection,
NM_TYPE_SETTING_WIRELESS_SECURITY));
- if (!s_wireless->security || strcmp (s_wireless->security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
+
+ security = nm_setting_wireless_get_security (s_wireless);
+ if (!security || strcmp (security, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME))
wsec = NULL;
if (wsec)
default_type = get_default_type_for_security (wsec, !!priv->ap, ap_flags, dev_caps);
@@ -933,10 +947,12 @@
char *tmp;
char *esc_ssid = NULL;
NMSettingWireless *s_wireless;
+ const GByteArray *ssid;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (priv->connection, NM_TYPE_SETTING_WIRELESS));
- if (s_wireless && s_wireless->ssid)
- esc_ssid = nm_utils_ssid_to_utf8 ((const char *) s_wireless->ssid->data, s_wireless->ssid->len);
+ ssid = s_wireless ? nm_setting_wireless_get_ssid (s_wireless) : NULL;
+ if (ssid)
+ esc_ssid = nm_utils_ssid_to_utf8 ((const char *) ssid->data, ssid->len);
tmp = g_strdup_printf (_("Passwords or encryption keys are required to access the wireless network '%s'."),
esc_ssid ? esc_ssid : "<unknown>");
@@ -1000,13 +1016,12 @@
nm_connection_add_setting (connection, (NMSetting *) s_con);
s_wireless = (NMSettingWireless *) nm_setting_wireless_new ();
- s_wireless->ssid = validate_dialog_ssid (self);
- g_assert (s_wireless->ssid);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SSID, validate_dialog_ssid (self), NULL);
if (priv->adhoc_create) {
NMSettingIP4Config *s_ip4;
- s_wireless->mode = g_strdup ("adhoc");
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_MODE, "adhoc", NULL);
s_ip4 = (NMSettingIP4Config *) nm_setting_ip4_config_new ();
s_ip4->method = g_strdup ("shared");
@@ -1029,10 +1044,7 @@
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- if (s_wireless->security) {
- g_free (s_wireless->security);
- s_wireless->security = NULL;
- }
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NULL, NULL);
}
/* Fill device */
Modified: trunk/src/wireless-security/wireless-security.c
==============================================================================
--- trunk/src/wireless-security/wireless-security.c (original)
+++ trunk/src/wireless-security/wireless-security.c Tue Oct 28 19:27:31 2008
@@ -384,9 +384,7 @@
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- if (s_wireless->security)
- g_free (s_wireless->security);
- s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
/* Blow away the old wireless security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
Modified: trunk/src/wireless-security/ws-leap.c
==============================================================================
--- trunk/src/wireless-security/ws-leap.c (original)
+++ trunk/src/wireless-security/ws-leap.c Tue Oct 28 19:27:31 2008
@@ -92,9 +92,7 @@
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- if (s_wireless->security)
- g_free (s_wireless->security);
- s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
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 Tue Oct 28 19:27:31 2008
@@ -182,9 +182,7 @@
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- if (s_wireless->security)
- g_free (s_wireless->security);
- s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
@@ -342,9 +340,11 @@
if (connection) {
NMSettingWireless *s_wireless;
+ const char *mode;
s_wireless = (NMSettingWireless *) nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS);
- if (s_wireless && s_wireless->mode && !strcmp (s_wireless->mode, "adhoc"))
+ mode = s_wireless ? nm_setting_wireless_get_mode (s_wireless) : NULL;
+ if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
s_wsec = NM_SETTING_WIRELESS_SECURITY (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS_SECURITY));
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 Tue Oct 28 19:27:31 2008
@@ -102,18 +102,17 @@
guint32 len;
NMSettingWireless *s_wireless;
NMSettingWirelessSecurity *s_wireless_sec;
+ const char *mode;
gboolean is_adhoc = FALSE;
s_wireless = NM_SETTING_WIRELESS (nm_connection_get_setting (connection, NM_TYPE_SETTING_WIRELESS));
g_assert (s_wireless);
- g_assert (s_wireless->ssid);
- if (s_wireless && s_wireless->mode && !strcmp (s_wireless->mode, "adhoc"))
+ mode = nm_setting_wireless_get_mode (s_wireless);
+ if (mode && !strcmp (mode, "adhoc"))
is_adhoc = TRUE;
- if (s_wireless->security)
- g_free (s_wireless->security);
- s_wireless->security = g_strdup (NM_SETTING_WIRELESS_SECURITY_SETTING_NAME);
+ g_object_set (s_wireless, NM_SETTING_WIRELESS_SEC, NM_SETTING_WIRELESS_SECURITY_SETTING_NAME, NULL);
/* Blow away the old security setting by adding a clear one */
s_wireless_sec = (NMSettingWirelessSecurity *) nm_setting_wireless_security_new ();
@@ -128,9 +127,10 @@
hashed = g_strdup (key);
} else {
/* passphrase */
+ const GByteArray *ssid = nm_setting_wireless_get_ssid (s_wireless);
unsigned char *buf = g_malloc0 (WPA_PMK_LEN * 2);
- pbkdf2_sha1 (key, (char *) s_wireless->ssid->data, s_wireless->ssid->len,
- 4096, buf, WPA_PMK_LEN);
+
+ pbkdf2_sha1 (key, (char *) ssid->data, ssid->len, 4096, buf, WPA_PMK_LEN);
hashed = utils_bin2hexstr ((const char *) buf, WPA_PMK_LEN, WPA_PMK_LEN * 2);
g_free (buf);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]