chore: Bump version of daemon

This commit is contained in:
Fabio Lenherr / DashieTM 2023-12-17 18:21:02 +01:00
parent 6055856f18
commit 1c0b467d8a
6 changed files with 14 additions and 43 deletions

View file

@ -7,7 +7,7 @@ repository = "https://github.com/Xetibo/ReSet"
license = "GPL-3.0-only"
[dependencies]
reset_daemon = "0.6.6"
reset_daemon = "0.6.9"
re_set-lib = "0.8.6"
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
dbus = "0.9.7"

View file

@ -13,7 +13,7 @@ use gtk::gio;
use crate::components::{
input::source_box::{start_input_box_listener, SourceBox},
output::sink_box::{start_output_box_listener, SinkBox},
utils::{AUDIO, BASE, DBUS_PATH, WIRELESS},
utils::{BASE, DBUS_PATH, WIRELESS},
};
#[derive(Default, PartialEq, Eq)]
@ -65,13 +65,11 @@ pub fn start_audio_listener(
source_box: Option<Arc<SourceBox>>,
) {
gio::spawn_blocking(move || {
let conn = Connection::new_session().unwrap();
let mut conn = Connection::new_session().unwrap();
if listeners.pulse_listener.load(Ordering::SeqCst) {
return;
}
let mut conn = start_dbus_audio_listener(conn);
if let Some(sink_box) = sink_box {
conn = start_output_box_listener(conn, sink_box);
}
@ -84,22 +82,8 @@ pub fn start_audio_listener(
loop {
let _ = conn.process(Duration::from_millis(1000));
if !listeners.pulse_listener.load(Ordering::SeqCst) {
stop_dbus_audio_listener(conn);
break;
}
// thread::sleep(Duration::from_millis(1000));
// TODO is this really how we should do this?
}
});
}
fn start_dbus_audio_listener(conn: Connection) -> Connection {
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000));
let _: Result<(), Error> = proxy.method_call(AUDIO, "StartAudioListener", ());
conn
}
fn stop_dbus_audio_listener(conn: Connection) {
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(1000));
let _: Result<(), Error> = proxy.method_call(AUDIO, "StopAudioListener", ());
}

View file

@ -1,6 +1,5 @@
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::time::{Duration, SystemTime};
use adw::glib;
@ -379,7 +378,6 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
.set_description(Some("Scanning..."));
time = SystemTime::now();
}
thread::sleep(Duration::from_millis(100));
}
});
}

View file

@ -1,4 +1,4 @@
mod base;
pub mod base;
pub mod bluetooth;
mod input;
pub mod output;

View file

@ -48,7 +48,6 @@ impl WifiBox {
}
fn setup_callbacks(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) -> Arc<WifiBox> {
let wifi_status = get_wifi_status();
let imp = wifi_box.imp();
let wifibox_ref = wifi_box.clone();
imp.reset_saved_networks.set_activatable(true);
@ -57,9 +56,6 @@ fn setup_callbacks(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) -> Arc<Wif
imp.reset_saved_networks
.set_action_target_value(Some(&Variant::from("saved")));
imp.reset_wifi_switch.set_active(wifi_status);
imp.reset_wifi_switch.set_state(wifi_status);
imp.reset_available_networks.set_activatable(true);
imp.reset_available_networks
.set_action_name(Some("navigation.pop"));
@ -86,6 +82,7 @@ fn setup_callbacks(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) -> Arc<Wif
glib::Propagation::Proceed
}),
);
wifi_box
}
@ -98,6 +95,7 @@ pub fn scan_for_wifi(wifi_box: Arc<WifiBox>) {
gio::spawn_blocking(move || {
let devices = get_wifi_devices();
let access_points = get_access_points();
let wifi_status = get_wifi_status();
{
let imp = wifibox_ref.imp();
let list = imp.reset_model_list.write().unwrap();
@ -123,6 +121,9 @@ pub fn scan_for_wifi(wifi_box: Arc<WifiBox>) {
let mut wifi_entries_path = wifi_entries_path.write().unwrap();
let imp = wifibox_ref.imp();
imp.reset_wifi_switch.set_active(wifi_status);
imp.reset_wifi_switch.set_state(wifi_status);
let list = imp.reset_model_list.read().unwrap();
imp.reset_wifi_device.set_model(Some(&*list));
let map = imp.reset_wifi_devices.read().unwrap();

View file

@ -10,8 +10,6 @@ use gtk::prelude::*;
use gtk::{gio, Application, CssProvider};
use reset_daemon::run_daemon;
mod components;
const APP_ID: &str = "org.Xetibo.ReSet";
@ -55,13 +53,8 @@ fn build_ui(app: &Application) {
fn shutdown(_: &Application) {
thread::spawn(|| {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
BASE,
DBUS_PATH,
Duration::from_millis(100),
);
let res: Result<(), Error> =
proxy.method_call(BASE, "UnregisterClient", ("ReSet",));
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(100));
let res: Result<(), Error> = proxy.method_call(BASE, "UnregisterClient", ("ReSet",));
res
});
}
@ -69,17 +62,12 @@ fn shutdown(_: &Application) {
async fn daemon_check() {
let handle = thread::spawn(|| {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
BASE,
DBUS_PATH,
Duration::from_millis(100),
);
let res: Result<(), Error> =
proxy.method_call(BASE, "RegisterClient", ("ReSet",));
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(100));
let res: Result<(), Error> = proxy.method_call(BASE, "RegisterClient", ("ReSet",));
res
});
let res = handle.join();
if res.unwrap().is_err() {
run_daemon().await;
}
}
}