implment set_seen

This commit is contained in:
dignifiedquire
2019-05-06 11:09:54 +02:00
parent 29a9a408ef
commit 7fe8584db3
2 changed files with 62 additions and 55 deletions

View File

@@ -1096,13 +1096,13 @@ impl dc_imap_t {
cvar.notify_one(); cvar.notify_one();
} }
pub fn mv( pub fn mv<S1: AsRef<str>, S2: AsRef<str>>(
&self, &self,
context: &dc_context_t, context: &dc_context_t,
folder: *const libc::c_char, folder: S1,
uid: uint32_t, uid: u32,
dest_folder: *const libc::c_char, dest_folder: S2,
dest_uid: *mut uint32_t, dest_uid: &mut u32,
) -> usize { ) -> usize {
unimplemented!() unimplemented!()
// let mut current_block: u64; // let mut current_block: u64;
@@ -1266,51 +1266,55 @@ impl dc_imap_t {
} }
} }
pub fn set_seen( pub fn set_seen<S: AsRef<str>>(&self, context: &dc_context_t, folder: S, uid: u32) -> usize {
&self, let mut res = DC_RETRY_LATER;
context: &dc_context_t,
folder: *const libc::c_char, if uid == 0 {
uid: uint32_t, res = DC_FAILED
) -> usize { } else if self.is_connected() {
unimplemented!() let folder_c = CString::new(folder.as_ref().to_owned()).unwrap();
// let mut res: usize = DC_RETRY_LATER;
// if folder.is_null() || uid == 0 as libc::c_uint { unsafe {
// res = DC_FAILED dc_log_info(
// } else if !imap.etpan.is_null() { context,
// dc_log_info( 0,
// context, b"Marking message %s/%i as seen...\x00" as *const u8 as *const libc::c_char,
// 0, folder_c.as_ptr(),
// b"Marking message %s/%i as seen...\x00" as *const u8 as *const libc::c_char, uid as libc::c_int,
// folder, )
// uid as libc::c_int, };
// ); if self.select_folder(context, Some(folder)) == 0 {
// if select_folder(context, imap, folder) == 0 { unsafe {
// dc_log_warning( dc_log_warning(
// context, context,
// 0, 0,
// b"Cannot select folder %s for setting SEEN flag.\x00" as *const u8 b"Cannot select folder %s for setting SEEN flag.\x00" as *const u8
// as *const libc::c_char, as *const libc::c_char,
// folder, folder_c.as_ptr(),
// ); )
// } else if add_flag(imap, uid, mailimap_flag_new_seen()) == 0 { };
// dc_log_warning( } else if self.add_flag(uid, "\\Seen") == 0 {
// context, unsafe {
// 0, dc_log_warning(
// b"Cannot mark message as seen.\x00" as *const u8 as *const libc::c_char, context,
// ); 0,
// } else { b"Cannot mark message as seen.\x00" as *const u8 as *const libc::c_char,
// res = DC_SUCCESS )
// } };
// } } else {
// return (if res as libc::c_uint == DC_RETRY_LATER as libc::c_int as libc::c_uint { res = DC_SUCCESS
// (if 0 != imap.should_reconnect { }
// DC_RETRY_LATER as libc::c_int }
// } else {
// DC_FAILED as libc::c_int if res == DC_RETRY_LATER {
// }) as libc::c_uint if self.should_reconnect() {
// } else { DC_RETRY_LATER
// res as libc::c_uint } else {
// }) as usize; DC_FAILED
}
} else {
res
}
} }
pub fn set_mdnsent<S: AsRef<str>>(&self, context: &dc_context_t, folder: S, uid: u32) -> usize { pub fn set_mdnsent<S: AsRef<str>>(&self, context: &dc_context_t, folder: S, uid: u32) -> usize {

View File

@@ -505,11 +505,13 @@ unsafe fn dc_job_do_DC_JOB_MOVE_MSG(mut context: &dc_context_t, mut job: *mut dc
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char, b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
0 as *const libc::c_char, 0 as *const libc::c_char,
); );
let server_folder = CStr::from_ptr((*msg).server_folder).to_str().unwrap();
match inbox.mv( match inbox.mv(
context, context,
(*msg).server_folder, server_folder,
(*msg).server_uid, (*msg).server_uid,
dest_folder, CStr::from_ptr(dest_folder).to_str().unwrap(),
&mut dest_uid, &mut dest_uid,
) as libc::c_uint ) as libc::c_uint
{ {
@@ -589,6 +591,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &dc_context_t, job: *mu
} }
match current_block { match current_block {
11006700562992250127 => { 11006700562992250127 => {
let folder = CStr::from_ptr(folder).to_str().unwrap();
if inbox.set_seen(context, folder, uid) as libc::c_uint == 0i32 as libc::c_uint { if inbox.set_seen(context, folder, uid) as libc::c_uint == 0i32 as libc::c_uint {
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char); dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
} }
@@ -608,6 +611,7 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(context: &dc_context_t, job: *mu
b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char, b"configured_mvbox_folder\x00" as *const u8 as *const libc::c_char,
0 as *const libc::c_char, 0 as *const libc::c_char,
); );
let dest_folder = CStr::from_ptr(dest_folder).to_str().unwrap();
match inbox.mv(context, folder, uid, dest_folder, &mut dest_uid) as libc::c_uint { match inbox.mv(context, folder, uid, dest_folder, &mut dest_uid) as libc::c_uint {
1 => { 1 => {
dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char); dc_job_try_again_later(job, 3i32, 0 as *const libc::c_char);
@@ -643,9 +647,8 @@ unsafe fn dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(
match current_block { match current_block {
15240798224410183470 => { 15240798224410183470 => {
if !(0 == dc_msg_load_from_db(msg, context, (*job).foreign_id)) { if !(0 == dc_msg_load_from_db(msg, context, (*job).foreign_id)) {
match inbox.set_seen(context, (*msg).server_folder, (*msg).server_uid) let server_folder = CStr::from_ptr((*msg).server_folder).to_str().unwrap();
as libc::c_uint match inbox.set_seen(context, server_folder, (*msg).server_uid) as libc::c_uint {
{
0 => {} 0 => {}
1 => { 1 => {
current_block = 12392248546350854223; current_block = 12392248546350854223;