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

@@ -6,7 +6,6 @@ use crate::dc_chat::*;
use crate::dc_contact::*;
use crate::dc_job::*;
use crate::dc_jobthread::*;
use crate::dc_log::*;
use crate::dc_loginparam::*;
use crate::dc_lot::dc_lot_t;
use crate::dc_move::*;
@@ -265,19 +264,19 @@ unsafe fn cb_precheck_imf(
if *old_server_folder.offset(0isize) as libc::c_int == 0i32
&& old_server_uid == 0i32 as libc::c_uint
{
dc_log_info(
info!(
context,
0i32,
b"[move] detected bbc-self %s\x00" as *const u8 as *const libc::c_char,
rfc724_mid,
0,
"[move] detected bbc-self {}",
as_str(rfc724_mid),
);
mark_seen = 1i32
} else if as_str(old_server_folder) != server_folder {
dc_log_info(
info!(
context,
0i32,
b"[move] detected moved message %s\x00" as *const u8 as *const libc::c_char,
rfc724_mid,
0,
"[move] detected moved message {}",
as_str(rfc724_mid),
);
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_contact::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*;
use crate::dc_param::*;
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
}
} else if !dc_real_contact_exists(context, contact_id) && contact_id != 1i32 as libc::c_uint {
dc_log_warning(
warn!(
context,
0i32,
b"Cannot create chat, contact %i does not exist.\x00" as *const u8
as *const libc::c_char,
contact_id as libc::c_int,
0, "Cannot create chat, contact {} does not exist.", contact_id as libc::c_int,
);
} else {
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);
if pathNfilename.is_null() {
dc_log_error(
error!(
context,
0i32,
b"Attachment missing for message of type #%i.\x00" as *const u8
as *const libc::c_char,
0,
"Attachment missing for message of type #{}.",
(*msg).type_0 as libc::c_int,
);
current_block = 2171833246886114521;
} else if (*msg).state == 18i32 && 0 == dc_is_blobdir_path(context, pathNfilename) {
dc_log_error(
context,
0i32,
b"Files must be created in the blob-directory.\x00" as *const u8
as *const libc::c_char,
);
error!(context, 0, "Files must be created in the blob-directory.",);
current_block = 2171833246886114521;
} else if 0 == dc_make_rel_and_copy(context, &mut pathNfilename) {
current_block = 2171833246886114521;
@@ -416,20 +406,20 @@ unsafe fn prepare_msg_common<'a>(
dc_param_set((*msg).param, 'm' as i32, better_mime_0);
free(better_mime_0 as *mut libc::c_void);
}
dc_log_info(
info!(
context,
0i32,
b"Attaching \"%s\" for message type #%i.\x00" as *const u8 as *const libc::c_char,
pathNfilename,
0,
"Attaching \"{}\" for message type #{}.",
as_str(pathNfilename),
(*msg).type_0 as libc::c_int,
);
current_block = 17281240262373992796;
}
} else {
dc_log_error(
error!(
context,
0i32,
b"Cannot send messages of type #%i.\x00" as *const u8 as *const libc::c_char,
0,
"Cannot send messages of type #{}.",
(*msg).type_0 as libc::c_int,
);
current_block = 2171833246886114521;
@@ -476,29 +466,20 @@ unsafe fn prepare_msg_raw(
let mut location_id = 0;
if !((*chat).type_0 == 100 || (*chat).type_0 == 120 || (*chat).type_0 == 130) {
dc_log_error(
context,
0,
b"Cannot send to chat type #%i.\x00" as *const u8 as *const libc::c_char,
(*chat).type_0,
);
error!(context, 0, "Cannot send to chat type #{}.", (*chat).type_0,);
} else if ((*chat).type_0 == 120 || (*chat).type_0 == 130)
&& 0 == dc_is_contact_in_chat(context, (*chat).id, 1 as uint32_t)
{
dc_log_event(
log_event!(
context,
Event::ERROR_SELF_NOT_IN_GROUP,
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 {
let from = dc_sqlite3_get_config(context, &context.sql, "configured_addr", None);
if from.is_none() {
dc_log_error(
context,
0,
b"Cannot send message, not configured.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Cannot send message, not configured.",);
} else {
let from_c = to_cstring(from.unwrap());
new_rfc724_mid = dc_create_outgoing_rfc724_mid(
@@ -521,11 +502,10 @@ unsafe fn prepare_msg_raw(
to_id = id;
current_block = 5689316957504528238;
} else {
dc_log_error(
error!(
context,
0,
b"Cannot send message, contact for chat #%i not found.\x00" as *const u8
as *const libc::c_char,
"Cannot send message, contact for chat #{} not found.",
(*chat).id,
);
current_block = 10477488590406205504;
@@ -1514,12 +1494,11 @@ pub unsafe fn dc_add_contact_to_chat_ex(
|| !dc_chat_load_from_db(chat, chat_id))
{
if !(dc_is_contact_in_chat(context, chat_id, 1 as uint32_t) == 1) {
dc_log_event(
log_event!(
context,
Event::ERROR_SELF_NOT_IN_GROUP,
0,
b"Cannot add contact to group; self not in group.\x00" as *const u8
as *const libc::c_char,
"Cannot add contact to group; self not in group.",
);
} else {
/* 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
if (*chat).type_0 == 130 {
if dc_contact_is_verified(contact) != 2 {
dc_log_error(
error!(
context, 0,
b"Only bidirectional verified contacts can be added to verified groups.\x00"
as *const u8 as *const libc::c_char
"Only bidirectional verified contacts can be added to verified groups."
);
current_block = 12326129973959287090;
} 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. */
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) {
dc_log_event(
log_event!(
context,
Event::ERROR_SELF_NOT_IN_GROUP,
0,
b"Cannot remove contact from chat; self not in group.\x00" as *const u8
as *const libc::c_char,
"Cannot remove contact from chat; self not in group.",
);
} else {
/* 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 {
success = 1i32
} else if !(dc_is_contact_in_chat(context, chat_id, 1i32 as uint32_t) == 1i32) {
dc_log_event(
log_event!(
context,
Event::ERROR_SELF_NOT_IN_GROUP,
0i32,
b"Cannot set chat name; self not in group\x00" as *const u8
as *const libc::c_char,
0,
"Cannot set chat name; self not in group",
);
} else {
/* 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 !(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) {
dc_log_event(
log_event!(
context,
Event::ERROR_SELF_NOT_IN_GROUP,
0i32,
b"Cannot set chat profile image; self not in group.\x00" as *const u8
as *const libc::c_char,
0,
"Cannot set chat profile image; self not in group.",
);
} else {
/* 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::dc_e2ee::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_loginparam::*;
use crate::dc_saxparser::*;
use crate::dc_sqlite3::*;
@@ -56,11 +55,9 @@ pub struct outlk_autodiscover_t<'a> {
// connect
pub unsafe fn dc_configure(context: &Context) {
if 0 != dc_has_ongoing(context) {
dc_log_warning(
warn!(
context,
0i32,
b"There is already another ongoing process running.\x00" as *const u8
as *const libc::c_char,
0, "There is already another ongoing process running.",
);
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)) {
ongoing_allocated_here = 1i32;
if !context.sql.is_open() {
dc_log_error(
context,
0i32,
b"Cannot configure, database not opened.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Cannot configure, database not opened.",);
} else {
context.inbox.read().unwrap().disconnect(context);
context
@@ -130,11 +123,7 @@ pub unsafe fn dc_job_do_DC_JOB_CONFIGURE_IMAP(context: &Context, _job: *mut dc_j
.imap
.disconnect(context);
context.smtp.clone().lock().unwrap().disconnect();
dc_log_info(
context,
0i32,
b"Configure ...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Configure ...",);
let s_a = context.running_state.clone();
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);
success = 1;
dc_log_info(
info!(
context,
0,
b"Configure completed.\x00"
as
*const u8
as
*const libc::c_char);
0,
"Configure completed."
);
if !s.shall_stop_ongoing
{
context.call_cb(
@@ -1483,11 +1469,9 @@ unsafe fn outlk_autodiscover_starttag_cb(
}
pub unsafe fn dc_alloc_ongoing(context: &Context) -> libc::c_int {
if 0 != dc_has_ongoing(context) {
dc_log_warning(
warn!(
context,
0,
b"There is already another ongoing process running.\x00" as *const u8
as *const libc::c_char,
0, "There is already another ongoing process running.",
);
return 0;
}

View File

@@ -375,7 +375,7 @@ pub fn dc_add_or_lookup_contact(
} else {
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;
}
Ok((row_id, row_name, row_addr, row_origin, row_authname))
@@ -391,7 +391,11 @@ pub fn dc_add_or_lookup_contact(
&context.sql,
"UPDATE contacts SET name=?, addr=?, origin=?, authname=? WHERE id=?;",
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 origin > row_origin {
origin
@@ -399,9 +403,9 @@ pub fn dc_add_or_lookup_contact(
row_origin
},
if update_authname {
as_str(name)
to_string(name)
} else {
&row_authname
row_authname
},
row_id
],
@@ -412,7 +416,7 @@ pub fn dc_add_or_lookup_contact(
context,
&context.sql,
"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 };
@@ -422,11 +426,7 @@ pub fn dc_add_or_lookup_contact(
context,
&context.sql,
"INSERT INTO contacts (name, addr, origin) VALUES(?, ?, ?);",
params![
if !name.is_null() { as_str(name) } else { "" },
addr,
origin,
],
params![to_string(name), addr, origin,],
) {
row_id = dc_sqlite3_get_rowid(context, &context.sql, "contacts", "addr", addr);
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::context::Context;
use crate::dc_log::*;
use crate::dc_mimeparser::*;
use crate::dc_securejoin::*;
use crate::dc_sqlite3::*;
@@ -521,27 +520,19 @@ unsafe fn load_or_generate_self_public_key(
&context.sql,
) {
/*set default*/
dc_log_warning(
context,
0,
b"Cannot save keypair.\x00" as *const u8 as *const libc::c_char,
);
warn!(context, 0, "Cannot save keypair.",);
} else {
dc_log_info(
info!(
context,
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,
);
}
key = Some(public_key);
} else {
dc_log_warning(
context,
0,
b"Cannot create keypair.\x00" as *const u8 as *const libc::c_char,
);
warn!(context, 0, "Cannot create keypair.");
}
if 0 != key_creation_here {
@@ -711,12 +702,11 @@ unsafe fn update_gossip_peerstates(
gossipped_addr.insert(header.addr.clone());
} else {
dc_log_info(
info!(
context,
0i32,
b"Ignoring gossipped \"%s\" as the address is not in To/Cc list.\x00"
as *const u8 as *const libc::c_char,
CString::new(header.addr.clone()).unwrap().as_ptr(),
0,
"Ignoring gossipped \"{}\" as the address is not in To/Cc list.",
&header.addr,
);
}
}
@@ -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);
if self_addr.is_none() {
dc_log_warning(
warn!(
context,
0i32,
b"Cannot ensure secret key if context is not configured.\x00" as *const u8
as *const libc::c_char,
0, "Cannot ensure secret key if context is not configured.",
);
} else if load_or_generate_self_public_key(context, self_addr.unwrap(), 0 as *mut mailmime)
.is_some()
{
/*no random text data for seeding available*/
success = 1i32
success = 1;
}
success

View File

@@ -12,7 +12,6 @@ use crate::dc_chat::*;
use crate::dc_configure::*;
use crate::dc_e2ee::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*;
use crate::dc_param::*;
use crate::dc_sqlite3::*;
@@ -51,13 +50,11 @@ pub unsafe fn dc_imex_has_backup(
let dir_name = as_path(dir_name);
let dir_iter = std::fs::read_dir(dir_name);
if dir_iter.is_err() {
dc_log_info(
info!(
context,
0i32,
b"Backup check: Cannot open directory \"%s\".\x00" as *const u8 as *const libc::c_char,
CString::new(format!("{}", dir_name.display()))
.unwrap()
.as_ptr(),
0,
"Backup check: Cannot open directory \"{}\".\x00",
dir_name.display(),
);
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() {
Ok(cstr) => dc_strdup(cstr.as_ptr()),
Err(err) => {
dc_log_error(
context,
0i32,
b"Invalid backup filename: %s\x00" as *const u8 as *const libc::c_char,
CString::new(format!("{}", err)).unwrap().as_ptr(),
);
error!(context, 0, "Invalid backup filename: {}", err);
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) {
dc_msg_unref(msg);
msg = 0 as *mut dc_msg_t;
dc_log_info(
context,
0i32,
b"Wait for setup message being sent ...\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Wait for setup message being sent ...",);
loop {
if context
.running_state
@@ -199,13 +186,8 @@ pub unsafe fn dc_initiate_key_transfer(context: &Context) -> *mut libc::c_char {
match current_block {
6116957410927263949 => {}
_ => {
dc_log_info(
context,
0i32,
b"... setup message sent.\x00" as *const u8
as *const libc::c_char,
);
success = 1i32
info!(context, 0, "... setup message sent.",);
success = 1;
}
}
}
@@ -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);
param2 = dc_param_get((*job).param, 'F' as i32, 0 as *const libc::c_char);
if param1.is_null() {
dc_log_error(
context,
0i32,
b"No Import/export dir/file given.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "No Import/export dir/file given.",);
} else {
dc_log_info(
context,
0i32,
b"Import/export process started.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Import/export process started.",);
context.call_cb(Event::IMEX_PROGRESS, 10i32 as uintptr_t, 0i32 as uintptr_t);
if !context.sql.is_open() {
dc_log_error(
context,
0i32,
b"Import/export: Database not opened.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Import/export: Database not opened.",);
} else {
if what == 1i32 || what == 11i32 {
/* before we export anything, make sure the private key exists */
if 0 == dc_ensure_secret_key_exists(context) {
dc_log_error(context, 0i32,
b"Import/export: Cannot create private key or private key not available.\x00"
as *const u8 as
*const libc::c_char);
error!(
context,
0,
"Import/export: Cannot create private key or private key not available.",
);
current_block = 3568988166330621280;
} else {
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 {
3568988166330621280 => {}
_ => {
dc_log_info(
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Import/export completed.",);
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 {
3568988166330621280 => {}
_ => {
dc_log_info(
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Import/export completed.",);
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 {
3568988166330621280 => {}
_ => {
dc_log_info(
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Import/export completed.",);
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 {
3568988166330621280 => {}
_ => {
dc_log_info(
context,
0i32,
b"Import/export completed.\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Import/export completed.",);
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 dest_pathNfilename = dc_get_fine_pathNfilename(context, dir, buffer.as_ptr());
if dest_pathNfilename.is_null() {
dc_log_error(
context,
0,
b"Cannot get backup file name.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Cannot get backup file name.",);
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;");
context.sql.close(context);
let mut closed = true;
dc_log_info(
info!(
context,
0,
b"Backup \"%s\" to \"%s\".\x00" as *const u8 as *const libc::c_char,
context.get_dbfile(),
dest_pathNfilename,
"Backup \"{}\" to \"{}\".",
as_str(context.get_dbfile()),
as_str(dest_pathNfilename),
);
if !(0 == dc_copy_file(context, context.get_dbfile(), dest_pathNfilename)) {
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_handle = std::fs::read_dir(dir);
if dir_handle.is_err() {
dc_log_error(
error!(
context,
0,
b"Backup: Cannot get info for blob-directory \"%s\".\x00" as *const u8
as *const libc::c_char,
context.get_blobdir(),
"Backup: Cannot get info for blob-directory \"{}\".",
as_str(context.get_blobdir()),
);
} else {
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_handle = std::fs::read_dir(dir);
if dir_handle.is_err() {
dc_log_error(
error!(
context,
0,
b"Import: Cannot open directory \"%s\".\x00" as *const u8 as *const libc::c_char,
dir_name,
"Import: Cannot open directory \"{}\".",
as_str(dir_name),
);
} else {
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,
name_c.as_ptr(),
);
dc_log_info(
context,
0,
b"Checking: %s\x00" as *const u8 as *const libc::c_char,
path_plus_name,
);
info!(context, 0, "Checking: {}", as_str(path_plus_name));
free(buf as *mut libc::c_void);
buf = 0 as *mut libc::c_char;
if 0 == dc_read_file(
@@ -1225,12 +1166,11 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
)
.is_null()
{
dc_log_info(
info!(
context,
0i32,
b"Treating \"%s\" as a legacy private key.\x00" as *const u8
as *const libc::c_char,
path_plus_name,
0,
"Treating \"{}\" as a legacy private key.",
as_str(path_plus_name),
);
set_default = 0i32
}
@@ -1240,11 +1180,11 @@ unsafe fn import_self_keys(context: &Context, dir_name: *const libc::c_char) ->
imported_cnt += 1
}
if imported_cnt == 0i32 {
dc_log_error(
error!(
context,
0i32,
b"No private keys found in \"%s\".\x00" as *const u8 as *const libc::c_char,
dir_name,
0,
"No private keys found in \"{}\".",
as_str(dir_name),
);
}
}
@@ -1343,20 +1283,10 @@ unsafe fn export_key_to_asc_file(
id,
)
}
dc_log_info(
context,
0i32,
b"Exporting key %s\x00" as *const u8 as *const libc::c_char,
file_name,
);
info!(context, 0, "Exporting key {}", as_str(file_name),);
dc_delete_file(context, file_name);
if !key.write_asc_to_file(file_name, context) {
dc_log_error(
context,
0i32,
b"Cannot write key to %s\x00" as *const u8 as *const libc::c_char,
file_name,
);
error!(context, 0, "Cannot write key to {}", as_str(file_name),);
} else {
context.call_cb(
Event::IMEX_FILE_WRITTEN,

View File

@@ -12,7 +12,6 @@ use crate::dc_configure::*;
use crate::dc_imex::*;
use crate::dc_jobthread::*;
use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_loginparam::*;
use crate::dc_mimefactory::*;
use crate::dc_msg::*;
@@ -304,21 +303,11 @@ unsafe fn dc_job_do_DC_JOB_SEND(context: &Context, job: &mut dc_job_t) {
13109137661213826276 => {
filename = dc_param_get(job.param, 'f' as i32, 0 as *const libc::c_char);
if filename.is_null() {
dc_log_warning(
context,
0i32,
b"Missing file name for job %d\x00" as *const u8 as *const libc::c_char,
job.job_id,
);
warn!(context, 0, "Missing file name for job {}", job.job_id,);
} 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);
if recipients.is_null() {
dc_log_warning(
context,
0i32,
b"Missing recipients for job %d\x00" as *const u8 as *const libc::c_char,
job.job_id,
);
warn!(context, 0, "Missing recipients for job {}", job.job_id,);
} else {
let recipients_list = std::ffi::CStr::from_ptr(recipients)
.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 */
if 0 != job.foreign_id {
if 0 == dc_msg_exists(context, job.foreign_id) {
dc_log_warning(
warn!(
context,
0i32,
b"Message %i for job %i does not exist\x00" as *const u8
as *const libc::c_char,
0,
"Message {} for job {} does not exist",
job.foreign_id,
job.job_id,
);
@@ -746,12 +734,11 @@ unsafe fn dc_add_smtp_job(
(*mimefactory).rfc724_mid,
);
if pathNfilename.is_null() {
dc_log_error(
error!(
context,
0i32,
b"Could not find free file name for message with ID <%s>.\x00" as *const u8
as *const libc::c_char,
(*mimefactory).rfc724_mid,
0,
"Could not find free file name for message with ID <{}>.",
to_string((*mimefactory).rfc724_mid),
);
} else if 0
== dc_write_file(
@@ -761,12 +748,12 @@ unsafe fn dc_add_smtp_job(
(*(*mimefactory).out).len,
)
{
dc_log_error(
error!(
context,
0i32,
b"Could not write message <%s> to \"%s\".\x00" as *const u8 as *const libc::c_char,
(*mimefactory).rfc724_mid,
pathNfilename,
0,
"Could not write message <{}> to \"{}\".",
to_string((*mimefactory).rfc724_mid),
as_str(pathNfilename),
);
} else {
recipients = dc_str_from_clist(
@@ -837,11 +824,7 @@ pub unsafe fn dc_job_add(
}
pub unsafe fn dc_interrupt_smtp_idle(context: &Context) {
dc_log_info(
context,
0i32,
b"Interrupting SMTP-idle...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Interrupting SMTP-idle...",);
let &(ref lock, ref cvar) = &*context.smtp_state.clone();
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) {
dc_log_info(
context,
0i32,
b"Interrupting IMAP-IDLE...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Interrupting IMAP-IDLE...",);
*context.perform_inbox_jobs_needed.write().unwrap() = 1;
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 */
if dc_rfc724_mid_cnt(context, (*msg).rfc724_mid) != 1i32 {
dc_log_info(
info!(
context,
0i32,
b"The message is deleted from the server when all parts are deleted.\x00"
as *const u8 as *const libc::c_char,
0, "The message is deleted from the server when all parts are deleted.",
);
delete_from_server = 0i32
}
@@ -939,31 +916,19 @@ pub unsafe fn dc_perform_imap_fetch(context: &Context) {
return;
}
if dc_sqlite3_get_config_int(context, &context.sql, "inbox_watch", 1) == 0 {
dc_log_info(
context,
0,
b"INBOX-watch disabled.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "INBOX-watch disabled.",);
return;
}
dc_log_info(
context,
0,
b"INBOX-fetch started...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "INBOX-fetch started...",);
inbox.fetch(context);
if inbox.should_reconnect() {
dc_log_info(
context,
0,
b"INBOX-fetch aborted, starting over...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "INBOX-fetch aborted, starting over...",);
inbox.fetch(context);
}
dc_log_info(
info!(
context,
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,
);
}
@@ -1066,11 +1031,9 @@ pub unsafe fn dc_perform_smtp_idle(context: &Context) {
let mut state = lock.lock().unwrap();
if state.perform_jobs_needed == 1 {
dc_log_info(
info!(
context,
0,
b"SMTP-idle will not be started because of waiting jobs.\x00" as *const u8
as *const libc::c_char,
0, "SMTP-idle will not be started because of waiting jobs.",
);
} else {
let dur = get_next_wakeup_time(context, 5000);
@@ -1088,11 +1051,7 @@ pub unsafe fn dc_perform_smtp_idle(context: &Context) {
}
}
dc_log_info(
context,
0,
b"SMTP-idle ended.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "SMTP-idle ended.",);
}
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);
/* load message data */
if 0 == dc_mimefactory_load_msg(&mut mimefactory, msg_id) || mimefactory.from_addr.is_null() {
dc_log_warning(
warn!(
context,
0i32,
b"Cannot load data to send, maybe the message is deleted in between.\x00" as *const u8
as *const libc::c_char,
0, "Cannot load data to send, maybe the message is deleted in between.",
);
} else {
// 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_chat::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_msg::*;
use crate::dc_param::*;
use crate::dc_saxparser::*;
@@ -472,12 +471,9 @@ pub unsafe fn dc_kml_parse(
};
if content_bytes > (1 * 1024 * 1024) {
dc_log_warning(
warn!(
context,
0,
b"A kml-files with %i bytes is larger than reasonably expected.\x00" as *const u8
as *const libc::c_char,
content_bytes,
0, "A kml-files with {} bytes is larger than reasonably expected.", content_bytes,
);
} else {
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) {
let now = time();
let mut continue_streaming: libc::c_int = 1;
dc_log_info(
info!(
context,
0,
b" ----------------- MAYBE_SEND_LOCATIONS -------------- \x00" as *const u8
as *const libc::c_char,
0, " ----------------- MAYBE_SEND_LOCATIONS -------------- ",
);
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_e2ee::*;
use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_msg::*;
use crate::dc_param::*;
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)
}
if 0 != dc_param_get_int((*msg).param, 'F' as i32, 0) & 0x1 {
dc_log_info(
info!(
(*msg).context,
0,
b"sending secure-join message \'%s\' >>>>>>>>>>>>>>>>>>>>>>>>>\x00"
as *const u8 as *const libc::c_char,
b"vg-member-added\x00" as *const u8 as *const libc::c_char,
"sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>",
"vg-member-added",
);
mailimf_fields_add(
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 =
dc_param_get((*msg).param, 'E' as i32, 0 as *const libc::c_char);
if !step.is_null() {
dc_log_info(
info!(
(*msg).context,
0,
b"sending secure-join message \'%s\' >>>>>>>>>>>>>>>>>>>>>>>>>\x00"
as *const u8 as *const libc::c_char,
step,
"sending secure-join message \'{}\' >>>>>>>>>>>>>>>>>>>>>>>>>",
as_str(step),
);
mailimf_fields_add(
imf_fields,

View File

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

View File

@@ -3,7 +3,6 @@ use crate::context::*;
use crate::dc_chat::*;
use crate::dc_contact::*;
use crate::dc_job::*;
use crate::dc_log::*;
use crate::dc_lot::dc_lot_t;
use crate::dc_lot::*;
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() {
dc_param_set((*msg).param, 'L' as i32, error);
dc_log_error(
context,
0,
b"%s\x00" as *const u8 as *const libc::c_char,
error,
);
error!(context, 0, "{}", as_str(error),);
}
if dc_sqlite3_execute(

View File

@@ -1,7 +1,6 @@
use crate::context::Context;
use crate::dc_chat::*;
use crate::dc_contact::*;
use crate::dc_log::*;
use crate::dc_lot::*;
use crate::dc_param::*;
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;
(*qr_parsed).state = 0i32;
if !qr.is_null() {
dc_log_info(
context,
0i32,
b"Scanned QR code: %s\x00" as *const u8 as *const libc::c_char,
qr,
);
info!(context, 0, "Scanned QR code: {}", as_str(qr),);
/* split parameters from the qr code
------------------------------------ */
if strncasecmp(

View File

@@ -14,7 +14,6 @@ use crate::dc_chat::*;
use crate::dc_contact::*;
use crate::dc_job::*;
use crate::dc_location::*;
use crate::dc_log::*;
use crate::dc_mimeparser::*;
use crate::dc_move::*;
use crate::dc_msg::*;
@@ -82,19 +81,11 @@ pub unsafe fn dc_receive_imf(
);
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() {
dc_log_info(
context,
0,
b"Bad param.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Bad param.",);
} else {
dc_mimeparser_parse(&mut mime_parser, imf_raw_not_terminated, imf_raw_bytes);
if mime_parser.header.is_empty() {
dc_log_info(
context,
0,
b"No header.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "No header.",);
} else {
/* Error - even adding an empty record won't help as we do not know the message ID */
field = dc_mimeparser_lookup_field(
@@ -195,11 +186,7 @@ pub unsafe fn dc_receive_imf(
if rfc724_mid.is_null() {
rfc724_mid = dc_create_incoming_rfc724_mid(sent_timestamp, from_id, to_ids);
if rfc724_mid.is_null() {
dc_log_info(
context,
0,
b"Cannot create Message-ID.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Cannot create Message-ID.",);
current_block = 16282941964262048061;
} else {
current_block = 777662472977924419;
@@ -316,12 +303,9 @@ pub unsafe fn dc_receive_imf(
if chat_id == 0 as libc::c_uint {
if 0 != dc_mimeparser_is_mailinglist_message(&mime_parser) {
chat_id = 3 as uint32_t;
dc_log_info(
info!(
context,
0,
b"Message belongs to a mailing list and is ignored.\x00"
as *const u8
as *const libc::c_char,
0, "Message belongs to a mailing list and is ignored.",
);
}
}
@@ -352,10 +336,11 @@ pub unsafe fn dc_receive_imf(
!= dc_is_reply_to_known_message(context, &mime_parser)
{
dc_scaleup_contact_origin(context, from_id, 0x100);
dc_log_info(context, 0,
b"Message is a reply to a known message, mark sender as known.\x00"
as *const u8 as
*const libc::c_char);
info!(
context,
0,
"Message is a reply to a known message, mark sender as known.",
);
incoming_origin = if incoming_origin > 0x100 {
incoming_origin
} else {
@@ -1343,15 +1328,14 @@ unsafe fn create_or_lookup_group(
}
if 0 != ok {
let chat: *mut Chat = dc_chat_new(context);
dc_log_info(
info!(
context,
0,
b"New group image set to %s.\x00" as *const u8
as *const libc::c_char,
"New group image set to {}.",
if !grpimage.is_null() {
b"DELETED\x00" as *const u8 as *const libc::c_char
"DELETED".to_string()
} else {
grpimage
to_string(grpimage)
},
);
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_contact::*;
use crate::dc_e2ee::*;
use crate::dc_log::*;
use crate::dc_lot::*;
use crate::dc_mimeparser::*;
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 join_vg: libc::c_int = 0i32;
let mut qr_scan: *mut dc_lot_t = 0 as *mut dc_lot_t;
dc_log_info(
context,
0i32,
b"Requesting secure-join ...\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Requesting secure-join ...",);
dc_ensure_secret_key_exists(context);
ongoing_allocated = dc_alloc_ongoing(context);
if !(ongoing_allocated == 0i32) {
qr_scan = dc_check_qr(context, qr);
if qr_scan.is_null() || (*qr_scan).state != 200i32 && (*qr_scan).state != 202i32 {
dc_log_error(
context,
0i32,
b"Unknown QR code.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Unknown QR code.",);
} else {
contact_chat_id = dc_create_chat_by_contact_id(context, (*qr_scan).id);
if contact_chat_id == 0i32 as libc::c_uint {
dc_log_error(
context,
0i32,
b"Unknown contact.\x00" as *const u8 as *const libc::c_char,
);
error!(context, 0, "Unknown contact.",);
} else if !(context
.running_state
.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)
{
dc_log_info(
context,
0i32,
b"Taking protocol shortcut.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Taking protocol shortcut.");
context.bob.clone().write().unwrap().expects = 6;
context.call_cb(
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,
);
if !step.is_null() {
dc_log_info(
info!(
context,
0i32,
b">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message \'%s\' received\x00" as *const u8
as *const libc::c_char,
step,
0,
">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message \'{}\' received",
as_str(step),
);
join_vg = (strncmp(step, b"vg-\x00" as *const u8 as *const libc::c_char, 3) == 0)
as libc::c_int;
@@ -456,12 +438,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
};
if cond {
dc_log_warning(
context,
0i32,
b"auth-required message out of sync.\x00" as *const u8
as *const libc::c_char,
);
warn!(context, 0, "auth-required message out of sync.",);
// no error, just aborted somehow or a mail from another handshake
current_block = 4378276786830486580;
} else {
@@ -501,11 +478,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
end_bobs_joining(context, 0i32);
current_block = 4378276786830486580;
} else {
dc_log_info(
context,
0i32,
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Fingerprint verified.",);
own_fingerprint = get_self_fingerprint(context);
context.call_cb(
Event::SECUREJOIN_JOINER_PROGRESS,
@@ -572,11 +545,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
);
current_block = 4378276786830486580;
} else {
dc_log_info(
context,
0i32,
b"Fingerprint verified.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Fingerprint verified.",);
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
let auth_0: *const libc::c_char;
auth_0 = lookup_field(
@@ -607,11 +576,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
current_block = 4378276786830486580;
} else {
dc_scaleup_contact_origin(context, contact_id, 0x1000000i32);
dc_log_info(
context,
0i32,
b"Auth verified.\x00" as *const u8 as *const libc::c_char,
);
info!(context, 0, "Auth verified.",);
secure_connection_established(context, contact_chat_id);
context.call_cb(
Event::CONTACTS_CHANGED,
@@ -635,12 +600,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
0 as *mut libc::c_int,
);
if group_chat_id == 0i32 as libc::c_uint {
dc_log_error(
context,
0i32,
b"Chat %s not found.\x00" as *const u8 as *const libc::c_char,
grpid,
);
error!(context, 0, "Chat {} not found.", as_str(grpid),);
current_block = 4378276786830486580;
} else {
dc_add_contact_to_chat_ex(
@@ -682,12 +642,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
ret = 0x1i32
}
if context.bob.clone().read().unwrap().expects != 6 {
dc_log_info(
context,
0i32,
b"Message belongs to a different handshake.\x00" as *const u8
as *const libc::c_char,
);
info!(context, 0, "Message belongs to a different handshake.",);
current_block = 4378276786830486580;
} else {
let cond = {
@@ -695,11 +650,9 @@ pub unsafe fn dc_handle_securejoin_handshake(
scan.is_null() || 0 != join_vg && (*scan).state != 202
};
if cond {
dc_log_warning(
warn!(
context,
0i32,
b"Message out of sync or belongs to a different handshake.\x00"
as *const u8 as *const libc::c_char,
0, "Message out of sync or belongs to a different handshake.",
);
current_block = 4378276786830486580;
} else {
@@ -767,10 +720,11 @@ pub unsafe fn dc_handle_securejoin_handshake(
as *const libc::c_char,
),
) {
dc_log_info(context, 0i32,
b"Message belongs to a different handshake (scaled up contact anyway to allow creation of group).\x00"
as *const u8 as
*const libc::c_char);
info!(
context,
0,
"Message belongs to a different handshake (scaled up contact anyway to allow creation of group)."
);
current_block = 4378276786830486580;
} else {
current_block = 9180031981464905198;
@@ -814,12 +768,7 @@ pub unsafe fn dc_handle_securejoin_handshake(
============================================================ */
contact = dc_get_contact(context, contact_id);
if contact.is_null() || 0 == dc_contact_is_verified(contact) {
dc_log_warning(
context,
0i32,
b"vg-member-added-received invalid.\x00" as *const u8
as *const libc::c_char,
);
warn!(context, 0, "vg-member-added-received invalid.",);
current_block = 4378276786830486580;
} else {
context.call_cb(
@@ -920,13 +869,7 @@ unsafe fn could_not_establish_secure_connection(
},
);
dc_add_device_msg(context, contact_chat_id, msg);
dc_log_error(
context,
0i32,
b"%s (%s)\x00" as *const u8 as *const libc::c_char,
msg,
details,
);
error!(context, 0, "{} ({})", as_str(msg), to_string(details),);
free(msg as *mut libc::c_void);
dc_contact_unref(contact);
}
@@ -961,27 +904,15 @@ unsafe fn encrypted_and_signed(
expected_fingerprint: *const libc::c_char,
) -> libc::c_int {
if 0 == mimeparser.e2ee_helper.encrypted {
dc_log_warning(
mimeparser.context,
0i32,
b"Message not encrypted.\x00" as *const u8 as *const libc::c_char,
);
warn!(mimeparser.context, 0, "Message not encrypted.",);
return 0i32;
}
if mimeparser.e2ee_helper.signatures.len() <= 0 {
dc_log_warning(
mimeparser.context,
0i32,
b"Message not signed.\x00" as *const u8 as *const libc::c_char,
);
warn!(mimeparser.context, 0, "Message not signed.",);
return 0i32;
}
if expected_fingerprint.is_null() {
dc_log_warning(
mimeparser.context,
0i32,
b"Fingerprint for comparison missing.\x00" as *const u8 as *const libc::c_char,
);
warn!(mimeparser.context, 0, "Fingerprint for comparison missing.",);
return 0i32;
}
if !mimeparser
@@ -989,14 +920,13 @@ unsafe fn encrypted_and_signed(
.signatures
.contains(as_str(expected_fingerprint))
{
dc_log_warning(
warn!(
mimeparser.context,
0i32,
b"Message does not match expected fingerprint %s.\x00" as *const u8
as *const libc::c_char,
expected_fingerprint,
0,
"Message does not match expected fingerprint {}.",
as_str(expected_fingerprint),
);
return 0i32;
return 0;
}
1

View File

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

View File

@@ -18,7 +18,7 @@ extern crate smallvec;
extern crate rusqlite;
#[macro_use]
pub mod dc_log;
mod log;
pub mod aheader;
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,
>,
);
pub fn vsnprintf(
_: *mut libc::c_char,
_: libc::c_ulong,
_: *const libc::c_char,
_: std::ffi::VaList,
) -> libc::c_int;
// -- DC Methods
pub fn dc_mprintf(format: *const libc::c_char, _: ...) -> *mut libc::c_char;