3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-12-23 06:02:37 +01:00

network: Rely on known_networks added event

This commit is contained in:
Denis Kenzior 2019-08-09 12:38:28 -05:00
parent 0e77bf1c39
commit 2c30a2f7ff
3 changed files with 20 additions and 16 deletions

View File

@ -149,8 +149,11 @@ static void known_network_update(struct network_info *orig_network,
if (orig_network) if (orig_network)
network = orig_network; network = orig_network;
else else {
network = network_info_add_known(ssid, security); network = l_new(struct network_info, 1);
strcpy(network->ssid, ssid);
network->type = security;
}
if (util_timespec_compare(&network->connected_time, connected_time) && if (util_timespec_compare(&network->connected_time, connected_time) &&
orig_network) { orig_network) {
@ -194,8 +197,11 @@ static void known_network_update(struct network_info *orig_network,
return; return;
l_queue_insert(known_networks, network, connected_time_compare, NULL); l_queue_insert(known_networks, network, connected_time_compare, NULL);
known_network_register_dbus(network); known_network_register_dbus(network);
WATCHLIST_NOTIFY(&known_network_watches,
known_networks_watch_func_t,
KNOWN_NETWORKS_EVENT_ADDED, network);
} }
bool known_networks_foreach(known_networks_foreach_func_t function, bool known_networks_foreach(known_networks_foreach_func_t function,

View File

@ -1344,18 +1344,18 @@ static void emit_known_network_changed(struct station *station, void *user_data)
IWD_NETWORK_INTERFACE, "KnownNetwork"); IWD_NETWORK_INTERFACE, "KnownNetwork");
} }
struct network_info *network_info_add_known(const char *ssid, static void match_known_network(struct station *station, void *user_data)
enum security security)
{ {
struct network_info *network; struct network_info *info = user_data;
struct network *network = station_network_find(station,
info->ssid, info->type);
network = l_new(struct network_info, 1); if (!network)
strcpy(network->ssid, ssid); return;
network->type = security;
station_foreach(emit_known_network_changed, network); network->info = info;
l_dbus_property_changed(dbus_get_bus(), network_get_path(network),
return network; IWD_NETWORK_INTERFACE, "KnownNetwork");
} }
static void disconnect_no_longer_known(struct station *station, void *user_data) static void disconnect_no_longer_known(struct station *station, void *user_data)
@ -1375,10 +1375,11 @@ static void known_networks_changed(enum known_networks_event event,
{ {
switch (event) { switch (event) {
case KNOWN_NETWORKS_EVENT_ADDED: case KNOWN_NETWORKS_EVENT_ADDED:
station_foreach(match_known_network, (void *) info);
break; break;
case KNOWN_NETWORKS_EVENT_REMOVED: case KNOWN_NETWORKS_EVENT_REMOVED:
station_foreach(emit_known_network_changed, (void *) info);
station_foreach(disconnect_no_longer_known, (void *) info); station_foreach(disconnect_no_longer_known, (void *) info);
station_foreach(emit_known_network_changed, (void *) info);
break; break;
} }
} }

View File

@ -85,6 +85,3 @@ struct network_info {
bool is_hidden:1; bool is_hidden:1;
bool is_autoconnectable:1; bool is_autoconnectable:1;
}; };
struct network_info *network_info_add_known(const char *ssid,
enum security security);