mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
Remove dc_tools::listflags_has
It was not even doing what the documentation says: the implementation worked correctly only for bitindex=1 and bitindex=2.
This commit is contained in:
@@ -1018,9 +1018,9 @@ pub async fn cmdline(context: Context, line: &str, chat_id: &mut ChatId) -> Resu
|
|||||||
let contacts = Contact::get_all(
|
let contacts = Contact::get_all(
|
||||||
&context,
|
&context,
|
||||||
if arg0 == "listverified" {
|
if arg0 == "listverified" {
|
||||||
0x1 | 0x2
|
DC_GCL_VERIFIED_ONLY | DC_GCL_ADD_SELF
|
||||||
} else {
|
} else {
|
||||||
0x2
|
DC_GCL_ADD_SELF
|
||||||
},
|
},
|
||||||
Some(arg1),
|
Some(arg1),
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ pub const DC_GCL_FOR_FORWARDING: usize = 0x08;
|
|||||||
pub const DC_GCM_ADDDAYMARKER: u32 = 0x01;
|
pub const DC_GCM_ADDDAYMARKER: u32 = 0x01;
|
||||||
pub const DC_GCM_INFO_ONLY: u32 = 0x02;
|
pub const DC_GCM_INFO_ONLY: u32 = 0x02;
|
||||||
|
|
||||||
pub const DC_GCL_VERIFIED_ONLY: usize = 0x01;
|
pub const DC_GCL_VERIFIED_ONLY: u32 = 0x01;
|
||||||
pub const DC_GCL_ADD_SELF: usize = 0x02;
|
pub const DC_GCL_ADD_SELF: u32 = 0x02;
|
||||||
|
|
||||||
// unchanged user avatars are resent to the recipients every some days
|
// unchanged user avatars are resent to the recipients every some days
|
||||||
pub const DC_RESEND_USER_AVATAR_DAYS: i64 = 14;
|
pub const DC_RESEND_USER_AVATAR_DAYS: i64 = 14;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use crate::constants::{
|
|||||||
DC_CONTACT_ID_LAST_SPECIAL, DC_CONTACT_ID_SELF, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY,
|
DC_CONTACT_ID_LAST_SPECIAL, DC_CONTACT_ID_SELF, DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY,
|
||||||
};
|
};
|
||||||
use crate::context::Context;
|
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::events::EventType;
|
||||||
use crate::key::{DcKey, SignedPublicKey};
|
use crate::key::{DcKey, SignedPublicKey};
|
||||||
use crate::login_param::LoginParam;
|
use crate::login_param::LoginParam;
|
||||||
@@ -586,8 +586,8 @@ impl Contact {
|
|||||||
|
|
||||||
let mut add_self = false;
|
let mut add_self = false;
|
||||||
let mut ret = Vec::new();
|
let mut ret = Vec::new();
|
||||||
let flag_verified_only = listflags_has(listflags, DC_GCL_VERIFIED_ONLY);
|
let flag_verified_only = (listflags & DC_GCL_VERIFIED_ONLY) != 0;
|
||||||
let flag_add_self = listflags_has(listflags, DC_GCL_ADD_SELF);
|
let flag_add_self = (listflags & DC_GCL_ADD_SELF) != 0;
|
||||||
|
|
||||||
if flag_verified_only || query.is_some() {
|
if flag_verified_only || query.is_some() {
|
||||||
let s3str_like_cmd = format!(
|
let s3str_like_cmd = format!(
|
||||||
|
|||||||
@@ -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.
|
/// 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<str>) -> String {
|
pub(crate) fn improve_single_line_input(input: impl AsRef<str>) -> String {
|
||||||
input
|
input
|
||||||
@@ -676,9 +669,7 @@ mod tests {
|
|||||||
#![allow(clippy::indexing_slicing)]
|
#![allow(clippy::indexing_slicing)]
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
use crate::constants::{DC_GCL_ADD_SELF, DC_GCL_VERIFIED_ONLY};
|
|
||||||
use crate::test_utils::TestContext;
|
use crate::test_utils::TestContext;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -930,20 +921,6 @@ mod tests {
|
|||||||
assert!(!dc_file_exist!(context, &fn0).await);
|
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_std::test]
|
||||||
async fn test_create_smeared_timestamp() {
|
async fn test_create_smeared_timestamp() {
|
||||||
let t = TestContext::new().await;
|
let t = TestContext::new().await;
|
||||||
|
|||||||
Reference in New Issue
Block a user