implements settings, conversation dbus encoding
This commit is contained in:
@@ -1,17 +1,14 @@
|
||||
use dbus::arg;
|
||||
use dbus_tree::MethodErr;
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::{Mutex, MutexGuard};
|
||||
use tokio::sync::mpsc;
|
||||
use std::future::Future;
|
||||
use std::thread;
|
||||
use tokio::sync::oneshot;
|
||||
use tokio::sync::mpsc;
|
||||
use futures_util::future::FutureExt;
|
||||
|
||||
use crate::daemon::{
|
||||
Daemon,
|
||||
DaemonResult,
|
||||
events::{Event, Reply},
|
||||
settings::Settings,
|
||||
};
|
||||
|
||||
use crate::dbus::interface::NetBuzzertKordophoneRepository as DbusRepository;
|
||||
@@ -63,7 +60,10 @@ impl DbusRepository for ServerImpl {
|
||||
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
|
||||
map.insert("last_message_preview".into(), arg::Variant(Box::new(conv.last_message_preview.unwrap_or_default())));
|
||||
map.insert("participants".into(), arg::Variant(Box::new(conv.participants.into_iter().map(|p| p.display_name()).collect::<Vec<String>>())));
|
||||
map.insert("date".into(), arg::Variant(Box::new(conv.date.and_utc().timestamp())));
|
||||
map
|
||||
}).collect();
|
||||
|
||||
Ok(result)
|
||||
@@ -77,35 +77,77 @@ impl DbusRepository for ServerImpl {
|
||||
|
||||
impl DbusSettings for ServerImpl {
|
||||
fn set_server(&mut self, url: String, user: String) -> Result<(), dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(|r|
|
||||
Event::UpdateSettings(Settings {
|
||||
server_url: Some(url),
|
||||
username: Some(user),
|
||||
credential_item: None,
|
||||
}, r)
|
||||
)
|
||||
}
|
||||
|
||||
fn set_credential_item_(&mut self, item_path: dbus::Path<'static>) -> Result<(), dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(|r|
|
||||
Event::UpdateSettings(Settings {
|
||||
server_url: None,
|
||||
username: None,
|
||||
credential_item: Some(item_path.to_string()),
|
||||
}, r)
|
||||
)
|
||||
}
|
||||
|
||||
fn server_url(&self) -> Result<String, dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.server_url.unwrap_or_default())
|
||||
})
|
||||
}
|
||||
|
||||
fn set_server_url(&self, value: String) -> Result<(), dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(|r|
|
||||
Event::UpdateSettings(Settings {
|
||||
server_url: Some(value),
|
||||
username: None,
|
||||
credential_item: None,
|
||||
}, r)
|
||||
)
|
||||
}
|
||||
|
||||
fn username(&self) -> Result<String, dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.username.unwrap_or_default())
|
||||
})
|
||||
}
|
||||
|
||||
fn set_username(&self, value: String) -> Result<(), dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(|r|
|
||||
Event::UpdateSettings(Settings {
|
||||
server_url: None,
|
||||
username: Some(value),
|
||||
credential_item: None,
|
||||
}, r)
|
||||
)
|
||||
}
|
||||
|
||||
fn credential_item(&self) -> Result<dbus::Path<'static>, dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(Event::GetAllSettings)
|
||||
.and_then(|settings| {
|
||||
Ok(settings.credential_item.unwrap_or_default())
|
||||
})
|
||||
.and_then(|item| {
|
||||
Ok(dbus::Path::new(item).unwrap_or_default())
|
||||
})
|
||||
}
|
||||
|
||||
fn set_credential_item(&self, value: dbus::Path<'static>) -> Result<(), dbus::MethodErr> {
|
||||
todo!()
|
||||
self.send_event_sync(|r|
|
||||
Event::UpdateSettings(Settings {
|
||||
server_url: None,
|
||||
username: None,
|
||||
credential_item: Some(value.to_string()),
|
||||
}, r)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user