1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-05 10:39:27 +02:00

refactor logging functions

This commit is contained in:
B. Petersen 2018-06-25 01:23:50 +02:00
parent dac18336d4
commit ae2b68b225
22 changed files with 394 additions and 394 deletions

View file

@ -46,23 +46,23 @@ int mrmailbox_reset_tables(mrmailbox_t* ths, int bits)
return 0;
}
mrmailbox_log_info(ths, 0, "Resetting tables (%i)...", bits);
dc_log_info(ths, 0, "Resetting tables (%i)...", bits);
mrsqlite3_lock(ths->m_sql);
if( bits & 1 ) {
mrsqlite3_execute__(ths->m_sql, "DELETE FROM jobs;");
mrmailbox_log_info(ths, 0, "(1) Jobs reset.");
dc_log_info(ths, 0, "(1) Jobs reset.");
}
if( bits & 2 ) {
mrsqlite3_execute__(ths->m_sql, "DELETE FROM acpeerstates;");
mrmailbox_log_info(ths, 0, "(2) Peerstates reset.");
dc_log_info(ths, 0, "(2) Peerstates reset.");
}
if( bits & 4 ) {
mrsqlite3_execute__(ths->m_sql, "DELETE FROM keypairs;");
mrmailbox_log_info(ths, 0, "(4) Private keypairs reset.");
dc_log_info(ths, 0, "(4) Private keypairs reset.");
}
if( bits & 8 ) {
@ -72,7 +72,7 @@ int mrmailbox_reset_tables(mrmailbox_t* ths, int bits)
mrsqlite3_execute__(ths->m_sql, "DELETE FROM msgs WHERE id>" MR_STRINGIFY(MR_MSG_ID_LAST_SPECIAL) ";");
mrsqlite3_execute__(ths->m_sql, "DELETE FROM config WHERE keyname LIKE 'imap.%' OR keyname LIKE 'configured%';");
mrsqlite3_execute__(ths->m_sql, "DELETE FROM leftgrps;");
mrmailbox_log_info(ths, 0, "(8) Rest but server config reset.");
dc_log_info(ths, 0, "(8) Rest but server config reset.");
}
mrsqlite3_unlock(ths->m_sql);
@ -99,7 +99,7 @@ static int mrmailbox_cleanup_contacts(mrmailbox_t* ths)
return 0;
}
mrmailbox_log_info(ths, 0, "Cleaning up contacts ...");
dc_log_info(ths, 0, "Cleaning up contacts ...");
mrsqlite3_lock(ths->m_sql);
@ -152,7 +152,7 @@ static int poke_public_key(mrmailbox_t* mailbox, const char* addr, const char* p
header->m_prefer_encrypt = MRA_PE_MUTUAL;
if( !mrkey_set_from_file(header->m_public_key, public_key_file, mailbox)
|| !mrpgp_is_valid_key(mailbox, header->m_public_key) ) {
mrmailbox_log_warning(mailbox, 0, "No valid key found in \"%s\".", public_key_file);
dc_log_warning(mailbox, 0, "No valid key found in \"%s\".", public_key_file);
goto cleanup;
}
@ -207,7 +207,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
}
if( !mrsqlite3_is_open(mailbox->m_sql) ) {
mrmailbox_log_error(mailbox, 0, "Import: Database not opened.");
dc_log_error(mailbox, 0, "Import: Database not opened.");
goto cleanup;
}
@ -224,7 +224,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
real_spec = mrsqlite3_get_config__(mailbox->m_sql, "import_spec", NULL); /* may still NULL */
mrsqlite3_unlock(mailbox->m_sql);
if( real_spec == NULL ) {
mrmailbox_log_error(mailbox, 0, "Import: No file or folder given.");
dc_log_error(mailbox, 0, "Import: No file or folder given.");
goto cleanup;
}
}
@ -240,7 +240,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
/* import a publix key */
char* separator = strchr(real_spec, ' ');
if( separator==NULL ) {
mrmailbox_log_error(mailbox, 0, "Import: Key files must be specified as \"<addr> <key-file>\".");
dc_log_error(mailbox, 0, "Import: Key files must be specified as \"<addr> <key-file>\".");
goto cleanup;
}
*separator = 0;
@ -252,7 +252,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
else {
/* import a directory */
if( (dir=opendir(real_spec))==NULL ) {
mrmailbox_log_error(mailbox, 0, "Import: Cannot open directory \"%s\".", real_spec);
dc_log_error(mailbox, 0, "Import: Cannot open directory \"%s\".", real_spec);
goto cleanup;
}
@ -260,7 +260,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
name = dir_entry->d_name; /* name without path; may also be `.` or `..` */
if( strlen(name)>=4 && strcmp(&name[strlen(name)-4], ".eml")==0 ) {
char* path_plus_name = mr_mprintf("%s/%s", real_spec, name);
mrmailbox_log_info(mailbox, 0, "Import: %s", path_plus_name);
dc_log_info(mailbox, 0, "Import: %s", path_plus_name);
if( mrmailbox_poke_eml_file(mailbox, path_plus_name) ) { /* no abort on single errors errors are logged in any case */
read_cnt++;
}
@ -269,7 +269,7 @@ static int poke_spec(mrmailbox_t* mailbox, const char* spec)
}
}
mrmailbox_log_info(mailbox, 0, "Import: %i items read from \"%s\".", read_cnt, real_spec);
dc_log_info(mailbox, 0, "Import: %i items read from \"%s\".", read_cnt, real_spec);
if( read_cnt > 0 ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0); /* even if read_cnt>0, the number of messages added to the database may be 0. While we regard this issue using IMAP, we ignore it here. */
}
@ -291,10 +291,10 @@ static void log_msglist(mrmailbox_t* mailbox, mrarray_t* msglist)
{
uint32_t msg_id = mrarray_get_id(msglist, i);
if( msg_id == MR_MSG_ID_DAYMARKER ) {
mrmailbox_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); lines_out++;
dc_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); lines_out++;
}
else if( msg_id > 0 ) {
if( lines_out==0 ) { mrmailbox_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); lines_out++; }
if( lines_out==0 ) { dc_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); lines_out++; }
mrmsg_t* msg = mrmailbox_get_msg(mailbox, msg_id);
mrcontact_t* contact = mrmailbox_get_contact(mailbox, mrmsg_get_from_id(msg));
@ -311,7 +311,7 @@ static void log_msglist(mrmailbox_t* mailbox, mrarray_t* msglist)
char* temp2 = mr_timestamp_to_str(mrmsg_get_timestamp(msg));
char* msgtext = mrmsg_get_text(msg);
mrmailbox_log_info(mailbox, 0, "Msg#%i%s: %s (Contact#%i): %s %s%s%s%s [%s]",
dc_log_info(mailbox, 0, "Msg#%i%s: %s (Contact#%i): %s %s%s%s%s [%s]",
(int)mrmsg_get_id(msg),
mrmsg_get_showpadlock(msg)? "\xF0\x9F\x94\x92" : "",
contact_name,
@ -331,7 +331,7 @@ static void log_msglist(mrmailbox_t* mailbox, mrarray_t* msglist)
}
}
if( lines_out > 0 ) { mrmailbox_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); }
if( lines_out > 0 ) { dc_log_info(mailbox, 0, "--------------------------------------------------------------------------------"); }
}
@ -372,7 +372,7 @@ static void log_contactlist(mrmailbox_t* mailbox, mrarray_t* contacts)
else {
line = safe_strdup("Read error.");
}
mrmailbox_log_info(mailbox, 0, "Contact#%i: %s%s", (int)contact_id, line, line2? line2:"");
dc_log_info(mailbox, 0, "Contact#%i: %s%s", (int)contact_id, line, line2? line2:"");
free(line);
free(line2);
}
@ -696,14 +696,14 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
if( chatlist ) {
int i, cnt = mrchatlist_get_cnt(chatlist);
if( cnt>0 ) {
mrmailbox_log_info(mailbox, 0, "================================================================================");
dc_log_info(mailbox, 0, "================================================================================");
for( i = cnt-1; i >= 0; i-- )
{
mrchat_t* chat = mrmailbox_get_chat(mailbox, mrchatlist_get_chat_id(chatlist, i));
char* temp_subtitle = mrchat_get_subtitle(chat);
char* temp_name = mrchat_get_name(chat);
mrmailbox_log_info(mailbox, 0, "%s#%i: %s [%s] [%i fresh]",
dc_log_info(mailbox, 0, "%s#%i: %s [%s] [%i fresh]",
chat_prefix(chat),
(int)mrchat_get_id(chat), temp_name, temp_subtitle, (int)mrmailbox_get_fresh_msg_count(mailbox, mrchat_get_id(chat)));
free(temp_subtitle);
@ -725,7 +725,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
char* timestr = mr_timestamp_to_str(mrlot_get_timestamp(lot));
char* text1 = mrlot_get_text1(lot);
char* text2 = mrlot_get_text2(lot);
mrmailbox_log_info(mailbox, 0, "%s%s%s%s [%s]",
dc_log_info(mailbox, 0, "%s%s%s%s [%s]",
text1? text1 : "",
text1? ": " : "",
text2? text2 : "",
@ -739,7 +739,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
mrchat_unref(chat);
mrmailbox_log_info(mailbox, 0, "================================================================================");
dc_log_info(mailbox, 0, "================================================================================");
}
}
ret = mr_mprintf("%i chats.", (int)cnt);
@ -766,7 +766,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
mrarray_t* msglist = mrmailbox_get_chat_msgs(mailbox, mrchat_get_id(sel_chat), MR_GCM_ADDDAYMARKER, 0);
char* temp2 = mrchat_get_subtitle(sel_chat);
char* temp_name = mrchat_get_name(sel_chat);
mrmailbox_log_info(mailbox, 0, "%s#%i: %s [%s]", chat_prefix(sel_chat), mrchat_get_id(sel_chat), temp_name, temp2);
dc_log_info(mailbox, 0, "%s#%i: %s [%s]", chat_prefix(sel_chat), mrchat_get_id(sel_chat), temp_name, temp2);
free(temp_name);
free(temp2);
if( msglist ) {
@ -776,7 +776,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
if( mrchat_get_draft_timestamp(sel_chat) ) {
char* timestr = mr_timestamp_to_str(mrchat_get_draft_timestamp(sel_chat));
char* drafttext = mrchat_get_draft(sel_chat);
mrmailbox_log_info(mailbox, 0, "Draft: %s [%s]", drafttext, timestr);
dc_log_info(mailbox, 0, "Draft: %s [%s]", drafttext, timestr);
free(drafttext);
free(timestr);
}
@ -904,7 +904,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
if( sel_chat ) {
mrarray_t* contacts = mrmailbox_get_chat_contacts(mailbox, mrchat_get_id(sel_chat));
if( contacts ) {
mrmailbox_log_info(mailbox, 0, "Memberlist:");
dc_log_info(mailbox, 0, "Memberlist:");
log_contactlist(mailbox, contacts);
ret = mr_mprintf("%i contacts.", (int)mrarray_get_cnt(contacts));
}

View file

@ -392,7 +392,7 @@ int mrchatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* que
success = 1;
cleanup:
//mrmailbox_log_info(ths->m_mailbox, 0, "Chatlist for search \"%s\" created in %.3f ms.", query__?query__:"", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
//dc_log_info(ths->m_mailbox, 0, "Chatlist for search \"%s\" created in %.3f ms.", query__?query__:"", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
free(query);
free(strLikeCmd);

View file

@ -38,10 +38,10 @@
static char* read_autoconf_file(mrmailbox_t* mailbox, const char* url)
{
char* filecontent = NULL;
mrmailbox_log_info(mailbox, 0, "Testing %s ...", url);
filecontent = (char*)mailbox->m_cb(mailbox, MR_EVENT_HTTP_GET, (uintptr_t)url, 0);
dc_log_info(mailbox, 0, "Testing %s ...", url);
filecontent = (char*)mailbox->m_cb(mailbox, DC_EVENT_HTTP_GET, (uintptr_t)url, 0);
if( filecontent == NULL ) {
mrmailbox_log_info(mailbox, 0, "Can't read file."); /* this is not a warning or an error, we're just testing */
dc_log_info(mailbox, 0, "Can't read file."); /* this is not a warning or an error, we're just testing */
return NULL;
}
return filecontent;
@ -190,7 +190,7 @@ static mrloginparam_t* moz_autoconfigure(mrmailbox_t* mailbox, const char* url,
|| moz_ac.m_out->m_send_server == NULL
|| moz_ac.m_out->m_send_port == 0 )
{
{ char* r = mrloginparam_get_readable(moz_ac.m_out); mrmailbox_log_warning(mailbox, 0, "Bad or incomplete autoconfig: %s", r); free(r); }
{ char* r = mrloginparam_get_readable(moz_ac.m_out); dc_log_warning(mailbox, 0, "Bad or incomplete autoconfig: %s", r); free(r); }
mrloginparam_unref(moz_ac.m_out); /* autoconfig failed for the given URL */
moz_ac.m_out = NULL;
@ -342,7 +342,7 @@ static mrloginparam_t* outlk_autodiscover(mrmailbox_t* mailbox, const char* url_
|| outlk_ad.m_out->m_send_server == NULL
|| outlk_ad.m_out->m_send_port == 0 )
{
{ char* r = mrloginparam_get_readable(outlk_ad.m_out); mrmailbox_log_warning(mailbox, 0, "Bad or incomplete autoconfig: %s", r); free(r); }
{ char* r = mrloginparam_get_readable(outlk_ad.m_out); dc_log_warning(mailbox, 0, "Bad or incomplete autoconfig: %s", r); free(r); }
mrloginparam_unref(outlk_ad.m_out); /* autoconfig failed for the given URL */
outlk_ad.m_out = NULL;
goto cleanup;
@ -385,10 +385,10 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
#define PROGRESS(p) \
if( mr_shall_stop_ongoing ) { goto cleanup; } \
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, (p)<1? 1 : ((p)>999? 999 : (p)), 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, (p)<1? 1 : ((p)>999? 999 : (p)), 0);
if( !mrsqlite3_is_open(mailbox->m_sql) ) {
mrmailbox_log_error(mailbox, 0, "Cannot configure, database not opened.");
dc_log_error(mailbox, 0, "Cannot configure, database not opened.");
goto cleanup;
}
@ -407,12 +407,12 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mrmailbox_log_info(mailbox, 0, "Configure ...");
dc_log_info(mailbox, 0, "Configure ...");
PROGRESS(0)
if( mailbox->m_cb(mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
mrmailbox_log_error(mailbox, MR_ERR_NONETWORK, NULL);
if( mailbox->m_cb(mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
dc_log_error(mailbox, DC_ERROR_NO_NETWORK, NULL);
goto cleanup;
}
@ -432,14 +432,14 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
locked = 0;
if( param->m_addr == NULL ) {
mrmailbox_log_error(mailbox, 0, "Please enter the email address.");
dc_log_error(mailbox, 0, "Please enter the email address.");
goto cleanup;
}
mr_trim(param->m_addr);
param_domain = strchr(param->m_addr, '@');
if( param_domain==NULL || param_domain[0]==0 ) {
mrmailbox_log_error(mailbox, 0, "Bad email-address.");
dc_log_error(mailbox, 0, "Bad email-address.");
goto cleanup;
}
param_domain++;
@ -507,7 +507,7 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
/* C. Do we have any result? */
if( param_autoconfig )
{
{ char* r = mrloginparam_get_readable(param_autoconfig); mrmailbox_log_info(mailbox, 0, "Got autoconfig: %s", r); free(r); }
{ char* r = mrloginparam_get_readable(param_autoconfig); dc_log_info(mailbox, 0, "Got autoconfig: %s", r); free(r); }
if( param_autoconfig->m_mail_user ) {
free(param->m_mail_user);
@ -611,14 +611,14 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
|| param->m_send_pw == NULL
|| param->m_server_flags == 0 )
{
mrmailbox_log_error(mailbox, 0, "Account settings incomplete.");
dc_log_error(mailbox, 0, "Account settings incomplete.");
goto cleanup;
}
PROGRESS(600)
/* try to connect to IMAP */
{ char* r = mrloginparam_get_readable(param); mrmailbox_log_info(mailbox, 0, "Trying: %s", r); free(r); }
{ char* r = mrloginparam_get_readable(param); dc_log_info(mailbox, 0, "Trying: %s", r); free(r); }
if( !mrimap_connect(mailbox->m_imap, param) ) {
goto cleanup;
@ -639,7 +639,7 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
param->m_server_flags &= ~MR_SMTP_SOCKET_FLAGS;
param->m_server_flags |= MR_SMTP_SOCKET_STARTTLS;
param->m_send_port = TYPICAL_SMTP_STARTTLS_PORT;
{ char* r = mrloginparam_get_readable(param); mrmailbox_log_info(mailbox, 0, "Trying: %s", r); free(r); }
{ char* r = mrloginparam_get_readable(param); dc_log_info(mailbox, 0, "Trying: %s", r); free(r); }
if( !mrsmtp_connect(mailbox->m_smtp, param) ) {
goto cleanup;
@ -668,30 +668,30 @@ void mrjob_do_MRJ_CONFIGURE_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
mrmailbox_ensure_secret_key_exists(mailbox);
success = 1;
mrmailbox_log_info(mailbox, 0, "Configure completed successfully.");
dc_log_info(mailbox, 0, "Configure completed successfully.");
PROGRESS(940)
cleanup:
if( locked ) { mrsqlite3_unlock(mailbox->m_sql); }
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, 950, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 950, 0);
if( imap_connected_here ) { mrimap_disconnect(mailbox->m_imap); }
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, 960, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 960, 0);
if( smtp_connected_here ) { mrsmtp_disconnect(mailbox->m_smtp); }
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, 970, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 970, 0);
mrloginparam_unref(param);
mrloginparam_unref(param_autoconfig);
free(param_addr_urlencoded);
if( ongoing_allocated_here ) { mrmailbox_free_ongoing(mailbox); }
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, 980, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 980, 0);
mrmailbox_suspend_smtp_thread(mailbox, 0);
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, 990, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 990, 0);
mailbox->m_cb(mailbox, MR_EVENT_CONFIGURE_PROGRESS, success? 1000 : 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, success? 1000 : 0, 0);
}
@ -780,7 +780,7 @@ int mrmailbox_alloc_ongoing(mrmailbox_t* mailbox)
}
if( s_ongoing_running || mr_shall_stop_ongoing == 0 ) {
mrmailbox_log_warning(mailbox, 0, "There is already another ongoing process running.");
dc_log_warning(mailbox, 0, "There is already another ongoing process running.");
return 0;
}
@ -837,11 +837,11 @@ void dc_stop_ongoing_process(dc_context_t* mailbox)
if( s_ongoing_running && mr_shall_stop_ongoing==0 )
{
mrmailbox_log_info(mailbox, 0, "Signaling the ongoing process to stop ASAP.");
dc_log_info(mailbox, 0, "Signaling the ongoing process to stop ASAP.");
mr_shall_stop_ongoing = 1;
}
else
{
mrmailbox_log_info(mailbox, 0, "No ongoing process to stop.");
dc_log_info(mailbox, 0, "No ongoing process to stop.");
}
}

View file

@ -898,7 +898,7 @@ uint32_t dc_create_chat_by_contact_id(dc_context_t* mailbox, uint32_t contact_id
}
if( 0==mrmailbox_real_contact_exists__(mailbox, contact_id) && contact_id!=MR_CONTACT_ID_SELF ) {
mrmailbox_log_warning(mailbox, 0, "Cannot create chat, contact %i does not exist.", (int)contact_id);
dc_log_warning(mailbox, 0, "Cannot create chat, contact %i does not exist.", (int)contact_id);
goto cleanup;
}
@ -913,7 +913,7 @@ cleanup:
if( locked ) { mrsqlite3_unlock(mailbox->m_sql); }
if( send_event ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
}
return chat_id;
@ -983,7 +983,7 @@ cleanup:
mrmsg_unref(msg);
mrchat_unref(chat);
if( send_event ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
}
return chat_id;
}
@ -1333,7 +1333,7 @@ dc_array_t* dc_get_chat_msgs(dc_context_t* mailbox, uint32_t chat_id, uint32_t f
cleanup:
if( locked ) { mrsqlite3_unlock(mailbox->m_sql); }
//mrmailbox_log_info(mailbox, 0, "Message list for chat #%i created in %.3f ms.", chat_id, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
//dc_log_info(mailbox, 0, "Message list for chat #%i created in %.3f ms.", chat_id, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
if( success ) {
return ret;
@ -1443,7 +1443,7 @@ cleanup:
free(strLikeBeg);
free(real_query);
//mrmailbox_log_info(mailbox, 0, "Message list for search \"%s\" in chat #%i created in %.3f ms.", query, chat_id, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
//dc_log_info(mailbox, 0, "Message list for search \"%s\" in chat #%i created in %.3f ms.", query, chat_id, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
if( success ) {
@ -1505,7 +1505,7 @@ static void set_draft_int(dc_context_t* mailbox, mrchat_t* chat, uint32_t chat_i
mrsqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
cleanup:
mrchat_unref(chat_to_delete);
@ -1819,7 +1819,7 @@ void dc_archive_chat(dc_context_t* mailbox, uint32_t chat_id, int archive)
sqlite3_finalize(stmt);
mrsqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
}
@ -1914,7 +1914,7 @@ void dc_delete_chat(dc_context_t* mailbox, uint32_t chat_id)
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
cleanup:
if( pending_transaction ) { mrsqlite3_rollback__(mailbox->m_sql); }
@ -1957,19 +1957,19 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
uint32_t msg_id = 0, to_id = 0;
if( !MR_CHAT_TYPE_CAN_SEND(chat->m_type) ) {
mrmailbox_log_error(mailbox, 0, "Cannot send to chat type #%i.", chat->m_type);
dc_log_error(mailbox, 0, "Cannot send to chat type #%i.", chat->m_type);
goto cleanup;
}
if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) && !mrmailbox_is_contact_in_chat__(mailbox, chat->m_id, MR_CONTACT_ID_SELF) ) {
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup;
}
{
char* from = mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", NULL);
if( from == NULL ) {
mrmailbox_log_error(mailbox, 0, "Cannot send message, not configured successfully.");
dc_log_error(mailbox, 0, "Cannot send message, not configured successfully.");
goto cleanup;
}
rfc724_mid = mr_create_outgoing_rfc724_mid(MR_CHAT_TYPE_IS_MULTI(chat->m_type)? chat->m_grpid : NULL, from);
@ -1982,7 +1982,7 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
"SELECT contact_id FROM chats_contacts WHERE chat_id=?;");
sqlite3_bind_int(stmt, 1, chat->m_id);
if( sqlite3_step(stmt) != SQLITE_ROW ) {
mrmailbox_log_error(mailbox, 0, "Cannot send message, contact for chat #%i not found.", chat->m_id);
dc_log_error(mailbox, 0, "Cannot send message, contact for chat #%i not found.", chat->m_id);
goto cleanup;
}
to_id = sqlite3_column_int(stmt, 0);
@ -2056,7 +2056,7 @@ static uint32_t mrmailbox_send_msg_i__(mrmailbox_t* mailbox, mrchat_t* chat, con
sqlite3_bind_text (stmt, 9, msg->m_param->m_packed, -1, SQLITE_STATIC);
sqlite3_bind_int (stmt, 10, msg->m_hidden);
if( sqlite3_step(stmt) != SQLITE_DONE ) {
mrmailbox_log_error(mailbox, 0, "Cannot send message, cannot insert to database.", chat->m_id);
dc_log_error(mailbox, 0, "Cannot send message, cannot insert to database.", chat->m_id);
goto cleanup;
}
@ -2151,7 +2151,7 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, mrms
free(buf);
}
mrmailbox_log_info(mailbox, 0, "Attaching \"%s\" for message type #%i.", pathNfilename, (int)msg->m_type);
dc_log_info(mailbox, 0, "Attaching \"%s\" for message type #%i.", pathNfilename, (int)msg->m_type);
if( msg->m_text ) { free(msg->m_text); }
if( msg->m_type == MR_MSG_AUDIO ) {
@ -2172,13 +2172,13 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, mrms
}
else
{
mrmailbox_log_error(mailbox, 0, "Attachment missing for message of type #%i.", (int)msg->m_type); /* should not happen */
dc_log_error(mailbox, 0, "Attachment missing for message of type #%i.", (int)msg->m_type); /* should not happen */
goto cleanup;
}
}
else
{
mrmailbox_log_error(mailbox, 0, "Cannot send messages of type #%i.", (int)msg->m_type); /* should not happen */
dc_log_error(mailbox, 0, "Cannot send messages of type #%i.", (int)msg->m_type); /* should not happen */
goto cleanup;
}
@ -2207,7 +2207,7 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, mrms
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
cleanup:
if( transaction_pending ) { mrsqlite3_rollback__(mailbox->m_sql); }
@ -2577,7 +2577,7 @@ uint32_t mrmailbox_add_device_msg(mrmailbox_t* mailbox, uint32_t chat_id, const
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg_id);
cleanup:
if( locked ) { mrsqlite3_unlock(mailbox->m_sql); }
@ -2718,7 +2718,7 @@ cleanup:
free(grpid);
if( chat_id ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
}
return chat_id;
@ -2769,7 +2769,7 @@ int dc_set_chat_name(dc_context_t* mailbox, uint32_t chat_id, const char* new_na
}
if( !IS_SELF_IN_GROUP__ ) {
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup; /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
}
@ -2788,9 +2788,9 @@ int dc_set_chat_name(dc_context_t* mailbox, uint32_t chat_id, const char* new_na
msg->m_text = mrstock_str_repl_string2(MR_STR_MSGGRPNAME, chat->m_name, new_name);
mrparam_set_int(msg->m_param, MRP_CMD, MR_CMD_GROUPNAME_CHANGED);
msg->m_id = mrmailbox_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
success = 1;
@ -2843,7 +2843,7 @@ int dc_set_chat_profile_image(dc_context_t* mailbox, uint32_t chat_id, const cha
}
if( !IS_SELF_IN_GROUP__ ) {
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup; /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
}
@ -2863,9 +2863,9 @@ int dc_set_chat_profile_image(dc_context_t* mailbox, uint32_t chat_id, const cha
msg->m_type = MR_MSG_TEXT;
msg->m_text = mrstock_str(new_image? MR_STR_MSGGRPIMGCHANGED : MR_STR_MSGGRPIMGDELETED);
msg->m_id = mrmailbox_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
success = 1;
@ -2956,7 +2956,7 @@ int mrmailbox_add_contact_to_chat_ex(mrmailbox_t* mailbox, uint32_t chat_id, uin
}
if( !IS_SELF_IN_GROUP__ ) {
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup; /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
}
@ -2985,7 +2985,7 @@ int mrmailbox_add_contact_to_chat_ex(mrmailbox_t* mailbox, uint32_t chat_id, uin
{
if( !mrapeerstate_load_by_addr__(peerstate, mailbox->m_sql, contact->m_addr)
|| mrcontact_is_verified__(contact, peerstate) != MRV_BIDIRECTIONAL ) {
mrmailbox_log_error(mailbox, 0, "Only bidirectional verified contacts can be added to verfied groups.");
dc_log_error(mailbox, 0, "Only bidirectional verified contacts can be added to verfied groups.");
goto cleanup;
}
}
@ -3007,9 +3007,9 @@ int mrmailbox_add_contact_to_chat_ex(mrmailbox_t* mailbox, uint32_t chat_id, uin
mrparam_set (msg->m_param, MRP_CMD_PARAM, contact->m_addr);
mrparam_set_int(msg->m_param, MRP_CMD_PARAM2,flags); // combine the Secure-Join protocol headers with the Chat-Group-Member-Added header
msg->m_id = mrmailbox_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
success = 1;
@ -3089,7 +3089,7 @@ int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_
}
if( !IS_SELF_IN_GROUP__ ) {
mrmailbox_log_error(mailbox, MR_ERR_SELF_NOT_IN_GROUP, NULL);
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup; /* we shoud respect this - whatever we send to the group, it gets discarded anyway! */
}
@ -3113,7 +3113,7 @@ int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_
mrparam_set_int(msg->m_param, MRP_CMD, MR_CMD_MEMBER_REMOVED_FROM_GROUP);
mrparam_set (msg->m_param, MRP_CMD_PARAM, contact->m_addr);
msg->m_id = mrmailbox_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
}
@ -3128,7 +3128,7 @@ int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
success = 1;
@ -3216,7 +3216,7 @@ uint32_t mrmailbox_add_or_lookup_contact__( mrmailbox_t* mailbox,
/* rough check if email-address is valid */
if( strlen(addr) < 3 || strchr(addr, '@')==NULL || strchr(addr, '.')==NULL ) {
mrmailbox_log_warning(mailbox, 0, "Bad address \"%s\" for contact \"%s\".", addr, name?name:"<unset>");
dc_log_warning(mailbox, 0, "Bad address \"%s\" for contact \"%s\".", addr, name?name:"<unset>");
goto cleanup;
}
@ -3295,7 +3295,7 @@ uint32_t mrmailbox_add_or_lookup_contact__( mrmailbox_t* mailbox,
}
else
{
mrmailbox_log_error(mailbox, 0, "Cannot add contact."); /* should not happen */
dc_log_error(mailbox, 0, "Cannot add contact."); /* should not happen */
}
}
@ -3403,7 +3403,7 @@ uint32_t dc_create_contact(dc_context_t* mailbox, const char* name, const char*
mrsqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, MR_EVENT_CONTACTS_CHANGED, sth_modified==CONTACT_CREATED? contact_id : 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONTACTS_CHANGED, sth_modified==CONTACT_CREATED? contact_id : 0, 0);
if( blocked ) {
mrmailbox_block_contact(mailbox, contact_id, 0);
@ -3802,7 +3802,7 @@ void dc_block_contact(dc_context_t* mailbox, uint32_t contact_id, int new_blocki
locked = 0;
if( send_event ) {
mailbox->m_cb(mailbox, MR_EVENT_CONTACTS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONTACTS_CHANGED, 0, 0);
}
cleanup:
@ -3990,7 +3990,7 @@ int dc_delete_contact(dc_context_t* mailbox, uint32_t contact_id)
mrsqlite3_unlock(mailbox->m_sql);
locked = 0;
mailbox->m_cb(mailbox, MR_EVENT_CONTACTS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONTACTS_CHANGED, 0, 0);
success = 1;
@ -4450,7 +4450,7 @@ cleanup:
if( created_db_entries ) {
size_t i, icnt = carray_count(created_db_entries);
for( i = 0; i < icnt; i += 2 ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, (uintptr_t)carray_get(created_db_entries, i), (uintptr_t)carray_get(created_db_entries, i+1));
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, (uintptr_t)carray_get(created_db_entries, i), (uintptr_t)carray_get(created_db_entries, i+1));
}
carray_free(created_db_entries);
}
@ -4599,7 +4599,7 @@ void dc_markseen_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cn
{
if( curr_state == MR_STATE_IN_FRESH || curr_state == MR_STATE_IN_NOTICED ) {
mrmailbox_update_msg_state__(mailbox, msg_ids[i], MR_STATE_IN_SEEN);
mrmailbox_log_info(mailbox, 0, "Seen message #%i.", msg_ids[i]);
dc_log_info(mailbox, 0, "Seen message #%i.", msg_ids[i]);
mrjob_add(mailbox, MRJ_MARKSEEN_MSG_ON_IMAP, msg_ids[i], NULL, 0); /* results in a call to mrmailbox_markseen_msg_on_imap() */
send_event = 1;
}
@ -4621,7 +4621,7 @@ void dc_markseen_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cn
/* the event is needed eg. to remove the deaddrop from the chatlist */
if( send_event ) {
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, 0, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, 0, 0);
}
cleanup:

View file

@ -104,10 +104,10 @@ struct _dc_context
/* logging and error handling */
void mrmailbox_log_error (mrmailbox_t*, int code, const char* msg, ...);
void mrmailbox_log_error_if (int* condition, mrmailbox_t*, int code, const char* msg, ...);
void mrmailbox_log_warning (mrmailbox_t*, int code, const char* msg, ...);
void mrmailbox_log_info (mrmailbox_t*, int code, const char* msg, ...);
void dc_log_error (dc_context_t*, int code, const char* msg, ...);
void dc_log_error_if (int* condition, dc_context_t*, int code, const char* msg, ...);
void dc_log_warning (dc_context_t*, int code, const char* msg, ...);
void dc_log_info (dc_context_t*, int code, const char* msg, ...);
/* misc.*/
@ -185,8 +185,8 @@ extern int mr_shall_stop_ongoing;
int mrmailbox_alloc_ongoing (mrmailbox_t*);
void mrmailbox_free_ongoing (mrmailbox_t*);
#define dc_is_online(m) ((m)->m_cb((m), MR_EVENT_IS_OFFLINE, 0, 0)==0)
#define dc_is_offline(m) ((m)->m_cb((m), MR_EVENT_IS_OFFLINE, 0, 0)!=0)
#define dc_is_online(m) ((m)->m_cb((m), DC_EVENT_IS_OFFLINE, 0, 0)==0)
#define dc_is_offline(m) ((m)->m_cb((m), DC_EVENT_IS_OFFLINE, 0, 0)!=0)
/* library private: secure-join */

View file

@ -233,7 +233,7 @@ static int load_or_generate_self_public_key__(mrmailbox_t* mailbox, mrkey_t* pub
{
mrkey_t* private_key = mrkey_new();
mrmailbox_log_info(mailbox, 0, "Generating keypair ...");
dc_log_info(mailbox, 0, "Generating keypair ...");
mrsqlite3_unlock(mailbox->m_sql); /* SIC! unlock database during creation - otherwise the GUI may hang */
@ -249,22 +249,22 @@ static int load_or_generate_self_public_key__(mrmailbox_t* mailbox, mrkey_t* pub
mrsqlite3_lock(mailbox->m_sql);
if( !key_created ) {
mrmailbox_log_warning(mailbox, 0, "Cannot create keypair.");
dc_log_warning(mailbox, 0, "Cannot create keypair.");
goto cleanup;
}
if( !mrpgp_is_valid_key(mailbox, public_key)
|| !mrpgp_is_valid_key(mailbox, private_key) ) {
mrmailbox_log_warning(mailbox, 0, "Generated keys are not valid.");
dc_log_warning(mailbox, 0, "Generated keys are not valid.");
goto cleanup;
}
if( !mrkey_save_self_keypair__(public_key, private_key, self_addr, 1/*set default*/, mailbox->m_sql) ) {
mrmailbox_log_warning(mailbox, 0, "Cannot save keypair.");
dc_log_warning(mailbox, 0, "Cannot save keypair.");
goto cleanup;
}
mrmailbox_log_info(mailbox, 0, "Keypair generated.");
dc_log_info(mailbox, 0, "Keypair generated.");
mrkey_unref(private_key);
}
@ -294,7 +294,7 @@ int mrmailbox_ensure_secret_key_exists(mrmailbox_t* mailbox)
locked = 1;
if( (self_addr=mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", NULL))==NULL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot ensure secret key if mailbox is not configured.");
dc_log_warning(mailbox, 0, "Cannot ensure secret key if mailbox is not configured.");
goto cleanup;
}
@ -792,7 +792,7 @@ static mrhash_t* update_gossip_peerstates(mrmailbox_t* mailbox, time_t message_t
}
else
{
mrmailbox_log_info(mailbox, 0, "Ignoring gossipped \"%s\" as the address is not in To/Cc list.", gossip_header->m_addr);
dc_log_info(mailbox, 0, "Ignoring gossipped \"%s\" as the address is not in To/Cc list.", gossip_header->m_addr);
}
}
mraheader_unref(gossip_header);

View file

@ -52,7 +52,7 @@ static int is_error(mrimap_t* ths, int code)
if( code == MAILIMAP_ERROR_STREAM /*4*/
|| code == MAILIMAP_ERROR_PARSE /*5*/ )
{
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP stream lost; we'll reconnect soon.");
dc_log_info(ths->m_mailbox, 0, "IMAP stream lost; we'll reconnect soon.");
ths->m_should_reconnect = 1;
}
@ -221,12 +221,12 @@ static clist* list_folders__(mrimap_t* ths)
if( is_error(ths, r) || imap_list==NULL ) {
imap_list = NULL;
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot get folder list.");
dc_log_warning(ths->m_mailbox, 0, "Cannot get folder list.");
goto cleanup;
}
if( clist_count(imap_list)<=0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Folder list is empty.");
dc_log_warning(ths->m_mailbox, 0, "Folder list is empty.");
goto cleanup;
}
@ -337,23 +337,23 @@ static int init_chat_folders__(mrimap_t* ths)
}
if( chats_folder == NULL && (ths->m_server_flags&MR_NO_MOVE_TO_CHATS)==0 ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Creating IMAP-folder \"%s\"...", MR_CHATS_FOLDER);
dc_log_info(ths->m_mailbox, 0, "Creating IMAP-folder \"%s\"...", MR_CHATS_FOLDER);
int r = mailimap_create(ths->m_hEtpan, MR_CHATS_FOLDER);
if( is_error(ths, r) ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using trying INBOX subfolder.");
dc_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using trying INBOX subfolder.");
r = mailimap_create(ths->m_hEtpan, fallback_folder);
if( is_error(ths, r) ) {
/* continue on errors, we'll just use a different folder then */
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using default.");
dc_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using default.");
}
else {
chats_folder = safe_strdup(fallback_folder);
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-folder created (inbox subfolder).");
dc_log_info(ths->m_mailbox, 0, "IMAP-folder created (inbox subfolder).");
}
}
else {
chats_folder = safe_strdup(MR_CHATS_FOLDER);
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-folder created.");
dc_log_info(ths->m_mailbox, 0, "IMAP-folder created.");
}
}
@ -408,7 +408,7 @@ static int select_folder__(mrimap_t* ths, const char* folder /*may be NULL*/)
/* deselect existing folder, if needed (it's also done implicitly by SELECT, however, without EXPUNGE then) */
if( ths->m_selected_folder_needs_expunge ) {
if( ths->m_selected_folder[0] ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Expunge messages in \"%s\".", ths->m_selected_folder);
dc_log_info(ths->m_mailbox, 0, "Expunge messages in \"%s\".", ths->m_selected_folder);
mailimap_close(ths->m_hEtpan); /* a CLOSE-SELECT is considerably faster than an EXPUNGE-SELECT, see https://tools.ietf.org/html/rfc3501#section-6.4.2 */
}
ths->m_selected_folder_needs_expunge = 0;
@ -657,7 +657,7 @@ static int fetch_single_msg(mrimap_t* ths, const char* folder, uint32_t server_u
if( is_error(ths, r) || fetch_result == NULL ) {
fetch_result = NULL;
mrmailbox_log_warning(ths->m_mailbox, 0, "Error #%i on fetching message #%i from folder \"%s\"; retry=%i.", (int)r, (int)server_uid, folder, (int)ths->m_should_reconnect);
dc_log_warning(ths->m_mailbox, 0, "Error #%i on fetching message #%i from folder \"%s\"; retry=%i.", (int)r, (int)server_uid, folder, (int)ths->m_should_reconnect);
if( ths->m_should_reconnect ) {
retry_later = 1; /* maybe we should also retry on other errors, however, we should check this carefully, as this may result in a dead lock! */
}
@ -665,14 +665,14 @@ static int fetch_single_msg(mrimap_t* ths, const char* folder, uint32_t server_u
}
if( (cur=clist_begin(fetch_result)) == NULL ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Message #%i does not exist in folder \"%s\".", (int)server_uid, folder);
dc_log_warning(ths->m_mailbox, 0, "Message #%i does not exist in folder \"%s\".", (int)server_uid, folder);
goto cleanup; /* server response is fine, however, there is no such message, do not try to fetch the message again */
}
struct mailimap_msg_att* msg_att = (struct mailimap_msg_att*)clist_content(cur);
peek_body(msg_att, &msg_content, &msg_bytes, &flags, &deleted);
if( msg_content == NULL || msg_bytes <= 0 || deleted ) {
/* mrmailbox_log_warning(ths->m_mailbox, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */
/* dc_log_warning(ths->m_mailbox, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */
goto cleanup;
}
@ -702,12 +702,12 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
}
if( ths->m_hEtpan==NULL ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Cannot fetch from \"%s\" - not connected.", folder);
dc_log_info(ths->m_mailbox, 0, "Cannot fetch from \"%s\" - not connected.", folder);
goto cleanup;
}
if( select_folder__(ths, folder)==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder);
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder);
goto cleanup;
}
@ -717,13 +717,13 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
{
/* first time this folder is selected or UIDVALIDITY has changed, init lastseenuid and save it to config */
if( ths->m_hEtpan->imap_selection_info->sel_uidvalidity <= 0 ) {
mrmailbox_log_error(ths->m_mailbox, 0, "Cannot get UIDVALIDITY for folder \"%s\".", folder);
dc_log_error(ths->m_mailbox, 0, "Cannot get UIDVALIDITY for folder \"%s\".", folder);
goto cleanup;
}
if( ths->m_hEtpan->imap_selection_info->sel_has_exists ) {
if( ths->m_hEtpan->imap_selection_info->sel_exists <= 0 ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty.", folder);
dc_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty.", folder);
goto cleanup;
}
/* `FETCH <message sequence number> (UID)` */
@ -732,14 +732,14 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
else {
/* `FETCH * (UID)` - according to RFC 3501, `*` represents the largest message sequence number; if the mailbox is empty,
an error resp. an empty list is returned. */
mrmailbox_log_info(ths->m_mailbox, 0, "EXISTS is missing for folder \"%s\", using fallback.", folder);
dc_log_info(ths->m_mailbox, 0, "EXISTS is missing for folder \"%s\", using fallback.", folder);
set = mailimap_set_new_single(0);
}
r = mailimap_fetch(ths->m_hEtpan, set, ths->m_fetch_type_uid, &fetch_result);
mailimap_set_free(set);
if( is_error(ths, r) || fetch_result==NULL || (cur=clist_begin(fetch_result))==NULL ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Empty result returned for folder \"%s\".", folder);
dc_log_info(ths->m_mailbox, 0, "Empty result returned for folder \"%s\".", folder);
goto cleanup; /* this might happen if the mailbox is empty an EXISTS does not work */
}
@ -748,7 +748,7 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
mailimap_fetch_list_free(fetch_result);
fetch_result = NULL;
if( lastseenuid <= 0 ) {
mrmailbox_log_error(ths->m_mailbox, 0, "Cannot get largest UID for folder \"%s\"", folder);
dc_log_error(ths->m_mailbox, 0, "Cannot get largest UID for folder \"%s\"", folder);
goto cleanup;
}
@ -771,10 +771,10 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
{
fetch_result = NULL;
if( r == MAILIMAP_ERROR_PROTOCOL ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty", folder);
dc_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty", folder);
goto cleanup; /* the folder is simply empty, this is no error */
}
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot fetch message list from folder \"%s\".", folder);
dc_log_warning(ths->m_mailbox, 0, "Cannot fetch message list from folder \"%s\".", folder);
goto cleanup;
}
@ -805,10 +805,10 @@ static int fetch_from_single_folder(mrimap_t* ths, const char* folder)
cleanup:
if( read_errors ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "%i mails read from \"%s\" with %i errors.", (int)read_cnt, folder, (int)read_errors);
dc_log_warning(ths->m_mailbox, 0, "%i mails read from \"%s\" with %i errors.", (int)read_cnt, folder, (int)read_errors);
}
else {
mrmailbox_log_info(ths->m_mailbox, 0, "%i mails read from \"%s\".", (int)read_cnt, folder);
dc_log_info(ths->m_mailbox, 0, "%i mails read from \"%s\".", (int)read_cnt, folder);
}
if( fetch_result ) {
@ -841,7 +841,7 @@ static int fetch_from_all_folders(mrimap_t* ths)
{
mrimapfolder_t* folder = (mrimapfolder_t*)clist_content(cur);
if( folder->m_meaning == MEANING_IGNORE ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Ignoring \"%s\".", folder->m_name_utf8);
dc_log_info(ths->m_mailbox, 0, "Ignoring \"%s\".", folder->m_name_utf8);
}
else if( folder->m_meaning != MEANING_INBOX ) {
total_cnt += fetch_from_single_folder(ths, folder->m_name_to_select);
@ -892,7 +892,7 @@ static void fake_idle(mrimap_t* imap)
time_t fake_idle_start_time = time(NULL), seconds_to_wait;
mrmailbox_log_info(imap->m_mailbox, 0, "IMAP-fake-IDLEing...");
dc_log_info(imap->m_mailbox, 0, "IMAP-fake-IDLEing...");
int do_fake_idle = 1;
while( do_fake_idle )
@ -948,7 +948,7 @@ void mrimap_idle(mrimap_t* imap)
if( imap->m_idle_set_up==0 && imap->m_hEtpan && imap->m_hEtpan->imap_stream ) {
r = mailstream_setup_idle(imap->m_hEtpan->imap_stream);
if( is_error(imap, r) ) {
mrmailbox_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot setup.");
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot setup.");
fake_idle(imap);
return;
}
@ -956,14 +956,14 @@ void mrimap_idle(mrimap_t* imap)
}
if( !imap->m_idle_set_up || !select_folder__(imap, "INBOX") ) {
mrmailbox_log_warning(imap->m_mailbox, 0, "IMAP-IDLE not setup.");
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE not setup.");
fake_idle(imap);
return;
}
r = mailimap_idle(imap->m_hEtpan);
if( is_error(imap, r) ) {
mrmailbox_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot start.");
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot start.");
fake_idle(imap);
return;
}
@ -977,20 +977,20 @@ void mrimap_idle(mrimap_t* imap)
r2 = mailimap_idle_done(imap->m_hEtpan);
if( r == MAILSTREAM_IDLE_ERROR /*0*/ || r==MAILSTREAM_IDLE_CANCELLED /*4*/ ) {
mrmailbox_log_info(imap->m_mailbox, 0, "IMAP-IDLE wait cancelled, r=%i, r2=%i; we'll reconnect soon.", r, r2);
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE wait cancelled, r=%i, r2=%i; we'll reconnect soon.", r, r2);
imap->m_should_reconnect = 1;
}
else if( r == MAILSTREAM_IDLE_INTERRUPTED /*1*/ ) {
mrmailbox_log_info(imap->m_mailbox, 0, "IMAP-IDLE interrupted.");
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE interrupted.");
}
else if( r == MAILSTREAM_IDLE_HASDATA /*2*/ ) {
mrmailbox_log_info(imap->m_mailbox, 0, "IMAP-IDLE has data.");
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE has data.");
}
else if( r == MAILSTREAM_IDLE_TIMEOUT /*3*/ ) {
mrmailbox_log_info(imap->m_mailbox, 0, "IMAP-IDLE timeout.");
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE timeout.");
}
else {
mrmailbox_log_warning(imap->m_mailbox, 0, "IMAP-IDLE returns unknown value r=%i, r2=%i.", r, r2);
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE returns unknown value r=%i, r2=%i.", r, r2);
}
}
else
@ -1003,7 +1003,7 @@ void mrimap_idle(mrimap_t* imap)
void mrimap_interrupt_idle(mrimap_t* ths)
{
if( ths==NULL ) { // ths->m_hEtPan may be NULL
mrmailbox_log_warning(ths->m_mailbox, 0, "Interrupt IMAP-IDLE: Bad parameter.");
dc_log_warning(ths->m_mailbox, 0, "Interrupt IMAP-IDLE: Bad parameter.");
return;
}
@ -1044,8 +1044,8 @@ static int setup_handle_if_needed__(mrimap_t* ths)
goto cleanup;
}
if( ths->m_mailbox->m_cb(ths->m_mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, MR_ERR_NONETWORK, NULL);
if( ths->m_mailbox->m_cb(ths->m_mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, DC_ERROR_NO_NETWORK, NULL);
goto cleanup;
}
@ -1057,7 +1057,7 @@ static int setup_handle_if_needed__(mrimap_t* ths)
{
r = mailimap_socket_connect(ths->m_hEtpan, ths->m_imap_server, ths->m_imap_port);
if( is_error(ths, r) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
goto cleanup;
}
@ -1065,24 +1065,24 @@ static int setup_handle_if_needed__(mrimap_t* ths)
{
r = mailimap_socket_starttls(ths->m_hEtpan);
if( is_error(ths, r) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using STARTTLS. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using STARTTLS. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i STARTTLS-connected.", ths->m_imap_server, (int)ths->m_imap_port);
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i STARTTLS-connected.", ths->m_imap_server, (int)ths->m_imap_port);
}
else
{
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i connected.", ths->m_imap_server, (int)ths->m_imap_port);
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i connected.", ths->m_imap_server, (int)ths->m_imap_port);
}
}
else
{
r = mailimap_ssl_connect(ths->m_hEtpan, ths->m_imap_server, ths->m_imap_port);
if( is_error(ths, r) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using SSL. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using SSL. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i SSL-connected.", ths->m_imap_server, (int)ths->m_imap_port);
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i SSL-connected.", ths->m_imap_server, (int)ths->m_imap_port);
}
/* TODO: There are more authorisation types, see mailcore2/MCIMAPSession.cpp, however, I'm not sure of they are really all needed */
@ -1104,11 +1104,11 @@ static int setup_handle_if_needed__(mrimap_t* ths)
}
if( is_error(ths, r) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not login as %s: %s (Error #%i)", ths->m_imap_user, ths->m_hEtpan->imap_response? ths->m_hEtpan->imap_response : "Unknown error.", (int)r);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not login as %s: %s (Error #%i)", ths->m_imap_user, ths->m_hEtpan->imap_response? ths->m_hEtpan->imap_response : "Unknown error.", (int)r);
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-login as %s ok.", ths->m_imap_user);
dc_log_info(ths->m_mailbox, 0, "IMAP-login as %s ok.", ths->m_imap_user);
success = 1;
@ -1143,7 +1143,7 @@ static void unsetup_handle__(mrimap_t* ths)
mailimap_free(ths->m_hEtpan);
ths->m_hEtpan = NULL;
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP disconnected.");
dc_log_info(ths->m_mailbox, 0, "IMAP disconnected.");
}
ths->m_selected_folder[0] = 0;
@ -1232,7 +1232,7 @@ int mrimap_connect(mrimap_t* ths, const mrloginparam_t* lp)
}
}
}
mrmailbox_log_info(ths->m_mailbox, 0, "IMAP-capabilities:%s", capinfostr.m_buf);
dc_log_info(ths->m_mailbox, 0, "IMAP-capabilities:%s", capinfostr.m_buf);
free(capinfostr.m_buf);
}
@ -1363,15 +1363,15 @@ int mrimap_append_msg(mrimap_t* ths, time_t timestamp, const char* data_not_term
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Appending message to IMAP-server...");
dc_log_info(ths->m_mailbox, 0, "Appending message to IMAP-server...");
if( !init_chat_folders__(ths) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot find out IMAP-sent-folder.");
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot find out IMAP-sent-folder.");
goto cleanup;
}
if( !select_folder__(ths, ths->m_sent_folder) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot select IMAP-folder \"%s\".", ths->m_sent_folder);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot select IMAP-folder \"%s\".", ths->m_sent_folder);
ths->m_sent_folder[0] = 0; /* force re-init */
goto cleanup;
}
@ -1381,19 +1381,19 @@ int mrimap_append_msg(mrimap_t* ths, time_t timestamp, const char* data_not_term
imap_date = mr_timestamp_to_mailimap_date_time(timestamp);
if( imap_date == NULL ) {
mrmailbox_log_error(ths->m_mailbox, 0, "Bad date.");
dc_log_error(ths->m_mailbox, 0, "Bad date.");
goto cleanup;
}
r = mailimap_uidplus_append(ths->m_hEtpan, ths->m_sent_folder, flag_list, imap_date, data_not_terminated, data_bytes, &ret_uidvalidity, ret_server_uid);
if( is_error(ths, r) ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot append message to \"%s\", error #%i.", ths->m_sent_folder, (int)r);
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot append message to \"%s\", error #%i.", ths->m_sent_folder, (int)r);
goto cleanup;
}
*ret_server_folder = safe_strdup(ths->m_sent_folder);
mrmailbox_log_info(ths->m_mailbox, 0, "Message appended to \"%s\".", ths->m_sent_folder);
dc_log_info(ths->m_mailbox, 0, "Message appended to \"%s\".", ths->m_sent_folder);
success = 1;
@ -1464,19 +1464,19 @@ int mrimap_markseen_msg(mrimap_t* ths, const char* folder, uint32_t server_uid,
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Marking message %s/%i as seen...", folder, (int)server_uid);
dc_log_info(ths->m_mailbox, 0, "Marking message %s/%i as seen...", folder, (int)server_uid);
if( select_folder__(ths, folder)==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot select folder.");
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder.");
goto cleanup;
}
if( add_flag__(ths, server_uid, mailimap_flag_new_seen())==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot mark message as seen.");
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as seen.");
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Message marked as seen.");
dc_log_info(ths->m_mailbox, 0, "Message marked as seen.");
if( (ms_flags&MR_MS_SET_MDNSent_FLAG)
&& ths->m_hEtpan->imap_selection_info!=NULL && ths->m_hEtpan->imap_selection_info->sel_perm_flags!=NULL )
@ -1517,12 +1517,12 @@ int mrimap_markseen_msg(mrimap_t* ths, const char* folder, uint32_t server_uid,
}
mailimap_fetch_list_free(fetch_result);
}
mrmailbox_log_info(ths->m_mailbox, 0, ((*ret_ms_flags)&MR_MS_MDNSent_JUST_SET)? "$MDNSent just set and MDN will be sent." : "$MDNSent already set and MDN already sent.");
dc_log_info(ths->m_mailbox, 0, ((*ret_ms_flags)&MR_MS_MDNSent_JUST_SET)? "$MDNSent just set and MDN will be sent." : "$MDNSent already set and MDN already sent.");
}
else
{
*ret_ms_flags |= MR_MS_MDNSent_JUST_SET;
mrmailbox_log_info(ths->m_mailbox, 0, "Cannot store $MDNSent flags, risk sending duplicate MDN.");
dc_log_info(ths->m_mailbox, 0, "Cannot store $MDNSent flags, risk sending duplicate MDN.");
}
}
@ -1531,13 +1531,13 @@ int mrimap_markseen_msg(mrimap_t* ths, const char* folder, uint32_t server_uid,
init_chat_folders__(ths);
if( ths->m_moveto_folder && strcmp(folder, ths->m_moveto_folder)==0 )
{
mrmailbox_log_info(ths->m_mailbox, 0, "Message %s/%i is already in %s...", folder, (int)server_uid, ths->m_moveto_folder);
dc_log_info(ths->m_mailbox, 0, "Message %s/%i is already in %s...", folder, (int)server_uid, ths->m_moveto_folder);
/* avoid deadlocks as moving messages in the same folder may be result in a new server_uid and the state "fresh" -
we will catch these messages again on the next poll, try to move them away and so on, see also (***) in mrmailbox.c */
}
else if( ths->m_moveto_folder )
{
mrmailbox_log_info(ths->m_mailbox, 0, "Moving message %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
dc_log_info(ths->m_mailbox, 0, "Moving message %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
/* TODO/TOCHECK: MOVE may not be supported on servers, if this is often the case, we should fallback to a COPY/DELETE implementation.
Same for the UIDPLUS extension (if in doubt, we can find out the resulting UID using "imap_selection_info->sel_uidnext" then). */
@ -1546,16 +1546,16 @@ int mrimap_markseen_msg(mrimap_t* ths, const char* folder, uint32_t server_uid,
struct mailimap_set* res_setdest = NULL;
r = mailimap_uidplus_uid_move(ths->m_hEtpan, set, ths->m_moveto_folder, &res_uid, &res_setsrc, &res_setdest); /* the correct folder is already selected in add_flag__() above */
if( is_error(ths, r) ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Cannot move message, fallback to COPY/DELETE %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
dc_log_info(ths->m_mailbox, 0, "Cannot move message, fallback to COPY/DELETE %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
r = mailimap_uidplus_uid_copy(ths->m_hEtpan, set, ths->m_moveto_folder, &res_uid, &res_setsrc, &res_setdest);
if (is_error(ths, r)) {
mrmailbox_log_info(ths->m_mailbox, 0, "Cannot copy message. Leaving in INBOX");
dc_log_info(ths->m_mailbox, 0, "Cannot copy message. Leaving in INBOX");
goto cleanup;
}
else {
mrmailbox_log_info(ths->m_mailbox, 0, "Deleting msg ...");
dc_log_info(ths->m_mailbox, 0, "Deleting msg ...");
if( add_flag__(ths, server_uid, mailimap_flag_new_deleted())==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\".");/* maybe the message is already deleted */
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\".");/* maybe the message is already deleted */
}
/* force an EXPUNGE resp. CLOSE for the selected folder */
@ -1582,7 +1582,7 @@ int mrimap_markseen_msg(mrimap_t* ths, const char* folder, uint32_t server_uid,
// TODO: If the new UID is equal to lastuid.Chats, we should increase lastuid.Chats by one
// (otherwise, we'll download the mail in moment again from the chats folder ...)
mrmailbox_log_info(ths->m_mailbox, 0, "Message moved.");
dc_log_info(ths->m_mailbox, 0, "Message moved.");
}
}
@ -1606,10 +1606,10 @@ int mrimap_delete_msg(mrimap_t* ths, const char* rfc724_mid, const char* folder,
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Marking message \"%s\", %s/%i for deletion...", rfc724_mid, folder, (int)server_uid);
dc_log_info(ths->m_mailbox, 0, "Marking message \"%s\", %s/%i for deletion...", rfc724_mid, folder, (int)server_uid);
if( select_folder__(ths, folder)==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder); /* maybe the folder does no longer exist */
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder); /* maybe the folder does no longer exist */
goto cleanup;
}
@ -1630,7 +1630,7 @@ int mrimap_delete_msg(mrimap_t* ths, const char* rfc724_mid, const char* folder,
|| (is_rfc724_mid=unquote_rfc724_mid(is_quoted_rfc724_mid))==NULL
|| strcmp(is_rfc724_mid, rfc724_mid)!=0 )
{
mrmailbox_log_warning(ths->m_mailbox, 0, "UID not found in the given folder or does not match Message-ID.");
dc_log_warning(ths->m_mailbox, 0, "UID not found in the given folder or does not match Message-ID.");
server_uid = 0;
}
}
@ -1638,18 +1638,18 @@ int mrimap_delete_msg(mrimap_t* ths, const char* rfc724_mid, const char* folder,
/* server_uid is 0 now if it was not given or if it does not match the given message id;
try to search for it in all folders (the message may be moved by another MUA to a folder we do not sync or the sync is a moment ago) */
if( server_uid == 0 ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Searching UID by Message-ID \"%s\"...", rfc724_mid);
dc_log_info(ths->m_mailbox, 0, "Searching UID by Message-ID \"%s\"...", rfc724_mid);
if( (server_uid=search_uid__(ths, rfc724_mid))==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Message-ID \"%s\" not found in any folder, cannot delete message.", rfc724_mid);
dc_log_warning(ths->m_mailbox, 0, "Message-ID \"%s\" not found in any folder, cannot delete message.", rfc724_mid);
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Message-ID \"%s\" found in %s/%i", rfc724_mid, ths->m_selected_folder, server_uid);
dc_log_info(ths->m_mailbox, 0, "Message-ID \"%s\" found in %s/%i", rfc724_mid, ths->m_selected_folder, server_uid);
}
/* mark the message for deletion */
if( add_flag__(ths, server_uid, mailimap_flag_new_deleted())==0 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\"."); /* maybe the message is already deleted */
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\"."); /* maybe the message is already deleted */
goto cleanup;
}

View file

@ -379,7 +379,7 @@ char* mrmailbox_create_setup_code(dc_context_t* mailbox)
do
{
if( !RAND_bytes((unsigned char*)&random_val, sizeof(uint16_t)) ) {
mrmailbox_log_warning(mailbox, 0, "Falling back to pseudo-number generation for the setup code.");
dc_log_warning(mailbox, 0, "Falling back to pseudo-number generation for the setup code.");
RAND_pseudo_bytes((unsigned char*)&random_val, sizeof(uint16_t));
}
}
@ -523,7 +523,7 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
msg = NULL;
/* wait until the message is really sent */
mrmailbox_log_info(mailbox, 0, "Wait for setup message being sent ...");
dc_log_info(mailbox, 0, "Wait for setup message being sent ...");
while( 1 )
{
@ -539,7 +539,7 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
msg = NULL;
}
mrmailbox_log_info(mailbox, 0, "... setup message sent.");
dc_log_info(mailbox, 0, "... setup message sent.");
success = 1;
@ -567,14 +567,14 @@ static int set_self_key(mrmailbox_t* mailbox, const char* armored, int set_defau
buf = safe_strdup(armored);
if( !mr_split_armored_data(buf, &buf_headerline, NULL, &buf_preferencrypt, &buf_base64)
|| strcmp(buf_headerline, "-----BEGIN PGP PRIVATE KEY BLOCK-----")!=0 || buf_base64 == NULL ) {
mrmailbox_log_warning(mailbox, 0, "File does not contain a private key."); /* do not log as error - this is quite normal after entering the bad setup code */
dc_log_warning(mailbox, 0, "File does not contain a private key."); /* do not log as error - this is quite normal after entering the bad setup code */
goto cleanup;
}
if( !mrkey_set_from_base64(private_key, buf_base64, MR_PRIVATE)
|| !mrpgp_is_valid_key(mailbox, private_key)
|| !mrpgp_split_key(mailbox, private_key, public_key) ) {
mrmailbox_log_error(mailbox, 0, "File does not contain a valid private key.");
dc_log_error(mailbox, 0, "File does not contain a valid private key.");
goto cleanup;
}
@ -595,7 +595,7 @@ static int set_self_key(mrmailbox_t* mailbox, const char* armored, int set_defau
self_addr = mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", NULL);
if( !mrkey_save_self_keypair__(public_key, private_key, self_addr, set_default, mailbox->m_sql) ) {
mrmailbox_log_error(mailbox, 0, "Cannot save keypair.");
dc_log_error(mailbox, 0, "Cannot save keypair.");
goto cleanup;
}
@ -663,22 +663,22 @@ int dc_continue_key_transfer(dc_context_t* mailbox, uint32_t msg_id, const char*
if( (msg=mrmailbox_get_msg(mailbox, msg_id))==NULL || !mrmsg_is_setupmessage(msg)
|| (filename=mrmsg_get_file(msg))==NULL || filename[0]==0 ) {
mrmailbox_log_error(mailbox, 0, "Message is no Autocrypt Setup Message.");
dc_log_error(mailbox, 0, "Message is no Autocrypt Setup Message.");
goto cleanup;
}
if( !mr_read_file(filename, (void**)&filecontent, &filebytes, msg->m_mailbox) || filecontent == NULL || filebytes <= 0 ) {
mrmailbox_log_error(mailbox, 0, "Cannot read Autocrypt Setup Message file.");
dc_log_error(mailbox, 0, "Cannot read Autocrypt Setup Message file.");
goto cleanup;
}
if( (norm_sc = mrmailbox_normalize_setup_code(mailbox, setup_code))==NULL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot normalize Setup Code.");
dc_log_warning(mailbox, 0, "Cannot normalize Setup Code.");
goto cleanup;
}
if( (armored_key=mrmailbox_decrypt_setup_file(mailbox, norm_sc, filecontent)) == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot decrypt Autocrypt Setup Message."); /* do not log as error - this is quite normal after entering the bad setup code */
dc_log_warning(mailbox, 0, "Cannot decrypt Autocrypt Setup Message."); /* do not log as error - this is quite normal after entering the bad setup code */
goto cleanup;
}
@ -712,11 +712,11 @@ static void export_key_to_asc_file(mrmailbox_t* mailbox, const char* dir, int id
else {
file_name = mr_mprintf("%s/%s-key-%i.asc", dir, key->m_type==MR_PUBLIC? "public" : "private", id);
}
mrmailbox_log_info(mailbox, 0, "Exporting key %s", file_name);
dc_log_info(mailbox, 0, "Exporting key %s", file_name);
mr_delete_file(file_name, mailbox);
if( mrkey_render_asc_to_file(key, file_name, mailbox) ) {
mailbox->m_cb(mailbox, MR_EVENT_IMEX_FILE_WRITTEN, (uintptr_t)file_name, 0);
mrmailbox_log_error(mailbox, 0, "Cannot write key to %s", file_name);
mailbox->m_cb(mailbox, DC_EVENT_IMEX_FILE_WRITTEN, (uintptr_t)file_name, 0);
dc_log_error(mailbox, 0, "Cannot write key to %s", file_name);
}
free(file_name);
}
@ -788,7 +788,7 @@ static int import_self_keys(mrmailbox_t* mailbox, const char* dir_name)
goto cleanup;
}
if( (dir_handle=opendir(dir_name))==NULL ) {
mrmailbox_log_error(mailbox, 0, "Import: Cannot open directory \"%s\".", dir_name);
dc_log_error(mailbox, 0, "Import: Cannot open directory \"%s\".", dir_name);
goto cleanup;
}
@ -802,7 +802,7 @@ static int import_self_keys(mrmailbox_t* mailbox, const char* dir_name)
free(path_plus_name);
path_plus_name = mr_mprintf("%s/%s", dir_name, dir_entry->d_name/* name without path; may also be `.` or `..` */);
mrmailbox_log_info(mailbox, 0, "Checking: %s", path_plus_name);
dc_log_info(mailbox, 0, "Checking: %s", path_plus_name);
free(buf);
buf = NULL;
@ -827,7 +827,7 @@ static int import_self_keys(mrmailbox_t* mailbox, const char* dir_name)
set_default = 1;
if( strstr(dir_entry->d_name, "legacy")!=NULL ) {
mrmailbox_log_info(mailbox, 0, "Treating \"%s\" as a legacy private key.", path_plus_name);
dc_log_info(mailbox, 0, "Treating \"%s\" as a legacy private key.", path_plus_name);
set_default = 0; /* a key with "legacy" in its name is not made default; this may result in a keychain with _no_ default, however, this is no problem, as this will create a default key later */
}
@ -839,7 +839,7 @@ static int import_self_keys(mrmailbox_t* mailbox, const char* dir_name)
}
if( imported_count == 0 ) {
mrmailbox_log_error(mailbox, 0, "No private keys found in \"%s\".", dir_name);
dc_log_error(mailbox, 0, "No private keys found in \"%s\".", dir_name);
goto cleanup;
}
@ -865,7 +865,7 @@ The macro avoids weird values of 0% or 100% while still working. */
int permille = (processed_files_count*1000)/total_files_count; \
if( permille < 10 ) { permille = 10; } \
if( permille > 990 ) { permille = 990; } \
mailbox->m_cb(mailbox, MR_EVENT_IMEX_PROGRESS, permille, 0);
mailbox->m_cb(mailbox, DC_EVENT_IMEX_PROGRESS, permille, 0);
static int export_backup(mrmailbox_t* mailbox, const char* dir)
@ -893,7 +893,7 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
timeinfo = localtime(&now);
strftime(buffer, 256, DC_BAK_PREFIX "-%Y-%m-%d." DC_BAK_SUFFIX, timeinfo);
if( (dest_pathNfilename=mr_get_fine_pathNfilename(dir, buffer))==NULL ) {
mrmailbox_log_error(mailbox, 0, "Cannot get backup file name.");
dc_log_error(mailbox, 0, "Cannot get backup file name.");
goto cleanup;
}
}
@ -905,7 +905,7 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
closed = 1;
/* copy file to backup directory */
mrmailbox_log_info(mailbox, 0, "Backup \"%s\" to \"%s\".", mailbox->m_dbfile, dest_pathNfilename);
dc_log_info(mailbox, 0, "Backup \"%s\" to \"%s\".", mailbox->m_dbfile, dest_pathNfilename);
if( !mr_copy_file(mailbox->m_dbfile, dest_pathNfilename, mailbox) ) {
goto cleanup; /* error already logged */
}
@ -931,7 +931,7 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
/* scan directory, pass 1: collect file info */
total_files_count = 0;
if( (dir_handle=opendir(mailbox->m_blobdir))==NULL ) {
mrmailbox_log_error(mailbox, 0, "Backup: Cannot get info for blob-directory \"%s\".", mailbox->m_blobdir);
dc_log_error(mailbox, 0, "Backup: Cannot get info for blob-directory \"%s\".", mailbox->m_blobdir);
goto cleanup;
}
@ -946,7 +946,7 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
{
/* scan directory, pass 2: copy files */
if( (dir_handle=opendir(mailbox->m_blobdir))==NULL ) {
mrmailbox_log_error(mailbox, 0, "Backup: Cannot copy from blob-directory \"%s\".", mailbox->m_blobdir);
dc_log_error(mailbox, 0, "Backup: Cannot copy from blob-directory \"%s\".", mailbox->m_blobdir);
goto cleanup;
}
@ -965,11 +965,11 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
if( (name_len==1 && name[0]=='.')
|| (name_len==2 && name[0]=='.' && name[1]=='.')
|| (name_len > prefix_len && strncmp(name, DC_BAK_PREFIX, prefix_len)==0 && name_len > suffix_len && strncmp(&name[name_len-suffix_len-1], "." DC_BAK_SUFFIX, suffix_len)==0) ) {
//mrmailbox_log_info(mailbox, 0, "Backup: Skipping \"%s\".", name);
//dc_log_info(mailbox, 0, "Backup: Skipping \"%s\".", name);
continue;
}
//mrmailbox_log_info(mailbox, 0, "Backup \"%s\".", name);
//dc_log_info(mailbox, 0, "Backup \"%s\".", name);
free(curr_pathNfilename);
curr_pathNfilename = mr_mprintf("%s/%s", mailbox->m_blobdir, name);
free(buf);
@ -980,7 +980,7 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
sqlite3_bind_text(stmt, 1, name, -1, SQLITE_STATIC);
sqlite3_bind_blob(stmt, 2, buf, buf_bytes, SQLITE_STATIC);
if( sqlite3_step(stmt)!=SQLITE_DONE ) {
mrmailbox_log_error(mailbox, 0, "Disk full? Cannot add file \"%s\" to backup.", curr_pathNfilename);
dc_log_error(mailbox, 0, "Disk full? Cannot add file \"%s\" to backup.", curr_pathNfilename);
goto cleanup; /* this is not recoverable! writing to the sqlite database should work! */
}
sqlite3_reset(stmt);
@ -988,14 +988,14 @@ static int export_backup(mrmailbox_t* mailbox, const char* dir)
}
else
{
mrmailbox_log_info(mailbox, 0, "Backup: No files to copy.", mailbox->m_blobdir);
dc_log_info(mailbox, 0, "Backup: No files to copy.", mailbox->m_blobdir);
}
/* done - set some special config values (do this last to avoid importing crashed backups) */
mrsqlite3_set_config_int__(dest_sql, "backup_time", now);
mrsqlite3_set_config__ (dest_sql, "backup_for", mailbox->m_blobdir);
mailbox->m_cb(mailbox, MR_EVENT_IMEX_FILE_WRITTEN, (uintptr_t)dest_pathNfilename, 0);
mailbox->m_cb(mailbox, DC_EVENT_IMEX_FILE_WRITTEN, (uintptr_t)dest_pathNfilename, 0);
success = 1;
cleanup:
@ -1046,10 +1046,10 @@ static int import_backup(mrmailbox_t* mailbox, const char* backup_to_import)
char* repl_from = NULL;
char* repl_to = NULL;
mrmailbox_log_info(mailbox, 0, "Import \"%s\" to \"%s\".", backup_to_import, mailbox->m_dbfile);
dc_log_info(mailbox, 0, "Import \"%s\" to \"%s\".", backup_to_import, mailbox->m_dbfile);
if( mrmailbox_is_configured(mailbox) ) {
mrmailbox_log_error(mailbox, 0, "Cannot import backups to mailboxes in use.");
dc_log_error(mailbox, 0, "Cannot import backups to mailboxes in use.");
goto cleanup;
}
@ -1064,7 +1064,7 @@ static int import_backup(mrmailbox_t* mailbox, const char* backup_to_import)
mr_delete_file(mailbox->m_dbfile, mailbox);
if( mr_file_exist(mailbox->m_dbfile) ) {
mrmailbox_log_error(mailbox, 0, "Cannot import backups: Cannot delete the old file.");
dc_log_error(mailbox, 0, "Cannot import backups: Cannot delete the old file.");
goto cleanup;
}
@ -1102,7 +1102,7 @@ static int import_backup(mrmailbox_t* mailbox, const char* backup_to_import)
free(pathNfilename);
pathNfilename = mr_mprintf("%s/%s", mailbox->m_blobdir, file_name);
if( !mr_write_file(pathNfilename, file_content, file_bytes, mailbox) ) {
mrmailbox_log_error(mailbox, 0, "Storage full? Cannot write file %s with %i bytes.", pathNfilename, file_bytes);
dc_log_error(mailbox, 0, "Storage full? Cannot write file %s with %i bytes.", pathNfilename, file_bytes);
goto cleanup; /* otherwise the user may believe the stuff is imported correctly, but there are files missing ... */
}
}
@ -1124,7 +1124,7 @@ static int import_backup(mrmailbox_t* mailbox, const char* backup_to_import)
repl_to = safe_strdup(mailbox->m_blobdir);
ensure_no_slash(repl_to);
mrmailbox_log_info(mailbox, 0, "Rewriting paths from '%s' to '%s' ...", repl_from, repl_to);
dc_log_info(mailbox, 0, "Rewriting paths from '%s' to '%s' ...", repl_from, repl_to);
assert( 'f' == MRP_FILE );
assert( 'i' == MRP_PROFILE_IMAGE );
@ -1216,22 +1216,22 @@ int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* par
}
if( param1 == NULL ) {
mrmailbox_log_error(mailbox, 0, "No Import/export dir/file given.");
dc_log_error(mailbox, 0, "No Import/export dir/file given.");
return 0;
}
mrmailbox_log_info(mailbox, 0, "Import/export process started.");
mailbox->m_cb(mailbox, MR_EVENT_IMEX_PROGRESS, 0, 0);
dc_log_info(mailbox, 0, "Import/export process started.");
mailbox->m_cb(mailbox, DC_EVENT_IMEX_PROGRESS, 0, 0);
if( !mrsqlite3_is_open(mailbox->m_sql) ) {
mrmailbox_log_error(mailbox, 0, "Import/export: Database not opened.");
dc_log_error(mailbox, 0, "Import/export: Database not opened.");
goto cleanup;
}
if( what==MR_IMEX_EXPORT_SELF_KEYS || what==MR_IMEX_EXPORT_BACKUP ) {
/* before we export anything, make sure the private key exists */
if( !mrmailbox_ensure_secret_key_exists(mailbox) ) {
mrmailbox_log_error(mailbox, 0, "Import/export: Cannot create private key or private key not available.");
dc_log_error(mailbox, 0, "Import/export: Cannot create private key or private key not available.");
goto cleanup;
}
/* also make sure, the directory for exporting exists */
@ -1269,10 +1269,10 @@ int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* par
}
success = 1;
mailbox->m_cb(mailbox, MR_EVENT_IMEX_PROGRESS, 1000, 0);
mailbox->m_cb(mailbox, DC_EVENT_IMEX_PROGRESS, 1000, 0);
cleanup:
mrmailbox_log_info(mailbox, 0, "Import/export process ended.");
dc_log_info(mailbox, 0, "Import/export process ended.");
mrmailbox_free_ongoing(mailbox);
return success;
}
@ -1345,7 +1345,7 @@ char* dc_imex_has_backup(dc_context_t* mailbox, const char* dir_name)
}
if( (dir_handle=opendir(dir_name))==NULL ) {
mrmailbox_log_info(mailbox, 0, "Backup check: Cannot open directory \"%s\".", dir_name); /* this is not an error - eg. the directory may not exist or the user has not given us access to read data from the storage */
dc_log_info(mailbox, 0, "Backup check: Cannot open directory \"%s\".", dir_name); /* this is not an error - eg. the directory may not exist or the user has not given us access to read data from the storage */
goto cleanup;
}

View file

@ -45,7 +45,7 @@ static int connect_to_imap(mrmailbox_t* mailbox, mrjob_t* job /*may be NULL if t
mrloginparam_t* param = mrloginparam_new();
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || mailbox->m_imap == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot connect to IMAP: Bad parameters.");
dc_log_warning(mailbox, 0, "Cannot connect to IMAP: Bad parameters.");
goto cleanup;
}
@ -58,7 +58,7 @@ static int connect_to_imap(mrmailbox_t* mailbox, mrjob_t* job /*may be NULL if t
is_locked = 1;
if( mrsqlite3_get_config_int__(mailbox->m_sql, "configured", 0) == 0 ) {
mrmailbox_log_warning(mailbox, 0, "Not configured, cannot connect."); // this is no error, connect() is called eg. when the screen is switched on, it's okay if the caller does not check all circumstances here
dc_log_warning(mailbox, 0, "Not configured, cannot connect."); // this is no error, connect() is called eg. when the screen is switched on, it's okay if the caller does not check all circumstances here
goto cleanup;
}
@ -138,7 +138,7 @@ static void mrjob_do_MRJ_DELETE_MSG_ON_IMAP(mrmailbox_t* mailbox, mrjob_t* job)
}
if( mrmailbox_rfc724_mid_cnt__(mailbox, msg->m_rfc724_mid) != 1 ) {
mrmailbox_log_info(mailbox, 0, "The message is deleted from the server when all parts are deleted.");
dc_log_info(mailbox, 0, "The message is deleted from the server when all parts are deleted.");
delete_from_server = 0;
}
@ -336,7 +336,7 @@ static void mark_as_error(mrmailbox_t* mailbox, mrmsg_t* msg)
mrsqlite3_lock(mailbox->m_sql);
mrmailbox_update_msg_state__(mailbox, msg->m_id, MR_STATE_OUT_ERROR);
mrsqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, MR_EVENT_MSGS_CHANGED, msg->m_chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, msg->m_chat_id, 0);
}
@ -363,13 +363,13 @@ static void mrjob_do_MRJ_SEND_MSG_TO_SMTP(mrmailbox_t* mailbox, mrjob_t* job)
/* load message data */
if( !mrmimefactory_load_msg(&mimefactory, job->m_foreign_id)
|| mimefactory.m_from_addr == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot load data to send, maybe the message is deleted in between.");
dc_log_warning(mailbox, 0, "Cannot load data to send, maybe the message is deleted in between.");
goto cleanup; /* no redo, no IMAP - there won't be more recipients next time (as the data does not exist, there is no need in calling mark_as_error()) */
}
/* check if the message is ready (normally, only video files may be delayed this way) */
if( mimefactory.m_increation ) {
mrmailbox_log_info(mailbox, 0, "File is in creation, retrying later.");
dc_log_info(mailbox, 0, "File is in creation, retrying later.");
mrjob_try_again_later(job, MR_INCREATION_POLL);
goto cleanup;
}
@ -378,14 +378,14 @@ static void mrjob_do_MRJ_SEND_MSG_TO_SMTP(mrmailbox_t* mailbox, mrjob_t* job)
if( clist_count(mimefactory.m_recipients_addr) > 0 ) {
if( !mrmimefactory_render(&mimefactory) ) {
mark_as_error(mailbox, mimefactory.m_msg);
mrmailbox_log_error(mailbox, 0, "Empty message."); /* should not happen */
dc_log_error(mailbox, 0, "Empty message."); /* should not happen */
goto cleanup; /* no redo, no IMAP - there won't be more recipients next time. */
}
/* have we guaranteed encryption but cannot fulfill it for any reason? Do not send the message then.*/
if( mrparam_get_int(mimefactory.m_msg->m_param, MRP_GUARANTEE_E2EE, 0) && !mimefactory.m_out_encrypted ) {
mark_as_error(mailbox, mimefactory.m_msg);
mrmailbox_log_error(mailbox, 0, "End-to-end-encryption unavailable unexpectedly.");
dc_log_error(mailbox, 0, "End-to-end-encryption unavailable unexpectedly.");
goto cleanup; /* unrecoverable */
}
@ -431,7 +431,7 @@ static void mrjob_do_MRJ_SEND_MSG_TO_SMTP(mrmailbox_t* mailbox, mrjob_t* job)
mrsqlite3_commit__(mailbox->m_sql);
mrsqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, MR_EVENT_MSG_DELIVERED, mimefactory.m_msg->m_chat_id, mimefactory.m_msg->m_id);
mailbox->m_cb(mailbox, DC_EVENT_MSG_DELIVERED, mimefactory.m_msg->m_chat_id, mimefactory.m_msg->m_id);
cleanup:
mrmimefactory_empty(&mimefactory);
@ -595,7 +595,7 @@ static void mrjob_perform(mrmailbox_t* mailbox, int thread)
job.m_foreign_id = sqlite3_column_int (select_stmt, 2);
mrparam_set_packed(job.m_param, (char*)sqlite3_column_text(select_stmt, 3));
mrmailbox_log_info(mailbox, 0, "%s-job #%i, action %i started...", THREAD_STR, (int)job.m_job_id, (int)job.m_action);
dc_log_info(mailbox, 0, "%s-job #%i, action %i started...", THREAD_STR, (int)job.m_job_id, (int)job.m_action);
for( int tries = 0; tries <= 1; tries++ )
{
@ -620,7 +620,7 @@ static void mrjob_perform(mrmailbox_t* mailbox, int thread)
if( job.m_try_again == MR_INCREATION_POLL )
{
// just try over next loop unconditionally, the ui typically interrupts idle when the file (video) is ready
mrmailbox_log_info(mailbox, 0, "%s-job #%i not yet ready and will be delayed.", THREAD_STR, (int)job.m_job_id);
dc_log_info(mailbox, 0, "%s-job #%i not yet ready and will be delayed.", THREAD_STR, (int)job.m_job_id);
}
else if( job.m_try_again == MR_AT_ONCE || job.m_try_again == MR_STANDARD_DELAY )
{
@ -633,7 +633,7 @@ static void mrjob_perform(mrmailbox_t* mailbox, int thread)
sqlite3_bind_int (update_stmt, 2, job.m_job_id);
sqlite3_step(update_stmt);
sqlite3_finalize(update_stmt);
mrmailbox_log_info(mailbox, 0, "%s-job #%i not succeeded, trying again asap.", THREAD_STR, (int)job.m_job_id);
dc_log_info(mailbox, 0, "%s-job #%i not succeeded, trying again asap.", THREAD_STR, (int)job.m_job_id);
// if the job did not succeeded AND this is a smtp-job AND we're online, try over after a mini-delay of one second.
// if we're not online, the ui calls interrupt idle as soon as we're online again.
@ -680,7 +680,7 @@ cleanup:
*/
void dc_perform_imap_jobs(dc_context_t* mailbox)
{
mrmailbox_log_info(mailbox, 0, "IMAP-jobs started...");
dc_log_info(mailbox, 0, "IMAP-jobs started...");
pthread_mutex_lock(&mailbox->m_imapidle_condmutex);
mailbox->m_perform_imap_jobs_needed = 0;
@ -688,7 +688,7 @@ void dc_perform_imap_jobs(dc_context_t* mailbox)
mrjob_perform(mailbox, MR_IMAP_THREAD);
mrmailbox_log_info(mailbox, 0, "IMAP-jobs ended.");
dc_log_info(mailbox, 0, "IMAP-jobs ended.");
}
@ -711,18 +711,18 @@ void dc_perform_imap_fetch(dc_context_t* mailbox)
return;
}
mrmailbox_log_info(mailbox, 0, "IMAP-fetch started...");
dc_log_info(mailbox, 0, "IMAP-fetch started...");
mrimap_fetch(mailbox->m_imap);
if( mailbox->m_imap->m_should_reconnect
&& mailbox->m_cb(mailbox, MR_EVENT_IS_OFFLINE, 0, 0)==0 )
&& mailbox->m_cb(mailbox, DC_EVENT_IS_OFFLINE, 0, 0)==0 )
{
mrmailbox_log_info(mailbox, 0, "IMAP-fetch aborted, starting over...");
dc_log_info(mailbox, 0, "IMAP-fetch aborted, starting over...");
mrimap_fetch(mailbox->m_imap);
}
mrmailbox_log_info(mailbox, 0, "IMAP-fetch done in %.0f ms.", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
dc_log_info(mailbox, 0, "IMAP-fetch done in %.0f ms.", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
}
@ -745,17 +745,17 @@ void dc_perform_imap_idle(dc_context_t* mailbox)
pthread_mutex_lock(&mailbox->m_imapidle_condmutex);
if( mailbox->m_perform_imap_jobs_needed ) {
mrmailbox_log_info(mailbox, 0, "IMAP-IDLE will not be started because of waiting jobs.");
dc_log_info(mailbox, 0, "IMAP-IDLE will not be started because of waiting jobs.");
pthread_mutex_unlock(&mailbox->m_imapidle_condmutex);
return;
}
pthread_mutex_unlock(&mailbox->m_imapidle_condmutex);
mrmailbox_log_info(mailbox, 0, "IMAP-IDLE started...");
dc_log_info(mailbox, 0, "IMAP-IDLE started...");
mrimap_idle(mailbox->m_imap);
mrmailbox_log_info(mailbox, 0, "IMAP-IDLE ended.");
dc_log_info(mailbox, 0, "IMAP-IDLE ended.");
}
@ -796,11 +796,11 @@ void dc_perform_imap_idle(dc_context_t* mailbox)
void dc_interrupt_imap_idle(dc_context_t* mailbox)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || mailbox->m_imap == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Interrupt IMAP-IDLE: Bad parameters.");
dc_log_warning(mailbox, 0, "Interrupt IMAP-IDLE: Bad parameters.");
return;
}
mrmailbox_log_info(mailbox, 0, "Interrupting IMAP-IDLE...");
dc_log_info(mailbox, 0, "Interrupting IMAP-IDLE...");
pthread_mutex_lock(&mailbox->m_imapidle_condmutex);
// when this function is called, it might be that the idle-thread is in
@ -831,7 +831,7 @@ void dc_interrupt_imap_idle(dc_context_t* mailbox)
*/
void dc_perform_smtp_jobs(mrmailbox_t* mailbox)
{
mrmailbox_log_info(mailbox, 0, "SMTP-jobs started...");
dc_log_info(mailbox, 0, "SMTP-jobs started...");
pthread_mutex_lock(&mailbox->m_smtpidle_condmutex);
mailbox->m_perform_smtp_jobs_needed = 0;
@ -839,7 +839,7 @@ void dc_perform_smtp_jobs(mrmailbox_t* mailbox)
mrjob_perform(mailbox, MR_SMTP_THREAD);
mrmailbox_log_info(mailbox, 0, "SMTP-jobs ended.");
dc_log_info(mailbox, 0, "SMTP-jobs ended.");
}
@ -857,17 +857,17 @@ void dc_perform_smtp_jobs(mrmailbox_t* mailbox)
void dc_perform_smtp_idle(mrmailbox_t* mailbox)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
mrmailbox_log_warning(mailbox, 0, "Cannot perform SMTP-idle: Bad parameters.");
dc_log_warning(mailbox, 0, "Cannot perform SMTP-idle: Bad parameters.");
return;
}
mrmailbox_log_info(mailbox, 0, "SMTP-idle started...");
dc_log_info(mailbox, 0, "SMTP-idle started...");
pthread_mutex_lock(&mailbox->m_smtpidle_condmutex);
if( mailbox->m_perform_smtp_jobs_needed == MR_JOBS_NEEDED_AT_ONCE )
{
mrmailbox_log_info(mailbox, 0, "SMTP-idle will not be started because of waiting jobs.");
dc_log_info(mailbox, 0, "SMTP-idle will not be started because of waiting jobs.");
}
else
{
@ -889,7 +889,7 @@ void dc_perform_smtp_idle(mrmailbox_t* mailbox)
pthread_mutex_unlock(&mailbox->m_smtpidle_condmutex);
mrmailbox_log_info(mailbox, 0, "SMTP-idle ended.");
dc_log_info(mailbox, 0, "SMTP-idle ended.");
}
@ -928,11 +928,11 @@ void dc_perform_smtp_idle(mrmailbox_t* mailbox)
void dc_interrupt_smtp_idle(mrmailbox_t* mailbox)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
mrmailbox_log_warning(mailbox, 0, "Interrupt SMTP-idle: Bad parameters.");
dc_log_warning(mailbox, 0, "Interrupt SMTP-idle: Bad parameters.");
return;
}
mrmailbox_log_info(mailbox, 0, "Interrupting SMTP-idle...");
dc_log_info(mailbox, 0, "Interrupting SMTP-idle...");
pthread_mutex_lock(&mailbox->m_smtpidle_condmutex);

View file

@ -189,12 +189,12 @@ int mrkey_set_from_file(mrkey_t* ths, const char* pathNfilename, mrmailbox_t* ma
type = MR_PRIVATE;
}
else {
mrmailbox_log_warning(mailbox, 0, "Header missing for key \"%s\".", pathNfilename);
dc_log_warning(mailbox, 0, "Header missing for key \"%s\".", pathNfilename);
goto cleanup;
}
if( !mrkey_set_from_base64(ths, base64, type) ) {
mrmailbox_log_warning(mailbox, 0, "Bad data in key \"%s\".", pathNfilename);
dc_log_warning(mailbox, 0, "Bad data in key \"%s\".", pathNfilename);
goto cleanup;
}
@ -418,7 +418,7 @@ int mrkey_render_asc_to_file(const mrkey_t* key, const char* file, mrmailbox_t*
}
if( !mr_write_file(file, file_content, strlen(file_content), mailbox) ) {
mrmailbox_log_error(mailbox, 0, "Cannot write key to %s", file);
dc_log_error(mailbox, 0, "Cannot write key to %s", file);
goto cleanup;
}

View file

@ -20,13 +20,13 @@
******************************************************************************/
/* Asynchronous "Thread-errors" are reported by the mrmailbox_log_error()
/* 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 mrmailbox_log_error() - its up to the caller to
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 mrmailbox_log_warning(). */
are usually logged by dc_log_warning(). */
#include <stdarg.h>
@ -39,7 +39,7 @@ are usually logged by mrmailbox_log_warning(). */
******************************************************************************/
static void mrmailbox_log_vprintf(mrmailbox_t* mailbox, int event, int code, const char* msg_format, va_list va)
static void log_vprintf(mrmailbox_t* mailbox, int event, int code, const char* msg_format, va_list va)
{
char* msg = NULL;
@ -48,11 +48,11 @@ static void mrmailbox_log_vprintf(mrmailbox_t* mailbox, int event, int code, con
}
/* format message from variable parameters or translate very comming errors */
if( code == MR_ERR_SELF_NOT_IN_GROUP )
if( code == DC_ERROR_SELF_NOT_IN_GROUP )
{
msg = mrstock_str(MR_STR_SELFNOTINGRP);
}
else if( code == MR_ERR_NONETWORK )
else if( code == DC_ERROR_NO_NETWORK )
{
msg = mrstock_str(MR_STR_NONETWORK);
}
@ -66,8 +66,8 @@ static void mrmailbox_log_vprintf(mrmailbox_t* mailbox, int event, int code, con
/* if we have still no message, create one based upon the code */
if( msg == NULL ) {
if( event == MR_EVENT_INFO ) { msg = mr_mprintf("Info: %i", (int)code); }
else if( event == MR_EVENT_WARNING ) { msg = mr_mprintf("Warning: %i", (int)code); }
if( event == DC_EVENT_INFO ) { msg = mr_mprintf("Info: %i", (int)code); }
else if( event == DC_EVENT_WARNING ) { msg = mr_mprintf("Warning: %i", (int)code); }
else { msg = mr_mprintf("Error: %i", (int)code); }
}
@ -84,35 +84,35 @@ static void mrmailbox_log_vprintf(mrmailbox_t* mailbox, int event, int code, con
}
void mrmailbox_log_info(mrmailbox_t* mailbox, int code, const char* msg, ...)
void dc_log_info(mrmailbox_t* mailbox, int code, const char* msg, ...)
{
va_list va;
va_start(va, msg); /* va_start() expects the last non-variable argument as the second parameter */
mrmailbox_log_vprintf(mailbox, MR_EVENT_INFO, code, msg, va);
log_vprintf(mailbox, DC_EVENT_INFO, code, msg, va);
va_end(va);
}
void mrmailbox_log_warning(mrmailbox_t* mailbox, int code, const char* msg, ...)
void dc_log_warning(mrmailbox_t* mailbox, int code, const char* msg, ...)
{
va_list va;
va_start(va, msg);
mrmailbox_log_vprintf(mailbox, MR_EVENT_WARNING, code, msg, va);
log_vprintf(mailbox, DC_EVENT_WARNING, code, msg, va);
va_end(va);
}
void mrmailbox_log_error(mrmailbox_t* mailbox, int code, const char* msg, ...)
void dc_log_error(mrmailbox_t* mailbox, int code, const char* msg, ...)
{
va_list va;
va_start(va, msg);
mrmailbox_log_vprintf(mailbox, MR_EVENT_ERROR, code, msg, va);
log_vprintf(mailbox, DC_EVENT_ERROR, code, msg, va);
va_end(va);
}
void mrmailbox_log_error_if(int* condition, mrmailbox_t* mailbox, int code, const char* msg, ...)
void dc_log_error_if(int* condition, mrmailbox_t* mailbox, int code, const char* msg, ...)
{
if( condition == NULL || mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
return;
@ -122,17 +122,17 @@ void mrmailbox_log_error_if(int* condition, mrmailbox_t* mailbox, int code, cons
va_start(va, msg);
if( *condition ) {
/* pop-up error, if we're offline, force a "not connected" error (the function is not used for other cases) */
if( mailbox->m_cb(mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
mrmailbox_log_vprintf(mailbox, MR_EVENT_ERROR, MR_ERR_NONETWORK, NULL, va);
if( mailbox->m_cb(mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
log_vprintf(mailbox, DC_EVENT_ERROR, DC_ERROR_NO_NETWORK, NULL, va);
}
else {
mrmailbox_log_vprintf(mailbox, MR_EVENT_ERROR, code, msg, va);
log_vprintf(mailbox, DC_EVENT_ERROR, code, msg, va);
}
*condition = 0;
}
else {
/* log a warning only (eg. for subsequent connection errors) */
mrmailbox_log_vprintf(mailbox, MR_EVENT_WARNING, code, msg, va);
log_vprintf(mailbox, DC_EVENT_WARNING, code, msg, va);
}
va_end(va);
}

View file

@ -586,7 +586,7 @@ int mrmimefactory_render(mrmimefactory_t* factory)
}
if( mrparam_get_int(msg->m_param, MRP_CMD_PARAM2, 0)&MR_FROM_HANDSHAKE ) {
mrmailbox_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", "vg-member-added");
dc_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", "vg-member-added");
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Secure-Join"), strdup("vg-member-added")));
}
}
@ -611,7 +611,7 @@ int mrmimefactory_render(mrmimefactory_t* factory)
if( command == MR_CMD_SECUREJOIN_MESSAGE ) {
char* step = mrparam_get(msg->m_param, MRP_CMD_PARAM, NULL);
if( step ) {
mrmailbox_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", step);
dc_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", step);
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Secure-Join"), step/*mailimf takes ownership of string*/));
char* param2 = mrparam_get(msg->m_param, MRP_CMD_PARAM2, NULL);

View file

@ -1065,7 +1065,7 @@ static int mrmimeparser_add_single_part_if_known(mrmimeparser_t* ths, struct mai
size_t ret_bytes = 0;
int r = charconv_buffer("utf-8", charset, decoded_data, decoded_data_bytes, &charset_buffer, &ret_bytes);
if( r != MAIL_CHARCONV_NO_ERROR ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Cannot convert %i bytes from \"%s\" to \"utf-8\"; errorcode is %i.", /* if this warning comes up for usual character sets, maybe libetpan is compiled without iconv? */
dc_log_warning(ths->m_mailbox, 0, "Cannot convert %i bytes from \"%s\" to \"utf-8\"; errorcode is %i.", /* if this warning comes up for usual character sets, maybe libetpan is compiled without iconv? */
(int)decoded_data_bytes, charset, (int)r); /* continue, however */
}
else if( charset_buffer==NULL || ret_bytes <= 0 ) {
@ -1235,7 +1235,7 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
&& mime->mm_content_type->ct_type->tp_data.tp_discrete_type->dt_type==MAILMIME_DISCRETE_TYPE_TEXT
&& mime->mm_content_type->ct_subtype
&& strcmp(mime->mm_content_type->ct_subtype, "rfc822-headers")==0 ) {
mrmailbox_log_info(ths->m_mailbox, 0, "Protected headers found in text/rfc822-headers attachment: Will be ignored."); /* we want the protected headers in the normal header of the payload */
dc_log_info(ths->m_mailbox, 0, "Protected headers found in text/rfc822-headers attachment: Will be ignored."); /* we want the protected headers in the normal header of the payload */
return 0;
}
@ -1243,11 +1243,11 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
size_t dummy = 0;
if( mailimf_envelope_and_optional_fields_parse(mime->mm_mime_start, mime->mm_length, &dummy, &ths->m_header_protected)!=MAILIMF_NO_ERROR
|| ths->m_header_protected==NULL ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "Protected headers parsing error.");
dc_log_warning(ths->m_mailbox, 0, "Protected headers parsing error.");
}
}
else {
mrmailbox_log_info(ths->m_mailbox, 0, "Protected headers found in MIME header: Will be ignored as we already found an outer one.");
dc_log_info(ths->m_mailbox, 0, "Protected headers found in MIME header: Will be ignored as we already found an outer one.");
}
}
@ -1365,7 +1365,7 @@ static int mrmimeparser_parse_mime_recursive(mrmimeparser_t* ths, struct mailmim
}
}
if( plain_cnt==1 && html_cnt==1 ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "HACK: multipart/mixed message found with PLAIN and HTML, we'll skip the HTML part as this seems to be unwanted.");
dc_log_warning(ths->m_mailbox, 0, "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;
}
}
@ -1446,7 +1446,7 @@ static void hash_header(mrhash_t* out, const struct mailimf_fields* in, mrmailbo
if( field->fld_type!=MAILIMF_FIELD_OPTIONAL_FIELD
|| (key_len>5 && strncasecmp(key, "Chat-", 5)==0) )
{
//mrmailbox_log_info(mailbox, 0, "Protected headers: Overwriting \"%s\".", key);
//dc_log_info(mailbox, 0, "Protected headers: Overwriting \"%s\".", key);
mrhash_insert(out, key, key_len, field);
}
}

View file

@ -500,12 +500,12 @@ int mrpgp_split_key(mrmailbox_t* mailbox, const mrkey_t* private_in, mrkey_t* re
pgp_filter_keys_from_mem(&s_io, public_keys, private_keys, NULL, 0, keysmem);
if( private_in->m_type!=MR_PRIVATE || private_keys->keyc <= 0 ) {
mrmailbox_log_warning(mailbox, 0, "Split key: Given key is no private key.");
dc_log_warning(mailbox, 0, "Split key: Given key is no private key.");
goto cleanup;
}
if( public_keys->keyc <= 0 ) {
mrmailbox_log_warning(mailbox, 0, "Split key: Given key does not contain a public key.");
dc_log_warning(mailbox, 0, "Split key: Given key does not contain a public key.");
goto cleanup;
}
@ -567,7 +567,7 @@ int mrpgp_pk_encrypt( mrmailbox_t* mailbox,
}
if( public_keys->keyc <=0 || private_keys->keyc!=0 ) {
mrmailbox_log_warning(mailbox, 0, "Encryption-keyring contains unexpected data (%i/%i)", public_keys->keyc, private_keys->keyc);
dc_log_warning(mailbox, 0, "Encryption-keyring contains unexpected data (%i/%i)", public_keys->keyc, private_keys->keyc);
goto cleanup;
}
@ -582,7 +582,7 @@ int mrpgp_pk_encrypt( mrmailbox_t* mailbox,
pgp_memory_add(keysmem, raw_private_key_for_signing->m_binary, raw_private_key_for_signing->m_bytes);
pgp_filter_keys_from_mem(&s_io, dummy_keys, private_keys, NULL, 0, keysmem);
if( private_keys->keyc <= 0 ) {
mrmailbox_log_warning(mailbox, 0, "No key for signing found.");
dc_log_warning(mailbox, 0, "No key for signing found.");
goto cleanup;
}
@ -590,7 +590,7 @@ int mrpgp_pk_encrypt( mrmailbox_t* mailbox,
signedmem = pgp_sign_buf(&s_io, plain_text, plain_bytes, &sk0->key.seckey, time(NULL)/*birthtime*/, 0/*duration*/,
NULL/*hash, defaults to sha256*/, 0/*armored*/, 0/*cleartext*/);
if( signedmem == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Signing failed.");
dc_log_warning(mailbox, 0, "Signing failed.");
goto cleanup;
}
signed_text = signedmem->buf;
@ -605,7 +605,7 @@ int mrpgp_pk_encrypt( mrmailbox_t* mailbox,
pgp_memory_t* outmem = pgp_encrypt_buf(&s_io, signed_text, signed_bytes, public_keys, use_armor, NULL/*cipher*/, encrypt_raw_packet);
if( outmem == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Encryption failed.");
dc_log_warning(mailbox, 0, "Encryption failed.");
goto cleanup;
}
*ret_ctext = outmem->buf;
@ -661,7 +661,7 @@ int mrpgp_pk_decrypt( mrmailbox_t* mailbox,
}
if( private_keys->keyc<=0 ) {
mrmailbox_log_warning(mailbox, 0, "Decryption-keyring contains unexpected data (%i/%i)", public_keys->keyc, private_keys->keyc);
dc_log_warning(mailbox, 0, "Decryption-keyring contains unexpected data (%i/%i)", public_keys->keyc, private_keys->keyc);
goto cleanup;
}
@ -678,7 +678,7 @@ int mrpgp_pk_decrypt( mrmailbox_t* mailbox,
pgp_memory_t* outmem = pgp_decrypt_and_validate_buf(&s_io, vresult, ctext, ctext_bytes, private_keys, public_keys,
use_armor, &recipients_key_ids, &recipients_count);
if( outmem == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Decryption failed.");
dc_log_warning(mailbox, 0, "Decryption failed.");
goto cleanup;
}
*ret_plain = outmem->buf;

View file

@ -66,7 +66,7 @@ dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr)
goto cleanup;
}
mrmailbox_log_info(mailbox, 0, "Scanned QR code: %s", qr);
dc_log_info(mailbox, 0, "Scanned QR code: %s", qr);
/* split parameters from the qr code
------------------------------------ */

View file

@ -569,7 +569,7 @@ static void create_or_lookup_adhoc_group__(mrmailbox_t* mailbox, mrmimeparser_t*
mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, mrarray_get_id(member_ids, i));
}
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
cleanup:
mrarray_unref(member_ids);
@ -598,19 +598,19 @@ static int check_verified_properties__(mrmailbox_t* mailbox, mrmimeparser_t* mim
if( !mrcontact_load_from_db__(contact, mailbox->m_sql, from_id)
|| !mrapeerstate_load_by_addr__(peerstate, mailbox->m_sql, contact->m_addr)
|| mrcontact_is_verified__(contact, peerstate) < MRV_BIDIRECTIONAL ) {
mrmailbox_log_warning(mailbox, 0, "Cannot verifiy group; sender is not verified.");
dc_log_warning(mailbox, 0, "Cannot verifiy group; sender is not verified.");
goto cleanup;
}
// ensure, the message is encrypted
if( !mimeparser->m_e2ee_helper->m_encrypted ) {
mrmailbox_log_warning(mailbox, 0, "Cannot verifiy group; message is not encrypted properly.");
dc_log_warning(mailbox, 0, "Cannot verifiy group; message is not encrypted properly.");
goto cleanup;
}
// ensure, the message is signed with a verified key of the sender
if( !mrapeerstate_has_verified_key(peerstate, mimeparser->m_e2ee_helper->m_signatures) ) {
mrmailbox_log_warning(mailbox, 0, "Cannot verifiy group; message is not signed properly.");
dc_log_warning(mailbox, 0, "Cannot verifiy group; message is not signed properly.");
goto cleanup;
}
@ -640,7 +640,7 @@ static int check_verified_properties__(mrmailbox_t* mailbox, mrmimeparser_t* mim
|| (strcmp(peerstate->m_verified_key_fingerprint, peerstate->m_public_key_fingerprint)!=0
&& strcmp(peerstate->m_verified_key_fingerprint, peerstate->m_gossip_key_fingerprint)!=0) )
{
mrmailbox_log_info(mailbox, 0, "Marking gossipped key %s as verified due to verified %s.", to_addr, contact->m_addr);
dc_log_info(mailbox, 0, "Marking gossipped key %s as verified due to verified %s.", to_addr, contact->m_addr);
mrapeerstate_set_verified(peerstate, MRA_GOSSIP_KEY, peerstate->m_gossip_key_fingerprint, MRV_BIDIRECTIONAL);
mrapeerstate_save_to_db__(peerstate, mailbox->m_sql, 0);
is_verified = 1;
@ -649,7 +649,7 @@ static int check_verified_properties__(mrmailbox_t* mailbox, mrmimeparser_t* mim
if( !is_verified )
{
mrmailbox_log_warning(mailbox, 0, "Cannot verifiy group; recipient %s is not gossipped.", to_addr);
dc_log_warning(mailbox, 0, "Cannot verifiy group; recipient %s is not gossipped.", to_addr);
goto cleanup;
}
}
@ -838,7 +838,7 @@ static void create_or_lookup_group__(mrmailbox_t* mailbox, mrmimeparser_t* mime_
sqlite3_bind_int (stmt, 2, chat_id);
sqlite3_step(stmt);
sqlite3_finalize(stmt);
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
}
if( X_MrGrpImageChanged )
@ -863,7 +863,7 @@ static void create_or_lookup_group__(mrmailbox_t* mailbox, mrmimeparser_t* mime_
if( ok ) {
mrchat_t* chat = mrchat_new(mailbox);
mrmailbox_log_info(mailbox, 0, "New group image set to %s.", grpimage? "DELETED" : grpimage);
dc_log_info(mailbox, 0, "New group image set to %s.", grpimage? "DELETED" : grpimage);
mrchat_load_from_db__(chat, chat_id);
mrparam_set(chat->m_param, MRP_PROFILE_IMAGE, grpimage/*may be NULL*/);
mrchat_update_param__(chat);
@ -907,7 +907,7 @@ static void create_or_lookup_group__(mrmailbox_t* mailbox, mrmimeparser_t* mime_
}
if( send_EVENT_CHAT_MODIFIED ) {
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
}
/* check the number of receivers -
@ -967,17 +967,17 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
const struct mailimf_field* field;
carray* created_db_entries = carray_new(16);
int create_event_to_send = MR_EVENT_MSGS_CHANGED;
int create_event_to_send = DC_EVENT_MSGS_CHANGED;
carray* rr_event_to_send = carray_new(16);
char* txt_raw = NULL;
mrmailbox_log_info(mailbox, 0, "Receiving message %s/%lu...", server_folder? server_folder:"?", server_uid);
dc_log_info(mailbox, 0, "Receiving message %s/%lu...", server_folder? server_folder:"?", server_uid);
to_ids = mrarray_new(mailbox, 16);
if( to_ids==NULL || created_db_entries==NULL || rr_event_to_send==NULL || mime_parser == NULL ) {
mrmailbox_log_info(mailbox, 0, "Bad param.");
dc_log_info(mailbox, 0, "Bad param.");
goto cleanup;
}
@ -995,7 +995,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
that speaks against this approach yet) */
mrmimeparser_parse(mime_parser, imf_raw_not_terminated, imf_raw_bytes);
if( mrhash_count(&mime_parser->m_header)==0 ) {
mrmailbox_log_info(mailbox, 0, "No header.");
dc_log_info(mailbox, 0, "No header.");
goto cleanup; /* Error - even adding an empty record won't help as we do not know the message ID */
}
@ -1097,7 +1097,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
if( rfc724_mid == NULL ) {
rfc724_mid = mr_create_incoming_rfc724_mid(sort_timestamp, from_id, to_ids);
if( rfc724_mid == NULL ) {
mrmailbox_log_info(mailbox, 0, "Cannot create Message-ID.");
dc_log_info(mailbox, 0, "Cannot create Message-ID.");
goto cleanup;
}
}
@ -1114,7 +1114,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
mrmailbox_update_server_uid__(mailbox, rfc724_mid, server_folder, server_uid);
}
free(old_server_folder);
mrmailbox_log_info(mailbox, 0, "Message already in DB.");
dc_log_info(mailbox, 0, "Message already in DB.");
goto cleanup;
}
}
@ -1165,7 +1165,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
/* check if the message belongs to a mailing list */
if( mrmimeparser_is_mailinglist_message(mime_parser) ) {
chat_id = MR_CHAT_ID_TRASH;
mrmailbox_log_info(mailbox, 0, "Message belongs to a mailing list and is ignored.");
dc_log_info(mailbox, 0, "Message belongs to a mailing list and is ignored.");
}
}
@ -1188,7 +1188,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
}
else if( mrmailbox_is_reply_to_known_message__(mailbox, mime_parser) ) {
mrmailbox_scaleup_contact_origin__(mailbox, from_id, MR_ORIGIN_INCOMING_REPLY_TO); /* we do not want any chat to be created implicitly. Because of the origin-scale-up, the contact requests will pop up and this should be just fine. */
mrmailbox_log_info(mailbox, 0, "Message is a reply to a known message, mark sender as known.");
dc_log_info(mailbox, 0, "Message is a reply to a known message, mark sender as known.");
incoming_origin = MR_MAX(incoming_origin, MR_ORIGIN_INCOMING_REPLY_TO);
}
}
@ -1265,13 +1265,13 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
int msgrmsg = mime_parser->m_is_send_by_messenger; /* 1 or 0 for yes/no */
if( msgrmsg )
{
mrmailbox_log_info(mailbox, 0, "Message sent by another messenger.");
dc_log_info(mailbox, 0, "Message sent by another messenger.");
}
else
{
if( mrmailbox_is_reply_to_messenger_message__(mailbox, mime_parser) )
{
mrmailbox_log_info(mailbox, 0, "Message is a reply to a messenger message.");
dc_log_info(mailbox, 0, "Message is a reply to a messenger message.");
msgrmsg = 2; /* 2=no, but is reply to messenger message */
}
}
@ -1316,7 +1316,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
sqlite3_bind_int (stmt, 16, part->m_bytes);
sqlite3_bind_int (stmt, 17, hidden);
if( sqlite3_step(stmt) != SQLITE_DONE ) {
mrmailbox_log_info(mailbox, 0, "Cannot write DB.");
dc_log_info(mailbox, 0, "Cannot write DB.");
goto cleanup; /* i/o error - there is nothing more we can do - in other cases, we try to write at least an empty record */
}
@ -1331,7 +1331,7 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
carray_add(created_db_entries, (void*)(uintptr_t)first_dblocal_id, NULL);
}
mrmailbox_log_info(mailbox, 0, "Message has %i parts and is assigned to chat #%i.", icnt, chat_id);
dc_log_info(mailbox, 0, "Message has %i parts and is assigned to chat #%i.", icnt, chat_id);
/* check event to send */
if( chat_id == MR_CHAT_ID_TRASH )
@ -1344,13 +1344,13 @@ void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_termina
create_event_to_send = 0;
}
else if( chat_id_blocked ) {
create_event_to_send = MR_EVENT_MSGS_CHANGED;
create_event_to_send = DC_EVENT_MSGS_CHANGED;
/*if( mrsqlite3_get_config_int__(mailbox->m_sql, "show_deaddrop", 0)!=0 ) {
create_event_to_send = MR_EVENT_INCOMING_MSG;
create_event_to_send = DC_EVENT_INCOMING_MSG;
}*/
}
else {
create_event_to_send = MR_EVENT_INCOMING_MSG;
create_event_to_send = DC_EVENT_INCOMING_MSG;
}
}
}
@ -1489,7 +1489,7 @@ cleanup:
if( rr_event_to_send ) {
size_t i, icnt = carray_count(rr_event_to_send);
for( i = 0; i < icnt; i += 2 ) {
mailbox->m_cb(mailbox, MR_EVENT_MSG_READ, (uintptr_t)carray_get(rr_event_to_send, i), (uintptr_t)carray_get(rr_event_to_send, i+1));
mailbox->m_cb(mailbox, DC_EVENT_MSG_READ, (uintptr_t)carray_get(rr_event_to_send, i), (uintptr_t)carray_get(rr_event_to_send, i+1));
}
carray_free(rr_event_to_send);
}

View file

@ -78,7 +78,7 @@ void mrmailbox_handle_degrade_event(mrmailbox_t* mailbox, mrapeerstate_t* peerst
char* msg = mr_mprintf("Changed setup for %s", peerstate->m_addr);
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
free(msg);
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, contact_chat_id, 0);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, contact_chat_id, 0);
}
cleanup:
@ -94,22 +94,22 @@ cleanup:
static int encrypted_and_signed(mrmimeparser_t* mimeparser, const char* expected_fingerprint)
{
if( !mimeparser->m_e2ee_helper->m_encrypted ) {
mrmailbox_log_warning(mimeparser->m_mailbox, 0, "Message not encrypted.");
dc_log_warning(mimeparser->m_mailbox, 0, "Message not encrypted.");
return 0;
}
if( mrhash_count(mimeparser->m_e2ee_helper->m_signatures)<=0 ) {
mrmailbox_log_warning(mimeparser->m_mailbox, 0, "Message not signed.");
dc_log_warning(mimeparser->m_mailbox, 0, "Message not signed.");
return 0;
}
if( expected_fingerprint == NULL ) {
mrmailbox_log_warning(mimeparser->m_mailbox, 0, "Fingerprint for comparison missing.");
dc_log_warning(mimeparser->m_mailbox, 0, "Fingerprint for comparison missing.");
return 0;
}
if( mrhash_find_str(mimeparser->m_e2ee_helper->m_signatures, expected_fingerprint) == NULL ) {
mrmailbox_log_warning(mimeparser->m_mailbox, 0, "Message does not match expected fingerprint %s.", expected_fingerprint);
dc_log_warning(mimeparser->m_mailbox, 0, "Message does not match expected fingerprint %s.", expected_fingerprint);
return 0;
}
@ -286,7 +286,7 @@ static void could_not_establish_secure_connection(mrmailbox_t* mailbox, uint32_t
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
mrmailbox_log_error(mailbox, 0, "%s (%s)", msg, details); // additionaly raise an error; this typically results in a toast (inviter side) or a dialog (joiner side)
dc_log_error(mailbox, 0, "%s (%s)", msg, details); // additionaly raise an error; this typically results in a toast (inviter side) or a dialog (joiner side)
free(msg);
mrcontact_unref(contact);
@ -301,8 +301,8 @@ static void secure_connection_established(mrmailbox_t* mailbox, uint32_t contact
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
// in addition to MR_EVENT_MSGS_CHANGED (sent by mrmailbox_add_device_msg()), also send MR_EVENT_CHAT_MODIFIED to update all views
mailbox->m_cb(mailbox, MR_EVENT_CHAT_MODIFIED, contact_chat_id, 0);
// in addition to DC_EVENT_MSGS_CHANGED (sent by mrmailbox_add_device_msg()), also send DC_EVENT_CHAT_MODIFIED to update all views
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, contact_chat_id, 0);
free(msg);
mrcontact_unref(contact);
@ -394,7 +394,7 @@ char* dc_get_securejoin_qr(dc_context_t* mailbox, uint32_t group_chat_id)
}
if( (self_addr = mrsqlite3_get_config__(mailbox->m_sql, "configured_addr", NULL)) == NULL ) {
mrmailbox_log_error(mailbox, 0, "Not configured, cannot generate QR code.");
dc_log_error(mailbox, 0, "Not configured, cannot generate QR code.");
goto cleanup;
}
@ -415,7 +415,7 @@ char* dc_get_securejoin_qr(dc_context_t* mailbox, uint32_t group_chat_id)
// parameters used: a=g=x=i=s=
chat = mrmailbox_get_chat(mailbox, group_chat_id);
if( chat == NULL || chat->m_type != MR_CHAT_TYPE_VERIFIED_GROUP ) {
mrmailbox_log_error(mailbox, 0, "Secure join is only available for verified groups.");
dc_log_error(mailbox, 0, "Secure join is only available for verified groups.");
goto cleanup;
}
group_name = mrchat_get_name(chat);
@ -483,7 +483,7 @@ uint32_t dc_join_securejoin(dc_context_t* mailbox, const char* qr)
mrlot_t* qr_scan = NULL;
int join_vg = 0;
mrmailbox_log_info(mailbox, 0, "Requesting secure-join ...");
dc_log_info(mailbox, 0, "Requesting secure-join ...");
mrmailbox_ensure_secret_key_exists(mailbox);
@ -493,19 +493,19 @@ uint32_t dc_join_securejoin(dc_context_t* mailbox, const char* qr)
if( ((qr_scan=mrmailbox_check_qr(mailbox, qr))==NULL)
|| (qr_scan->m_state!=MR_QR_ASK_VERIFYCONTACT && qr_scan->m_state!=MR_QR_ASK_VERIFYGROUP) ) {
mrmailbox_log_error(mailbox, 0, "Unknown QR code.");
dc_log_error(mailbox, 0, "Unknown QR code.");
goto cleanup;
}
if( (contact_chat_id=mrmailbox_create_chat_by_contact_id(mailbox, qr_scan->m_id)) == 0 ) {
mrmailbox_log_error(mailbox, 0, "Unknown contact.");
dc_log_error(mailbox, 0, "Unknown contact.");
goto cleanup;
}
CHECK_EXIT
if( mailbox->m_cb(mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
mrmailbox_log_error(mailbox, MR_ERR_NONETWORK, NULL);
if( mailbox->m_cb(mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
dc_log_error(mailbox, DC_ERROR_NO_NETWORK, NULL);
goto cleanup;
}
@ -520,9 +520,9 @@ uint32_t dc_join_securejoin(dc_context_t* mailbox, const char* qr)
if( fingerprint_equals_sender(mailbox, qr_scan->m_fingerprint, contact_chat_id) ) {
// the scanned fingerprint matches Alice's key, we can proceed to step 4b) directly and save two mails
mrmailbox_log_info(mailbox, 0, "Taking protocol shortcut.");
dc_log_info(mailbox, 0, "Taking protocol shortcut.");
s_bob_expects = VC_CONTACT_CONFIRM;
mailbox->m_cb(mailbox, MR_EVENT_SECUREJOIN_JOINER_PROGRESS, chat_id_2_contact_id(mailbox, contact_chat_id), 4);
mailbox->m_cb(mailbox, DC_EVENT_SECUREJOIN_JOINER_PROGRESS, chat_id_2_contact_id(mailbox, contact_chat_id), 4);
char* own_fingerprint = get_self_fingerprint(mailbox);
send_handshake_msg(mailbox, contact_chat_id, join_vg? "vg-request-with-auth" : "vc-request-with-auth",
qr_scan->m_auth, own_fingerprint, join_vg? qr_scan->m_text2 : NULL); // Bob -> Alice
@ -585,7 +585,7 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
if( (step=lookup_field(mimeparser, "Secure-Join")) == NULL ) {
goto cleanup;
}
mrmailbox_log_info(mailbox, 0, ">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message '%s' received", step);
dc_log_info(mailbox, 0, ">>>>>>>>>>>>>>>>>>>>>>>>> secure-join message '%s' received", step);
join_vg = (strncmp(step, "vg-", 3)==0);
LOCK
@ -612,20 +612,20 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
// verify that the `Secure-Join-Invitenumber:`-header matches invitenumber written to the QR code
const char* invitenumber = NULL;
if( (invitenumber=lookup_field(mimeparser, "Secure-Join-Invitenumber")) == NULL ) {
mrmailbox_log_warning(mailbox, 0, "Secure-join denied (invitenumber missing)."); // do not raise an error, this might just be spam or come from an old request
dc_log_warning(mailbox, 0, "Secure-join denied (invitenumber missing)."); // do not raise an error, this might just be spam or come from an old request
goto cleanup;
}
LOCK
if( mrtoken_exists__(mailbox, MRT_INVITENUMBER, invitenumber) == 0 ) {
mrmailbox_log_warning(mailbox, 0, "Secure-join denied (bad invitenumber)."); // do not raise an error, this might just be spam or come from an old request
dc_log_warning(mailbox, 0, "Secure-join denied (bad invitenumber)."); // do not raise an error, this might just be spam or come from an old request
goto cleanup;
}
UNLOCK
mrmailbox_log_info(mailbox, 0, "Secure-join requested.");
dc_log_info(mailbox, 0, "Secure-join requested.");
mailbox->m_cb(mailbox, MR_EVENT_SECUREJOIN_INVITER_PROGRESS, contact_id, 3);
mailbox->m_cb(mailbox, DC_EVENT_SECUREJOIN_INVITER_PROGRESS, contact_id, 3);
send_handshake_msg(mailbox, contact_chat_id, join_vg? "vg-auth-required" : "vc-auth-required",
NULL, NULL, NULL); // Alice -> Bob
@ -640,7 +640,7 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
// verify that Alice's Autocrypt key and fingerprint matches the QR-code
LOCK
if( s_bobs_qr_scan == NULL || s_bob_expects != VC_AUTH_REQUIRED || (join_vg && s_bobs_qr_scan->m_state!=MR_QR_ASK_VERIFYGROUP) ) {
mrmailbox_log_warning(mailbox, 0, "auth-required message out of sync.");
dc_log_warning(mailbox, 0, "auth-required message out of sync.");
goto cleanup; // no error, just aborted somehow or a mail from another handshake
}
scanned_fingerprint_of_alice = safe_strdup(s_bobs_qr_scan->m_fingerprint);
@ -663,11 +663,11 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
goto cleanup;
}
mrmailbox_log_info(mailbox, 0, "Fingerprint verified.");
dc_log_info(mailbox, 0, "Fingerprint verified.");
own_fingerprint = get_self_fingerprint(mailbox);
mailbox->m_cb(mailbox, MR_EVENT_SECUREJOIN_JOINER_PROGRESS, contact_id, 4);
mailbox->m_cb(mailbox, DC_EVENT_SECUREJOIN_JOINER_PROGRESS, contact_id, 4);
s_bob_expects = VC_CONTACT_CONFIRM;
send_handshake_msg(mailbox, contact_chat_id, join_vg? "vg-request-with-auth" : "vc-request-with-auth",
@ -699,7 +699,7 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
goto cleanup;
}
mrmailbox_log_info(mailbox, 0, "Fingerprint verified.");
dc_log_info(mailbox, 0, "Fingerprint verified.");
// verify that the `Secure-Join-Auth:`-header matches the secret written to the QR code
const char* auth = NULL;
@ -726,12 +726,12 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
mrmailbox_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_SECUREJOIN_INVITED);
UNLOCK
mrmailbox_log_info(mailbox, 0, "Auth verified.");
dc_log_info(mailbox, 0, "Auth verified.");
secure_connection_established(mailbox, contact_chat_id);
mailbox->m_cb(mailbox, MR_EVENT_CONTACTS_CHANGED, contact_id/*selected contact*/, 0);
mailbox->m_cb(mailbox, MR_EVENT_SECUREJOIN_INVITER_PROGRESS, contact_id, 6);
mailbox->m_cb(mailbox, DC_EVENT_CONTACTS_CHANGED, contact_id/*selected contact*/, 0);
mailbox->m_cb(mailbox, DC_EVENT_SECUREJOIN_INVITER_PROGRESS, contact_id, 6);
if( join_vg ) {
// the vg-member-added message is special: this is a normal Chat-Group-Member-Added message with an additional Secure-Join header
@ -741,7 +741,7 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
uint32_t verified_chat_id = mrmailbox_get_chat_id_by_grpid__(mailbox, grpid, NULL, &is_verified);
UNLOCK
if( verified_chat_id == 0 || !is_verified ) {
mrmailbox_log_error(mailbox, 0, "Verified chat not found.");
dc_log_error(mailbox, 0, "Verified chat not found.");
goto cleanup;
}
@ -766,17 +766,17 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
if( s_bob_expects != VC_CONTACT_CONFIRM ) {
if( join_vg ) {
mrmailbox_log_info(mailbox, 0, "vg-member-added received as broadcast.");
dc_log_info(mailbox, 0, "vg-member-added received as broadcast.");
}
else {
mrmailbox_log_warning(mailbox, 0, "Unexpected secure-join mail order.");
dc_log_warning(mailbox, 0, "Unexpected secure-join mail order.");
}
goto cleanup;
}
LOCK
if( s_bobs_qr_scan == NULL || (join_vg && s_bobs_qr_scan->m_state!=MR_QR_ASK_VERIFYGROUP) ) {
mrmailbox_log_warning(mailbox, 0, "Message out of sync or belongs to a different handshake.");
dc_log_warning(mailbox, 0, "Message out of sync or belongs to a different handshake.");
goto cleanup;
}
scanned_fingerprint_of_alice = safe_strdup(s_bobs_qr_scan->m_fingerprint);
@ -801,7 +801,7 @@ int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, mrmimeparser_t*
secure_connection_established(mailbox, contact_chat_id);
mailbox->m_cb(mailbox, MR_EVENT_CONTACTS_CHANGED, 0/*no select event*/, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONTACTS_CHANGED, 0/*no select event*/, 0);
s_bob_expects = 0;
end_bobs_joining(mailbox, BOB_SUCCESS);

View file

@ -100,19 +100,19 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
return 0;
}
if( ths->m_mailbox->m_cb(ths->m_mailbox, MR_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, MR_ERR_NONETWORK, NULL);
if( ths->m_mailbox->m_cb(ths->m_mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, DC_ERROR_NO_NETWORK, NULL);
goto cleanup;
}
if( ths->m_hEtpan ) {
mrmailbox_log_warning(ths->m_mailbox, 0, "SMTP already connected.");
dc_log_warning(ths->m_mailbox, 0, "SMTP already connected.");
success = 1; /* otherwise, the handle would get deleted */
goto cleanup;
}
if( lp->m_addr == NULL || lp->m_send_server == NULL || lp->m_send_port == 0 ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP bad parameters.");
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP bad parameters.");
goto cleanup;
}
@ -121,7 +121,7 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
ths->m_hEtpan = mailsmtp_new(0, NULL);
if( ths->m_hEtpan == NULL ) {
mrmailbox_log_error(ths->m_mailbox, 0, "SMTP-object creation failed.");
dc_log_error(ths->m_mailbox, 0, "SMTP-object creation failed.");
goto cleanup;
}
mailsmtp_set_timeout(ths->m_hEtpan, MR_SMTP_TIMEOUT_SEC);
@ -134,14 +134,14 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
if( lp->m_server_flags&(MR_SMTP_SOCKET_STARTTLS|MR_SMTP_SOCKET_PLAIN) )
{
if( (r=mailsmtp_socket_connect(ths->m_hEtpan, lp->m_send_server, lp->m_send_port)) != MAILSMTP_NO_ERROR ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-Socket connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-Socket connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
goto cleanup;
}
}
else
{
if( (r=mailsmtp_ssl_connect(ths->m_hEtpan, lp->m_send_server, lp->m_send_port)) != MAILSMTP_NO_ERROR ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMPT-SSL connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMPT-SSL connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
goto cleanup;
}
}
@ -156,14 +156,14 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
}
if( r != MAILSMTP_NO_ERROR ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
goto cleanup;
}
if( lp->m_server_flags&MR_SMTP_SOCKET_STARTTLS )
{
if( (r=mailsmtp_socket_starttls(ths->m_hEtpan)) != MAILSMTP_NO_ERROR ) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-STARTTLS failed (%s)", mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-STARTTLS failed (%s)", mailsmtp_strerror(r));
goto cleanup;
}
@ -176,18 +176,18 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
}
if (r != MAILSMTP_NO_ERROR) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
goto cleanup;
}
mrmailbox_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i STARTTLS-connected.", lp->m_send_server, (int)lp->m_send_port);
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i STARTTLS-connected.", lp->m_send_server, (int)lp->m_send_port);
}
else if( lp->m_server_flags&MR_SMTP_SOCKET_PLAIN )
{
mrmailbox_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i connected.", lp->m_send_server, (int)lp->m_send_port);
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i connected.", lp->m_send_server, (int)lp->m_send_port);
}
else
{
mrmailbox_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i SSL-connected.", lp->m_send_server, (int)lp->m_send_port);
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i SSL-connected.", lp->m_send_server, (int)lp->m_send_port);
}
if( lp->m_send_user )
@ -198,25 +198,25 @@ int mrsmtp_connect(mrsmtp_t* ths, const mrloginparam_t* lp)
* So here we try a workaround. See https://github.com/deltachat/deltachat-android/issues/67
*/
if (ths->m_hEtpan->auth & MAILSMTP_AUTH_PLAIN) {
mrmailbox_log_info(ths->m_mailbox, 0, "Trying SMTP-Login workaround \"%s\"...", lp->m_send_user);
dc_log_info(ths->m_mailbox, 0, "Trying SMTP-Login workaround \"%s\"...", lp->m_send_user);
int err;
char hostname[513];
err = gethostname(hostname, sizeof(hostname));
if (err < 0) {
mrmailbox_log_error(ths->m_mailbox, 0, "SMTP-Login: Cannot get hostname.");
dc_log_error(ths->m_mailbox, 0, "SMTP-Login: Cannot get hostname.");
goto cleanup;
}
r = mailesmtp_auth_sasl(ths->m_hEtpan, "PLAIN", hostname, NULL, NULL, NULL, lp->m_send_user, lp->m_send_pw, NULL);
}
if (r != MAILSMTP_NO_ERROR)
{
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-login failed for user %s (%s)", lp->m_send_user, mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-login failed for user %s (%s)", lp->m_send_user, mailsmtp_strerror(r));
goto cleanup;
}
}
mrmailbox_log_info(ths->m_mailbox, 0, "SMTP-login as %s ok.", lp->m_send_user);
dc_log_info(ths->m_mailbox, 0, "SMTP-login as %s ok.", lp->m_send_user);
}
success = 1;
@ -276,7 +276,7 @@ int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not
{
// this error is very usual - we've simply lost the server connection and reconnect as soon as possible.
// so, we do not log the first time this happens
mrmailbox_log_error_if(&ths->m_log_usual_error, ths->m_mailbox, 0, "mailsmtp_mail: %s, %s (%i)", ths->m_from, mailsmtp_strerror(r), (int)r);
dc_log_error_if(&ths->m_log_usual_error, ths->m_mailbox, 0, "mailsmtp_mail: %s, %s (%i)", ths->m_from, mailsmtp_strerror(r), (int)r);
ths->m_log_usual_error = 1;
goto cleanup;
}
@ -289,7 +289,7 @@ int mrsmtp_send_msg(mrsmtp_t* ths, const clist* recipients, const char* data_not
if( (r = (ths->m_esmtp?
mailesmtp_rcpt(ths->m_hEtpan, rcpt, MAILSMTP_DSN_NOTIFY_FAILURE|MAILSMTP_DSN_NOTIFY_DELAY, NULL) :
mailsmtp_rcpt(ths->m_hEtpan, rcpt))) != MAILSMTP_NO_ERROR) {
mrmailbox_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "mailsmtp_rcpt: %s: %s", rcpt, mailsmtp_strerror(r));
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "mailsmtp_rcpt: %s: %s", rcpt, mailsmtp_strerror(r));
goto cleanup;
}
}

View file

@ -52,8 +52,8 @@ void mrsqlite3_log_error(mrsqlite3_t* ths, const char* msg_format, ...)
va_list va;
va_start(va, msg_format);
msg = sqlite3_vmprintf(msg_format, va); if( msg == NULL ) { mrmailbox_log_error(ths->m_mailbox, 0, "Bad log format string \"%s\".", msg_format); }
mrmailbox_log_error(ths->m_mailbox, 0, "%s SQLite says: %s", msg, ths->m_cobj? sqlite3_errmsg(ths->m_cobj) : notSetUp);
msg = sqlite3_vmprintf(msg_format, va); if( msg == NULL ) { dc_log_error(ths->m_mailbox, 0, "Bad log format string \"%s\".", msg_format); }
dc_log_error(ths->m_mailbox, 0, "%s SQLite says: %s", msg, ths->m_cobj? sqlite3_errmsg(ths->m_cobj) : notSetUp);
sqlite3_free(msg);
va_end(va);
}
@ -158,12 +158,12 @@ int mrsqlite3_open__(mrsqlite3_t* ths, const char* dbfile, int flags)
}
if( sqlite3_threadsafe() == 0 ) {
mrmailbox_log_error(ths->m_mailbox, 0, "Sqlite3 compiled thread-unsafe; this is not supported.");
dc_log_error(ths->m_mailbox, 0, "Sqlite3 compiled thread-unsafe; this is not supported.");
goto cleanup;
}
if( ths->m_cobj ) {
mrmailbox_log_error(ths->m_mailbox, 0, "Cannot open, database \"%s\" already opened.", dbfile);
dc_log_error(ths->m_mailbox, 0, "Cannot open, database \"%s\" already opened.", dbfile);
goto cleanup;
}
@ -192,7 +192,7 @@ int mrsqlite3_open__(mrsqlite3_t* ths, const char* dbfile, int flags)
/* Init tables to dbversion=0 */
if( !mrsqlite3_table_exists__(ths, "config") )
{
mrmailbox_log_info(ths->m_mailbox, 0, "First time init: creating tables in \"%s\".", dbfile);
dc_log_info(ths->m_mailbox, 0, "First time init: creating tables in \"%s\".", dbfile);
mrsqlite3_execute__(ths, "CREATE TABLE config (id INTEGER PRIMARY KEY, keyname TEXT, value TEXT);");
mrsqlite3_execute__(ths, "CREATE INDEX config_index1 ON config (keyname);");
@ -454,7 +454,7 @@ int mrsqlite3_open__(mrsqlite3_t* ths, const char* dbfile, int flags)
}
}
mrmailbox_log_info(ths->m_mailbox, 0, "Opened \"%s\" successfully.", dbfile);
dc_log_info(ths->m_mailbox, 0, "Opened \"%s\" successfully.", dbfile);
return 1;
cleanup:
@ -484,7 +484,7 @@ void mrsqlite3_close__(mrsqlite3_t* ths)
ths->m_cobj = NULL;
}
mrmailbox_log_info(ths->m_mailbox, 0, "Database closed."); /* We log the information even if not real closing took place; this is to detect logic errors. */
dc_log_info(ths->m_mailbox, 0, "Database closed."); /* We log the information even if not real closing took place; this is to detect logic errors. */
}
@ -550,7 +550,7 @@ int mrsqlite3_table_exists__(mrsqlite3_t* ths, const char* name)
int sqlState;
if( (querystr=sqlite3_mprintf("PRAGMA table_info(%s)", name)) == NULL ) { /* this statement cannot be used with binded variables */
mrmailbox_log_error(ths->m_mailbox, 0, "mrsqlite3_table_exists_(): Out of memory.");
dc_log_error(ths->m_mailbox, 0, "mrsqlite3_table_exists_(): Out of memory.");
goto cleanup;
}
@ -591,12 +591,12 @@ int mrsqlite3_set_config__(mrsqlite3_t* ths, const char* key, const char* value)
sqlite3_stmt* stmt;
if( key == NULL ) {
mrmailbox_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Bad parameter.");
dc_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Bad parameter.");
return 0;
}
if( !mrsqlite3_is_open(ths) ) {
mrmailbox_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Database not ready.");
dc_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Database not ready.");
return 0;
}
@ -621,7 +621,7 @@ int mrsqlite3_set_config__(mrsqlite3_t* ths, const char* key, const char* value)
state=sqlite3_step(stmt);
}
else {
mrmailbox_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Cannot read value.");
dc_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Cannot read value.");
return 0;
}
}
@ -634,7 +634,7 @@ int mrsqlite3_set_config__(mrsqlite3_t* ths, const char* key, const char* value)
}
if( state != SQLITE_DONE ) {
mrmailbox_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Cannot change value.");
dc_log_error(ths->m_mailbox, 0, "mrsqlite3_set_config(): Cannot change value.");
return 0;
}
@ -704,13 +704,13 @@ void mrsqlite3_lock(mrsqlite3_t* ths) /* wait and lock */
{
#ifdef MR_USE_LOCK_DEBUG
clock_t start = clock();
mrmailbox_log_info(ths->m_mailbox, 0, " waiting for lock at %s#L%i", filename, linenum);
dc_log_info(ths->m_mailbox, 0, " waiting for lock at %s#L%i", filename, linenum);
#endif
pthread_mutex_lock(&ths->m_critical_);
#ifdef MR_USE_LOCK_DEBUG
mrmailbox_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
dc_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
#endif
}
@ -722,7 +722,7 @@ void mrsqlite3_unlock(mrsqlite3_t* ths)
#endif
{
#ifdef MR_USE_LOCK_DEBUG
mrmailbox_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
dc_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
#endif
pthread_mutex_unlock(&ths->m_critical_);

View file

@ -84,7 +84,7 @@ char* mrstock_str(int id) /* get the string with the given ID, the result must b
{
char* ret = NULL;
if( s_localize_mb_obj && s_localize_mb_obj->m_cb ) {
ret = (char*)s_localize_mb_obj->m_cb(s_localize_mb_obj, MR_EVENT_GET_STRING, id, 0);
ret = (char*)s_localize_mb_obj->m_cb(s_localize_mb_obj, DC_EVENT_GET_STRING, id, 0);
}
if( ret == NULL ) {
ret = default_string(id, 0);
@ -123,7 +123,7 @@ char* mrstock_str_repl_pl(int id, int cnt)
{
char* ret = NULL;
if( s_localize_mb_obj && s_localize_mb_obj->m_cb ) {
ret = (char*)s_localize_mb_obj->m_cb(s_localize_mb_obj, MR_EVENT_GET_QUANTITY_STRING, id, cnt);
ret = (char*)s_localize_mb_obj->m_cb(s_localize_mb_obj, DC_EVENT_GET_QUANTITY_STRING, id, cnt);
}
if( ret == NULL ) {
ret = default_string(id, cnt);

View file

@ -32,7 +32,7 @@ extern "C" {
#include <string.h>
/* Strings requested by MR_EVENT_GET_STRING and MR_EVENT_GET_QUANTITY_STRING */
/* Strings requested by DC_EVENT_GET_STRING and DC_EVENT_GET_QUANTITY_STRING */
#define MR_STR_FREE_ 0
#define MR_STR_NOMESSAGES 1
#define MR_STR_SELF 2
@ -76,7 +76,7 @@ extern "C" {
extern mrmailbox_t* s_localize_mb_obj;
/* Return the string with the given ID by calling MR_EVENT_GET_STRING.
/* Return the string with the given ID by calling DC_EVENT_GET_STRING.
The result must be free()'d! */
char* mrstock_str (int id);
@ -92,7 +92,7 @@ The result must be free()'d! */
char* mrstock_str_repl_string2 (int id, const char*, const char*);
/* Return a string with a correct plural form by callint MR_EVENT_GET_QUANTITY_STRING.
/* Return a string with a correct plural form by callint DC_EVENT_GET_QUANTITY_STRING.
The result must be free()'d! */
char* mrstock_str_repl_pl (int id, int cnt);

View file

@ -1025,7 +1025,7 @@ int mr_delete_file(const char* pathNfilename, mrmailbox_t* log/*may be NULL*/)
}
if( remove(pathNfilename)!=0 ) {
mrmailbox_log_warning(log, 0, "Cannot delete \"%s\".", pathNfilename);
dc_log_warning(log, 0, "Cannot delete \"%s\".", pathNfilename);
return 0;
}
@ -1046,18 +1046,18 @@ int mr_copy_file(const char* src, const char* dest, mrmailbox_t* log/*may be NUL
}
if( (fd_src=open(src, O_RDONLY)) < 0 ) {
mrmailbox_log_error(log, 0, "Cannot open source file \"%s\".", src);
dc_log_error(log, 0, "Cannot open source file \"%s\".", src);
goto cleanup;
}
if( (fd_dest=open(dest, O_WRONLY|O_CREAT|O_EXCL, 0666)) < 0 ) {
mrmailbox_log_error(log, 0, "Cannot open destination file \"%s\".", dest);
dc_log_error(log, 0, "Cannot open destination file \"%s\".", dest);
goto cleanup;
}
while( (bytes_read=read(fd_src, buf, MR_COPY_BUF_SIZE)) > 0 ) {
if (write(fd_dest, buf, bytes_read) != bytes_read) {
mrmailbox_log_error(log, 0, "Cannot write %i bytes to \"%s\".", bytes_read, dest);
dc_log_error(log, 0, "Cannot write %i bytes to \"%s\".", bytes_read, dest);
}
anything_copied = 1;
}
@ -1067,7 +1067,7 @@ int mr_copy_file(const char* src, const char* dest, mrmailbox_t* log/*may be NUL
close(fd_src);
fd_src = -1;
if( mr_get_filebytes(src)!=0 ) {
mrmailbox_log_error(log, 0, "Different size information for \"%s\".", bytes_read, dest);
dc_log_error(log, 0, "Different size information for \"%s\".", bytes_read, dest);
goto cleanup;
}
}
@ -1086,7 +1086,7 @@ int mr_create_folder(const char* pathNfilename, mrmailbox_t* log)
struct stat st;
if (stat(pathNfilename, &st) == -1) {
if( mkdir(pathNfilename, 0755) != 0 ) {
mrmailbox_log_warning(log, 0, "Cannot create directory \"%s\".", pathNfilename);
dc_log_warning(log, 0, "Cannot create directory \"%s\".", pathNfilename);
return 0;
}
}
@ -1188,12 +1188,12 @@ int mr_write_file(const char* pathNfilename, const void* buf, size_t buf_bytes,
success = 1;
}
else {
mrmailbox_log_warning(log, 0, "Cannot write %lu bytes to \"%s\".", (unsigned long)buf_bytes, pathNfilename);
dc_log_warning(log, 0, "Cannot write %lu bytes to \"%s\".", (unsigned long)buf_bytes, pathNfilename);
}
fclose(f);
}
else {
mrmailbox_log_warning(log, 0, "Cannot open \"%s\" for writing.", pathNfilename);
dc_log_warning(log, 0, "Cannot open \"%s\" for writing.", pathNfilename);
}
return success;
@ -1235,7 +1235,7 @@ cleanup:
free(*buf);
*buf = NULL;
*buf_bytes = 0;
mrmailbox_log_warning(log, 0, "Cannot read \"%s\" or file is empty.", pathNfilename);
dc_log_warning(log, 0, "Cannot read \"%s\" or file is empty.", pathNfilename);
}
return success; /* buf must be free()'d by the caller */
}