mirror of
https://github.com/chatmail/core.git
synced 2026-05-03 05:16:28 +03:00
remove/push down some unsafe-fn
This commit is contained in:
@@ -35,7 +35,6 @@ fn cb(_ctx: &Context, event: Event) -> usize {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
unsafe {
|
|
||||||
let dir = tempdir().unwrap();
|
let dir = tempdir().unwrap();
|
||||||
let dbfile = dir.path().join("db.sqlite");
|
let dbfile = dir.path().join("db.sqlite");
|
||||||
println!("creating database {:?}", dbfile);
|
println!("creating database {:?}", dbfile);
|
||||||
@@ -85,8 +84,7 @@ fn main() {
|
|||||||
thread::sleep(duration);
|
thread::sleep(duration);
|
||||||
|
|
||||||
println!("sending a message");
|
println!("sending a message");
|
||||||
let contact_id =
|
let contact_id = Contact::create(&ctx, "dignifiedquire", "dignifiedquire@gmail.com").unwrap();
|
||||||
Contact::create(&ctx, "dignifiedquire", "dignifiedquire@gmail.com").unwrap();
|
|
||||||
let chat_id = chat::create_by_contact_id(&ctx, contact_id).unwrap();
|
let chat_id = chat::create_by_contact_id(&ctx, contact_id).unwrap();
|
||||||
chat::send_text_msg(&ctx, chat_id, "Hi, here is my first message!".into()).unwrap();
|
chat::send_text_msg(&ctx, chat_id, "Hi, here is my first message!".into()).unwrap();
|
||||||
|
|
||||||
@@ -124,4 +122,3 @@ fn main() {
|
|||||||
|
|
||||||
println!("closing");
|
println!("closing");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ macro_rules! progress {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// connect
|
// connect
|
||||||
pub unsafe fn configure(context: &Context) {
|
pub fn configure(context: &Context) {
|
||||||
if context.has_ongoing() {
|
if context.has_ongoing() {
|
||||||
warn!(context, "There is already another ongoing process running.",);
|
warn!(context, "There is already another ongoing process running.",);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ pub fn try_decrypt(
|
|||||||
in_out_message: *mut Mailmime,
|
in_out_message: *mut Mailmime,
|
||||||
) -> Result<(bool, HashSet<String>, HashSet<String>)> {
|
) -> Result<(bool, HashSet<String>, HashSet<String>)> {
|
||||||
// just a pointer into mailmime structure, must not be freed
|
// just a pointer into mailmime structure, must not be freed
|
||||||
let imffields = unsafe { mailmime_find_mailimf_fields(in_out_message) };
|
let imffields = mailmime_find_mailimf_fields(in_out_message);
|
||||||
ensure!(
|
ensure!(
|
||||||
!in_out_message.is_null() && !imffields.is_null(),
|
!in_out_message.is_null() && !imffields.is_null(),
|
||||||
"corrupt invalid mime inputs"
|
"corrupt invalid mime inputs"
|
||||||
|
|||||||
@@ -175,21 +175,21 @@ pub fn mailimf_find_field(
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*the result is a pointer to mime, must not be freed*/
|
/*the result is a pointer to mime, must not be freed*/
|
||||||
pub unsafe fn mailmime_find_mailimf_fields(mime: *mut Mailmime) -> *mut mailimf_fields {
|
pub fn mailmime_find_mailimf_fields(mime: *mut Mailmime) -> *mut mailimf_fields {
|
||||||
if mime.is_null() {
|
if mime.is_null() {
|
||||||
return ptr::null_mut();
|
return ptr::null_mut();
|
||||||
}
|
}
|
||||||
|
|
||||||
match (*mime).mm_type as _ {
|
match unsafe { (*mime).mm_type as _ } {
|
||||||
MAILMIME_MULTIPLE => {
|
MAILMIME_MULTIPLE => {
|
||||||
for cur_data in (*(*mime).mm_data.mm_multipart.mm_mp_list).into_iter() {
|
for cur_data in unsafe { (*(*mime).mm_data.mm_multipart.mm_mp_list).into_iter() } {
|
||||||
let header = mailmime_find_mailimf_fields(cur_data as *mut _);
|
let header = mailmime_find_mailimf_fields(cur_data as *mut _);
|
||||||
if !header.is_null() {
|
if !header.is_null() {
|
||||||
return header;
|
return header;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MAILMIME_MESSAGE => return (*mime).mm_data.mm_message.mm_fields,
|
MAILMIME_MESSAGE => return unsafe { (*mime).mm_data.mm_message.mm_fields },
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user