|
|
|
|
|
|
|
|
#![allow(missing_docs)] |
|
|
|
|
|
use deltachat_derive::{FromSql, ToSql}; |
|
|
use once_cell::sync::Lazy; |
|
|
use serde::{Deserialize, Serialize}; |
|
|
|
|
|
use crate::chat::ChatId; |
|
|
|
|
|
pub static DC_VERSION_STR: Lazy<String> = Lazy::new(|| env!("CARGO_PKG_VERSION").to_string()); |
|
|
|
|
|
#[derive( |
|
|
Debug, |
|
|
Default, |
|
|
Display, |
|
|
Clone, |
|
|
Copy, |
|
|
PartialEq, |
|
|
Eq, |
|
|
FromPrimitive, |
|
|
ToPrimitive, |
|
|
FromSql, |
|
|
ToSql, |
|
|
Serialize, |
|
|
Deserialize, |
|
|
)] |
|
|
#[repr(i8)] |
|
|
pub enum Blocked { |
|
|
#[default] |
|
|
Not = 0, |
|
|
Yes = 1, |
|
|
Request = 2, |
|
|
} |
|
|
|
|
|
#[derive( |
|
|
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, |
|
|
)] |
|
|
#[repr(u8)] |
|
|
pub enum ShowEmails { |
|
|
Off = 0, |
|
|
AcceptedContacts = 1, |
|
|
#[default] |
|
|
All = 2, |
|
|
} |
|
|
|
|
|
#[derive( |
|
|
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, |
|
|
)] |
|
|
#[repr(u8)] |
|
|
pub enum MediaQuality { |
|
|
#[default] |
|
|
Balanced = 0, |
|
|
Worse = 1, |
|
|
} |
|
|
|
|
|
|
|
|
#[derive( |
|
|
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, |
|
|
)] |
|
|
#[repr(u8)] |
|
|
pub enum KeyGenType { |
|
|
#[default] |
|
|
Default = 0, |
|
|
|
|
|
|
|
|
Rsa2048 = 1, |
|
|
|
|
|
|
|
|
Ed25519 = 2, |
|
|
|
|
|
|
|
|
Rsa4096 = 3, |
|
|
} |
|
|
|
|
|
|
|
|
#[derive( |
|
|
Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql, |
|
|
)] |
|
|
#[repr(i8)] |
|
|
pub enum VideochatType { |
|
|
|
|
|
#[default] |
|
|
Unknown = 0, |
|
|
|
|
|
|
|
|
BasicWebrtc = 1, |
|
|
|
|
|
|
|
|
Jitsi = 2, |
|
|
} |
|
|
|
|
|
pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01; |
|
|
pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02; |
|
|
pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04; |
|
|
|
|
|
pub(crate) const DC_FROM_HANDSHAKE: i32 = 0x01; |
|
|
|
|
|
pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01; |
|
|
pub const DC_GCL_NO_SPECIALS: usize = 0x02; |
|
|
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04; |
|
|
pub const DC_GCL_FOR_FORWARDING: usize = 0x08; |
|
|
|
|
|
pub const DC_GCL_VERIFIED_ONLY: u32 = 0x01; |
|
|
pub const DC_GCL_ADD_SELF: u32 = 0x02; |
|
|
|
|
|
|
|
|
pub(crate) const DC_RESEND_USER_AVATAR_DAYS: i64 = 14; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) const DC_OUTDATED_WARNING_DAYS: i64 = 365; |
|
|
|
|
|
|
|
|
pub const DC_CHAT_ID_TRASH: ChatId = ChatId::new(3); |
|
|
|
|
|
pub const DC_CHAT_ID_ARCHIVED_LINK: ChatId = ChatId::new(6); |
|
|
|
|
|
pub const DC_CHAT_ID_ALLDONE_HINT: ChatId = ChatId::new(7); |
|
|
|
|
|
pub const DC_CHAT_ID_LAST_SPECIAL: ChatId = ChatId::new(9); |
|
|
|
|
|
|
|
|
#[derive( |
|
|
Debug, |
|
|
Display, |
|
|
Clone, |
|
|
Copy, |
|
|
PartialEq, |
|
|
Eq, |
|
|
FromPrimitive, |
|
|
ToPrimitive, |
|
|
FromSql, |
|
|
ToSql, |
|
|
IntoStaticStr, |
|
|
Serialize, |
|
|
Deserialize, |
|
|
)] |
|
|
#[repr(u32)] |
|
|
pub enum Chattype { |
|
|
|
|
|
Single = 100, |
|
|
|
|
|
|
|
|
Group = 120, |
|
|
|
|
|
|
|
|
Mailinglist = 140, |
|
|
|
|
|
|
|
|
Broadcast = 160, |
|
|
} |
|
|
|
|
|
pub const DC_MSG_ID_DAYMARKER: u32 = 9; |
|
|
pub const DC_MSG_ID_LAST_SPECIAL: u32 = 9; |
|
|
|
|
|
|
|
|
pub(crate) const DC_ELLIPSIS: &str = "[...]"; |
|
|
|
|
|
|
|
|
pub const DC_DESIRED_TEXT_LINES: usize = 38; |
|
|
|
|
|
pub const DC_DESIRED_TEXT_LINE_LEN: usize = 100; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub const DC_DESIRED_TEXT_LEN: usize = DC_DESIRED_TEXT_LINE_LEN * DC_DESIRED_TEXT_LINES; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub const DC_LP_AUTH_OAUTH2: i32 = 0x2; |
|
|
|
|
|
|
|
|
|
|
|
pub const DC_LP_AUTH_NORMAL: i32 = 0x4; |
|
|
|
|
|
|
|
|
pub const DC_LP_AUTH_FLAGS: i32 = DC_LP_AUTH_OAUTH2 | DC_LP_AUTH_NORMAL; |
|
|
|
|
|
|
|
|
pub(crate) const DC_FETCH_EXISTING_MSGS_COUNT: i64 = 100; |
|
|
|
|
|
|
|
|
pub const BALANCED_IMAGE_BYTES: usize = 500_000; |
|
|
pub const WORSE_IMAGE_BYTES: usize = 130_000; |
|
|
|
|
|
|
|
|
pub(crate) const BALANCED_AVATAR_SIZE: u32 = 256; |
|
|
pub(crate) const WORSE_AVATAR_SIZE: u32 = 128; |
|
|
|
|
|
|
|
|
pub const BALANCED_IMAGE_SIZE: u32 = 1280; |
|
|
pub const WORSE_IMAGE_SIZE: u32 = 640; |
|
|
|
|
|
|
|
|
pub(crate) const DC_FOLDERS_CONFIGURED_KEY: &str = "folders_configured"; |
|
|
|
|
|
pub(crate) const DC_FOLDERS_CONFIGURED_VERSION: i32 = 4; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50; |
|
|
|
|
|
|
|
|
pub(crate) const DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT: u64 = 12 * 60 * 60; |
|
|
|
|
|
|
|
|
|
|
|
pub(crate) const TIMESTAMP_SENT_TOLERANCE: i64 = 60; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub(crate) const SECUREJOIN_WAIT_TIMEOUT: u64 = 15; |
|
|
|
|
|
#[cfg(test)] |
|
|
mod tests { |
|
|
use num_traits::FromPrimitive; |
|
|
|
|
|
use super::*; |
|
|
|
|
|
#[test] |
|
|
fn test_chattype_values() { |
|
|
|
|
|
assert_eq!(Chattype::Single, Chattype::from_i32(100).unwrap()); |
|
|
assert_eq!(Chattype::Group, Chattype::from_i32(120).unwrap()); |
|
|
assert_eq!(Chattype::Mailinglist, Chattype::from_i32(140).unwrap()); |
|
|
assert_eq!(Chattype::Broadcast, Chattype::from_i32(160).unwrap()); |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_keygentype_values() { |
|
|
|
|
|
assert_eq!(KeyGenType::Default, KeyGenType::default()); |
|
|
assert_eq!(KeyGenType::Default, KeyGenType::from_i32(0).unwrap()); |
|
|
assert_eq!(KeyGenType::Rsa2048, KeyGenType::from_i32(1).unwrap()); |
|
|
assert_eq!(KeyGenType::Ed25519, KeyGenType::from_i32(2).unwrap()); |
|
|
assert_eq!(KeyGenType::Rsa4096, KeyGenType::from_i32(3).unwrap()); |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_showemails_values() { |
|
|
|
|
|
assert_eq!(ShowEmails::All, ShowEmails::default()); |
|
|
assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap()); |
|
|
assert_eq!( |
|
|
ShowEmails::AcceptedContacts, |
|
|
ShowEmails::from_i32(1).unwrap() |
|
|
); |
|
|
assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap()); |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_blocked_values() { |
|
|
|
|
|
assert_eq!(Blocked::Not, Blocked::default()); |
|
|
assert_eq!(Blocked::Not, Blocked::from_i32(0).unwrap()); |
|
|
assert_eq!(Blocked::Yes, Blocked::from_i32(1).unwrap()); |
|
|
assert_eq!(Blocked::Request, Blocked::from_i32(2).unwrap()); |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_mediaquality_values() { |
|
|
|
|
|
assert_eq!(MediaQuality::Balanced, MediaQuality::default()); |
|
|
assert_eq!(MediaQuality::Balanced, MediaQuality::from_i32(0).unwrap()); |
|
|
assert_eq!(MediaQuality::Worse, MediaQuality::from_i32(1).unwrap()); |
|
|
} |
|
|
|
|
|
#[test] |
|
|
fn test_videochattype_values() { |
|
|
|
|
|
assert_eq!(VideochatType::Unknown, VideochatType::default()); |
|
|
assert_eq!(VideochatType::Unknown, VideochatType::from_i32(0).unwrap()); |
|
|
assert_eq!( |
|
|
VideochatType::BasicWebrtc, |
|
|
VideochatType::from_i32(1).unwrap() |
|
|
); |
|
|
assert_eq!(VideochatType::Jitsi, VideochatType::from_i32(2).unwrap()); |
|
|
} |
|
|
} |
|
|
|