From 94d4b341e3990324fd18a6e9cf5de7986a3d1770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alvin=20=C5=A0ipraga?= Date: Fri, 14 Aug 2020 15:40:32 +0200 Subject: [PATCH] station: refresh ordered network list on (dis)connect Doing so ensures that the currently connected network is always at the beginning of the list. Previously, the list would only get updated after a scan. This fixes the documented behaviour of GetOrderedNetworks() DBus method, which states that the currently connected network is always at the beginning of the returned array. --- src/station.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/station.c b/src/station.c index 42d60942..a0ec4038 100644 --- a/src/station.c +++ b/src/station.c @@ -1195,6 +1195,12 @@ static void station_enter_state(struct station *station, new_scan_results, station); break; case STATION_STATE_CONNECTING: + /* Refresh the ordered network list */ + network_rank_update(station->connected_network, true); + l_queue_remove(station->networks_sorted, station->connected_network); + l_queue_insert(station->networks_sorted, station->connected_network, + network_rank_compare, NULL); + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); l_dbus_property_changed(dbus, @@ -1295,6 +1301,12 @@ static void station_reset_connection_state(struct station *station) station->connected_bss = NULL; station->connected_network = NULL; + /* Refresh the ordered network list */ + network_rank_update(station->connected_network, false); + l_queue_remove(station->networks_sorted, station->connected_network); + l_queue_insert(station->networks_sorted, station->connected_network, + network_rank_compare, NULL); + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); l_dbus_property_changed(dbus, network_get_path(network),