1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

refactor mrmailbox functions

This commit is contained in:
B. Petersen 2018-06-25 12:49:45 +02:00
parent e1cebe7234
commit 6679f90fbd
21 changed files with 345 additions and 345 deletions

View file

@ -125,7 +125,7 @@ static int mrmailbox_poke_eml_file(mrmailbox_t* ths, const char* filename)
goto cleanup;
}
mrmailbox_receive_imf(ths, data, data_bytes, "import", 0, 0); /* this static function is the reason why this function is not moved to mrmailbox_imex.c */
dc_receive_imf(ths, data, data_bytes, "import", 0, 0); /* this static function is the reason why this function is not moved to mrmailbox_imex.c */
success = 1;
cleanup:
@ -614,10 +614,10 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
}
else if( strcmp(cmd, "export-setup")==0 )
{
char* setup_code = mrmailbox_create_setup_code(mailbox);
char* setup_code = dc_create_setup_code(mailbox);
char* file_name = mr_mprintf("%s/autocrypt-setup-message.html", mailbox->m_blobdir);
char* file_content = NULL;
if( (file_content=mrmailbox_render_setup_file(mailbox, setup_code)) != NULL
if( (file_content=dc_render_setup_file(mailbox, setup_code)) != NULL
&& mr_write_file(file_name, file_content, strlen(file_content), mailbox) ) {
ret = mr_mprintf("Setup message written to: %s\nSetup code: %s", file_name, setup_code);
}

View file

@ -172,7 +172,7 @@ static const char* s_em_setupfile =
"-----END PGP MESSAGE-----\n";
void stress_functions(mrmailbox_t* mailbox)
void stress_functions(dc_context_t* context)
{
/* test mrsimplify and mrsaxparser (indirectly used by mrsimplify)
**************************************************************************/
@ -237,7 +237,7 @@ void stress_functions(mrmailbox_t* mailbox)
**************************************************************************/
{
dc_mimeparser_t* mimeparser = dc_mimeparser_new(mailbox->m_blobdir, mailbox);
dc_mimeparser_t* mimeparser = dc_mimeparser_new(context->m_blobdir, context);
const char* raw =
"Content-Type: multipart/mixed; boundary=\"==break==\";\n"
@ -678,11 +678,11 @@ void stress_functions(mrmailbox_t* mailbox)
**************************************************************************/
{
char* norm = mrmailbox_normalize_setup_code(mailbox, "123422343234423452346234723482349234");
char* norm = dc_normalize_setup_code(context, "123422343234423452346234723482349234");
assert( norm );
assert( strcmp(norm, "1234-2234-3234-4234-5234-6234-7234-8234-9234") == 0 );
norm = mrmailbox_normalize_setup_code(mailbox, "\t1 2 3422343234- foo bar-- 423-45 2 34 6234723482349234 ");
norm = dc_normalize_setup_code(context, "\t1 2 3422343234- foo bar-- 423-45 2 34 6234723482349234 ");
assert( norm );
assert( strcmp(norm, "1234-2234-3234-4234-5234-6234-7234-8234-9234") == 0 );
}
@ -698,7 +698,7 @@ void stress_functions(mrmailbox_t* mailbox)
assert( preferencrypt==NULL );
free(buf);
assert( (buf=mrmailbox_decrypt_setup_file(mailbox, s_em_setupcode, s_em_setupfile)) != NULL );
assert( (buf=dc_decrypt_setup_file(context, s_em_setupcode, s_em_setupfile)) != NULL );
assert( dc_split_armored_data(buf, &headerline, &setupcodebegin, &preferencrypt, NULL) );
assert( headerline && strcmp(headerline, "-----BEGIN PGP PRIVATE KEY BLOCK-----")==0 );
assert( setupcodebegin==NULL );
@ -706,15 +706,15 @@ void stress_functions(mrmailbox_t* mailbox)
free(buf);
}
if( mrmailbox_is_configured(mailbox) )
if( dc_is_configured(context) )
{
char *setupcode = NULL, *setupfile = NULL;
assert( (setupcode=mrmailbox_create_setup_code(mailbox)) != NULL );
assert( (setupcode=dc_create_setup_code(context)) != NULL );
assert( strlen(setupcode) == 44 );
assert( setupcode[4]=='-' && setupcode[9]=='-' && setupcode[14]=='-' && setupcode[19]=='-' && setupcode[24]=='-' && setupcode[29]=='-' && setupcode[34]=='-' && setupcode[39]=='-' );
assert( (setupfile=mrmailbox_render_setup_file(mailbox, setupcode)) != NULL );
assert( (setupfile=dc_render_setup_file(context, setupcode)) != NULL );
{
char *buf = safe_strdup(setupfile);
@ -728,7 +728,7 @@ void stress_functions(mrmailbox_t* mailbox)
{
char *payload = NULL;
const char *headerline = NULL;
assert( (payload=mrmailbox_decrypt_setup_file(mailbox, setupcode, setupfile))!=NULL );
assert( (payload=dc_decrypt_setup_file(context, setupcode, setupfile))!=NULL );
assert( dc_split_armored_data(payload, &headerline, NULL, NULL, NULL) );
assert( headerline && strcmp(headerline, "-----BEGIN PGP PRIVATE KEY BLOCK-----")==0 );
free(payload);
@ -750,28 +750,28 @@ void stress_functions(mrmailbox_t* mailbox)
}
for( int j = 0; j < BAD_DATA_BYTES/40; j++ ) {
dc_key_set_from_binary(bad_key, &bad_data[j], BAD_DATA_BYTES/2 + j, (j&1)? MR_PUBLIC : MR_PRIVATE);
assert( !dc_pgp_is_valid_key(mailbox, bad_key) );
assert( !dc_pgp_is_valid_key(context, bad_key) );
}
dc_key_unref(bad_key);
}
{
dc_key_t *public_key = dc_key_new(), *private_key = dc_key_new();
dc_pgp_create_keypair(mailbox, "foo@bar.de", public_key, private_key);
assert( dc_pgp_is_valid_key(mailbox, public_key) );
assert( dc_pgp_is_valid_key(mailbox, private_key) );
//{char *t1=mrkey_render_asc(public_key); printf("%s",t1);mr_write_file("/home/bpetersen/temp/stress-public.asc", t1,strlen(t1),mailbox);mr_write_file("/home/bpetersen/temp/stress-public.der", public_key->m_binary, public_key->m_bytes, mailbox);free(t1);}
//{char *t1=mrkey_render_asc(private_key);printf("%s",t1);mr_write_file("/home/bpetersen/temp/stress-private.asc",t1,strlen(t1),mailbox);mr_write_file("/home/bpetersen/temp/stress-private.der",private_key->m_binary,private_key->m_bytes,mailbox);free(t1);}
dc_pgp_create_keypair(context, "foo@bar.de", public_key, private_key);
assert( dc_pgp_is_valid_key(context, public_key) );
assert( dc_pgp_is_valid_key(context, private_key) );
//{char *t1=dc_key_render_asc(public_key); printf("%s",t1);mr_write_file("/home/bpetersen/temp/stress-public.asc", t1,strlen(t1),mailbox);mr_write_file("/home/bpetersen/temp/stress-public.der", public_key->m_binary, public_key->m_bytes, mailbox);free(t1);}
//{char *t1=dc_key_render_asc(private_key);printf("%s",t1);mr_write_file("/home/bpetersen/temp/stress-private.asc",t1,strlen(t1),mailbox);mr_write_file("/home/bpetersen/temp/stress-private.der",private_key->m_binary,private_key->m_bytes,mailbox);free(t1);}
{
dc_key_t *test_key = dc_key_new();
assert( dc_pgp_split_key(mailbox, private_key, test_key) );
//assert( mrkey_equals(public_key, test_key) );
assert( dc_pgp_split_key(context, private_key, test_key) );
//assert( dc_key_equals(public_key, test_key) );
dc_key_unref(test_key);
}
dc_key_t *public_key2 = dc_key_new(), *private_key2 = dc_key_new();
dc_pgp_create_keypair(mailbox, "two@zwo.de", public_key2, private_key2);
dc_pgp_create_keypair(context, "two@zwo.de", public_key2, private_key2);
assert( !dc_key_equals(public_key, public_key2) );
@ -783,13 +783,13 @@ void stress_functions(mrmailbox_t* mailbox)
dc_keyring_t* keyring = dc_keyring_new();
dc_keyring_add(keyring, public_key);
dc_keyring_add(keyring, public_key2);
int ok = dc_pgp_pk_encrypt(mailbox, original_text, strlen(original_text), keyring, private_key, 1, (void**)&ctext_signed, &ctext_signed_bytes);
int ok = dc_pgp_pk_encrypt(context, original_text, strlen(original_text), keyring, private_key, 1, (void**)&ctext_signed, &ctext_signed_bytes);
assert( ok && ctext_signed && ctext_signed_bytes>0 );
assert( strncmp((char*)ctext_signed, "-----BEGIN PGP MESSAGE-----", 27)==0 );
assert( ((char*)ctext_signed)[ctext_signed_bytes-1]!=0 ); /*armored strings are not null-terminated!*/
//{char* t3 = mr_null_terminate((char*)ctext,ctext_bytes);printf("\n%i ENCRYPTED BYTES: {\n%s\n}\n",(int)ctext_bytes,t3);free(t3);}
ok = dc_pgp_pk_encrypt(mailbox, original_text, strlen(original_text), keyring, NULL, 1, (void**)&ctext_unsigned, &ctext_unsigned_bytes);
ok = dc_pgp_pk_encrypt(context, original_text, strlen(original_text), keyring, NULL, 1, (void**)&ctext_unsigned, &ctext_unsigned_bytes);
assert( ok && ctext_unsigned && ctext_unsigned_bytes>0 );
assert( strncmp((char*)ctext_unsigned, "-----BEGIN PGP MESSAGE-----", 27)==0 );
assert( ctext_unsigned_bytes < ctext_signed_bytes );
@ -812,21 +812,21 @@ void stress_functions(mrmailbox_t* mailbox)
dc_hash_init(&valid_signatures, MRHASH_STRING, 1/*copy key*/);
int ok;
ok = dc_pgp_pk_decrypt(mailbox, ctext_signed, ctext_signed_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
ok = dc_pgp_pk_decrypt(context, ctext_signed, ctext_signed_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
assert( ok && plain && plain_bytes>0 );
assert( strncmp((char*)plain, original_text, strlen(original_text))==0 );
assert( dc_hash_count(&valid_signatures) == 1 );
free(plain); plain = NULL;
dc_hash_clear(&valid_signatures);
ok = dc_pgp_pk_decrypt(mailbox, ctext_signed, ctext_signed_bytes, keyring, NULL/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
ok = dc_pgp_pk_decrypt(context, ctext_signed, ctext_signed_bytes, keyring, NULL/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
assert( ok && plain && plain_bytes>0 );
assert( strncmp((char*)plain, original_text, strlen(original_text))==0 );
assert( dc_hash_count(&valid_signatures) == 0 );
free(plain); plain = NULL;
dc_hash_clear(&valid_signatures);
ok = dc_pgp_pk_decrypt(mailbox, ctext_signed, ctext_signed_bytes, keyring, public_keyring2/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
ok = dc_pgp_pk_decrypt(context, ctext_signed, ctext_signed_bytes, keyring, public_keyring2/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
assert( ok && plain && plain_bytes>0 );
assert( strncmp((char*)plain, original_text, strlen(original_text))==0 );
assert( dc_hash_count(&valid_signatures) == 0 );
@ -834,14 +834,14 @@ void stress_functions(mrmailbox_t* mailbox)
dc_hash_clear(&valid_signatures);
dc_keyring_add(public_keyring2, public_key);
ok = dc_pgp_pk_decrypt(mailbox, ctext_signed, ctext_signed_bytes, keyring, public_keyring2/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
ok = dc_pgp_pk_decrypt(context, ctext_signed, ctext_signed_bytes, keyring, public_keyring2/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
assert( ok && plain && plain_bytes>0 );
assert( strncmp((char*)plain, original_text, strlen(original_text))==0 );
assert( dc_hash_count(&valid_signatures) == 1 );
free(plain); plain = NULL;
dc_hash_clear(&valid_signatures);
ok = dc_pgp_pk_decrypt(mailbox, ctext_unsigned, ctext_unsigned_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
ok = dc_pgp_pk_decrypt(context, ctext_unsigned, ctext_unsigned_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, &valid_signatures);
assert( ok && plain && plain_bytes>0 );
assert( strncmp((char*)plain, original_text, strlen(original_text))==0 );
assert( dc_hash_count(&valid_signatures) == 0 );
@ -861,7 +861,7 @@ void stress_functions(mrmailbox_t* mailbox)
dc_keyring_add(public_keyring, public_key);
void* plain = NULL;
int ok = dc_pgp_pk_decrypt(mailbox, ctext_signed, ctext_signed_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, NULL);
int ok = dc_pgp_pk_decrypt(context, ctext_signed, ctext_signed_bytes, keyring, public_keyring/*for validate*/, 1, &plain, &plain_bytes, NULL);
assert( ok && plain && plain_bytes>0 );
assert( strcmp(plain, original_text)==0 );
free(plain);
@ -888,22 +888,22 @@ void stress_functions(mrmailbox_t* mailbox)
assert( strcmp(fingerprint, "1234567890ABCDABCDEFABCDEF") == 0 );
}
if( mrmailbox_is_configured(mailbox) )
if( dc_is_configured(context) )
{
char* qr = mrmailbox_get_securejoin_qr(mailbox, 0);
char* qr = dc_get_securejoin_qr(context, 0);
assert( strlen(qr)>55 && strncmp(qr, "OPENPGP4FPR:", 12)==0 && strncmp(&qr[52], "#a=", 3)==0 );
mrlot_t* res = mrmailbox_check_qr(mailbox, qr);
dc_lot_t* res = dc_check_qr(context, qr);
assert( res );
assert( res->m_state == MR_QR_ASK_VERIFYCONTACT || res->m_state == MR_QR_FPR_MISMATCH || res->m_state == MR_QR_FPR_WITHOUT_ADDR );
mrlot_unref(res);
dc_lot_unref(res);
free(qr);
res = mrmailbox_check_qr(mailbox, "BEGIN:VCARD\nVERSION:3.0\nN:Last;First\nEMAIL;TYPE=INTERNET:stress@test.local\nEND:VCARD");
res = dc_check_qr(context, "BEGIN:VCARD\nVERSION:3.0\nN:Last;First\nEMAIL;TYPE=INTERNET:stress@test.local\nEND:VCARD");
assert( res );
assert( res->m_state == MR_QR_ADDR );
assert( res->m_id != 0 );
mrlot_unref(res);
dc_lot_unref(res);
}
}

View file

@ -254,7 +254,7 @@ char* dc_chat_get_subtitle(dc_chat_t* chat)
{
dc_sqlite3_lock(chat->m_context->m_sql);
cnt = mrmailbox_get_chat_contact_count__(chat->m_context, chat->m_id);
cnt = dc_get_chat_contact_count__(chat->m_context, chat->m_id);
ret = mrstock_str_repl_pl(MR_STR_MEMBER, cnt /*SELF is included in group chats (if not removed)*/);
dc_sqlite3_unlock(chat->m_context->m_sql);
@ -513,7 +513,7 @@ static int dc_chat_set_from_stmt__(dc_chat_t* ths, sqlite3_stmt* row)
else if( ths->m_id == MR_CHAT_ID_ARCHIVED_LINK ) {
free(ths->m_name);
char* tempname = mrstock_str(MR_STR_ARCHIVEDCHATS);
ths->m_name = mr_mprintf("%s (%i)", tempname, mrmailbox_get_archived_count__(ths->m_context));
ths->m_name = mr_mprintf("%s (%i)", tempname, dc_get_archived_count__(ths->m_context));
free(tempname);
}
else if( ths->m_id == MR_CHAT_ID_STARRED ) {

View file

@ -328,7 +328,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
" ORDER BY MAX(c.draft_timestamp, IFNULL(m.timestamp,0)) DESC,m.id DESC;" /* the list starts with the newest chats */
// nb: the query currently shows messages from blocked contacts in groups.
// however, for normal-groups, this is okay as the message is also returned by mrmailbox_get_chat_msgs()
// however, for normal-groups, this is okay as the message is also returned by dc_get_chat_msgs()
// (otherwise it would be hard to follow conversations, wa and tg do the same)
// for the deaddrop, however, they should really be hidden, however, _currently_ the deaddrop is not
// shown at all permanent in the chatlist.
@ -350,7 +350,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
{
/* show normal chatlist */
if( !(listflags & MR_GCL_NO_SPECIALS) ) {
uint32_t last_deaddrop_fresh_msg_id = mrmailbox_get_last_deaddrop_fresh_msg__(ths->m_context);
uint32_t last_deaddrop_fresh_msg_id = dc_get_last_deaddrop_fresh_msg__(ths->m_context);
if( last_deaddrop_fresh_msg_id > 0 ) {
dc_array_add_id(ths->m_chatNlastmsg_ids, MR_CHAT_ID_DEADDROP); /* show deaddrop with the last fresh message */
dc_array_add_id(ths->m_chatNlastmsg_ids, last_deaddrop_fresh_msg_id);
@ -382,7 +382,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
dc_array_add_id(ths->m_chatNlastmsg_ids, sqlite3_column_int(stmt, 1));
}
if( add_archived_link_item && mrmailbox_get_archived_count__(ths->m_context)>0 )
if( add_archived_link_item && dc_get_archived_count__(ths->m_context)>0 )
{
dc_array_add_id(ths->m_chatNlastmsg_ids, MR_CHAT_ID_ARCHIVED_LINK);
dc_array_add_id(ths->m_chatNlastmsg_ids, 0);

View file

@ -375,10 +375,10 @@ void dc_job_do_DC_JOB_CONFIGURE_IMAP(dc_context_t* mailbox, dc_job_t* job)
goto cleanup;
}
mrmailbox_suspend_smtp_thread(mailbox, 1);
dc_suspend_smtp_thread(mailbox, 1);
dc_job_kill_actions(mailbox, DC_JOB_CONFIGURE_IMAP, 0); // normally, the job will be deleted when the function returns. however, on crashes, timouts etc. we do not want the job in the database
if( !mrmailbox_alloc_ongoing(mailbox) ) {
if( !dc_alloc_ongoing(mailbox) ) {
goto cleanup;
}
ongoing_allocated_here = 1;
@ -665,7 +665,7 @@ void dc_job_do_DC_JOB_CONFIGURE_IMAP(dc_context_t* mailbox, dc_job_t* job)
// we generate the keypair just now - we could also postpone this until the first message is sent, however,
// this may result in a unexpected and annoying delay when the user sends his very first message
// (~30 seconds on a Moto G4 play) and might looks as if message sending is always that slow.
mrmailbox_ensure_secret_key_exists(mailbox);
dc_ensure_secret_key_exists(mailbox);
success = 1;
dc_log_info(mailbox, 0, "Configure completed successfully.");
@ -685,10 +685,10 @@ cleanup:
dc_loginparam_unref(param);
dc_loginparam_unref(param_autoconfig);
free(param_addr_urlencoded);
if( ongoing_allocated_here ) { mrmailbox_free_ongoing(mailbox); }
if( ongoing_allocated_here ) { dc_free_ongoing(mailbox); }
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 980, 0);
mrmailbox_suspend_smtp_thread(mailbox, 0);
dc_suspend_smtp_thread(mailbox, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, 990, 0);
mailbox->m_cb(mailbox, DC_EVENT_CONFIGURE_PROGRESS, success? 1000 : 0, 0);
@ -728,7 +728,7 @@ cleanup:
void dc_configure(dc_context_t* mailbox)
{
dc_job_kill_actions(mailbox, DC_JOB_CONFIGURE_IMAP, 0);
dc_job_add(mailbox, DC_JOB_CONFIGURE_IMAP, 0, NULL, 0); // results in a call to mrmailbox_configure_job()
dc_job_add(mailbox, DC_JOB_CONFIGURE_IMAP, 0, NULL, 0); // results in a call to dc_configure_job()
}
@ -772,8 +772,8 @@ int dc_is_configured(dc_context_t* mailbox)
* Returns 0=process started, 1=not started, there is running another process
*/
static int s_ongoing_running = 0;
int mr_shall_stop_ongoing = 1; /* the value 1 avoids mrmailbox_stop_ongoing_process() from stopping already stopped threads */
int mrmailbox_alloc_ongoing(dc_context_t* mailbox)
int mr_shall_stop_ongoing = 1; /* the value 1 avoids dc_stop_ongoing_process() from stopping already stopped threads */
int dc_alloc_ongoing(dc_context_t* mailbox)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
return 0;
@ -791,17 +791,17 @@ int mrmailbox_alloc_ongoing(dc_context_t* mailbox)
/*
* Frees the process allocated with mrmailbox_alloc_ongoing() - independingly of mr_shall_stop_ongoing.
* If mrmailbox_alloc_ongoing() fails, this function MUST NOT be called.
* Frees the process allocated with dc_alloc_ongoing() - independingly of mr_shall_stop_ongoing.
* If dc_alloc_ongoing() fails, this function MUST NOT be called.
*/
void mrmailbox_free_ongoing(dc_context_t* mailbox)
void dc_free_ongoing(dc_context_t* mailbox)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
return;
}
s_ongoing_running = 0;
mr_shall_stop_ongoing = 1; /* avoids mrmailbox_stop_ongoing_process() to stop the thread */
mr_shall_stop_ongoing = 1; /* avoids dc_stop_ongoing_process() to stop the thread */
}

View file

@ -377,7 +377,7 @@ char* mr_get_first_name(const char* full_name)
* - Convert names as "Petersen, Björn" to "Björn Petersen"
* - Trims the resulting string
*
* Typically, this function is not needed as it is called implicitly by mrmailbox_add_address_book()
* Typically, this function is not needed as it is called implicitly by dc_add_address_book()
*
* @private @memberof dc_contact_t
*

View file

@ -43,7 +43,7 @@ struct _dc_contact
* The contact ID.
*
* Special message IDs:
* - MR_CONTACT_ID_SELF (1) - this is the owner of the mailbox with the email-address set by mrmailbox_set_config() using "addr".
* - MR_CONTACT_ID_SELF (1) - this is the owner of the mailbox with the email-address set by dc_set_config() using "addr".
*
* Normal contact IDs are larger than these special ones (larger than MR_CONTACT_ID_LAST_SPECIAL).
*/
@ -72,7 +72,7 @@ struct _dc_contact
#define MR_ORIGIN_ADRESS_BOOK 0x80000 /* address is in our address book */
#define MR_ORIGIN_SECUREJOIN_INVITED 0x1000000 /* set on Alice's side for contacts like Bob that have scanned the QR code offered by her. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verfied() ! */
#define MR_ORIGIN_SECUREJOIN_JOINED 0x2000000 /* set on Bob's side for contacts scanned and verified from a QR code. Only means the contact has once been established using the "securejoin" procedure in the past, getting the current key verification status requires calling dc_contact_is_verfied() ! */
#define MR_ORIGIN_MANUALLY_CREATED 0x4000000 /* contact added mannually by mrmailbox_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */
#define MR_ORIGIN_MANUALLY_CREATED 0x4000000 /* contact added mannually by dc_create_contact(), this should be the largets origin as otherwise the user cannot modify the names */
#define MR_ORIGIN_MIN_CONTACT_LIST (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are shown in the contact list */
#define MR_ORIGIN_MIN_VERIFIED (MR_ORIGIN_INCOMING_REPLY_TO) /* contacts with at least this origin value are verified and known not to be spam */

View file

@ -63,7 +63,7 @@ static void cb_set_config(dc_imap_t* imap, const char* key, const char* value)
static void cb_receive_imf(dc_imap_t* imap, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags)
{
dc_context_t* mailbox = (dc_context_t*)imap->m_userData;
mrmailbox_receive_imf(mailbox, imf_raw_not_terminated, imf_raw_bytes, server_folder, server_uid, flags);
dc_receive_imf(mailbox, imf_raw_not_terminated, imf_raw_bytes, server_folder, server_uid, flags);
}
@ -159,8 +159,8 @@ void dc_context_unref(dc_context_t* mailbox)
dc_pgp_exit(mailbox);
if( mrmailbox_is_open(mailbox) ) {
mrmailbox_close(mailbox);
if( dc_is_open(mailbox) ) {
dc_close(mailbox);
}
dc_imap_unref(mailbox->m_imap);
@ -532,10 +532,10 @@ char* dc_get_info(dc_context_t* mailbox)
displayname = dc_sqlite3_get_config__(mailbox->m_sql, "displayname", NULL);
chats = mrmailbox_get_chat_cnt__(mailbox);
real_msgs = mrmailbox_get_real_msg_cnt__(mailbox);
deaddrop_msgs = mrmailbox_get_deaddrop_msg_cnt__(mailbox);
contacts = mrmailbox_get_real_contact_cnt__(mailbox);
chats = dc_get_chat_cnt__(mailbox);
real_msgs = dc_get_real_msg_cnt__(mailbox);
deaddrop_msgs = dc_get_deaddrop_msg_cnt__(mailbox);
contacts = dc_get_real_contact_cnt__(mailbox);
is_configured = dc_sqlite3_get_config_int__(mailbox->m_sql, "configured", 0);
@ -646,7 +646,7 @@ char* dc_get_info(dc_context_t* mailbox)
******************************************************************************/
int mrmailbox_get_archived_count__(dc_context_t* mailbox)
int dc_get_archived_count__(dc_context_t* mailbox)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_COUNT_FROM_chats_WHERE_archived,
"SELECT COUNT(*) FROM chats WHERE blocked=0 AND archived=1;");
@ -823,7 +823,7 @@ uint32_t dc_get_chat_id_by_contact_id(dc_context_t* mailbox, uint32_t contact_id
dc_sqlite3_lock(mailbox->m_sql);
mrmailbox_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_id_blocked);
dc_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_id_blocked);
dc_sqlite3_unlock(mailbox->m_sql);
@ -831,7 +831,7 @@ uint32_t dc_get_chat_id_by_contact_id(dc_context_t* mailbox, uint32_t contact_id
}
uint32_t mrmailbox_get_chat_id_by_grpid__(dc_context_t* mailbox, const char* grpid, int* ret_blocked, int* ret_verified)
uint32_t dc_get_chat_id_by_grpid__(dc_context_t* mailbox, const char* grpid, int* ret_blocked, int* ret_verified)
{
uint32_t chat_id = 0;
sqlite3_stmt* stmt;
@ -888,26 +888,26 @@ uint32_t dc_create_chat_by_contact_id(dc_context_t* mailbox, uint32_t contact_id
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
mrmailbox_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_blocked);
dc_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_blocked);
if( chat_id ) {
if( chat_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id); /* unblock chat (typically move it from the deaddrop to view) */
dc_unblock_chat__(mailbox, chat_id); /* unblock chat (typically move it from the deaddrop to view) */
send_event = 1;
}
goto cleanup; /* success */
}
if( 0==mrmailbox_real_contact_exists__(mailbox, contact_id) && contact_id!=MR_CONTACT_ID_SELF ) {
if( 0==dc_real_contact_exists__(mailbox, contact_id) && contact_id!=MR_CONTACT_ID_SELF ) {
dc_log_warning(mailbox, 0, "Cannot create chat, contact %i does not exist.", (int)contact_id);
goto cleanup;
}
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_NOT_BLOCKED, &chat_id, NULL);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_NOT_BLOCKED, &chat_id, NULL);
if( chat_id ) {
send_event = 1;
}
mrmailbox_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_CREATE_CHAT);
dc_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_CREATE_CHAT);
cleanup:
if( locked ) { dc_sqlite3_unlock(mailbox->m_sql); }
@ -972,11 +972,11 @@ uint32_t dc_create_chat_by_msg_id(dc_context_t* mailbox, uint32_t msg_id)
chat_id = chat->m_id;
if( chat->m_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat->m_id);
dc_unblock_chat__(mailbox, chat->m_id);
send_event = 1;
}
mrmailbox_scaleup_contact_origin__(mailbox, msg->m_from_id, MR_ORIGIN_CREATE_CHAT);
dc_scaleup_contact_origin__(mailbox, msg->m_from_id, MR_ORIGIN_CREATE_CHAT);
cleanup:
if( locked ) { dc_sqlite3_unlock(mailbox->m_sql); }
@ -989,7 +989,7 @@ cleanup:
}
static dc_array_t* mrmailbox_get_chat_media__(dc_context_t* mailbox, uint32_t chat_id, int msg_type, int or_msg_type)
static dc_array_t* dc_get_chat_media__(dc_context_t* mailbox, uint32_t chat_id, int msg_type, int or_msg_type)
{
dc_array_t* ret = dc_array_new(mailbox, 100);
@ -1033,7 +1033,7 @@ dc_array_t* dc_get_chat_media(dc_context_t* mailbox, uint32_t chat_id, int msg_t
dc_sqlite3_lock(mailbox->m_sql);
ret = mrmailbox_get_chat_media__(mailbox, chat_id, msg_type, or_msg_type);
ret = dc_get_chat_media__(mailbox, chat_id, msg_type, or_msg_type);
dc_sqlite3_unlock(mailbox->m_sql);
@ -1078,7 +1078,7 @@ uint32_t dc_get_next_media(dc_context_t* mailbox, uint32_t curr_msg_id, int dir)
goto cleanup;
}
if( (list=mrmailbox_get_chat_media__(mailbox, msg->m_chat_id, msg->m_type, 0))==NULL ) {
if( (list=dc_get_chat_media__(mailbox, msg->m_chat_id, msg->m_type, 0))==NULL ) {
goto cleanup;
}
@ -1516,7 +1516,7 @@ cleanup:
}
int mrmailbox_get_fresh_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
int dc_get_fresh_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
{
sqlite3_stmt* stmt = NULL;
@ -1535,7 +1535,7 @@ int mrmailbox_get_fresh_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
}
uint32_t mrmailbox_get_last_deaddrop_fresh_msg__(dc_context_t* mailbox)
uint32_t dc_get_last_deaddrop_fresh_msg__(dc_context_t* mailbox)
{
sqlite3_stmt* stmt = NULL;
@ -1556,7 +1556,7 @@ uint32_t mrmailbox_get_last_deaddrop_fresh_msg__(dc_context_t* mailbox)
}
int mrmailbox_get_total_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
int dc_get_total_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
{
sqlite3_stmt* stmt = NULL;
@ -1572,7 +1572,7 @@ int mrmailbox_get_total_msg_count__(dc_context_t* mailbox, uint32_t chat_id)
}
size_t mrmailbox_get_chat_cnt__(dc_context_t* mailbox)
size_t dc_get_chat_cnt__(dc_context_t* mailbox)
{
sqlite3_stmt* stmt;
@ -1590,7 +1590,7 @@ size_t mrmailbox_get_chat_cnt__(dc_context_t* mailbox)
}
void mrmailbox_lookup_real_nchat_by_contact_id__(dc_context_t* mailbox, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked)
void dc_lookup_real_nchat_by_contact_id__(dc_context_t* mailbox, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked)
{
/* checks for "real" chats or self-chat */
sqlite3_stmt* stmt;
@ -1616,7 +1616,7 @@ void mrmailbox_lookup_real_nchat_by_contact_id__(dc_context_t* mailbox, uint32_t
}
void mrmailbox_create_or_lookup_nchat_by_contact_id__(dc_context_t* mailbox, uint32_t contact_id, int create_blocked, uint32_t* ret_chat_id, int* ret_chat_blocked)
void dc_create_or_lookup_nchat_by_contact_id__(dc_context_t* mailbox, uint32_t contact_id, int create_blocked, uint32_t* ret_chat_id, int* ret_chat_blocked)
{
uint32_t chat_id = 0;
int chat_blocked = 0;
@ -1636,7 +1636,7 @@ void mrmailbox_create_or_lookup_nchat_by_contact_id__(dc_context_t* mailbox, uin
return;
}
mrmailbox_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_blocked);
dc_lookup_real_nchat_by_contact_id__(mailbox, contact_id, &chat_id, &chat_blocked);
if( chat_id != 0 ) {
if( ret_chat_id ) { *ret_chat_id = chat_id; }
if( ret_chat_blocked ) { *ret_chat_blocked = chat_blocked; }
@ -1671,7 +1671,7 @@ void mrmailbox_create_or_lookup_nchat_by_contact_id__(dc_context_t* mailbox, uin
sqlite3_finalize(stmt);
stmt = NULL;
/* add contact IDs to the new chat record (may be replaced by mrmailbox_add_to_chat_contacts_table__()) */
/* add contact IDs to the new chat record (may be replaced by dc_add_to_chat_contacts_table__()) */
q = sqlite3_mprintf("INSERT INTO chats_contacts (chat_id, contact_id) VALUES(%i, %i)", chat_id, contact_id);
stmt = dc_sqlite3_prepare_v2_(mailbox->m_sql, q);
@ -1694,7 +1694,7 @@ cleanup:
}
void mrmailbox_unarchive_chat__(dc_context_t* mailbox, uint32_t chat_id)
void dc_unarchive_chat__(dc_context_t* mailbox, uint32_t chat_id)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, UPDATE_chats_SET_unarchived, "UPDATE chats SET archived=0 WHERE id=?");
sqlite3_bind_int (stmt, 1, chat_id);
@ -1722,7 +1722,7 @@ int dc_get_total_msg_count(dc_context_t* mailbox, uint32_t chat_id)
}
dc_sqlite3_lock(mailbox->m_sql);
ret = mrmailbox_get_total_msg_count__(mailbox, chat_id);
ret = dc_get_total_msg_count__(mailbox, chat_id);
dc_sqlite3_unlock(mailbox->m_sql);
return ret;
@ -1750,7 +1750,7 @@ int dc_get_fresh_msg_count(dc_context_t* mailbox, uint32_t chat_id)
}
dc_sqlite3_lock(mailbox->m_sql);
ret = mrmailbox_get_fresh_msg_count__(mailbox, chat_id);
ret = dc_get_fresh_msg_count__(mailbox, chat_id);
dc_sqlite3_unlock(mailbox->m_sql);
return ret;
@ -1926,7 +1926,7 @@ static int last_msg_in_chat_encrypted(dc_sqlite3_t* sql, uint32_t chat_id)
}
static uint32_t mrmailbox_send_msg_i__(dc_context_t* mailbox, dc_chat_t* chat, const dc_msg_t* msg, time_t timestamp)
static uint32_t dc_send_msg_i__(dc_context_t* mailbox, dc_chat_t* chat, const dc_msg_t* msg, time_t timestamp)
{
char* rfc724_mid = NULL;
sqlite3_stmt* stmt;
@ -1937,7 +1937,7 @@ static uint32_t mrmailbox_send_msg_i__(dc_context_t* mailbox, dc_chat_t* chat, c
goto cleanup;
}
if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) && !mrmailbox_is_contact_in_chat__(mailbox, chat->m_id, MR_CONTACT_ID_SELF) ) {
if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) && !dc_is_contact_in_chat__(mailbox, chat->m_id, MR_CONTACT_ID_SELF) ) {
dc_log_error(mailbox, DC_ERROR_SELF_NOT_IN_GROUP, NULL);
goto cleanup;
}
@ -2039,7 +2039,7 @@ static uint32_t mrmailbox_send_msg_i__(dc_context_t* mailbox, dc_chat_t* chat, c
msg_id = sqlite3_last_insert_rowid(mailbox->m_sql->m_cobj);
/* finalize message object on database, we set the chat ID late as we don't know it sooner */
mrmailbox_update_msg_chat_id__(mailbox, msg_id, chat->m_id);
dc_update_msg_chat_id__(mailbox, msg_id, chat->m_id);
dc_job_add(mailbox, DC_JOB_SEND_MSG_TO_SMTP, msg_id, NULL, 0);
cleanup:
@ -2072,7 +2072,7 @@ cleanup:
*
* @return The ID of the message that is about being sent.
*/
uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, dc_msg_t* msg)
uint32_t dc_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, dc_msg_t* msg)
{
int locked = 0, transaction_pending = 0;
char* pathNfilename = NULL;
@ -2163,14 +2163,14 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, dc_m
dc_sqlite3_begin_transaction__(mailbox->m_sql);
transaction_pending = 1;
mrmailbox_unarchive_chat__(mailbox, chat_id);
dc_unarchive_chat__(mailbox, chat_id);
mailbox->m_smtp->m_log_connect_errors = 1;
{
dc_chat_t* chat = dc_chat_new(mailbox);
if( dc_chat_load_from_db__(chat, chat_id) ) {
msg->m_id = mrmailbox_send_msg_i__(mailbox, chat, msg, mr_create_smeared_timestamp__());
msg->m_id = dc_send_msg_i__(mailbox, chat, msg, mr_create_smeared_timestamp__());
if( msg ->m_id == 0 ) {
goto cleanup; /* error already logged */
}
@ -2223,7 +2223,7 @@ uint32_t dc_send_text_msg(dc_context_t* mailbox, uint32_t chat_id, const char* t
msg->m_type = MR_MSG_TEXT;
msg->m_text = safe_strdup(text_to_send);
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2266,7 +2266,7 @@ uint32_t dc_send_image_msg(dc_context_t* mailbox, uint32_t chat_id, const char*
mrparam_set_int(msg->m_param, MRP_WIDTH, width); /* set in sending job, if 0 */
mrparam_set_int(msg->m_param, MRP_HEIGHT, height); /* set in sending job, if 0 */
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2313,7 +2313,7 @@ uint32_t dc_send_video_msg(dc_context_t* mailbox, uint32_t chat_id, const char*
mrparam_set_int(msg->m_param, MRP_HEIGHT, height);
mrparam_set_int(msg->m_param, MRP_DURATION, duration);
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2355,7 +2355,7 @@ uint32_t dc_send_voice_msg(dc_context_t* mailbox, uint32_t chat_id, const char*
mrparam_set (msg->m_param, MRP_MIMETYPE, filemime);
mrparam_set_int(msg->m_param, MRP_DURATION, duration);
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2400,7 +2400,7 @@ uint32_t dc_send_audio_msg(dc_context_t* mailbox, uint32_t chat_id, const char*
mrparam_set (msg->m_param, MRP_AUTHORNAME, author);
mrparam_set (msg->m_param, MRP_TRACKNAME, trackname);
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2439,7 +2439,7 @@ uint32_t dc_send_file_msg(dc_context_t* mailbox, uint32_t chat_id, const char* f
mrparam_set(msg->m_param, MRP_FILE, file);
mrparam_set(msg->m_param, MRP_MIMETYPE, filemime);
ret = mrmailbox_send_msg_object(mailbox, chat_id, msg);
ret = dc_send_msg_object(mailbox, chat_id, msg);
cleanup:
dc_msg_unref(msg);
@ -2482,7 +2482,7 @@ uint32_t dc_send_vcard_msg(dc_context_t* mailbox, uint32_t chat_id, uint32_t con
goto cleanup;
}
if( (contact=mrmailbox_get_contact(mailbox, contact_id)) == NULL ) {
if( (contact=dc_get_contact(mailbox, contact_id)) == NULL ) {
goto cleanup;
}
@ -2493,7 +2493,7 @@ uint32_t dc_send_vcard_msg(dc_context_t* mailbox, uint32_t chat_id, uint32_t con
text_to_send = safe_strdup(contact->m_addr);
}
ret = mrmailbox_send_text_msg(mailbox, chat_id, text_to_send);
ret = dc_send_text_msg(mailbox, chat_id, text_to_send);
cleanup:
dc_msg_unref(msg);
@ -2503,10 +2503,10 @@ cleanup:
}
/* similar to mrmailbox_add_device_msg() but without locking and without sending
/* similar to dc_add_device_msg() but without locking and without sending
* an event.
*/
uint32_t mrmailbox_add_device_msg__(dc_context_t* mailbox, uint32_t chat_id, const char* text, time_t timestamp)
uint32_t dc_add_device_msg__(dc_context_t* mailbox, uint32_t chat_id, const char* text, time_t timestamp)
{
sqlite3_stmt* stmt = NULL;
@ -2536,7 +2536,7 @@ uint32_t mrmailbox_add_device_msg__(dc_context_t* mailbox, uint32_t chat_id, con
* Such a message is typically shown in the "middle" of the chat, the user can check this using dc_msg_is_info().
* Texts are typically "Alice has added Bob to the group" or "Alice fingerprint verified."
*/
uint32_t mrmailbox_add_device_msg(dc_context_t* mailbox, uint32_t chat_id, const char* text)
uint32_t dc_add_device_msg(dc_context_t* mailbox, uint32_t chat_id, const char* text)
{
uint32_t msg_id = 0;
int locked = 0;
@ -2548,7 +2548,7 @@ uint32_t mrmailbox_add_device_msg(dc_context_t* mailbox, uint32_t chat_id, const
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
mrmailbox_add_device_msg__(mailbox, chat_id, text, mr_create_smeared_timestamp__());
dc_add_device_msg__(mailbox, chat_id, text, mr_create_smeared_timestamp__());
dc_sqlite3_unlock(mailbox->m_sql);
locked = 0;
@ -2566,11 +2566,11 @@ cleanup:
******************************************************************************/
#define IS_SELF_IN_GROUP__ (mrmailbox_is_contact_in_chat__(mailbox, chat_id, MR_CONTACT_ID_SELF)==1)
#define IS_SELF_IN_GROUP__ (dc_is_contact_in_chat__(mailbox, chat_id, MR_CONTACT_ID_SELF)==1)
#define DO_SEND_STATUS_MAILS (mrparam_get_int(chat->m_param, MRP_UNPROMOTED, 0)==0)
int mrmailbox_is_group_explicitly_left__(dc_context_t* mailbox, const char* grpid)
int dc_is_group_explicitly_left__(dc_context_t* mailbox, const char* grpid)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_FROM_leftgrps_WHERE_grpid, "SELECT id FROM leftgrps WHERE grpid=?;");
sqlite3_bind_text (stmt, 1, grpid, -1, SQLITE_STATIC);
@ -2578,9 +2578,9 @@ int mrmailbox_is_group_explicitly_left__(dc_context_t* mailbox, const char* grpi
}
void mrmailbox_set_group_explicitly_left__(dc_context_t* mailbox, const char* grpid)
void dc_set_group_explicitly_left__(dc_context_t* mailbox, const char* grpid)
{
if( !mrmailbox_is_group_explicitly_left__(mailbox, grpid) )
if( !dc_is_group_explicitly_left__(mailbox, grpid) )
{
sqlite3_stmt* stmt = dc_sqlite3_prepare_v2_(mailbox->m_sql, "INSERT INTO leftgrps (grpid) VALUES(?);");
sqlite3_bind_text (stmt, 1, grpid, -1, SQLITE_STATIC);
@ -2590,7 +2590,7 @@ void mrmailbox_set_group_explicitly_left__(dc_context_t* mailbox, const char* gr
}
static int mrmailbox_real_group_exists__(dc_context_t* mailbox, uint32_t chat_id)
static int dc_real_group_exists__(dc_context_t* mailbox, uint32_t chat_id)
{
// check if a group or a verified group exists under the given ID
sqlite3_stmt* stmt;
@ -2615,7 +2615,7 @@ static int mrmailbox_real_group_exists__(dc_context_t* mailbox, uint32_t chat_id
}
int mrmailbox_add_to_chat_contacts_table__(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id)
int dc_add_to_chat_contacts_table__(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id)
{
/* add a contact to a chat; the function does not check the type or if any of the record exist or are already added to the chat! */
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, INSERT_INTO_chats_contacts,
@ -2683,7 +2683,7 @@ uint32_t dc_create_group_chat(dc_context_t* mailbox, int verified, const char* c
goto cleanup;
}
if( mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, MR_CONTACT_ID_SELF) ) {
if( dc_add_to_chat_contacts_table__(mailbox, chat_id, MR_CONTACT_ID_SELF) ) {
goto cleanup;
}
@ -2734,7 +2734,7 @@ int dc_set_chat_name(dc_context_t* mailbox, uint32_t chat_id, const char* new_na
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
if( 0==mrmailbox_real_group_exists__(mailbox, chat_id)
if( 0==dc_real_group_exists__(mailbox, chat_id)
|| 0==dc_chat_load_from_db__(chat, chat_id) ) {
goto cleanup;
}
@ -2763,7 +2763,7 @@ int dc_set_chat_name(dc_context_t* mailbox, uint32_t chat_id, const char* new_na
msg->m_type = MR_MSG_TEXT;
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);
msg->m_id = dc_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
@ -2813,7 +2813,7 @@ int dc_set_chat_profile_image(dc_context_t* mailbox, uint32_t chat_id, const cha
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
if( 0==mrmailbox_real_group_exists__(mailbox, chat_id)
if( 0==dc_real_group_exists__(mailbox, chat_id)
|| 0==dc_chat_load_from_db__(chat, chat_id) ) {
goto cleanup;
}
@ -2838,7 +2838,7 @@ int dc_set_chat_profile_image(dc_context_t* mailbox, uint32_t chat_id, const cha
mrparam_set (msg->m_param, MRP_CMD_PARAM, new_image);
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);
msg->m_id = dc_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
@ -2853,7 +2853,7 @@ cleanup:
}
int mrmailbox_get_chat_contact_count__(dc_context_t* mailbox, uint32_t chat_id)
int dc_get_chat_contact_count__(dc_context_t* mailbox, uint32_t chat_id)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_COUNT_FROM_chats_contacts_WHERE_chat_id,
"SELECT COUNT(*) FROM chats_contacts WHERE chat_id=?;");
@ -2865,7 +2865,7 @@ int mrmailbox_get_chat_contact_count__(dc_context_t* mailbox, uint32_t chat_id)
}
int mrmailbox_is_contact_in_chat__(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id)
int dc_is_contact_in_chat__(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_void_FROM_chats_contacts_WHERE_chat_id_AND_contact_id,
"SELECT contact_id FROM chats_contacts WHERE chat_id=? AND contact_id=?;");
@ -2901,7 +2901,7 @@ int dc_is_contact_in_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t cont
dc_sqlite3_lock(mailbox->m_sql);
ret = mrmailbox_is_contact_in_chat__(mailbox, chat_id, contact_id);
ret = dc_is_contact_in_chat__(mailbox, chat_id, contact_id);
dc_sqlite3_unlock(mailbox->m_sql);
@ -2909,10 +2909,10 @@ int dc_is_contact_in_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t cont
}
int mrmailbox_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id, int flags)
int dc_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id, int flags)
{
int success = 0, locked = 0;
dc_contact_t* contact = mrmailbox_get_contact(mailbox, contact_id);
dc_contact_t* contact = dc_get_contact(mailbox, contact_id);
dc_apeerstate_t* peerstate = dc_apeerstate_new(mailbox);
dc_chat_t* chat = dc_chat_new(mailbox);
dc_msg_t* msg = dc_msg_new();
@ -2925,8 +2925,8 @@ int mrmailbox_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, ui
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
if( 0==mrmailbox_real_group_exists__(mailbox, chat_id) /*this also makes sure, not contacts are added to special or normal chats*/
|| (0==mrmailbox_real_contact_exists__(mailbox, contact_id) && contact_id!=MR_CONTACT_ID_SELF)
if( 0==dc_real_group_exists__(mailbox, chat_id) /*this also makes sure, not contacts are added to special or normal chats*/
|| (0==dc_real_contact_exists__(mailbox, contact_id) && contact_id!=MR_CONTACT_ID_SELF)
|| 0==dc_chat_load_from_db__(chat, chat_id) ) {
goto cleanup;
}
@ -2947,7 +2947,7 @@ int mrmailbox_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, ui
goto cleanup; /* ourself is added using MR_CONTACT_ID_SELF, do not add it explicitly. if SELF is not in the group, members cannot be added at all. */
}
if( mrmailbox_is_contact_in_chat__(mailbox, chat_id, contact_id) )
if( dc_is_contact_in_chat__(mailbox, chat_id, contact_id) )
{
if( !(flags&MR_FROM_HANDSHAKE) ) {
success = 1;
@ -2966,7 +2966,7 @@ int mrmailbox_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, ui
}
}
if( 0==mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, contact_id) ) {
if( 0==dc_add_to_chat_contacts_table__(mailbox, chat_id, contact_id) ) {
goto cleanup;
}
}
@ -2982,7 +2982,7 @@ int mrmailbox_add_contact_to_chat_ex(dc_context_t* mailbox, uint32_t chat_id, ui
mrparam_set_int(msg->m_param, MRP_CMD, MR_CMD_MEMBER_ADDED_TO_GROUP);
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);
msg->m_id = dc_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
@ -3022,7 +3022,7 @@ cleanup:
*/
int dc_add_contact_to_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/)
{
return mrmailbox_add_contact_to_chat_ex(mailbox, chat_id, contact_id, 0);
return dc_add_contact_to_chat_ex(mailbox, chat_id, contact_id, 0);
}
@ -3047,7 +3047,7 @@ int dc_add_contact_to_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t con
int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t contact_id /*may be MR_CONTACT_ID_SELF*/)
{
int success = 0, locked = 0;
dc_contact_t* contact = mrmailbox_get_contact(mailbox, contact_id);
dc_contact_t* contact = dc_get_contact(mailbox, contact_id);
dc_chat_t* chat = dc_chat_new(mailbox);
dc_msg_t* msg = dc_msg_new();
char* q3 = NULL;
@ -3059,7 +3059,7 @@ int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
if( 0==mrmailbox_real_group_exists__(mailbox, chat_id)
if( 0==dc_real_group_exists__(mailbox, chat_id)
|| 0==dc_chat_load_from_db__(chat, chat_id) ) {
goto cleanup;
}
@ -3080,7 +3080,7 @@ int dc_remove_contact_from_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_
{
msg->m_type = MR_MSG_TEXT;
if( contact->m_id == MR_CONTACT_ID_SELF ) {
mrmailbox_set_group_explicitly_left__(mailbox, chat->m_grpid);
dc_set_group_explicitly_left__(mailbox, chat->m_grpid);
msg->m_text = mrstock_str(MR_STR_MSGGROUPLEFT);
}
else {
@ -3088,7 +3088,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);
msg->m_id = dc_send_msg_object(mailbox, chat_id, msg);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, chat_id, msg->m_id);
}
}
@ -3123,7 +3123,7 @@ cleanup:
******************************************************************************/
int mrmailbox_real_contact_exists__(dc_context_t* mailbox, uint32_t contact_id)
int dc_real_contact_exists__(dc_context_t* mailbox, uint32_t contact_id)
{
sqlite3_stmt* stmt;
int ret = 0;
@ -3145,7 +3145,7 @@ int mrmailbox_real_contact_exists__(dc_context_t* mailbox, uint32_t contact_id)
}
size_t mrmailbox_get_real_contact_cnt__(dc_context_t* mailbox)
size_t dc_get_real_contact_cnt__(dc_context_t* mailbox)
{
sqlite3_stmt* stmt;
@ -3163,7 +3163,7 @@ size_t mrmailbox_get_real_contact_cnt__(dc_context_t* mailbox)
}
uint32_t mrmailbox_add_or_lookup_contact__( dc_context_t* mailbox,
uint32_t dc_add_or_lookup_contact__( dc_context_t* mailbox,
const char* name /*can be NULL, the caller may use mr_normalize_name() before*/,
const char* addr__,
int origin,
@ -3281,7 +3281,7 @@ cleanup:
}
void mrmailbox_scaleup_contact_origin__(dc_context_t* mailbox, uint32_t contact_id, int origin)
void dc_scaleup_contact_origin__(dc_context_t* mailbox, uint32_t contact_id, int origin)
{
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
return;
@ -3296,7 +3296,7 @@ void mrmailbox_scaleup_contact_origin__(dc_context_t* mailbox, uint32_t contact_
}
int mrmailbox_is_contact_blocked__(dc_context_t* mailbox, uint32_t contact_id)
int dc_is_contact_blocked__(dc_context_t* mailbox, uint32_t contact_id)
{
int is_blocked = 0;
dc_contact_t* contact = dc_contact_new(mailbox);
@ -3312,7 +3312,7 @@ int mrmailbox_is_contact_blocked__(dc_context_t* mailbox, uint32_t contact_id)
}
int mrmailbox_get_contact_origin__(dc_context_t* mailbox, uint32_t contact_id, int* ret_blocked)
int dc_get_contact_origin__(dc_context_t* mailbox, uint32_t contact_id, int* ret_blocked)
{
int ret = 0;
int dummy; if( ret_blocked==NULL ) { ret_blocked = &dummy; }
@ -3373,16 +3373,16 @@ uint32_t dc_create_contact(dc_context_t* mailbox, const char* name, const char*
dc_sqlite3_lock(mailbox->m_sql);
contact_id = mrmailbox_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_MANUALLY_CREATED, &sth_modified);
contact_id = dc_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_MANUALLY_CREATED, &sth_modified);
blocked = mrmailbox_is_contact_blocked__(mailbox, contact_id);
blocked = dc_is_contact_blocked__(mailbox, contact_id);
dc_sqlite3_unlock(mailbox->m_sql);
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);
dc_block_contact(mailbox, contact_id, 0);
}
cleanup:
@ -3435,7 +3435,7 @@ int dc_add_address_book(dc_context_t* mailbox, const char* adr_book) /* format:
char* name = (char*)carray_get(lines, i);
char* addr = (char*)carray_get(lines, i+1);
mr_normalize_name(name);
mrmailbox_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_ADRESS_BOOK, &sth_modified);
dc_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_ADRESS_BOOK, &sth_modified);
if( sth_modified ) {
modify_cnt++;
}
@ -3499,7 +3499,7 @@ dc_array_t* dc_get_contacts(dc_context_t* mailbox, uint32_t listflags, const cha
stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_contacts_WHERE_query_ORDER_BY,
"SELECT c.id FROM contacts c"
" LEFT JOIN acpeerstates ps ON c.addr=ps.addr "
" WHERE c.addr!=? AND c.id>" MR_STRINGIFY(MR_CONTACT_ID_LAST_SPECIAL) " AND c.origin>=" MR_STRINGIFY(MR_ORIGIN_MIN_CONTACT_LIST) " AND c.blocked=0 AND (c.name LIKE ? OR c.addr LIKE ?)" /* see comments in mrmailbox_search_msgs() about the LIKE operator */
" WHERE c.addr!=? AND c.id>" MR_STRINGIFY(MR_CONTACT_ID_LAST_SPECIAL) " AND c.origin>=" MR_STRINGIFY(MR_ORIGIN_MIN_CONTACT_LIST) " AND c.blocked=0 AND (c.name LIKE ? OR c.addr LIKE ?)" /* see comments in dc_search_msgs() about the LIKE operator */
" AND (1=? OR LENGTH(ps.verified_key_fingerprint)!=0) "
" ORDER BY LOWER(c.name||c.addr),c.id;");
sqlite3_bind_text(stmt, 1, self_addr, -1, SQLITE_STATIC);
@ -3688,7 +3688,7 @@ void dc_marknoticed_contact(dc_context_t* mailbox, uint32_t contact_id)
}
void mrmailbox_block_chat__(dc_context_t* mailbox, uint32_t chat_id, int new_blocking)
void dc_block_chat__(dc_context_t* mailbox, uint32_t chat_id, int new_blocking)
{
sqlite3_stmt* stmt;
@ -3704,9 +3704,9 @@ void mrmailbox_block_chat__(dc_context_t* mailbox, uint32_t chat_id, int new_blo
}
void mrmailbox_unblock_chat__(dc_context_t* mailbox, uint32_t chat_id)
void dc_unblock_chat__(dc_context_t* mailbox, uint32_t chat_id)
{
mrmailbox_block_chat__(mailbox, chat_id, MR_CHAT_NOT_BLOCKED);
dc_block_chat__(mailbox, chat_id, MR_CHAT_NOT_BLOCKED);
}
@ -3861,7 +3861,7 @@ char* dc_get_contact_encrinfo(dc_context_t* mailbox, uint32_t contact_id)
if( self_key->m_binary == NULL ) {
dc_pgp_rand_seed(mailbox, peerstate->m_addr, strlen(peerstate->m_addr) /*just some random data*/);
mrmailbox_ensure_secret_key_exists(mailbox);
dc_ensure_secret_key_exists(mailbox);
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
dc_key_load_self_public__(self_key, loginparam->m_addr, mailbox->m_sql);
@ -3976,7 +3976,7 @@ cleanup:
}
int mrmailbox_contact_addr_equals__(dc_context_t* mailbox, uint32_t contact_id, const char* other_addr)
int dc_contact_addr_equals__(dc_context_t* mailbox, uint32_t contact_id, const char* other_addr)
{
int addr_are_equal = 0;
if( other_addr ) {
@ -3999,7 +3999,7 @@ int mrmailbox_contact_addr_equals__(dc_context_t* mailbox, uint32_t contact_id,
******************************************************************************/
void mrmailbox_update_msg_chat_id__(dc_context_t* mailbox, uint32_t msg_id, uint32_t chat_id)
void dc_update_msg_chat_id__(dc_context_t* mailbox, uint32_t msg_id, uint32_t chat_id)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, UPDATE_msgs_SET_chat_id_WHERE_id,
"UPDATE msgs SET chat_id=? WHERE id=?;");
@ -4009,7 +4009,7 @@ void mrmailbox_update_msg_chat_id__(dc_context_t* mailbox, uint32_t msg_id, uint
}
void mrmailbox_update_msg_state__(dc_context_t* mailbox, uint32_t msg_id, int state)
void dc_update_msg_state__(dc_context_t* mailbox, uint32_t msg_id, int state)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, UPDATE_msgs_SET_state_WHERE_id,
"UPDATE msgs SET state=? WHERE id=?;");
@ -4019,7 +4019,7 @@ void mrmailbox_update_msg_state__(dc_context_t* mailbox, uint32_t msg_id, int st
}
size_t mrmailbox_get_real_msg_cnt__(dc_context_t* mailbox)
size_t dc_get_real_msg_cnt__(dc_context_t* mailbox)
{
if( mailbox->m_sql->m_cobj==NULL ) {
return 0;
@ -4041,7 +4041,7 @@ size_t mrmailbox_get_real_msg_cnt__(dc_context_t* mailbox)
}
size_t mrmailbox_get_deaddrop_msg_cnt__(dc_context_t* mailbox)
size_t dc_get_deaddrop_msg_cnt__(dc_context_t* mailbox)
{
if( mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || mailbox->m_sql->m_cobj==NULL ) {
return 0;
@ -4057,7 +4057,7 @@ size_t mrmailbox_get_deaddrop_msg_cnt__(dc_context_t* mailbox)
}
int mrmailbox_rfc724_mid_cnt__(dc_context_t* mailbox, const char* rfc724_mid)
int dc_rfc724_mid_cnt__(dc_context_t* mailbox, const char* rfc724_mid)
{
if( mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || mailbox->m_sql->m_cobj==NULL ) {
return 0;
@ -4077,7 +4077,7 @@ int mrmailbox_rfc724_mid_cnt__(dc_context_t* mailbox, const char* rfc724_mid)
/* check, if the given Message-ID exists in the database (if not, the message is normally downloaded from the server and parsed,
so, we should even keep unuseful messages in the database (we can leave the other fields empty to save space) */
uint32_t mrmailbox_rfc724_mid_exists__(dc_context_t* mailbox, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid)
uint32_t dc_rfc724_mid_exists__(dc_context_t* mailbox, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_ss_FROM_msgs_WHERE_m,
"SELECT server_folder, server_uid, id FROM msgs WHERE rfc724_mid=?;");
@ -4094,7 +4094,7 @@ uint32_t mrmailbox_rfc724_mid_exists__(dc_context_t* mailbox, const char* rfc724
}
void mrmailbox_update_server_uid__(dc_context_t* mailbox, const char* rfc724_mid, const char* server_folder, uint32_t server_uid)
void dc_update_server_uid__(dc_context_t* mailbox, const char* rfc724_mid, const char* server_folder, uint32_t server_uid)
{
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, UPDATE_msgs_SET_ss_WHERE_rfc724_mid,
"UPDATE msgs SET server_folder=?, server_uid=? WHERE rfc724_mid=?;"); /* we update by "rfc724_mid" instead of "id" as there may be several db-entries refering to the same "rfc724_mid" */
@ -4388,7 +4388,7 @@ void dc_forward_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt
dc_sqlite3_begin_transaction__(mailbox->m_sql);
transaction_pending = 1;
mrmailbox_unarchive_chat__(mailbox, chat_id);
dc_unarchive_chat__(mailbox, chat_id);
mailbox->m_smtp->m_log_connect_errors = 1;
@ -4412,7 +4412,7 @@ void dc_forward_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt
mrparam_set (msg->m_param, MRP_GUARANTEE_E2EE, NULL);
mrparam_set (msg->m_param, MRP_FORCE_PLAINTEXT, NULL);
uint32_t new_msg_id = mrmailbox_send_msg_i__(mailbox, chat, msg, curr_timestamp++);
uint32_t new_msg_id = dc_send_msg_i__(mailbox, chat, msg, curr_timestamp++);
carray_add(created_db_entries, (void*)(uintptr_t)chat_id, NULL);
carray_add(created_db_entries, (void*)(uintptr_t)new_msg_id, NULL);
}
@ -4513,7 +4513,7 @@ void dc_delete_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cnt)
for( i = 0; i < msg_cnt; i++ )
{
mrmailbox_update_msg_chat_id__(mailbox, msg_ids[i], MR_CHAT_ID_TRASH);
dc_update_msg_chat_id__(mailbox, msg_ids[i], MR_CHAT_ID_TRASH);
dc_job_add(mailbox, DC_JOB_DELETE_MSG_ON_IMAP, msg_ids[i], NULL, 0);
}
@ -4574,9 +4574,9 @@ void dc_markseen_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cn
if( curr_blocked == 0 )
{
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);
dc_update_msg_state__(mailbox, msg_ids[i], MR_STATE_IN_SEEN);
dc_log_info(mailbox, 0, "Seen message #%i.", msg_ids[i]);
dc_job_add(mailbox, DC_JOB_MARKSEEN_MSG_ON_IMAP, msg_ids[i], NULL, 0); /* results in a call to mrmailbox_markseen_msg_on_imap() */
dc_job_add(mailbox, DC_JOB_MARKSEEN_MSG_ON_IMAP, msg_ids[i], NULL, 0); /* results in a call to dc_markseen_msg_on_imap() */
send_event = 1;
}
}
@ -4584,7 +4584,7 @@ void dc_markseen_msgs(dc_context_t* mailbox, const uint32_t* msg_ids, int msg_cn
{
/* message may be in contact requests, mark as NOTICED, this does not force IMAP updated nor send MDNs */
if( curr_state == MR_STATE_IN_FRESH ) {
mrmailbox_update_msg_state__(mailbox, msg_ids[i], MR_STATE_IN_NOTICED);
dc_update_msg_state__(mailbox, msg_ids[i], MR_STATE_IN_NOTICED);
send_event = 1;
}
}
@ -4606,7 +4606,7 @@ cleanup:
}
int mrmailbox_mdn_from_ext__(dc_context_t* mailbox, uint32_t from_id, const char* rfc724_mid, time_t timestamp_sent,
int dc_mdn_from_ext__(dc_context_t* mailbox, uint32_t from_id, const char* rfc724_mid, time_t timestamp_sent,
uint32_t* ret_chat_id,
uint32_t* ret_msg_id)
{
@ -4650,7 +4650,7 @@ int mrmailbox_mdn_from_ext__(dc_context_t* mailbox, uint32_t from_id, const char
// Normal chat? that's quite easy.
if( chat_type == MR_CHAT_TYPE_SINGLE ) {
mrmailbox_update_msg_state__(mailbox, *ret_msg_id, MR_STATE_OUT_MDN_RCVD);
dc_update_msg_state__(mailbox, *ret_msg_id, MR_STATE_OUT_MDN_RCVD);
return 1; /* send event about new state */
}
@ -4675,12 +4675,12 @@ int mrmailbox_mdn_from_ext__(dc_context_t* mailbox, uint32_t from_id, const char
(S=Sender, R=Recipient)
*/
int soll_cnt = (mrmailbox_get_chat_contact_count__(mailbox, *ret_chat_id)+1/*for rounding, SELF is already included!*/) / 2;
int soll_cnt = (dc_get_chat_contact_count__(mailbox, *ret_chat_id)+1/*for rounding, SELF is already included!*/) / 2;
if( ist_cnt < soll_cnt ) {
return 0; /* wait for more receipts */
}
/* got enough receipts :-) */
mrmailbox_update_msg_state__(mailbox, *ret_msg_id, MR_STATE_OUT_MDN_RCVD);
dc_update_msg_state__(mailbox, *ret_msg_id, MR_STATE_OUT_MDN_RCVD);
return 1;
}

View file

@ -111,46 +111,46 @@ void dc_log_info (dc_context_t*, int code, const char* msg,
/* misc.*/
void mrmailbox_receive_imf (dc_context_t*, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags);
uint32_t mrmailbox_send_msg_object (dc_context_t*, uint32_t chat_id, dc_msg_t*);
int mrmailbox_get_archived_count__ (dc_context_t*);
size_t mrmailbox_get_real_contact_cnt__ (dc_context_t*);
uint32_t mrmailbox_add_or_lookup_contact__ (dc_context_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
int mrmailbox_get_contact_origin__ (dc_context_t*, uint32_t id, int* ret_blocked);
int mrmailbox_is_contact_blocked__ (dc_context_t*, uint32_t id);
int mrmailbox_real_contact_exists__ (dc_context_t*, uint32_t id);
int mrmailbox_contact_addr_equals__ (dc_context_t*, uint32_t contact_id, const char* other_addr);
void mrmailbox_scaleup_contact_origin__ (dc_context_t*, uint32_t contact_id, int origin);
void mrmailbox_unarchive_chat__ (dc_context_t*, uint32_t chat_id);
size_t mrmailbox_get_chat_cnt__ (dc_context_t*);
void mrmailbox_block_chat__ (dc_context_t*, uint32_t chat_id, int new_blocking);
void mrmailbox_unblock_chat__ (dc_context_t*, uint32_t chat_id);
void mrmailbox_create_or_lookup_nchat_by_contact_id__ (dc_context_t*, uint32_t contact_id, int create_blocked, uint32_t* ret_chat_id, int* ret_chat_blocked);
void mrmailbox_lookup_real_nchat_by_contact_id__ (dc_context_t*, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked);
int mrmailbox_get_total_msg_count__ (dc_context_t*, uint32_t chat_id);
int mrmailbox_get_fresh_msg_count__ (dc_context_t*, uint32_t chat_id);
uint32_t mrmailbox_get_last_deaddrop_fresh_msg__ (dc_context_t*);
int mrmailbox_add_to_chat_contacts_table__ (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
int mrmailbox_is_contact_in_chat__ (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
int mrmailbox_get_chat_contact_count__ (dc_context_t*, uint32_t chat_id);
int mrmailbox_is_group_explicitly_left__ (dc_context_t*, const char* grpid);
void mrmailbox_set_group_explicitly_left__ (dc_context_t*, const char* grpid);
size_t mrmailbox_get_real_msg_cnt__ (dc_context_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
size_t mrmailbox_get_deaddrop_msg_cnt__ (dc_context_t*);
int mrmailbox_rfc724_mid_cnt__ (dc_context_t*, const char* rfc724_mid);
uint32_t mrmailbox_rfc724_mid_exists__ (dc_context_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
void mrmailbox_update_server_uid__ (dc_context_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
void mrmailbox_update_msg_chat_id__ (dc_context_t*, uint32_t msg_id, uint32_t chat_id);
void mrmailbox_update_msg_state__ (dc_context_t*, uint32_t msg_id, int state);
int mrmailbox_mdn_from_ext__ (dc_context_t*, uint32_t from_id, const char* rfc724_mid, time_t, uint32_t* ret_chat_id, uint32_t* ret_msg_id); /* returns 1 if an event should be send */
uint32_t mrmailbox_add_device_msg (dc_context_t*, uint32_t chat_id, const char* text);
uint32_t mrmailbox_add_device_msg__ (dc_context_t*, uint32_t chat_id, const char* text, time_t timestamp);
void mrmailbox_suspend_smtp_thread (dc_context_t*, int suspend);
void dc_receive_imf (dc_context_t*, const char* imf_raw_not_terminated, size_t imf_raw_bytes, const char* server_folder, uint32_t server_uid, uint32_t flags);
uint32_t dc_send_msg_object (dc_context_t*, uint32_t chat_id, dc_msg_t*);
int dc_get_archived_count__ (dc_context_t*);
size_t dc_get_real_contact_cnt__ (dc_context_t*);
uint32_t dc_add_or_lookup_contact__ (dc_context_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
int dc_get_contact_origin__ (dc_context_t*, uint32_t id, int* ret_blocked);
int dc_is_contact_blocked__ (dc_context_t*, uint32_t id);
int dc_real_contact_exists__ (dc_context_t*, uint32_t id);
int dc_contact_addr_equals__ (dc_context_t*, uint32_t contact_id, const char* other_addr);
void dc_scaleup_contact_origin__ (dc_context_t*, uint32_t contact_id, int origin);
void dc_unarchive_chat__ (dc_context_t*, uint32_t chat_id);
size_t dc_get_chat_cnt__ (dc_context_t*);
void dc_block_chat__ (dc_context_t*, uint32_t chat_id, int new_blocking);
void dc_unblock_chat__ (dc_context_t*, uint32_t chat_id);
void dc_create_or_lookup_nchat_by_contact_id__ (dc_context_t*, uint32_t contact_id, int create_blocked, uint32_t* ret_chat_id, int* ret_chat_blocked);
void dc_lookup_real_nchat_by_contact_id__ (dc_context_t*, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked);
int dc_get_total_msg_count__ (dc_context_t*, uint32_t chat_id);
int dc_get_fresh_msg_count__ (dc_context_t*, uint32_t chat_id);
uint32_t dc_get_last_deaddrop_fresh_msg__ (dc_context_t*);
int dc_add_to_chat_contacts_table__ (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
int dc_is_contact_in_chat__ (dc_context_t*, uint32_t chat_id, uint32_t contact_id);
int dc_get_chat_contact_count__ (dc_context_t*, uint32_t chat_id);
int dc_is_group_explicitly_left__ (dc_context_t*, const char* grpid);
void dc_set_group_explicitly_left__ (dc_context_t*, const char* grpid);
size_t dc_get_real_msg_cnt__ (dc_context_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
size_t dc_get_deaddrop_msg_cnt__ (dc_context_t*);
int dc_rfc724_mid_cnt__ (dc_context_t*, const char* rfc724_mid);
uint32_t dc_rfc724_mid_exists__ (dc_context_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
void dc_update_server_uid__ (dc_context_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
void dc_update_msg_chat_id__ (dc_context_t*, uint32_t msg_id, uint32_t chat_id);
void dc_update_msg_state__ (dc_context_t*, uint32_t msg_id, int state);
int dc_mdn_from_ext__ (dc_context_t*, uint32_t from_id, const char* rfc724_mid, time_t, uint32_t* ret_chat_id, uint32_t* ret_msg_id); /* returns 1 if an event should be send */
uint32_t dc_add_device_msg (dc_context_t*, uint32_t chat_id, const char* text);
uint32_t dc_add_device_msg__ (dc_context_t*, uint32_t chat_id, const char* text, time_t timestamp);
void dc_suspend_smtp_thread (dc_context_t*, int suspend);
#define MR_FROM_HANDSHAKE 0x01
int mrmailbox_add_contact_to_chat_ex (dc_context_t*, uint32_t chat_id, uint32_t contact_id, int flags);
int dc_add_contact_to_chat_ex (dc_context_t*, uint32_t chat_id, uint32_t contact_id, int flags);
uint32_t mrmailbox_get_chat_id_by_grpid__ (dc_context_t*, const char* grpid, int* ret_blocked, int* ret_verified);
uint32_t dc_get_chat_id_by_grpid__ (dc_context_t*, const char* grpid, int* ret_blocked, int* ret_verified);
#define DC_BAK_PREFIX "delta-chat"
#define DC_BAK_SUFFIX "bak"
@ -172,18 +172,18 @@ typedef struct dc_e2ee_helper_t {
} dc_e2ee_helper_t;
void mrmailbox_e2ee_encrypt (dc_context_t*, const clist* recipients_addr, int force_plaintext, int e2ee_guaranteed, int min_verified, struct mailmime* in_out_message, dc_e2ee_helper_t*);
void mrmailbox_e2ee_decrypt (dc_context_t*, struct mailmime* in_out_message, dc_e2ee_helper_t*); /* returns 1 if sth. was decrypted, 0 in other cases */
void mrmailbox_e2ee_thanks (dc_e2ee_helper_t*); /* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling mre2ee_unhelp(), in_out_message cannot be used any longer! */
int mrmailbox_ensure_secret_key_exists (dc_context_t*); /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */
char* mrmailbox_create_setup_code (dc_context_t*);
char* mrmailbox_normalize_setup_code(dc_context_t*, const char* passphrase);
char* mrmailbox_render_setup_file (dc_context_t*, const char* passphrase);
char* mrmailbox_decrypt_setup_file(dc_context_t*, const char* passphrase, const char* filecontent);
void dc_e2ee_encrypt (dc_context_t*, const clist* recipients_addr, int force_plaintext, int e2ee_guaranteed, int min_verified, struct mailmime* in_out_message, dc_e2ee_helper_t*);
void dc_e2ee_decrypt (dc_context_t*, struct mailmime* in_out_message, dc_e2ee_helper_t*); /* returns 1 if sth. was decrypted, 0 in other cases */
void dc_e2ee_thanks (dc_e2ee_helper_t*); /* frees data referenced by "mailmime" but not freed by mailmime_free(). After calling mre2ee_unhelp(), in_out_message cannot be used any longer! */
int dc_ensure_secret_key_exists (dc_context_t*); /* makes sure, the private key exists, needed only for exporting keys and the case no message was sent before */
char* dc_create_setup_code (dc_context_t*);
char* dc_normalize_setup_code(dc_context_t*, const char* passphrase);
char* dc_render_setup_file (dc_context_t*, const char* passphrase);
char* dc_decrypt_setup_file(dc_context_t*, const char* passphrase, const char* filecontent);
extern int mr_shall_stop_ongoing;
int mrmailbox_alloc_ongoing (dc_context_t*);
void mrmailbox_free_ongoing (dc_context_t*);
int dc_alloc_ongoing (dc_context_t*);
void dc_free_ongoing (dc_context_t*);
#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)
@ -192,15 +192,15 @@ void mrmailbox_free_ongoing (dc_context_t*);
/* library private: secure-join */
#define MR_IS_HANDSHAKE_CONTINUE_NORMAL_PROCESSING 1
#define MR_IS_HANDSHAKE_STOP_NORMAL_PROCESSING 2
int mrmailbox_handle_securejoin_handshake(dc_context_t*, dc_mimeparser_t*, uint32_t contact_id);
void mrmailbox_handle_degrade_event (dc_context_t*, dc_apeerstate_t*);
int dc_handle_securejoin_handshake(dc_context_t*, dc_mimeparser_t*, uint32_t contact_id);
void dc_handle_degrade_event (dc_context_t*, dc_apeerstate_t*);
#define OPENPGP4FPR_SCHEME "OPENPGP4FPR:" /* yes: uppercase */
/* library private: key-history */
void mrmailbox_add_to_keyhistory__(dc_context_t*, const char* rfc724_mid, time_t, const char* addr, const char* fingerprint);
void dc_add_to_keyhistory__(dc_context_t*, const char* rfc724_mid, time_t, const char* addr, const char* fingerprint);
#ifdef __cplusplus

View file

@ -278,7 +278,7 @@ cleanup:
}
int mrmailbox_ensure_secret_key_exists(dc_context_t* mailbox)
int dc_ensure_secret_key_exists(dc_context_t* mailbox)
{
/* normally, the key is generated as soon as the first mail is send
(this is to gain some extra-random-seed by the message content and the timespan between program start and message sending) */
@ -317,7 +317,7 @@ cleanup:
******************************************************************************/
void mrmailbox_e2ee_encrypt(dc_context_t* mailbox, const clist* recipients_addr,
void dc_e2ee_encrypt(dc_context_t* mailbox, const clist* recipients_addr,
int force_unencrypted,
int e2ee_guaranteed, /*set if e2ee was possible on sending time; we should not degrade to transport*/
int min_verified,
@ -519,7 +519,7 @@ cleanup:
}
void mrmailbox_e2ee_thanks(dc_e2ee_helper_t* helper)
void dc_e2ee_thanks(dc_e2ee_helper_t* helper)
{
if( helper == NULL ) {
return;
@ -777,7 +777,7 @@ static dc_hash_t* update_gossip_peerstates(dc_context_t* mailbox, time_t message
dc_sqlite3_unlock(mailbox->m_sql);
if( peerstate->m_degrade_event ) {
mrmailbox_handle_degrade_event(mailbox, peerstate);
dc_handle_degrade_event(mailbox, peerstate);
}
dc_apeerstate_unref(peerstate);
@ -809,7 +809,7 @@ static dc_hash_t* update_gossip_peerstates(dc_context_t* mailbox, time_t message
}
void mrmailbox_e2ee_decrypt(dc_context_t* mailbox, struct mailmime* in_out_message,
void dc_e2ee_decrypt(dc_context_t* mailbox, struct mailmime* in_out_message,
dc_e2ee_helper_t* helper)
{
/* return values: 0=nothing to decrypt/cannot decrypt, 1=sth. decrypted
@ -907,7 +907,7 @@ void mrmailbox_e2ee_decrypt(dc_context_t* mailbox, struct mailmime* in_out_messa
locked = 0;
if( peerstate->m_degrade_event ) {
mrmailbox_handle_degrade_event(mailbox, peerstate);
dc_handle_degrade_event(mailbox, peerstate);
}
// offer both, gossip and public, for signature validation.

View file

@ -1616,7 +1616,7 @@ int dc_imap_delete_msg(dc_imap_t* ths, const char* rfc724_mid, const char* folde
/* check if Folder+UID matches the Message-ID (to detect if the messages
was moved around by other MUAs and in place of an UIDVALIDITY check)
(we also detect messages moved around when we do a fetch-all, see
mrmailbox_update_server_uid__() in receive_imf(), however this may take a while) */
dc_update_server_uid__() in receive_imf(), however this may take a while) */
if( server_uid )
{
clistiter* cur = NULL;

View file

@ -88,18 +88,18 @@
* .....
* -----END PGP PRIVATE KEY BLOCK-----
*
* mrmailbox_render_setup_file() renders the body after the second
* dc_render_setup_file() renders the body after the second
* `-==break1==` in this example.
*
* @private @memberof dc_context_t
*
* @param mailbox The mailbox object
* @param passphrase The setup code that shall be used to encrypt the message.
* Typically created by mrmailbox_create_setup_code().
* Typically created by dc_create_setup_code().
* @return String with the HTML-code of the message on success, NULL on errors.
* The returned value must be free()'d
*/
char* mrmailbox_render_setup_file(dc_context_t* mailbox, const char* passphrase)
char* dc_render_setup_file(dc_context_t* mailbox, const char* passphrase)
{
int locked = 0;
sqlite3_stmt* stmt = NULL;
@ -130,7 +130,7 @@ char* mrmailbox_render_setup_file(dc_context_t* mailbox, const char* passphrase)
/* create the payload */
if( !mrmailbox_ensure_secret_key_exists(mailbox) ) {
if( !dc_ensure_secret_key_exists(mailbox) ) {
goto cleanup;
}
@ -301,15 +301,15 @@ cleanup:
*
* @param mailbox The mailbox object
* @param passphrase The setup code that shall be used to decrypt the message.
* May be created by mrmailbox_create_setup_code() on another device or by
* May be created by dc_create_setup_code() on another device or by
* a completely different app as Thunderbird/Enigmail or K-9.
* @param filecontent The file content of the setup message, may be HTML.
* May be created by mrmailbox_render_setup_code() on another device or by
* May be created by dc_render_setup_code() on another device or by
* a completely different app as Thunderbird/Enigmail or K-9.
* @return The decrypted private key as armored-ascii-data or NULL on errors.
* Must be dc_key_unref()'d.
*/
char* mrmailbox_decrypt_setup_file(dc_context_t* mailbox, const char* passphrase, const char* filecontent)
char* dc_decrypt_setup_file(dc_context_t* mailbox, const char* passphrase, const char* filecontent)
{
char* fc_buf = NULL;
const char *fc_headerline = NULL, *fc_base64 = NULL;
@ -355,9 +355,9 @@ cleanup:
*
* The created "Autocrypt Level 1" setup code has the form `1234-1234-1234-1234-1234-1234-1234-1234-1234`.
* Linebreaks and spaces are not added to the setup code, but the `-` are.
* The setup code is typically given to mrmailbox_render_setup_file().
* The setup code is typically given to dc_render_setup_file().
*
* A higher-level function to initiate the key transfer is mrmailbox_initiate_key_transfer().
* A higher-level function to initiate the key transfer is dc_initiate_key_transfer().
*
* @private @memberof dc_context_t
*
@ -365,7 +365,7 @@ cleanup:
*
* @return Setup code, must be free()'d after usage. NULL on errors.
*/
char* mrmailbox_create_setup_code(dc_context_t* mailbox)
char* dc_create_setup_code(dc_context_t* mailbox)
{
#define CODE_ELEMS 9
uint16_t random_val;
@ -395,7 +395,7 @@ char* mrmailbox_create_setup_code(dc_context_t* mailbox)
/* Function remove all special characters from the given code and brings it to the 9x4 form */
char* mrmailbox_normalize_setup_code(dc_context_t* mailbox, const char* in)
char* dc_normalize_setup_code(dc_context_t* mailbox, const char* in)
{
if( in == NULL ) {
return NULL;
@ -480,18 +480,18 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
dc_msg_t* msg = NULL;
uint32_t msg_id = 0;
if( !mrmailbox_alloc_ongoing(mailbox) ) {
return 0; /* no cleanup as this would call mrmailbox_free_ongoing() */
if( !dc_alloc_ongoing(mailbox) ) {
return 0; /* no cleanup as this would call dc_free_ongoing() */
}
#define CHECK_EXIT if( mr_shall_stop_ongoing ) { goto cleanup; }
if( (setup_code=mrmailbox_create_setup_code(mailbox)) == NULL ) { /* this may require a keypair to be created. this may take a second ... */
if( (setup_code=dc_create_setup_code(mailbox)) == NULL ) { /* this may require a keypair to be created. this may take a second ... */
goto cleanup;
}
CHECK_EXIT
if( (setup_file_content=mrmailbox_render_setup_file(mailbox, setup_code))==NULL ) { /* encrypting may also take a while ... */
if( (setup_file_content=dc_render_setup_file(mailbox, setup_code))==NULL ) { /* encrypting may also take a while ... */
goto cleanup;
}
@ -502,7 +502,7 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
goto cleanup;
}
if( (chat_id=mrmailbox_create_chat_by_contact_id(mailbox, MR_CONTACT_ID_SELF))==0 ) {
if( (chat_id=dc_create_chat_by_contact_id(mailbox, MR_CONTACT_ID_SELF))==0 ) {
goto cleanup;
}
@ -515,7 +515,7 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
CHECK_EXIT
if( (msg_id = mrmailbox_send_msg_object(mailbox, chat_id, msg)) == 0 ) {
if( (msg_id = dc_send_msg_object(mailbox, chat_id, msg)) == 0 ) {
goto cleanup;
}
@ -531,7 +531,7 @@ char* dc_initiate_key_transfer(dc_context_t* mailbox)
sleep(1);
msg = mrmailbox_get_msg(mailbox, msg_id);
msg = dc_get_msg(mailbox, msg_id);
if( dc_msg_is_sent(msg) ) {
break;
}
@ -548,7 +548,7 @@ cleanup:
free(setup_file_name);
free(setup_file_content);
dc_msg_unref(msg);
mrmailbox_free_ongoing(mailbox);
dc_free_ongoing(mailbox);
return setup_code;
}
@ -605,10 +605,10 @@ static int set_self_key(dc_context_t* mailbox, const char* armored, int set_defa
/* if we also received an Autocrypt-Prefer-Encrypt header, handle this */
if( buf_preferencrypt ) {
if( strcmp(buf_preferencrypt, "nopreference")==0 ) {
mrmailbox_set_config_int(mailbox, "e2ee_enabled", 0); /* use the top-level function as this also resets cached values */
dc_set_config_int(mailbox, "e2ee_enabled", 0); /* use the top-level function as this also resets cached values */
}
else if( strcmp(buf_preferencrypt, "mutual")==0 ) {
mrmailbox_set_config_int(mailbox, "e2ee_enabled", 1); /* use the top-level function as this also resets cached values */
dc_set_config_int(mailbox, "e2ee_enabled", 1); /* use the top-level function as this also resets cached values */
}
}
@ -661,7 +661,7 @@ int dc_continue_key_transfer(dc_context_t* mailbox, uint32_t msg_id, const char*
goto cleanup;
}
if( (msg=mrmailbox_get_msg(mailbox, msg_id))==NULL || !dc_msg_is_setupmessage(msg)
if( (msg=dc_get_msg(mailbox, msg_id))==NULL || !dc_msg_is_setupmessage(msg)
|| (filename=dc_msg_get_file(msg))==NULL || filename[0]==0 ) {
dc_log_error(mailbox, 0, "Message is no Autocrypt Setup Message.");
goto cleanup;
@ -672,12 +672,12 @@ int dc_continue_key_transfer(dc_context_t* mailbox, uint32_t msg_id, const char*
goto cleanup;
}
if( (norm_sc = mrmailbox_normalize_setup_code(mailbox, setup_code))==NULL ) {
if( (norm_sc = dc_normalize_setup_code(mailbox, setup_code))==NULL ) {
dc_log_warning(mailbox, 0, "Cannot normalize Setup Code.");
goto cleanup;
}
if( (armored_key=mrmailbox_decrypt_setup_file(mailbox, norm_sc, filecontent)) == NULL ) {
if( (armored_key=dc_decrypt_setup_file(mailbox, norm_sc, filecontent)) == NULL ) {
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;
}
@ -1048,7 +1048,7 @@ static int import_backup(dc_context_t* mailbox, const char* backup_to_import)
dc_log_info(mailbox, 0, "Import \"%s\" to \"%s\".", backup_to_import, mailbox->m_dbfile);
if( mrmailbox_is_configured(mailbox) ) {
if( dc_is_configured(mailbox) ) {
dc_log_error(mailbox, 0, "Cannot import backups to mailboxes in use.");
goto cleanup;
}
@ -1211,8 +1211,8 @@ int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* par
return 0;
}
if( !mrmailbox_alloc_ongoing(mailbox) ) {
return 0; /* no cleanup as this would call mrmailbox_free_ongoing() */
if( !dc_alloc_ongoing(mailbox) ) {
return 0; /* no cleanup as this would call dc_free_ongoing() */
}
if( param1 == NULL ) {
@ -1230,7 +1230,7 @@ int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* par
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) ) {
if( !dc_ensure_secret_key_exists(mailbox) ) {
dc_log_error(mailbox, 0, "Import/export: Cannot create private key or private key not available.");
goto cleanup;
}
@ -1273,7 +1273,7 @@ int dc_imex(dc_context_t* mailbox, int what, const char* param1, const char* par
cleanup:
dc_log_info(mailbox, 0, "Import/export process ended.");
mrmailbox_free_ongoing(mailbox);
dc_free_ongoing(mailbox);
return success;
}

View file

@ -114,7 +114,7 @@ static void dc_job_do_DC_JOB_SEND_MSG_TO_IMAP(dc_context_t* mailbox, dc_job_t* j
}
else {
dc_sqlite3_lock(mailbox->m_sql);
mrmailbox_update_server_uid__(mailbox, mimefactory.m_msg->m_rfc724_mid, server_folder, server_uid);
dc_update_server_uid__(mailbox, mimefactory.m_msg->m_rfc724_mid, server_folder, server_uid);
dc_sqlite3_unlock(mailbox->m_sql);
}
@ -137,7 +137,7 @@ static void dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(dc_context_t* mailbox, dc_job_t*
goto cleanup;
}
if( mrmailbox_rfc724_mid_cnt__(mailbox, msg->m_rfc724_mid) != 1 ) {
if( dc_rfc724_mid_cnt__(mailbox, msg->m_rfc724_mid) != 1 ) {
dc_log_info(mailbox, 0, "The message is deleted from the server when all parts are deleted.");
delete_from_server = 0;
}
@ -272,7 +272,7 @@ static void dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(dc_context_t* mailbox, dc_job_
if( new_server_folder && new_server_uid )
{
mrmailbox_update_server_uid__(mailbox, msg->m_rfc724_mid, new_server_folder, new_server_uid);
dc_update_server_uid__(mailbox, msg->m_rfc724_mid, new_server_folder, new_server_uid);
}
if( out_ms_flags&MR_MS_MDNSent_JUST_SET )
@ -334,7 +334,7 @@ static void mark_as_error(dc_context_t* mailbox, dc_msg_t* msg)
}
dc_sqlite3_lock(mailbox->m_sql);
mrmailbox_update_msg_state__(mailbox, msg->m_id, MR_STATE_OUT_ERROR);
dc_update_msg_state__(mailbox, msg->m_id, MR_STATE_OUT_ERROR);
dc_sqlite3_unlock(mailbox->m_sql);
mailbox->m_cb(mailbox, DC_EVENT_MSGS_CHANGED, msg->m_chat_id, 0);
}
@ -413,7 +413,7 @@ static void dc_job_do_DC_JOB_SEND_MSG_TO_SMTP(dc_context_t* mailbox, dc_job_t* j
free(emlname);
}
mrmailbox_update_msg_state__(mailbox, mimefactory.m_msg->m_id, MR_STATE_OUT_DELIVERED);
dc_update_msg_state__(mailbox, mimefactory.m_msg->m_id, MR_STATE_OUT_DELIVERED);
if( mimefactory.m_out_encrypted && mrparam_get_int(mimefactory.m_msg->m_param, MRP_GUARANTEE_E2EE, 0)==0 ) {
mrparam_set_int(mimefactory.m_msg->m_param, MRP_GUARANTEE_E2EE, 1); /* can upgrade to E2EE - fine! */
dc_msg_save_param_to_disk__(mimefactory.m_msg);
@ -426,7 +426,7 @@ static void dc_job_do_DC_JOB_SEND_MSG_TO_SMTP(dc_context_t* mailbox, dc_job_t* j
}
// TODO: add to keyhistory
mrmailbox_add_to_keyhistory__(mailbox, NULL, 0, NULL, NULL);
dc_add_to_keyhistory__(mailbox, NULL, 0, NULL, NULL);
dc_sqlite3_commit__(mailbox->m_sql);
dc_sqlite3_unlock(mailbox->m_sql);
@ -480,7 +480,7 @@ cleanup:
}
void mrmailbox_suspend_smtp_thread(dc_context_t* mailbox, int suspend)
void dc_suspend_smtp_thread(dc_context_t* mailbox, int suspend)
{
pthread_mutex_lock(&mailbox->m_smtpidle_condmutex);
mailbox->m_smtpidle_suspend = suspend;

View file

@ -23,7 +23,7 @@
#include "dc_context.h"
void mrmailbox_add_to_keyhistory__(dc_context_t* mailbox, const char* rfc724_mid, time_t sending_time, const char* addr, const char* fingerprint)
void dc_add_to_keyhistory__(dc_context_t* mailbox, const char* rfc724_mid, time_t sending_time, const char* addr, const char* fingerprint)
{
// TODO
}

View file

@ -268,7 +268,7 @@ int dc_mimefactory_load_mdn(dc_mimefactory_t* factory, uint32_t msg_id)
}
if( contact->m_blocked
|| factory->m_msg->m_chat_id<=MR_CHAT_ID_LAST_SPECIAL/* Do not send MDNs trash etc.; chats.blocked is already checked by the caller in mrmailbox_markseen_msgs() */ ) {
|| factory->m_msg->m_chat_id<=MR_CHAT_ID_LAST_SPECIAL/* Do not send MDNs trash etc.; chats.blocked is already checked by the caller in dc_markseen_msgs() */ ) {
goto cleanup;
}
@ -788,7 +788,7 @@ int dc_mimefactory_render(dc_mimefactory_t* factory)
mailimf_fields_add(imf_fields, mailimf_field_new(MAILIMF_FIELD_SUBJECT, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, subject, NULL, NULL, NULL));
if( force_plaintext != MRFP_NO_AUTOCRYPT_HEADER ) {
mrmailbox_e2ee_encrypt(factory->m_context, factory->m_recipients_addr, force_plaintext, e2ee_guaranteed, min_verified, message, &e2ee_helper);
dc_e2ee_encrypt(factory->m_context, factory->m_recipients_addr, force_plaintext, e2ee_guaranteed, min_verified, message, &e2ee_helper);
}
if( e2ee_helper.m_encryption_successfull ) {
@ -807,7 +807,7 @@ cleanup:
if( message ) {
mailmime_free(message);
}
mrmailbox_e2ee_thanks(&e2ee_helper); /* frees data referenced by "mailmime" but not freed by mailmime_free() */
dc_e2ee_thanks(&e2ee_helper); /* frees data referenced by "mailmime" but not freed by mailmime_free() */
free(message_text); free(message_text2); /* mailmime_set_body_text() does not take ownership of "text" */
free(subject_str);
free(grpimage);

View file

@ -938,7 +938,7 @@ void dc_mimeparser_empty(dc_mimeparser_t* ths)
ths->m_decrypting_failed = 0;
mrmailbox_e2ee_thanks(ths->m_e2ee_helper);
dc_e2ee_thanks(ths->m_e2ee_helper);
}
@ -1495,7 +1495,7 @@ void dc_mimeparser_parse(dc_mimeparser_t* ths, const char* body_not_terminated,
/* decrypt, if possible; handle Autocrypt:-header
(decryption may modifiy the given object) */
mrmailbox_e2ee_decrypt(ths->m_context, ths->m_mimeroot, ths->m_e2ee_helper);
dc_e2ee_decrypt(ths->m_context, ths->m_mimeroot, ths->m_e2ee_helper);
//printf("after decryption:\n"); mailmime_print(ths->m_mimeroot);

View file

@ -463,7 +463,7 @@ dc_lot_t* dc_msg_get_mediainfo(const dc_msg_t* msg)
if( msg->m_type == MR_MSG_VOICE )
{
if( (contact = mrmailbox_get_contact(msg->m_context, msg->m_from_id))==NULL ) {
if( (contact = dc_get_contact(msg->m_context, msg->m_from_id))==NULL ) {
goto cleanup;
}
ret->m_text1 = safe_strdup((contact->m_name&&contact->m_name[0])? contact->m_name : contact->m_addr);
@ -590,7 +590,7 @@ int dc_msg_get_showpadlock(const dc_msg_t* msg)
show_encryption_state = 1;
}
else {
dc_chat_t* chat = mrmailbox_get_chat(msg->m_context, msg->m_chat_id);
dc_chat_t* chat = dc_get_chat(msg->m_context, msg->m_chat_id);
show_encryption_state = dc_chat_is_verified(chat);
dc_chat_unref(chat);
}
@ -645,14 +645,14 @@ dc_lot_t* dc_msg_get_summary(const dc_msg_t* msg, const dc_chat_t* chat)
}
if( chat == NULL ) {
if( (chat_to_delete=mrmailbox_get_chat(msg->m_context, msg->m_chat_id)) == NULL ) {
if( (chat_to_delete=dc_get_chat(msg->m_context, msg->m_chat_id)) == NULL ) {
goto cleanup;
}
chat = chat_to_delete;
}
if( msg->m_from_id != MR_CONTACT_ID_SELF && MR_CHAT_TYPE_IS_MULTI(chat->m_type) ) {
contact = mrmailbox_get_contact(chat->m_context, msg->m_from_id);
contact = dc_get_contact(chat->m_context, msg->m_from_id);
}
dc_lot_fill(ret, msg, chat, contact);

View file

@ -46,21 +46,21 @@ struct _dc_msg
/**
* Contact ID of the sender. Never 0. See dc_contact_t::m_id for special IDs.
* Use mrmailbox_get_contact() to load details about this contact.
* Use dc_get_contact() to load details about this contact.
*/
uint32_t m_from_id;
/**
* Contact ID of the recipient. Never 0. See dc_contact_t::m_id for special IDs.
* Use mrmailbox_get_contact() to load details about this contact.
* Use dc_get_contact() to load details about this contact.
*/
uint32_t m_to_id;
/**
* Chat ID the message belongs to. Never 0. See dc_chat_t::m_id for special IDs.
* Use mrmailbox_get_chat() to load details about the chat.
* Use dc_get_chat() to load details about the chat.
*/
uint32_t m_chat_id;

View file

@ -212,9 +212,9 @@ dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr)
if( dc_apeerstate_load_by_fingerprint__(peerstate, mailbox->m_sql, fingerprint) ) {
qr_parsed->m_state = MR_QR_FPR_OK;
qr_parsed->m_id = mrmailbox_add_or_lookup_contact__(mailbox, NULL, peerstate->m_addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
qr_parsed->m_id = dc_add_or_lookup_contact__(mailbox, NULL, peerstate->m_addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, qr_parsed->m_id, MR_CHAT_DEADDROP_BLOCKED, &chat_id, NULL);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, qr_parsed->m_id, MR_CHAT_DEADDROP_BLOCKED, &chat_id, NULL);
device_msg = mr_mprintf("%s verified.", peerstate->m_addr);
}
else {
@ -242,7 +242,7 @@ dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr)
qr_parsed->m_state = MR_QR_ASK_VERIFYCONTACT;
}
qr_parsed->m_id = mrmailbox_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
qr_parsed->m_id = dc_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
qr_parsed->m_fingerprint = safe_strdup(fingerprint);
qr_parsed->m_invitenumber = safe_strdup(invitenumber);
qr_parsed->m_auth = safe_strdup(auth);
@ -255,7 +255,7 @@ dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr)
else if( addr )
{
qr_parsed->m_state = MR_QR_ADDR;
qr_parsed->m_id = mrmailbox_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
qr_parsed->m_id = dc_add_or_lookup_contact__(mailbox, name, addr, MR_ORIGIN_UNHANDLED_QR_SCAN, NULL);
}
else if( strstr(qr, "http://")==qr || strstr(qr, "https://")==qr )
{
@ -269,7 +269,7 @@ dc_lot_t* dc_check_qr(dc_context_t* mailbox, const char* qr)
}
if( device_msg ) {
mrmailbox_add_device_msg(mailbox, chat_id, device_msg);
dc_add_device_msg(mailbox, chat_id, device_msg);
}
cleanup:

View file

@ -65,7 +65,7 @@ static void add_or_lookup_contact_by_addr__(dc_context_t* mailbox, const char* d
mr_normalize_name(display_name_dec);
}
uint32_t row_id = mrmailbox_add_or_lookup_contact__(mailbox, display_name_dec /*can be NULL*/, addr_spec, origin, NULL);
uint32_t row_id = dc_add_or_lookup_contact__(mailbox, display_name_dec /*can be NULL*/, addr_spec, origin, NULL);
free(display_name_dec);
@ -77,7 +77,7 @@ static void add_or_lookup_contact_by_addr__(dc_context_t* mailbox, const char* d
}
static void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(dc_context_t* mailbox, const struct mailimf_mailbox_list* mb_list, int origin, dc_array_t* ids, int* check_self)
static void dc_add_or_lookup_contacts_by_mailbox_list__(dc_context_t* mailbox, const struct mailimf_mailbox_list* mb_list, int origin, dc_array_t* ids, int* check_self)
{
clistiter* cur;
@ -94,7 +94,7 @@ static void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(dc_context_t* mai
}
static void mrmailbox_add_or_lookup_contacts_by_address_list__(dc_context_t* mailbox, const struct mailimf_address_list* adr_list, int origin, dc_array_t* ids, int* check_self)
static void dc_add_or_lookup_contacts_by_address_list__(dc_context_t* mailbox, const struct mailimf_address_list* adr_list, int origin, dc_array_t* ids, int* check_self)
{
clistiter* cur;
@ -114,7 +114,7 @@ static void mrmailbox_add_or_lookup_contacts_by_address_list__(dc_context_t* mai
else if( adr->ad_type == MAILIMF_ADDRESS_GROUP ) {
struct mailimf_group* group = adr->ad_data.ad_group; /* can be NULL */
if( group && group->grp_mb_list /*can be NULL*/ ) {
mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mailbox, group->grp_mb_list, origin, ids, check_self);
dc_add_or_lookup_contacts_by_mailbox_list__(mailbox, group->grp_mb_list, origin, ids, check_self);
}
}
}
@ -160,7 +160,7 @@ static int is_known_rfc724_mid_in_list__(dc_context_t* mailbox, const clist* mid
}
static int mrmailbox_is_reply_to_known_message__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser)
static int dc_is_reply_to_known_message__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser)
{
/* check if the message is a reply to a known message; the replies are identified by the Message-ID from
`In-Reply-To`/`References:` (to support non-Delta-Clients) or from `Chat-Predecessor:` (Delta clients, see comment in mrchat.c) */
@ -237,7 +237,7 @@ static int is_msgrmsg_rfc724_mid_in_list__(dc_context_t* mailbox, const clist* m
}
static int mrmailbox_is_reply_to_messenger_message__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser)
static int dc_is_reply_to_messenger_message__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser)
{
/* function checks, if the message defined by mime_parser references a message send by us from Delta Chat.
@ -281,7 +281,7 @@ static int mrmailbox_is_reply_to_messenger_message__(dc_context_t* mailbox, dc_m
static void mrmailbox_calc_timestamps__(dc_context_t* mailbox, uint32_t chat_id, uint32_t from_id, time_t message_timestamp, int is_fresh_msg,
static void dc_calc_timestamps__(dc_context_t* mailbox, uint32_t chat_id, uint32_t from_id, time_t message_timestamp, int is_fresh_msg,
time_t* sort_timestamp, time_t* sent_timestamp, time_t* rcvd_timestamp)
{
*rcvd_timestamp = time(NULL);
@ -566,7 +566,7 @@ static void create_or_lookup_adhoc_group__(dc_context_t* mailbox, dc_mimeparser_
chat_id = create_group_record__(mailbox, grpid, grpname, create_blocked, 0);
chat_id_blocked = create_blocked;
for( i = 0; i < dc_array_get_cnt(member_ids); i++ ) {
mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, dc_array_get_id(member_ids, i));
dc_add_to_chat_contacts_table__(mailbox, chat_id, dc_array_get_id(member_ids, i));
}
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, chat_id, 0);
@ -768,7 +768,7 @@ static void create_or_lookup_group__(dc_context_t* mailbox, dc_mimeparser_t* mim
}
/* check, if we have a chat with this group ID */
if( (chat_id=mrmailbox_get_chat_id_by_grpid__(mailbox, grpid, &chat_id_blocked, &chat_id_verified))!=0 ) {
if( (chat_id=dc_get_chat_id_by_grpid__(mailbox, grpid, &chat_id_blocked, &chat_id_verified))!=0 ) {
if( chat_id_verified
&& !check_verified_properties__(mailbox, mime_parser, from_id, to_ids) ) {
chat_id = 0; // force the creation of an unverified ad-hoc group.
@ -783,14 +783,14 @@ static void create_or_lookup_group__(dc_context_t* mailbox, dc_mimeparser_t* mim
/* check if the sender is a member of the existing group -
if not, the message does not go to the group chat but to the normal chat with the sender */
if( chat_id!=0 && !mrmailbox_is_contact_in_chat__(mailbox, chat_id, from_id) ) {
if( chat_id!=0 && !dc_is_contact_in_chat__(mailbox, chat_id, from_id) ) {
chat_id = 0;
create_or_lookup_adhoc_group__(mailbox, mime_parser, create_blocked, from_id, to_ids, &chat_id, &chat_id_blocked);
goto cleanup;
}
/* check if the group does not exist but should be created */
int group_explicitly_left = mrmailbox_is_group_explicitly_left__(mailbox, grpid);
int group_explicitly_left = dc_is_group_explicitly_left__(mailbox, grpid);
self_addr = dc_sqlite3_get_config__(mailbox->m_sql, "configured_addr", "");
if( chat_id == 0
@ -885,22 +885,22 @@ static void create_or_lookup_group__(dc_context_t* mailbox, dc_mimeparser_t* mim
sqlite3_finalize(stmt);
if( skip==NULL || strcasecmp(self_addr, skip) != 0 ) {
mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, MR_CONTACT_ID_SELF);
dc_add_to_chat_contacts_table__(mailbox, chat_id, MR_CONTACT_ID_SELF);
}
if( from_id > MR_CONTACT_ID_LAST_SPECIAL ) {
if( mrmailbox_contact_addr_equals__(mailbox, from_id, self_addr)==0
&& (skip==NULL || mrmailbox_contact_addr_equals__(mailbox, from_id, skip)==0) ) {
mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, from_id);
if( dc_contact_addr_equals__(mailbox, from_id, self_addr)==0
&& (skip==NULL || dc_contact_addr_equals__(mailbox, from_id, skip)==0) ) {
dc_add_to_chat_contacts_table__(mailbox, chat_id, from_id);
}
}
for( i = 0; i < to_ids_cnt; i++ )
{
uint32_t to_id = dc_array_get_id(to_ids, i); /* to_id is only once in to_ids and is non-special */
if( mrmailbox_contact_addr_equals__(mailbox, to_id, self_addr)==0
&& (skip==NULL || mrmailbox_contact_addr_equals__(mailbox, to_id, skip)==0) ) {
mrmailbox_add_to_chat_contacts_table__(mailbox, chat_id, to_id);
if( dc_contact_addr_equals__(mailbox, to_id, self_addr)==0
&& (skip==NULL || dc_contact_addr_equals__(mailbox, to_id, skip)==0) ) {
dc_add_to_chat_contacts_table__(mailbox, chat_id, to_id);
}
}
send_EVENT_CHAT_MODIFIED = 1;
@ -913,7 +913,7 @@ static void create_or_lookup_group__(dc_context_t* mailbox, dc_mimeparser_t* mim
/* check the number of receivers -
the only critical situation is if the user hits "Reply" instead of "Reply all" in a non-messenger-client */
if( to_ids_cnt == 1 && mime_parser->m_is_send_by_messenger==0 ) {
int is_contact_cnt = mrmailbox_get_chat_contact_count__(mailbox, chat_id);
int is_contact_cnt = dc_get_chat_contact_count__(mailbox, chat_id);
if( is_contact_cnt > 3 /* to_ids_cnt==1 may be "From: A, To: B, SELF" as SELF is not counted in to_ids_cnt. So everything up to 3 is no error. */ ) {
chat_id = 0;
create_or_lookup_adhoc_group__(mailbox, mime_parser, create_blocked, from_id, to_ids, &chat_id, &chat_id_blocked);
@ -935,7 +935,7 @@ cleanup:
******************************************************************************/
void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_terminated, size_t imf_raw_bytes,
void dc_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_terminated, size_t imf_raw_bytes,
const char* server_folder, uint32_t server_uid, uint32_t flags)
{
/* the function returns the number of created messages in the database */
@ -1031,7 +1031,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
{
int check_self;
dc_array_t* from_list = dc_array_new(mailbox, 16);
mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mailbox, fld_from->frm_mb_list, MR_ORIGIN_INCOMING_UNKNOWN_FROM, from_list, &check_self);
dc_add_or_lookup_contacts_by_mailbox_list__(mailbox, fld_from->frm_mb_list, MR_ORIGIN_INCOMING_UNKNOWN_FROM, from_list, &check_self);
if( check_self )
{
incoming = 0;
@ -1046,7 +1046,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
if( dc_array_get_cnt(from_list)>=1 ) /* if there is no from given, from_id stays 0 which is just fine. These messages are very rare, however, we have to add them to the database (they go to the "deaddrop" chat) to avoid a re-download from the server. See also [**] */
{
from_id = dc_array_get_id(from_list, 0);
incoming_origin = mrmailbox_get_contact_origin__(mailbox, from_id, &from_id_blocked);
incoming_origin = dc_get_contact_origin__(mailbox, from_id, &from_id_blocked);
}
}
dc_array_unref(from_list);
@ -1060,7 +1060,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
struct mailimf_to* fld_to = field->fld_data.fld_to; /* can be NULL */
if( fld_to )
{
mrmailbox_add_or_lookup_contacts_by_address_list__(mailbox, fld_to->to_addr_list /*!= NULL*/,
dc_add_or_lookup_contacts_by_address_list__(mailbox, fld_to->to_addr_list /*!= NULL*/,
outgoing? MR_ORIGIN_OUTGOING_TO : (incoming_origin>=MR_ORIGIN_MIN_VERIFIED? MR_ORIGIN_INCOMING_TO : MR_ORIGIN_INCOMING_UNKNOWN_TO), to_ids, &to_self);
}
}
@ -1079,7 +1079,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
{
struct mailimf_cc* fld_cc = field->fld_data.fld_cc;
if( fld_cc ) {
mrmailbox_add_or_lookup_contacts_by_address_list__(mailbox, fld_cc->cc_addr_list,
dc_add_or_lookup_contacts_by_address_list__(mailbox, fld_cc->cc_addr_list,
outgoing? MR_ORIGIN_OUTGOING_CC : (incoming_origin>=MR_ORIGIN_MIN_VERIFIED? MR_ORIGIN_INCOMING_CC : MR_ORIGIN_INCOMING_UNKNOWN_CC), to_ids, NULL);
}
}
@ -1107,11 +1107,11 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
{
char* old_server_folder = NULL;
uint32_t old_server_uid = 0;
if( mrmailbox_rfc724_mid_exists__(mailbox, rfc724_mid, &old_server_folder, &old_server_uid) ) {
if( dc_rfc724_mid_exists__(mailbox, rfc724_mid, &old_server_folder, &old_server_uid) ) {
if( strcmp(old_server_folder, server_folder)!=0 || old_server_uid!=server_uid ) {
dc_sqlite3_rollback__(mailbox->m_sql);
transaction_pending = 0;
mrmailbox_update_server_uid__(mailbox, rfc724_mid, server_folder, server_uid);
dc_update_server_uid__(mailbox, rfc724_mid, server_folder, server_uid);
}
free(old_server_folder);
dc_log_info(mailbox, 0, "Message already in DB.");
@ -1133,7 +1133,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
if( dc_mimeparser_lookup_field(mime_parser, "Secure-Join") ) {
dc_sqlite3_commit__(mailbox->m_sql);
dc_sqlite3_unlock(mailbox->m_sql);
if( mrmailbox_handle_securejoin_handshake(mailbox, mime_parser, from_id) == MR_IS_HANDSHAKE_STOP_NORMAL_PROCESSING ) {
if( dc_handle_securejoin_handshake(mailbox, mime_parser, from_id) == MR_IS_HANDSHAKE_STOP_NORMAL_PROCESSING ) {
hidden = 1;
state = MR_STATE_IN_SEEN;
}
@ -1144,7 +1144,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
/* test if there is a normal chat with the sender - if so, this allows us to create groups in the next step */
uint32_t test_normal_chat_id = 0;
int test_normal_chat_id_blocked = 0;
mrmailbox_lookup_real_nchat_by_contact_id__(mailbox, from_id, &test_normal_chat_id, &test_normal_chat_id_blocked);
dc_lookup_real_nchat_by_contact_id__(mailbox, from_id, &test_normal_chat_id, &test_normal_chat_id_blocked);
/* get the chat_id - a chat_id here is no indicator that the chat is displayed in the normal list, it might also be
blocked and displayed in the deaddrop as a result */
@ -1155,7 +1155,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
int create_blocked = ((test_normal_chat_id&&test_normal_chat_id_blocked==MR_CHAT_NOT_BLOCKED) || incoming_origin>=MR_ORIGIN_MIN_START_NEW_NCHAT/*always false, for now*/)? MR_CHAT_NOT_BLOCKED : MR_CHAT_DEADDROP_BLOCKED;
create_or_lookup_group__(mailbox, mime_parser, create_blocked, from_id, to_ids, &chat_id, &chat_id_blocked);
if( chat_id && chat_id_blocked && !create_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id);
dc_unblock_chat__(mailbox, chat_id);
chat_id_blocked = 0;
}
}
@ -1178,16 +1178,16 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
chat_id_blocked = test_normal_chat_id_blocked;
}
else {
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, from_id, create_blocked, &chat_id, &chat_id_blocked);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, from_id, create_blocked, &chat_id, &chat_id_blocked);
}
if( chat_id && chat_id_blocked ) {
if( !create_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id);
dc_unblock_chat__(mailbox, chat_id);
chat_id_blocked = 0;
}
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. */
else if( dc_is_reply_to_known_message__(mailbox, mime_parser) ) {
dc_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. */
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);
}
@ -1220,17 +1220,17 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
{
create_or_lookup_group__(mailbox, mime_parser, MR_CHAT_NOT_BLOCKED, from_id, to_ids, &chat_id, &chat_id_blocked);
if( chat_id && chat_id_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id);
dc_unblock_chat__(mailbox, chat_id);
chat_id_blocked = 0;
}
}
if( chat_id == 0 )
{
int create_blocked = (mime_parser->m_is_send_by_messenger && !mrmailbox_is_contact_blocked__(mailbox, to_id))? MR_CHAT_NOT_BLOCKED : MR_CHAT_DEADDROP_BLOCKED;
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, to_id, create_blocked, &chat_id, &chat_id_blocked);
int create_blocked = (mime_parser->m_is_send_by_messenger && !dc_is_contact_blocked__(mailbox, to_id))? MR_CHAT_NOT_BLOCKED : MR_CHAT_DEADDROP_BLOCKED;
dc_create_or_lookup_nchat_by_contact_id__(mailbox, to_id, create_blocked, &chat_id, &chat_id_blocked);
if( chat_id && chat_id_blocked && !create_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id);
dc_unblock_chat__(mailbox, chat_id);
chat_id_blocked = 0;
}
}
@ -1239,9 +1239,9 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
if( chat_id == 0 ) {
if( dc_array_get_cnt(to_ids) == 0 && to_self ) {
/* from_id == to_id == MR_CONTACT_ID_SELF - this is a self-sent messages, maybe an Autocrypt Setup Message */
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, MR_CONTACT_ID_SELF, MR_CHAT_NOT_BLOCKED, &chat_id, &chat_id_blocked);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, MR_CONTACT_ID_SELF, MR_CHAT_NOT_BLOCKED, &chat_id, &chat_id_blocked);
if( chat_id && chat_id_blocked ) {
mrmailbox_unblock_chat__(mailbox, chat_id);
dc_unblock_chat__(mailbox, chat_id);
chat_id_blocked = 0;
}
}
@ -1254,11 +1254,11 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
/* correct message_timestamp, it should not be used before,
however, we cannot do this earlier as we need from_id to be set */
mrmailbox_calc_timestamps__(mailbox, chat_id, from_id, sent_timestamp, (flags&MR_IMAP_SEEN)? 0 : 1 /*fresh message?*/,
dc_calc_timestamps__(mailbox, chat_id, from_id, sent_timestamp, (flags&MR_IMAP_SEEN)? 0 : 1 /*fresh message?*/,
&sort_timestamp, &sent_timestamp, &rcvd_timestamp);
/* unarchive chat */
mrmailbox_unarchive_chat__(mailbox, chat_id);
dc_unarchive_chat__(mailbox, chat_id);
/* if the message is not sent by a messenger, check if it is sent at least as a reply to a messenger message
(later, we move these replies to the folder used for DeltaChat messages) */
@ -1269,7 +1269,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
}
else
{
if( mrmailbox_is_reply_to_messenger_message__(mailbox, mime_parser) )
if( dc_is_reply_to_messenger_message__(mailbox, mime_parser) )
{
dc_log_info(mailbox, 0, "Message is a reply to a messenger message.");
msgrmsg = 2; /* 2=no, but is reply to messenger message */
@ -1416,7 +1416,7 @@ void mrmailbox_receive_imf(dc_context_t* mailbox, const char* imf_raw_not_termin
{
uint32_t chat_id = 0;
uint32_t msg_id = 0;
if( mrmailbox_mdn_from_ext__(mailbox, from_id, rfc724_mid, sent_timestamp, &chat_id, &msg_id) ) {
if( dc_mdn_from_ext__(mailbox, from_id, rfc724_mid, sent_timestamp, &chat_id, &msg_id) ) {
carray_add(rr_event_to_send, (void*)(uintptr_t)chat_id, NULL);
carray_add(rr_event_to_send, (void*)(uintptr_t)msg_id, NULL);
}

View file

@ -40,7 +40,7 @@
******************************************************************************/
void mrmailbox_handle_degrade_event(dc_context_t* mailbox, dc_apeerstate_t* peerstate)
void dc_handle_degrade_event(dc_context_t* mailbox, dc_apeerstate_t* peerstate)
{
sqlite3_stmt* stmt = NULL;
int locked = 0;
@ -71,12 +71,12 @@ void mrmailbox_handle_degrade_event(dc_context_t* mailbox, dc_apeerstate_t* peer
goto cleanup;
}
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_DEADDROP_BLOCKED, &contact_chat_id, NULL);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_DEADDROP_BLOCKED, &contact_chat_id, NULL);
UNLOCK
char* msg = mr_mprintf("Changed setup for %s", peerstate->m_addr);
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
dc_add_device_msg(mailbox, contact_chat_id, msg);
free(msg);
mailbox->m_cb(mailbox, DC_EVENT_CHAT_MODIFIED, contact_chat_id, 0);
}
@ -150,7 +150,7 @@ cleanup:
static uint32_t chat_id_2_contact_id(dc_context_t* mailbox, uint32_t contact_chat_id)
{
uint32_t contact_id = 0;
dc_array_t* contacts = mrmailbox_get_chat_contacts(mailbox, contact_chat_id);
dc_array_t* contacts = dc_get_chat_contacts(mailbox, contact_chat_id);
if( dc_array_get_cnt(contacts) != 1 ) {
goto cleanup;
@ -168,7 +168,7 @@ static int fingerprint_equals_sender(dc_context_t* mailbox, const char* fingerpr
{
int fingerprint_equal = 0;
int locked = 0;
dc_array_t* contacts = mrmailbox_get_chat_contacts(mailbox, contact_chat_id);
dc_array_t* contacts = dc_get_chat_contacts(mailbox, contact_chat_id);
dc_contact_t* contact = dc_contact_new(mailbox);
dc_apeerstate_t* peerstate = dc_apeerstate_new(mailbox);
char* fingerprint_normalized = NULL;
@ -272,7 +272,7 @@ static void send_handshake_msg(dc_context_t* mailbox, uint32_t contact_chat_id,
mrparam_set_int(msg->m_param, MRP_GUARANTEE_E2EE, 1); /* all but the first message MUST be encrypted */
}
mrmailbox_send_msg_object(mailbox, contact_chat_id, msg);
dc_send_msg_object(mailbox, contact_chat_id, msg);
dc_msg_unref(msg);
}
@ -281,10 +281,10 @@ static void send_handshake_msg(dc_context_t* mailbox, uint32_t contact_chat_id,
static void could_not_establish_secure_connection(dc_context_t* mailbox, uint32_t contact_chat_id, const char* details)
{
uint32_t contact_id = chat_id_2_contact_id(mailbox, contact_chat_id);
dc_contact_t* contact = mrmailbox_get_contact(mailbox, contact_id);
dc_contact_t* contact = dc_get_contact(mailbox, contact_id);
char* msg = mr_mprintf("Could not establish secure connection to %s.", contact? contact->m_addr : "?");
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
dc_add_device_msg(mailbox, contact_chat_id, msg);
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)
@ -296,12 +296,12 @@ static void could_not_establish_secure_connection(dc_context_t* mailbox, uint32_
static void secure_connection_established(dc_context_t* mailbox, uint32_t contact_chat_id)
{
uint32_t contact_id = chat_id_2_contact_id(mailbox, contact_chat_id);
dc_contact_t* contact = mrmailbox_get_contact(mailbox, contact_id);
dc_contact_t* contact = dc_get_contact(mailbox, contact_id);
char* msg = mr_mprintf("Secure connection to %s established.", contact? contact->m_addr : "?");
mrmailbox_add_device_msg(mailbox, contact_chat_id, msg);
dc_add_device_msg(mailbox, contact_chat_id, msg);
// in addition to DC_EVENT_MSGS_CHANGED (sent by mrmailbox_add_device_msg()), also send DC_EVENT_CHAT_MODIFIED to update all views
// in addition to DC_EVENT_MSGS_CHANGED (sent by dc_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);
@ -323,7 +323,7 @@ static int s_bobs_status = 0;
static void end_bobs_joining(dc_context_t* mailbox, int status)
{
s_bobs_status = status;
mrmailbox_stop_ongoing_process(mailbox);
dc_stop_ongoing_process(mailbox);
}
@ -375,7 +375,7 @@ char* dc_get_securejoin_qr(dc_context_t* mailbox, uint32_t group_chat_id)
goto cleanup;
}
mrmailbox_ensure_secret_key_exists(mailbox);
dc_ensure_secret_key_exists(mailbox);
dc_sqlite3_lock(mailbox->m_sql);
locked = 1;
@ -413,7 +413,7 @@ char* dc_get_securejoin_qr(dc_context_t* mailbox, uint32_t group_chat_id)
if( group_chat_id )
{
// parameters used: a=g=x=i=s=
chat = mrmailbox_get_chat(mailbox, group_chat_id);
chat = dc_get_chat(mailbox, group_chat_id);
if( chat == NULL || chat->m_type != MR_CHAT_TYPE_VERIFIED_GROUP ) {
dc_log_error(mailbox, 0, "Secure join is only available for verified groups.");
goto cleanup;
@ -485,19 +485,19 @@ uint32_t dc_join_securejoin(dc_context_t* mailbox, const char* qr)
dc_log_info(mailbox, 0, "Requesting secure-join ...");
mrmailbox_ensure_secret_key_exists(mailbox);
dc_ensure_secret_key_exists(mailbox);
if( (ongoing_allocated=mrmailbox_alloc_ongoing(mailbox)) == 0 ) {
if( (ongoing_allocated=dc_alloc_ongoing(mailbox)) == 0 ) {
goto cleanup;
}
if( ((qr_scan=mrmailbox_check_qr(mailbox, qr))==NULL)
if( ((qr_scan=dc_check_qr(mailbox, qr))==NULL)
|| (qr_scan->m_state!=MR_QR_ASK_VERIFYCONTACT && qr_scan->m_state!=MR_QR_ASK_VERIFYGROUP) ) {
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 ) {
if( (contact_chat_id=dc_create_chat_by_contact_id(mailbox, qr_scan->m_id)) == 0 ) {
dc_log_error(mailbox, 0, "Unknown contact.");
goto cleanup;
}
@ -546,7 +546,7 @@ cleanup:
if( s_bobs_status == BOB_SUCCESS ) {
if( join_vg ) {
dc_sqlite3_lock(mailbox->m_sql);
ret_chat_id = mrmailbox_get_chat_id_by_grpid__(mailbox, qr_scan->m_text2, NULL, NULL);
ret_chat_id = dc_get_chat_id_by_grpid__(mailbox, qr_scan->m_text2, NULL, NULL);
dc_sqlite3_unlock(mailbox->m_sql);
}
else {
@ -560,12 +560,12 @@ cleanup:
dc_lot_unref(qr_scan);
if( ongoing_allocated ) { mrmailbox_free_ongoing(mailbox); }
if( ongoing_allocated ) { dc_free_ongoing(mailbox); }
return ret_chat_id;
}
int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t* mimeparser, uint32_t contact_id)
int dc_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t* mimeparser, uint32_t contact_id)
{
int locked = 0;
const char* step = NULL;
@ -589,9 +589,9 @@ int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t
join_vg = (strncmp(step, "vg-", 3)==0);
LOCK
mrmailbox_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_NOT_BLOCKED, &contact_chat_id, &contact_chat_id_blocked);
dc_create_or_lookup_nchat_by_contact_id__(mailbox, contact_id, MR_CHAT_NOT_BLOCKED, &contact_chat_id, &contact_chat_id_blocked);
if( contact_chat_id_blocked ) {
mrmailbox_unblock_chat__(mailbox, contact_chat_id);
dc_unblock_chat__(mailbox, contact_chat_id);
}
UNLOCK
@ -723,7 +723,7 @@ int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t
goto cleanup;
}
mrmailbox_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_SECUREJOIN_INVITED);
dc_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_SECUREJOIN_INVITED);
UNLOCK
dc_log_info(mailbox, 0, "Auth verified.");
@ -738,14 +738,14 @@ int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t
grpid = safe_strdup(lookup_field(mimeparser, "Secure-Join-Group"));
int is_verified = 0;
LOCK
uint32_t verified_chat_id = mrmailbox_get_chat_id_by_grpid__(mailbox, grpid, NULL, &is_verified);
uint32_t verified_chat_id = dc_get_chat_id_by_grpid__(mailbox, grpid, NULL, &is_verified);
UNLOCK
if( verified_chat_id == 0 || !is_verified ) {
dc_log_error(mailbox, 0, "Verified chat not found.");
goto cleanup;
}
mrmailbox_add_contact_to_chat_ex(mailbox, verified_chat_id, contact_id, MR_FROM_HANDSHAKE); // Alice -> Bob and all members
dc_add_contact_to_chat_ex(mailbox, verified_chat_id, contact_id, MR_FROM_HANDSHAKE); // Alice -> Bob and all members
}
else {
send_handshake_msg(mailbox, contact_chat_id, "vc-contact-confirm",
@ -796,7 +796,7 @@ int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t
goto cleanup;
}
mrmailbox_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_SECUREJOIN_JOINED);
dc_scaleup_contact_origin__(mailbox, contact_id, MR_ORIGIN_SECUREJOIN_JOINED);
UNLOCK
secure_connection_established(mailbox, contact_chat_id);
@ -814,7 +814,7 @@ int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t
if( (field=dc_mimeparser_lookup_field(mimeparser, "Message-ID"))!=NULL && field->fld_type==MAILIMF_FIELD_MESSAGE_ID ) {
struct mailimf_message_id* fld_message_id = field->fld_data.fld_message_id;
if( fld_message_id && fld_message_id->mid_value ) {
dc_job_add(mailbox, DC_JOB_DELETE_MSG_ON_IMAP, mrmailbox_rfc724_mid_exists__(mailbox, fld_message_id->mid_value, NULL, NULL), NULL, 0);
dc_job_add(mailbox, DC_JOB_DELETE_MSG_ON_IMAP, dc_rfc724_mid_exists__(mailbox, fld_message_id->mid_value, NULL, NULL), NULL, 0);
}
}
}