diff options
author | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-11-21 21:14:40 +0100 |
---|---|---|
committer | Jannis M. Hoffmann <jannis@fehcom.de> | 2024-11-21 21:14:40 +0100 |
commit | 48c2945172b88c35c187d298a35bf26716af4e91 (patch) | |
tree | 2af21ddb4dcacd191e07fef156609b7c1488ebaf /src/cmd/show.rs | |
parent | 6ed535387df0dffa72a10e601b8ea37c99345d84 (diff) |
Switch to varlink as IPC protocol
This is a lot! Whole new design on top of a statefult varlink interface.
You can now handle multiple request response cycles over a single
connection.
The error responses are lot more refined than just status codes with
optional messages and finally part of the protocol.
TODO: A lot of error handling needs to be improved.
Diffstat (limited to 'src/cmd/show.rs')
-rw-r--r-- | src/cmd/show.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/cmd/show.rs b/src/cmd/show.rs new file mode 100644 index 0000000..442eb21 --- /dev/null +++ b/src/cmd/show.rs @@ -0,0 +1,26 @@ +use crate::cmd::{open_submaildir, MailStorage}; +use crate::de_jmhoffmann_jwebmail_mailstorage::Call_Show; +use crate::rfc822::parsed_mail_to_mail; + +pub fn show( + ms: &MailStorage, + call: &mut dyn Call_Show, + folder: String, + mid: String, +) -> varlink::Result<()> { + if let Some(path) = ms.maildir_path.read().unwrap().clone() { + let md = open_submaildir(path, &folder); + + md.add_flags(&mid, "S").map_err(varlink::map_context!())?; + + if let Some(mut mail) = md.find(&mid) { + let mail2 = parsed_mail_to_mail(mail.parsed().unwrap()).unwrap(); + + call.reply(mail2) + } else { + call.reply_invalid_mid(folder, mid) + } + } else { + call.reply_not_initialized() + } +} |