cargo fmt
This commit is contained in:
@@ -42,11 +42,11 @@ impl DbusRegistry {
|
||||
R: IntoIterator<Item = dbus_crossroads::IfaceToken<T>>,
|
||||
{
|
||||
let dbus_path = String::from(path);
|
||||
|
||||
|
||||
let mut cr = self.crossroads.lock().unwrap();
|
||||
let tokens: Vec<_> = register_fn(&mut cr).into_iter().collect();
|
||||
cr.insert(dbus_path, &tokens, implementation);
|
||||
|
||||
|
||||
// Start message handler if not already started
|
||||
let mut handler_started = self.message_handler_started.lock().unwrap();
|
||||
if !*handler_started {
|
||||
|
||||
@@ -13,4 +13,4 @@ pub mod interface {
|
||||
pub use crate::interface::NetBuzzertKordophoneRepositoryConversationsUpdated as ConversationsUpdated;
|
||||
pub use crate::interface::NetBuzzertKordophoneRepositoryMessagesUpdated as MessagesUpdated;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,8 @@ use tokio::sync::oneshot;
|
||||
|
||||
use crate::daemon::{
|
||||
events::{Event, Reply},
|
||||
settings::Settings, DaemonResult,
|
||||
settings::Settings,
|
||||
DaemonResult,
|
||||
};
|
||||
|
||||
use crate::dbus::interface::NetBuzzertKordophoneRepository as DbusRepository;
|
||||
@@ -136,52 +137,82 @@ impl DbusRepository for ServerImpl {
|
||||
"sender".into(),
|
||||
arg::Variant(Box::new(msg.sender.display_name())),
|
||||
);
|
||||
|
||||
|
||||
// Add attachments array
|
||||
let attachments: Vec<arg::PropMap> = msg.attachments
|
||||
let attachments: Vec<arg::PropMap> = msg
|
||||
.attachments
|
||||
.into_iter()
|
||||
.map(|attachment| {
|
||||
let mut attachment_map = arg::PropMap::new();
|
||||
attachment_map.insert("guid".into(), arg::Variant(Box::new(attachment.guid.clone())));
|
||||
|
||||
attachment_map.insert(
|
||||
"guid".into(),
|
||||
arg::Variant(Box::new(attachment.guid.clone())),
|
||||
);
|
||||
|
||||
// Get attachment paths and download status
|
||||
let path = attachment.get_path(false);
|
||||
let preview_path = attachment.get_path(true);
|
||||
let downloaded = attachment.is_downloaded(false);
|
||||
let preview_downloaded = attachment.is_downloaded(true);
|
||||
|
||||
attachment_map.insert("path".into(), arg::Variant(Box::new(path.to_string_lossy().to_string())));
|
||||
attachment_map.insert("preview_path".into(), arg::Variant(Box::new(preview_path.to_string_lossy().to_string())));
|
||||
attachment_map.insert("downloaded".into(), arg::Variant(Box::new(downloaded)));
|
||||
attachment_map.insert("preview_downloaded".into(), arg::Variant(Box::new(preview_downloaded)));
|
||||
|
||||
|
||||
attachment_map.insert(
|
||||
"path".into(),
|
||||
arg::Variant(Box::new(path.to_string_lossy().to_string())),
|
||||
);
|
||||
attachment_map.insert(
|
||||
"preview_path".into(),
|
||||
arg::Variant(Box::new(
|
||||
preview_path.to_string_lossy().to_string(),
|
||||
)),
|
||||
);
|
||||
attachment_map.insert(
|
||||
"downloaded".into(),
|
||||
arg::Variant(Box::new(downloaded)),
|
||||
);
|
||||
attachment_map.insert(
|
||||
"preview_downloaded".into(),
|
||||
arg::Variant(Box::new(preview_downloaded)),
|
||||
);
|
||||
|
||||
// Add metadata if present
|
||||
if let Some(ref metadata) = attachment.metadata {
|
||||
let mut metadata_map = arg::PropMap::new();
|
||||
|
||||
|
||||
// Add attribution_info if present
|
||||
if let Some(ref attribution_info) = metadata.attribution_info {
|
||||
let mut attribution_map = arg::PropMap::new();
|
||||
|
||||
|
||||
if let Some(width) = attribution_info.width {
|
||||
attribution_map.insert("width".into(), arg::Variant(Box::new(width as i32)));
|
||||
attribution_map.insert(
|
||||
"width".into(),
|
||||
arg::Variant(Box::new(width as i32)),
|
||||
);
|
||||
}
|
||||
if let Some(height) = attribution_info.height {
|
||||
attribution_map.insert("height".into(), arg::Variant(Box::new(height as i32)));
|
||||
attribution_map.insert(
|
||||
"height".into(),
|
||||
arg::Variant(Box::new(height as i32)),
|
||||
);
|
||||
}
|
||||
|
||||
metadata_map.insert("attribution_info".into(), arg::Variant(Box::new(attribution_map)));
|
||||
|
||||
metadata_map.insert(
|
||||
"attribution_info".into(),
|
||||
arg::Variant(Box::new(attribution_map)),
|
||||
);
|
||||
}
|
||||
|
||||
attachment_map.insert("metadata".into(), arg::Variant(Box::new(metadata_map)));
|
||||
|
||||
attachment_map.insert(
|
||||
"metadata".into(),
|
||||
arg::Variant(Box::new(metadata_map)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
attachment_map
|
||||
})
|
||||
.collect();
|
||||
|
||||
|
||||
map.insert("attachments".into(), arg::Variant(Box::new(attachments)));
|
||||
|
||||
|
||||
map
|
||||
})
|
||||
.collect()
|
||||
@@ -216,20 +247,21 @@ impl DbusRepository for ServerImpl {
|
||||
(
|
||||
// - path: string
|
||||
path.to_string_lossy().to_string(),
|
||||
|
||||
// - preview_path: string
|
||||
preview_path.to_string_lossy().to_string(),
|
||||
|
||||
// - downloaded: boolean
|
||||
downloaded,
|
||||
|
||||
// - preview_downloaded: boolean
|
||||
preview_downloaded,
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
fn download_attachment(&mut self, attachment_id: String, preview: bool) -> Result<(), dbus::MethodErr> {
|
||||
fn download_attachment(
|
||||
&mut self,
|
||||
attachment_id: String,
|
||||
preview: bool,
|
||||
) -> Result<(), dbus::MethodErr> {
|
||||
// For now, just trigger the download event - we'll implement the actual download logic later
|
||||
self.send_event_sync(|r| Event::DownloadAttachment(attachment_id, preview, r))
|
||||
}
|
||||
@@ -286,7 +318,6 @@ impl DbusSettings for ServerImpl {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn run_sync_future<F, T>(f: F) -> Result<T, MethodErr>
|
||||
where
|
||||
T: Send,
|
||||
|
||||
Reference in New Issue
Block a user