Change return type of Imap::set_seen to enum

This commit is contained in:
Dmitry Bogatov
2019-09-20 14:42:41 +00:00
parent 6ee9465d43
commit 6e2da27f45
2 changed files with 11 additions and 11 deletions

View File

@@ -1262,11 +1262,11 @@ impl Imap {
}
}
pub fn set_seen<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> usize {
let mut res = DC_RETRY_LATER;
pub fn set_seen<S: AsRef<str>>(&self, context: &Context, folder: S, uid: u32) -> ImapResult {
let mut res = ImapResult::RetryLater;
if uid == 0 {
res = DC_FAILED
res = ImapResult::Failed
} else if self.is_connected() {
info!(
context,
@@ -1284,15 +1284,15 @@ impl Imap {
} else if self.add_flag(context, uid, "\\Seen") == 0 {
warn!(context, "Cannot mark message as seen.",);
} else {
res = DC_SUCCESS
res = ImapResult::Success
}
}
if res == DC_RETRY_LATER {
if res == ImapResult::RetryLater {
if self.should_reconnect() {
DC_RETRY_LATER
ImapResult::RetryLater
} else {
DC_FAILED
ImapResult::Failed
}
} else {
res

View File

@@ -332,9 +332,9 @@ impl Job {
if ok_to_continue {
if let Ok(msg) = dc_msg_load_from_db(context, self.foreign_id) {
let server_folder = msg.server_folder.as_ref().unwrap();
match inbox.set_seen(context, server_folder, msg.server_uid) as libc::c_uint {
0 => {}
1 => {
match inbox.set_seen(context, server_folder, msg.server_uid) {
ImapResult::Failed => {}
ImapResult::RetryLater => {
self.try_again_later(3i32, None);
}
_ => {
@@ -387,7 +387,7 @@ impl Job {
ok_to_continue = true;
}
if ok_to_continue {
if inbox.set_seen(context, &folder, uid) == 0 {
if inbox.set_seen(context, &folder, uid) == ImapResult::Failed {
self.try_again_later(3i32, None);
}
if 0 != self.param.get_int(Param::AlsoMove).unwrap_or_default() {