mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-16 22:37:44 +02:00
fix: Use ssid over path for events
This commit is contained in:
parent
4a9f8bf90a
commit
c860fcddee
7 changed files with 532 additions and 46 deletions
|
@ -158,7 +158,7 @@ pub fn scan_for_wifi(wifi_box: Arc<WifiBox>) {
|
|||
let ssid = access_point.ssid.clone();
|
||||
let path = access_point.dbus_path.clone();
|
||||
let connected =
|
||||
imp.reset_current_wifi_device.borrow().active_access_point == path;
|
||||
imp.reset_current_wifi_device.borrow().active_access_point == ssid;
|
||||
let entry = WifiEntry::new(connected, access_point, imp);
|
||||
wifi_entries.insert(ssid, entry.clone());
|
||||
wifi_entries_path.insert(path, entry.clone());
|
||||
|
@ -294,7 +294,7 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
|||
return;
|
||||
}
|
||||
let connected = imp.reset_current_wifi_device.borrow().active_access_point
|
||||
== ir.access_point.dbus_path;
|
||||
== ir.access_point.ssid;
|
||||
let entry = WifiEntry::new(connected, ir.access_point, imp);
|
||||
wifi_entries.insert(ssid, entry.clone());
|
||||
wifi_entries_path.insert(path, entry.clone());
|
||||
|
@ -366,7 +366,7 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
|||
.borrow()
|
||||
.set_sensitive(false);
|
||||
}
|
||||
if ir.access_point.dbus_path
|
||||
if ir.access_point.ssid
|
||||
== imp.reset_current_wifi_device.borrow().active_access_point
|
||||
{
|
||||
entry_imp
|
||||
|
@ -403,7 +403,8 @@ pub fn start_event_listener(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) {
|
|||
for entry in wifi_entries.iter_mut() {
|
||||
let imp = entry.1.imp();
|
||||
let mut connected = imp.connected.borrow_mut();
|
||||
*connected = imp.access_point.borrow().dbus_path == current_device.path;
|
||||
*connected =
|
||||
imp.access_point.borrow().ssid == current_device.active_access_point;
|
||||
if *connected {
|
||||
imp.reset_wifi_connected.borrow().set_text("Connected");
|
||||
} else {
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::ops::Deref;
|
|||
use std::sync::Arc;
|
||||
use std::time::Duration;
|
||||
|
||||
use crate::components::utils::{WIRELESS, DBUS_PATH, BASE};
|
||||
use crate::components::utils::{BASE, DBUS_PATH, WIRELESS};
|
||||
use crate::components::wifi::utils::get_connection_settings;
|
||||
use adw::glib;
|
||||
use adw::glib::{Object, PropertySet};
|
||||
|
@ -119,20 +119,18 @@ impl WifiEntry {
|
|||
|
||||
pub fn click_disconnect(entry: Arc<WifiEntry>) {
|
||||
let entry_ref = entry.clone();
|
||||
entry_ref
|
||||
.imp()
|
||||
.reset_wifi_connected
|
||||
.borrow()
|
||||
.set_text("Disconnecting...");
|
||||
entry.set_activatable(false);
|
||||
gio::spawn_blocking(move || {
|
||||
let imp = entry_ref.imp();
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(10000),
|
||||
);
|
||||
let res: Result<(bool,), Error> = proxy.method_call(
|
||||
WIRELESS,
|
||||
"DisconnectFromCurrentAccessPoint",
|
||||
(),
|
||||
);
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(10000));
|
||||
let res: Result<(bool,), Error> =
|
||||
proxy.method_call(WIRELESS, "DisconnectFromCurrentAccessPoint", ());
|
||||
if res.is_err() {
|
||||
imp.connected.replace(false);
|
||||
return;
|
||||
|
@ -151,22 +149,19 @@ pub fn click_stored_network(entry: Arc<WifiEntry>) {
|
|||
let entry_imp = entry.imp();
|
||||
let access_point = entry_imp.access_point.borrow().clone();
|
||||
let entry_ref = entry.clone();
|
||||
entry.set_activatable(false);
|
||||
entry.set_sensitive(false);
|
||||
entry_imp
|
||||
.reset_wifi_connected
|
||||
.borrow()
|
||||
.set_text("Connecting...");
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(10000),
|
||||
);
|
||||
let res: Result<(bool,), Error> = proxy.method_call(
|
||||
WIRELESS,
|
||||
"ConnectToKnownAccessPoint",
|
||||
(access_point,),
|
||||
);
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(10000));
|
||||
let res: Result<(bool,), Error> =
|
||||
proxy.method_call(WIRELESS, "ConnectToKnownAccessPoint", (access_point,));
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
entry.set_activatable(true);
|
||||
entry.set_sensitive(true);
|
||||
let imp = entry_ref.imp();
|
||||
if res.is_err() {
|
||||
imp.connected.replace(false);
|
||||
|
@ -194,14 +189,11 @@ pub fn click_new_network(entry: Arc<WifiEntry>) {
|
|||
popup.reset_popup_label.set_visible(true);
|
||||
popup.reset_popup_entry.set_sensitive(false);
|
||||
popup.reset_popup_button.set_sensitive(false);
|
||||
entry.set_sensitive(false);
|
||||
|
||||
gio::spawn_blocking(move || {
|
||||
let conn = Connection::new_session().unwrap();
|
||||
let proxy = conn.with_proxy(
|
||||
BASE,
|
||||
DBUS_PATH,
|
||||
Duration::from_millis(10000),
|
||||
);
|
||||
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(10000));
|
||||
let res: Result<(bool,), Error> = proxy.method_call(
|
||||
WIRELESS,
|
||||
"ConnectToNewAccessPoint",
|
||||
|
@ -209,6 +201,7 @@ pub fn click_new_network(entry: Arc<WifiEntry>) {
|
|||
);
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
entry.set_sensitive(false);
|
||||
if res.is_err() {
|
||||
let imp = entry_ref.imp();
|
||||
imp.reset_wifi_popup
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue