Private
Public Access
1
0

kordophoned: better daemon bootstrapping

This commit is contained in:
2025-04-25 16:54:37 -07:00
parent b1f171136a
commit 0c6b55fa38
7 changed files with 202 additions and 67 deletions

View File

@@ -1,16 +1,30 @@
use dbus::arg;
use dbus_tree::MethodErr;
use std::sync::Arc;
use std::sync::{Arc, Mutex};
use crate::daemon::Daemon;
use crate::dbus::interface::NetBuzzertKordophoneServer as DbusServer;
impl DbusServer for Arc<Daemon> {
impl DbusServer for Arc<Mutex<Daemon>> {
fn get_version(&mut self) -> Result<String, MethodErr> {
Ok(self.version.clone())
let daemon = self.lock().map_err(|_| MethodErr::failed("Failed to lock daemon"))?;
Ok(daemon.version.clone())
}
fn get_conversations(&mut self) -> Result<Vec<arg::PropMap>, dbus::MethodErr> {
todo!()
// Get a repository instance and use it to fetch conversations
let mut daemon = self.lock().map_err(|_| MethodErr::failed("Failed to lock daemon"))?;
let conversations = daemon.get_conversations();
// Convert conversations to DBus property maps
let result = conversations.into_iter().map(|conv| {
let mut map = arg::PropMap::new();
map.insert("guid".into(), arg::Variant(Box::new(conv.guid)));
map.insert("display_name".into(), arg::Variant(Box::new(conv.display_name.unwrap_or_default())));
map.insert("unread_count".into(), arg::Variant(Box::new(conv.unread_count as i32)));
map
}).collect();
Ok(result)
}
}