1#![allow(missing_docs)]
4
5use deltachat_derive::{FromSql, ToSql};
6use percent_encoding::{AsciiSet, NON_ALPHANUMERIC};
7use serde::{Deserialize, Serialize};
8
9use crate::chat::ChatId;
10
11pub static DC_VERSION_STR: &str = env!("CARGO_PKG_VERSION");
12
13pub(crate) const NON_ALPHANUMERIC_WITHOUT_DOT: &AsciiSet = &NON_ALPHANUMERIC.remove(b'.');
15
16#[derive(
17 Debug,
18 Default,
19 Display,
20 Clone,
21 Copy,
22 PartialEq,
23 Eq,
24 FromPrimitive,
25 ToPrimitive,
26 FromSql,
27 ToSql,
28 Serialize,
29 Deserialize,
30)]
31#[repr(i8)]
32pub enum Blocked {
33 #[default]
34 Not = 0,
35 Yes = 1,
36 Request = 2,
37}
38
39#[derive(
40 Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql,
41)]
42#[repr(u8)]
43pub enum ShowEmails {
44 Off = 0,
45 AcceptedContacts = 1,
46 #[default] All = 2,
48}
49
50#[derive(
51 Debug, Default, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql,
52)]
53#[repr(u8)]
54pub enum MediaQuality {
55 #[default] Balanced = 0,
57 Worse = 1,
58}
59
60pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
61pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02;
62pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04;
63
64pub(crate) const DC_FROM_HANDSHAKE: i32 = 0x01;
65
66pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01;
67pub const DC_GCL_NO_SPECIALS: usize = 0x02;
68pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;
69pub const DC_GCL_FOR_FORWARDING: usize = 0x08;
70
71pub const DC_GCL_ADD_SELF: u32 = 0x02;
72pub const DC_GCL_ADDRESS: u32 = 0x04;
73
74pub(crate) const DC_RESEND_USER_AVATAR_DAYS: i64 = 14;
76
77pub(crate) const DC_OUTDATED_WARNING_DAYS: i64 = 183;
83
84pub const DC_CHAT_ID_TRASH: ChatId = ChatId::new(3);
86pub const DC_CHAT_ID_ARCHIVED_LINK: ChatId = ChatId::new(6);
88pub const DC_CHAT_ID_ALLDONE_HINT: ChatId = ChatId::new(7);
90pub const DC_CHAT_ID_LAST_SPECIAL: ChatId = ChatId::new(9);
92
93#[derive(
95 Debug,
96 Display,
97 Clone,
98 Copy,
99 PartialEq,
100 Eq,
101 PartialOrd,
102 Ord,
103 FromPrimitive,
104 ToPrimitive,
105 FromSql,
106 ToSql,
107 IntoStaticStr,
108 Serialize,
109 Deserialize,
110)]
111#[repr(u32)]
112pub enum Chattype {
113 Single = 100,
117
118 Group = 120,
122
123 Mailinglist = 140,
126
127 OutBroadcast = 160,
139
140 InBroadcast = 165,
153}
154
155pub const DC_MSG_ID_DAYMARKER: u32 = 9;
156pub const DC_MSG_ID_LAST_SPECIAL: u32 = 9;
157
158pub(crate) const DC_ELLIPSIS: &str = "[...]";
160pub const DC_DESIRED_TEXT_LINES: usize = 38;
163pub const DC_DESIRED_TEXT_LINE_LEN: usize = 100;
165
166pub const DC_DESIRED_TEXT_LEN: usize = DC_DESIRED_TEXT_LINE_LEN * DC_DESIRED_TEXT_LINES;
175
176pub const DC_LP_AUTH_OAUTH2: i32 = 0x2;
187
188pub const DC_LP_AUTH_NORMAL: i32 = 0x4;
191
192pub const DC_LP_AUTH_FLAGS: i32 = DC_LP_AUTH_OAUTH2 | DC_LP_AUTH_NORMAL;
194
195pub const BALANCED_IMAGE_BYTES: usize = 500_000;
197pub const WORSE_IMAGE_BYTES: usize = 130_000;
198
199pub(crate) const BALANCED_AVATAR_SIZE: u32 = 512;
201pub(crate) const BALANCED_AVATAR_BYTES: usize = 60_000;
202pub(crate) const WORSE_AVATAR_SIZE: u32 = 128;
203pub(crate) const WORSE_AVATAR_BYTES: usize = 20_000; pub const BALANCED_IMAGE_SIZE: u32 = 1280;
207pub const WORSE_IMAGE_SIZE: u32 = 640;
208
209pub const MAX_RCVD_IMAGE_PIXELS: u32 = 50_000_000;
212
213pub(crate) const DC_FOLDERS_CONFIGURED_KEY: &str = "folders_configured";
215pub(crate) const DC_FOLDERS_CONFIGURED_VERSION: i32 = 5;
217
218pub(crate) const DEFAULT_MAX_SMTP_RCPT_TO: usize = 50;
222
223pub(crate) const DEFAULT_CHATMAIL_MAX_SMTP_RCPT_TO: usize = 999;
225
226pub(crate) const DC_BACKGROUND_FETCH_QUOTA_CHECK_RATELIMIT: u64 = 12 * 60 * 60; pub(crate) const TIMESTAMP_SENT_TOLERANCE: i64 = 60;
232
233pub(crate) const EDITED_PREFIX: &str = "✏️";
236
237pub(crate) const HOUSEKEEPING_PERIOD: i64 = 24 * 60 * 60;
239
240pub(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.
241
242As we do not guarantee feature-stability for such experiments, this means, that you will need to create the channel again.
243
244Here is what to do:
245 • Create a new channel
246 • Tap on the channel name
247 • Tap on "QR Invite Code"
248 • Have all recipients scan the QR code, or send them the link
249
250If you have any questions, please send an email to delta@merlinux.eu or ask at https://support.delta.chat/."#;
251
252#[cfg(test)]
253mod tests {
254 use num_traits::FromPrimitive;
255
256 use super::*;
257
258 #[test]
259 fn test_chattype_values() {
260 assert_eq!(Chattype::Single, Chattype::from_i32(100).unwrap());
262 assert_eq!(Chattype::Group, Chattype::from_i32(120).unwrap());
263 assert_eq!(Chattype::Mailinglist, Chattype::from_i32(140).unwrap());
264 assert_eq!(Chattype::OutBroadcast, Chattype::from_i32(160).unwrap());
265 }
266
267 #[test]
268 fn test_showemails_values() {
269 assert_eq!(ShowEmails::All, ShowEmails::default());
271 assert_eq!(ShowEmails::Off, ShowEmails::from_i32(0).unwrap());
272 assert_eq!(
273 ShowEmails::AcceptedContacts,
274 ShowEmails::from_i32(1).unwrap()
275 );
276 assert_eq!(ShowEmails::All, ShowEmails::from_i32(2).unwrap());
277 }
278
279 #[test]
280 fn test_blocked_values() {
281 assert_eq!(Blocked::Not, Blocked::default());
283 assert_eq!(Blocked::Not, Blocked::from_i32(0).unwrap());
284 assert_eq!(Blocked::Yes, Blocked::from_i32(1).unwrap());
285 assert_eq!(Blocked::Request, Blocked::from_i32(2).unwrap());
286 }
287
288 #[test]
289 fn test_mediaquality_values() {
290 assert_eq!(MediaQuality::Balanced, MediaQuality::default());
292 assert_eq!(MediaQuality::Balanced, MediaQuality::from_i32(0).unwrap());
293 assert_eq!(MediaQuality::Worse, MediaQuality::from_i32(1).unwrap());
294 }
295}