forked from meli/meli
1
Fork 0

melib/imap: add support for CHILDREN extesion RFC 3348

imap-lemonade
Manos Pitsidianakis 2022-09-03 23:44:39 +03:00
parent 9fcf88b494
commit b2ff359eb7
3 changed files with 18 additions and 0 deletions

View File

@ -66,6 +66,7 @@ pub type MessageSequenceNumber = ImapNum;
pub static SUPPORTED_CAPABILITIES: &[&str] = &[
"AUTH=OAUTH2",
"CHILDREN",
#[cfg(feature = "deflate_compression")]
"COMPRESS=DEFLATE",
"CONDSTORE",

View File

@ -33,6 +33,7 @@ pub struct ImapMailbox {
pub path: String,
pub name: String,
pub parent: Option<MailboxHash>,
pub has_children: bool,
pub children: Vec<MailboxHash>,
pub separator: u8,
pub usage: Arc<RwLock<SpecialUsageMailbox>>,
@ -47,6 +48,12 @@ pub struct ImapMailbox {
}
impl ImapMailbox {
pub fn set_has_children(&mut self, has_children: bool) -> &mut Self {
self.has_children = has_children;
self
}
pub fn imap_path(&self) -> &str {
&self.imap_path
}
@ -88,6 +95,9 @@ impl BackendMailbox for ImapMailbox {
}
fn children(&self) -> &[MailboxHash] {
if !self.has_children {
return &[];
}
&self.children
}
@ -106,9 +116,11 @@ impl BackendMailbox for ImapMailbox {
fn permissions(&self) -> MailboxPermissions {
*self.permissions.lock().unwrap()
}
fn is_subscribed(&self) -> bool {
self.is_subscribed
}
fn set_is_subscribed(&mut self, new_val: bool) -> Result<()> {
self.is_subscribed = new_val;
Ok(())

View File

@ -449,6 +449,7 @@ pub fn list_mailbox_result(input: &[u8]) -> IResult<&[u8], ImapMailbox> {
({
let separator: u8 = separator[0];
let mut f = ImapMailbox::default();
f.has_children = true;
f.no_select = false;
f.is_subscribed = false;
@ -475,6 +476,10 @@ pub fn list_mailbox_result(input: &[u8]) -> IResult<&[u8], ImapMailbox> {
let _ = f.set_special_usage(SpecialUsageMailbox::Flagged);
} else if p.eq_ignore_ascii_case(b"\\Archive") {
let _ = f.set_special_usage(SpecialUsageMailbox::Archive);
} else if p.eq_ignore_ascii_case(b"\\HasChildren") {
f.has_children = true;
} else if p.eq_ignore_ascii_case(b"\\HasNoChildren") {
f.has_children = false;
}
}
f.imap_path = path.to_string();