feat: Add stop listener

This commit is contained in:
Fabio Lenherr / DashieTM 2023-11-13 10:28:48 +01:00
parent f5f6246ad1
commit e3b95d7540
14 changed files with 215 additions and 151 deletions

View file

@ -4,3 +4,4 @@ pub mod listEntry;
pub mod listEntryImpl;
pub mod popup;
pub mod popupImpl;
pub mod utils;

View file

@ -0,0 +1,36 @@
use std::{
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread,
time::Duration,
};
use dbus::{blocking::Connection, Error};
#[derive(Default)]
pub struct Listeners {
pub network_listener: AtomicBool,
pub bluetooth_listener: AtomicBool,
pub pulse_listener: AtomicBool,
}
impl Listeners {
pub fn stop_network_listener(&self) {
if !self.network_listener.load(Ordering::SeqCst) {
return;
}
self.network_listener.store(false, Ordering::SeqCst);
thread::spawn(|| {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
"org.xetibo.ReSet",
"/org/xetibo/ReSet",
Duration::from_millis(1000),
);
let _: Result<(bool,), Error> =
proxy.method_call("org.xetibo.ReSet", "StopNetworkListener", ());
});
}
}