cosmic-applets/applets/cosmic-applet-network/src/ui/current_networks.rs

30 lines
964 B
Rust
Raw Normal View History

2022-02-02 12:31:30 -05:00
// SPDX-License-Identifier: LGPL-3.0-or-later
2022-02-04 13:44:37 -05:00
use cosmic_dbus_networkmanager::{
access_point::AccessPoint, device::wired::WiredDevice, nm::NetworkManager,
};
use gtk4::glib::{self, clone, source::PRIORITY_DEFAULT, MainContext, Sender};
use zbus::Connection;
2022-02-02 12:31:30 -05:00
2022-02-07 11:13:34 -05:00
pub fn add_current_networks(target: &gtk4::Box) {
crate::task::spawn(handle_devices());
}
2022-02-04 13:44:37 -05:00
fn add_vpn(target: &gtk4::Box) {}
fn add_access_point(target: &gtk4::Box, access_point: &AccessPoint) {}
fn add_wired_device(target: &gtk4::Box, device: &WiredDevice) {}
async fn handle_devices() -> zbus::Result<()> {
let conn = Connection::system().await?;
let network_manager = NetworkManager::new(&conn).await?;
loop {
2022-02-07 11:13:34 -05:00
let active_connections = network_manager.active_connections().await?;
for connection in active_connections {
eprintln!("{}", connection.type_().await?);
}
2022-02-04 13:44:37 -05:00
tokio::time::sleep(std::time::Duration::from_secs(5)).await;
}
}