mirror of
https://github.com/chatmail/core.git
synced 2026-05-07 08:56:30 +03:00
e2ee_guaranteed -> bool, rustify set_error
This commit is contained in:
@@ -330,7 +330,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
let mut col: libc::c_int = 0;
|
let mut col: libc::c_int = 0;
|
||||||
let mut success = false;
|
let mut success = false;
|
||||||
let mut parts: libc::c_int = 0;
|
let mut parts: libc::c_int = 0;
|
||||||
let mut e2ee_guaranteed: libc::c_int = 0;
|
let mut e2ee_guaranteed = false;
|
||||||
let mut min_verified: libc::c_int = 0;
|
let mut min_verified: libc::c_int = 0;
|
||||||
// 1=add Autocrypt-header (needed eg. for handshaking), 2=no Autocrypte-header (used for MDN)
|
// 1=add Autocrypt-header (needed eg. for handshaking), 2=no Autocrypte-header (used for MDN)
|
||||||
let mut force_plaintext: libc::c_int = 0;
|
let mut force_plaintext: libc::c_int = 0;
|
||||||
@@ -340,10 +340,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
|
|
||||||
if factory.loaded == Loaded::Nothing || !factory.out.is_null() {
|
if factory.loaded == Loaded::Nothing || !factory.out.is_null() {
|
||||||
/*call empty() before*/
|
/*call empty() before*/
|
||||||
set_error(
|
set_error(factory, "Invalid use of mimefactory-object.");
|
||||||
factory,
|
|
||||||
b"Invalid use of mimefactory-object.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
let from: *mut mailimf_mailbox_list = mailimf_mailbox_list_new_empty();
|
let from: *mut mailimf_mailbox_list = mailimf_mailbox_list_new_empty();
|
||||||
mailimf_mailbox_list_add(
|
mailimf_mailbox_list_add(
|
||||||
@@ -484,7 +481,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
force_plaintext = 0;
|
force_plaintext = 0;
|
||||||
e2ee_guaranteed = 1;
|
e2ee_guaranteed = true;
|
||||||
min_verified = 2
|
min_verified = 2
|
||||||
} else {
|
} else {
|
||||||
force_plaintext = factory
|
force_plaintext = factory
|
||||||
@@ -498,6 +495,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
.param
|
.param
|
||||||
.get_int(Param::GuranteeE2ee)
|
.get_int(Param::GuranteeE2ee)
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
|
!= 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if chat.gossiped_timestamp == 0
|
if chat.gossiped_timestamp == 0
|
||||||
@@ -808,10 +806,8 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
let error = format!(
|
let error = format!(
|
||||||
"Message exceeds the recommended {} MB.",
|
"Message exceeds the recommended {} MB.",
|
||||||
24 * 1024 * 1024 / 4 * 3 / 1000 / 1000,
|
24 * 1024 * 1024 / 4 * 3 / 1000 / 1000,
|
||||||
)
|
);
|
||||||
.strdup();
|
set_error(factory, &error);
|
||||||
set_error(factory, error);
|
|
||||||
free(error.cast());
|
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
let file_part: *mut mailmime =
|
let file_part: *mut mailmime =
|
||||||
@@ -824,10 +820,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
}
|
}
|
||||||
if ok_to_continue {
|
if ok_to_continue {
|
||||||
if parts == 0 {
|
if parts == 0 {
|
||||||
set_error(
|
set_error(factory, "Empty message.");
|
||||||
factory,
|
|
||||||
b"Empty message.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
} else {
|
} else {
|
||||||
if !meta_part.is_null() {
|
if !meta_part.is_null() {
|
||||||
@@ -944,10 +937,7 @@ pub unsafe fn dc_mimefactory_render(context: &Context, factory: &mut MimeFactory
|
|||||||
mailmime_add_part(multipart, mach_mime_part);
|
mailmime_add_part(multipart, mach_mime_part);
|
||||||
force_plaintext = 2;
|
force_plaintext = 2;
|
||||||
} else {
|
} else {
|
||||||
set_error(
|
set_error(factory, "No message loaded.");
|
||||||
factory,
|
|
||||||
b"No message loaded.\x00" as *const u8 as *const libc::c_char,
|
|
||||||
);
|
|
||||||
ok_to_continue = false;
|
ok_to_continue = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1054,12 +1044,12 @@ unsafe fn get_subject(
|
|||||||
ret
|
ret
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn set_error(factory: *mut MimeFactory, text: *const libc::c_char) {
|
unsafe fn set_error(factory: *mut MimeFactory, text: &str) {
|
||||||
if factory.is_null() {
|
if factory.is_null() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
free((*factory).error as *mut libc::c_void);
|
free((*factory).error as *mut libc::c_void);
|
||||||
(*factory).error = dc_strdup_keep_null(text);
|
(*factory).error = text.strdup();
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn build_body_text(text: *mut libc::c_char) -> *mut mailmime {
|
unsafe fn build_body_text(text: *mut libc::c_char) -> *mut mailmime {
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ impl E2eeHelper {
|
|||||||
context: &Context,
|
context: &Context,
|
||||||
recipients_addr: *const clist,
|
recipients_addr: *const clist,
|
||||||
force_unencrypted: libc::c_int,
|
force_unencrypted: libc::c_int,
|
||||||
e2ee_guaranteed: libc::c_int,
|
e2ee_guaranteed: bool,
|
||||||
min_verified: libc::c_int,
|
min_verified: libc::c_int,
|
||||||
do_gossip: libc::c_int,
|
do_gossip: libc::c_int,
|
||||||
mut in_out_message: *mut mailmime,
|
mut in_out_message: *mut mailmime,
|
||||||
@@ -95,7 +95,7 @@ impl E2eeHelper {
|
|||||||
});
|
});
|
||||||
if let Ok(public_key) = pubkey_ret {
|
if let Ok(public_key) = pubkey_ret {
|
||||||
/*only for random-seed*/
|
/*only for random-seed*/
|
||||||
if prefer_encrypt == EncryptPreference::Mutual || 0 != e2ee_guaranteed {
|
if prefer_encrypt == EncryptPreference::Mutual || e2ee_guaranteed {
|
||||||
do_encrypt = 1i32;
|
do_encrypt = 1i32;
|
||||||
let mut iter1: *mut clistiter;
|
let mut iter1: *mut clistiter;
|
||||||
iter1 = (*recipients_addr).first;
|
iter1 = (*recipients_addr).first;
|
||||||
@@ -107,7 +107,7 @@ impl E2eeHelper {
|
|||||||
if peerstate.is_some()
|
if peerstate.is_some()
|
||||||
&& (peerstate.as_ref().unwrap().prefer_encrypt
|
&& (peerstate.as_ref().unwrap().prefer_encrypt
|
||||||
== EncryptPreference::Mutual
|
== EncryptPreference::Mutual
|
||||||
|| 0 != e2ee_guaranteed)
|
|| e2ee_guaranteed)
|
||||||
{
|
{
|
||||||
let peerstate = peerstate.unwrap();
|
let peerstate = peerstate.unwrap();
|
||||||
info!(
|
info!(
|
||||||
|
|||||||
Reference in New Issue
Block a user