mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-07-26 18:37:45 +02:00
feat: Add stop listener
This commit is contained in:
parent
f5f6246ad1
commit
e3b95d7540
14 changed files with 215 additions and 151 deletions
|
@ -4,3 +4,4 @@ pub mod listEntry;
|
|||
pub mod listEntryImpl;
|
||||
pub mod popup;
|
||||
pub mod popupImpl;
|
||||
pub mod utils;
|
||||
|
|
36
src/components/base/utils.rs
Normal file
36
src/components/base/utils.rs
Normal 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", ());
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue