No more vararg printing (drop dc_log_)

This commit is contained in:
dignifiedquire
2019-07-11 22:09:58 +02:00
parent b6392ee582
commit ecbd6fb154
20 changed files with 273 additions and 662 deletions

View File

@@ -1 +1 @@
nightly-2019-07-03 nightly-2019-07-10

View File

@@ -6,7 +6,6 @@ use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_jobthread::*; use crate::dc_jobthread::*;
use crate::dc_log::*;
use crate::dc_loginparam::*; use crate::dc_loginparam::*;
use crate::dc_lot::dc_lot_t; use crate::dc_lot::dc_lot_t;
use crate::dc_move::*; use crate::dc_move::*;
@@ -265,19 +264,19 @@ unsafe fn cb_precheck_imf(
if *old_server_folder.offset(0isize) as libc::c_int == 0i32 if *old_server_folder.offset(0isize) as libc::c_int == 0i32
&& old_server_uid == 0i32 as libc::c_uint && old_server_uid == 0i32 as libc::c_uint
{ {
dc_log_info( info!(
context, context,
0i32, 0,
b"[move] detected bbc-self %s\x00" as *const u8 as *const libc::c_char, "[move] detected bbc-self {}",
rfc724_mid, as_str(rfc724_mid),
); );
mark_seen = 1i32 mark_seen = 1i32
} else if as_str(old_server_folder) != server_folder { } else if as_str(old_server_folder) != server_folder {
dc_log_info( info!(
context, context,
0i32, 0,
b"[move] detected moved message %s\x00" as *const u8 as *const libc::c_char, "[move] detected moved message {}",
rfc724_mid, as_str(rfc724_mid),
); );
dc_update_msg_move_state(context, rfc724_mid, DC_MOVE_STATE_STAY); dc_update_msg_move_state(context, rfc724_mid, DC_MOVE_STATE_STAY);
} }

View File

@@ -4,7 +4,6 @@ use crate::dc_array::*;
use crate::dc_chatlist::*; use crate::dc_chatlist::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*; use crate::dc_msg::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_sqlite3::*; use crate::dc_sqlite3::*;
@@ -192,12 +191,9 @@ pub unsafe fn dc_create_chat_by_contact_id(context: &Context, contact_id: uint32
send_event = 1i32 send_event = 1i32
} }
} else if !dc_real_contact_exists(context, contact_id) && contact_id != 1i32 as libc::c_uint { } else if !dc_real_contact_exists(context, contact_id) && contact_id != 1i32 as libc::c_uint {
dc_log_warning( warn!(
context, context,
0i32, 0, "Cannot create chat, contact {} does not exist.", contact_id as libc::c_int,
b"Cannot create chat, contact %i does not exist.\x00" as *const u8
as *const libc::c_char,
contact_id as libc::c_int,
); );
} else { } else {
dc_create_or_lookup_nchat_by_contact_id( dc_create_or_lookup_nchat_by_contact_id(
@@ -377,21 +373,15 @@ unsafe fn prepare_msg_common<'a>(
{ {
pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char); pathNfilename = dc_param_get((*msg).param, 'f' as i32, 0 as *const libc::c_char);
if pathNfilename.is_null() { if pathNfilename.is_null() {
dc_log_error( error!(
context, context,
0i32, 0,
b"Attachment missing for message of type #%i.\x00" as *const u8 "Attachment missing for message of type #{}.",
as *const libc::c_char,
(*msg).type_0 as libc::c_int, (*msg).type_0 as libc::c_int,
); );
current_block = 2171833246886114521; current_block = 2171833246886114521;
} else if (*msg).state == 18i32 && 0 == dc_is_blobdir_path(context, pathNfilename) { } else if (*msg).state == 18i32 && 0 == dc_is_blobdir_path(context, pathNfilename) {
dc_log_error( error!(context, 0, "Files must be created in the blob-directory.",);
context,
0i32,
b"Files must be created in the blob-directory.\x00" as *const u8
as *const libc::c_char,
);
current_block = 2171833246886114521; current_block = 2171833246886114521;
} else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) { } else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) {
current_block = 2171833246886114521; current_block = 2171833246886114521;
@@ -416,20 +406,20 @@ unsafe fn prepare_msg_common<'a>(
dc_param_set((*msg).param, 'm' as i32, better_mime_0); dc_param_set((*msg).param, 'm' as i32, better_mime_0);
free(better_mime_0 as *mut libc::c_void); free(better_mime_0 as *mut libc::c_void);
} }
dc_log_info( info!(
context, context,
0i32, 0,
b"Attaching \"%s\" for message type #%i.\x00" as *const u8 as *const libc::c_char, "Attaching \"{}\" for message type #{}.",
pathNfilename, as_str(pathNfilename),
(*msg).type_0 as libc::c_int, (*msg).type_0 as libc::c_int,
); );
current_block = 17281240262373992796; current_block = 17281240262373992796;
} }
} else { } else {
dc_log_error( error!(
context, context,
0i32, 0,
b"Cannot send messages of type #%i.\x00" as *const u8 as *const libc::c_char, "Cannot send messages of type #{}.",
(*msg).type_0 as libc::c_int, (*msg).type_0 as libc::c_int,
); );
current_block = 2171833246886114521; current_block = 2171833246886114521;
@@ -476,29 +466,20 @@ unsafe fn prepare_msg_raw(
let mut location_id = 0; let mut location_id = 0;
if !((*chat).type_0 == 100 || (*chat).type_0 == 120 || (*chat).type_0 == 130) { if !((*chat).type_0 == 100 || (*chat).type_0 == 120 || (*chat).type_0 == 130) {
dc_log_error( error!(context, 0, "Cannot send to chat type #{}.", (*chat).type_0,);
context,
0,
b"Cannot send to chat type #%i.\x00" as *const u8 as *const libc::c_char,
(*chat).type_0,
);
} else if ((*chat).type_0 == 120 || (*chat).type_0 == 130) } else if ((*chat).type_0 == 120 || (*chat).type_0 == 130)
&& 0 == dc_is_contact_in_chat(context, (*chat).id, 1 as uint32_t) && 0 == dc_is_contact_in_chat(context, (*chat).id, 1 as uint32_t)
{ {
dc_log_event( log_event!(
context, context,
Event::ERROR_SELF_NOT_IN_GROUP, Event::ERROR_SELF_NOT_IN_GROUP,
0, 0,
b"Cannot send message; self not in group.\x00" as *const u8 as *const libc::c_char, "Cannot send message; self not in group.",
); );
} else { } else {
let from = dc_sqlite3_get_config(context, &context.sql, "configured_addr", None); let from = dc_sqlite3_get_config(context, &context.sql, "configured_addr", None);
if from.is_none() { if from.is_none() {
dc_log_error( error!(context, 0, "Cannot send message, not configured.",);
context,
0,
b"Cannot send message, not configured.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
let from_c = to_cstring(from.unwrap()); let from_c = to_cstring(from.unwrap());
new_rfc724_mid = dc_create_outgoing_rfc724_mid( new_rfc724_mid = dc_create_outgoing_rfc724_mid(
@@ -521,11 +502,10 @@ unsafe fn prepare_msg_raw(
to_id = id; to_id = id;
current_block = 5689316957504528238; current_block = 5689316957504528238;
} else { } else {
dc_log_error( error!(
context, context,
0, 0,
b"Cannot send message, contact for chat #%i not found.\x00" as *const u8 "Cannot send message, contact for chat #{} not found.",
as *const libc::c_char,
(*chat).id, (*chat).id,
); );
current_block = 10477488590406205504; current_block = 10477488590406205504;
@@ -1514,12 +1494,11 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|| !dc_chat_load_from_db(chat, chat_id)) || !dc_chat_load_from_db(chat, chat_id))
{ {
if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) { if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) {
dc_log_event( log_event!(
context, context,
Event::ERROR_SELF_NOT_IN_GROUP, Event::ERROR_SELF_NOT_IN_GROUP,
0, 0,
b"Cannot add contact to group; self not in group.\x00" as *const u8 "Cannot add contact to group; self not in group.",
as *const libc::c_char,
); );
} else { } else {
/* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
@@ -1545,10 +1524,9 @@ pub unsafe fn dc_add_contact_to_chat_ex(
// else continue and send status mail // else continue and send status mail
if (*chat).type_0 == 130 { if (*chat).type_0 == 130 {
if dc_contact_is_verified(contact) != 2 { if dc_contact_is_verified(contact) != 2 {
dc_log_error( error!(
context, 0, context, 0,
b"Only bidirectional verified contacts can be added to verified groups.\x00" "Only bidirectional verified contacts can be added to verified groups."
as *const u8 as *const libc::c_char
); );
current_block = 12326129973959287090; current_block = 12326129973959287090;
} else { } else {
@@ -1674,12 +1652,11 @@ pub unsafe fn dc_remove_contact_from_chat(
/* this allows to delete pending references to deleted contacts. Of course, this should _not_ happen. */ /* this allows to delete pending references to deleted contacts. Of course, this should _not_ happen. */
if !(0 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) { if !(0 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) { if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) {
dc_log_event( log_event!(
context, context,
Event::ERROR_SELF_NOT_IN_GROUP, Event::ERROR_SELF_NOT_IN_GROUP,
0, 0,
b"Cannot remove contact from chat; self not in group.\x00" as *const u8 "Cannot remove contact from chat; self not in group.",
as *const libc::c_char,
); );
} else { } else {
/* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
@@ -1774,12 +1751,11 @@ pub unsafe fn dc_set_chat_name(
if strcmp((*chat).name, new_name) == 0i32 { if strcmp((*chat).name, new_name) == 0i32 {
success = 1i32 success = 1i32
} else if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) { } else if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
dc_log_event( log_event!(
context, context,
Event::ERROR_SELF_NOT_IN_GROUP, Event::ERROR_SELF_NOT_IN_GROUP,
0i32, 0,
b"Cannot set chat name; self not in group\x00" as *const u8 "Cannot set chat name; self not in group",
as *const libc::c_char,
); );
} else { } else {
/* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
@@ -1838,12 +1814,11 @@ pub unsafe fn dc_set_chat_profile_image(
if !(chat_id <= 9i32 as libc::c_uint) { if !(chat_id <= 9i32 as libc::c_uint) {
if !(0i32 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) { if !(0i32 == real_group_exists(context, chat_id) || !dc_chat_load_from_db(chat, chat_id)) {
if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) { if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
dc_log_event( log_event!(
context, context,
Event::ERROR_SELF_NOT_IN_GROUP, Event::ERROR_SELF_NOT_IN_GROUP,
0i32, 0,
b"Cannot set chat profile image; self not in group.\x00" as *const u8 "Cannot set chat profile image; self not in group.",
as *const libc::c_char,
); );
} else { } else {
/* we shoud respect this - whatever we send to the group, it gets discarded anyway! */ /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */

View File

@@ -4,7 +4,6 @@ use crate::constants::Event;
use crate::context::Context; use crate::context::Context;
use crate::dc_e2ee::*; use crate::dc_e2ee::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_loginparam::*; use crate::dc_loginparam::*;
use crate::dc_saxparser::*; use crate::dc_saxparser::*;
use crate::dc_sqlite3::*; use crate::dc_sqlite3::*;
@@ -56,11 +55,9 @@ pub struct outlk_autodiscover_t<'a> {
// connect // connect
pub unsafe fn dc_configure(context: &Context) { pub unsafe fn dc_configure(context: &Context) {
if 0 != dc_has_ongoing(context) { if 0 != dc_has_ongoing(context) {
dc_log_warning( warn!(
context, context,
0i32, 0, "There is already another ongoing process running.",
b"There is already another ongoing process running.\x00" as *const u8
as *const libc::c_char,
); );
return; return;
} }
@@ -110,11 +107,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
if !(0 == dc_alloc_ongoing(context)) { if !(0 == dc_alloc_ongoing(context)) {
ongoing_allocated_here = 1i32; ongoing_allocated_here = 1i32;
if !context.sql.is_open() { if !context.sql.is_open() {
dc_log_error( error!(context, 0, "Cannot configure, database not opened.",);
context,
0i32,
b"Cannot configure, database not opened.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
context.inbox.read().unwrap().disconnect(context); context.inbox.read().unwrap().disconnect(context);
context context
@@ -130,11 +123,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
.imap .imap
.disconnect(context); .disconnect(context);
context.smtp.clone().lock().unwrap().disconnect(); context.smtp.clone().lock().unwrap().disconnect();
dc_log_info( info!(context, 0, "Configure ...",);
context,
0i32,
b"Configure ...\x00" as *const u8 as *const libc::c_char,
);
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();
@@ -1001,14 +990,11 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
); );
dc_ensure_secret_key_exists(context); dc_ensure_secret_key_exists(context);
success = 1; success = 1;
dc_log_info( info!(
context, context,
0, 0,
b"Configure completed.\x00" "Configure completed."
as );
*const u8
as
*const libc::c_char);
if !s.shall_stop_ongoing if !s.shall_stop_ongoing
{ {
context.call_cb( context.call_cb(
@@ -1483,11 +1469,9 @@ unsafe fn outlk_autodiscover_starttag_cb(
} }
pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int { pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int {
if 0 != dc_has_ongoing(context) { if 0 != dc_has_ongoing(context) {
dc_log_warning( warn!(
context, context,
0, 0, "There is already another ongoing process running.",
b"There is already another ongoing process running.\x00" as *const u8
as *const libc::c_char,
); );
return 0; return 0;
} }

View File

@@ -375,7 +375,7 @@ pub fn dc_add_or_lookup_contact(
} else { } else {
update_name = true; update_name = true;
} }
if origin == 0x10 && as_str(name) != row_authname { if origin == 0x10 && !name.is_null() && as_str(name) != row_authname {
update_authname = true; update_authname = true;
} }
Ok((row_id, row_name, row_addr, row_origin, row_authname)) Ok((row_id, row_name, row_addr, row_origin, row_authname))
@@ -391,7 +391,11 @@ pub fn dc_add_or_lookup_contact(
&context.sql, &context.sql,
"UPDATE contacts SET name=?, addr=?, origin=?, authname=? WHERE id=?;", "UPDATE contacts SET name=?, addr=?, origin=?, authname=? WHERE id=?;",
params![ params![
if update_name { as_str(name) } else { &row_name }, if update_name {
to_string(name)
} else {
row_name
},
if update_addr { addr } else { &row_addr }, if update_addr { addr } else { &row_addr },
if origin > row_origin { if origin > row_origin {
origin origin
@@ -399,9 +403,9 @@ pub fn dc_add_or_lookup_contact(
row_origin row_origin
}, },
if update_authname { if update_authname {
as_str(name) to_string(name)
} else { } else {
&row_authname row_authname
}, },
row_id row_id
], ],
@@ -412,7 +416,7 @@ pub fn dc_add_or_lookup_contact(
context, context,
&context.sql, &context.sql,
"UPDATE chats SET name=? WHERE type=? AND id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?);", "UPDATE chats SET name=? WHERE type=? AND id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?);",
params![as_str(name), 100, row_id] params![to_string(name), 100, row_id]
); );
} }
unsafe { *sth_modified = 1 }; unsafe { *sth_modified = 1 };
@@ -422,11 +426,7 @@ pub fn dc_add_or_lookup_contact(
context, context,
&context.sql, &context.sql,
"INSERT INTO contacts (name, addr, origin) VALUES(?, ?, ?);", "INSERT INTO contacts (name, addr, origin) VALUES(?, ?, ?);",
params![ params![to_string(name), addr, origin,],
if !name.is_null() { as_str(name) } else { "" },
addr,
origin,
],
) { ) {
row_id = dc_sqlite3_get_rowid(context, &context.sql, "contacts", "addr", addr); row_id = dc_sqlite3_get_rowid(context, &context.sql, "contacts", "addr", addr);
unsafe { *sth_modified = 2 }; unsafe { *sth_modified = 2 };

View File

@@ -17,7 +17,6 @@ use mmime::{mailmime_substitute, MAILIMF_NO_ERROR, MAIL_NO_ERROR};
use crate::aheader::*; use crate::aheader::*;
use crate::context::Context; use crate::context::Context;
use crate::dc_log::*;
use crate::dc_mimeparser::*; use crate::dc_mimeparser::*;
use crate::dc_securejoin::*; use crate::dc_securejoin::*;
use crate::dc_sqlite3::*; use crate::dc_sqlite3::*;
@@ -521,27 +520,19 @@ unsafe fn load_or_generate_self_public_key(
&context.sql, &context.sql,
) { ) {
/*set default*/ /*set default*/
dc_log_warning( warn!(context, 0, "Cannot save keypair.",);
context,
0,
b"Cannot save keypair.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
dc_log_info( info!(
context, context,
0, 0,
b"Keypair generated in %.3f s.\x00" as *const u8 as *const libc::c_char, "Keypair generated in {:.3}s.",
clock().wrapping_sub(start) as libc::c_double / 1000000 as libc::c_double, clock().wrapping_sub(start) as libc::c_double / 1000000 as libc::c_double,
); );
} }
key = Some(public_key); key = Some(public_key);
} else { } else {
dc_log_warning( warn!(context, 0, "Cannot create keypair.");
context,
0,
b"Cannot create keypair.\x00" as *const u8 as *const libc::c_char,
);
} }
if 0 != key_creation_here { if 0 != key_creation_here {
@@ -711,12 +702,11 @@ unsafe fn update_gossip_peerstates(
gossipped_addr.insert(header.addr.clone()); gossipped_addr.insert(header.addr.clone());
} else { } else {
dc_log_info( info!(
context, context,
0i32, 0,
b"Ignoring gossipped \"%s\" as the address is not in To/Cc list.\x00" "Ignoring gossipped \"{}\" as the address is not in To/Cc list.",
as *const u8 as *const libc::c_char, &header.addr,
CString::new(header.addr.clone()).unwrap().as_ptr(),
); );
} }
} }
@@ -1079,17 +1069,15 @@ pub unsafe fn dc_ensure_secret_key_exists(context: &Context) -> libc::c_int {
let self_addr = dc_sqlite3_get_config(context, &context.sql, "configured_addr", None); let self_addr = dc_sqlite3_get_config(context, &context.sql, "configured_addr", None);
if self_addr.is_none() { if self_addr.is_none() {
dc_log_warning( warn!(
context, context,
0i32, 0, "Cannot ensure secret key if context is not configured.",
b"Cannot ensure secret key if context is not configured.\x00" as *const u8
as *const libc::c_char,
); );
} else if load_or_generate_self_public_key(context, self_addr.unwrap(), 0 as *mut mailmime) } else if load_or_generate_self_public_key(context, self_addr.unwrap(), 0 as *mut mailmime)
.is_some() .is_some()
{ {
/*no random text data for seeding available*/ /*no random text data for seeding available*/
success = 1i32 success = 1;
} }
success success

View File

@@ -12,7 +12,6 @@ use crate::dc_chat::*;
use crate::dc_configure::*; use crate::dc_configure::*;
use crate::dc_e2ee::*; use crate::dc_e2ee::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*; use crate::dc_msg::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_sqlite3::*; use crate::dc_sqlite3::*;
@@ -51,13 +50,11 @@ pub unsafe fn dc_imex_has_backup(
let dir_name = as_path(dir_name); let dir_name = as_path(dir_name);
let dir_iter = std::fs::read_dir(dir_name); let dir_iter = std::fs::read_dir(dir_name);
if dir_iter.is_err() { if dir_iter.is_err() {
dc_log_info( info!(
context, context,
0i32, 0,
b"Backup check: Cannot open directory \"%s\".\x00" as *const u8 as *const libc::c_char, "Backup check: Cannot open directory \"{}\".\x00",
CString::new(format!("{}", dir_name.display())) dir_name.display(),
.unwrap()
.as_ptr(),
); );
return 0 as *mut libc::c_char; return 0 as *mut libc::c_char;
} }
@@ -88,12 +85,7 @@ pub unsafe fn dc_imex_has_backup(
Some(path) => match path.to_c_string() { Some(path) => match path.to_c_string() {
Ok(cstr) => dc_strdup(cstr.as_ptr()), Ok(cstr) => dc_strdup(cstr.as_ptr()),
Err(err) => { Err(err) => {
dc_log_error( error!(context, 0, "Invalid backup filename: {}", err);
context,
0i32,
b"Invalid backup filename: %s\x00" as *const u8 as *const libc::c_char,
CString::new(format!("{}", err)).unwrap().as_ptr(),
);
std::ptr::null_mut() std::ptr::null_mut()
} }
}, },
@@ -170,12 +162,7 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
if !(msg_id == 0i32 as libc::c_uint) { if !(msg_id == 0i32 as libc::c_uint) {
dc_msg_unref(msg); dc_msg_unref(msg);
msg = 0 as *mut dc_msg_t; msg = 0 as *mut dc_msg_t;
dc_log_info( info!(context, 0, "Wait for setup message being sent ...",);
context,
0i32,
b"Wait for setup message being sent ...\x00" as *const u8
as *const libc::c_char,
);
loop { loop {
if context if context
.running_state .running_state
@@ -199,13 +186,8 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
match current_block { match current_block {
6116957410927263949 => {} 6116957410927263949 => {}
_ => { _ => {
dc_log_info( info!(context, 0, "... setup message sent.",);
context, success = 1;
0i32,
b"... setup message sent.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32
} }
} }
} }
@@ -557,32 +539,21 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
param1 = dc_param_get((*job).param, 'E' as i32, 0 as *const libc::c_char); param1 = dc_param_get((*job).param, 'E' as i32, 0 as *const libc::c_char);
param2 = dc_param_get((*job).param, 'F' as i32, 0 as *const libc::c_char); param2 = dc_param_get((*job).param, 'F' as i32, 0 as *const libc::c_char);
if param1.is_null() { if param1.is_null() {
dc_log_error( error!(context, 0, "No Import/export dir/file given.",);
context,
0i32,
b"No Import/export dir/file given.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
dc_log_info( info!(context, 0, "Import/export process started.",);
context,
0i32,
b"Import/export process started.\x00" as *const u8 as *const libc::c_char,
);
context.call_cb(Event::IMEX_PROGRESS, 10i32 as uintptr_t, 0i32 as uintptr_t); context.call_cb(Event::IMEX_PROGRESS, 10i32 as uintptr_t, 0i32 as uintptr_t);
if !context.sql.is_open() { if !context.sql.is_open() {
dc_log_error( error!(context, 0, "Import/export: Database not opened.",);
context,
0i32,
b"Import/export: Database not opened.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
if what == 1i32 || what == 11i32 { if what == 1i32 || what == 11i32 {
/* before we export anything, make sure the private key exists */ /* before we export anything, make sure the private key exists */
if 0 == dc_ensure_secret_key_exists(context) { if 0 == dc_ensure_secret_key_exists(context) {
dc_log_error(context, 0i32, error!(
b"Import/export: Cannot create private key or private key not available.\x00" context,
as *const u8 as 0,
*const libc::c_char); "Import/export: Cannot create private key or private key not available.",
);
current_block = 3568988166330621280; current_block = 3568988166330621280;
} else { } else {
dc_create_folder(context, param1); dc_create_folder(context, param1);
@@ -629,12 +600,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
match current_block { match current_block {
3568988166330621280 => {} 3568988166330621280 => {}
_ => { _ => {
dc_log_info( info!(context, 0, "Import/export completed.",);
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32 success = 1i32
} }
} }
@@ -674,12 +640,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
match current_block { match current_block {
3568988166330621280 => {} 3568988166330621280 => {}
_ => { _ => {
dc_log_info( info!(context, 0, "Import/export completed.",);
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32 success = 1i32
} }
} }
@@ -719,12 +680,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
match current_block { match current_block {
3568988166330621280 => {} 3568988166330621280 => {}
_ => { _ => {
dc_log_info( info!(context, 0, "Import/export completed.",);
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32 success = 1i32
} }
} }
@@ -764,12 +720,7 @@ pub unsafe fn dc_job_do_DC_JOB_IMEX_IMAP(context: &Context, job: *mut dc_job_t)
match current_block { match current_block {
3568988166330621280 => {} 3568988166330621280 => {}
_ => { _ => {
dc_log_info( info!(context, 0, "Import/export completed.",);
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32 success = 1i32
} }
} }
@@ -936,11 +887,7 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
let buffer = to_cstring(res); let buffer = to_cstring(res);
let dest_pathNfilename = dc_get_fine_pathNfilename(context, dir, buffer.as_ptr()); let dest_pathNfilename = dc_get_fine_pathNfilename(context, dir, buffer.as_ptr());
if dest_pathNfilename.is_null() { if dest_pathNfilename.is_null() {
dc_log_error( error!(context, 0, "Cannot get backup file name.",);
context,
0,
b"Cannot get backup file name.\x00" as *const u8 as *const libc::c_char,
);
return success; return success;
} }
@@ -950,12 +897,12 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
dc_sqlite3_try_execute(context, &context.sql, "VACUUM;"); dc_sqlite3_try_execute(context, &context.sql, "VACUUM;");
context.sql.close(context); context.sql.close(context);
let mut closed = true; let mut closed = true;
dc_log_info( info!(
context, context,
0, 0,
b"Backup \"%s\" to \"%s\".\x00" as *const u8 as *const libc::c_char, "Backup \"{}\" to \"{}\".",
context.get_dbfile(), as_str(context.get_dbfile()),
dest_pathNfilename, as_str(dest_pathNfilename),
); );
if !(0 == dc_copy_file(context, context.get_dbfile(), dest_pathNfilename)) { if !(0 == dc_copy_file(context, context.get_dbfile(), dest_pathNfilename)) {
context.sql.open(&context, as_path(context.get_dbfile()), 0); context.sql.open(&context, as_path(context.get_dbfile()), 0);
@@ -986,12 +933,11 @@ unsafe fn export_backup(context: &Context, dir: *const libc::c_char) -> libc::c_
let dir = std::path::Path::new(as_str(context.get_blobdir())); let dir = std::path::Path::new(as_str(context.get_blobdir()));
let dir_handle = std::fs::read_dir(dir); let dir_handle = std::fs::read_dir(dir);
if dir_handle.is_err() { if dir_handle.is_err() {
dc_log_error( error!(
context, context,
0, 0,
b"Backup: Cannot get info for blob-directory \"%s\".\x00" as *const u8 "Backup: Cannot get info for blob-directory \"{}\".",
as *const libc::c_char, as_str(context.get_blobdir()),
context.get_blobdir(),
); );
} else { } else {
let dir_handle = dir_handle.unwrap(); let dir_handle = dir_handle.unwrap();
@@ -1150,11 +1096,11 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
let dir = std::path::Path::new(as_str(dir_name)); let dir = std::path::Path::new(as_str(dir_name));
let dir_handle = std::fs::read_dir(dir); let dir_handle = std::fs::read_dir(dir);
if dir_handle.is_err() { if dir_handle.is_err() {
dc_log_error( error!(
context, context,
0, 0,
b"Import: Cannot open directory \"%s\".\x00" as *const u8 as *const libc::c_char, "Import: Cannot open directory \"{}\".",
dir_name, as_str(dir_name),
); );
} else { } else {
let dir_handle = dir_handle.unwrap(); let dir_handle = dir_handle.unwrap();
@@ -1178,12 +1124,7 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
dir_name, dir_name,
name_c.as_ptr(), name_c.as_ptr(),
); );
dc_log_info( info!(context, 0, "Checking: {}", as_str(path_plus_name));
context,
0,
b"Checking: %s\x00" as *const u8 as *const libc::c_char,
path_plus_name,
);
free(buf as *mut libc::c_void); free(buf as *mut libc::c_void);
buf = 0 as *mut libc::c_char; buf = 0 as *mut libc::c_char;
if 0 == dc_read_file( if 0 == dc_read_file(
@@ -1225,12 +1166,11 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
) )
.is_null() .is_null()
{ {
dc_log_info( info!(
context, context,
0i32, 0,
b"Treating \"%s\" as a legacy private key.\x00" as *const u8 "Treating \"{}\" as a legacy private key.",
as *const libc::c_char, as_str(path_plus_name),
path_plus_name,
); );
set_default = 0i32 set_default = 0i32
} }
@@ -1240,11 +1180,11 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
imported_cnt += 1 imported_cnt += 1
} }
if imported_cnt == 0i32 { if imported_cnt == 0i32 {
dc_log_error( error!(
context, context,
0i32, 0,
b"No private keys found in \"%s\".\x00" as *const u8 as *const libc::c_char, "No private keys found in \"{}\".",
dir_name, as_str(dir_name),
); );
} }
} }
@@ -1343,20 +1283,10 @@ unsafe fn export_key_to_asc_file(
id, id,
) )
} }
dc_log_info( info!(context, 0, "Exporting key {}", as_str(file_name),);
context,
0i32,
b"Exporting key %s\x00" as *const u8 as *const libc::c_char,
file_name,
);
dc_delete_file(context, file_name); dc_delete_file(context, file_name);
if !key.write_asc_to_file(file_name, context) { if !key.write_asc_to_file(file_name, context) {
dc_log_error( error!(context, 0, "Cannot write key to {}", as_str(file_name),);
context,
0i32,
b"Cannot write key to %s\x00" as *const u8 as *const libc::c_char,
file_name,
);
} else { } else {
context.call_cb( context.call_cb(
Event::IMEX_FILE_WRITTEN, Event::IMEX_FILE_WRITTEN,

View File

@@ -12,7 +12,6 @@ use crate::dc_configure::*;
use crate::dc_imex::*; use crate::dc_imex::*;
use crate::dc_jobthread::*; use crate::dc_jobthread::*;
use crate::dc_location::*; use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_loginparam::*; use crate::dc_loginparam::*;
use crate::dc_mimefactory::*; use crate::dc_mimefactory::*;
use crate::dc_msg::*; use crate::dc_msg::*;
@@ -304,21 +303,11 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
13109137661213826276 => { 13109137661213826276 => {
filename = dc_param_get(job.param, 'f' as i32, 0 as *const libc::c_char); filename = dc_param_get(job.param, 'f' as i32, 0 as *const libc::c_char);
if filename.is_null() { if filename.is_null() {
dc_log_warning( warn!(context, 0, "Missing file name for job {}", job.job_id,);
context,
0i32,
b"Missing file name for job %d\x00" as *const u8 as *const libc::c_char,
job.job_id,
);
} else if !(0 == dc_read_file(context, filename, &mut buf, &mut buf_bytes)) { } else if !(0 == dc_read_file(context, filename, &mut buf, &mut buf_bytes)) {
recipients = dc_param_get(job.param, 'R' as i32, 0 as *const libc::c_char); recipients = dc_param_get(job.param, 'R' as i32, 0 as *const libc::c_char);
if recipients.is_null() { if recipients.is_null() {
dc_log_warning( warn!(context, 0, "Missing recipients for job {}", job.job_id,);
context,
0i32,
b"Missing recipients for job %d\x00" as *const u8 as *const libc::c_char,
job.job_id,
);
} else { } else {
let recipients_list = std::ffi::CStr::from_ptr(recipients) let recipients_list = std::ffi::CStr::from_ptr(recipients)
.to_str() .to_str()
@@ -337,11 +326,10 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
before the generated mime was sent out */ before the generated mime was sent out */
if 0 != job.foreign_id { if 0 != job.foreign_id {
if 0 == dc_msg_exists(context, job.foreign_id) { if 0 == dc_msg_exists(context, job.foreign_id) {
dc_log_warning( warn!(
context, context,
0i32, 0,
b"Message %i for job %i does not exist\x00" as *const u8 "Message {} for job {} does not exist",
as *const libc::c_char,
job.foreign_id, job.foreign_id,
job.job_id, job.job_id,
); );
@@ -746,12 +734,11 @@ unsafe fn dc_add_smtp_job(
(*mimefactory).rfc724_mid, (*mimefactory).rfc724_mid,
); );
if pathNfilename.is_null() { if pathNfilename.is_null() {
dc_log_error( error!(
context, context,
0i32, 0,
b"Could not find free file name for message with ID <%s>.\x00" as *const u8 "Could not find free file name for message with ID <{}>.",
as *const libc::c_char, to_string((*mimefactory).rfc724_mid),
(*mimefactory).rfc724_mid,
); );
} else if 0 } else if 0
== dc_write_file( == dc_write_file(
@@ -761,12 +748,12 @@ unsafe fn dc_add_smtp_job(
(*(*mimefactory).out).len, (*(*mimefactory).out).len,
) )
{ {
dc_log_error( error!(
context, context,
0i32, 0,
b"Could not write message <%s> to \"%s\".\x00" as *const u8 as *const libc::c_char, "Could not write message <{}> to \"{}\".",
(*mimefactory).rfc724_mid, to_string((*mimefactory).rfc724_mid),
pathNfilename, as_str(pathNfilename),
); );
} else { } else {
recipients = dc_str_from_clist( recipients = dc_str_from_clist(
@@ -837,11 +824,7 @@ pub unsafe fn dc_job_add(
} }
pub unsafe fn dc_interrupt_smtp_idle(context: &Context) { pub unsafe fn dc_interrupt_smtp_idle(context: &Context) {
dc_log_info( info!(context, 0, "Interrupting SMTP-idle...",);
context,
0i32,
b"Interrupting SMTP-idle...\x00" as *const u8 as *const libc::c_char,
);
let &(ref lock, ref cvar) = &*context.smtp_state.clone(); let &(ref lock, ref cvar) = &*context.smtp_state.clone();
let mut state = lock.lock().unwrap(); let mut state = lock.lock().unwrap();
@@ -852,11 +835,7 @@ pub unsafe fn dc_interrupt_smtp_idle(context: &Context) {
} }
pub unsafe fn dc_interrupt_imap_idle(context: &Context) { pub unsafe fn dc_interrupt_imap_idle(context: &Context) {
dc_log_info( info!(context, 0, "Interrupting IMAP-IDLE...",);
context,
0i32,
b"Interrupting IMAP-IDLE...\x00" as *const u8 as *const libc::c_char,
);
*context.perform_inbox_jobs_needed.write().unwrap() = 1; *context.perform_inbox_jobs_needed.write().unwrap() = 1;
context.inbox.read().unwrap().interrupt_idle(); context.inbox.read().unwrap().interrupt_idle();
@@ -874,11 +853,9 @@ unsafe fn dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(context: &Context, job: &mut dc_jo
{ {
/* eg. device messages have no Message-ID */ /* eg. device messages have no Message-ID */
if dc_rfc724_mid_cnt(context, (*msg).rfc724_mid) != 1i32 { if dc_rfc724_mid_cnt(context, (*msg).rfc724_mid) != 1i32 {
dc_log_info( info!(
context, context,
0i32, 0, "The message is deleted from the server when all parts are deleted.",
b"The message is deleted from the server when all parts are deleted.\x00"
as *const u8 as *const libc::c_char,
); );
delete_from_server = 0i32 delete_from_server = 0i32
} }
@@ -939,31 +916,19 @@ pub unsafe fn dc_perform_imap_fetch(context: &Context) {
return; return;
} }
if dc_sqlite3_get_config_int(context, &context.sql, "inbox_watch", 1) == 0 { if dc_sqlite3_get_config_int(context, &context.sql, "inbox_watch", 1) == 0 {
dc_log_info( info!(context, 0, "INBOX-watch disabled.",);
context,
0,
b"INBOX-watch disabled.\x00" as *const u8 as *const libc::c_char,
);
return; return;
} }
dc_log_info( info!(context, 0, "INBOX-fetch started...",);
context,
0,
b"INBOX-fetch started...\x00" as *const u8 as *const libc::c_char,
);
inbox.fetch(context); inbox.fetch(context);
if inbox.should_reconnect() { if inbox.should_reconnect() {
dc_log_info( info!(context, 0, "INBOX-fetch aborted, starting over...",);
context,
0,
b"INBOX-fetch aborted, starting over...\x00" as *const u8 as *const libc::c_char,
);
inbox.fetch(context); inbox.fetch(context);
} }
dc_log_info( info!(
context, context,
0, 0,
b"INBOX-fetch done in %.0f ms.\x00" as *const u8 as *const libc::c_char, "INBOX-fetch done in {:.4} ms.",
clock().wrapping_sub(start) as libc::c_double * 1000.0f64 / 1000000 as libc::c_double, clock().wrapping_sub(start) as libc::c_double * 1000.0f64 / 1000000 as libc::c_double,
); );
} }
@@ -1066,11 +1031,9 @@ pub unsafe fn dc_perform_smtp_idle(context: &Context) {
let mut state = lock.lock().unwrap(); let mut state = lock.lock().unwrap();
if state.perform_jobs_needed == 1 { if state.perform_jobs_needed == 1 {
dc_log_info( info!(
context, context,
0, 0, "SMTP-idle will not be started because of waiting jobs.",
b"SMTP-idle will not be started because of waiting jobs.\x00" as *const u8
as *const libc::c_char,
); );
} else { } else {
let dur = get_next_wakeup_time(context, 5000); let dur = get_next_wakeup_time(context, 5000);
@@ -1088,11 +1051,7 @@ pub unsafe fn dc_perform_smtp_idle(context: &Context) {
} }
} }
dc_log_info( info!(context, 0, "SMTP-idle ended.",);
context,
0,
b"SMTP-idle ended.\x00" as *const u8 as *const libc::c_char,
);
} }
unsafe fn get_next_wakeup_time(context: &Context, thread: libc::c_int) -> Duration { unsafe fn get_next_wakeup_time(context: &Context, thread: libc::c_int) -> Duration {
@@ -1168,11 +1127,9 @@ pub unsafe fn dc_job_send_msg(context: &Context, msg_id: uint32_t) -> libc::c_in
dc_mimefactory_init(&mut mimefactory, context); dc_mimefactory_init(&mut mimefactory, context);
/* load message data */ /* load message data */
if 0 == dc_mimefactory_load_msg(&mut mimefactory, msg_id) || mimefactory.from_addr.is_null() { if 0 == dc_mimefactory_load_msg(&mut mimefactory, msg_id) || mimefactory.from_addr.is_null() {
dc_log_warning( warn!(
context, context,
0i32, 0, "Cannot load data to send, maybe the message is deleted in between.",
b"Cannot load data to send, maybe the message is deleted in between.\x00" as *const u8
as *const libc::c_char,
); );
} else { } else {
// no redo, no IMAP. moreover, as the data does not exist, there is no need in calling dc_set_msg_failed() // no redo, no IMAP. moreover, as the data does not exist, there is no need in calling dc_set_msg_failed()

View File

@@ -3,7 +3,6 @@ use crate::context::*;
use crate::dc_array::*; use crate::dc_array::*;
use crate::dc_chat::*; use crate::dc_chat::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*; use crate::dc_msg::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_saxparser::*; use crate::dc_saxparser::*;
@@ -472,12 +471,9 @@ pub unsafe fn dc_kml_parse(
}; };
if content_bytes > (1 * 1024 * 1024) { if content_bytes > (1 * 1024 * 1024) {
dc_log_warning( warn!(
context, context,
0, 0, "A kml-files with {} bytes is larger than reasonably expected.", content_bytes,
b"A kml-files with %i bytes is larger than reasonably expected.\x00" as *const u8
as *const libc::c_char,
content_bytes,
); );
} else { } else {
content_nullterminated = dc_null_terminate(content, content_bytes as libc::c_int); content_nullterminated = dc_null_terminate(content, content_bytes as libc::c_int);
@@ -630,11 +626,9 @@ pub unsafe fn dc_kml_unref(kml: *mut dc_kml_t) {
pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mut dc_job_t) { pub unsafe fn dc_job_do_DC_JOB_MAYBE_SEND_LOCATIONS(context: &Context, _job: *mut dc_job_t) {
let now = time(); let now = time();
let mut continue_streaming: libc::c_int = 1; let mut continue_streaming: libc::c_int = 1;
dc_log_info( info!(
context, context,
0, 0, " ----------------- MAYBE_SEND_LOCATIONS -------------- ",
b" ----------------- MAYBE_SEND_LOCATIONS -------------- \x00" as *const u8
as *const libc::c_char,
); );
context context

View File

@@ -1,142 +0,0 @@
use crate::constants::Event;
use crate::context::Context;
use crate::dc_tools::*;
use crate::types::*;
use crate::x::*;
pub unsafe extern "C" fn dc_log_event(
context: &Context,
event_code: Event,
data1: libc::c_int,
msg: *const libc::c_char,
va: ...
) {
log_vprintf(context, event_code, data1, msg, va);
}
/* Asynchronous "Thread-errors" are reported by the dc_log_error()
function. These errors must be shown to the user by a bubble or so.
"Normal" errors are usually returned by a special value (null or so) and are
usually not reported using dc_log_error() - its up to the caller to
decide, what should be reported or done. However, these "Normal" errors
are usually logged by dc_log_warning(). */
unsafe extern "C" fn log_vprintf(
context: &Context,
event: Event,
data1: libc::c_int,
msg_format: *const libc::c_char,
mut va_0: ...
) {
let msg: *mut libc::c_char;
if !msg_format.is_null() {
let mut tempbuf: [libc::c_char; 1025] = [0; 1025];
vsnprintf(
tempbuf.as_mut_ptr(),
1024i32 as libc::c_ulong,
msg_format,
va_0.as_va_list(),
);
msg = dc_strdup(tempbuf.as_mut_ptr())
} else {
msg = dc_mprintf(
b"event #%i\x00" as *const u8 as *const libc::c_char,
event as libc::c_int,
)
}
context.call_cb(event, data1 as uintptr_t, msg as uintptr_t);
free(msg as *mut libc::c_void);
}
pub unsafe extern "C" fn dc_log_event_seq(
context: &Context,
event_code: Event,
sequence_start: *mut libc::c_int,
msg: *const libc::c_char,
va_0: ...
) {
if sequence_start.is_null() {
return;
}
log_vprintf(context, event_code, *sequence_start, msg, va_0);
*sequence_start = 0i32;
}
pub unsafe extern "C" fn dc_log_error(
context: &Context,
data1: libc::c_int,
msg: *const libc::c_char,
va_1: ...
) {
log_vprintf(context, Event::ERROR, data1, msg, va_1);
}
pub unsafe extern "C" fn dc_log_warning(
context: &Context,
data1: libc::c_int,
msg: *const libc::c_char,
va_2: ...
) {
log_vprintf(context, Event::WARNING, data1, msg, va_2);
}
pub unsafe extern "C" fn dc_log_info(
context: &Context,
data1: libc::c_int,
msg: *const libc::c_char,
va_3: ...
) {
log_vprintf(context, Event::INFO, data1, msg, va_3);
}
#[macro_export]
macro_rules! info {
($ctx:expr, $data1:expr, $msg:expr) => {
info!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::INFO, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
}};
}
#[macro_export]
macro_rules! warn {
($ctx:expr, $data1:expr, $msg:expr) => {
warn!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::WARNING, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}
#[macro_export]
macro_rules! error {
($ctx:expr, $data1:expr, $msg:expr) => {
error!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::ERROR, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}
#[macro_export]
macro_rules! log_event {
($ctx:expr, $data1:expr, $msg:expr) => {
log_event!($ctx, $data1, $msg,)
};
($ctx:expr, $event:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($event, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}

View File

@@ -14,7 +14,6 @@ use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_e2ee::*; use crate::dc_e2ee::*;
use crate::dc_location::*; use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_msg::*; use crate::dc_msg::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_sqlite3::*; use crate::dc_sqlite3::*;
@@ -602,12 +601,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
grpimage = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char) grpimage = dc_param_get((*chat).param, 'i' as i32, 0 as *const libc::c_char)
} }
if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 { if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 {
dc_log_info( info!(
(*msg).context, (*msg).context,
0, 0,
b"sending secure-join message \'%s\' >>>>>>>>>>>>>>>>>>>>>>>>>\x00" "sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>",
as *const u8 as *const libc::c_char, "vg-member-added",
b"vg-member-added\x00" as *const u8 as *const libc::c_char,
); );
mailimf_fields_add( mailimf_fields_add(
imf_fields, imf_fields,
@@ -669,12 +667,11 @@ pub unsafe fn dc_mimefactory_render(mut factory: *mut dc_mimefactory_t) -> libc:
let step: *mut libc::c_char = let step: *mut libc::c_char =
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char); dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
if !step.is_null() { if !step.is_null() {
dc_log_info( info!(
(*msg).context, (*msg).context,
0, 0,
b"sending secure-join message \'%s\' >>>>>>>>>>>>>>>>>>>>>>>>>\x00" "sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>",
as *const u8 as *const libc::c_char, as_str(step),
step,
); );
mailimf_fields_add( mailimf_fields_add(
imf_fields, imf_fields,

View File

@@ -15,7 +15,6 @@ use crate::context::Context;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_e2ee::*; use crate::dc_e2ee::*;
use crate::dc_location::*; use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_simplify::*; use crate::dc_simplify::*;
use crate::dc_stock::*; use crate::dc_stock::*;
@@ -544,11 +543,9 @@ unsafe fn dc_mimeparser_parse_mime_recursive(
b"rfc822-headers\x00" as *const u8 as *const libc::c_char, b"rfc822-headers\x00" as *const u8 as *const libc::c_char,
) == 0i32 ) == 0i32
{ {
dc_log_info( info!(
(*mimeparser).context, (*mimeparser).context,
0i32, 0, "Protected headers found in text/rfc822-headers attachment: Will be ignored.",
b"Protected headers found in text/rfc822-headers attachment: Will be ignored.\x00"
as *const u8 as *const libc::c_char,
); );
return 0i32; return 0i32;
} }
@@ -562,11 +559,7 @@ unsafe fn dc_mimeparser_parse_mime_recursive(
) != MAILIMF_NO_ERROR as libc::c_int ) != MAILIMF_NO_ERROR as libc::c_int
|| (*mimeparser).header_protected.is_null() || (*mimeparser).header_protected.is_null()
{ {
dc_log_warning( warn!((*mimeparser).context, 0, "Protected headers parsing error.",);
(*mimeparser).context,
0i32,
b"Protected headers parsing error.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
hash_header( hash_header(
&mut (*mimeparser).header, &mut (*mimeparser).header,
@@ -575,9 +568,11 @@ unsafe fn dc_mimeparser_parse_mime_recursive(
); );
} }
} else { } else {
dc_log_info((*mimeparser).context, 0i32, info!(
b"Protected headers found in MIME header: Will be ignored as we already found an outer one.\x00" (*mimeparser).context,
as *const u8 as *const libc::c_char); 0,
"Protected headers found in MIME header: Will be ignored as we already found an outer one."
);
} }
} }
match (*mime).mm_type { match (*mime).mm_type {
@@ -769,10 +764,11 @@ unsafe fn dc_mimeparser_parse_mime_recursive(
} }
} }
if plain_cnt == 1i32 && html_cnt == 1i32 { if plain_cnt == 1i32 && html_cnt == 1i32 {
dc_log_warning((*mimeparser).context, 0i32, warn!(
b"HACK: multipart/mixed message found with PLAIN and HTML, we\'ll skip the HTML part as this seems to be unwanted.\x00" (*mimeparser).context,
as *const u8 as 0i32,
*const libc::c_char); "HACK: multipart/mixed message found with PLAIN and HTML, we\'ll skip the HTML part as this seems to be unwanted."
);
skip_part = html_part skip_part = html_part
} }
cur = (*(*mime).mm_data.mm_multipart.mm_mp_list).first; cur = (*(*mime).mm_data.mm_multipart.mm_mp_list).first;
@@ -1226,14 +1222,12 @@ unsafe fn dc_mimeparser_add_single_part_if_known(
current_block = 17788412896529399552; current_block = 17788412896529399552;
} }
} else { } else {
dc_log_warning( warn!(
mimeparser.context, mimeparser.context,
0i32, 0,
b"Cannot convert %i bytes from \"%s\" to \"utf-8\".\x00" "Cannot convert {} bytes from \"{}\" to \"utf-8\".",
as *const u8
as *const libc::c_char,
decoded_data_bytes as libc::c_int, decoded_data_bytes as libc::c_int,
charset, as_str(charset),
); );
current_block = 17788412896529399552; current_block = 17788412896529399552;
} }

View File

@@ -3,7 +3,6 @@ use crate::context::*;
use crate::dc_chat::*; use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_lot::dc_lot_t; use crate::dc_lot::dc_lot_t;
use crate::dc_lot::*; use crate::dc_lot::*;
use crate::dc_param::*; use crate::dc_param::*;
@@ -1162,12 +1161,7 @@ pub unsafe fn dc_set_msg_failed(context: &Context, msg_id: uint32_t, error: *con
} }
if !error.is_null() { if !error.is_null() {
dc_param_set((*msg).param, 'L' as i32, error); dc_param_set((*msg).param, 'L' as i32, error);
dc_log_error( error!(context, 0, "{}", as_str(error),);
context,
0,
b"%s\x00" as *const u8 as *const libc::c_char,
error,
);
} }
if dc_sqlite3_execute( if dc_sqlite3_execute(

View File

@@ -1,7 +1,6 @@
use crate::context::Context; use crate::context::Context;
use crate::dc_chat::*; use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_log::*;
use crate::dc_lot::*; use crate::dc_lot::*;
use crate::dc_param::*; use crate::dc_param::*;
use crate::dc_strencode::*; use crate::dc_strencode::*;
@@ -38,12 +37,7 @@ pub unsafe fn dc_check_qr(context: &Context, qr: *const libc::c_char) -> *mut dc
let mut grpname: *mut libc::c_char = 0 as *mut libc::c_char; let mut grpname: *mut libc::c_char = 0 as *mut libc::c_char;
(*qr_parsed).state = 0i32; (*qr_parsed).state = 0i32;
if !qr.is_null() { if !qr.is_null() {
dc_log_info( info!(context, 0, "Scanned QR code: {}", as_str(qr),);
context,
0i32,
b"Scanned QR code: %s\x00" as *const u8 as *const libc::c_char,
qr,
);
/* split parameters from the qr code /* split parameters from the qr code
------------------------------------ */ ------------------------------------ */
if strncasecmp( if strncasecmp(

View File

@@ -14,7 +14,6 @@ use crate::dc_chat::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_job::*; use crate::dc_job::*;
use crate::dc_location::*; use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_mimeparser::*; use crate::dc_mimeparser::*;
use crate::dc_move::*; use crate::dc_move::*;
use crate::dc_msg::*; use crate::dc_msg::*;
@@ -82,19 +81,11 @@ pub unsafe fn dc_receive_imf(
); );
to_ids = dc_array_new(16 as size_t); 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() { if to_ids.is_null() || created_db_entries.is_null() || rr_event_to_send.is_null() {
dc_log_info( info!(context, 0, "Bad param.",);
context,
0,
b"Bad param.\x00" as *const u8 as *const libc::c_char,
);
} else { } 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,
0,
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(
@@ -195,11 +186,7 @@ pub unsafe fn dc_receive_imf(
if rfc724_mid.is_null() { if rfc724_mid.is_null() {
rfc724_mid = dc_create_incoming_rfc724_mid(sent_timestamp, from_id, to_ids); rfc724_mid = dc_create_incoming_rfc724_mid(sent_timestamp, from_id, to_ids);
if rfc724_mid.is_null() { if rfc724_mid.is_null() {
dc_log_info( info!(context, 0, "Cannot create Message-ID.",);
context,
0,
b"Cannot create Message-ID.\x00" as *const u8 as *const libc::c_char,
);
current_block = 16282941964262048061; current_block = 16282941964262048061;
} else { } else {
current_block = 777662472977924419; current_block = 777662472977924419;
@@ -316,12 +303,9 @@ pub unsafe fn dc_receive_imf(
if chat_id == 0 as libc::c_uint { if chat_id == 0 as libc::c_uint {
if 0 != dc_mimeparser_is_mailinglist_message(&mime_parser) { if 0 != dc_mimeparser_is_mailinglist_message(&mime_parser) {
chat_id = 3 as uint32_t; chat_id = 3 as uint32_t;
dc_log_info( info!(
context, context,
0, 0, "Message belongs to a mailing list and is ignored.",
b"Message belongs to a mailing list and is ignored.\x00"
as *const u8
as *const libc::c_char,
); );
} }
} }
@@ -352,10 +336,11 @@ pub unsafe fn dc_receive_imf(
!= dc_is_reply_to_known_message(context, &mime_parser) != dc_is_reply_to_known_message(context, &mime_parser)
{ {
dc_scaleup_contact_origin(context, from_id, 0x100); dc_scaleup_contact_origin(context, from_id, 0x100);
dc_log_info(context, 0, info!(
b"Message is a reply to a known message, mark sender as known.\x00" context,
as *const u8 as 0,
*const libc::c_char); "Message is a reply to a known message, mark sender as known.",
);
incoming_origin = if incoming_origin > 0x100 { incoming_origin = if incoming_origin > 0x100 {
incoming_origin incoming_origin
} else { } else {
@@ -1343,15 +1328,14 @@ unsafe fn create_or_lookup_group(
} }
if 0 != ok { if 0 != ok {
let chat: *mut Chat = dc_chat_new(context); let chat: *mut Chat = dc_chat_new(context);
dc_log_info( info!(
context, context,
0, 0,
b"New group image set to %s.\x00" as *const u8 "New group image set to {}.",
as *const libc::c_char,
if !grpimage.is_null() { if !grpimage.is_null() {
b"DELETED\x00" as *const u8 as *const libc::c_char "DELETED".to_string()
} else { } else {
grpimage to_string(grpimage)
}, },
); );
dc_chat_load_from_db(chat, chat_id); dc_chat_load_from_db(chat, chat_id);

View File

@@ -9,7 +9,6 @@ use crate::dc_chat::*;
use crate::dc_configure::*; use crate::dc_configure::*;
use crate::dc_contact::*; use crate::dc_contact::*;
use crate::dc_e2ee::*; use crate::dc_e2ee::*;
use crate::dc_log::*;
use crate::dc_lot::*; use crate::dc_lot::*;
use crate::dc_mimeparser::*; use crate::dc_mimeparser::*;
use crate::dc_msg::*; use crate::dc_msg::*;
@@ -144,29 +143,17 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
let mut contact_chat_id: uint32_t = 0i32 as uint32_t; let mut contact_chat_id: uint32_t = 0i32 as uint32_t;
let mut join_vg: libc::c_int = 0i32; let mut join_vg: libc::c_int = 0i32;
let mut qr_scan: *mut dc_lot_t = 0 as *mut dc_lot_t; let mut qr_scan: *mut dc_lot_t = 0 as *mut dc_lot_t;
dc_log_info( info!(context, 0, "Requesting secure-join ...",);
context,
0i32,
b"Requesting secure-join ...\x00" as *const u8 as *const libc::c_char,
);
dc_ensure_secret_key_exists(context); dc_ensure_secret_key_exists(context);
ongoing_allocated = dc_alloc_ongoing(context); ongoing_allocated = dc_alloc_ongoing(context);
if !(ongoing_allocated == 0i32) { if !(ongoing_allocated == 0i32) {
qr_scan = dc_check_qr(context, qr); qr_scan = dc_check_qr(context, qr);
if qr_scan.is_null() || (*qr_scan).state != 200i32 && (*qr_scan).state != 202i32 { if qr_scan.is_null() || (*qr_scan).state != 200i32 && (*qr_scan).state != 202i32 {
dc_log_error( error!(context, 0, "Unknown QR code.",);
context,
0i32,
b"Unknown QR code.\x00" as *const u8 as *const libc::c_char,
);
} else { } else {
contact_chat_id = dc_create_chat_by_contact_id(context, (*qr_scan).id); contact_chat_id = dc_create_chat_by_contact_id(context, (*qr_scan).id);
if contact_chat_id == 0i32 as libc::c_uint { if contact_chat_id == 0i32 as libc::c_uint {
dc_log_error( error!(context, 0, "Unknown contact.",);
context,
0i32,
b"Unknown contact.\x00" as *const u8 as *const libc::c_char,
);
} else if !(context } else if !(context
.running_state .running_state
.clone() .clone()
@@ -183,11 +170,7 @@ pub unsafe fn dc_join_securejoin(context: &Context, qr: *const libc::c_char) ->
} }
if 0 != fingerprint_equals_sender(context, (*qr_scan).fingerprint, contact_chat_id) if 0 != fingerprint_equals_sender(context, (*qr_scan).fingerprint, contact_chat_id)
{ {
dc_log_info( info!(context, 0, "Taking protocol shortcut.");
context,
0i32,
b"Taking protocol shortcut.\x00" as *const u8 as *const libc::c_char,
);
context.bob.clone().write().unwrap().expects = 6; context.bob.clone().write().unwrap().expects = 6;
context.call_cb( context.call_cb(
Event::SECUREJOIN_JOINER_PROGRESS, Event::SECUREJOIN_JOINER_PROGRESS,
@@ -375,12 +358,11 @@ pub unsafe fn dc_handle_securejoin_handshake(
b"Secure-Join\x00" as *const u8 as *const libc::c_char, b"Secure-Join\x00" as *const u8 as *const libc::c_char,
); );
if !step.is_null() { if !step.is_null() {
dc_log_info( info!(
context, context,
0i32, 0,
b">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message \'%s\' received\x00" as *const u8 ">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message \'{}\' received",
as *const libc::c_char, as_str(step),
step,
); );
join_vg = (strncmp(step, b"vg-\x00" as *const u8 as *const libc::c_char, 3) == 0) join_vg = (strncmp(step, b"vg-\x00" as *const u8 as *const libc::c_char, 3) == 0)
as libc::c_int; as libc::c_int;
@@ -456,12 +438,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
}; };
if cond { if cond {
dc_log_warning( warn!(context, 0, "auth-required message out of sync.",);
context,
0i32,
b"auth-required message out of sync.\x00" as *const u8
as *const libc::c_char,
);
// no error, just aborted somehow or a mail from another handshake // no error, just aborted somehow or a mail from another handshake
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
@@ -501,11 +478,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
end_bobs_joining(context, 0i32); end_bobs_joining(context, 0i32);
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
dc_log_info( info!(context, 0, "Fingerprint verified.",);
context,
0i32,
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
);
own_fingerprint = get_self_fingerprint(context); own_fingerprint = get_self_fingerprint(context);
context.call_cb( context.call_cb(
Event::SECUREJOIN_JOINER_PROGRESS, Event::SECUREJOIN_JOINER_PROGRESS,
@@ -572,11 +545,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
); );
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
dc_log_info( info!(context, 0, "Fingerprint verified.",);
context,
0i32,
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
);
// 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(
@@ -607,11 +576,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
dc_scaleup_contact_origin(context, contact_id, 0x1000000i32); dc_scaleup_contact_origin(context, contact_id, 0x1000000i32);
dc_log_info( info!(context, 0, "Auth verified.",);
context,
0i32,
b"Auth verified.\x00" as *const u8 as *const libc::c_char,
);
secure_connection_established(context, contact_chat_id); secure_connection_established(context, contact_chat_id);
context.call_cb( context.call_cb(
Event::CONTACTS_CHANGED, Event::CONTACTS_CHANGED,
@@ -635,12 +600,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
0 as *mut libc::c_int, 0 as *mut libc::c_int,
); );
if group_chat_id == 0i32 as libc::c_uint { if group_chat_id == 0i32 as libc::c_uint {
dc_log_error( error!(context, 0, "Chat {} not found.", as_str(grpid),);
context,
0i32,
b"Chat %s not found.\x00" as *const u8 as *const libc::c_char,
grpid,
);
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
dc_add_contact_to_chat_ex( dc_add_contact_to_chat_ex(
@@ -682,12 +642,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
ret = 0x1i32 ret = 0x1i32
} }
if context.bob.clone().read().unwrap().expects != 6 { if context.bob.clone().read().unwrap().expects != 6 {
dc_log_info( info!(context, 0, "Message belongs to a different handshake.",);
context,
0i32,
b"Message belongs to a different handshake.\x00" as *const u8
as *const libc::c_char,
);
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
let cond = { let cond = {
@@ -695,11 +650,9 @@ pub unsafe fn dc_handle_securejoin_handshake(
scan.is_null() || 0 != join_vg && (*scan).state != 202 scan.is_null() || 0 != join_vg && (*scan).state != 202
}; };
if cond { if cond {
dc_log_warning( warn!(
context, context,
0i32, 0, "Message out of sync or belongs to a different handshake.",
b"Message out of sync or belongs to a different handshake.\x00"
as *const u8 as *const libc::c_char,
); );
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
@@ -767,10 +720,11 @@ pub unsafe fn dc_handle_securejoin_handshake(
as *const libc::c_char, as *const libc::c_char,
), ),
) { ) {
dc_log_info(context, 0i32, info!(
b"Message belongs to a different handshake (scaled up contact anyway to allow creation of group).\x00" context,
as *const u8 as 0,
*const libc::c_char); "Message belongs to a different handshake (scaled up contact anyway to allow creation of group)."
);
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
current_block = 9180031981464905198; current_block = 9180031981464905198;
@@ -814,12 +768,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
============================================================ */ ============================================================ */
contact = dc_get_contact(context, contact_id); contact = dc_get_contact(context, contact_id);
if contact.is_null() || 0 == dc_contact_is_verified(contact) { if contact.is_null() || 0 == dc_contact_is_verified(contact) {
dc_log_warning( warn!(context, 0, "vg-member-added-received invalid.",);
context,
0i32,
b"vg-member-added-received invalid.\x00" as *const u8
as *const libc::c_char,
);
current_block = 4378276786830486580; current_block = 4378276786830486580;
} else { } else {
context.call_cb( context.call_cb(
@@ -920,13 +869,7 @@ unsafe fn could_not_establish_secure_connection(
}, },
); );
dc_add_device_msg(context, contact_chat_id, msg); dc_add_device_msg(context, contact_chat_id, msg);
dc_log_error( error!(context, 0, "{} ({})", as_str(msg), to_string(details),);
context,
0i32,
b"%s (%s)\x00" as *const u8 as *const libc::c_char,
msg,
details,
);
free(msg as *mut libc::c_void); free(msg as *mut libc::c_void);
dc_contact_unref(contact); dc_contact_unref(contact);
} }
@@ -961,27 +904,15 @@ unsafe fn encrypted_and_signed(
expected_fingerprint: *const libc::c_char, expected_fingerprint: *const libc::c_char,
) -> libc::c_int { ) -> libc::c_int {
if 0 == mimeparser.e2ee_helper.encrypted { if 0 == mimeparser.e2ee_helper.encrypted {
dc_log_warning( warn!(mimeparser.context, 0, "Message not encrypted.",);
mimeparser.context,
0i32,
b"Message not encrypted.\x00" as *const u8 as *const libc::c_char,
);
return 0i32; return 0i32;
} }
if mimeparser.e2ee_helper.signatures.len() <= 0 { if mimeparser.e2ee_helper.signatures.len() <= 0 {
dc_log_warning( warn!(mimeparser.context, 0, "Message not signed.",);
mimeparser.context,
0i32,
b"Message not signed.\x00" as *const u8 as *const libc::c_char,
);
return 0i32; return 0i32;
} }
if expected_fingerprint.is_null() { if expected_fingerprint.is_null() {
dc_log_warning( warn!(mimeparser.context, 0, "Fingerprint for comparison missing.",);
mimeparser.context,
0i32,
b"Fingerprint for comparison missing.\x00" as *const u8 as *const libc::c_char,
);
return 0i32; return 0i32;
} }
if !mimeparser if !mimeparser
@@ -989,14 +920,13 @@ unsafe fn encrypted_and_signed(
.signatures .signatures
.contains(as_str(expected_fingerprint)) .contains(as_str(expected_fingerprint))
{ {
dc_log_warning( warn!(
mimeparser.context, mimeparser.context,
0i32, 0,
b"Message does not match expected fingerprint %s.\x00" as *const u8 "Message does not match expected fingerprint {}.",
as *const libc::c_char, as_str(expected_fingerprint),
expected_fingerprint,
); );
return 0i32; return 0;
} }
1 1

View File

@@ -8,7 +8,6 @@ use rand::{thread_rng, Rng};
use crate::context::Context; use crate::context::Context;
use crate::dc_array::*; use crate::dc_array::*;
use crate::dc_log::*;
use crate::types::*; use crate::types::*;
use crate::x::*; use crate::x::*;
@@ -1173,12 +1172,7 @@ pub unsafe fn dc_delete_file(context: &Context, pathNfilename: *const libc::c_ch
success = 1; success = 1;
} }
Err(_err) => { Err(_err) => {
dc_log_warning( warn!(context, 0, "Cannot delete \"{}\".", as_str(pathNfilename),);
context,
0i32,
b"Cannot delete \"%s\".\x00" as *const u8 as *const libc::c_char,
pathNfilename,
);
} }
} }
@@ -1208,13 +1202,7 @@ pub unsafe fn dc_copy_file(
success = 1; success = 1;
} }
Err(_) => { Err(_) => {
dc_log_error( error!(context, 0, "Cannot copy \"{}\" to \"{}\".", src_p, dest_p,);
context,
0,
b"Cannot copy \"%s\" to \"%s\".\x00" as *const u8 as *const libc::c_char,
src,
dest,
);
} }
} }
@@ -1237,11 +1225,11 @@ pub unsafe fn dc_create_folder(
success = 1; success = 1;
} }
Err(_err) => { Err(_err) => {
dc_log_warning( warn!(
context, context,
0i32, 0,
b"Cannot create directory \"%s\".\x00" as *const u8 as *const libc::c_char, "Cannot create directory \"{}\".",
pathNfilename, as_str(pathNfilename),
); );
} }
} }

View File

@@ -18,7 +18,7 @@ extern crate smallvec;
extern crate rusqlite; extern crate rusqlite;
#[macro_use] #[macro_use]
pub mod dc_log; mod log;
pub mod aheader; pub mod aheader;
pub mod constants; pub mod constants;

51
src/log.rs Normal file
View File

@@ -0,0 +1,51 @@
#[macro_export]
macro_rules! info {
($ctx:expr, $data1:expr, $msg:expr) => {
info!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {{
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::INFO, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
}};
}
#[macro_export]
macro_rules! warn {
($ctx:expr, $data1:expr, $msg:expr) => {
warn!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::WARNING, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}
#[macro_export]
macro_rules! error {
($ctx:expr, $data1:expr, $msg:expr) => {
error!($ctx, $data1, $msg,)
};
($ctx:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($crate::constants::Event::ERROR, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}
#[macro_export]
macro_rules! log_event {
($ctx:expr, $data1:expr, $msg:expr) => {
log_event!($ctx, $data1, $msg,)
};
($ctx:expr, $event:expr, $data1:expr, $msg:expr, $($args:expr),* $(,)?) => {
let formatted = format!($msg, $($args),*);
let formatted_c = $crate::dc_tools::to_cstring(formatted);
$ctx.call_cb($event, $data1 as libc::uintptr_t,
formatted_c.as_ptr() as libc::uintptr_t)
};
}

View File

@@ -45,12 +45,6 @@ extern "C" {
unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int, unsafe extern "C" fn(_: *const libc::c_void, _: *const libc::c_void) -> libc::c_int,
>, >,
); );
pub fn vsnprintf(
_: *mut libc::c_char,
_: libc::c_ulong,
_: *const libc::c_char,
_: std::ffi::VaList,
) -> libc::c_int;
// -- DC Methods // -- DC Methods
pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char; pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char;