Wireless Daemon for Linux
 help / color / mirror / Atom feed
* [PATCH] client: Fix missing Connected Network display
@ 2020-02-06 16:51 Tim Kourt
  0 siblings, 0 replies; only message in thread
From: Tim Kourt @ 2020-02-06 16:51 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 2241 bytes --]

The connected network wasn’t displayed correctly within Station
object when connection was created before the start of iwctl
due to object dependency and timing of the sequential parsing of
the Object Manager’s objects. The issue is corrected by storing
the network path and doing lookups of the network proxy objects
at the time of display.
---
 client/station.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/client/station.c b/client/station.c
index b6b59239..86e18f06 100644
--- a/client/station.c
+++ b/client/station.c
@@ -35,7 +35,7 @@
 struct station {
 	bool scanning;
 	char *state;
-	const struct proxy_interface *connected_network;
+	char *connected_network;
 };
 
 static void *station_create(void)
@@ -48,7 +48,7 @@ static void station_destroy(void *data)
 	struct station *station = data;
 
 	l_free(station->state);
-	station->connected_network = NULL;
+	l_free(station->connected_network);
 
 	l_free(station);
 }
@@ -106,14 +106,15 @@ static void update_connected_network(void *data,
 	struct station *station = data;
 	const char *path;
 
+	l_free(station->connected_network);
+
 	if (!l_dbus_message_iter_get_variant(variant, "o", &path)) {
 		station->connected_network = NULL;
 
 		return;
 	}
 
-	station->connected_network = proxy_interface_find(IWD_NETWORK_INTERFACE,
-									path);
+	station->connected_network = l_strdup(path);
 }
 
 static const struct proxy_interface_property station_properties[] = {
@@ -145,10 +146,16 @@ static void display_station(const char *device_name,
 	proxy_properties_display(proxy, caption, MARGIN, 20, 47);
 	l_free(caption);
 
-	if (station->connected_network)
-		display("%s%*s  %-*s%-*s\n", MARGIN, 8, "", 20,
-				"Connected network", 47,
-				network_get_name(station->connected_network));
+	if (station->connected_network) {
+		const struct proxy_interface *network_proxy =
+			proxy_interface_find(IWD_NETWORK_INTERFACE,
+						station->connected_network);
+
+		if (network_proxy)
+			display("%s%*s  %-*s%-*s\n", MARGIN, 8, "", 20,
+					"Connected network", 47,
+					network_get_name(network_proxy));
+	}
 
 	display_table_footer();
 }
-- 
2.13.6

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2020-02-06 16:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-02-06 16:51 [PATCH] client: Fix missing Connected Network display Tim Kourt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox