diff --git a/deltachat-ffi/src/lib.rs b/deltachat-ffi/src/lib.rs index c042ded02..20b61f50a 100644 --- a/deltachat-ffi/src/lib.rs +++ b/deltachat-ffi/src/lib.rs @@ -2152,7 +2152,7 @@ pub unsafe extern "C" fn dc_msg_is_sent(msg: *mut dc_msg_t) -> libc::c_int { return 0; } let ffi_msg = &*msg; - message::dc_msg_is_sent(&ffi_msg.message) + message::dc_msg_is_sent(&ffi_msg.message).into() } #[no_mangle] @@ -2172,7 +2172,7 @@ pub unsafe extern "C" fn dc_msg_is_forwarded(msg: *mut dc_msg_t) -> libc::c_int return 0; } let ffi_msg = &*msg; - message::dc_msg_is_forwarded(&ffi_msg.message) + message::dc_msg_is_forwarded(&ffi_msg.message).into() } #[no_mangle] @@ -2182,7 +2182,7 @@ pub unsafe extern "C" fn dc_msg_is_info(msg: *mut dc_msg_t) -> libc::c_int { return 0; } let ffi_msg = &*msg; - message::dc_msg_is_info(&ffi_msg.message) + message::dc_msg_is_info(&ffi_msg.message).into() } #[no_mangle] @@ -2192,7 +2192,7 @@ pub unsafe extern "C" fn dc_msg_is_increation(msg: *mut dc_msg_t) -> libc::c_int return 0; } let ffi_msg = &*msg; - message::dc_msg_is_increation(&ffi_msg.message) + message::dc_msg_is_increation(&ffi_msg.message).into() } #[no_mangle] @@ -2202,7 +2202,7 @@ pub unsafe extern "C" fn dc_msg_is_setupmessage(msg: *mut dc_msg_t) -> libc::c_i return 0; } let ffi_msg = &*msg; - message::dc_msg_is_setupmessage(&ffi_msg.message) as libc::c_int + message::dc_msg_is_setupmessage(&ffi_msg.message).into() } #[no_mangle] diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 8f6ea5a5e..8e0923f06 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -248,11 +248,7 @@ unsafe fn log_msg(context: &Context, prefix: impl AsRef, msg: &Message) { } else { "[FRESH]" }, - if 0 != dc_msg_is_info(msg) { - "[INFO]" - } else { - "" - }, + if dc_msg_is_info(msg) { "[INFO]" } else { "" }, statestr, &temp2, ); diff --git a/src/chat.rs b/src/chat.rs index 243f1f88f..4442cb350 100644 --- a/src/chat.rs +++ b/src/chat.rs @@ -868,7 +868,7 @@ unsafe fn set_draft_raw(context: &Context, chat_id: u32, mut msg: Option<&mut Me } else if msgtype_has_file(msg.type_0) { if let Some(path_filename) = msg.param.get(Param::File) { let mut path_filename = path_filename.to_string(); - if 0 != dc_msg_is_increation(msg) && !dc_is_blobdir_path(context, &path_filename) { + if dc_msg_is_increation(msg) && !dc_is_blobdir_path(context, &path_filename) { OK_TO_CONTINUE = false; } else if !dc_make_rel_and_copy(context, &mut path_filename) { OK_TO_CONTINUE = false; diff --git a/src/dc_imex.rs b/src/dc_imex.rs index 54d6161ab..06f6c6e87 100644 --- a/src/dc_imex.rs +++ b/src/dc_imex.rs @@ -168,7 +168,7 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char { } std::thread::sleep(std::time::Duration::from_secs(1)); if let Ok(msg) = dc_get_msg(context, msg_id) { - if 0 != dc_msg_is_sent(&msg) { + if dc_msg_is_sent(&msg) { info!(context, "... setup message sent.",); break; } diff --git a/src/dc_mimefactory.rs b/src/dc_mimefactory.rs index 371c55b33..090cc4a00 100644 --- a/src/dc_mimefactory.rs +++ b/src/dc_mimefactory.rs @@ -39,7 +39,7 @@ pub struct dc_mimefactory_t<'a> { pub loaded: dc_mimefactory_loaded_t, pub msg: Message, pub chat: Option, - pub increation: libc::c_int, + pub increation: bool, pub in_reply_to: *mut libc::c_char, pub references: *mut libc::c_char, pub req_mdn: libc::c_int, @@ -102,7 +102,7 @@ pub unsafe fn dc_mimefactory_load_msg( loaded: DC_MF_NOTHING_LOADED, msg, chat: Some(chat), - increation: 0, + increation: false, in_reply_to: ptr::null_mut(), references: ptr::null_mut(), req_mdn: 0, @@ -290,7 +290,7 @@ pub unsafe fn dc_mimefactory_load_mdn<'a>( loaded: DC_MF_NOTHING_LOADED, msg, chat: None, - increation: 0, + increation: false, in_reply_to: ptr::null_mut(), references: ptr::null_mut(), req_mdn: 0, diff --git a/src/message.rs b/src/message.rs index 7b50fb9b5..368a2f83f 100644 --- a/src/message.rs +++ b/src/message.rs @@ -87,7 +87,7 @@ impl Lot { self.text1 = Some(context.stock_str(StockMessage::Draft).to_owned().into()); self.text1_meaning = Meaning::Text1Draft; } else if msg.from_id == DC_CONTACT_ID_SELF { - if 0 != dc_msg_is_info(msg) || chat.is_self_talk() { + if dc_msg_is_info(msg) || chat.is_self_talk() { self.text1 = None; self.text1_meaning = Meaning::None; } else { @@ -95,7 +95,7 @@ impl Lot { self.text1_meaning = Meaning::Text1Self; } } else if chat.typ == Chattype::Group || chat.typ == Chattype::VerifiedGroup { - if 0 != dc_msg_is_info(msg) || contact.is_none() { + if dc_msg_is_info(msg) || contact.is_none() { self.text1 = None; self.text1_meaning = Meaning::None; } else { @@ -820,48 +820,27 @@ pub unsafe fn dc_msg_has_deviating_timestamp(msg: &Message) -> libc::c_int { (sort_timestamp / 86400 != send_timestamp / 86400) as libc::c_int } -// TODO should return bool /rtn -pub fn dc_msg_is_sent(msg: &Message) -> libc::c_int { - if msg.state as i32 >= MessageState::OutDelivered as i32 { - 1 - } else { - 0 - } +pub fn dc_msg_is_sent(msg: &Message) -> bool { + msg.state as i32 >= MessageState::OutDelivered as i32 } pub fn dc_msg_is_starred(msg: &Message) -> bool { msg.starred } -// TODO should return bool /rtn -pub fn dc_msg_is_forwarded(msg: &Message) -> libc::c_int { - if 0 != msg.param.get_int(Param::Forwarded).unwrap_or_default() { - 1 - } else { - 0 - } +pub fn dc_msg_is_forwarded(msg: &Message) -> bool { + 0 != msg.param.get_int(Param::Forwarded).unwrap_or_default() } -// TODO should return bool /rtn -pub fn dc_msg_is_info(msg: &Message) -> libc::c_int { +pub fn dc_msg_is_info(msg: &Message) -> bool { let cmd = msg.param.get_int(Param::Cmd).unwrap_or_default(); - if msg.from_id == 2i32 as libc::c_uint + msg.from_id == 2i32 as libc::c_uint || msg.to_id == 2i32 as libc::c_uint || 0 != cmd && cmd != 6i32 - { - return 1; - } - - 0 } -// TODO should return bool /rtn -pub fn dc_msg_is_increation(msg: &Message) -> libc::c_int { - if chat::msgtype_has_file(msg.type_0) && msg.state == MessageState::OutPreparing { - 1 - } else { - 0 - } +pub fn dc_msg_is_increation(msg: &Message) -> bool { + chat::msgtype_has_file(msg.type_0) && msg.state == MessageState::OutPreparing } pub fn dc_msg_is_setupmessage(msg: &Message) -> bool {