Browse Source

imap: use ImapLineIterator in imap_mailboxes()

async
Manos Pitsidianakis 2 years ago
parent
commit
350c8033b1
Signed by: epilys GPG Key ID: 73627C2F690DF710
  1. 8
      melib/src/backends/imap.rs
  2. 3
      melib/src/backends/imap/protocol_parser.rs

8
melib/src/backends/imap.rs

@ -919,10 +919,10 @@ impl ImapType {
.read_response(&mut res, RequiredResponses::LIST_REQUIRED)
.await?;
debug!("out: {}", &res);
let mut lines = res.lines();
let mut lines = res.split_rn();
/* Remove "M__ OK .." line */
lines.next_back();
for l in lines.map(|l| l.trim()) {
for l in lines {
if let Ok(mut mailbox) =
protocol_parser::list_mailbox_result(l.as_bytes()).map(|(_, v)| v)
{
@ -959,11 +959,11 @@ impl ImapType {
conn.send_command(b"LSUB \"\" \"*\"").await?;
conn.read_response(&mut res, RequiredResponses::LSUB_REQUIRED)
.await?;
let mut lines = res.lines();
let mut lines = res.split_rn();
debug!("out: {}", &res);
/* Remove "M__ OK .." line */
lines.next_back();
for l in lines.map(|l| l.trim()) {
for l in lines {
if let Ok(subscription) =
protocol_parser::list_mailbox_result(l.as_bytes()).map(|(_, v)| v)
{

3
melib/src/backends/imap/protocol_parser.rs

@ -392,6 +392,7 @@ pub fn list_mailbox_result(input: &[u8]) -> IResult<&[u8], ImapMailbox> {
let (input, separator) = delimited(tag(b"\""), take(1_u32), tag(b"\""))(input)?;
let (input, _) = take(1_u32)(input)?;
let (input, path) = mailbox_token(input)?;
let (input, _) = tag("\r\n")(input)?;
Ok((
input,
({
@ -1565,5 +1566,5 @@ fn string_token(input: &[u8]) -> IResult<&[u8], &[u8]> {
// atom-specials = "(" / ")" / "{" / SP / CTL / list-wildcards / quoted-specials / resp-specials
fn astring_char_tokens(input: &[u8]) -> IResult<&[u8], &[u8]> {
// FIXME
is_not(" ")(input)
is_not(" \r\n")(input)
}
Loading…
Cancel
Save