init: store true if daemon is already started

This commit is contained in:
DashieTM 2024-06-12 19:46:11 +02:00
parent 0b12d95c83
commit e7c0995aa3
3 changed files with 19 additions and 1 deletions

View file

@ -10,6 +10,9 @@ use glib::prelude::Cast;
use glib::Object;
use gtk::prelude::{GObjectPropertyExpressionExt, ListBoxRowExt, ListItemExt, WidgetExt};
use gtk::{Align, SignalListItemFactory, StringObject};
use re_set_lib::ERROR;
#[cfg(debug_assertions)]
use re_set_lib::{utils::macros::ErrorLevel, write_log_to_file};
pub const DBUS_PATH: &str = "/org/Xetibo/ReSet/Daemon";
pub const WIRELESS: &str = "org.Xetibo.ReSet.Network";
@ -93,5 +96,12 @@ pub fn get_capabilities() -> Vec<String> {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(BASE, DBUS_PATH, Duration::from_millis(10000));
let res: Result<(Vec<String>,), Error> = proxy.method_call(BASE, "GetCapabilities", ());
if res.is_err() {
ERROR!(
"Could not call capabilities from daemon",
ErrorLevel::Critical
);
return Vec::new();
}
res.unwrap().0
}

View file

@ -1,5 +1,5 @@
use std::hint::{self};
use std::sync::atomic::AtomicBool;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::thread;
use std::time::Duration;
@ -81,5 +81,7 @@ async fn daemon_check(ready: Arc<AtomicBool>) {
let res = handle.join();
if res.unwrap().is_err() {
run_daemon(Some(ready)).await;
} else {
ready.store(true, Ordering::SeqCst);
}
}