mirror of
https://github.com/chatmail/core.git
synced 2026-05-16 13:26:38 +03:00
192
src/constants.rs
192
src/constants.rs
@@ -1,5 +1,5 @@
|
|||||||
//! Constants
|
//! Constants
|
||||||
#![allow(non_camel_case_types)]
|
#![allow(non_camel_case_types, dead_code)]
|
||||||
|
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
|
|
||||||
@@ -19,20 +19,20 @@ pub enum MoveState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// some defaults
|
// some defaults
|
||||||
pub const DC_E2EE_DEFAULT_ENABLED: i32 = 1;
|
const DC_E2EE_DEFAULT_ENABLED: i32 = 1;
|
||||||
pub const DC_MDNS_DEFAULT_ENABLED: i32 = 1;
|
pub const DC_MDNS_DEFAULT_ENABLED: i32 = 1;
|
||||||
pub const DC_INBOX_WATCH_DEFAULT: i32 = 1;
|
const DC_INBOX_WATCH_DEFAULT: i32 = 1;
|
||||||
pub const DC_SENTBOX_WATCH_DEFAULT: i32 = 1;
|
const DC_SENTBOX_WATCH_DEFAULT: i32 = 1;
|
||||||
pub const DC_MVBOX_WATCH_DEFAULT: i32 = 1;
|
const DC_MVBOX_WATCH_DEFAULT: i32 = 1;
|
||||||
pub const DC_MVBOX_MOVE_DEFAULT: i32 = 1;
|
const DC_MVBOX_MOVE_DEFAULT: i32 = 1;
|
||||||
|
|
||||||
pub const DC_CHAT_NOT_BLOCKED: i32 = 0;
|
pub const DC_CHAT_NOT_BLOCKED: i32 = 0;
|
||||||
pub const DC_CHAT_MANUALLY_BLOCKED: i32 = 1;
|
const DC_CHAT_MANUALLY_BLOCKED: i32 = 1;
|
||||||
pub const DC_CHAT_DEADDROP_BLOCKED: i32 = 2;
|
pub const DC_CHAT_DEADDROP_BLOCKED: i32 = 2;
|
||||||
|
|
||||||
pub const DC_IMAP_SEEN: u32 = 0x1;
|
pub const DC_IMAP_SEEN: u32 = 0x1;
|
||||||
|
|
||||||
pub const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
|
const DC_HANDSHAKE_CONTINUE_NORMAL_PROCESSING: i32 = 0x01;
|
||||||
pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02;
|
pub const DC_HANDSHAKE_STOP_NORMAL_PROCESSING: i32 = 0x02;
|
||||||
pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04;
|
pub const DC_HANDSHAKE_ADD_DELETE_JOB: i32 = 0x04;
|
||||||
|
|
||||||
@@ -40,47 +40,47 @@ pub const DC_GCL_ARCHIVED_ONLY: usize = 0x01;
|
|||||||
pub const DC_GCL_NO_SPECIALS: usize = 0x02;
|
pub const DC_GCL_NO_SPECIALS: usize = 0x02;
|
||||||
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;
|
pub const DC_GCL_ADD_ALLDONE_HINT: usize = 0x04;
|
||||||
|
|
||||||
pub const DC_GCM_ADDDAYMARKER: usize = 0x01;
|
const DC_GCM_ADDDAYMARKER: usize = 0x01;
|
||||||
|
|
||||||
pub const DC_GCL_VERIFIED_ONLY: usize = 0x01;
|
const DC_GCL_VERIFIED_ONLY: usize = 0x01;
|
||||||
pub const DC_GCL_ADD_SELF: usize = 0x02;
|
pub const DC_GCL_ADD_SELF: usize = 0x02;
|
||||||
|
|
||||||
/// param1 is a directory where the keys are written to
|
/// param1 is a directory where the keys are written to
|
||||||
pub const DC_IMEX_EXPORT_SELF_KEYS: usize = 1;
|
const DC_IMEX_EXPORT_SELF_KEYS: usize = 1;
|
||||||
/// param1 is a directory where the keys are searched in and read from
|
/// param1 is a directory where the keys are searched in and read from
|
||||||
pub const DC_IMEX_IMPORT_SELF_KEYS: usize = 2;
|
const DC_IMEX_IMPORT_SELF_KEYS: usize = 2;
|
||||||
/// param1 is a directory where the backup is written to
|
/// param1 is a directory where the backup is written to
|
||||||
pub const DC_IMEX_EXPORT_BACKUP: usize = 11;
|
const DC_IMEX_EXPORT_BACKUP: usize = 11;
|
||||||
/// param1 is the file with the backup to import
|
/// param1 is the file with the backup to import
|
||||||
pub const DC_IMEX_IMPORT_BACKUP: usize = 12;
|
const DC_IMEX_IMPORT_BACKUP: usize = 12;
|
||||||
|
|
||||||
/// id=contact
|
/// id=contact
|
||||||
pub const DC_QR_ASK_VERIFYCONTACT: usize = 200;
|
const DC_QR_ASK_VERIFYCONTACT: usize = 200;
|
||||||
/// text1=groupname
|
/// text1=groupname
|
||||||
pub const DC_QR_ASK_VERIFYGROUP: usize = 202;
|
const DC_QR_ASK_VERIFYGROUP: usize = 202;
|
||||||
/// id=contact
|
/// id=contact
|
||||||
pub const DC_QR_FPR_OK: usize = 210;
|
const DC_QR_FPR_OK: usize = 210;
|
||||||
/// id=contact
|
/// id=contact
|
||||||
pub const DC_QR_FPR_MISMATCH: usize = 220;
|
const DC_QR_FPR_MISMATCH: usize = 220;
|
||||||
/// test1=formatted fingerprint
|
/// test1=formatted fingerprint
|
||||||
pub const DC_QR_FPR_WITHOUT_ADDR: usize = 230;
|
const DC_QR_FPR_WITHOUT_ADDR: usize = 230;
|
||||||
/// id=contact
|
/// id=contact
|
||||||
pub const DC_QR_ADDR: usize = 320;
|
const DC_QR_ADDR: usize = 320;
|
||||||
/// text1=text
|
/// text1=text
|
||||||
pub const DC_QR_TEXT: usize = 330;
|
const DC_QR_TEXT: usize = 330;
|
||||||
/// text1=URL
|
/// text1=URL
|
||||||
pub const DC_QR_URL: usize = 332;
|
const DC_QR_URL: usize = 332;
|
||||||
/// text1=error string
|
/// text1=error string
|
||||||
pub const DC_QR_ERROR: usize = 400;
|
const DC_QR_ERROR: usize = 400;
|
||||||
|
|
||||||
/// virtual chat showing all messages belonging to chats flagged with chats.blocked=2
|
/// virtual chat showing all messages belonging to chats flagged with chats.blocked=2
|
||||||
pub const DC_CHAT_ID_DEADDROP: usize = 1;
|
const DC_CHAT_ID_DEADDROP: usize = 1;
|
||||||
/// messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again)
|
/// messages that should be deleted get this chat_id; the messages are deleted from the working thread later then. This is also needed as rfc724_mid should be preset as long as the message is not deleted on the server (otherwise it is downloaded again)
|
||||||
pub const DC_CHAT_ID_TRASH: usize = 3;
|
pub const DC_CHAT_ID_TRASH: usize = 3;
|
||||||
/// a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be sent and shown)
|
/// a message is just in creation but not yet assigned to a chat (eg. we may need the message ID to set up blobs; this avoids unready message to be sent and shown)
|
||||||
pub const DC_CHAT_ID_MSGS_IN_CREATION: usize = 4;
|
const DC_CHAT_ID_MSGS_IN_CREATION: usize = 4;
|
||||||
/// virtual chat showing all messages flagged with msgs.starred=2
|
/// virtual chat showing all messages flagged with msgs.starred=2
|
||||||
pub const DC_CHAT_ID_STARRED: usize = 5;
|
const DC_CHAT_ID_STARRED: usize = 5;
|
||||||
/// only an indicator in a chatlist
|
/// only an indicator in a chatlist
|
||||||
pub const DC_CHAT_ID_ARCHIVED_LINK: usize = 6;
|
pub const DC_CHAT_ID_ARCHIVED_LINK: usize = 6;
|
||||||
/// only an indicator in a chatlist
|
/// only an indicator in a chatlist
|
||||||
@@ -88,16 +88,16 @@ pub const DC_CHAT_ID_ALLDONE_HINT: usize = 7;
|
|||||||
/// larger chat IDs are "real" chats, their messages are "real" messages.
|
/// larger chat IDs are "real" chats, their messages are "real" messages.
|
||||||
pub const DC_CHAT_ID_LAST_SPECIAL: usize = 9;
|
pub const DC_CHAT_ID_LAST_SPECIAL: usize = 9;
|
||||||
|
|
||||||
pub const DC_CHAT_TYPE_UNDEFINED: i32 = 0;
|
const DC_CHAT_TYPE_UNDEFINED: i32 = 0;
|
||||||
pub const DC_CHAT_TYPE_SINGLE: i32 = 100;
|
pub const DC_CHAT_TYPE_SINGLE: i32 = 100;
|
||||||
pub const DC_CHAT_TYPE_GROUP: i32 = 120;
|
pub const DC_CHAT_TYPE_GROUP: i32 = 120;
|
||||||
pub const DC_CHAT_TYPE_VERIFIED_GROUP: i32 = 130;
|
pub const DC_CHAT_TYPE_VERIFIED_GROUP: i32 = 130;
|
||||||
|
|
||||||
pub const DC_MSG_ID_MARKER1: usize = 1;
|
pub const DC_MSG_ID_MARKER1: usize = 1;
|
||||||
pub const DC_MSG_ID_DAYMARKER: usize = 9;
|
const DC_MSG_ID_DAYMARKER: usize = 9;
|
||||||
pub const DC_MSG_ID_LAST_SPECIAL: usize = 9;
|
pub const DC_MSG_ID_LAST_SPECIAL: usize = 9;
|
||||||
|
|
||||||
pub const DC_STATE_UNDEFINED: i32 = 0;
|
const DC_STATE_UNDEFINED: i32 = 0;
|
||||||
pub const DC_STATE_IN_FRESH: i32 = 10;
|
pub const DC_STATE_IN_FRESH: i32 = 10;
|
||||||
pub const DC_STATE_IN_NOTICED: i32 = 13;
|
pub const DC_STATE_IN_NOTICED: i32 = 13;
|
||||||
pub const DC_STATE_IN_SEEN: i32 = 16;
|
pub const DC_STATE_IN_SEEN: i32 = 16;
|
||||||
@@ -110,18 +110,18 @@ pub const DC_STATE_OUT_DELIVERED: i32 = 26;
|
|||||||
pub const DC_STATE_OUT_MDN_RCVD: i32 = 28;
|
pub const DC_STATE_OUT_MDN_RCVD: i32 = 28;
|
||||||
|
|
||||||
/// approx. max. length returned by dc_msg_get_text()
|
/// approx. max. length returned by dc_msg_get_text()
|
||||||
pub const DC_MAX_GET_TEXT_LEN: usize = 30000;
|
const DC_MAX_GET_TEXT_LEN: usize = 30000;
|
||||||
/// approx. max. length returned by dc_get_msg_info()
|
/// approx. max. length returned by dc_get_msg_info()
|
||||||
pub const DC_MAX_GET_INFO_LEN: usize = 100000;
|
const DC_MAX_GET_INFO_LEN: usize = 100000;
|
||||||
|
|
||||||
pub const DC_CONTACT_ID_UNDEFINED: usize = 0;
|
pub const DC_CONTACT_ID_UNDEFINED: usize = 0;
|
||||||
pub const DC_CONTACT_ID_SELF: usize = 1;
|
pub const DC_CONTACT_ID_SELF: usize = 1;
|
||||||
pub const DC_CONTACT_ID_DEVICE: usize = 2;
|
const DC_CONTACT_ID_DEVICE: usize = 2;
|
||||||
pub const DC_CONTACT_ID_LAST_SPECIAL: usize = 9;
|
pub const DC_CONTACT_ID_LAST_SPECIAL: usize = 9;
|
||||||
|
|
||||||
pub const DC_TEXT1_DRAFT: usize = 1;
|
const DC_TEXT1_DRAFT: usize = 1;
|
||||||
pub const DC_TEXT1_USERNAME: usize = 2;
|
const DC_TEXT1_USERNAME: usize = 2;
|
||||||
pub const DC_TEXT1_SELF: usize = 3;
|
const DC_TEXT1_SELF: usize = 3;
|
||||||
|
|
||||||
pub const DC_CREATE_MVBOX: usize = 1;
|
pub const DC_CREATE_MVBOX: usize = 1;
|
||||||
|
|
||||||
@@ -137,7 +137,7 @@ pub const DC_LP_AUTH_OAUTH2: usize = 0x2;
|
|||||||
|
|
||||||
/// Force NORMAL authorization, this is the default.
|
/// Force NORMAL authorization, this is the default.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
pub const DC_LP_AUTH_NORMAL: usize = 0x4;
|
const DC_LP_AUTH_NORMAL: usize = 0x4;
|
||||||
|
|
||||||
/// Connect to IMAP via STARTTLS.
|
/// Connect to IMAP via STARTTLS.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
@@ -145,7 +145,7 @@ pub const DC_LP_IMAP_SOCKET_STARTTLS: usize = 0x100;
|
|||||||
|
|
||||||
/// Connect to IMAP via SSL.
|
/// Connect to IMAP via SSL.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
pub const DC_LP_IMAP_SOCKET_SSL: usize = 0x200;
|
const DC_LP_IMAP_SOCKET_SSL: usize = 0x200;
|
||||||
|
|
||||||
/// Connect to IMAP unencrypted, this should not be used.
|
/// Connect to IMAP unencrypted, this should not be used.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
@@ -157,19 +157,19 @@ pub const DC_LP_SMTP_SOCKET_STARTTLS: usize = 0x10000;
|
|||||||
|
|
||||||
/// Connect to SMTP via SSL.
|
/// Connect to SMTP via SSL.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
pub const DC_LP_SMTP_SOCKET_SSL: usize = 0x20000;
|
const DC_LP_SMTP_SOCKET_SSL: usize = 0x20000;
|
||||||
|
|
||||||
/// Connect to SMTP unencrypted, this should not be used.
|
/// Connect to SMTP unencrypted, this should not be used.
|
||||||
/// If this flag is set, automatic configuration is skipped.
|
/// If this flag is set, automatic configuration is skipped.
|
||||||
pub const DC_LP_SMTP_SOCKET_PLAIN: usize = 0x40000;
|
pub const DC_LP_SMTP_SOCKET_PLAIN: usize = 0x40000;
|
||||||
|
|
||||||
/// if none of these flags are set, the default is chosen
|
/// if none of these flags are set, the default is chosen
|
||||||
pub const DC_LP_AUTH_FLAGS: usize = (DC_LP_AUTH_OAUTH2 | DC_LP_AUTH_NORMAL);
|
const DC_LP_AUTH_FLAGS: usize = (DC_LP_AUTH_OAUTH2 | DC_LP_AUTH_NORMAL);
|
||||||
/// if none of these flags are set, the default is chosen
|
/// if none of these flags are set, the default is chosen
|
||||||
pub const DC_LP_IMAP_SOCKET_FLAGS: usize =
|
const DC_LP_IMAP_SOCKET_FLAGS: usize =
|
||||||
(DC_LP_IMAP_SOCKET_STARTTLS | DC_LP_IMAP_SOCKET_SSL | DC_LP_IMAP_SOCKET_PLAIN);
|
(DC_LP_IMAP_SOCKET_STARTTLS | DC_LP_IMAP_SOCKET_SSL | DC_LP_IMAP_SOCKET_PLAIN);
|
||||||
/// if none of these flags are set, the default is chosen
|
/// if none of these flags are set, the default is chosen
|
||||||
pub const DC_LP_SMTP_SOCKET_FLAGS: usize =
|
const DC_LP_SMTP_SOCKET_FLAGS: usize =
|
||||||
(DC_LP_SMTP_SOCKET_STARTTLS | DC_LP_SMTP_SOCKET_SSL | DC_LP_SMTP_SOCKET_PLAIN);
|
(DC_LP_SMTP_SOCKET_STARTTLS | DC_LP_SMTP_SOCKET_SSL | DC_LP_SMTP_SOCKET_PLAIN);
|
||||||
|
|
||||||
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)]
|
#[derive(Debug, Display, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive, FromSql, ToSql)]
|
||||||
@@ -468,65 +468,65 @@ pub enum Event {
|
|||||||
GET_STRING = 2091,
|
GET_STRING = 2091,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub const DC_EVENT_FILE_COPIED: usize = 2055; // deprecated;
|
const DC_EVENT_FILE_COPIED: usize = 2055; // deprecated;
|
||||||
pub const DC_EVENT_IS_OFFLINE: usize = 2081; // deprecated;
|
const DC_EVENT_IS_OFFLINE: usize = 2081; // deprecated;
|
||||||
pub const DC_ERROR_SEE_STRING: usize = 0; // deprecated;
|
const DC_ERROR_SEE_STRING: usize = 0; // deprecated;
|
||||||
pub const DC_ERROR_SELF_NOT_IN_GROUP: usize = 1; // deprecated;
|
const DC_ERROR_SELF_NOT_IN_GROUP: usize = 1; // deprecated;
|
||||||
pub const DC_STR_SELFNOTINGRP: usize = 21; // deprecated;
|
const DC_STR_SELFNOTINGRP: usize = 21; // deprecated;
|
||||||
|
|
||||||
/// Values for dc_get|set_config("show_emails")
|
/// Values for dc_get|set_config("show_emails")
|
||||||
pub const DC_SHOW_EMAILS_OFF: usize = 0;
|
const DC_SHOW_EMAILS_OFF: usize = 0;
|
||||||
pub const DC_SHOW_EMAILS_ACCEPTED_CONTACTS: usize = 1;
|
const DC_SHOW_EMAILS_ACCEPTED_CONTACTS: usize = 1;
|
||||||
pub const DC_SHOW_EMAILS_ALL: usize = 2;
|
const DC_SHOW_EMAILS_ALL: usize = 2;
|
||||||
|
|
||||||
// TODO: Strings need some doumentation about used placeholders.
|
// TODO: Strings need some doumentation about used placeholders.
|
||||||
// These constants are used to request strings using #DC_EVENT_GET_STRING.
|
// These constants are used to request strings using #DC_EVENT_GET_STRING.
|
||||||
|
|
||||||
pub const DC_STR_NOMESSAGES: usize = 1;
|
const DC_STR_NOMESSAGES: usize = 1;
|
||||||
pub const DC_STR_SELF: usize = 2;
|
const DC_STR_SELF: usize = 2;
|
||||||
pub const DC_STR_DRAFT: usize = 3;
|
const DC_STR_DRAFT: usize = 3;
|
||||||
pub const DC_STR_MEMBER: usize = 4;
|
const DC_STR_MEMBER: usize = 4;
|
||||||
pub const DC_STR_CONTACT: usize = 6;
|
const DC_STR_CONTACT: usize = 6;
|
||||||
pub const DC_STR_VOICEMESSAGE: usize = 7;
|
const DC_STR_VOICEMESSAGE: usize = 7;
|
||||||
pub const DC_STR_DEADDROP: usize = 8;
|
const DC_STR_DEADDROP: usize = 8;
|
||||||
pub const DC_STR_IMAGE: usize = 9;
|
const DC_STR_IMAGE: usize = 9;
|
||||||
pub const DC_STR_VIDEO: usize = 10;
|
const DC_STR_VIDEO: usize = 10;
|
||||||
pub const DC_STR_AUDIO: usize = 11;
|
const DC_STR_AUDIO: usize = 11;
|
||||||
pub const DC_STR_FILE: usize = 12;
|
const DC_STR_FILE: usize = 12;
|
||||||
pub const DC_STR_STATUSLINE: usize = 13;
|
const DC_STR_STATUSLINE: usize = 13;
|
||||||
pub const DC_STR_NEWGROUPDRAFT: usize = 14;
|
const DC_STR_NEWGROUPDRAFT: usize = 14;
|
||||||
pub const DC_STR_MSGGRPNAME: usize = 15;
|
const DC_STR_MSGGRPNAME: usize = 15;
|
||||||
pub const DC_STR_MSGGRPIMGCHANGED: usize = 16;
|
const DC_STR_MSGGRPIMGCHANGED: usize = 16;
|
||||||
pub const DC_STR_MSGADDMEMBER: usize = 17;
|
const DC_STR_MSGADDMEMBER: usize = 17;
|
||||||
pub const DC_STR_MSGDELMEMBER: usize = 18;
|
const DC_STR_MSGDELMEMBER: usize = 18;
|
||||||
pub const DC_STR_MSGGROUPLEFT: usize = 19;
|
const DC_STR_MSGGROUPLEFT: usize = 19;
|
||||||
pub const DC_STR_GIF: usize = 23;
|
const DC_STR_GIF: usize = 23;
|
||||||
pub const DC_STR_ENCRYPTEDMSG: usize = 24;
|
const DC_STR_ENCRYPTEDMSG: usize = 24;
|
||||||
pub const DC_STR_E2E_AVAILABLE: usize = 25;
|
const DC_STR_E2E_AVAILABLE: usize = 25;
|
||||||
pub const DC_STR_ENCR_TRANSP: usize = 27;
|
const DC_STR_ENCR_TRANSP: usize = 27;
|
||||||
pub const DC_STR_ENCR_NONE: usize = 28;
|
const DC_STR_ENCR_NONE: usize = 28;
|
||||||
pub const DC_STR_CANTDECRYPT_MSG_BODY: usize = 29;
|
const DC_STR_CANTDECRYPT_MSG_BODY: usize = 29;
|
||||||
pub const DC_STR_FINGERPRINTS: usize = 30;
|
const DC_STR_FINGERPRINTS: usize = 30;
|
||||||
pub const DC_STR_READRCPT: usize = 31;
|
const DC_STR_READRCPT: usize = 31;
|
||||||
pub const DC_STR_READRCPT_MAILBODY: usize = 32;
|
const DC_STR_READRCPT_MAILBODY: usize = 32;
|
||||||
pub const DC_STR_MSGGRPIMGDELETED: usize = 33;
|
const DC_STR_MSGGRPIMGDELETED: usize = 33;
|
||||||
pub const DC_STR_E2E_PREFERRED: usize = 34;
|
const DC_STR_E2E_PREFERRED: usize = 34;
|
||||||
pub const DC_STR_CONTACT_VERIFIED: usize = 35;
|
const DC_STR_CONTACT_VERIFIED: usize = 35;
|
||||||
pub const DC_STR_CONTACT_NOT_VERIFIED: usize = 36;
|
const DC_STR_CONTACT_NOT_VERIFIED: usize = 36;
|
||||||
pub const DC_STR_CONTACT_SETUP_CHANGED: usize = 37;
|
const DC_STR_CONTACT_SETUP_CHANGED: usize = 37;
|
||||||
pub const DC_STR_ARCHIVEDCHATS: usize = 40;
|
const DC_STR_ARCHIVEDCHATS: usize = 40;
|
||||||
pub const DC_STR_STARREDMSGS: usize = 41;
|
const DC_STR_STARREDMSGS: usize = 41;
|
||||||
pub const DC_STR_AC_SETUP_MSG_SUBJECT: usize = 42;
|
const DC_STR_AC_SETUP_MSG_SUBJECT: usize = 42;
|
||||||
pub const DC_STR_AC_SETUP_MSG_BODY: usize = 43;
|
const DC_STR_AC_SETUP_MSG_BODY: usize = 43;
|
||||||
pub const DC_STR_SELFTALK_SUBTITLE: usize = 50;
|
const DC_STR_SELFTALK_SUBTITLE: usize = 50;
|
||||||
pub const DC_STR_CANNOT_LOGIN: usize = 60;
|
const DC_STR_CANNOT_LOGIN: usize = 60;
|
||||||
pub const DC_STR_SERVER_RESPONSE: usize = 61;
|
const DC_STR_SERVER_RESPONSE: usize = 61;
|
||||||
pub const DC_STR_MSGACTIONBYUSER: usize = 62;
|
const DC_STR_MSGACTIONBYUSER: usize = 62;
|
||||||
pub const DC_STR_MSGACTIONBYME: usize = 63;
|
const DC_STR_MSGACTIONBYME: usize = 63;
|
||||||
pub const DC_STR_MSGLOCATIONENABLED: usize = 64;
|
const DC_STR_MSGLOCATIONENABLED: usize = 64;
|
||||||
pub const DC_STR_MSGLOCATIONDISABLED: usize = 65;
|
const DC_STR_MSGLOCATIONDISABLED: usize = 65;
|
||||||
pub const DC_STR_LOCATION: usize = 66;
|
const DC_STR_LOCATION: usize = 66;
|
||||||
pub const DC_STR_COUNT: usize = 66;
|
const DC_STR_COUNT: usize = 66;
|
||||||
|
|
||||||
pub const DC_JOB_DELETE_MSG_ON_IMAP: i32 = 110;
|
pub const DC_JOB_DELETE_MSG_ON_IMAP: i32 = 110;
|
||||||
|
|
||||||
@@ -542,6 +542,6 @@ pub const DC_CMD_GROUPIMAGE_CHANGED: libc::c_int = 3;
|
|||||||
pub const DC_CMD_MEMBER_ADDED_TO_GROUP: libc::c_int = 4;
|
pub const DC_CMD_MEMBER_ADDED_TO_GROUP: libc::c_int = 4;
|
||||||
pub const DC_CMD_MEMBER_REMOVED_FROM_GROUP: libc::c_int = 5;
|
pub const DC_CMD_MEMBER_REMOVED_FROM_GROUP: libc::c_int = 5;
|
||||||
pub const DC_CMD_AUTOCRYPT_SETUP_MESSAGE: libc::c_int = 6;
|
pub const DC_CMD_AUTOCRYPT_SETUP_MESSAGE: libc::c_int = 6;
|
||||||
pub const DC_CMD_SECUREJOIN_MESSAGE: libc::c_int = 7;
|
const DC_CMD_SECUREJOIN_MESSAGE: libc::c_int = 7;
|
||||||
pub const DC_CMD_LOCATION_STREAMING_ENABLED: libc::c_int = 8;
|
pub const DC_CMD_LOCATION_STREAMING_ENABLED: libc::c_int = 8;
|
||||||
pub const DC_CMD_LOCATION_ONLY: libc::c_int = 9;
|
const DC_CMD_LOCATION_ONLY: libc::c_int = 9;
|
||||||
|
|||||||
@@ -903,7 +903,7 @@ impl<'a> Contact<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_first_name<'a>(full_name: &'a str) -> &'a str {
|
fn get_first_name<'a>(full_name: &'a str) -> &'a str {
|
||||||
full_name.splitn(2, ' ').next().unwrap_or_default()
|
full_name.splitn(2, ' ').next().unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -224,11 +224,8 @@ pub fn dc_array_new(initsize: size_t) -> *mut dc_array_t {
|
|||||||
dc_array_t::new(initsize).into_raw()
|
dc_array_t::new(initsize).into_raw()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_array_new_locations(initsize: size_t) -> *mut dc_array_t {
|
#[cfg(test)]
|
||||||
dc_array_t::new_locations(initsize).into_raw()
|
unsafe fn dc_array_empty(array: *mut dc_array_t) {
|
||||||
}
|
|
||||||
|
|
||||||
pub unsafe fn dc_array_empty(array: *mut dc_array_t) {
|
|
||||||
assert!(!array.is_null());
|
assert!(!array.is_null());
|
||||||
|
|
||||||
(*array).clear()
|
(*array).clear()
|
||||||
|
|||||||
@@ -88,7 +88,7 @@ pub unsafe fn dc_chat_unref(chat: *mut Chat) {
|
|||||||
Box::from_raw(chat);
|
Box::from_raw(chat);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_chat_empty(mut chat: *mut Chat) {
|
unsafe fn dc_chat_empty(mut chat: *mut Chat) {
|
||||||
if chat.is_null() {
|
if chat.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -107,7 +107,7 @@ pub unsafe fn dc_unblock_chat(context: &Context, chat_id: uint32_t) {
|
|||||||
dc_block_chat(context, chat_id, 0i32);
|
dc_block_chat(context, chat_id, 0i32);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_block_chat(context: &Context, chat_id: u32, new_blocking: libc::c_int) -> bool {
|
fn dc_block_chat(context: &Context, chat_id: u32, new_blocking: libc::c_int) -> bool {
|
||||||
sql::execute(
|
sql::execute(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
@@ -1749,7 +1749,7 @@ pub unsafe fn dc_remove_contact_from_chat(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should return Result
|
// Should return Result
|
||||||
pub fn dc_set_group_explicitly_left(context: &Context, grpid: *const libc::c_char) {
|
fn dc_set_group_explicitly_left(context: &Context, grpid: *const libc::c_char) {
|
||||||
if 0 == dc_is_group_explicitly_left(context, grpid) {
|
if 0 == dc_is_group_explicitly_left(context, grpid) {
|
||||||
sql::execute(
|
sql::execute(
|
||||||
context,
|
context,
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ macro_rules! progress {
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#[derive(Copy, Clone)]
|
#[derive(Copy, Clone)]
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct dc_imapfolder_t {
|
struct dc_imapfolder_t {
|
||||||
pub name_to_select: *mut libc::c_char,
|
pub name_to_select: *mut libc::c_char,
|
||||||
pub name_utf8: *mut libc::c_char,
|
pub name_utf8: *mut libc::c_char,
|
||||||
pub meaning: libc::c_int,
|
pub meaning: libc::c_int,
|
||||||
@@ -43,7 +43,7 @@ pub struct dc_imapfolder_t {
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
/* documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration */
|
/* documentation: https://developer.mozilla.org/en-US/docs/Mozilla/Thunderbird/Autoconfiguration */
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct moz_autoconfigure_t<'a> {
|
struct moz_autoconfigure_t<'a> {
|
||||||
pub in_0: &'a dc_loginparam_t,
|
pub in_0: &'a dc_loginparam_t,
|
||||||
pub in_emaildomain: *mut libc::c_char,
|
pub in_emaildomain: *mut libc::c_char,
|
||||||
pub in_emaillocalpart: *mut libc::c_char,
|
pub in_emaillocalpart: *mut libc::c_char,
|
||||||
@@ -58,7 +58,7 @@ pub struct moz_autoconfigure_t<'a> {
|
|||||||
* Outlook's Autodiscover
|
* Outlook's Autodiscover
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct outlk_autodiscover_t<'a> {
|
struct outlk_autodiscover_t<'a> {
|
||||||
pub in_0: &'a dc_loginparam_t,
|
pub in_0: &'a dc_loginparam_t,
|
||||||
pub out: dc_loginparam_t,
|
pub out: dc_loginparam_t,
|
||||||
pub out_imap_set: libc::c_int,
|
pub out_imap_set: libc::c_int,
|
||||||
@@ -80,7 +80,7 @@ pub unsafe fn dc_configure(context: &Context) {
|
|||||||
dc_job_add(context, 900, 0, Params::new(), 0);
|
dc_job_add(context, 900, 0, Params::new(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_has_ongoing(context: &Context) -> libc::c_int {
|
unsafe fn dc_has_ongoing(context: &Context) -> libc::c_int {
|
||||||
let s_a = context.running_state.clone();
|
let s_a = context.running_state.clone();
|
||||||
let s = s_a.read().unwrap();
|
let s = s_a.read().unwrap();
|
||||||
|
|
||||||
|
|||||||
@@ -389,7 +389,7 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this value does not increase the number of tries
|
// this value does not increase the number of tries
|
||||||
pub unsafe fn dc_job_try_again_later(
|
unsafe fn dc_job_try_again_later(
|
||||||
job: &mut dc_job_t,
|
job: &mut dc_job_t,
|
||||||
try_again: libc::c_int,
|
try_again: libc::c_int,
|
||||||
pending_error: *const libc::c_char,
|
pending_error: *const libc::c_char,
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ pub struct dc_mimefactory_t<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type dc_mimefactory_loaded_t = libc::c_uint;
|
type dc_mimefactory_loaded_t = libc::c_uint;
|
||||||
pub const DC_MF_MDN_LOADED: dc_mimefactory_loaded_t = 2;
|
const DC_MF_MDN_LOADED: dc_mimefactory_loaded_t = 2;
|
||||||
pub const DC_MF_MSG_LOADED: dc_mimefactory_loaded_t = 1;
|
pub const DC_MF_MSG_LOADED: dc_mimefactory_loaded_t = 1;
|
||||||
pub const DC_MF_NOTHING_LOADED: dc_mimefactory_loaded_t = 0;
|
pub const DC_MF_NOTHING_LOADED: dc_mimefactory_loaded_t = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -61,11 +61,6 @@ pub struct dc_mimeparser_t<'a> {
|
|||||||
pub message_kml: Option<dc_kml_t>,
|
pub message_kml: Option<dc_kml_t>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// deprecated
|
|
||||||
pub unsafe fn dc_no_compound_msgs() {
|
|
||||||
S_GENERATE_COMPOUND_MSGS = 0i32;
|
|
||||||
}
|
|
||||||
|
|
||||||
// deprecated: flag to switch generation of compound messages on and off.
|
// deprecated: flag to switch generation of compound messages on and off.
|
||||||
static mut S_GENERATE_COMPOUND_MSGS: libc::c_int = 1i32;
|
static mut S_GENERATE_COMPOUND_MSGS: libc::c_int = 1i32;
|
||||||
|
|
||||||
@@ -93,7 +88,7 @@ pub unsafe fn dc_mimeparser_unref(mimeparser: &mut dc_mimeparser_t) {
|
|||||||
dc_mimeparser_empty(mimeparser);
|
dc_mimeparser_empty(mimeparser);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_mimeparser_empty(mimeparser: &mut dc_mimeparser_t) {
|
unsafe fn dc_mimeparser_empty(mimeparser: &mut dc_mimeparser_t) {
|
||||||
for part in mimeparser.parts.drain(..) {
|
for part in mimeparser.parts.drain(..) {
|
||||||
dc_mimepart_unref(part);
|
dc_mimepart_unref(part);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -498,7 +498,7 @@ pub unsafe fn dc_delete_msgs(context: &Context, msg_ids: *const uint32_t, msg_cn
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn dc_update_msg_chat_id(context: &Context, msg_id: u32, chat_id: u32) -> bool {
|
fn dc_update_msg_chat_id(context: &Context, msg_id: u32, chat_id: u32) -> bool {
|
||||||
sql::execute(
|
sql::execute(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
|
|||||||
@@ -13,13 +13,13 @@ pub struct dc_saxparser_t {
|
|||||||
|
|
||||||
/* len is only informational, text is already null-terminated */
|
/* len is only informational, text is already null-terminated */
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type dc_saxparser_text_cb_t =
|
type dc_saxparser_text_cb_t =
|
||||||
Option<unsafe fn(_: *mut libc::c_void, _: *const libc::c_char, _: libc::c_int) -> ()>;
|
Option<unsafe fn(_: *mut libc::c_void, _: *const libc::c_char, _: libc::c_int) -> ()>;
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type dc_saxparser_endtag_cb_t =
|
type dc_saxparser_endtag_cb_t =
|
||||||
Option<unsafe fn(_: *mut libc::c_void, _: *const libc::c_char) -> ()>;
|
Option<unsafe fn(_: *mut libc::c_void, _: *const libc::c_char) -> ()>;
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type dc_saxparser_starttag_cb_t = Option<
|
type dc_saxparser_starttag_cb_t = Option<
|
||||||
unsafe fn(_: *mut libc::c_void, _: *const libc::c_char, _: *mut *mut libc::c_char) -> (),
|
unsafe fn(_: *mut libc::c_void, _: *const libc::c_char, _: *mut *mut libc::c_char) -> (),
|
||||||
>;
|
>;
|
||||||
|
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::types::*;
|
|||||||
use crate::x::*;
|
use crate::x::*;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn isalnum(c: libc::c_int) -> libc::c_int {
|
fn isalnum(c: libc::c_int) -> libc::c_int {
|
||||||
if c < std::u8::MAX as libc::c_int {
|
if c < std::u8::MAX as libc::c_int {
|
||||||
(c as u8 as char).is_ascii_alphanumeric() as libc::c_int
|
(c as u8 as char).is_ascii_alphanumeric() as libc::c_int
|
||||||
} else {
|
} else {
|
||||||
@@ -331,7 +331,8 @@ pub unsafe fn dc_decode_header_words(in_0: *const libc::c_char) -> *mut libc::c_
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_encode_modified_utf7(
|
#[cfg(test)]
|
||||||
|
unsafe fn dc_encode_modified_utf7(
|
||||||
mut to_encode: *const libc::c_char,
|
mut to_encode: *const libc::c_char,
|
||||||
change_spaces: libc::c_int,
|
change_spaces: libc::c_int,
|
||||||
) -> *mut libc::c_char {
|
) -> *mut libc::c_char {
|
||||||
@@ -475,13 +476,15 @@ pub unsafe fn dc_encode_modified_utf7(
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
// UTF7 modified base64 alphabet
|
// UTF7 modified base64 alphabet
|
||||||
|
#[cfg(test)]
|
||||||
static mut BASE64CHARS: [libc::c_char; 65] = [
|
static mut BASE64CHARS: [libc::c_char; 65] = [
|
||||||
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
|
||||||
89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
|
89, 90, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
|
||||||
115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 44, 0,
|
115, 116, 117, 118, 119, 120, 121, 122, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 43, 44, 0,
|
||||||
];
|
];
|
||||||
|
|
||||||
pub unsafe fn dc_decode_modified_utf7(
|
#[cfg(test)]
|
||||||
|
unsafe fn dc_decode_modified_utf7(
|
||||||
to_decode: *const libc::c_char,
|
to_decode: *const libc::c_char,
|
||||||
change_spaces: libc::c_int,
|
change_spaces: libc::c_int,
|
||||||
) -> *mut libc::c_char {
|
) -> *mut libc::c_char {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use crate::sql;
|
|||||||
|
|
||||||
// Token namespaces
|
// Token namespaces
|
||||||
#[allow(non_camel_case_types)]
|
#[allow(non_camel_case_types)]
|
||||||
pub type dc_tokennamespc_t = usize;
|
type dc_tokennamespc_t = usize;
|
||||||
pub const DC_TOKEN_AUTH: dc_tokennamespc_t = 110;
|
pub const DC_TOKEN_AUTH: dc_tokennamespc_t = 110;
|
||||||
pub const DC_TOKEN_INVITENUMBER: dc_tokennamespc_t = 100;
|
pub const DC_TOKEN_INVITENUMBER: dc_tokennamespc_t = 100;
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ pub unsafe fn dc_ftoa(f: libc::c_double) -> *mut libc::c_char {
|
|||||||
str
|
str
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
||||||
let mut len: size_t;
|
let mut len: size_t;
|
||||||
let mut cur: *const libc::c_uchar;
|
let mut cur: *const libc::c_uchar;
|
||||||
if !buf.is_null() && 0 != *buf as libc::c_int {
|
if !buf.is_null() && 0 != *buf as libc::c_int {
|
||||||
@@ -140,7 +140,7 @@ pub unsafe fn dc_ltrim(buf: *mut libc::c_char) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_rtrim(buf: *mut libc::c_char) {
|
unsafe fn dc_rtrim(buf: *mut libc::c_char) {
|
||||||
let mut len: size_t;
|
let mut len: size_t;
|
||||||
let mut cur: *mut libc::c_uchar;
|
let mut cur: *mut libc::c_uchar;
|
||||||
if !buf.is_null() && 0 != *buf as libc::c_int {
|
if !buf.is_null() && 0 != *buf as libc::c_int {
|
||||||
@@ -168,7 +168,7 @@ pub unsafe fn dc_trim(buf: *mut libc::c_char) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* the result must be free()'d */
|
/* the result must be free()'d */
|
||||||
pub unsafe fn dc_strlower(in_0: *const libc::c_char) -> *mut libc::c_char {
|
unsafe fn dc_strlower(in_0: *const libc::c_char) -> *mut libc::c_char {
|
||||||
to_string(in_0).to_lowercase().strdup()
|
to_string(in_0).to_lowercase().strdup()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,29 +178,6 @@ pub unsafe fn dc_strlower_in_place(in_0: *mut libc::c_char) {
|
|||||||
memcpy(in_0 as *mut _, raw.as_ptr() as *const _, strlen(in_0));
|
memcpy(in_0 as *mut _, raw.as_ptr() as *const _, strlen(in_0));
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_str_contains(
|
|
||||||
haystack: *const libc::c_char,
|
|
||||||
needle: *const libc::c_char,
|
|
||||||
) -> libc::c_int {
|
|
||||||
if haystack.is_null() || needle.is_null() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if !strstr(haystack, needle).is_null() {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
let haystack_lower: *mut libc::c_char = dc_strlower(haystack);
|
|
||||||
let needle_lower: *mut libc::c_char = dc_strlower(needle);
|
|
||||||
let ret = if !strstr(haystack_lower, needle_lower).is_null() {
|
|
||||||
1
|
|
||||||
} else {
|
|
||||||
0
|
|
||||||
};
|
|
||||||
free(haystack_lower as *mut libc::c_void);
|
|
||||||
free(needle_lower as *mut libc::c_void);
|
|
||||||
|
|
||||||
ret
|
|
||||||
}
|
|
||||||
|
|
||||||
/* the result must be free()'d */
|
/* the result must be free()'d */
|
||||||
pub unsafe fn dc_null_terminate(
|
pub unsafe fn dc_null_terminate(
|
||||||
in_0: *const libc::c_char,
|
in_0: *const libc::c_char,
|
||||||
@@ -216,7 +193,8 @@ pub unsafe fn dc_null_terminate(
|
|||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_binary_to_uc_hex(buf: *const uint8_t, bytes: size_t) -> *mut libc::c_char {
|
#[cfg(test)]
|
||||||
|
unsafe fn dc_binary_to_uc_hex(buf: *const uint8_t, bytes: size_t) -> *mut libc::c_char {
|
||||||
if buf.is_null() || bytes == 0 {
|
if buf.is_null() || bytes == 0 {
|
||||||
return std::ptr::null_mut();
|
return std::ptr::null_mut();
|
||||||
}
|
}
|
||||||
@@ -248,10 +226,6 @@ pub unsafe fn dc_remove_cr_chars(buf: *mut libc::c_char) {
|
|||||||
*p2 = 0 as libc::c_char;
|
*p2 = 0 as libc::c_char;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_unify_lineends(buf: *mut libc::c_char) {
|
|
||||||
dc_remove_cr_chars(buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
|
/* replace bad UTF-8 characters by sequences of `_` (to avoid problems in filenames, we do not use eg. `?`) the function is useful if strings are unexpectingly encoded eg. as ISO-8859-1 */
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
||||||
@@ -318,7 +292,8 @@ pub unsafe fn dc_replace_bad_utf8_chars(buf: *mut libc::c_char) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_utf8_strlen(s: *const libc::c_char) -> size_t {
|
#[cfg(test)]
|
||||||
|
unsafe fn dc_utf8_strlen(s: *const libc::c_char) -> size_t {
|
||||||
if s.is_null() {
|
if s.is_null() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -436,7 +411,8 @@ pub unsafe fn dc_free_splitted_lines(lines: Vec<*mut libc::c_char>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* insert a break every n characters, the return must be free()'d */
|
/* insert a break every n characters, the return must be free()'d */
|
||||||
pub unsafe fn dc_insert_breaks(
|
#[cfg(test)]
|
||||||
|
unsafe fn dc_insert_breaks(
|
||||||
in_0: *const libc::c_char,
|
in_0: *const libc::c_char,
|
||||||
break_every: libc::c_int,
|
break_every: libc::c_int,
|
||||||
break_chars: *const libc::c_char,
|
break_chars: *const libc::c_char,
|
||||||
@@ -839,7 +815,7 @@ pub unsafe fn dc_extract_grpid_from_rfc724_mid_list(list: *const clist) -> *mut
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char) {
|
unsafe fn dc_ensure_no_slash(pathNfilename: *mut libc::c_char) {
|
||||||
let path_len = strlen(pathNfilename);
|
let path_len = strlen(pathNfilename);
|
||||||
if path_len > 0 && *pathNfilename.add(path_len - 1) as libc::c_int == '/' as i32
|
if path_len > 0 && *pathNfilename.add(path_len - 1) as libc::c_int == '/' as i32
|
||||||
|| *pathNfilename.add(path_len - 1) as libc::c_int == '\\' as i32
|
|| *pathNfilename.add(path_len - 1) as libc::c_int == '\\' as i32
|
||||||
@@ -855,7 +831,7 @@ pub fn dc_ensure_no_slash_safe(path: &str) -> &str {
|
|||||||
path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_validate_filename(filename: *mut libc::c_char) {
|
unsafe fn dc_validate_filename(filename: *mut libc::c_char) {
|
||||||
/* function modifies the given buffer and replaces all characters not valid in filenames by a "-" */
|
/* function modifies the given buffer and replaces all characters not valid in filenames by a "-" */
|
||||||
let mut p1: *mut libc::c_char = filename;
|
let mut p1: *mut libc::c_char = filename;
|
||||||
while 0 != *p1 {
|
while 0 != *p1 {
|
||||||
@@ -885,7 +861,7 @@ pub unsafe fn dc_get_filename(pathNfilename: *const libc::c_char) -> *mut libc::
|
|||||||
|
|
||||||
// the case of the suffix is preserved
|
// the case of the suffix is preserved
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
pub unsafe fn dc_split_filename(
|
unsafe fn dc_split_filename(
|
||||||
pathNfilename: *const libc::c_char,
|
pathNfilename: *const libc::c_char,
|
||||||
ret_basename: *mut *mut libc::c_char,
|
ret_basename: *mut *mut libc::c_char,
|
||||||
ret_all_suffixes_incl_dot: *mut *mut libc::c_char,
|
ret_all_suffixes_incl_dot: *mut *mut libc::c_char,
|
||||||
@@ -1185,7 +1161,7 @@ pub unsafe fn dc_is_blobdir_path(context: &Context, path: *const libc::c_char) -
|
|||||||
|| strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0
|
|| strncmp(path, b"$BLOBDIR\x00" as *const u8 as *const libc::c_char, 8) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
pub unsafe fn dc_make_rel_path(context: &Context, path: *mut *mut libc::c_char) {
|
unsafe fn dc_make_rel_path(context: &Context, path: *mut *mut libc::c_char) {
|
||||||
if path.is_null() || (*path).is_null() {
|
if path.is_null() || (*path).is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1386,7 @@ pub fn as_str<'a>(s: *const libc::c_char) -> &'a str {
|
|||||||
as_str_safe(s).unwrap_or_else(|err| panic!("{}", err))
|
as_str_safe(s).unwrap_or_else(|err| panic!("{}", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn as_str_safe<'a>(s: *const libc::c_char) -> Result<&'a str, Error> {
|
fn as_str_safe<'a>(s: *const libc::c_char) -> Result<&'a str, Error> {
|
||||||
assert!(!s.is_null(), "cannot be used on null pointers");
|
assert!(!s.is_null(), "cannot be used on null pointers");
|
||||||
|
|
||||||
let cstr = unsafe { CStr::from_ptr(s) };
|
let cstr = unsafe { CStr::from_ptr(s) };
|
||||||
|
|||||||
22
src/imap.rs
22
src/imap.rs
@@ -13,13 +13,13 @@ use crate::dc_tools::CStringExt;
|
|||||||
use crate::oauth2::dc_get_oauth2_access_token;
|
use crate::oauth2::dc_get_oauth2_access_token;
|
||||||
use crate::types::*;
|
use crate::types::*;
|
||||||
|
|
||||||
pub const DC_IMAP_SEEN: usize = 0x0001;
|
const DC_IMAP_SEEN: usize = 0x0001;
|
||||||
pub const DC_REGENERATE: usize = 0x01;
|
const DC_REGENERATE: usize = 0x01;
|
||||||
|
|
||||||
pub const DC_SUCCESS: usize = 3;
|
const DC_SUCCESS: usize = 3;
|
||||||
pub const DC_ALREADY_DONE: usize = 2;
|
const DC_ALREADY_DONE: usize = 2;
|
||||||
pub const DC_RETRY_LATER: usize = 1;
|
const DC_RETRY_LATER: usize = 1;
|
||||||
pub const DC_FAILED: usize = 0;
|
const DC_FAILED: usize = 0;
|
||||||
|
|
||||||
const PREFETCH_FLAGS: &str = "(UID ENVELOPE)";
|
const PREFETCH_FLAGS: &str = "(UID ENVELOPE)";
|
||||||
const BODY_FLAGS: &str = "(FLAGS BODY.PEEK[])";
|
const BODY_FLAGS: &str = "(FLAGS BODY.PEEK[])";
|
||||||
@@ -60,13 +60,13 @@ impl imap::Authenticator for OAuth2 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum FolderMeaning {
|
enum FolderMeaning {
|
||||||
Unknown,
|
Unknown,
|
||||||
SentObjects,
|
SentObjects,
|
||||||
Other,
|
Other,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Client {
|
enum Client {
|
||||||
Secure(
|
Secure(
|
||||||
imap::Client<native_tls::TlsStream<net::TcpStream>>,
|
imap::Client<native_tls::TlsStream<net::TcpStream>>,
|
||||||
net::TcpStream,
|
net::TcpStream,
|
||||||
@@ -74,12 +74,12 @@ pub enum Client {
|
|||||||
Insecure(imap::Client<net::TcpStream>, net::TcpStream),
|
Insecure(imap::Client<net::TcpStream>, net::TcpStream),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Session {
|
enum Session {
|
||||||
Secure(imap::Session<native_tls::TlsStream<net::TcpStream>>),
|
Secure(imap::Session<native_tls::TlsStream<net::TcpStream>>),
|
||||||
Insecure(imap::Session<net::TcpStream>),
|
Insecure(imap::Session<net::TcpStream>),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum IdleHandle<'a> {
|
enum IdleHandle<'a> {
|
||||||
Secure(imap::extensions::idle::Handle<'a, native_tls::TlsStream<net::TcpStream>>),
|
Secure(imap::extensions::idle::Handle<'a, native_tls::TlsStream<net::TcpStream>>),
|
||||||
Insecure(imap::extensions::idle::Handle<'a, net::TcpStream>),
|
Insecure(imap::extensions::idle::Handle<'a, net::TcpStream>),
|
||||||
}
|
}
|
||||||
@@ -308,7 +308,7 @@ impl Session {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ImapConfig {
|
struct ImapConfig {
|
||||||
pub addr: String,
|
pub addr: String,
|
||||||
pub imap_server: String,
|
pub imap_server: String,
|
||||||
pub imap_port: u16,
|
pub imap_port: u16,
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ pub fn dc_key_save_self_keypair(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Make a fingerprint human-readable, in hex format.
|
/// Make a fingerprint human-readable, in hex format.
|
||||||
pub fn dc_format_fingerprint(fingerprint: &str) -> String {
|
fn dc_format_fingerprint(fingerprint: &str) -> String {
|
||||||
// split key into chunks of 4 with space, and 20 newline
|
// split key into chunks of 4 with space, and 20 newline
|
||||||
let mut res = String::new();
|
let mut res = String::new();
|
||||||
|
|
||||||
|
|||||||
34
src/lib.rs
34
src/lib.rs
@@ -20,52 +20,50 @@ extern crate strum_macros;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
mod log;
|
mod log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
pub mod error;
|
mod error;
|
||||||
|
|
||||||
pub mod aheader;
|
mod aheader;
|
||||||
pub mod chatlist;
|
pub mod chatlist;
|
||||||
pub mod config;
|
pub mod config;
|
||||||
pub mod constants;
|
pub mod constants;
|
||||||
pub mod contact;
|
pub mod contact;
|
||||||
pub mod context;
|
pub mod context;
|
||||||
pub mod imap;
|
mod imap;
|
||||||
pub mod key;
|
pub mod key;
|
||||||
pub mod keyring;
|
pub mod keyring;
|
||||||
pub mod oauth2;
|
pub mod oauth2;
|
||||||
pub mod param;
|
mod param;
|
||||||
pub mod peerstate;
|
pub mod peerstate;
|
||||||
pub mod pgp;
|
pub mod pgp;
|
||||||
pub mod smtp;
|
mod smtp;
|
||||||
pub mod sql;
|
pub mod sql;
|
||||||
pub mod stock;
|
mod stock;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
pub mod x;
|
pub mod x;
|
||||||
|
|
||||||
pub mod dc_array;
|
pub mod dc_array;
|
||||||
pub mod dc_chat;
|
pub mod dc_chat;
|
||||||
pub mod dc_configure;
|
pub mod dc_configure;
|
||||||
pub mod dc_dehtml;
|
mod dc_dehtml;
|
||||||
pub mod dc_e2ee;
|
mod dc_e2ee;
|
||||||
pub mod dc_imex;
|
pub mod dc_imex;
|
||||||
pub mod dc_job;
|
pub mod dc_job;
|
||||||
pub mod dc_jobthread;
|
mod dc_jobthread;
|
||||||
pub mod dc_location;
|
pub mod dc_location;
|
||||||
pub mod dc_loginparam;
|
mod dc_loginparam;
|
||||||
pub mod dc_lot;
|
pub mod dc_lot;
|
||||||
pub mod dc_mimefactory;
|
mod dc_mimefactory;
|
||||||
pub mod dc_mimeparser;
|
pub mod dc_mimeparser;
|
||||||
pub mod dc_move;
|
mod dc_move;
|
||||||
pub mod dc_msg;
|
pub mod dc_msg;
|
||||||
pub mod dc_qr;
|
pub mod dc_qr;
|
||||||
pub mod dc_receive_imf;
|
pub mod dc_receive_imf;
|
||||||
pub mod dc_saxparser;
|
pub mod dc_saxparser;
|
||||||
pub mod dc_securejoin;
|
pub mod dc_securejoin;
|
||||||
pub mod dc_simplify;
|
mod dc_simplify;
|
||||||
pub mod dc_strencode;
|
mod dc_strencode;
|
||||||
pub mod dc_token;
|
mod dc_token;
|
||||||
pub mod dc_tools;
|
pub mod dc_tools;
|
||||||
|
|
||||||
pub use self::constants::*;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub mod test_utils;
|
mod test_utils;
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ const OAUTH2_YANDEX: Oauth2 = Oauth2 {
|
|||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub struct Oauth2 {
|
struct Oauth2 {
|
||||||
client_id: &'static str,
|
client_id: &'static str,
|
||||||
get_code: &'static str,
|
get_code: &'static str,
|
||||||
init_token: &'static str,
|
init_token: &'static str,
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ pub enum DegradeEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
|
||||||
pub enum VerifiedKey {
|
enum VerifiedKey {
|
||||||
Gossip,
|
Gossip,
|
||||||
Public,
|
Public,
|
||||||
None,
|
None,
|
||||||
|
|||||||
@@ -34,14 +34,9 @@ pub type dc_precheck_imf_t =
|
|||||||
pub type dc_set_config_t = fn(_: &Context, _: &str, _: Option<&str>) -> ();
|
pub type dc_set_config_t = fn(_: &Context, _: &str, _: Option<&str>) -> ();
|
||||||
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
pub type dc_get_config_t = fn(_: &Context, _: &str) -> Option<String>;
|
||||||
|
|
||||||
pub type sqlite_int64 = i64;
|
|
||||||
pub type sqlite3_int64 = sqlite_int64;
|
|
||||||
|
|
||||||
pub type int32_t = i32;
|
pub type int32_t = i32;
|
||||||
pub type int64_t = i64;
|
|
||||||
pub type uintptr_t = libc::uintptr_t;
|
pub type uintptr_t = libc::uintptr_t;
|
||||||
pub type size_t = libc::size_t;
|
pub type size_t = libc::size_t;
|
||||||
pub type ssize_t = libc::ssize_t;
|
|
||||||
pub type uint32_t = libc::c_uint;
|
pub type uint32_t = libc::c_uint;
|
||||||
pub type uint8_t = libc::c_uchar;
|
pub type uint8_t = libc::c_uchar;
|
||||||
pub type uint16_t = libc::c_ushort;
|
pub type uint16_t = libc::c_ushort;
|
||||||
|
|||||||
Reference in New Issue
Block a user