mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-12 08:28:32 +02:00
chore: Bump version of daemon
This commit is contained in:
parent
6055856f18
commit
1c0b467d8a
|
@ -7,7 +7,7 @@ repository = "https://github.com/Xetibo/ReSet"
|
||||||
license = "GPL-3.0-only"
|
license = "GPL-3.0-only"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
reset_daemon = "0.6.6"
|
reset_daemon = "0.6.9"
|
||||||
re_set-lib = "0.8.6"
|
re_set-lib = "0.8.6"
|
||||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||||
dbus = "0.9.7"
|
dbus = "0.9.7"
|
||||||
|
|
|
@ -13,7 +13,7 @@ use gtk::gio;
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
input::source_box::{start_input_box_listener, SourceBox},
|
input::source_box::{start_input_box_listener, SourceBox},
|
||||||
output::sink_box::{start_output_box_listener, SinkBox},
|
output::sink_box::{start_output_box_listener, SinkBox},
|
||||||
utils::{AUDIO, BASE, DBUS_PATH, WIRELESS},
|
utils::{BASE, DBUS_PATH, WIRELESS},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Default, PartialEq, Eq)]
|
#[derive(Default, PartialEq, Eq)]
|
||||||
|
@ -65,13 +65,11 @@ pub fn start_audio_listener(
|
||||||
source_box: Option<Arc<SourceBox>>,
|
source_box: Option<Arc<SourceBox>>,
|
||||||
) {
|
) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let mut conn = Connection::new_session().unwrap();
|
||||||
if listeners.pulse_listener.load(Ordering::SeqCst) {
|
if listeners.pulse_listener.load(Ordering::SeqCst) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut conn = start_dbus_audio_listener(conn);
|
|
||||||
|
|
||||||
if let Some(sink_box) = sink_box {
|
if let Some(sink_box) = sink_box {
|
||||||
conn = start_output_box_listener(conn, sink_box);
|
conn = start_output_box_listener(conn, sink_box);
|
||||||
}
|
}
|
||||||
|
@ -84,22 +82,8 @@ pub fn start_audio_listener(
|
||||||
loop {
|
loop {
|
||||||
let _ = conn.process(Duration::from_millis(1000));
|
let _ = conn.process(Duration::from_millis(1000));
|
||||||
if !listeners.pulse_listener.load(Ordering::SeqCst) {
|
if !listeners.pulse_listener.load(Ordering::SeqCst) {
|
||||||
stop_dbus_audio_listener(conn);
|
|
||||||
break;
|
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", ());
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
use std::sync::atomic::Ordering;
|
use std::sync::atomic::Ordering;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread;
|
|
||||||
use std::time::{Duration, SystemTime};
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
use adw::glib;
|
use adw::glib;
|
||||||
|
@ -379,7 +378,6 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
|
||||||
.set_description(Some("Scanning..."));
|
.set_description(Some("Scanning..."));
|
||||||
time = SystemTime::now();
|
time = SystemTime::now();
|
||||||
}
|
}
|
||||||
thread::sleep(Duration::from_millis(100));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
mod base;
|
pub mod base;
|
||||||
pub mod bluetooth;
|
pub mod bluetooth;
|
||||||
mod input;
|
mod input;
|
||||||
pub mod output;
|
pub mod output;
|
||||||
|
|
|
@ -48,7 +48,6 @@ impl WifiBox {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn setup_callbacks(listeners: Arc<Listeners>, wifi_box: Arc<WifiBox>) -> Arc<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 imp = wifi_box.imp();
|
||||||
let wifibox_ref = wifi_box.clone();
|
let wifibox_ref = wifi_box.clone();
|
||||||
imp.reset_saved_networks.set_activatable(true);
|
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
|
imp.reset_saved_networks
|
||||||
.set_action_target_value(Some(&Variant::from("saved")));
|
.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_activatable(true);
|
||||||
imp.reset_available_networks
|
imp.reset_available_networks
|
||||||
.set_action_name(Some("navigation.pop"));
|
.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
|
glib::Propagation::Proceed
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
wifi_box
|
wifi_box
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,6 +95,7 @@ pub fn scan_for_wifi(wifi_box: Arc<WifiBox>) {
|
||||||
gio::spawn_blocking(move || {
|
gio::spawn_blocking(move || {
|
||||||
let devices = get_wifi_devices();
|
let devices = get_wifi_devices();
|
||||||
let access_points = get_access_points();
|
let access_points = get_access_points();
|
||||||
|
let wifi_status = get_wifi_status();
|
||||||
{
|
{
|
||||||
let imp = wifibox_ref.imp();
|
let imp = wifibox_ref.imp();
|
||||||
let list = imp.reset_model_list.write().unwrap();
|
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 mut wifi_entries_path = wifi_entries_path.write().unwrap();
|
||||||
let imp = wifibox_ref.imp();
|
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();
|
let list = imp.reset_model_list.read().unwrap();
|
||||||
imp.reset_wifi_device.set_model(Some(&*list));
|
imp.reset_wifi_device.set_model(Some(&*list));
|
||||||
let map = imp.reset_wifi_devices.read().unwrap();
|
let map = imp.reset_wifi_devices.read().unwrap();
|
||||||
|
|
22
src/main.rs
22
src/main.rs
|
@ -10,8 +10,6 @@ use gtk::prelude::*;
|
||||||
use gtk::{gio, Application, CssProvider};
|
use gtk::{gio, Application, CssProvider};
|
||||||
use reset_daemon::run_daemon;
|
use reset_daemon::run_daemon;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
mod components;
|
mod components;
|
||||||
|
|
||||||
const APP_ID: &str = "org.Xetibo.ReSet";
|
const APP_ID: &str = "org.Xetibo.ReSet";
|
||||||
|
@ -55,13 +53,8 @@ fn build_ui(app: &Application) {
|
||||||
fn shutdown(_: &Application) {
|
fn shutdown(_: &Application) {
|
||||||
thread::spawn(|| {
|
thread::spawn(|| {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(100));
|
||||||
BASE,
|
let res: Result<(), Error> = proxy.method_call(BASE, "UnregisterClient", ("ReSet",));
|
||||||
DBUS_PATH,
|
|
||||||
Duration::from_millis(100),
|
|
||||||
);
|
|
||||||
let res: Result<(), Error> =
|
|
||||||
proxy.method_call(BASE, "UnregisterClient", ("ReSet",));
|
|
||||||
res
|
res
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -69,17 +62,12 @@ fn shutdown(_: &Application) {
|
||||||
async fn daemon_check() {
|
async fn daemon_check() {
|
||||||
let handle = thread::spawn(|| {
|
let handle = thread::spawn(|| {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(100));
|
||||||
BASE,
|
let res: Result<(), Error> = proxy.method_call(BASE, "RegisterClient", ("ReSet",));
|
||||||
DBUS_PATH,
|
|
||||||
Duration::from_millis(100),
|
|
||||||
);
|
|
||||||
let res: Result<(), Error> =
|
|
||||||
proxy.method_call(BASE, "RegisterClient", ("ReSet",));
|
|
||||||
res
|
res
|
||||||
});
|
});
|
||||||
let res = handle.join();
|
let res = handle.join();
|
||||||
if res.unwrap().is_err() {
|
if res.unwrap().is_err() {
|
||||||
run_daemon().await;
|
run_daemon().await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue