2008-04-17 Dan Williams <dcbw@redhat.com>

* src/nm-device-802-11-wireless.c
		- (state_changed_cb): clear AP list when device transitions to
			unavailable or unmanaged
		- (nm_device_802_11_wireless_dispose): remove redundant set_current_ap()
			since this is already done in device_cleanup()
		- (supplicant_iface_scanned_ap_cb): don't leak new APs when the device
			isn't available or managed
		- (device_cleanup): use remove_all_aps()
		- (remove_all_aps): consolidate code removing all APs



git-svn-id: http://svn-archive.gnome.org/svn/NetworkManager/trunk@3572 4912f4e0-d625-0410-9fb7-b9a5a253dbdc
This commit is contained in:
Dan Williams 2008-04-17 17:09:59 +00:00
parent 3b9eccd1bc
commit e2e9680e7d
2 changed files with 46 additions and 8 deletions

View file

@ -1,3 +1,15 @@
2008-04-17 Dan Williams <dcbw@redhat.com>
* src/nm-device-802-11-wireless.c
- (state_changed_cb): clear AP list when device transitions to
unavailable or unmanaged
- (nm_device_802_11_wireless_dispose): remove redundant set_current_ap()
since this is already done in device_cleanup()
- (supplicant_iface_scanned_ap_cb): don't leak new APs when the device
isn't available or managed
- (device_cleanup): use remove_all_aps()
- (remove_all_aps): consolidate code removing all APs
2008-04-17 Dan Williams <dcbw@redhat.com>
* src/nm-serial-device.c

View file

@ -759,6 +759,23 @@ real_bring_up (NMDevice *dev)
return TRUE;
}
static void
remove_all_aps (NMDevice80211Wireless *self)
{
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
/* Remove outdated APs */
while (g_slist_length (priv->ap_list)) {
NMAccessPoint *ap = NM_AP (priv->ap_list->data);
access_point_removed (self, ap);
priv->ap_list = g_slist_remove (priv->ap_list, ap);
g_object_unref (ap);
}
g_slist_free (priv->ap_list);
priv->ap_list = NULL;
}
static void
device_cleanup (NMDevice80211Wireless *self)
{
@ -791,11 +808,8 @@ device_cleanup (NMDevice80211Wireless *self)
priv->supplicant.mgr = NULL;
}
g_slist_foreach (self->priv->ap_list, (GFunc) g_object_unref, NULL);
g_slist_free (self->priv->ap_list);
self->priv->ap_list = NULL;
set_current_ap (self, NULL);
remove_all_aps (self);
}
static void
@ -1819,16 +1833,22 @@ set_ap_strength_from_properties (NMDevice80211Wireless *self,
}
static void
supplicant_iface_scanned_ap_cb (NMSupplicantInterface * iface,
supplicant_iface_scanned_ap_cb (NMSupplicantInterface *iface,
GHashTable *properties,
NMDevice80211Wireless * self)
NMDevice80211Wireless *self)
{
NMDeviceState state;
NMAccessPoint *ap;
g_return_if_fail (self != NULL);
g_return_if_fail (properties != NULL);
g_return_if_fail (iface != NULL);
/* Ignore new APs when unavailable or unamnaged */
state = nm_device_get_state (NM_DEVICE (self));
if (state <= NM_DEVICE_STATE_UNAVAILABLE)
return;
ap = nm_ap_new_from_properties (properties);
if (!ap)
return;
@ -2983,8 +3003,6 @@ nm_device_802_11_wireless_dispose (GObject *object)
device_cleanup (self);
set_current_ap (self, NULL);
if (priv->state_to_disconnected_id) {
g_source_remove (priv->state_to_disconnected_id);
priv->state_to_disconnected_id = 0;
@ -3148,6 +3166,7 @@ state_changed_cb (NMDevice *device, NMDeviceState state, gpointer user_data)
{
NMDevice80211Wireless *self = NM_DEVICE_802_11_WIRELESS (device);
NMDevice80211WirelessPrivate *priv = NM_DEVICE_802_11_WIRELESS_GET_PRIVATE (self);
gboolean clear_aps = FALSE;
/* Remove any previous delayed transition to disconnected */
if (priv->state_to_disconnected_id) {
@ -3156,6 +3175,9 @@ state_changed_cb (NMDevice *device, NMDeviceState state, gpointer user_data)
}
switch (state) {
case NM_DEVICE_STATE_UNMANAGED:
clear_aps = TRUE;
break;
case NM_DEVICE_STATE_UNAVAILABLE:
/* If transitioning to UNAVAILBLE and the device is not rfkilled,
* transition to DISCONNECTED because the device is ready to use.
@ -3164,6 +3186,7 @@ state_changed_cb (NMDevice *device, NMDeviceState state, gpointer user_data)
*/
if (priv->enabled)
priv->state_to_disconnected_id = g_idle_add (unavailable_to_disconnected, self);
clear_aps = TRUE;
break;
case NM_DEVICE_STATE_ACTIVATED:
activation_success_handler (device);
@ -3177,6 +3200,9 @@ state_changed_cb (NMDevice *device, NMDeviceState state, gpointer user_data)
default:
break;
}
if (clear_aps)
remove_all_aps (self);
}