Make Imap::set_mdnseen return enum, not int

This commit is contained in:
Dmitry Bogatov
2019-09-20 14:47:28 +00:00
parent 6e2da27f45
commit 4bf5ba594c
2 changed files with 14 additions and 15 deletions

View File

@@ -1299,13 +1299,13 @@ impl Imap {
} }
} }
pub fn set_mdnsent<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> usize { pub fn set_mdnsent<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> ImapResult {
// returns 0=job should be retried later, 1=job done, 2=job done and flag just set // returns 0=job should be retried later, 1=job done, 2=job done and flag just set
let mut res = DC_RETRY_LATER; let mut res = ImapResult::RetryLater;
let set = format!("{}", uid); let set = format!("{}", uid);
if uid == 0 { if uid == 0 {
res = DC_FAILED; res = ImapResult::Failed;
} else if self.is_connected() { } else if self.is_connected() {
info!( info!(
context, context,
@@ -1375,21 +1375,21 @@ impl Imap {
.unwrap_or_else(|| false); .unwrap_or_else(|| false);
res = if flag_set { res = if flag_set {
DC_ALREADY_DONE ImapResult::AlreadyDone
} else if self.add_flag(context, uid, "$MDNSent") != 0 { } else if self.add_flag(context, uid, "$MDNSent") != 0 {
DC_SUCCESS ImapResult::Success
} else { } else {
res res
}; };
if res == DC_SUCCESS { if res == ImapResult::Success {
info!(context, "$MDNSent just set and MDN will be sent."); info!(context, "$MDNSent just set and MDN will be sent.");
} else { } else {
info!(context, "$MDNSent already set and MDN already sent."); info!(context, "$MDNSent already set and MDN already sent.");
} }
} }
} else { } else {
res = DC_SUCCESS; res = ImapResult::Success;
info!( info!(
context, context,
"Cannot store $MDNSent flags, risk sending duplicate MDN.", "Cannot store $MDNSent flags, risk sending duplicate MDN.",
@@ -1398,11 +1398,11 @@ impl Imap {
} }
} }
if res == DC_RETRY_LATER { if res == ImapResult::RetryLater {
if self.should_reconnect() { if self.should_reconnect() {
DC_RETRY_LATER ImapResult::RetryLater
} else { } else {
DC_FAILED ImapResult::Failed
} }
} else { } else {
res res

View File

@@ -346,15 +346,14 @@ impl Job {
{ {
let folder = msg.server_folder.as_ref().unwrap(); let folder = msg.server_folder.as_ref().unwrap();
match inbox.set_mdnsent(context, folder, msg.server_uid) as libc::c_uint match inbox.set_mdnsent(context, folder, msg.server_uid) {
{ ImapResult::RetryLater => {
1 => {
self.try_again_later(3i32, None); self.try_again_later(3i32, None);
} }
3 => { ImapResult::Success => {
send_mdn(context, msg.id); send_mdn(context, msg.id);
} }
0 | 2 | _ => {} ImapResult::Failed | ImapResult::AlreadyDone => {}
} }
} }
} }