Skip to contentSkip to conversation

client: Fix missing Connected Network display

PATCH New Tim Kourt 1 participant 1 message Feb 6, 2020

lore
Share & tools
lore

Tim Kourt

author
#0 lore raw

PATCH 1/1 client: Fix missing Connected Network display

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(-)
client/station.c +15 -8
index b6b59239..86e18f06 100644
@@ -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();
 }
Signature · 1 line
2.13.6