Remove DC_IMAP_SEEN constant

Replace "flags" integer with a "seen" boolean.
This commit is contained in:
Alexander Krotov
2020-02-13 13:45:15 +03:00
committed by holger krekel
parent 4e07e4c7f3
commit 9008a65c14
4 changed files with 7 additions and 13 deletions

View File

@@ -94,7 +94,7 @@ fn dc_reset_tables(context: &Context, bits: i32) -> i32 {
fn dc_poke_eml_file(context: &Context, filename: impl AsRef<Path>) -> Result<(), Error> { fn dc_poke_eml_file(context: &Context, filename: impl AsRef<Path>) -> Result<(), Error> {
let data = dc_read_file(context, filename)?; let data = dc_read_file(context, filename)?;
if let Err(err) = dc_receive_imf(context, &data, "import", 0, 0) { if let Err(err) = dc_receive_imf(context, &data, "import", 0, false) {
println!("dc_receive_imf errored: {:?}", err); println!("dc_receive_imf errored: {:?}", err);
} }
Ok(()) Ok(())

View File

@@ -57,8 +57,6 @@ impl Default for ShowEmails {
} }
} }
pub const DC_IMAP_SEEN: u32 = 0x1;
pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01; pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02; pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02;
pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04; pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04;

View File

@@ -37,7 +37,7 @@ pub fn dc_receive_imf(
imf_raw: &[u8], imf_raw: &[u8],
server_folder: impl AsRef<str>, server_folder: impl AsRef<str>,
server_uid: u32, server_uid: u32,
flags: u32, seen: bool,
) -> Result<()> { ) -> Result<()> {
info!( info!(
context, context,
@@ -153,7 +153,7 @@ pub fn dc_receive_imf(
from_id_blocked, from_id_blocked,
&mut hidden, &mut hidden,
&mut chat_id, &mut chat_id,
flags, seen,
&mut needs_delete_job, &mut needs_delete_job,
&mut insert_msg_id, &mut insert_msg_id,
&mut created_db_entries, &mut created_db_entries,
@@ -274,7 +274,7 @@ fn add_parts(
from_id_blocked: bool, from_id_blocked: bool,
hidden: &mut bool, hidden: &mut bool,
chat_id: &mut ChatId, chat_id: &mut ChatId,
flags: u32, seen: bool,
needs_delete_job: &mut bool, needs_delete_job: &mut bool,
insert_msg_id: &mut MsgId, insert_msg_id: &mut MsgId,
created_db_entries: &mut Vec<(ChatId, MsgId)>, created_db_entries: &mut Vec<(ChatId, MsgId)>,
@@ -333,7 +333,7 @@ fn add_parts(
let to_id: u32; let to_id: u32;
if incoming { if incoming {
state = if 0 != flags & DC_IMAP_SEEN { state = if seen {
MessageState::InSeen MessageState::InSeen
} else { } else {
MessageState::InFresh MessageState::InFresh
@@ -541,7 +541,7 @@ fn add_parts(
*chat_id, *chat_id,
from_id, from_id,
*sent_timestamp, *sent_timestamp,
0 == flags & DC_IMAP_SEEN, !seen,
&mut sort_timestamp, &mut sort_timestamp,
sent_timestamp, sent_timestamp,
&mut rcvd_timestamp, &mut rcvd_timestamp,

View File

@@ -33,8 +33,6 @@ use crate::stock::StockMessage;
mod idle; mod idle;
pub mod select_folder; pub mod select_folder;
const DC_IMAP_SEEN: usize = 0x0001;
type Result<T> = std::result::Result<T, Error>; type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, Fail)] #[derive(Debug, Fail)]
@@ -773,12 +771,10 @@ impl Imap {
_ => false, _ => false,
}); });
let flags = if is_seen { DC_IMAP_SEEN } else { 0 };
if !is_deleted && msg.body().is_some() { if !is_deleted && msg.body().is_some() {
let body = msg.body().unwrap_or_default(); let body = msg.body().unwrap_or_default();
if let Err(err) = if let Err(err) =
dc_receive_imf(context, &body, folder.as_ref(), server_uid, flags as u32) dc_receive_imf(context, &body, folder.as_ref(), server_uid, is_seen)
{ {
warn!( warn!(
context, context,