chore: align applets with local stack
This commit is contained in:
parent
1c7143af97
commit
6c24edfae2
39 changed files with 165 additions and 313 deletions
|
|
@ -2,7 +2,6 @@ use anyhow::Context;
|
|||
use cosmic_dbus_networkmanager::settings::{NetworkManagerSettings, connection::Settings};
|
||||
use cosmic_settings_network_manager_subscription::{
|
||||
self as network_manager, NetworkManagerState, UUID,
|
||||
active_conns::active_conns_subscription,
|
||||
available_wifi::{AccessPoint, NetworkType},
|
||||
current_networks::ActiveConnectionInfo,
|
||||
hw_address::HwAddress,
|
||||
|
|
@ -15,7 +14,6 @@ use std::{
|
|||
borrow::Cow,
|
||||
collections::{BTreeMap, BTreeSet},
|
||||
sync::{Arc, LazyLock},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use cosmic::{
|
||||
|
|
@ -33,17 +31,14 @@ use cosmic::{
|
|||
},
|
||||
surface, theme,
|
||||
widget::{
|
||||
Column, Id, Row, button, column, container, divider,
|
||||
Id, button, column, container, divider,
|
||||
icon::{self, from_name},
|
||||
row, scrollable, secure_input, text, text_input, toggler,
|
||||
},
|
||||
};
|
||||
use cosmic_dbus_networkmanager::interface::{
|
||||
access_point,
|
||||
enums::{ActiveConnectionState, DeviceState, NmConnectivityState, NmState},
|
||||
};
|
||||
use cosmic_dbus_networkmanager::interface::enums::{ActiveConnectionState, DeviceState, NmConnectivityState};
|
||||
|
||||
use futures::{StreamExt, channel::mpsc::TrySendError};
|
||||
use futures::StreamExt;
|
||||
use zbus::{Connection, zvariant::ObjectPath};
|
||||
|
||||
use crate::{config, fl};
|
||||
|
|
@ -74,6 +69,7 @@ impl NewConnectionState {
|
|||
}
|
||||
.ssid
|
||||
}
|
||||
#[allow(dead_code)]
|
||||
pub fn hw_address(&self) -> HwAddress {
|
||||
match self {
|
||||
Self::EnterPassword { access_point, .. } => access_point,
|
||||
|
|
@ -96,6 +92,7 @@ impl From<NewConnectionState> for AccessPoint {
|
|||
|
||||
pub static SECURE_INPUT_WIFI: LazyLock<Id> = LazyLock::new(Id::unique);
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Default, Debug, Clone)]
|
||||
pub struct MyNetworkState {
|
||||
pub known_vpns: IndexMap<UUID, ConnectionSettings>,
|
||||
|
|
@ -107,6 +104,7 @@ pub struct MyNetworkState {
|
|||
pub requested_vpn: Option<RequestedVpn>,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct RequestedVpn {
|
||||
name: String,
|
||||
|
|
@ -123,6 +121,7 @@ pub enum ConnectionSettings {
|
|||
Wireguard { id: String },
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct VpnConnectionSettings {
|
||||
id: String,
|
||||
|
|
@ -136,6 +135,7 @@ enum ConnectionType {
|
|||
Password,
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl VpnConnectionSettings {
|
||||
fn password_flag(&self) -> Option<PasswordFlag> {
|
||||
self.connection_type
|
||||
|
|
@ -366,15 +366,12 @@ impl CosmicNetworkApplet {
|
|||
}
|
||||
|
||||
fn update_togglers(&mut self, state: &NetworkManagerState) {
|
||||
let mut changed = false;
|
||||
if self.nm_state.nm_state.wifi_enabled != state.wifi_enabled {
|
||||
self.nm_state.nm_state.wifi_enabled = state.wifi_enabled;
|
||||
changed = true;
|
||||
}
|
||||
|
||||
if self.nm_state.nm_state.airplane_mode != state.airplane_mode {
|
||||
self.nm_state.nm_state.airplane_mode = state.airplane_mode;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -447,6 +444,7 @@ impl CosmicNetworkApplet {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[allow(dead_code)]
|
||||
pub(crate) enum Message {
|
||||
TogglePopup,
|
||||
CloseRequested(window::Id),
|
||||
|
|
@ -501,8 +499,9 @@ pub(crate) enum Message {
|
|||
SelectDevice(Option<Arc<network_manager::devices::DeviceInfo>>),
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug, Clone)]
|
||||
struct Password {
|
||||
pub(crate) struct Password {
|
||||
ssid: network_manager::SSID,
|
||||
hw_address: HwAddress,
|
||||
identity: Option<String>,
|
||||
|
|
@ -759,7 +758,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
const APP_ID: &'static str = config::APP_ID;
|
||||
|
||||
fn init(core: cosmic::app::Core, _flags: ()) -> (Self, app::Task<Message>) {
|
||||
let mut applet = Self {
|
||||
let applet = Self {
|
||||
core,
|
||||
icon_name: "network-wired-disconnected-symbolic".to_string(),
|
||||
token_tx: None,
|
||||
|
|
@ -1153,9 +1152,9 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
} => {
|
||||
if let network_manager::Request::SelectAccessPoint(
|
||||
ssid,
|
||||
hw_address,
|
||||
_hw_address,
|
||||
_network_type,
|
||||
secret_tx,
|
||||
_secret_tx,
|
||||
) = &req
|
||||
{
|
||||
let conn_match = self
|
||||
|
|
@ -1168,7 +1167,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
.active_conns
|
||||
.iter_mut()
|
||||
.find(|ap| {
|
||||
let ap_hw_address = match ap {
|
||||
let _ap_hw_address = match ap {
|
||||
ActiveConnectionInfo::Wired { hw_address, .. }
|
||||
| ActiveConnectionInfo::WiFi { hw_address, .. } => {
|
||||
HwAddress::from_str(&hw_address).unwrap()
|
||||
|
|
@ -1192,8 +1191,8 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
ssid,
|
||||
identity: _,
|
||||
password: _,
|
||||
secret_tx,
|
||||
interface
|
||||
secret_tx: _,
|
||||
interface: _
|
||||
} = &req
|
||||
{
|
||||
if let Some(NewConnectionState::Waiting(access_point)) =
|
||||
|
|
@ -1246,9 +1245,9 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
}
|
||||
}
|
||||
cosmic_settings_network_manager_subscription::Event::WiFiCredentials {
|
||||
ssid,
|
||||
password,
|
||||
security_type,
|
||||
ssid: _,
|
||||
password: _,
|
||||
security_type: _,
|
||||
} => {}
|
||||
},
|
||||
Message::NetworkManagerConnect(connection) => {
|
||||
|
|
@ -1441,7 +1440,7 @@ impl cosmic::Application for CosmicNetworkApplet {
|
|||
}
|
||||
ActiveConnectionInfo::Wired {
|
||||
name,
|
||||
hw_address,
|
||||
hw_address: _,
|
||||
speed,
|
||||
ip_addresses,
|
||||
} => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue