Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only display WPS hint when WPS push button mode is available #793

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions cosmic-applet-network/src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -981,30 +981,34 @@ impl cosmic::Application for CosmicNetworkApplet {
.spacing(12),
);
content = content.push(id);
let col = padded_control(
column![
text::body(fl!("enter-password")),
text_input::secure_input(
"",
password,
Some(Message::TogglePasswordVisibility),
*password_hidden,
)
.on_input(Message::Password)
.on_paste(Message::Password)
.on_submit(Message::SubmitPassword),
container(text::body(fl!("router-wps-button"))).padding(8),
row![
button::standard(fl!("cancel"))
.on_press(Message::CancelNewConnection),
button::suggested(fl!("connect")).on_press(Message::SubmitPassword)
]
.spacing(24)
]
.spacing(8)
.align_x(Alignment::Center),
let enter_password_col = column![
text::body(fl!("enter-password")),
text_input::secure_input(
"",
password,
Some(Message::TogglePasswordVisibility),
*password_hidden,
)
.on_input(Message::Password)
.on_paste(Message::Password)
.on_submit(Message::SubmitPassword)
.password(),
]
.push_maybe(
access_point
.wps_push
.then(|| container(text::body(fl!("router-wps-button"))).padding(8)),
)
.align_x(Alignment::Center);
.push(
row![
button::standard(fl!("cancel")).on_press(Message::CancelNewConnection),
button::suggested(fl!("connect")).on_press(Message::SubmitPassword)
]
.spacing(24),
);
let col =
padded_control(enter_password_col.spacing(8).align_x(Alignment::Center))
.align_x(Alignment::Center);
content = content.push(col);
}
NewConnectionState::Waiting(access_point) => {
Expand Down
8 changes: 7 additions & 1 deletion cosmic-applet-network/src/network_manager/available_wifi.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-or-later

use cosmic_dbus_networkmanager::{device::wireless::WirelessDevice, interface::enums::DeviceState};
use cosmic_dbus_networkmanager::{
device::wireless::WirelessDevice,
interface::enums::{ApFlags, DeviceState},
};

use futures_util::StreamExt;
use itertools::Itertools;
Expand Down Expand Up @@ -33,6 +36,7 @@ pub async fn handle_wireless_device(
let mut aps = HashMap::<String, AccessPoint>::new();
for ap in access_points {
let ssid = String::from_utf8_lossy(&ap.ssid().await?.clone()).into_owned();
let wps_push = ap.flags().await?.contains(ApFlags::WPS_PBC);
let strength = ap.strength().await?;
if let Some(access_point) = aps.get(&ssid) {
if access_point.strength > strength {
Expand All @@ -51,6 +55,7 @@ pub async fn handle_wireless_device(
.as_ref()
.and_then(|str_addr| HwAddress::from_str(str_addr))
.unwrap_or_default(),
wps_push,
},
);
}
Expand All @@ -69,4 +74,5 @@ pub struct AccessPoint {
pub working: bool,
pub path: ObjectPath<'static>,
pub hw_address: HwAddress,
pub wps_push: bool,
}
Loading