melib/imap: add support for CHILDREN extesion RFC 3348
parent
9fcf88b494
commit
b2ff359eb7
|
@ -66,6 +66,7 @@ pub type MessageSequenceNumber = ImapNum;
|
||||||
|
|
||||||
pub static SUPPORTED_CAPABILITIES: &[&str] = &[
|
pub static SUPPORTED_CAPABILITIES: &[&str] = &[
|
||||||
"AUTH=OAUTH2",
|
"AUTH=OAUTH2",
|
||||||
|
"CHILDREN",
|
||||||
#[cfg(feature = "deflate_compression")]
|
#[cfg(feature = "deflate_compression")]
|
||||||
"COMPRESS=DEFLATE",
|
"COMPRESS=DEFLATE",
|
||||||
"CONDSTORE",
|
"CONDSTORE",
|
||||||
|
|
|
@ -33,6 +33,7 @@ pub struct ImapMailbox {
|
||||||
pub path: String,
|
pub path: String,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub parent: Option<MailboxHash>,
|
pub parent: Option<MailboxHash>,
|
||||||
|
pub has_children: bool,
|
||||||
pub children: Vec<MailboxHash>,
|
pub children: Vec<MailboxHash>,
|
||||||
pub separator: u8,
|
pub separator: u8,
|
||||||
pub usage: Arc<RwLock<SpecialUsageMailbox>>,
|
pub usage: Arc<RwLock<SpecialUsageMailbox>>,
|
||||||
|
@ -47,6 +48,12 @@ pub struct ImapMailbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
pub fn imap_path(&self) -> &str {
|
||||||
&self.imap_path
|
&self.imap_path
|
||||||
}
|
}
|
||||||
|
@ -88,6 +95,9 @@ impl BackendMailbox for ImapMailbox {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn children(&self) -> &[MailboxHash] {
|
fn children(&self) -> &[MailboxHash] {
|
||||||
|
if !self.has_children {
|
||||||
|
return &[];
|
||||||
|
}
|
||||||
&self.children
|
&self.children
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,9 +116,11 @@ impl BackendMailbox for ImapMailbox {
|
||||||
fn permissions(&self) -> MailboxPermissions {
|
fn permissions(&self) -> MailboxPermissions {
|
||||||
*self.permissions.lock().unwrap()
|
*self.permissions.lock().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_subscribed(&self) -> bool {
|
fn is_subscribed(&self) -> bool {
|
||||||
self.is_subscribed
|
self.is_subscribed
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_is_subscribed(&mut self, new_val: bool) -> Result<()> {
|
fn set_is_subscribed(&mut self, new_val: bool) -> Result<()> {
|
||||||
self.is_subscribed = new_val;
|
self.is_subscribed = new_val;
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -449,6 +449,7 @@ pub fn list_mailbox_result(input: &[u8]) -> IResult<&[u8], ImapMailbox> {
|
||||||
({
|
({
|
||||||
let separator: u8 = separator[0];
|
let separator: u8 = separator[0];
|
||||||
let mut f = ImapMailbox::default();
|
let mut f = ImapMailbox::default();
|
||||||
|
f.has_children = true;
|
||||||
f.no_select = false;
|
f.no_select = false;
|
||||||
f.is_subscribed = 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);
|
let _ = f.set_special_usage(SpecialUsageMailbox::Flagged);
|
||||||
} else if p.eq_ignore_ascii_case(b"\\Archive") {
|
} else if p.eq_ignore_ascii_case(b"\\Archive") {
|
||||||
let _ = f.set_special_usage(SpecialUsageMailbox::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();
|
f.imap_path = path.to_string();
|
||||||
|
|
Loading…
Reference in New Issue