mirror of
https://github.com/chatmail/core.git
synced 2026-05-01 20:36:31 +03:00
Merge pull request #181 from deltachat/improve_receive_imf1
improve dc_receive_imf and friends a little (part 1)
This commit is contained in:
@@ -483,6 +483,8 @@ pub const DC_STR_MSGLOCATIONDISABLED: usize = 65;
|
|||||||
pub const DC_STR_LOCATION: usize = 66;
|
pub const DC_STR_LOCATION: usize = 66;
|
||||||
pub const DC_STR_COUNT: 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)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, FromPrimitive, ToPrimitive)]
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
pub enum KeyType {
|
pub enum KeyType {
|
||||||
|
|||||||
@@ -176,10 +176,7 @@ pub unsafe fn dc_mimeparser_parse(
|
|||||||
&mut (*mimeparser).e2ee_helper,
|
&mut (*mimeparser).e2ee_helper,
|
||||||
);
|
);
|
||||||
dc_mimeparser_parse_mime_recursive(mimeparser, (*mimeparser).mimeroot);
|
dc_mimeparser_parse_mime_recursive(mimeparser, (*mimeparser).mimeroot);
|
||||||
let field: *mut mailimf_field = dc_mimeparser_lookup_field(
|
let field: *mut mailimf_field = dc_mimeparser_lookup_field(mimeparser, "Subject");
|
||||||
mimeparser,
|
|
||||||
b"Subject\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_SUBJECT as libc::c_int {
|
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_SUBJECT as libc::c_int {
|
||||||
(*mimeparser).subject =
|
(*mimeparser).subject =
|
||||||
dc_decode_header_words((*(*field).fld_data.fld_subject).sbj_value)
|
dc_decode_header_words((*(*field).fld_data.fld_subject).sbj_value)
|
||||||
@@ -192,12 +189,7 @@ pub unsafe fn dc_mimeparser_parse(
|
|||||||
{
|
{
|
||||||
(*mimeparser).is_send_by_messenger = 1i32
|
(*mimeparser).is_send_by_messenger = 1i32
|
||||||
}
|
}
|
||||||
if !dc_mimeparser_lookup_field(
|
if !dc_mimeparser_lookup_field(mimeparser, "Autocrypt-Setup-Message").is_null() {
|
||||||
mimeparser,
|
|
||||||
b"Autocrypt-Setup-Message\x00" as *const u8 as *const libc::c_char,
|
|
||||||
)
|
|
||||||
.is_null()
|
|
||||||
{
|
|
||||||
let mut i: libc::c_int;
|
let mut i: libc::c_int;
|
||||||
let mut has_setup_file: libc::c_int = 0i32;
|
let mut has_setup_file: libc::c_int = 0i32;
|
||||||
i = 0i32;
|
i = 0i32;
|
||||||
@@ -238,11 +230,7 @@ pub unsafe fn dc_mimeparser_parse(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !dc_mimeparser_lookup_field(
|
if !dc_mimeparser_lookup_field(mimeparser, "Chat-Group-Image").is_null()
|
||||||
mimeparser,
|
|
||||||
b"Chat-Group-Image\x00" as *const u8 as *const libc::c_char,
|
|
||||||
)
|
|
||||||
.is_null()
|
|
||||||
&& carray_count((*mimeparser).parts) >= 1i32 as libc::c_uint
|
&& carray_count((*mimeparser).parts) >= 1i32 as libc::c_uint
|
||||||
{
|
{
|
||||||
let textpart: *mut dc_mimepart_t =
|
let textpart: *mut dc_mimepart_t =
|
||||||
@@ -384,10 +372,8 @@ pub unsafe fn dc_mimeparser_parse(
|
|||||||
{
|
{
|
||||||
let dn_to_addr: *mut libc::c_char = mailimf_find_first_addr(mb_list);
|
let dn_to_addr: *mut libc::c_char = mailimf_find_first_addr(mb_list);
|
||||||
if !dn_to_addr.is_null() {
|
if !dn_to_addr.is_null() {
|
||||||
let from_field: *mut mailimf_field = dc_mimeparser_lookup_field(
|
let from_field: *mut mailimf_field =
|
||||||
mimeparser,
|
dc_mimeparser_lookup_field(mimeparser, "From");
|
||||||
b"From\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !from_field.is_null()
|
if !from_field.is_null()
|
||||||
&& (*from_field).fld_type == MAILIMF_FIELD_FROM as libc::c_int
|
&& (*from_field).fld_type == MAILIMF_FIELD_FROM as libc::c_int
|
||||||
&& !(*from_field).fld_data.fld_from.is_null()
|
&& !(*from_field).fld_data.fld_from.is_null()
|
||||||
@@ -488,13 +474,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() */
|
/* the following functions can be used only after a call to dc_mimeparser_parse() */
|
||||||
|
|
||||||
pub fn dc_mimeparser_lookup_field(
|
pub fn dc_mimeparser_lookup_field(
|
||||||
mimeparser: &dc_mimeparser_t,
|
mimeparser: &dc_mimeparser_t,
|
||||||
field_name: *const libc::c_char,
|
field_name: &str,
|
||||||
) -> *mut mailimf_field {
|
) -> *mut mailimf_field {
|
||||||
mimeparser
|
mimeparser
|
||||||
.header
|
.header
|
||||||
.get(as_str(field_name))
|
.get(field_name)
|
||||||
.map(|v| *v)
|
.map(|v| *v)
|
||||||
.unwrap_or_else(|| std::ptr::null_mut())
|
.unwrap_or_else(|| std::ptr::null_mut())
|
||||||
}
|
}
|
||||||
@@ -1627,12 +1614,7 @@ pub unsafe fn mailmime_transfer_decode(
|
|||||||
|
|
||||||
// TODO should return bool /rtn
|
// TODO should return bool /rtn
|
||||||
pub unsafe fn dc_mimeparser_is_mailinglist_message(mimeparser: &dc_mimeparser_t) -> libc::c_int {
|
pub unsafe fn dc_mimeparser_is_mailinglist_message(mimeparser: &dc_mimeparser_t) -> libc::c_int {
|
||||||
if !dc_mimeparser_lookup_field(
|
if !dc_mimeparser_lookup_field(&mimeparser, "List-Id").is_null() {
|
||||||
&mimeparser,
|
|
||||||
b"List-Id\x00" as *const u8 as *const libc::c_char,
|
|
||||||
)
|
|
||||||
.is_null()
|
|
||||||
{
|
|
||||||
return 1i32;
|
return 1i32;
|
||||||
}
|
}
|
||||||
let precedence: *mut mailimf_optional_field = dc_mimeparser_lookup_optional_field(
|
let precedence: *mut mailimf_optional_field = dc_mimeparser_lookup_optional_field(
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ pub unsafe fn dc_receive_imf(
|
|||||||
/* the function returns the number of created messages in the database */
|
/* the function returns the number of created messages in the database */
|
||||||
let mut incoming: libc::c_int = 1i32;
|
let mut incoming: libc::c_int = 1i32;
|
||||||
let mut incoming_origin: libc::c_int = 0i32;
|
let mut incoming_origin: libc::c_int = 0i32;
|
||||||
let to_ids: *mut dc_array_t;
|
|
||||||
let mut to_self: libc::c_int = 0i32;
|
let mut to_self: libc::c_int = 0i32;
|
||||||
let mut from_id: uint32_t = 0i32 as uint32_t;
|
let mut from_id: uint32_t = 0i32 as uint32_t;
|
||||||
let mut from_id_blocked: libc::c_int = 0i32;
|
let mut from_id_blocked: libc::c_int = 0i32;
|
||||||
@@ -60,56 +59,43 @@ pub unsafe fn dc_receive_imf(
|
|||||||
let mut sort_timestamp = 0;
|
let mut sort_timestamp = 0;
|
||||||
let mut sent_timestamp = 0;
|
let mut sent_timestamp = 0;
|
||||||
let mut rcvd_timestamp = 0;
|
let mut rcvd_timestamp = 0;
|
||||||
let mut mime_parser = dc_mimeparser_new(context);
|
|
||||||
let mut field: *const mailimf_field;
|
let mut field: *const mailimf_field;
|
||||||
let mut mime_in_reply_to: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut mime_in_reply_to: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
let mut mime_references: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut mime_references: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
let created_db_entries: *mut carray = carray_new(16i32 as libc::c_uint);
|
let mut created_db_entries = Vec::new();
|
||||||
let mut create_event_to_send = Some(Event::MSGS_CHANGED);
|
let mut create_event_to_send = Some(Event::MSGS_CHANGED);
|
||||||
let rr_event_to_send: *mut carray = carray_new(16i32 as libc::c_uint);
|
let mut rr_event_to_send = Vec::new();
|
||||||
let mut txt_raw: *mut libc::c_char = 0 as *mut libc::c_char;
|
let mut txt_raw: *mut libc::c_char = 0 as *mut libc::c_char;
|
||||||
dc_log_info(
|
|
||||||
|
// 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: *mut dc_array_t = dc_array_new(16);
|
||||||
|
assert!(!to_ids.is_null());
|
||||||
|
info!(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0,
|
||||||
b"Receiving message %s/%lu...\x00" as *const u8 as *const libc::c_char,
|
"Receiving message {}/{}...",
|
||||||
if !server_folder.is_null() {
|
if !server_folder.is_null() {
|
||||||
server_folder
|
as_str(server_folder)
|
||||||
} else {
|
} else {
|
||||||
b"?\x00" as *const u8 as *const libc::c_char
|
"?"
|
||||||
},
|
},
|
||||||
server_uid,
|
server_uid,
|
||||||
);
|
);
|
||||||
to_ids = dc_array_new(16i32 as size_t);
|
let mut mime_parser = dc_mimeparser_new(context);
|
||||||
if to_ids.is_null() || created_db_entries.is_null() || rr_event_to_send.is_null() {
|
|
||||||
dc_log_info(
|
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"Bad param.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
dc_mimeparser_parse(&mut mime_parser, imf_raw_not_terminated, imf_raw_bytes);
|
dc_mimeparser_parse(&mut mime_parser, imf_raw_not_terminated, imf_raw_bytes);
|
||||||
if mime_parser.header.is_empty() {
|
if mime_parser.header.is_empty() {
|
||||||
dc_log_info(
|
info!(context, 0, "No header.",);
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"No header.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
/* Error - even adding an empty record won't help as we do not know the message ID */
|
/* Error - even adding an empty record won't help as we do not know the message ID */
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mut mime_parser, "Date");
|
||||||
&mut mime_parser,
|
|
||||||
b"Date\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_ORIG_DATE as libc::c_int {
|
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;
|
let orig_date: *mut mailimf_orig_date = (*field).fld_data.fld_orig_date;
|
||||||
if !orig_date.is_null() {
|
if !orig_date.is_null() {
|
||||||
sent_timestamp = dc_timestamp_from_date((*orig_date).dt_date_time)
|
sent_timestamp = dc_timestamp_from_date((*orig_date).dt_date_time)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "From");
|
||||||
&mime_parser,
|
|
||||||
b"From\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_FROM as libc::c_int {
|
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;
|
let fld_from: *mut mailimf_from = (*field).fld_data.fld_from;
|
||||||
if !fld_from.is_null() {
|
if !fld_from.is_null() {
|
||||||
@@ -129,16 +115,12 @@ pub unsafe fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
} else if dc_array_get_cnt(from_list) >= 1 {
|
} else if dc_array_get_cnt(from_list) >= 1 {
|
||||||
from_id = dc_array_get_id(from_list, 0i32 as size_t);
|
from_id = dc_array_get_id(from_list, 0i32 as size_t);
|
||||||
incoming_origin =
|
incoming_origin = dc_get_contact_origin(context, from_id, &mut from_id_blocked)
|
||||||
dc_get_contact_origin(context, from_id, &mut from_id_blocked)
|
|
||||||
}
|
}
|
||||||
dc_array_unref(from_list);
|
dc_array_unref(from_list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "To");
|
||||||
&mime_parser,
|
|
||||||
b"To\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_TO as libc::c_int {
|
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;
|
let fld_to: *mut mailimf_to = (*field).fld_data.fld_to;
|
||||||
if !fld_to.is_null() {
|
if !fld_to.is_null() {
|
||||||
@@ -158,10 +140,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !dc_mimeparser_get_last_nonmeta(&mime_parser).is_null() {
|
if !dc_mimeparser_get_last_nonmeta(&mime_parser).is_null() {
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "Cc");
|
||||||
&mime_parser,
|
|
||||||
b"Cc\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_CC as libc::c_int {
|
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;
|
let fld_cc: *mut mailimf_cc = (*field).fld_data.fld_cc;
|
||||||
if !fld_cc.is_null() {
|
if !fld_cc.is_null() {
|
||||||
@@ -180,12 +159,8 @@ pub unsafe fn dc_receive_imf(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "Message-ID");
|
||||||
&mime_parser,
|
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_MESSAGE_ID as libc::c_int {
|
||||||
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
|
|
||||||
{
|
|
||||||
let fld_message_id: *mut mailimf_message_id = (*field).fld_data.fld_message_id;
|
let fld_message_id: *mut mailimf_message_id = (*field).fld_data.fld_message_id;
|
||||||
if !fld_message_id.is_null() {
|
if !fld_message_id.is_null() {
|
||||||
rfc724_mid = dc_strdup((*fld_message_id).mid_value)
|
rfc724_mid = dc_strdup((*fld_message_id).mid_value)
|
||||||
@@ -222,12 +197,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
if strcmp(old_server_folder, server_folder) != 0i32
|
if strcmp(old_server_folder, server_folder) != 0i32
|
||||||
|| old_server_uid != server_uid
|
|| old_server_uid != server_uid
|
||||||
{
|
{
|
||||||
dc_update_server_uid(
|
dc_update_server_uid(context, rfc724_mid, server_folder, server_uid);
|
||||||
context,
|
|
||||||
rfc724_mid,
|
|
||||||
server_folder,
|
|
||||||
server_uid,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
free(old_server_folder as *mut libc::c_void);
|
free(old_server_folder as *mut libc::c_void);
|
||||||
dc_log_info(
|
dc_log_info(
|
||||||
@@ -264,24 +234,16 @@ pub unsafe fn dc_receive_imf(
|
|||||||
if 0 != incoming {
|
if 0 != incoming {
|
||||||
state = if 0 != flags & 0x1 { 16 } else { 10 };
|
state = if 0 != flags & 0x1 { 16 } else { 10 };
|
||||||
to_id = 1 as uint32_t;
|
to_id = 1 as uint32_t;
|
||||||
if !dc_mimeparser_lookup_field(
|
if !dc_mimeparser_lookup_field(&mime_parser, "Secure-Join").is_null() {
|
||||||
&mime_parser,
|
|
||||||
b"Secure-Join\x00" as *const u8 as *const libc::c_char,
|
|
||||||
)
|
|
||||||
.is_null()
|
|
||||||
{
|
|
||||||
msgrmsg = 1i32;
|
msgrmsg = 1i32;
|
||||||
chat_id = 0i32 as uint32_t;
|
chat_id = 0i32 as uint32_t;
|
||||||
allow_creation = 1i32;
|
allow_creation = 1i32;
|
||||||
let handshake: libc::c_int = dc_handle_securejoin_handshake(
|
let handshake: libc::c_int =
|
||||||
context,
|
dc_handle_securejoin_handshake(context, &mime_parser, from_id);
|
||||||
&mime_parser,
|
if 0 != handshake & 0x2 {
|
||||||
from_id,
|
hidden = 1;
|
||||||
);
|
add_delete_job = handshake & 0x4;
|
||||||
if 0 != handshake & 0x2i32 {
|
state = 16
|
||||||
hidden = 1i32;
|
|
||||||
add_delete_job = handshake & 0x4i32;
|
|
||||||
state = 16i32
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut test_normal_chat_id: uint32_t = 0i32 as uint32_t;
|
let mut test_normal_chat_id: uint32_t = 0i32 as uint32_t;
|
||||||
@@ -397,9 +359,8 @@ pub unsafe fn dc_receive_imf(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if chat_id == 0i32 as libc::c_uint && 0 != allow_creation {
|
if chat_id == 0i32 as libc::c_uint && 0 != allow_creation {
|
||||||
let create_blocked_1: libc::c_int = if 0 != msgrmsg
|
let create_blocked_1: libc::c_int =
|
||||||
&& !dc_is_contact_blocked(context, to_id)
|
if 0 != msgrmsg && !dc_is_contact_blocked(context, to_id) {
|
||||||
{
|
|
||||||
0i32
|
0i32
|
||||||
} else {
|
} else {
|
||||||
2i32
|
2i32
|
||||||
@@ -411,9 +372,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
&mut chat_id,
|
&mut chat_id,
|
||||||
&mut chat_id_blocked,
|
&mut chat_id_blocked,
|
||||||
);
|
);
|
||||||
if 0 != chat_id
|
if 0 != chat_id && 0 != chat_id_blocked && 0 == create_blocked_1
|
||||||
&& 0 != chat_id_blocked
|
|
||||||
&& 0 == create_blocked_1
|
|
||||||
{
|
{
|
||||||
dc_unblock_chat(context, chat_id);
|
dc_unblock_chat(context, chat_id);
|
||||||
chat_id_blocked = 0i32
|
chat_id_blocked = 0i32
|
||||||
@@ -466,8 +425,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
b"\r\n\r\n\x00" as *const u8 as *const libc::c_char,
|
b"\r\n\r\n\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
if !p.is_null() {
|
if !p.is_null() {
|
||||||
header_bytes = (p.wrapping_offset_from(imf_raw_not_terminated)
|
header_bytes = (p.wrapping_offset_from(imf_raw_not_terminated) + 4)
|
||||||
+ 4)
|
|
||||||
as libc::c_int
|
as libc::c_int
|
||||||
} else {
|
} else {
|
||||||
p = strstr(
|
p = strstr(
|
||||||
@@ -475,16 +433,13 @@ pub unsafe fn dc_receive_imf(
|
|||||||
b"\n\n\x00" as *const u8 as *const libc::c_char,
|
b"\n\n\x00" as *const u8 as *const libc::c_char,
|
||||||
);
|
);
|
||||||
if !p.is_null() {
|
if !p.is_null() {
|
||||||
header_bytes =
|
header_bytes = (p.wrapping_offset_from(imf_raw_not_terminated)
|
||||||
(p.wrapping_offset_from(imf_raw_not_terminated) + 2)
|
+ 2)
|
||||||
as libc::c_int
|
as libc::c_int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "In-Reply-To");
|
||||||
&mime_parser,
|
|
||||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null()
|
if !field.is_null()
|
||||||
&& (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int
|
&& (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int
|
||||||
{
|
{
|
||||||
@@ -497,10 +452,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(&mime_parser, "References");
|
||||||
&mime_parser,
|
|
||||||
b"References\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null()
|
if !field.is_null()
|
||||||
&& (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int
|
&& (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int
|
||||||
{
|
{
|
||||||
@@ -624,8 +576,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
dc_log_info(
|
dc_log_info(
|
||||||
context,
|
context,
|
||||||
0i32,
|
0i32,
|
||||||
b"Cannot write DB.\x00" as *const u8
|
b"Cannot write DB.\x00" as *const u8 as *const libc::c_char,
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
);
|
||||||
/* i/o error - there is nothing more we can do - in other cases, we try to write at least an empty record */
|
/* i/o error - there is nothing more we can do - in other cases, we try to write at least an empty record */
|
||||||
current_block = 16282941964262048061;
|
current_block = 16282941964262048061;
|
||||||
@@ -640,16 +591,8 @@ pub unsafe fn dc_receive_imf(
|
|||||||
b"rfc724_mid\x00" as *const u8 as *const libc::c_char,
|
b"rfc724_mid\x00" as *const u8 as *const libc::c_char,
|
||||||
rfc724_mid,
|
rfc724_mid,
|
||||||
);
|
);
|
||||||
carray_add(
|
created_db_entries
|
||||||
created_db_entries,
|
.push((chat_id as usize, insert_msg_id as usize))
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
i = i.wrapping_add(1)
|
i = i.wrapping_add(1)
|
||||||
@@ -716,17 +659,13 @@ pub unsafe fn dc_receive_imf(
|
|||||||
{
|
{
|
||||||
if strcmp(
|
if strcmp(
|
||||||
(*report_type).pa_value,
|
(*report_type).pa_value,
|
||||||
b"disposition-notification\x00" as *const u8
|
b"disposition-notification\x00" as *const u8 as *const libc::c_char,
|
||||||
as *const libc::c_char,
|
|
||||||
) == 0i32
|
) == 0i32
|
||||||
&& (*(*report_root).mm_data.mm_multipart.mm_mp_list).count
|
&& (*(*report_root).mm_data.mm_multipart.mm_mp_list).count >= 2i32
|
||||||
>= 2i32
|
|
||||||
{
|
{
|
||||||
if 0 != mdns_enabled {
|
if 0 != mdns_enabled {
|
||||||
let report_data: *mut mailmime = (if !if !(*(*report_root)
|
let report_data: *mut mailmime =
|
||||||
.mm_data
|
(if !if !(*(*report_root).mm_data.mm_multipart.mm_mp_list)
|
||||||
.mm_multipart
|
|
||||||
.mm_mp_list)
|
|
||||||
.first
|
.first
|
||||||
.is_null()
|
.is_null()
|
||||||
{
|
{
|
||||||
@@ -751,8 +690,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
.data
|
.data
|
||||||
} else {
|
} else {
|
||||||
0 as *mut libc::c_void
|
0 as *mut libc::c_void
|
||||||
})
|
}) as *mut mailmime;
|
||||||
as *mut mailmime;
|
|
||||||
if !report_data.is_null()
|
if !report_data.is_null()
|
||||||
&& (*(*(*report_data).mm_content_type).ct_type).tp_type
|
&& (*(*(*report_data).mm_content_type).ct_type).tp_type
|
||||||
== MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int
|
== MAILMIME_TYPE_COMPOSITE_TYPE as libc::c_int
|
||||||
@@ -800,25 +738,19 @@ pub unsafe fn dc_receive_imf(
|
|||||||
*const u8
|
*const u8
|
||||||
as
|
as
|
||||||
*const libc::c_char);
|
*const libc::c_char);
|
||||||
let of_org_msgid:
|
let of_org_msgid: *mut mailimf_optional_field =
|
||||||
*mut mailimf_optional_field =
|
mailimf_find_optional_field(
|
||||||
mailimf_find_optional_field(report_fields,
|
report_fields,
|
||||||
b"Original-Message-ID\x00"
|
b"Original-Message-ID\x00" as *const u8
|
||||||
as
|
as *const libc::c_char,
|
||||||
*const u8
|
);
|
||||||
as
|
|
||||||
*const libc::c_char);
|
|
||||||
if !of_disposition.is_null()
|
if !of_disposition.is_null()
|
||||||
&& !(*of_disposition)
|
&& !(*of_disposition).fld_value.is_null()
|
||||||
.fld_value
|
|
||||||
.is_null()
|
|
||||||
&& !of_org_msgid.is_null()
|
&& !of_org_msgid.is_null()
|
||||||
&& !(*of_org_msgid).fld_value.is_null()
|
&& !(*of_org_msgid).fld_value.is_null()
|
||||||
{
|
{
|
||||||
let mut rfc724_mid_0:
|
let mut rfc724_mid_0: *mut libc::c_char =
|
||||||
*mut libc::c_char =
|
0 as *mut libc::c_char;
|
||||||
0 as
|
|
||||||
*mut libc::c_char;
|
|
||||||
dummy = 0i32 as size_t;
|
dummy = 0i32 as size_t;
|
||||||
if mailimf_msg_id_parse(
|
if mailimf_msg_id_parse(
|
||||||
(*of_org_msgid).fld_value,
|
(*of_org_msgid).fld_value,
|
||||||
@@ -840,26 +772,14 @@ pub unsafe fn dc_receive_imf(
|
|||||||
&mut chat_id_0,
|
&mut chat_id_0,
|
||||||
&mut msg_id,
|
&mut msg_id,
|
||||||
) {
|
) {
|
||||||
carray_add(
|
rr_event_to_send
|
||||||
rr_event_to_send,
|
.push((chat_id_0, 0));
|
||||||
chat_id_0 as uintptr_t
|
rr_event_to_send.push((msg_id, 0));
|
||||||
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,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
mdn_consumed = (msg_id
|
mdn_consumed = (msg_id
|
||||||
!= 0i32 as libc::c_uint)
|
!= 0i32 as libc::c_uint)
|
||||||
as libc::c_int;
|
as libc::c_int;
|
||||||
free(
|
free(rfc724_mid_0 as *mut libc::c_void);
|
||||||
rfc724_mid_0
|
|
||||||
as *mut libc::c_void,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -879,8 +799,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
&& 0 != dc_sqlite3_get_config_int(
|
&& 0 != dc_sqlite3_get_config_int(
|
||||||
context,
|
context,
|
||||||
&context.sql,
|
&context.sql,
|
||||||
b"mvbox_move\x00" as *const u8
|
b"mvbox_move\x00" as *const u8 as *const libc::c_char,
|
||||||
as *const libc::c_char,
|
|
||||||
1i32,
|
1i32,
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@@ -922,8 +841,7 @@ pub unsafe fn dc_receive_imf(
|
|||||||
if !(*mime_parser.location_kml).addr.is_null()
|
if !(*mime_parser.location_kml).addr.is_null()
|
||||||
&& !contact.is_null()
|
&& !contact.is_null()
|
||||||
&& !(*contact).addr.is_null()
|
&& !(*contact).addr.is_null()
|
||||||
&& strcasecmp((*contact).addr, (*mime_parser.location_kml).addr)
|
&& strcasecmp((*contact).addr, (*mime_parser.location_kml).addr) == 0i32
|
||||||
== 0i32
|
|
||||||
{
|
{
|
||||||
let newest_location_id = dc_save_locations(
|
let newest_location_id = dc_save_locations(
|
||||||
context,
|
context,
|
||||||
@@ -933,75 +851,44 @@ pub unsafe fn dc_receive_imf(
|
|||||||
0,
|
0,
|
||||||
);
|
);
|
||||||
if newest_location_id != 0 && hidden == 0 && !location_id_written {
|
if newest_location_id != 0 && hidden == 0 && !location_id_written {
|
||||||
dc_set_msg_location_id(
|
dc_set_msg_location_id(context, insert_msg_id, newest_location_id);
|
||||||
context,
|
|
||||||
insert_msg_id,
|
|
||||||
newest_location_id,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
send_event = true;
|
send_event = true;
|
||||||
}
|
}
|
||||||
dc_contact_unref(contact);
|
dc_contact_unref(contact);
|
||||||
}
|
}
|
||||||
if send_event {
|
if send_event {
|
||||||
context.call_cb(
|
context.call_cb(Event::LOCATION_CHANGED, from_id as uintptr_t, 0);
|
||||||
Event::LOCATION_CHANGED,
|
|
||||||
from_id as uintptr_t,
|
|
||||||
0i32 as uintptr_t,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if 0 != add_delete_job
|
if 0 != add_delete_job && created_db_entries.len() > 0 {
|
||||||
&& carray_count(created_db_entries) >= 2i32 as libc::c_uint
|
|
||||||
{
|
|
||||||
dc_job_add(
|
dc_job_add(
|
||||||
context,
|
context,
|
||||||
110i32,
|
DC_JOB_DELETE_MSG_ON_IMAP,
|
||||||
carray_get(created_db_entries, 1i32 as libc::c_uint) as uintptr_t
|
created_db_entries[0].1 as i32,
|
||||||
as libc::c_int,
|
|
||||||
0 as *const libc::c_char,
|
0 as *const libc::c_char,
|
||||||
0i32,
|
0,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
free(rfc724_mid as *mut libc::c_void);
|
free(rfc724_mid as *mut libc::c_void);
|
||||||
free(mime_in_reply_to as *mut libc::c_void);
|
free(mime_in_reply_to as *mut libc::c_void);
|
||||||
free(mime_references as *mut libc::c_void);
|
free(mime_references as *mut libc::c_void);
|
||||||
dc_array_unref(to_ids);
|
dc_array_unref(to_ids);
|
||||||
if !created_db_entries.is_null() {
|
|
||||||
if let Some(create_event_to_send) = create_event_to_send {
|
if let Some(create_event_to_send) = create_event_to_send {
|
||||||
let mut i_0: size_t = 0;
|
for entry in &created_db_entries {
|
||||||
let icnt_0: size_t = carray_count(created_db_entries) as size_t;
|
let (msg_id, insert_id) = entry;
|
||||||
while i_0 < icnt_0 {
|
context.call_cb(create_event_to_send, *msg_id, *insert_id);
|
||||||
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(2i32 as libc::c_ulong) as size_t as size_t
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
carray_free(created_db_entries);
|
for ev in &rr_event_to_send {
|
||||||
}
|
let (chat_id, msg_id) = ev;
|
||||||
if !rr_event_to_send.is_null() {
|
context.call_cb(Event::MSG_READ, *chat_id as uintptr_t, *msg_id as uintptr_t);
|
||||||
let mut i_1: size_t;
|
|
||||||
let icnt_1: size_t = carray_count(rr_event_to_send) as size_t;
|
|
||||||
i_1 = 0i32 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(2i32 as libc::c_ulong) as size_t as size_t
|
|
||||||
}
|
|
||||||
carray_free(rr_event_to_send);
|
|
||||||
}
|
}
|
||||||
free(txt_raw as *mut libc::c_void);
|
free(txt_raw as *mut libc::c_void);
|
||||||
sqlite3_finalize(stmt);
|
sqlite3_finalize(stmt);
|
||||||
@@ -1113,10 +1000,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
grpid = dc_strdup((*optional_field).fld_value)
|
grpid = dc_strdup((*optional_field).fld_value)
|
||||||
}
|
}
|
||||||
if grpid.is_null() {
|
if grpid.is_null() {
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "Message-ID");
|
||||||
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 {
|
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;
|
let fld_message_id: *mut mailimf_message_id = (*field).fld_data.fld_message_id;
|
||||||
if !fld_message_id.is_null() {
|
if !fld_message_id.is_null() {
|
||||||
@@ -1124,10 +1008,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if grpid.is_null() {
|
if grpid.is_null() {
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||||
mime_parser,
|
|
||||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
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;
|
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||||
if !fld_in_reply_to.is_null() {
|
if !fld_in_reply_to.is_null() {
|
||||||
@@ -1135,10 +1016,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if grpid.is_null() {
|
if grpid.is_null() {
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||||
mime_parser,
|
|
||||||
b"References\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int
|
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;
|
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||||
@@ -1304,12 +1182,7 @@ unsafe fn create_or_lookup_group(
|
|||||||
/*otherwise, a pending "quit" message may pop up*/
|
/*otherwise, a pending "quit" message may pop up*/
|
||||||
/*re-create explicitly left groups only if ourself is re-added*/
|
/*re-create explicitly left groups only if ourself is re-added*/
|
||||||
let mut create_verified: libc::c_int = 0i32;
|
let mut create_verified: libc::c_int = 0i32;
|
||||||
if !dc_mimeparser_lookup_field(
|
if !dc_mimeparser_lookup_field(mime_parser, "Chat-Verified").is_null() {
|
||||||
mime_parser,
|
|
||||||
b"Chat-Verified\x00" as *const u8 as *const libc::c_char,
|
|
||||||
)
|
|
||||||
.is_null()
|
|
||||||
{
|
|
||||||
create_verified = 1i32;
|
create_verified = 1i32;
|
||||||
if 0 == check_verified_properties(
|
if 0 == check_verified_properties(
|
||||||
context,
|
context,
|
||||||
@@ -1969,10 +1842,7 @@ unsafe fn dc_is_reply_to_known_message(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut field: *mut mailimf_field;
|
let mut field: *mut mailimf_field;
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||||
mime_parser,
|
|
||||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
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;
|
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||||
if !fld_in_reply_to.is_null() {
|
if !fld_in_reply_to.is_null() {
|
||||||
@@ -1984,10 +1854,7 @@ unsafe fn dc_is_reply_to_known_message(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||||
mime_parser,
|
|
||||||
b"References\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
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;
|
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||||
if !fld_references.is_null() {
|
if !fld_references.is_null() {
|
||||||
@@ -2053,10 +1920,7 @@ unsafe fn dc_is_reply_to_messenger_message(
|
|||||||
- it is okay, if the referenced messages are moved to trash here
|
- 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) */
|
- no check for the Chat-* headers (function is only called if it is no messenger message itself) */
|
||||||
let mut field: *mut mailimf_field;
|
let mut field: *mut mailimf_field;
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "In-Reply-To");
|
||||||
mime_parser,
|
|
||||||
b"In-Reply-To\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_IN_REPLY_TO as libc::c_int {
|
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;
|
let fld_in_reply_to: *mut mailimf_in_reply_to = (*field).fld_data.fld_in_reply_to;
|
||||||
if !fld_in_reply_to.is_null() {
|
if !fld_in_reply_to.is_null() {
|
||||||
@@ -2068,10 +1932,7 @@ unsafe fn dc_is_reply_to_messenger_message(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
field = dc_mimeparser_lookup_field(
|
field = dc_mimeparser_lookup_field(mime_parser, "References");
|
||||||
mime_parser,
|
|
||||||
b"References\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !field.is_null() && (*field).fld_type == MAILIMF_FIELD_REFERENCES as libc::c_int {
|
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;
|
let fld_references: *mut mailimf_references = (*field).fld_data.fld_references;
|
||||||
if !fld_references.is_null() {
|
if !fld_references.is_null() {
|
||||||
|
|||||||
@@ -401,10 +401,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
let mut ret: libc::c_int = 0i32;
|
let mut ret: libc::c_int = 0i32;
|
||||||
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
|
let mut contact: *mut dc_contact_t = 0 as *mut dc_contact_t;
|
||||||
if !(contact_id <= 9i32 as libc::c_uint) {
|
if !(contact_id <= 9i32 as libc::c_uint) {
|
||||||
step = lookup_field(
|
step = lookup_field(mimeparser, "Secure-Join");
|
||||||
mimeparser,
|
|
||||||
b"Secure-Join\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if !step.is_null() {
|
if !step.is_null() {
|
||||||
dc_log_info(
|
dc_log_info(
|
||||||
context,
|
context,
|
||||||
@@ -438,32 +435,15 @@ 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.
|
// 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
|
// verify that the `Secure-Join-Invitenumber:`-header matches invitenumber written to the QR code
|
||||||
let invitenumber: *const libc::c_char;
|
let invitenumber: *const libc::c_char;
|
||||||
invitenumber = lookup_field(
|
invitenumber = lookup_field(mimeparser, "Secure-Join-Invitenumber");
|
||||||
mimeparser,
|
|
||||||
b"Secure-Join-Invitenumber\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if invitenumber.is_null() {
|
if invitenumber.is_null() {
|
||||||
dc_log_warning(
|
warn!(context, 0, "Secure-join denied (invitenumber missing).",);
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"Secure-join denied (invitenumber missing).\x00" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
|
||||||
current_block = 4378276786830486580;
|
current_block = 4378276786830486580;
|
||||||
} else if dc_token_exists(context, DC_TOKEN_INVITENUMBER, invitenumber) == 0i32 {
|
} else if dc_token_exists(context, DC_TOKEN_INVITENUMBER, invitenumber) == 0i32 {
|
||||||
dc_log_warning(
|
warn!(context, 0, "Secure-join denied (bad invitenumber).",);
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"Secure-join denied (bad invitenumber).\x00" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
);
|
|
||||||
current_block = 4378276786830486580;
|
current_block = 4378276786830486580;
|
||||||
} else {
|
} else {
|
||||||
dc_log_info(
|
info!(context, 0, "Secure-join requested.",);
|
||||||
context,
|
|
||||||
0i32,
|
|
||||||
b"Secure-join requested.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
context.call_cb(
|
context.call_cb(
|
||||||
Event::SECUREJOIN_INVITER_PROGRESS,
|
Event::SECUREJOIN_INVITER_PROGRESS,
|
||||||
contact_id as uintptr_t,
|
contact_id as uintptr_t,
|
||||||
@@ -589,10 +569,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
============================================================ */
|
============================================================ */
|
||||||
// verify that Secure-Join-Fingerprint:-header matches the fingerprint of Bob
|
// verify that Secure-Join-Fingerprint:-header matches the fingerprint of Bob
|
||||||
let fingerprint: *const libc::c_char;
|
let fingerprint: *const libc::c_char;
|
||||||
fingerprint = lookup_field(
|
fingerprint = lookup_field(mimeparser, "Secure-Join-Fingerprint");
|
||||||
mimeparser,
|
|
||||||
b"Secure-Join-Fingerprint\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if fingerprint.is_null() {
|
if fingerprint.is_null() {
|
||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
@@ -623,10 +600,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
);
|
);
|
||||||
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
|
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
|
||||||
let auth_0: *const libc::c_char;
|
let auth_0: *const libc::c_char;
|
||||||
auth_0 = lookup_field(
|
auth_0 = lookup_field(mimeparser, "Secure-Join-Auth");
|
||||||
mimeparser,
|
|
||||||
b"Secure-Join-Auth\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
if auth_0.is_null() {
|
if auth_0.is_null() {
|
||||||
could_not_establish_secure_connection(
|
could_not_establish_secure_connection(
|
||||||
context,
|
context,
|
||||||
@@ -668,10 +642,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
600i32 as uintptr_t,
|
600i32 as uintptr_t,
|
||||||
);
|
);
|
||||||
if 0 != join_vg {
|
if 0 != join_vg {
|
||||||
grpid = dc_strdup(lookup_field(
|
grpid = dc_strdup(lookup_field(mimeparser, "Secure-Join-Group"));
|
||||||
mimeparser,
|
|
||||||
b"Secure-Join-Group\x00" as *const u8 as *const libc::c_char,
|
|
||||||
));
|
|
||||||
let group_chat_id: uint32_t = dc_get_chat_id_by_grpid(
|
let group_chat_id: uint32_t = dc_get_chat_id_by_grpid(
|
||||||
context,
|
context,
|
||||||
grpid,
|
grpid,
|
||||||
@@ -805,11 +776,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
|
|||||||
if 0 != join_vg {
|
if 0 != join_vg {
|
||||||
if 0 == dc_addr_equals_self(
|
if 0 == dc_addr_equals_self(
|
||||||
context,
|
context,
|
||||||
lookup_field(
|
lookup_field(mimeparser, "Chat-Group-Member-Added"),
|
||||||
mimeparser,
|
|
||||||
b"Chat-Group-Member-Added\x00" as *const u8
|
|
||||||
as *const libc::c_char,
|
|
||||||
),
|
|
||||||
) {
|
) {
|
||||||
dc_log_info(context, 0i32,
|
dc_log_info(context, 0i32,
|
||||||
b"Message belongs to a different handshake (scaled up contact anyway to allow creation of group).\x00"
|
b"Message belongs to a different handshake (scaled up contact anyway to allow creation of group).\x00"
|
||||||
@@ -927,10 +894,7 @@ unsafe fn secure_connection_established(context: &Context, contact_chat_id: uint
|
|||||||
dc_contact_unref(contact);
|
dc_contact_unref(contact);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn lookup_field(
|
unsafe fn lookup_field(mimeparser: &dc_mimeparser_t, key: &str) -> *const libc::c_char {
|
||||||
mimeparser: &dc_mimeparser_t,
|
|
||||||
key: *const libc::c_char,
|
|
||||||
) -> *const libc::c_char {
|
|
||||||
let mut value: *const libc::c_char = 0 as *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);
|
let field: *mut mailimf_field = dc_mimeparser_lookup_field(mimeparser, key);
|
||||||
if field.is_null()
|
if field.is_null()
|
||||||
|
|||||||
Reference in New Issue
Block a user