use std::path::PathBuf; use std::sync::RwLock; use crate::de_jmhoffmann_jwebmail_mailstorage::*; use maildir::Maildir; mod add_folder; mod folders; mod init; mod list_search; mod r#move; mod raw; mod remove; mod show; mod stats; use add_folder::add_folder; use folders::folders; use init::init; use list_search::list_search; use r#move::r#move; use raw::raw; use remove::remove; use show::show; use stats::stats; pub fn open_submaildir(mut path: PathBuf, sub: &str) -> Maildir { if !sub.is_empty() { path.push(String::from(".") + sub); } Maildir::from(path) } pub struct MailStorage { maildir_path: RwLock>, } impl Default for MailStorage { fn default() -> Self { MailStorage { maildir_path: RwLock::new(None), } } } impl VarlinkInterface for MailStorage { fn init( &self, call: &mut dyn Call_Init, unix_user: String, mailbox_path: String, ) -> varlink::Result<()> { init(self, call, unix_user, mailbox_path) } fn add_folder(&self, call: &mut dyn Call_AddFolder, name: String) -> varlink::Result<()> { add_folder(self, call, name) } fn stats(&self, call: &mut dyn Call_Stats, folder: String) -> varlink::Result<()> { stats(self, call, folder) } fn folders(&self, call: &mut dyn Call_Folders) -> varlink::Result<()> { folders(self, call) } fn list( &self, call: &mut dyn Call_List, folder: String, start: i64, end: i64, sort: Sort, ) -> varlink::Result<()> { todo!() } fn list_search( &self, call: &mut dyn Call_ListSearch, folder: String, bound: Option, direction: ListSearch_Args_direction, limit: i64, sort: Sort, search: Option, ) -> varlink::Result<()> { list_search(self, call, folder, bound, direction, limit, sort, search) } fn r#move( &self, call: &mut dyn Call_Move, mid: String, from_folder: String, to_folder: String, ) -> varlink::Result<()> { r#move(self, call, mid, from_folder, to_folder) } fn raw( &self, call: &mut dyn Call_Raw, folder: String, mid: String, path: Option, ) -> varlink::Result<()> { raw(self, call, folder, mid, path) } fn remove( &self, call: &mut dyn Call_Remove, folder: String, mid: String, ) -> varlink::Result<()> { remove(self, call, folder, mid) } fn search( &self, call: &mut dyn Call_Search, folder: String, pattern: String, ) -> varlink::Result<()> { todo!() } fn show(&self, call: &mut dyn Call_Show, folder: String, mid: String) -> varlink::Result<()> { show(self, call, folder, mid) } }