| | |
| |
|
| | #![allow(missing_docs)] |
| |
|
| | use deltachat_derive::{FromSql, ToSql}; |
| | use percent_encoding::{AsciiSet, NON_ALPHANUMERIC}; |
| | use serde::{Deserialize, Serialize}; |
| |
|
| | use crate::chat::ChatId; |
| |
|
| | pub static DC_VERSION_STR: &str = env!("CARGO_PKG_VERSION"); |
| |
|
| | |
| | pub(crate) const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.'); |
| |
|
| | #[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, |
| | } |
| |
|
| | 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_ADD_SELF: u32 = 0x02; |
| | pub const DC_GCL_ADDRESS: u32 = 0x04; |
| |
|
| | |
| | pub(crate) const DC_RESEND_USER_AVATAR_DAYS: i64 = 14; |
| |
|
| | |
| | |
| | |
| | |
| | |
| | pub(crate) const DC_OUTDATED_WARNING_DAYS: i64 = 183; |
| |
|
| | |
| | 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, |
| | PartialOrd, |
| | Ord, |
| | FromPrimitive, |
| | ToPrimitive, |
| | FromSql, |
| | ToSql, |
| | IntoStaticStr, |
| | Serialize, |
| | Deserialize, |
| | )] |
| | #[repr(u32)] |
| | pub enum Chattype { |
| | |
| | |
| | |
| | Single = 100, |
| |
|
| | |
| | |
| | |
| | Group = 120, |
| |
|
| | |
| | |
| | Mailinglist = 140, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | OutBroadcast = 160, |
| |
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | InBroadcast = 165, |
| | } |
| |
|
| | 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 const BALANCED_IMAGE_BYTES: usize = 500_000; |
| | pub const WORSE_IMAGE_BYTES: usize = 130_000; |
| |
|
| | |
| | pub(crate) const BALANCED_AVATAR_SIZE: u32 = 512; |
| | pub(crate) const BALANCED_AVATAR_BYTES: usize = 60_000; |
| | pub(crate) const WORSE_AVATAR_SIZE: u32 = 128; |
| | pub(crate) const WORSE_AVATAR_BYTES: usize = 20_000; |
| |
|
| | |
| | pub const BALANCED_IMAGE_SIZE: u32 = 1280; |
| | pub const WORSE_IMAGE_SIZE: u32 = 640; |
| |
|
| | |
| | |
| | pub const MAX_RCVD_IMAGE_PIXELS: u32 = 50_000_000; |
| |
|
| | |
| | pub(crate) const DC_FOLDERS_CONFIGURED_KEY: &str = "folders_configured"; |
| | |
| | pub(crate) const DC_FOLDERS_CONFIGURED_VERSION: i32 = 5; |
| |
|
| | |
| | |
| | |
| | pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50; |
| |
|
| | |
| | pub(crate) const DEFAULT_CHATMAIL_MAX_SMTP_RCPT_TO: usize = 999; |
| |
|
| | |
| | pub(crate) const DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT: u64 = 12 * 60 * 60; |
| |
|
| | |
| | |
| | pub(crate) const TIMESTAMP_SENT_TOLERANCE: i64 = 60; |
| |
|
| | |
| | |
| | pub(crate) const EDITED_PREFIX: &str = "✏️"; |
| |
|
| | |
| | |
| | pub(crate) const ASM_SUBJECT: &str = "Autocrypt Setup Message"; |
| | pub(crate) const ASM_BODY: &str = "This is the Autocrypt Setup Message \ |
| | used to transfer your end-to-end setup between clients. |
| | |
| | To decrypt and use your setup, \ |
| | open the message in an Autocrypt-compliant client \ |
| | and enter the setup code presented on the generating device. |
| | |
| | If you see this message in a chatmail client (Delta Chat, Arcane Chat, Delta Touch ...), \ |
| | use \"Settings / Add Second Device\" instead."; |
| |
|
| | |
| | pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60; |
| |
|
| | pub(crate) const BROADCAST_INCOMPATIBILITY_MSG: &str = r#"The up to now "experimental channels feature" is about to become an officially supported one. By that, privacy will be improved, it will become faster, and less traffic will be consumed. |
| | |
| | As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again. |
| | |
| | Here is what to do: |
| | • Create a new channel |
| | • Tap on the channel name |
| | • Tap on "QR Invite Code" |
| | • Have all recipients scan the QR code, or send them the link |
| | |
| | If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#; |
| |
|
| | #[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::OutBroadcast, Chattype::from_i32(160).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()); |
| | } |
| | } |
| |
|