diff options
Diffstat (limited to 'src/de_jmhoffmann_jwebmail_mail-storage.rs')
-rw-r--r-- | src/de_jmhoffmann_jwebmail_mail-storage.rs | 112 |
1 files changed, 111 insertions, 1 deletions
diff --git a/src/de_jmhoffmann_jwebmail_mail-storage.rs b/src/de_jmhoffmann_jwebmail_mail-storage.rs index bf3b148..4c0486d 100644 --- a/src/de_jmhoffmann_jwebmail_mail-storage.rs +++ b/src/de_jmhoffmann_jwebmail_mail-storage.rs @@ -314,6 +314,11 @@ pub trait VarlinkCallError: varlink::CallTrait { } impl<'a> VarlinkCallError for varlink::Call<'a> {} #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct r#Bound { + pub r#param: String, + pub r#id: String, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct r#ListMailHeader { pub r#byte_size: i64, pub r#unread: bool, @@ -493,6 +498,47 @@ pub trait Call_List: VarlinkCallError { } impl<'a> Call_List for varlink::Call<'a> {} #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub enum r#ListSearch_Args_direction { + r#after, + r#before, +} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct ListSearch_Reply { + pub r#mail_heads: Vec<ListMailHeader>, + pub r#first: bool, + pub r#last: bool, +} +impl varlink::VarlinkReply for ListSearch_Reply {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] +pub struct ListSearch_Args { + pub r#folder: String, + #[serde(skip_serializing_if = "Option::is_none")] + pub r#bound: Option<Bound>, + pub r#direction: ListSearch_Args_direction, + pub r#limit: i64, + pub r#sort: Sort, + #[serde(skip_serializing_if = "Option::is_none")] + pub r#search: Option<String>, +} +pub trait Call_ListSearch: VarlinkCallError { + fn reply( + &mut self, + r#mail_heads: Vec<ListMailHeader>, + r#first: bool, + r#last: bool, + ) -> varlink::Result<()> { + self.reply_struct( + ListSearch_Reply { + r#mail_heads, + r#first, + r#last, + } + .into(), + ) + } +} +impl<'a> Call_ListSearch for varlink::Call<'a> {} +#[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] pub struct Move_Reply {} impl varlink::VarlinkReply for Move_Reply {} #[derive(Serialize, Deserialize, Debug, PartialEq, Clone)] @@ -618,6 +664,16 @@ pub trait VarlinkInterface { r#end: i64, r#sort: Sort, ) -> varlink::Result<()>; + fn list_search( + &self, + call: &mut dyn Call_ListSearch, + r#folder: String, + r#bound: Option<Bound>, + r#direction: ListSearch_Args_direction, + r#limit: i64, + r#sort: Sort, + r#search: Option<String>, + ) -> varlink::Result<()>; fn r#move( &self, call: &mut dyn Call_Move, @@ -677,6 +733,15 @@ pub trait VarlinkClientInterface { r#end: i64, r#sort: Sort, ) -> varlink::MethodCall<List_Args, List_Reply, Error>; + fn list_search( + &mut self, + r#folder: String, + r#bound: Option<Bound>, + r#direction: ListSearch_Args_direction, + r#limit: i64, + r#sort: Sort, + r#search: Option<String>, + ) -> varlink::MethodCall<ListSearch_Args, ListSearch_Reply, Error>; fn r#move( &mut self, r#mid: String, @@ -766,6 +831,28 @@ impl VarlinkClientInterface for VarlinkClient { }, ) } + fn list_search( + &mut self, + r#folder: String, + r#bound: Option<Bound>, + r#direction: ListSearch_Args_direction, + r#limit: i64, + r#sort: Sort, + r#search: Option<String>, + ) -> varlink::MethodCall<ListSearch_Args, ListSearch_Reply, Error> { + varlink::MethodCall::<ListSearch_Args, ListSearch_Reply, Error>::new( + self.connection.clone(), + "de.jmhoffmann.jwebmail.mail-storage.ListSearch", + ListSearch_Args { + r#folder, + r#bound, + r#direction, + r#limit, + r#sort, + r#search, + }, + ) + } fn r#move( &mut self, r#mid: String, @@ -852,7 +939,7 @@ pub fn new(inner: Box<dyn VarlinkInterface + Send + Sync>) -> VarlinkInterfacePr } impl varlink::Interface for VarlinkInterfaceProxy { fn get_description(&self) -> &'static str { - "interface de.jmhoffmann.jwebmail.mail-storage\n\n\ntype MIMEHeader (\n mime_type: (main_type: string, sub_type: string),\n content_dispo: (none, inline, attachment),\n file_name: ?string\n)\n\ntype MailAddr (\n name: ?string,\n address: string\n)\n\n# send_date is of ISO 8601 date-time format\ntype MailHeader (\n send_date: string,\n written_from: []MailAddr,\n sender: ?MailAddr,\n reply_to: []MailAddr,\n send_to: []MailAddr,\n cc: []MailAddr,\n bcc: []MailAddr,\n subject: string,\n comments: []string,\n keywords: []string,\n mime: MIMEHeader\n)\n\ntype ListMailHeader (\n byte_size: int,\n unread: bool,\n rec_date: string,\n mid: string,\n header: MailHeader\n)\n\ntype Multipart (\n preamble: ?string,\n parts: []MIMEPart,\n epilogue: ?string\n)\n\n# exactly one of these fileds must be present\ntype MailBody (\n discrete: ?string,\n multipart: ?Multipart,\n mail: ?Mail\n)\n\ntype Mail (\n head: MailHeader,\n body: MailBody\n)\n\ntype MIMEPart (\n mime_header: MIMEHeader,\n body: MailBody\n)\n\ntype Sort (\n direction: (asc, desc),\n parameter: (date, size, sender)\n)\n\n\nmethod Init(unix_user: string, mailbox_path: string) -> ()\nmethod List(folder: string, start: int, end: int, sort: Sort) -> (mail_heads: []ListMailHeader)\nmethod Stats(folder: string) -> (mail_count: int, unread_count: int, byte_size: int)\nmethod Show(folder: string, mid: string) -> (mail: Mail)\n# body is base64 encoded\nmethod Raw(folder: string, mid: string, path: ?string) -> (header: MIMEHeader, body: string)\nmethod Search(folder: string, pattern: string) -> (found: []ListMailHeader)\nmethod Folders() -> (folders: []string)\nmethod Move(mid: string, from_folder: string, to_folder: string) -> ()\nmethod Remove(folder: string, mid: string) -> ()\nmethod AddFolder(name: string) -> (status: (created, skiped))\n\n\nerror NotInitialized()\nerror InvalidFolder(folder: string)\nerror InvalidMID(folder: string, mid: string)\nerror InvalidPathInMail(folder: string, mid: string, path: string)\nerror InvalidSearchPattern(pattern: string)\nerror InvalidUser(unix_user: string)\nerror InvalidMailbox(path: string, not_a_mailbox: bool, user_mismatch: bool)\n" + "interface de.jmhoffmann.jwebmail.mail-storage\n\n\ntype MIMEHeader (\n mime_type: (main_type: string, sub_type: string),\n content_dispo: (none, inline, attachment),\n file_name: ?string\n)\n\ntype MailAddr (\n name: ?string,\n address: string\n)\n\n# send_date is of ISO 8601 date-time format\ntype MailHeader (\n send_date: string,\n written_from: []MailAddr,\n sender: ?MailAddr,\n reply_to: []MailAddr,\n send_to: []MailAddr,\n cc: []MailAddr,\n bcc: []MailAddr,\n subject: string,\n comments: []string,\n keywords: []string,\n mime: MIMEHeader\n)\n\ntype ListMailHeader (\n byte_size: int,\n unread: bool,\n rec_date: string,\n mid: string,\n header: MailHeader\n)\n\ntype Multipart (\n preamble: ?string,\n parts: []MIMEPart,\n epilogue: ?string\n)\n\n# exactly one of these fileds must be present\ntype MailBody (\n discrete: ?string,\n multipart: ?Multipart,\n mail: ?Mail\n)\n\ntype Mail (\n head: MailHeader,\n body: MailBody\n)\n\ntype MIMEPart (\n mime_header: MIMEHeader,\n body: MailBody\n)\n\ntype Sort (\n direction: (asc, desc),\n parameter: (date, size, sender, subject)\n)\n\ntype Bound (\n param: string,\n id: string\n)\n\n\nmethod Init(unix_user: string, mailbox_path: string) -> ()\n\n# deprecated: use ListSearch instead\nmethod List(folder: string, start: int, end: int, sort: Sort) -> (mail_heads: []ListMailHeader)\n\nmethod Stats(folder: string) -> (mail_count: int, unread_count: int, byte_size: int)\n\nmethod Show(folder: string, mid: string) -> (mail: Mail)\n\n# body is base64 encoded\nmethod Raw(folder: string, mid: string, path: ?string) -> (header: MIMEHeader, body: string)\n\n# deprecated: use ListSearch instead\nmethod Search(folder: string, pattern: string) -> (found: []ListMailHeader)\n\nmethod Folders() -> (folders: []string)\n\nmethod Move(mid: string, from_folder: string, to_folder: string) -> ()\n\nmethod Remove(folder: string, mid: string) -> ()\n\nmethod AddFolder(name: string) -> (status: (created, skiped))\n\nmethod ListSearch(\n folder: string,\n bound: ?Bound,\n direction: (after, before),\n limit: int,\n sort: Sort,\n search: ?string\n) -> (\n mail_heads: []ListMailHeader,\n first: bool,\n last: bool\n)\n\n\nerror NotInitialized()\nerror InvalidFolder(folder: string)\nerror InvalidMID(folder: string, mid: string)\nerror InvalidPathInMail(folder: string, mid: string, path: string)\nerror InvalidSearchPattern(pattern: string)\nerror InvalidUser(unix_user: string)\nerror InvalidMailbox(path: string, not_a_mailbox: bool, user_mismatch: bool)\n" } fn get_name(&self) -> &'static str { "de.jmhoffmann.jwebmail.mail-storage" @@ -926,6 +1013,29 @@ impl varlink::Interface for VarlinkInterfaceProxy { call.reply_invalid_parameter("parameters".into()) } } + "de.jmhoffmann.jwebmail.mail-storage.ListSearch" => { + if let Some(args) = req.parameters.clone() { + let args: ListSearch_Args = match serde_json::from_value(args) { + Ok(v) => v, + Err(e) => { + let es = format!("{}", e); + let _ = call.reply_invalid_parameter(es.clone()); + return Err(varlink::context!(varlink::ErrorKind::SerdeJsonDe(es))); + } + }; + self.inner.list_search( + call as &mut dyn Call_ListSearch, + args.r#folder, + args.r#bound, + args.r#direction, + args.r#limit, + args.r#sort, + args.r#search, + ) + } else { + call.reply_invalid_parameter("parameters".into()) + } + } "de.jmhoffmann.jwebmail.mail-storage.Move" => { if let Some(args) = req.parameters.clone() { let args: Move_Args = match serde_json::from_value(args) { |