diff --git a/src/device.c b/src/device.c index 50d6410c..752c002a 100644 --- a/src/device.c +++ b/src/device.c @@ -83,38 +83,13 @@ static bool device_is_busy(struct device *device) return station_is_busy(device->station); } -static void device_reset_connection_state(struct device *device) -{ - struct station *station = device->station; - struct network *network = station->connected_network; - struct l_dbus *dbus = dbus_get_bus(); - - if (!network) - return; - - if (station->state == STATION_STATE_CONNECTED || - station->state == STATION_STATE_CONNECTING || - station->state == STATION_STATE_ROAMING) - network_disconnected(network); - - station_roam_state_clear(station); - - station->connected_bss = NULL; - station->connected_network = NULL; - - l_dbus_property_changed(dbus, netdev_get_path(device->netdev), - IWD_DEVICE_INTERFACE, "ConnectedNetwork"); - l_dbus_property_changed(dbus, network_get_path(network), - IWD_NETWORK_INTERFACE, "Connected"); -} - void device_disassociated(struct device *device) { struct station *station = device->station; l_debug("%d", device->index); - device_reset_connection_state(device); + station_reset_connection_state(station); station_enter_state(station, STATION_STATE_DISCONNECTED); @@ -593,7 +568,7 @@ int device_disconnect(struct device *device) * connected so we may as well indicate now that we're no longer * connected. */ - device_reset_connection_state(device); + station_reset_connection_state(station); station_enter_state(station, STATION_STATE_DISCONNECTING); @@ -1315,8 +1290,6 @@ static void device_netdev_notify(struct netdev *netdev, dbus_pending_reply(&device->connect_pending, dbus_error_aborted(device->connect_pending)); - device_reset_connection_state(device); - l_dbus_property_changed(dbus, netdev_get_path(device->netdev), IWD_DEVICE_INTERFACE, "Powered"); break; diff --git a/src/station.c b/src/station.c index 98bbc549..d1cf2c38 100644 --- a/src/station.c +++ b/src/station.c @@ -668,7 +668,7 @@ bool station_set_autoconnect(struct station *station, bool autoconnect) return true; } -void station_roam_state_clear(struct station *station) +static void station_roam_state_clear(struct station *station) { l_timeout_remove(station->roam_trigger_timeout); station->roam_trigger_timeout = NULL; @@ -1232,6 +1232,30 @@ void station_ok_rssi(struct station *station) station->signal_low = false; } +void station_reset_connection_state(struct station *station) +{ + struct network *network = station->connected_network; + struct l_dbus *dbus = dbus_get_bus(); + + if (!network) + return; + + if (station->state == STATION_STATE_CONNECTED || + station->state == STATION_STATE_CONNECTING || + station->state == STATION_STATE_ROAMING) + network_disconnected(network); + + station_roam_state_clear(station); + + station->connected_bss = NULL; + station->connected_network = NULL; + + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_DEVICE_INTERFACE, "ConnectedNetwork"); + l_dbus_property_changed(dbus, network_get_path(network), + IWD_NETWORK_INTERFACE, "Connected"); +} + static void station_dbus_scan_triggered(int err, void *user_data) { struct station *station = user_data; diff --git a/src/station.h b/src/station.h index 67bec501..051beba9 100644 --- a/src/station.h +++ b/src/station.h @@ -99,7 +99,6 @@ bool station_remove_state_watch(struct station *station, uint32_t id); bool station_set_autoconnect(struct station *station, bool autoconnect); -void station_roam_state_clear(struct station *station); void station_roam_failed(struct station *station); void station_roamed(struct station *station); void station_lost_beacon(struct station *station); @@ -110,6 +109,8 @@ void station_ap_directed_roam(struct station *station, void station_low_rssi(struct station *station); void station_ok_rssi(struct station *station); +void station_reset_connection_state(struct station *station); + struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data);