mirror of
https://github.com/chatmail/core.git
synced 2026-05-22 16:26:31 +03:00
Merge remote-tracking branch 'origin/master' into flub-sqlite
This commit is contained in:
@@ -1,15 +1,17 @@
|
||||
deltachat python bindings
|
||||
=========================
|
||||
|
||||
The ``deltachat`` Python package provides two bindings for the core C-library
|
||||
The ``deltachat`` Python package provides two bindings for the core Rust-library
|
||||
of the https://delta.chat messaging ecosystem:
|
||||
|
||||
- :doc:`capi` is a lowlevel CFFI-binding to the
|
||||
`deltachat-core C-API <https://c.delta.chat>`_.
|
||||
|
||||
- :doc:`api` [work-in-progress] is a high level interface to deltachat-core which aims
|
||||
- :doc:`api` is a high level interface to deltachat-core which aims
|
||||
to be memory safe and thoroughly tested through continous tox/pytest runs.
|
||||
|
||||
- :doc:`capi` is a lowlevel CFFI-binding to the previous
|
||||
`deltachat-core C-API <https://c.delta.chat>`_ (so far the Rust library
|
||||
replicates exactly the same C-level API).
|
||||
|
||||
|
||||
|
||||
getting started
|
||||
---------------
|
||||
|
||||
@@ -483,6 +483,8 @@ pub const DC_STR_MSGLOCATIONDISABLED: usize = 65;
|
||||
pub const DC_STR_LOCATION: usize = 66;
|
||||
pub const DC_STR_COUNT: usize = 66;
|
||||
|
||||
pub const DC_JOB_DELETE_MSG_ON_IMAP: i32 = 110;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)]
|
||||
#[repr(u8)]
|
||||
pub enum KeyType {
|
||||
|
||||
@@ -175,10 +175,7 @@ pub unsafe fn dc_mimeparser_parse(
|
||||
&mut (*mimeparser).e2ee_helper,
|
||||
);
|
||||
dc_mimeparser_parse_mime_recursive(mimeparser, (*mimeparser).mimeroot);
|
||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(
|
||||
mimeparser,
|
||||
b"Subject\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(mimeparser, "Subject");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_SUBJECT as libc::c_int {
|
||||
(*mimeparser).subject =
|
||||
dc_decode_header_words((*(*field).fld_data.fld_subject).sbj_value)
|
||||
@@ -191,12 +188,7 @@ pub unsafe fn dc_mimeparser_parse(
|
||||
{
|
||||
(*mimeparser).is_send_by_messenger = 1i32
|
||||
}
|
||||
if !dc_mimeparser_lookup_field(
|
||||
mimeparser,
|
||||
b"Autocrypt-Setup-Message\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
if !dc_mimeparser_lookup_field(mimeparser, "Autocrypt-Setup-Message").is_null() {
|
||||
let mut i: libc::c_int;
|
||||
let mut has_setup_file: libc::c_int = 0i32;
|
||||
i = 0i32;
|
||||
@@ -237,11 +229,7 @@ pub unsafe fn dc_mimeparser_parse(
|
||||
}
|
||||
}
|
||||
}
|
||||
if !dc_mimeparser_lookup_field(
|
||||
mimeparser,
|
||||
b"Chat-Group-Image\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
.is_null()
|
||||
if !dc_mimeparser_lookup_field(mimeparser, "Chat-Group-Image").is_null()
|
||||
&& carray_count((*mimeparser).parts) >= 1i32 as libc::c_uint
|
||||
{
|
||||
let textpart: *mut dc_mimepart_t =
|
||||
@@ -383,10 +371,8 @@ pub unsafe fn dc_mimeparser_parse(
|
||||
{
|
||||
let dn_to_addr: *mut libc::c_char = mailimf_find_first_addr(mb_list);
|
||||
if !dn_to_addr.is_null() {
|
||||
let from_field: *mut mailimf_field = dc_mimeparser_lookup_field(
|
||||
mimeparser,
|
||||
b"From\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let from_field: *mut mailimf_field =
|
||||
dc_mimeparser_lookup_field(mimeparser, "From");
|
||||
if !from_field.is_null()
|
||||
&& (*from_field).fld_type == MAILIMF_FIELD_FROM as libc::c_int
|
||||
&& !(*from_field).fld_data.fld_from.is_null()
|
||||
@@ -487,13 +473,14 @@ pub unsafe fn mailimf_find_first_addr(mb_list: *const mailimf_mailbox_list) -> *
|
||||
}
|
||||
|
||||
/* the following functions can be used only after a call to dc_mimeparser_parse() */
|
||||
|
||||
pub fn dc_mimeparser_lookup_field(
|
||||
mimeparser: &dc_mimeparser_t,
|
||||
field_name: *const libc::c_char,
|
||||
field_name: &str,
|
||||
) -> *mut mailimf_field {
|
||||
mimeparser
|
||||
.header
|
||||
.get(as_str(field_name))
|
||||
.get(field_name)
|
||||
.map(|v| *v)
|
||||
.unwrap_or_else(|| std::ptr::null_mut())
|
||||
}
|
||||
@@ -1621,12 +1608,7 @@ pub unsafe fn mailmime_transfer_decode(
|
||||
|
||||
// TODO should return bool /rtn
|
||||
pub unsafe fn dc_mimeparser_is_mailinglist_message(mimeparser: &dc_mimeparser_t) -> libc::c_int {
|
||||
if !dc_mimeparser_lookup_field(
|
||||
&mimeparser,
|
||||
b"List-Id\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
if !dc_mimeparser_lookup_field(&mimeparser, "List-Id").is_null() {
|
||||
return 1i32;
|
||||
}
|
||||
let precedence: *mut mailimf_optional_field = dc_mimeparser_lookup_optional_field(
|
||||
|
||||
@@ -39,7 +39,6 @@ pub unsafe fn dc_receive_imf(
|
||||
/* the function returns the number of created messages in the database */
|
||||
let mut incoming: libc::c_int = 1;
|
||||
let mut incoming_origin: libc::c_int = 0;
|
||||
let to_ids: *mut dc_array_t;
|
||||
let mut to_self: libc::c_int = 0;
|
||||
let mut from_id: uint32_t = 0 as uint32_t;
|
||||
let mut from_id_blocked: libc::c_int = 0;
|
||||
@@ -59,15 +58,19 @@ pub unsafe fn dc_receive_imf(
|
||||
let mut sort_timestamp = 0;
|
||||
let mut sent_timestamp = 0;
|
||||
let mut rcvd_timestamp = 0;
|
||||
let mut mime_parser = dc_mimeparser_new(context);
|
||||
let mut field: *const mailimf_field;
|
||||
let mut mime_in_reply_to = 0 as *mut libc::c_char;
|
||||
let mut mime_references = 0 as *mut libc::c_char;
|
||||
let created_db_entries = carray_new(16 as libc::c_uint);
|
||||
let mut created_db_entries = Vec::new();
|
||||
let mut create_event_to_send = Some(Event::MSGS_CHANGED);
|
||||
let rr_event_to_send = carray_new(16 as libc::c_uint);
|
||||
let mut rr_event_to_send = Vec::new();
|
||||
let mut txt_raw = 0 as *mut libc::c_char;
|
||||
|
||||
// XXX converting the below "to_ids" to a Vec quickly leads to lots of changes
|
||||
// so we keep it as a dc_array for now
|
||||
let to_ids = dc_array_new(16);
|
||||
assert!(!to_ids.is_null());
|
||||
|
||||
info!(
|
||||
context,
|
||||
0,
|
||||
@@ -79,29 +82,21 @@ pub unsafe fn dc_receive_imf(
|
||||
},
|
||||
server_uid,
|
||||
);
|
||||
to_ids = dc_array_new(16 as size_t);
|
||||
if to_ids.is_null() || created_db_entries.is_null() || rr_event_to_send.is_null() {
|
||||
info!(context, 0, "Bad param.",);
|
||||
} else {
|
||||
|
||||
let mut mime_parser = dc_mimeparser_new(context);
|
||||
dc_mimeparser_parse(&mut mime_parser, imf_raw_not_terminated, imf_raw_bytes);
|
||||
if mime_parser.header.is_empty() {
|
||||
info!(context, 0, "No header.",);
|
||||
} else {
|
||||
/* Error - even adding an empty record won't help as we do not know the message ID */
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mut mime_parser,
|
||||
b"Date\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mut mime_parser, "Date");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_ORIG_DATE as libc::c_int {
|
||||
let orig_date: *mut mailimf_orig_date = (*field).fld_data.fld_orig_date;
|
||||
if !orig_date.is_null() {
|
||||
sent_timestamp = dc_timestamp_from_date((*orig_date).dt_date_time)
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"From\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "From");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_FROM as libc::c_int {
|
||||
let fld_from: *mut mailimf_from = (*field).fld_data.fld_from;
|
||||
if !fld_from.is_null() {
|
||||
@@ -121,16 +116,12 @@ pub unsafe fn dc_receive_imf(
|
||||
}
|
||||
} else if dc_array_get_cnt(from_list) >= 1 {
|
||||
from_id = dc_array_get_id(from_list, 0 as size_t);
|
||||
incoming_origin =
|
||||
dc_get_contact_origin(context, from_id, &mut from_id_blocked)
|
||||
incoming_origin = dc_get_contact_origin(context, from_id, &mut from_id_blocked)
|
||||
}
|
||||
dc_array_unref(from_list);
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"To\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "To");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_TO as libc::c_int {
|
||||
let fld_to: *mut mailimf_to = (*field).fld_data.fld_to;
|
||||
if !fld_to.is_null() {
|
||||
@@ -150,10 +141,7 @@ pub unsafe fn dc_receive_imf(
|
||||
}
|
||||
}
|
||||
if !dc_mimeparser_get_last_nonmeta(&mime_parser).is_null() {
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"Cc\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "Cc");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_CC as libc::c_int {
|
||||
let fld_cc: *mut mailimf_cc = (*field).fld_data.fld_cc;
|
||||
if !fld_cc.is_null() {
|
||||
@@ -172,12 +160,8 @@ pub unsafe fn dc_receive_imf(
|
||||
);
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"Message-ID\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_MESSAGE_ID as libc::c_int
|
||||
{
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "Message-ID");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_MESSAGE_ID as libc::c_int {
|
||||
let fld_message_id: *mut mailimf_message_id = (*field).fld_data.fld_message_id;
|
||||
if !fld_message_id.is_null() {
|
||||
rfc724_mid = dc_strdup((*fld_message_id).mid_value)
|
||||
@@ -244,20 +228,12 @@ pub unsafe fn dc_receive_imf(
|
||||
if 0 != incoming {
|
||||
state = if 0 != flags & 0x1 { 16 } else { 10 };
|
||||
to_id = 1 as uint32_t;
|
||||
if !dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"Secure-Join\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
if !dc_mimeparser_lookup_field(&mime_parser, "Secure-Join").is_null() {
|
||||
msgrmsg = 1;
|
||||
chat_id = 0 as uint32_t;
|
||||
allow_creation = 1;
|
||||
let handshake: libc::c_int = dc_handle_securejoin_handshake(
|
||||
context,
|
||||
&mime_parser,
|
||||
from_id,
|
||||
);
|
||||
let handshake: libc::c_int =
|
||||
dc_handle_securejoin_handshake(context, &mime_parser, from_id);
|
||||
if 0 != handshake & 0x2 {
|
||||
hidden = 1;
|
||||
add_delete_job = handshake & 0x4;
|
||||
@@ -375,9 +351,8 @@ pub unsafe fn dc_receive_imf(
|
||||
}
|
||||
}
|
||||
if chat_id == 0 as libc::c_uint && 0 != allow_creation {
|
||||
let create_blocked_1: libc::c_int = if 0 != msgrmsg
|
||||
&& !dc_is_contact_blocked(context, to_id)
|
||||
{
|
||||
let create_blocked_1: libc::c_int =
|
||||
if 0 != msgrmsg && !dc_is_contact_blocked(context, to_id) {
|
||||
0
|
||||
} else {
|
||||
2
|
||||
@@ -389,9 +364,7 @@ pub unsafe fn dc_receive_imf(
|
||||
&mut chat_id,
|
||||
&mut chat_id_blocked,
|
||||
);
|
||||
if 0 != chat_id
|
||||
&& 0 != chat_id_blocked
|
||||
&& 0 == create_blocked_1
|
||||
if 0 != chat_id && 0 != chat_id_blocked && 0 == create_blocked_1
|
||||
{
|
||||
dc_unblock_chat(context, chat_id);
|
||||
chat_id_blocked = 0
|
||||
@@ -432,10 +405,7 @@ pub unsafe fn dc_receive_imf(
|
||||
// (the mime-header ends with an empty line)
|
||||
let save_mime_headers =
|
||||
sql::get_config_int(context, &context.sql, "save_mime_headers", 0);
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "In-Reply-To");
|
||||
if !field.is_null()
|
||||
&& (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int
|
||||
{
|
||||
@@ -448,10 +418,7 @@ pub unsafe fn dc_receive_imf(
|
||||
)
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
&mime_parser,
|
||||
b"References\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(&mime_parser, "References");
|
||||
if !field.is_null()
|
||||
&& (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int
|
||||
{
|
||||
@@ -564,16 +531,7 @@ pub unsafe fn dc_receive_imf(
|
||||
"rfc724_mid",
|
||||
as_str(rfc724_mid),
|
||||
);
|
||||
carray_add(
|
||||
created_db_entries,
|
||||
chat_id as uintptr_t as *mut libc::c_void,
|
||||
0 as *mut libc::c_uint,
|
||||
);
|
||||
carray_add(
|
||||
created_db_entries,
|
||||
insert_msg_id as uintptr_t as *mut libc::c_void,
|
||||
0 as *mut libc::c_uint,
|
||||
);
|
||||
created_db_entries.push((chat_id as usize, insert_msg_id as usize));
|
||||
}
|
||||
}
|
||||
i = i.wrapping_add(1)
|
||||
@@ -641,16 +599,13 @@ pub unsafe fn dc_receive_imf(
|
||||
{
|
||||
if strcmp(
|
||||
(*report_type).pa_value,
|
||||
b"disposition-notification\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
b"disposition-notification\x00" as *const u8 as *const libc::c_char,
|
||||
) == 0
|
||||
&& (*(*report_root).mm_data.mm_multipart.mm_mp_list).count >= 2
|
||||
{
|
||||
if 0 != mdns_enabled {
|
||||
let report_data: *mut mailmime = (if !if !(*(*report_root)
|
||||
.mm_data
|
||||
.mm_multipart
|
||||
.mm_mp_list)
|
||||
let report_data: *mut mailmime =
|
||||
(if !if !(*(*report_root).mm_data.mm_multipart.mm_mp_list)
|
||||
.first
|
||||
.is_null()
|
||||
{
|
||||
@@ -675,8 +630,7 @@ pub unsafe fn dc_receive_imf(
|
||||
.data
|
||||
} else {
|
||||
0 as *mut libc::c_void
|
||||
})
|
||||
as *mut mailmime;
|
||||
}) as *mut mailmime;
|
||||
if !report_data.is_null()
|
||||
&& (*(*(*report_data).mm_content_type).ct_type).tp_type
|
||||
== MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int
|
||||
@@ -724,25 +678,19 @@ pub unsafe fn dc_receive_imf(
|
||||
*const u8
|
||||
as
|
||||
*const libc::c_char);
|
||||
let of_org_msgid:
|
||||
*mut mailimf_optional_field =
|
||||
mailimf_find_optional_field(report_fields,
|
||||
b"Original-Message-ID\x00"
|
||||
as
|
||||
*const u8
|
||||
as
|
||||
*const libc::c_char);
|
||||
let of_org_msgid: *mut mailimf_optional_field =
|
||||
mailimf_find_optional_field(
|
||||
report_fields,
|
||||
b"Original-Message-ID\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
);
|
||||
if !of_disposition.is_null()
|
||||
&& !(*of_disposition)
|
||||
.fld_value
|
||||
.is_null()
|
||||
&& !(*of_disposition).fld_value.is_null()
|
||||
&& !of_org_msgid.is_null()
|
||||
&& !(*of_org_msgid).fld_value.is_null()
|
||||
{
|
||||
let mut rfc724_mid_0:
|
||||
*mut libc::c_char =
|
||||
0 as
|
||||
*mut libc::c_char;
|
||||
let mut rfc724_mid_0: *mut libc::c_char =
|
||||
0 as *mut libc::c_char;
|
||||
dummy = 0 as size_t;
|
||||
if mailimf_msg_id_parse(
|
||||
(*of_org_msgid).fld_value,
|
||||
@@ -764,26 +712,14 @@ pub unsafe fn dc_receive_imf(
|
||||
&mut chat_id_0,
|
||||
&mut msg_id,
|
||||
) {
|
||||
carray_add(
|
||||
rr_event_to_send,
|
||||
chat_id_0 as uintptr_t
|
||||
as *mut libc::c_void,
|
||||
0 as *mut libc::c_uint,
|
||||
);
|
||||
carray_add(
|
||||
rr_event_to_send,
|
||||
msg_id as uintptr_t
|
||||
as *mut libc::c_void,
|
||||
0 as *mut libc::c_uint,
|
||||
);
|
||||
rr_event_to_send
|
||||
.push((chat_id_0, 0));
|
||||
rr_event_to_send.push((msg_id, 0));
|
||||
}
|
||||
mdn_consumed = (msg_id
|
||||
!= 0 as libc::c_uint)
|
||||
as libc::c_int;
|
||||
free(
|
||||
rfc724_mid_0
|
||||
as *mut libc::c_void,
|
||||
);
|
||||
free(rfc724_mid_0 as *mut libc::c_void);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -849,8 +785,7 @@ pub unsafe fn dc_receive_imf(
|
||||
if !(*mime_parser.location_kml).addr.is_null()
|
||||
&& !contact.is_null()
|
||||
&& !(*contact).addr.is_null()
|
||||
&& strcasecmp((*contact).addr, (*mime_parser.location_kml).addr)
|
||||
== 0
|
||||
&& strcasecmp((*contact).addr, (*mime_parser.location_kml).addr) == 0
|
||||
{
|
||||
let newest_location_id = dc_save_locations(
|
||||
context,
|
||||
@@ -860,11 +795,7 @@ pub unsafe fn dc_receive_imf(
|
||||
0,
|
||||
);
|
||||
if newest_location_id != 0 && hidden == 0 && !location_id_written {
|
||||
dc_set_msg_location_id(
|
||||
context,
|
||||
insert_msg_id,
|
||||
newest_location_id,
|
||||
);
|
||||
dc_set_msg_location_id(context, insert_msg_id, newest_location_id);
|
||||
}
|
||||
send_event = true;
|
||||
}
|
||||
@@ -879,13 +810,11 @@ pub unsafe fn dc_receive_imf(
|
||||
}
|
||||
}
|
||||
|
||||
if 0 != add_delete_job && carray_count(created_db_entries) >= 2 as libc::c_uint
|
||||
{
|
||||
if 0 != add_delete_job && !created_db_entries.is_empty() {
|
||||
dc_job_add(
|
||||
context,
|
||||
110,
|
||||
carray_get(created_db_entries, 1 as libc::c_uint) as uintptr_t
|
||||
as libc::c_int,
|
||||
DC_JOB_DELETE_MSG_ON_IMAP,
|
||||
created_db_entries[0].1 as i32,
|
||||
0 as *const libc::c_char,
|
||||
0,
|
||||
);
|
||||
@@ -893,42 +822,21 @@ pub unsafe fn dc_receive_imf(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(rfc724_mid as *mut libc::c_void);
|
||||
free(mime_in_reply_to as *mut libc::c_void);
|
||||
free(mime_references as *mut libc::c_void);
|
||||
dc_array_unref(to_ids);
|
||||
if !created_db_entries.is_null() {
|
||||
|
||||
if let Some(create_event_to_send) = create_event_to_send {
|
||||
let mut i_0: size_t = 0;
|
||||
let icnt_0: size_t = carray_count(created_db_entries) as size_t;
|
||||
while i_0 < icnt_0 {
|
||||
context.call_cb(
|
||||
create_event_to_send,
|
||||
carray_get(created_db_entries, i_0 as libc::c_uint) as uintptr_t,
|
||||
carray_get(created_db_entries, i_0.wrapping_add(1) as libc::c_uint)
|
||||
as uintptr_t,
|
||||
);
|
||||
i_0 = (i_0 as libc::c_ulong).wrapping_add(2 as libc::c_ulong) as size_t as size_t
|
||||
for (msg_id, insert_id) in &created_db_entries {
|
||||
context.call_cb(create_event_to_send, *msg_id, *insert_id);
|
||||
}
|
||||
}
|
||||
carray_free(created_db_entries);
|
||||
}
|
||||
if !rr_event_to_send.is_null() {
|
||||
let mut i_1: size_t;
|
||||
let icnt_1: size_t = carray_count(rr_event_to_send) as size_t;
|
||||
i_1 = 0 as size_t;
|
||||
while i_1 < icnt_1 {
|
||||
context.call_cb(
|
||||
Event::MSG_READ,
|
||||
carray_get(rr_event_to_send, i_1 as libc::c_uint) as uintptr_t,
|
||||
carray_get(rr_event_to_send, i_1.wrapping_add(1) as libc::c_uint) as uintptr_t,
|
||||
);
|
||||
i_1 = (i_1 as libc::c_ulong).wrapping_add(2 as libc::c_ulong) as size_t as size_t
|
||||
}
|
||||
carray_free(rr_event_to_send);
|
||||
for (chat_id, msg_id) in &rr_event_to_send {
|
||||
context.call_cb(Event::MSG_READ, *chat_id as uintptr_t, *msg_id as uintptr_t);
|
||||
}
|
||||
|
||||
free(txt_raw as *mut libc::c_void);
|
||||
}
|
||||
|
||||
@@ -1034,10 +942,7 @@ unsafe fn create_or_lookup_group(
|
||||
grpid = dc_strdup((*optional_field).fld_value)
|
||||
}
|
||||
if grpid.is_null() {
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"Message-ID\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(mime_parser, "Message-ID");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_MESSAGE_ID as libc::c_int {
|
||||
let fld_message_id: *mut mailimf_message_id = (*field).fld_data.fld_message_id;
|
||||
if !fld_message_id.is_null() {
|
||||
@@ -1045,10 +950,7 @@ unsafe fn create_or_lookup_group(
|
||||
}
|
||||
}
|
||||
if grpid.is_null() {
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
||||
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||
if !fld_in_reply_to.is_null() {
|
||||
@@ -1056,10 +958,7 @@ unsafe fn create_or_lookup_group(
|
||||
}
|
||||
}
|
||||
if grpid.is_null() {
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"References\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int
|
||||
{
|
||||
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||
@@ -1221,12 +1120,7 @@ unsafe fn create_or_lookup_group(
|
||||
/*otherwise, a pending "quit" message may pop up*/
|
||||
/*re-create explicitly left groups only if ourself is re-added*/
|
||||
let mut create_verified: libc::c_int = 0;
|
||||
if !dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"Chat-Verified\x00" as *const u8 as *const libc::c_char,
|
||||
)
|
||||
.is_null()
|
||||
{
|
||||
if !dc_mimeparser_lookup_field(mime_parser, "Chat-Verified").is_null() {
|
||||
create_verified = 1;
|
||||
if 0 == check_verified_properties(
|
||||
context,
|
||||
@@ -1815,8 +1709,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
) -> libc::c_int {
|
||||
/* check if the message is a reply to a known message; the replies are identified by the Message-ID from
|
||||
`In-Reply-To`/`References:` (to support non-Delta-Clients) or from `Chat-Predecessor:` (Delta clients, see comment in dc_chat.c) */
|
||||
let optional_field: *mut mailimf_optional_field;
|
||||
optional_field = dc_mimeparser_lookup_optional_field(
|
||||
let optional_field = dc_mimeparser_lookup_optional_field(
|
||||
mime_parser,
|
||||
b"Chat-Predecessor\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
@@ -1825,11 +1718,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
let mut field: *mut mailimf_field;
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
||||
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||
if !fld_in_reply_to.is_null() {
|
||||
@@ -1841,10 +1730,7 @@ unsafe fn dc_is_reply_to_known_message(
|
||||
}
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"References\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
||||
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||
if !fld_references.is_null() {
|
||||
@@ -1912,11 +1798,7 @@ unsafe fn dc_is_reply_to_messenger_message(
|
||||
- checks also if any of the referenced IDs are send by a messenger
|
||||
- it is okay, if the referenced messages are moved to trash here
|
||||
- no check for the Chat-* headers (function is only called if it is no messenger message itself) */
|
||||
let mut field: *mut mailimf_field;
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
||||
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||
if !fld_in_reply_to.is_null() {
|
||||
@@ -1928,10 +1810,7 @@ unsafe fn dc_is_reply_to_messenger_message(
|
||||
}
|
||||
}
|
||||
}
|
||||
field = dc_mimeparser_lookup_field(
|
||||
mime_parser,
|
||||
b"References\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
let field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
||||
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||
if !fld_references.is_null() {
|
||||
|
||||
@@ -353,10 +353,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
let mut ret: libc::c_int = 0i32;
|
||||
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
|
||||
if !(contact_id <= 9i32 as libc::c_uint) {
|
||||
step = lookup_field(
|
||||
mimeparser,
|
||||
b"Secure-Join\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
step = lookup_field(mimeparser, "Secure-Join");
|
||||
if !step.is_null() {
|
||||
info!(
|
||||
context,
|
||||
@@ -389,10 +386,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
// send_message() will fail with the error "End-to-end-encryption unavailable unexpectedly.", so, there is no additional check needed here.
|
||||
// verify that the `Secure-Join-Invitenumber:`-header matches invitenumber written to the QR code
|
||||
let invitenumber: *const libc::c_char;
|
||||
invitenumber = lookup_field(
|
||||
mimeparser,
|
||||
b"Secure-Join-Invitenumber\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
invitenumber = lookup_field(mimeparser, "Secure-Join-Invitenumber");
|
||||
if invitenumber.is_null() {
|
||||
warn!(context, 0, "Secure-join denied (invitenumber missing).",);
|
||||
current_block = 4378276786830486580;
|
||||
@@ -518,10 +512,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
============================================================ */
|
||||
// verify that Secure-Join-Fingerprint:-header matches the fingerprint of Bob
|
||||
let fingerprint: *const libc::c_char;
|
||||
fingerprint = lookup_field(
|
||||
mimeparser,
|
||||
b"Secure-Join-Fingerprint\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
fingerprint = lookup_field(mimeparser, "Secure-Join-Fingerprint");
|
||||
if fingerprint.is_null() {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
@@ -548,10 +539,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
info!(context, 0, "Fingerprint verified.",);
|
||||
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
|
||||
let auth_0: *const libc::c_char;
|
||||
auth_0 = lookup_field(
|
||||
mimeparser,
|
||||
b"Secure-Join-Auth\x00" as *const u8 as *const libc::c_char,
|
||||
);
|
||||
auth_0 = lookup_field(mimeparser, "Secure-Join-Auth");
|
||||
if auth_0.is_null() {
|
||||
could_not_establish_secure_connection(
|
||||
context,
|
||||
@@ -589,10 +577,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
600i32 as uintptr_t,
|
||||
);
|
||||
if 0 != join_vg {
|
||||
grpid = dc_strdup(lookup_field(
|
||||
mimeparser,
|
||||
b"Secure-Join-Group\x00" as *const u8 as *const libc::c_char,
|
||||
));
|
||||
grpid = dc_strdup(lookup_field(mimeparser, "Secure-Join-Group"));
|
||||
let group_chat_id: uint32_t = dc_get_chat_id_by_grpid(
|
||||
context,
|
||||
grpid,
|
||||
@@ -714,11 +699,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
||||
if 0 != join_vg {
|
||||
if 0 == dc_addr_equals_self(
|
||||
context,
|
||||
lookup_field(
|
||||
mimeparser,
|
||||
b"Chat-Group-Member-Added\x00" as *const u8
|
||||
as *const libc::c_char,
|
||||
),
|
||||
lookup_field(mimeparser, "Chat-Group-Member-Added"),
|
||||
) {
|
||||
info!(
|
||||
context,
|
||||
@@ -832,10 +813,7 @@ unsafe fn secure_connection_established(context: &Context, contact_chat_id: uint
|
||||
dc_contact_unref(contact);
|
||||
}
|
||||
|
||||
unsafe fn lookup_field(
|
||||
mimeparser: &dc_mimeparser_t,
|
||||
key: *const libc::c_char,
|
||||
) -> *const libc::c_char {
|
||||
unsafe fn lookup_field(mimeparser: &dc_mimeparser_t, key: &str) -> *const libc::c_char {
|
||||
let mut value: *const libc::c_char = 0 as *const libc::c_char;
|
||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(mimeparser, key);
|
||||
if field.is_null()
|
||||
|
||||
Reference in New Issue
Block a user