Added UI for several wifi adapters

This commit is contained in:
András 2024-11-08 12:22:15 +02:00 committed by Michael Murphy
parent 7932be526d
commit b743c724ff
2 changed files with 7 additions and 2 deletions

View file

@ -7,7 +7,10 @@ use itertools::Itertools;
use std::collections::HashMap; use std::collections::HashMap;
use zbus::zvariant::ObjectPath; use zbus::zvariant::ObjectPath;
pub async fn handle_wireless_device(device: WirelessDevice<'_>) -> zbus::Result<Vec<AccessPoint>> { pub async fn handle_wireless_device(
device: WirelessDevice<'_>,
hw_address: Option<String>,
) -> zbus::Result<Vec<AccessPoint>> {
device.request_scan(HashMap::new()).await?; device.request_scan(HashMap::new()).await?;
let mut scan_changed = device.receive_last_scan_changed().await; let mut scan_changed = device.receive_last_scan_changed().await;
if let Some(t) = scan_changed.next().await { if let Some(t) = scan_changed.next().await {
@ -42,6 +45,7 @@ pub async fn handle_wireless_device(device: WirelessDevice<'_>) -> zbus::Result<
state, state,
working: false, working: false,
path: ap.inner().path().to_owned(), path: ap.inner().path().to_owned(),
hw_address: hw_address.as_ref().unwrap_or(&"".to_string()).clone(),
}, },
); );
} }
@ -59,4 +63,5 @@ pub struct AccessPoint {
pub state: DeviceState, pub state: DeviceState,
pub working: bool, pub working: bool,
pub path: ObjectPath<'static>, pub path: ObjectPath<'static>,
pub hw_address: String,
} }

View file

@ -353,7 +353,7 @@ impl NetworkManagerState {
if let Ok(Some(SpecificDevice::Wireless(wireless_device))) = if let Ok(Some(SpecificDevice::Wireless(wireless_device))) =
device.downcast_to_device().await device.downcast_to_device().await
{ {
handle_wireless_device(wireless_device) handle_wireless_device(wireless_device, device.hw_address().await.ok())
.await .await
.unwrap_or_default() .unwrap_or_default()
} else { } else {