diff --git a/examples/repl/cmdline.rs b/examples/repl/cmdline.rs index 2db101ff3..072463cc9 100644 --- a/examples/repl/cmdline.rs +++ b/examples/repl/cmdline.rs @@ -1018,9 +1018,9 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu let contacts = Contact::get_all( &context, if arg0 == "listverified" { - 0x1 | 0x2 + DC_GCL_VERIFIED_ONLY | DC_GCL_ADD_SELF } else { - 0x2 + DC_GCL_ADD_SELF }, Some(arg1), ) diff --git a/src/constants.rs b/src/constants.rs index b60f2b418..52019567c 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -101,8 +101,8 @@ pub const DC_GCL_FOR_FORWARDING: usize = 0x08; pub const DC_GCM_ADDDAYMARKER: u32 = 0x01; pub const DC_GCM_INFO_ONLY: u32 = 0x02; -pub const DC_GCL_VERIFIED_ONLY: usize = 0x01; -pub const DC_GCL_ADD_SELF: usize = 0x02; +pub const DC_GCL_VERIFIED_ONLY: u32 = 0x01; +pub const DC_GCL_ADD_SELF: u32 = 0x02; // unchanged user avatars are resent to the recipients every some days pub const DC_RESEND_USER_AVATAR_DAYS: i64 = 14; diff --git a/src/contact.rs b/src/contact.rs index 92e100149..d72a51d7e 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -16,7 +16,7 @@ use crate::constants::{ DC_CONTACT_ID_LAST_SPECIAL, DC_CONTACT_ID_SELF, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY, }; use crate::context::Context; -use crate::dc_tools::{dc_get_abs_path, improve_single_line_input, listflags_has, EmailAddress}; +use crate::dc_tools::{dc_get_abs_path, improve_single_line_input, EmailAddress}; use crate::events::EventType; use crate::key::{DcKey, SignedPublicKey}; use crate::login_param::LoginParam; @@ -586,8 +586,8 @@ impl Contact { let mut add_self = false; let mut ret = Vec::new(); - let flag_verified_only = listflags_has(listflags, DC_GCL_VERIFIED_ONLY); - let flag_add_self = listflags_has(listflags, DC_GCL_ADD_SELF); + let flag_verified_only = (listflags & DC_GCL_VERIFIED_ONLY) != 0; + let flag_add_self = (listflags & DC_GCL_ADD_SELF) != 0; if flag_verified_only || query.is_some() { let s3str_like_cmd = format!( diff --git a/src/dc_tools.rs b/src/dc_tools.rs index 7b7ac7207..6d80274b8 100644 --- a/src/dc_tools.rs +++ b/src/dc_tools.rs @@ -642,13 +642,6 @@ impl rusqlite::types::ToSql for EmailAddress { } } -/// Utility to check if a in the binary represantion of listflags -/// the bit at position bitindex is 1. -pub(crate) fn listflags_has(listflags: u32, bitindex: usize) -> bool { - let listflags = listflags as usize; - (listflags & bitindex) == bitindex -} - /// Makes sure that a user input that is not supposed to contain newlines does not contain newlines. pub(crate) fn improve_single_line_input(input: impl AsRef) -> String { input @@ -676,9 +669,7 @@ mod tests { #![allow(clippy::indexing_slicing)] use super::*; - use std::convert::TryInto; - use crate::constants::{DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY}; use crate::test_utils::TestContext; #[test] @@ -930,20 +921,6 @@ mod tests { assert!(!dc_file_exist!(context, &fn0).await); } - #[test] - fn test_listflags_has() { - let listflags: u32 = 0x1101; - assert!(listflags_has(listflags, 0x1)); - assert!(!listflags_has(listflags, 0x10)); - assert!(listflags_has(listflags, 0x100)); - assert!(listflags_has(listflags, 0x1000)); - let listflags: u32 = (DC_GCL_ADD_SELF | DC_GCL_VERIFIED_ONLY).try_into().unwrap(); - assert!(listflags_has(listflags, DC_GCL_VERIFIED_ONLY)); - assert!(listflags_has(listflags, DC_GCL_ADD_SELF)); - let listflags: u32 = DC_GCL_VERIFIED_ONLY.try_into().unwrap(); - assert!(!listflags_has(listflags, DC_GCL_ADD_SELF)); - } - #[async_std::test] async fn test_create_smeared_timestamp() { let t = TestContext::new().await;