From ca270e9de27fec013a713058f0eb53f22627d774 Mon Sep 17 00:00:00 2001 From: Andrew Zaborowski Date: Thu, 9 Aug 2018 16:33:44 +0200 Subject: [PATCH] network: Drop actions to be handled by filesystem watch --- src/knownnetworks.c | 31 +------------------------------ src/knownnetworks.h | 1 - src/network.c | 26 +++++++------------------- 3 files changed, 8 insertions(+), 50 deletions(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index 5af818b9..5cf6b282 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -160,25 +160,6 @@ struct network_info *known_networks_find(const char *ssid, return l_queue_find(known_networks, network_info_match, &query); } -void known_networks_connected(struct network_info *network) -{ - bool is_new; - - is_new = !l_queue_remove(known_networks, network); - l_queue_push_head(known_networks, network); - - if (is_new && network->is_hidden) - num_known_hidden_networks++; - - if (is_new) - known_network_register_dbus(network); - else - l_dbus_property_changed(dbus_get_bus(), - iwd_known_network_get_path(network), - IWD_KNOWN_NETWORK_INTERFACE, - "LastConnectedTime"); -} - static struct l_dbus_message *known_network_forget(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data) @@ -186,19 +167,9 @@ static struct l_dbus_message *known_network_forget(struct l_dbus *dbus, struct network_info *network = user_data; struct l_dbus_message *reply; - if (network->is_hidden) - num_known_hidden_networks--; - - l_queue_remove(known_networks, network); - l_dbus_unregister_object(dbus, iwd_known_network_get_path(network)); + /* Other actions taken care of by the filesystem watch callback */ storage_network_remove(network->type, network->ssid); - /* - * network_info_forget_known will either re-add the network_info to - * its seen networks lists or call network_info_free. - */ - network_info_forget_known(network); - reply = l_dbus_message_new_method_return(message); l_dbus_message_set_arguments(reply, ""); diff --git a/src/knownnetworks.h b/src/knownnetworks.h index 46336cb1..e18b5a7f 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -31,7 +31,6 @@ bool known_networks_foreach(known_networks_foreach_func_t function, bool known_networks_has_hidden(void); struct network_info *known_networks_find(const char *ssid, enum security security); -void known_networks_connected(struct network_info *network); bool known_networks_init(void); void known_networks_exit(void); diff --git a/src/network.c b/src/network.c index 124bc861..ecab5860 100644 --- a/src/network.c +++ b/src/network.c @@ -119,6 +119,10 @@ void network_connected(struct network *network) { int err; + /* + * This triggers an update to network->info->connected_time and + * other possible actions in knownnetworks.c. + */ err = storage_network_touch(network_get_security(network), network->info->ssid); switch (err) { @@ -143,24 +147,8 @@ void network_connected(struct network *network) break; } - err = storage_network_get_mtime(network_get_security(network), - network->info->ssid, - &network->info->connected_time); - if (err < 0) - l_error("Error %i reading network timestamp", err); - l_queue_foreach_remove(network->secrets, network_secret_check_cacheable, network); - - /* - * If this is the first ever connection to this network, we move the - * network_info to the Known Networks list. Otherwise this only has - * the effect of updating the connected time on the Known Network - * and moving it to the top of the list for network_find_rank_index's - * purposes. - */ - l_queue_remove(networks, network->info); - known_networks_connected(network->info); } void network_disconnected(struct network *network) @@ -1000,9 +988,9 @@ void network_connect_new_hidden_network(struct network *network, l_debug(""); /* - * This is not a Known Network. If connection succeeds, - * known_networks_connected() is going to be called and will save - * this network as hidden and update the hidden networks count. + * This is not a Known Network. If connection succeeds, either + * network_sync_psk or network_connected will save this network + * as hidden and trigger an update to the hidden networks count. */ network->info->is_hidden = true;