mirror of
https://github.com/deltachat/deltachat-core.git
synced 2025-10-05 10:39:27 +02:00
refactor mrmailbox
This commit is contained in:
parent
815641151e
commit
e1cebe7234
43 changed files with 442 additions and 442 deletions
|
@ -229,7 +229,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
dc_apeerstate_t* dc_apeerstate_new(mrmailbox_t* mailbox)
|
||||
dc_apeerstate_t* dc_apeerstate_new(dc_context_t* mailbox)
|
||||
{
|
||||
dc_apeerstate_t* ths = NULL;
|
||||
|
||||
|
@ -237,7 +237,7 @@ dc_apeerstate_t* dc_apeerstate_new(mrmailbox_t* mailbox)
|
|||
exit(43); /* cannot allocate little memory, unrecoverable error */
|
||||
}
|
||||
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
|
||||
return ths;
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ typedef struct dc_aheader_t dc_aheader_t;
|
|||
typedef struct dc_apeerstate_t
|
||||
{
|
||||
/** @privatesection */
|
||||
mrmailbox_t* m_mailbox;
|
||||
dc_context_t* m_context;
|
||||
|
||||
char* m_addr;
|
||||
time_t m_last_seen; /* may be 0 if the peer was created by gossipping */
|
||||
|
@ -76,7 +76,7 @@ typedef struct dc_apeerstate_t
|
|||
} dc_apeerstate_t;
|
||||
|
||||
|
||||
dc_apeerstate_t* dc_apeerstate_new (mrmailbox_t*); /* the returned pointer is ref'd and must be unref'd after usage */
|
||||
dc_apeerstate_t* dc_apeerstate_new (dc_context_t*); /* the returned pointer is ref'd and must be unref'd after usage */
|
||||
void dc_apeerstate_unref (dc_apeerstate_t*);
|
||||
|
||||
int dc_apeerstate_init_from_header (dc_apeerstate_t*, const dc_aheader_t*, time_t message_time);
|
||||
|
|
|
@ -46,7 +46,7 @@ dc_array_t* dc_array_new(dc_context_t* mailbox, size_t initsize)
|
|||
}
|
||||
|
||||
array->m_magic = MR_ARRAY_MAGIC;
|
||||
array->m_mailbox = mailbox;
|
||||
array->m_context = mailbox;
|
||||
array->m_count = 0;
|
||||
array->m_allocated = initsize < 1? 1 : initsize;
|
||||
array->m_array = malloc(array->m_allocated * sizeof(uintptr_t));
|
||||
|
@ -125,7 +125,7 @@ dc_array_t* dc_array_duplicate(const dc_array_t* array)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
ret = dc_array_new(array->m_mailbox, array->m_allocated);
|
||||
ret = dc_array_new(array->m_context, array->m_allocated);
|
||||
ret->m_count = array->m_count;
|
||||
memcpy(ret->m_array, array->m_array, array->m_count * sizeof(uintptr_t));
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ struct _dc_array
|
|||
/** @privatesection */
|
||||
|
||||
uint32_t m_magic;
|
||||
mrmailbox_t* m_mailbox; /**< The mailbox the array belongs to. May be NULL when NULL is given to dc_array_new(). */
|
||||
dc_context_t* m_context; /**< The mailbox the array belongs to. May be NULL when NULL is given to dc_array_new(). */
|
||||
size_t m_allocated; /**< The number of allocated items. Initially ~ 200. */
|
||||
size_t m_count; /**< The number of used items. Initially 0. */
|
||||
uintptr_t* m_array; /**< The data items, can be used between m_data[0] and m_data[m_cnt-1]. Never NULL. */
|
||||
|
|
|
@ -48,7 +48,7 @@ dc_chat_t* dc_chat_new(dc_context_t* mailbox)
|
|||
}
|
||||
|
||||
ths->m_magic = MR_CHAT_MAGIC;
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
ths->m_type = MR_CHAT_TYPE_UNDEFINED;
|
||||
ths->m_param = mrparam_new();
|
||||
|
||||
|
@ -228,9 +228,9 @@ char* dc_chat_get_subtitle(dc_chat_t* chat)
|
|||
else if( chat->m_type == MR_CHAT_TYPE_SINGLE )
|
||||
{
|
||||
int r;
|
||||
dc_sqlite3_lock(chat->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(chat->m_context->m_sql);
|
||||
|
||||
stmt = dc_sqlite3_predefine__(chat->m_mailbox->m_sql, SELECT_a_FROM_chats_contacts_WHERE_i,
|
||||
stmt = dc_sqlite3_predefine__(chat->m_context->m_sql, SELECT_a_FROM_chats_contacts_WHERE_i,
|
||||
"SELECT c.addr FROM chats_contacts cc "
|
||||
" LEFT JOIN contacts c ON c.id=cc.contact_id "
|
||||
" WHERE cc.chat_id=?;");
|
||||
|
@ -241,7 +241,7 @@ char* dc_chat_get_subtitle(dc_chat_t* chat)
|
|||
ret = safe_strdup((const char*)sqlite3_column_text(stmt, 0));
|
||||
}
|
||||
|
||||
dc_sqlite3_unlock(chat->m_mailbox->m_sql);
|
||||
dc_sqlite3_unlock(chat->m_context->m_sql);
|
||||
}
|
||||
else if( MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
|
@ -252,12 +252,12 @@ char* dc_chat_get_subtitle(dc_chat_t* chat)
|
|||
}
|
||||
else
|
||||
{
|
||||
dc_sqlite3_lock(chat->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(chat->m_context->m_sql);
|
||||
|
||||
cnt = mrmailbox_get_chat_contact_count__(chat->m_mailbox, chat->m_id);
|
||||
cnt = mrmailbox_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_mailbox->m_sql);
|
||||
dc_sqlite3_unlock(chat->m_context->m_sql);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -413,7 +413,7 @@ int dc_chat_are_all_members_verified__(dc_chat_t* chat)
|
|||
goto cleanup; // deaddrop & co. are never verified
|
||||
}
|
||||
|
||||
stmt = dc_sqlite3_predefine__(chat->m_mailbox->m_sql, SELECT_verified_FROM_chats_contacts_WHERE_chat_id,
|
||||
stmt = dc_sqlite3_predefine__(chat->m_context->m_sql, SELECT_verified_FROM_chats_contacts_WHERE_chat_id,
|
||||
"SELECT c.id, LENGTH(ps.verified_key_fingerprint) "
|
||||
" FROM chats_contacts cc"
|
||||
" LEFT JOIN contacts c ON c.id=cc.contact_id"
|
||||
|
@ -465,7 +465,7 @@ int dc_chat_is_self_talk(dc_chat_t* chat)
|
|||
int dc_chat_update_param__(dc_chat_t* ths)
|
||||
{
|
||||
int success = 0;
|
||||
sqlite3_stmt* stmt = dc_sqlite3_prepare_v2_(ths->m_mailbox->m_sql, "UPDATE chats SET param=? WHERE id=?");
|
||||
sqlite3_stmt* stmt = dc_sqlite3_prepare_v2_(ths->m_context->m_sql, "UPDATE chats SET param=? WHERE id=?");
|
||||
sqlite3_bind_text(stmt, 1, ths->m_param->m_packed, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_int (stmt, 2, ths->m_id);
|
||||
success = sqlite3_step(stmt)==SQLITE_DONE? 1 : 0;
|
||||
|
@ -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_mailbox));
|
||||
ths->m_name = mr_mprintf("%s (%i)", tempname, mrmailbox_get_archived_count__(ths->m_context));
|
||||
free(tempname);
|
||||
}
|
||||
else if( ths->m_id == MR_CHAT_ID_STARRED ) {
|
||||
|
@ -553,7 +553,7 @@ int dc_chat_load_from_db__(dc_chat_t* chat, uint32_t chat_id)
|
|||
|
||||
dc_chat_empty(chat);
|
||||
|
||||
stmt = dc_sqlite3_predefine__(chat->m_mailbox->m_sql, SELECT_itndd_FROM_chats_WHERE_i,
|
||||
stmt = dc_sqlite3_predefine__(chat->m_context->m_sql, SELECT_itndd_FROM_chats_WHERE_i,
|
||||
"SELECT " MR_CHAT_FIELDS " FROM chats c WHERE c.id=?;");
|
||||
sqlite3_bind_int(stmt, 1, chat_id);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ struct _dc_chat
|
|||
char* m_draft_text; /**< Draft text. NULL if there is no draft. */
|
||||
time_t m_draft_timestamp; /**< Timestamp of the draft. 0 if there is no draft. */
|
||||
int m_archived; /**< Archived state. Better use dc_chat_get_archived() to access this object. */
|
||||
mrmailbox_t* m_mailbox; /**< The mailbox object the chat belongs to. */
|
||||
dc_context_t* m_context; /**< The mailbox object the chat belongs to. */
|
||||
char* m_grpid; /**< Group ID that is used by all clients. Only used if the chat is a group. NULL if unset */
|
||||
int m_blocked; /**< One of MR_CHAT_*_BLOCKED */
|
||||
mrparam_t* m_param; /**< Additional parameters for a chat. Should not be used directly. */
|
||||
|
|
|
@ -44,7 +44,7 @@ dc_chatlist_t* dc_chatlist_new(dc_context_t* mailbox)
|
|||
}
|
||||
|
||||
ths->m_magic = MR_CHATLIST_MAGIC;
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
if( (ths->m_chatNlastmsg_ids=dc_array_new(mailbox, 128))==NULL ) {
|
||||
exit(32);
|
||||
}
|
||||
|
@ -214,11 +214,11 @@ dc_lot_t* dc_chatlist_get_summary(dc_chatlist_t* chatlist, size_t index, dc_chat
|
|||
lastmsg_id = dc_array_get_id(chatlist->m_chatNlastmsg_ids, index*MR_CHATLIST_IDS_PER_RESULT+1);
|
||||
|
||||
/* load data from database */
|
||||
dc_sqlite3_lock(chatlist->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(chatlist->m_context->m_sql);
|
||||
locked = 1;
|
||||
|
||||
if( chat==NULL ) {
|
||||
chat = dc_chat_new(chatlist->m_mailbox);
|
||||
chat = dc_chat_new(chatlist->m_context);
|
||||
chat_to_delete = chat;
|
||||
if( !dc_chat_load_from_db__(chat, dc_array_get_id(chatlist->m_chatNlastmsg_ids, index*MR_CHATLIST_IDS_PER_RESULT)) ) {
|
||||
ret->m_text2 = safe_strdup("ErrCannotReadChat");
|
||||
|
@ -230,17 +230,17 @@ dc_lot_t* dc_chatlist_get_summary(dc_chatlist_t* chatlist, size_t index, dc_chat
|
|||
{
|
||||
|
||||
lastmsg = dc_msg_new();
|
||||
dc_msg_load_from_db__(lastmsg, chatlist->m_mailbox, lastmsg_id);
|
||||
dc_msg_load_from_db__(lastmsg, chatlist->m_context, lastmsg_id);
|
||||
|
||||
if( lastmsg->m_from_id != MR_CONTACT_ID_SELF && MR_CHAT_TYPE_IS_MULTI(chat->m_type) )
|
||||
{
|
||||
lastcontact = dc_contact_new(chatlist->m_mailbox);
|
||||
dc_contact_load_from_db__(lastcontact, chatlist->m_mailbox->m_sql, lastmsg->m_from_id);
|
||||
lastcontact = dc_contact_new(chatlist->m_context);
|
||||
dc_contact_load_from_db__(lastcontact, chatlist->m_context->m_sql, lastmsg->m_from_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
dc_sqlite3_unlock(chatlist->m_mailbox->m_sql);
|
||||
dc_sqlite3_unlock(chatlist->m_context->m_sql);
|
||||
locked = 0;
|
||||
|
||||
if( chat->m_id == MR_CHAT_ID_ARCHIVED_LINK )
|
||||
|
@ -272,7 +272,7 @@ dc_lot_t* dc_chatlist_get_summary(dc_chatlist_t* chatlist, size_t index, dc_chat
|
|||
}
|
||||
|
||||
cleanup:
|
||||
if( locked ) { dc_sqlite3_unlock(chatlist->m_mailbox->m_sql); }
|
||||
if( locked ) { dc_sqlite3_unlock(chatlist->m_context->m_sql); }
|
||||
dc_msg_unref(lastmsg);
|
||||
dc_contact_unref(lastcontact);
|
||||
dc_chat_unref(chat_to_delete);
|
||||
|
@ -294,7 +294,7 @@ dc_context_t* dc_chatlist_get_context(dc_chatlist_t* chatlist)
|
|||
if( chatlist == NULL || chatlist->m_magic != MR_CHATLIST_MAGIC ) {
|
||||
return NULL;
|
||||
}
|
||||
return chatlist->m_mailbox;
|
||||
return chatlist->m_context;
|
||||
}
|
||||
|
||||
|
||||
|
@ -314,7 +314,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
|
|||
sqlite3_stmt* stmt = NULL;
|
||||
char* strLikeCmd = NULL, *query = NULL;
|
||||
|
||||
if( ths == NULL || ths->m_magic != MR_CHATLIST_MAGIC || ths->m_mailbox == NULL ) {
|
||||
if( ths == NULL || ths->m_magic != MR_CHATLIST_MAGIC || ths->m_context == NULL ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -336,21 +336,21 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
|
|||
if( query_contact_id )
|
||||
{
|
||||
// show chats shared with a given contact
|
||||
stmt = dc_sqlite3_predefine__(ths->m_mailbox->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_contact_id,
|
||||
stmt = dc_sqlite3_predefine__(ths->m_context->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_contact_id,
|
||||
QUR1 " AND c.id IN(SELECT chat_id FROM chats_contacts WHERE contact_id=?) " QUR2);
|
||||
sqlite3_bind_int(stmt, 1, query_contact_id);
|
||||
}
|
||||
else if( listflags & MR_GCL_ARCHIVED_ONLY )
|
||||
{
|
||||
/* show archived chats */
|
||||
stmt = dc_sqlite3_predefine__(ths->m_mailbox->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_archived,
|
||||
stmt = dc_sqlite3_predefine__(ths->m_context->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_archived,
|
||||
QUR1 " AND c.archived=1 " QUR2);
|
||||
}
|
||||
else if( query__==NULL )
|
||||
{
|
||||
/* show normal chatlist */
|
||||
if( !(listflags & MR_GCL_NO_SPECIALS) ) {
|
||||
uint32_t last_deaddrop_fresh_msg_id = mrmailbox_get_last_deaddrop_fresh_msg__(ths->m_mailbox);
|
||||
uint32_t last_deaddrop_fresh_msg_id = mrmailbox_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);
|
||||
|
@ -358,7 +358,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
|
|||
add_archived_link_item = 1;
|
||||
}
|
||||
|
||||
stmt = dc_sqlite3_predefine__(ths->m_mailbox->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_unarchived,
|
||||
stmt = dc_sqlite3_predefine__(ths->m_context->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_unarchived,
|
||||
QUR1 " AND c.archived=0 " QUR2);
|
||||
}
|
||||
else
|
||||
|
@ -371,7 +371,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
|
|||
goto cleanup;
|
||||
}
|
||||
strLikeCmd = mr_mprintf("%%%s%%", query);
|
||||
stmt = dc_sqlite3_predefine__(ths->m_mailbox->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_query,
|
||||
stmt = dc_sqlite3_predefine__(ths->m_context->m_sql, SELECT_ii_FROM_chats_LEFT_JOIN_msgs_WHERE_query,
|
||||
QUR1 " AND c.name LIKE ? " QUR2);
|
||||
sqlite3_bind_text(stmt, 1, strLikeCmd, -1, SQLITE_STATIC);
|
||||
}
|
||||
|
@ -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_mailbox)>0 )
|
||||
if( add_archived_link_item && mrmailbox_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);
|
||||
|
@ -392,7 +392,7 @@ int dc_chatlist_load_from_db__(dc_chatlist_t* ths, int listflags, const char* qu
|
|||
success = 1;
|
||||
|
||||
cleanup:
|
||||
//dc_log_info(ths->m_mailbox, 0, "Chatlist for search \"%s\" created in %.3f ms.", query__?query__:"", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
||||
//dc_log_info(ths->m_context, 0, "Chatlist for search \"%s\" created in %.3f ms.", query__?query__:"", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
||||
|
||||
free(query);
|
||||
free(strLikeCmd);
|
||||
|
|
|
@ -32,7 +32,7 @@ struct _dc_chatlist
|
|||
{
|
||||
/** @privatesection */
|
||||
uint32_t m_magic;
|
||||
mrmailbox_t* m_mailbox; /**< The mailbox, the chatlist belongs to */
|
||||
dc_context_t* m_context; /**< The mailbox, the chatlist belongs to */
|
||||
#define MR_CHATLIST_IDS_PER_RESULT 2
|
||||
size_t m_cnt;
|
||||
dc_array_t* m_chatNlastmsg_ids;
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static char* read_autoconf_file(mrmailbox_t* mailbox, const char* url)
|
||||
static char* read_autoconf_file(dc_context_t* mailbox, const char* url)
|
||||
{
|
||||
char* filecontent = NULL;
|
||||
dc_log_info(mailbox, 0, "Testing %s ...", url);
|
||||
|
@ -163,7 +163,7 @@ static void moz_autoconfigure_endtag_cb(void* userdata, const char* tag)
|
|||
}
|
||||
|
||||
|
||||
static dc_loginparam_t* moz_autoconfigure(mrmailbox_t* mailbox, const char* url, const dc_loginparam_t* param_in)
|
||||
static dc_loginparam_t* moz_autoconfigure(dc_context_t* mailbox, const char* url, const dc_loginparam_t* param_in)
|
||||
{
|
||||
char* xml_raw = NULL;
|
||||
moz_autoconfigure_t moz_ac;
|
||||
|
@ -302,7 +302,7 @@ static void outlk_autodiscover_endtag_cb(void* userdata, const char* tag)
|
|||
}
|
||||
|
||||
|
||||
static dc_loginparam_t* outlk_autodiscover(mrmailbox_t* mailbox, const char* url__, const dc_loginparam_t* param_in)
|
||||
static dc_loginparam_t* outlk_autodiscover(dc_context_t* mailbox, const char* url__, const dc_loginparam_t* param_in)
|
||||
{
|
||||
char* xml_raw = NULL, *url = safe_strdup(url__);
|
||||
outlk_autodiscover_t outlk_ad;
|
||||
|
@ -773,7 +773,7 @@ int dc_is_configured(dc_context_t* mailbox)
|
|||
*/
|
||||
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(mrmailbox_t* mailbox)
|
||||
int mrmailbox_alloc_ongoing(dc_context_t* mailbox)
|
||||
{
|
||||
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
|
||||
return 0;
|
||||
|
@ -794,7 +794,7 @@ int mrmailbox_alloc_ongoing(mrmailbox_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.
|
||||
*/
|
||||
void mrmailbox_free_ongoing(mrmailbox_t* mailbox)
|
||||
void mrmailbox_free_ongoing(dc_context_t* mailbox)
|
||||
{
|
||||
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
|
||||
return;
|
||||
|
|
|
@ -46,7 +46,7 @@ dc_contact_t* dc_contact_new(dc_context_t* mailbox)
|
|||
}
|
||||
|
||||
ths->m_magic = MR_CONTACT_MAGIC;
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
|
||||
return ths;
|
||||
}
|
||||
|
@ -318,19 +318,19 @@ int dc_contact_is_verified(const dc_contact_t* contact)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
peerstate = dc_apeerstate_new(contact->m_mailbox);
|
||||
peerstate = dc_apeerstate_new(contact->m_context);
|
||||
|
||||
dc_sqlite3_lock(contact->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(contact->m_context->m_sql);
|
||||
locked = 1;
|
||||
|
||||
if( !dc_apeerstate_load_by_addr__(peerstate, contact->m_mailbox->m_sql, contact->m_addr) ) {
|
||||
if( !dc_apeerstate_load_by_addr__(peerstate, contact->m_context->m_sql, contact->m_addr) ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
contact_verified = dc_contact_is_verified__(contact, peerstate);
|
||||
|
||||
cleanup:
|
||||
if( locked ) { dc_sqlite3_unlock(contact->m_mailbox->m_sql); }
|
||||
if( locked ) { dc_sqlite3_unlock(contact->m_context->m_sql); }
|
||||
dc_apeerstate_unref(peerstate);
|
||||
return contact_verified;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ struct _dc_contact
|
|||
/** @privatesection */
|
||||
|
||||
uint32_t m_magic;
|
||||
mrmailbox_t* m_mailbox;
|
||||
dc_context_t* m_context;
|
||||
|
||||
/**
|
||||
* The contact ID.
|
||||
|
|
|
@ -41,13 +41,13 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static uintptr_t cb_dummy(mrmailbox_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
|
||||
static uintptr_t cb_dummy(dc_context_t* mailbox, int event, uintptr_t data1, uintptr_t data2)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
static char* cb_get_config(dc_imap_t* imap, const char* key, const char* def)
|
||||
{
|
||||
mrmailbox_t* mailbox = (mrmailbox_t*)imap->m_userData;
|
||||
dc_context_t* mailbox = (dc_context_t*)imap->m_userData;
|
||||
dc_sqlite3_lock(mailbox->m_sql);
|
||||
char* ret = dc_sqlite3_get_config__(mailbox->m_sql, key, def);
|
||||
dc_sqlite3_unlock(mailbox->m_sql);
|
||||
|
@ -55,14 +55,14 @@ static char* cb_get_config(dc_imap_t* imap, const char* key, const char* def)
|
|||
}
|
||||
static void cb_set_config(dc_imap_t* imap, const char* key, const char* value)
|
||||
{
|
||||
mrmailbox_t* mailbox = (mrmailbox_t*)imap->m_userData;
|
||||
dc_context_t* mailbox = (dc_context_t*)imap->m_userData;
|
||||
dc_sqlite3_lock(mailbox->m_sql);
|
||||
dc_sqlite3_set_config__(mailbox->m_sql, key, value);
|
||||
dc_sqlite3_unlock(mailbox->m_sql);
|
||||
}
|
||||
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)
|
||||
{
|
||||
mrmailbox_t* mailbox = (mrmailbox_t*)imap->m_userData;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -98,9 +98,9 @@ static void cb_receive_imf(dc_imap_t* imap, const char* imf_raw_not_terminated,
|
|||
*/
|
||||
dc_context_t* dc_context_new(dc_callback_t cb, void* userdata, const char* os_name)
|
||||
{
|
||||
mrmailbox_t* ths = NULL;
|
||||
dc_context_t* ths = NULL;
|
||||
|
||||
if( (ths=calloc(1, sizeof(mrmailbox_t)))==NULL ) {
|
||||
if( (ths=calloc(1, sizeof(dc_context_t)))==NULL ) {
|
||||
exit(23); /* cannot allocate little memory, unrecoverable error */
|
||||
}
|
||||
|
||||
|
@ -646,7 +646,7 @@ char* dc_get_info(dc_context_t* mailbox)
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
int mrmailbox_get_archived_count__(mrmailbox_t* mailbox)
|
||||
int mrmailbox_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;");
|
||||
|
@ -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__(mrmailbox_t* mailbox, const char* grpid, int* ret_blocked, int* ret_verified)
|
||||
uint32_t mrmailbox_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;
|
||||
|
@ -989,7 +989,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static dc_array_t* mrmailbox_get_chat_media__(mrmailbox_t* mailbox, uint32_t chat_id, int msg_type, int or_msg_type)
|
||||
static dc_array_t* mrmailbox_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);
|
||||
|
||||
|
@ -1516,7 +1516,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_get_fresh_msg_count__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t chat_id)
|
|||
}
|
||||
|
||||
|
||||
uint32_t mrmailbox_get_last_deaddrop_fresh_msg__(mrmailbox_t* mailbox)
|
||||
uint32_t mrmailbox_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__(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_get_total_msg_count__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t chat_id)
|
|||
}
|
||||
|
||||
|
||||
size_t mrmailbox_get_chat_cnt__(mrmailbox_t* mailbox)
|
||||
size_t mrmailbox_get_chat_cnt__(dc_context_t* mailbox)
|
||||
{
|
||||
sqlite3_stmt* stmt;
|
||||
|
||||
|
@ -1590,7 +1590,7 @@ size_t mrmailbox_get_chat_cnt__(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_lookup_real_nchat_by_contact_id__(mrmailbox_t* mailbox, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked)
|
||||
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)
|
||||
{
|
||||
/* checks for "real" chats or self-chat */
|
||||
sqlite3_stmt* stmt;
|
||||
|
@ -1616,7 +1616,7 @@ void mrmailbox_lookup_real_nchat_by_contact_id__(mrmailbox_t* mailbox, uint32_t
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_create_or_lookup_nchat_by_contact_id__(mrmailbox_t* mailbox, uint32_t contact_id, int create_blocked, uint32_t* ret_chat_id, int* ret_chat_blocked)
|
||||
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)
|
||||
{
|
||||
uint32_t chat_id = 0;
|
||||
int chat_blocked = 0;
|
||||
|
@ -1694,7 +1694,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_unarchive_chat__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
void mrmailbox_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);
|
||||
|
@ -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__(mrmailbox_t* mailbox, dc_chat_t* chat, const dc_msg_t* msg, time_t timestamp)
|
||||
static uint32_t mrmailbox_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;
|
||||
|
@ -2082,7 +2082,7 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, dc_m
|
|||
}
|
||||
|
||||
msg->m_id = 0;
|
||||
msg->m_mailbox = mailbox;
|
||||
msg->m_context = mailbox;
|
||||
|
||||
if( msg->m_type == MR_MSG_TEXT )
|
||||
{
|
||||
|
@ -2118,7 +2118,7 @@ uint32_t mrmailbox_send_msg_object(dc_context_t* mailbox, uint32_t chat_id, dc_m
|
|||
&& (mrparam_get_int(msg->m_param, MRP_WIDTH, 0)<=0 || mrparam_get_int(msg->m_param, MRP_HEIGHT, 0)<=0) ) {
|
||||
/* set width/height of images, if not yet done */
|
||||
unsigned char* buf = NULL; size_t buf_bytes; uint32_t w, h;
|
||||
if( mr_read_file(pathNfilename, (void**)&buf, &buf_bytes, msg->m_mailbox) ) {
|
||||
if( mr_read_file(pathNfilename, (void**)&buf, &buf_bytes, msg->m_context) ) {
|
||||
if( mr_get_filemeta(buf, buf_bytes, &w, &h) ) {
|
||||
mrparam_set_int(msg->m_param, MRP_WIDTH, w);
|
||||
mrparam_set_int(msg->m_param, MRP_HEIGHT, h);
|
||||
|
@ -2506,7 +2506,7 @@ cleanup:
|
|||
/* similar to mrmailbox_add_device_msg() but without locking and without sending
|
||||
* an event.
|
||||
*/
|
||||
uint32_t mrmailbox_add_device_msg__(mrmailbox_t* mailbox, uint32_t chat_id, const char* text, time_t timestamp)
|
||||
uint32_t mrmailbox_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__(mrmailbox_t* mailbox, uint32_t chat_id, cons
|
|||
* 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(mrmailbox_t* mailbox, uint32_t chat_id, const char* text)
|
||||
uint32_t mrmailbox_add_device_msg(dc_context_t* mailbox, uint32_t chat_id, const char* text)
|
||||
{
|
||||
uint32_t msg_id = 0;
|
||||
int locked = 0;
|
||||
|
@ -2570,7 +2570,7 @@ cleanup:
|
|||
#define DO_SEND_STATUS_MAILS (mrparam_get_int(chat->m_param, MRP_UNPROMOTED, 0)==0)
|
||||
|
||||
|
||||
int mrmailbox_is_group_explicitly_left__(mrmailbox_t* mailbox, const char* grpid)
|
||||
int mrmailbox_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,7 +2578,7 @@ int mrmailbox_is_group_explicitly_left__(mrmailbox_t* mailbox, const char* grpid
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_set_group_explicitly_left__(mrmailbox_t* mailbox, const char* grpid)
|
||||
void mrmailbox_set_group_explicitly_left__(dc_context_t* mailbox, const char* grpid)
|
||||
{
|
||||
if( !mrmailbox_is_group_explicitly_left__(mailbox, grpid) )
|
||||
{
|
||||
|
@ -2590,7 +2590,7 @@ void mrmailbox_set_group_explicitly_left__(mrmailbox_t* mailbox, const char* grp
|
|||
}
|
||||
|
||||
|
||||
static int mrmailbox_real_group_exists__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
static int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t chat_id)
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_add_to_chat_contacts_table__(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id)
|
||||
int mrmailbox_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,
|
||||
|
@ -2853,7 +2853,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_get_chat_contact_count__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t chat_id)
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_is_contact_in_chat__(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id)
|
||||
int mrmailbox_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=?;");
|
||||
|
@ -2909,7 +2909,7 @@ int dc_is_contact_in_chat(dc_context_t* mailbox, uint32_t chat_id, uint32_t cont
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_add_contact_to_chat_ex(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t contact_id, int flags)
|
||||
int mrmailbox_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);
|
||||
|
@ -3123,7 +3123,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
int mrmailbox_real_contact_exists__(mrmailbox_t* mailbox, uint32_t contact_id)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t contact_id)
|
|||
}
|
||||
|
||||
|
||||
size_t mrmailbox_get_real_contact_cnt__(mrmailbox_t* mailbox)
|
||||
size_t mrmailbox_get_real_contact_cnt__(dc_context_t* mailbox)
|
||||
{
|
||||
sqlite3_stmt* stmt;
|
||||
|
||||
|
@ -3163,7 +3163,7 @@ size_t mrmailbox_get_real_contact_cnt__(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
uint32_t mrmailbox_add_or_lookup_contact__( mrmailbox_t* mailbox,
|
||||
uint32_t mrmailbox_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__(mrmailbox_t* mailbox, uint32_t contact_id, int origin)
|
||||
void mrmailbox_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__(mrmailbox_t* mailbox, uint32_t contact_i
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_is_contact_blocked__(mrmailbox_t* mailbox, uint32_t contact_id)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t contact_id)
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_get_contact_origin__(mrmailbox_t* mailbox, uint32_t contact_id, int* ret_blocked)
|
||||
int mrmailbox_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; }
|
||||
|
@ -3653,7 +3653,7 @@ dc_contact_t* dc_get_contact(dc_context_t* mailbox, uint32_t contact_id)
|
|||
}
|
||||
|
||||
|
||||
static void marknoticed_contact__(mrmailbox_t* mailbox, uint32_t contact_id)
|
||||
static void marknoticed_contact__(dc_context_t* mailbox, uint32_t contact_id)
|
||||
{
|
||||
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, UPDATE_msgs_SET_state_WHERE_from_id_AND_state,
|
||||
"UPDATE msgs SET state=" MR_STRINGIFY(MR_STATE_IN_NOTICED) " WHERE from_id=? AND state=" MR_STRINGIFY(MR_STATE_IN_FRESH) ";");
|
||||
|
@ -3688,7 +3688,7 @@ void dc_marknoticed_contact(dc_context_t* mailbox, uint32_t contact_id)
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_block_chat__(mrmailbox_t* mailbox, uint32_t chat_id, int new_blocking)
|
||||
void mrmailbox_block_chat__(dc_context_t* mailbox, uint32_t chat_id, int new_blocking)
|
||||
{
|
||||
sqlite3_stmt* stmt;
|
||||
|
||||
|
@ -3704,7 +3704,7 @@ void mrmailbox_block_chat__(mrmailbox_t* mailbox, uint32_t chat_id, int new_bloc
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_unblock_chat__(mrmailbox_t* mailbox, uint32_t chat_id)
|
||||
void mrmailbox_unblock_chat__(dc_context_t* mailbox, uint32_t chat_id)
|
||||
{
|
||||
mrmailbox_block_chat__(mailbox, chat_id, MR_CHAT_NOT_BLOCKED);
|
||||
}
|
||||
|
@ -3976,7 +3976,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_contact_addr_equals__(mrmailbox_t* mailbox, uint32_t contact_id, const char* other_addr)
|
||||
int mrmailbox_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__(mrmailbox_t* mailbox, uint32_t contact_id, c
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void mrmailbox_update_msg_chat_id__(mrmailbox_t* mailbox, uint32_t msg_id, uint32_t chat_id)
|
||||
void mrmailbox_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__(mrmailbox_t* mailbox, uint32_t msg_id, uint3
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_update_msg_state__(mrmailbox_t* mailbox, uint32_t msg_id, int state)
|
||||
void mrmailbox_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__(mrmailbox_t* mailbox, uint32_t msg_id, int sta
|
|||
}
|
||||
|
||||
|
||||
size_t mrmailbox_get_real_msg_cnt__(mrmailbox_t* mailbox)
|
||||
size_t mrmailbox_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__(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
size_t mrmailbox_get_deaddrop_msg_cnt__(mrmailbox_t* mailbox)
|
||||
size_t mrmailbox_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__(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_rfc724_mid_cnt__(mrmailbox_t* mailbox, const char* rfc724_mid)
|
||||
int mrmailbox_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__(mrmailbox_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__(mrmailbox_t* mailbox, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid)
|
||||
uint32_t mrmailbox_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__(mrmailbox_t* mailbox, const char* rfc724_
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_update_server_uid__(mrmailbox_t* mailbox, const char* rfc724_mid, const char* server_folder, uint32_t server_uid)
|
||||
void mrmailbox_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" */
|
||||
|
@ -4606,7 +4606,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_mdn_from_ext__(mrmailbox_t* mailbox, uint32_t from_id, const char* rfc724_mid, time_t timestamp_sent,
|
||||
int mrmailbox_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)
|
||||
{
|
||||
|
|
110
src/dc_context.h
110
src/dc_context.h
|
@ -63,10 +63,10 @@ struct _dc_context
|
|||
#define MR_MAILBOX_MAGIC 0x11a11807
|
||||
uint32_t m_magic; /**< @private */
|
||||
|
||||
void* m_userdata; /**< Use data, may be used for any purpose. The same pointer as given to mrmailbox_new(), may be used by the caller for any purpose. */
|
||||
void* m_userdata; /**< Use data, may be used for any purpose. The same pointer as given to dc_context_new(), may be used by the caller for any purpose. */
|
||||
|
||||
char* m_dbfile; /**< The database file. This is the file given to mrmailbox_new(). */
|
||||
char* m_blobdir; /**< Full path of the blob directory. This is the directory given to mrmailbox_new() or a directory in the same directory as mrmailbox_t::m_dbfile. */
|
||||
char* m_dbfile; /**< The database file. This is the file given to dc_context_new(). */
|
||||
char* m_blobdir; /**< Full path of the blob directory. This is the directory given to dc_context_new() or a directory in the same directory as dc_context_t::m_dbfile. */
|
||||
|
||||
dc_sqlite3_t* m_sql; /**< Internal SQL object, never NULL */
|
||||
|
||||
|
@ -111,46 +111,46 @@ void dc_log_info (dc_context_t*, int code, const char* msg,
|
|||
|
||||
|
||||
/* misc.*/
|
||||
void mrmailbox_receive_imf (mrmailbox_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 (mrmailbox_t*, uint32_t chat_id, dc_msg_t*);
|
||||
int mrmailbox_get_archived_count__ (mrmailbox_t*);
|
||||
size_t mrmailbox_get_real_contact_cnt__ (mrmailbox_t*);
|
||||
uint32_t mrmailbox_add_or_lookup_contact__ (mrmailbox_t*, const char* display_name /*can be NULL*/, const char* addr_spec, int origin, int* sth_modified);
|
||||
int mrmailbox_get_contact_origin__ (mrmailbox_t*, uint32_t id, int* ret_blocked);
|
||||
int mrmailbox_is_contact_blocked__ (mrmailbox_t*, uint32_t id);
|
||||
int mrmailbox_real_contact_exists__ (mrmailbox_t*, uint32_t id);
|
||||
int mrmailbox_contact_addr_equals__ (mrmailbox_t*, uint32_t contact_id, const char* other_addr);
|
||||
void mrmailbox_scaleup_contact_origin__ (mrmailbox_t*, uint32_t contact_id, int origin);
|
||||
void mrmailbox_unarchive_chat__ (mrmailbox_t*, uint32_t chat_id);
|
||||
size_t mrmailbox_get_chat_cnt__ (mrmailbox_t*);
|
||||
void mrmailbox_block_chat__ (mrmailbox_t*, uint32_t chat_id, int new_blocking);
|
||||
void mrmailbox_unblock_chat__ (mrmailbox_t*, uint32_t chat_id);
|
||||
void mrmailbox_create_or_lookup_nchat_by_contact_id__ (mrmailbox_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__ (mrmailbox_t*, uint32_t contact_id, uint32_t* ret_chat_id, int* ret_chat_blocked);
|
||||
int mrmailbox_get_total_msg_count__ (mrmailbox_t*, uint32_t chat_id);
|
||||
int mrmailbox_get_fresh_msg_count__ (mrmailbox_t*, uint32_t chat_id);
|
||||
uint32_t mrmailbox_get_last_deaddrop_fresh_msg__ (mrmailbox_t*);
|
||||
int mrmailbox_add_to_chat_contacts_table__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
|
||||
int mrmailbox_is_contact_in_chat__ (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id);
|
||||
int mrmailbox_get_chat_contact_count__ (mrmailbox_t*, uint32_t chat_id);
|
||||
int mrmailbox_is_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
|
||||
void mrmailbox_set_group_explicitly_left__ (mrmailbox_t*, const char* grpid);
|
||||
size_t mrmailbox_get_real_msg_cnt__ (mrmailbox_t*); /* the number of messages assigned to real chat (!=deaddrop, !=trash) */
|
||||
size_t mrmailbox_get_deaddrop_msg_cnt__ (mrmailbox_t*);
|
||||
int mrmailbox_rfc724_mid_cnt__ (mrmailbox_t*, const char* rfc724_mid);
|
||||
uint32_t mrmailbox_rfc724_mid_exists__ (mrmailbox_t*, const char* rfc724_mid, char** ret_server_folder, uint32_t* ret_server_uid);
|
||||
void mrmailbox_update_server_uid__ (mrmailbox_t*, const char* rfc724_mid, const char* server_folder, uint32_t server_uid);
|
||||
void mrmailbox_update_msg_chat_id__ (mrmailbox_t*, uint32_t msg_id, uint32_t chat_id);
|
||||
void mrmailbox_update_msg_state__ (mrmailbox_t*, uint32_t msg_id, int state);
|
||||
int mrmailbox_mdn_from_ext__ (mrmailbox_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 (mrmailbox_t*, uint32_t chat_id, const char* text);
|
||||
uint32_t mrmailbox_add_device_msg__ (mrmailbox_t*, uint32_t chat_id, const char* text, time_t timestamp);
|
||||
void mrmailbox_suspend_smtp_thread (mrmailbox_t*, int suspend);
|
||||
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);
|
||||
|
||||
#define MR_FROM_HANDSHAKE 0x01
|
||||
int mrmailbox_add_contact_to_chat_ex (mrmailbox_t*, uint32_t chat_id, uint32_t contact_id, int flags);
|
||||
int mrmailbox_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__ (mrmailbox_t*, const char* grpid, int* ret_blocked, int* ret_verified);
|
||||
uint32_t mrmailbox_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"
|
||||
|
@ -160,7 +160,7 @@ uint32_t mrmailbox_get_chat_id_by_grpid__ (mrmailbox_t*,
|
|||
#define MR_E2EE_DEFAULT_ENABLED 1
|
||||
#define MR_MDNS_DEFAULT_ENABLED 1
|
||||
|
||||
typedef struct mrmailbox_e2ee_helper_t {
|
||||
typedef struct dc_e2ee_helper_t {
|
||||
// encryption
|
||||
int m_encryption_successfull;
|
||||
void* m_cdata_to_free;
|
||||
|
@ -170,20 +170,20 @@ typedef struct mrmailbox_e2ee_helper_t {
|
|||
dc_hash_t* m_signatures; // fingerprints of valid signatures
|
||||
dc_hash_t* m_gossipped_addr;
|
||||
|
||||
} mrmailbox_e2ee_helper_t;
|
||||
} dc_e2ee_helper_t;
|
||||
|
||||
void mrmailbox_e2ee_encrypt (mrmailbox_t*, const clist* recipients_addr, int force_plaintext, int e2ee_guaranteed, int min_verified, struct mailmime* in_out_message, mrmailbox_e2ee_helper_t*);
|
||||
void mrmailbox_e2ee_decrypt (mrmailbox_t*, struct mailmime* in_out_message, mrmailbox_e2ee_helper_t*); /* returns 1 if sth. was decrypted, 0 in other cases */
|
||||
void mrmailbox_e2ee_thanks (mrmailbox_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 (mrmailbox_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 (mrmailbox_t*);
|
||||
char* mrmailbox_normalize_setup_code(mrmailbox_t*, const char* passphrase);
|
||||
char* mrmailbox_render_setup_file (mrmailbox_t*, const char* passphrase);
|
||||
char* mrmailbox_decrypt_setup_file(mrmailbox_t*, const char* passphrase, const char* filecontent);
|
||||
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);
|
||||
|
||||
extern int mr_shall_stop_ongoing;
|
||||
int mrmailbox_alloc_ongoing (mrmailbox_t*);
|
||||
void mrmailbox_free_ongoing (mrmailbox_t*);
|
||||
int mrmailbox_alloc_ongoing (dc_context_t*);
|
||||
void mrmailbox_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 (mrmailbox_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(mrmailbox_t*, dc_mimeparser_t*, uint32_t contact_id);
|
||||
void mrmailbox_handle_degrade_event (mrmailbox_t*, dc_apeerstate_t*);
|
||||
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*);
|
||||
|
||||
|
||||
#define OPENPGP4FPR_SCHEME "OPENPGP4FPR:" /* yes: uppercase */
|
||||
|
||||
|
||||
/* library private: key-history */
|
||||
void mrmailbox_add_to_keyhistory__(mrmailbox_t*, const char* rfc724_mid, time_t, const char* addr, const char* fingerprint);
|
||||
void mrmailbox_add_to_keyhistory__(dc_context_t*, const char* rfc724_mid, time_t, const char* addr, const char* fingerprint);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -191,7 +191,7 @@ static int contains_report(struct mailmime* mime)
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static int load_or_generate_self_public_key__(mrmailbox_t* mailbox, dc_key_t* public_key, const char* self_addr,
|
||||
static int load_or_generate_self_public_key__(dc_context_t* mailbox, dc_key_t* public_key, const char* self_addr,
|
||||
struct mailmime* random_data_mime /*for an extra-seed of the random generator. For speed reasons, only give _available_ pointers here, do not create any data - in very most cases, the key is not generated!*/)
|
||||
{
|
||||
static int s_in_key_creation = 0; /* avoid double creation (we unlock the database during creation) */
|
||||
|
@ -278,7 +278,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_ensure_secret_key_exists(mrmailbox_t* mailbox)
|
||||
int mrmailbox_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,11 +317,11 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void mrmailbox_e2ee_encrypt(mrmailbox_t* mailbox, const clist* recipients_addr,
|
||||
void mrmailbox_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,
|
||||
struct mailmime* in_out_message, mrmailbox_e2ee_helper_t* helper)
|
||||
struct mailmime* in_out_message, dc_e2ee_helper_t* helper)
|
||||
{
|
||||
int locked = 0, col = 0, do_encrypt = 0;
|
||||
dc_aheader_t* autocryptheader = dc_aheader_new();
|
||||
|
@ -333,7 +333,7 @@ void mrmailbox_e2ee_encrypt(mrmailbox_t* mailbox, const clist* recipients_addr,
|
|||
size_t ctext_bytes = 0;
|
||||
dc_array_t* peerstates = dc_array_new(NULL, 10);
|
||||
|
||||
if( helper ) { memset(helper, 0, sizeof(mrmailbox_e2ee_helper_t)); }
|
||||
if( helper ) { memset(helper, 0, sizeof(dc_e2ee_helper_t)); }
|
||||
|
||||
if( mailbox == NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || recipients_addr == NULL || in_out_message == NULL
|
||||
|| in_out_message->mm_parent /* libEtPan's pgp_encrypt_mime() takes the parent as the new root. We just expect the root as being given to this function. */
|
||||
|
@ -519,7 +519,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_e2ee_thanks(mrmailbox_e2ee_helper_t* helper)
|
||||
void mrmailbox_e2ee_thanks(dc_e2ee_helper_t* helper)
|
||||
{
|
||||
if( helper == NULL ) {
|
||||
return;
|
||||
|
@ -566,7 +566,7 @@ static int has_decrypted_pgp_armor(const char* str__, int str_bytes)
|
|||
}
|
||||
|
||||
|
||||
static int decrypt_part(mrmailbox_t* mailbox,
|
||||
static int decrypt_part(dc_context_t* mailbox,
|
||||
struct mailmime* mime,
|
||||
const dc_keyring_t* private_keyring,
|
||||
const dc_keyring_t* public_keyring_for_validate, /*may be NULL*/
|
||||
|
@ -670,7 +670,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static int decrypt_recursive(mrmailbox_t* mailbox,
|
||||
static int decrypt_recursive(dc_context_t* mailbox,
|
||||
struct mailmime* mime,
|
||||
const dc_keyring_t* private_keyring,
|
||||
const dc_keyring_t* public_keyring_for_validate,
|
||||
|
@ -738,7 +738,7 @@ static int decrypt_recursive(mrmailbox_t* mailbox,
|
|||
}
|
||||
|
||||
|
||||
static dc_hash_t* update_gossip_peerstates(mrmailbox_t* mailbox, time_t message_time, struct mailimf_fields* imffields, const struct mailimf_fields* gossip_headers)
|
||||
static dc_hash_t* update_gossip_peerstates(dc_context_t* mailbox, time_t message_time, struct mailimf_fields* imffields, const struct mailimf_fields* gossip_headers)
|
||||
{
|
||||
clistiter* cur1;
|
||||
dc_hash_t* recipients = NULL;
|
||||
|
@ -809,8 +809,8 @@ static dc_hash_t* update_gossip_peerstates(mrmailbox_t* mailbox, time_t message_
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_e2ee_decrypt(mrmailbox_t* mailbox, struct mailmime* in_out_message,
|
||||
mrmailbox_e2ee_helper_t* helper)
|
||||
void mrmailbox_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
|
||||
(to detect parts that could not be decrypted, simply look for left "multipart/encrypted" MIME types */
|
||||
|
@ -824,7 +824,7 @@ void mrmailbox_e2ee_decrypt(mrmailbox_t* mailbox, struct mailmime* in_out_messag
|
|||
dc_keyring_t* public_keyring_for_validate = dc_keyring_new();
|
||||
struct mailimf_fields* gossip_headers = NULL;
|
||||
|
||||
if( helper ) { memset(helper, 0, sizeof(mrmailbox_e2ee_helper_t)); }
|
||||
if( helper ) { memset(helper, 0, sizeof(dc_e2ee_helper_t)); }
|
||||
|
||||
if( mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC || in_out_message==NULL
|
||||
|| helper == NULL || imffields==NULL ) {
|
||||
|
|
148
src/dc_imap.c
148
src/dc_imap.c
|
@ -52,7 +52,7 @@ static int is_error(dc_imap_t* ths, int code)
|
|||
if( code == MAILIMAP_ERROR_STREAM /*4*/
|
||||
|| code == MAILIMAP_ERROR_PARSE /*5*/ )
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP stream lost; we'll reconnect soon.");
|
||||
dc_log_info(ths->m_context, 0, "IMAP stream lost; we'll reconnect soon.");
|
||||
ths->m_should_reconnect = 1;
|
||||
}
|
||||
|
||||
|
@ -221,12 +221,12 @@ static clist* list_folders__(dc_imap_t* ths)
|
|||
|
||||
if( is_error(ths, r) || imap_list==NULL ) {
|
||||
imap_list = NULL;
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot get folder list.");
|
||||
dc_log_warning(ths->m_context, 0, "Cannot get folder list.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( clist_count(imap_list)<=0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Folder list is empty.");
|
||||
dc_log_warning(ths->m_context, 0, "Folder list is empty.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -337,23 +337,23 @@ static int init_chat_folders__(dc_imap_t* ths)
|
|||
}
|
||||
|
||||
if( chats_folder == NULL && (ths->m_server_flags&MR_NO_MOVE_TO_CHATS)==0 ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Creating IMAP-folder \"%s\"...", MR_CHATS_FOLDER);
|
||||
dc_log_info(ths->m_context, 0, "Creating IMAP-folder \"%s\"...", MR_CHATS_FOLDER);
|
||||
int r = mailimap_create(ths->m_hEtpan, MR_CHATS_FOLDER);
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using trying INBOX subfolder.");
|
||||
dc_log_warning(ths->m_context, 0, "Cannot create IMAP-folder, using trying INBOX subfolder.");
|
||||
r = mailimap_create(ths->m_hEtpan, fallback_folder);
|
||||
if( is_error(ths, r) ) {
|
||||
/* continue on errors, we'll just use a different folder then */
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot create IMAP-folder, using default.");
|
||||
dc_log_warning(ths->m_context, 0, "Cannot create IMAP-folder, using default.");
|
||||
}
|
||||
else {
|
||||
chats_folder = safe_strdup(fallback_folder);
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-folder created (inbox subfolder).");
|
||||
dc_log_info(ths->m_context, 0, "IMAP-folder created (inbox subfolder).");
|
||||
}
|
||||
}
|
||||
else {
|
||||
chats_folder = safe_strdup(MR_CHATS_FOLDER);
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-folder created.");
|
||||
dc_log_info(ths->m_context, 0, "IMAP-folder created.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,7 @@ static int select_folder__(dc_imap_t* ths, const char* folder /*may be NULL*/)
|
|||
/* deselect existing folder, if needed (it's also done implicitly by SELECT, however, without EXPUNGE then) */
|
||||
if( ths->m_selected_folder_needs_expunge ) {
|
||||
if( ths->m_selected_folder[0] ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Expunge messages in \"%s\".", ths->m_selected_folder);
|
||||
dc_log_info(ths->m_context, 0, "Expunge messages in \"%s\".", ths->m_selected_folder);
|
||||
mailimap_close(ths->m_hEtpan); /* a CLOSE-SELECT is considerably faster than an EXPUNGE-SELECT, see https://tools.ietf.org/html/rfc3501#section-6.4.2 */
|
||||
}
|
||||
ths->m_selected_folder_needs_expunge = 0;
|
||||
|
@ -657,7 +657,7 @@ static int fetch_single_msg(dc_imap_t* ths, const char* folder, uint32_t server_
|
|||
|
||||
if( is_error(ths, r) || fetch_result == NULL ) {
|
||||
fetch_result = NULL;
|
||||
dc_log_warning(ths->m_mailbox, 0, "Error #%i on fetching message #%i from folder \"%s\"; retry=%i.", (int)r, (int)server_uid, folder, (int)ths->m_should_reconnect);
|
||||
dc_log_warning(ths->m_context, 0, "Error #%i on fetching message #%i from folder \"%s\"; retry=%i.", (int)r, (int)server_uid, folder, (int)ths->m_should_reconnect);
|
||||
if( ths->m_should_reconnect ) {
|
||||
retry_later = 1; /* maybe we should also retry on other errors, however, we should check this carefully, as this may result in a dead lock! */
|
||||
}
|
||||
|
@ -665,14 +665,14 @@ static int fetch_single_msg(dc_imap_t* ths, const char* folder, uint32_t server_
|
|||
}
|
||||
|
||||
if( (cur=clist_begin(fetch_result)) == NULL ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Message #%i does not exist in folder \"%s\".", (int)server_uid, folder);
|
||||
dc_log_warning(ths->m_context, 0, "Message #%i does not exist in folder \"%s\".", (int)server_uid, folder);
|
||||
goto cleanup; /* server response is fine, however, there is no such message, do not try to fetch the message again */
|
||||
}
|
||||
|
||||
struct mailimap_msg_att* msg_att = (struct mailimap_msg_att*)clist_content(cur);
|
||||
peek_body(msg_att, &msg_content, &msg_bytes, &flags, &deleted);
|
||||
if( msg_content == NULL || msg_bytes <= 0 || deleted ) {
|
||||
/* dc_log_warning(ths->m_mailbox, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */
|
||||
/* dc_log_warning(ths->m_context, 0, "Message #%i in folder \"%s\" is empty or deleted.", (int)server_uid, folder); -- this is a quite usual situation, do not print a warning */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -702,12 +702,12 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
}
|
||||
|
||||
if( ths->m_hEtpan==NULL ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Cannot fetch from \"%s\" - not connected.", folder);
|
||||
dc_log_info(ths->m_context, 0, "Cannot fetch from \"%s\" - not connected.", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( select_folder__(ths, folder)==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder);
|
||||
dc_log_warning(ths->m_context, 0, "Cannot select folder \"%s\".", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -717,13 +717,13 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
{
|
||||
/* first time this folder is selected or UIDVALIDITY has changed, init lastseenuid and save it to config */
|
||||
if( ths->m_hEtpan->imap_selection_info->sel_uidvalidity <= 0 ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "Cannot get UIDVALIDITY for folder \"%s\".", folder);
|
||||
dc_log_error(ths->m_context, 0, "Cannot get UIDVALIDITY for folder \"%s\".", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( ths->m_hEtpan->imap_selection_info->sel_has_exists ) {
|
||||
if( ths->m_hEtpan->imap_selection_info->sel_exists <= 0 ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty.", folder);
|
||||
dc_log_info(ths->m_context, 0, "Folder \"%s\" is empty.", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
/* `FETCH <message sequence number> (UID)` */
|
||||
|
@ -732,14 +732,14 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
else {
|
||||
/* `FETCH * (UID)` - according to RFC 3501, `*` represents the largest message sequence number; if the mailbox is empty,
|
||||
an error resp. an empty list is returned. */
|
||||
dc_log_info(ths->m_mailbox, 0, "EXISTS is missing for folder \"%s\", using fallback.", folder);
|
||||
dc_log_info(ths->m_context, 0, "EXISTS is missing for folder \"%s\", using fallback.", folder);
|
||||
set = mailimap_set_new_single(0);
|
||||
}
|
||||
r = mailimap_fetch(ths->m_hEtpan, set, ths->m_fetch_type_uid, &fetch_result);
|
||||
mailimap_set_free(set);
|
||||
|
||||
if( is_error(ths, r) || fetch_result==NULL || (cur=clist_begin(fetch_result))==NULL ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Empty result returned for folder \"%s\".", folder);
|
||||
dc_log_info(ths->m_context, 0, "Empty result returned for folder \"%s\".", folder);
|
||||
goto cleanup; /* this might happen if the mailbox is empty an EXISTS does not work */
|
||||
}
|
||||
|
||||
|
@ -748,7 +748,7 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
mailimap_fetch_list_free(fetch_result);
|
||||
fetch_result = NULL;
|
||||
if( lastseenuid <= 0 ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "Cannot get largest UID for folder \"%s\"", folder);
|
||||
dc_log_error(ths->m_context, 0, "Cannot get largest UID for folder \"%s\"", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -771,10 +771,10 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
{
|
||||
fetch_result = NULL;
|
||||
if( r == MAILIMAP_ERROR_PROTOCOL ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Folder \"%s\" is empty", folder);
|
||||
dc_log_info(ths->m_context, 0, "Folder \"%s\" is empty", folder);
|
||||
goto cleanup; /* the folder is simply empty, this is no error */
|
||||
}
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot fetch message list from folder \"%s\".", folder);
|
||||
dc_log_warning(ths->m_context, 0, "Cannot fetch message list from folder \"%s\".", folder);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -805,10 +805,10 @@ static int fetch_from_single_folder(dc_imap_t* ths, const char* folder)
|
|||
cleanup:
|
||||
|
||||
if( read_errors ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "%i mails read from \"%s\" with %i errors.", (int)read_cnt, folder, (int)read_errors);
|
||||
dc_log_warning(ths->m_context, 0, "%i mails read from \"%s\" with %i errors.", (int)read_cnt, folder, (int)read_errors);
|
||||
}
|
||||
else {
|
||||
dc_log_info(ths->m_mailbox, 0, "%i mails read from \"%s\".", (int)read_cnt, folder);
|
||||
dc_log_info(ths->m_context, 0, "%i mails read from \"%s\".", (int)read_cnt, folder);
|
||||
}
|
||||
|
||||
if( fetch_result ) {
|
||||
|
@ -841,7 +841,7 @@ static int fetch_from_all_folders(dc_imap_t* ths)
|
|||
{
|
||||
mrimapfolder_t* folder = (mrimapfolder_t*)clist_content(cur);
|
||||
if( folder->m_meaning == MEANING_IGNORE ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Ignoring \"%s\".", folder->m_name_utf8);
|
||||
dc_log_info(ths->m_context, 0, "Ignoring \"%s\".", folder->m_name_utf8);
|
||||
}
|
||||
else if( folder->m_meaning != MEANING_INBOX ) {
|
||||
total_cnt += fetch_from_single_folder(ths, folder->m_name_to_select);
|
||||
|
@ -892,7 +892,7 @@ static void fake_idle(dc_imap_t* imap)
|
|||
|
||||
time_t fake_idle_start_time = time(NULL), seconds_to_wait;
|
||||
|
||||
dc_log_info(imap->m_mailbox, 0, "IMAP-fake-IDLEing...");
|
||||
dc_log_info(imap->m_context, 0, "IMAP-fake-IDLEing...");
|
||||
|
||||
int do_fake_idle = 1;
|
||||
while( do_fake_idle )
|
||||
|
@ -948,7 +948,7 @@ void dc_imap_idle(dc_imap_t* imap)
|
|||
if( imap->m_idle_set_up==0 && imap->m_hEtpan && imap->m_hEtpan->imap_stream ) {
|
||||
r = mailstream_setup_idle(imap->m_hEtpan->imap_stream);
|
||||
if( is_error(imap, r) ) {
|
||||
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot setup.");
|
||||
dc_log_warning(imap->m_context, 0, "IMAP-IDLE: Cannot setup.");
|
||||
fake_idle(imap);
|
||||
return;
|
||||
}
|
||||
|
@ -956,14 +956,14 @@ void dc_imap_idle(dc_imap_t* imap)
|
|||
}
|
||||
|
||||
if( !imap->m_idle_set_up || !select_folder__(imap, "INBOX") ) {
|
||||
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE not setup.");
|
||||
dc_log_warning(imap->m_context, 0, "IMAP-IDLE not setup.");
|
||||
fake_idle(imap);
|
||||
return;
|
||||
}
|
||||
|
||||
r = mailimap_idle(imap->m_hEtpan);
|
||||
if( is_error(imap, r) ) {
|
||||
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE: Cannot start.");
|
||||
dc_log_warning(imap->m_context, 0, "IMAP-IDLE: Cannot start.");
|
||||
fake_idle(imap);
|
||||
return;
|
||||
}
|
||||
|
@ -977,20 +977,20 @@ void dc_imap_idle(dc_imap_t* imap)
|
|||
r2 = mailimap_idle_done(imap->m_hEtpan);
|
||||
|
||||
if( r == MAILSTREAM_IDLE_ERROR /*0*/ || r==MAILSTREAM_IDLE_CANCELLED /*4*/ ) {
|
||||
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE wait cancelled, r=%i, r2=%i; we'll reconnect soon.", r, r2);
|
||||
dc_log_info(imap->m_context, 0, "IMAP-IDLE wait cancelled, r=%i, r2=%i; we'll reconnect soon.", r, r2);
|
||||
imap->m_should_reconnect = 1;
|
||||
}
|
||||
else if( r == MAILSTREAM_IDLE_INTERRUPTED /*1*/ ) {
|
||||
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE interrupted.");
|
||||
dc_log_info(imap->m_context, 0, "IMAP-IDLE interrupted.");
|
||||
}
|
||||
else if( r == MAILSTREAM_IDLE_HASDATA /*2*/ ) {
|
||||
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE has data.");
|
||||
dc_log_info(imap->m_context, 0, "IMAP-IDLE has data.");
|
||||
}
|
||||
else if( r == MAILSTREAM_IDLE_TIMEOUT /*3*/ ) {
|
||||
dc_log_info(imap->m_mailbox, 0, "IMAP-IDLE timeout.");
|
||||
dc_log_info(imap->m_context, 0, "IMAP-IDLE timeout.");
|
||||
}
|
||||
else {
|
||||
dc_log_warning(imap->m_mailbox, 0, "IMAP-IDLE returns unknown value r=%i, r2=%i.", r, r2);
|
||||
dc_log_warning(imap->m_context, 0, "IMAP-IDLE returns unknown value r=%i, r2=%i.", r, r2);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -1003,7 +1003,7 @@ void dc_imap_idle(dc_imap_t* imap)
|
|||
void dc_imap_interrupt_idle(dc_imap_t* ths)
|
||||
{
|
||||
if( ths==NULL ) { // ths->m_hEtPan may be NULL
|
||||
dc_log_warning(ths->m_mailbox, 0, "Interrupt IMAP-IDLE: Bad parameter.");
|
||||
dc_log_warning(ths->m_context, 0, "Interrupt IMAP-IDLE: Bad parameter.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1044,8 +1044,8 @@ static int setup_handle_if_needed__(dc_imap_t* ths)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if( ths->m_mailbox->m_cb(ths->m_mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, DC_ERROR_NO_NETWORK, NULL);
|
||||
if( ths->m_context->m_cb(ths->m_context, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, DC_ERROR_NO_NETWORK, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1057,7 @@ static int setup_handle_if_needed__(dc_imap_t* ths)
|
|||
{
|
||||
r = mailimap_socket_connect(ths->m_hEtpan, ths->m_imap_server, ths->m_imap_port);
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Could not connect to IMAP-server %s:%i. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -1065,24 +1065,24 @@ static int setup_handle_if_needed__(dc_imap_t* ths)
|
|||
{
|
||||
r = mailimap_socket_starttls(ths->m_hEtpan);
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using STARTTLS. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Could not connect to IMAP-server %s:%i using STARTTLS. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
goto cleanup;
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i STARTTLS-connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
dc_log_info(ths->m_context, 0, "IMAP-server %s:%i STARTTLS-connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
dc_log_info(ths->m_context, 0, "IMAP-server %s:%i connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
r = mailimap_ssl_connect(ths->m_hEtpan, ths->m_imap_server, ths->m_imap_port);
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not connect to IMAP-server %s:%i using SSL. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Could not connect to IMAP-server %s:%i using SSL. (Error #%i)", ths->m_imap_server, (int)ths->m_imap_port, (int)r);
|
||||
goto cleanup;
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-server %s:%i SSL-connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
dc_log_info(ths->m_context, 0, "IMAP-server %s:%i SSL-connected.", ths->m_imap_server, (int)ths->m_imap_port);
|
||||
}
|
||||
|
||||
/* TODO: There are more authorisation types, see mailcore2/MCIMAPSession.cpp, however, I'm not sure of they are really all needed */
|
||||
|
@ -1104,11 +1104,11 @@ static int setup_handle_if_needed__(dc_imap_t* ths)
|
|||
}
|
||||
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Could not login as %s: %s (Error #%i)", ths->m_imap_user, ths->m_hEtpan->imap_response? ths->m_hEtpan->imap_response : "Unknown error.", (int)r);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Could not login as %s: %s (Error #%i)", ths->m_imap_user, ths->m_hEtpan->imap_response? ths->m_hEtpan->imap_response : "Unknown error.", (int)r);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-login as %s ok.", ths->m_imap_user);
|
||||
dc_log_info(ths->m_context, 0, "IMAP-login as %s ok.", ths->m_imap_user);
|
||||
|
||||
success = 1;
|
||||
|
||||
|
@ -1143,7 +1143,7 @@ static void unsetup_handle__(dc_imap_t* ths)
|
|||
mailimap_free(ths->m_hEtpan);
|
||||
ths->m_hEtpan = NULL;
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP disconnected.");
|
||||
dc_log_info(ths->m_context, 0, "IMAP disconnected.");
|
||||
}
|
||||
|
||||
ths->m_selected_folder[0] = 0;
|
||||
|
@ -1232,7 +1232,7 @@ int dc_imap_connect(dc_imap_t* ths, const dc_loginparam_t* lp)
|
|||
}
|
||||
}
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, "IMAP-capabilities:%s", capinfostr.m_buf);
|
||||
dc_log_info(ths->m_context, 0, "IMAP-capabilities:%s", capinfostr.m_buf);
|
||||
free(capinfostr.m_buf);
|
||||
}
|
||||
|
||||
|
@ -1274,7 +1274,7 @@ int dc_imap_is_connected(dc_imap_t* ths)
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
dc_imap_t* dc_imap_new(mr_get_config_t get_config, mr_set_config_t set_config, mr_receive_imf_t receive_imf, void* userData, mrmailbox_t* mailbox)
|
||||
dc_imap_t* dc_imap_new(mr_get_config_t get_config, mr_set_config_t set_config, mr_receive_imf_t receive_imf, void* userData, dc_context_t* mailbox)
|
||||
{
|
||||
dc_imap_t* ths = NULL;
|
||||
|
||||
|
@ -1284,7 +1284,7 @@ dc_imap_t* dc_imap_new(mr_get_config_t get_config, mr_set_config_t set_config, m
|
|||
|
||||
ths->m_log_connect_errors = 1;
|
||||
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
ths->m_get_config = get_config;
|
||||
ths->m_set_config = set_config;
|
||||
ths->m_receive_imf = receive_imf;
|
||||
|
@ -1363,15 +1363,15 @@ int dc_imap_append_msg(dc_imap_t* ths, time_t timestamp, const char* data_not_te
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Appending message to IMAP-server...");
|
||||
dc_log_info(ths->m_context, 0, "Appending message to IMAP-server...");
|
||||
|
||||
if( !init_chat_folders__(ths) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot find out IMAP-sent-folder.");
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Cannot find out IMAP-sent-folder.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( !select_folder__(ths, ths->m_sent_folder) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot select IMAP-folder \"%s\".", ths->m_sent_folder);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Cannot select IMAP-folder \"%s\".", ths->m_sent_folder);
|
||||
ths->m_sent_folder[0] = 0; /* force re-init */
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -1381,19 +1381,19 @@ int dc_imap_append_msg(dc_imap_t* ths, time_t timestamp, const char* data_not_te
|
|||
|
||||
imap_date = mr_timestamp_to_mailimap_date_time(timestamp);
|
||||
if( imap_date == NULL ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "Bad date.");
|
||||
dc_log_error(ths->m_context, 0, "Bad date.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
r = mailimap_uidplus_append(ths->m_hEtpan, ths->m_sent_folder, flag_list, imap_date, data_not_terminated, data_bytes, &ret_uidvalidity, ret_server_uid);
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "Cannot append message to \"%s\", error #%i.", ths->m_sent_folder, (int)r);
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "Cannot append message to \"%s\", error #%i.", ths->m_sent_folder, (int)r);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
*ret_server_folder = safe_strdup(ths->m_sent_folder);
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Message appended to \"%s\".", ths->m_sent_folder);
|
||||
dc_log_info(ths->m_context, 0, "Message appended to \"%s\".", ths->m_sent_folder);
|
||||
|
||||
success = 1;
|
||||
|
||||
|
@ -1464,19 +1464,19 @@ int dc_imap_markseen_msg(dc_imap_t* ths, const char* folder, uint32_t server_uid
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Marking message %s/%i as seen...", folder, (int)server_uid);
|
||||
dc_log_info(ths->m_context, 0, "Marking message %s/%i as seen...", folder, (int)server_uid);
|
||||
|
||||
if( select_folder__(ths, folder)==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder.");
|
||||
dc_log_warning(ths->m_context, 0, "Cannot select folder.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( add_flag__(ths, server_uid, mailimap_flag_new_seen())==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as seen.");
|
||||
dc_log_warning(ths->m_context, 0, "Cannot mark message as seen.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Message marked as seen.");
|
||||
dc_log_info(ths->m_context, 0, "Message marked as seen.");
|
||||
|
||||
if( (ms_flags&MR_MS_SET_MDNSent_FLAG)
|
||||
&& ths->m_hEtpan->imap_selection_info!=NULL && ths->m_hEtpan->imap_selection_info->sel_perm_flags!=NULL )
|
||||
|
@ -1517,12 +1517,12 @@ int dc_imap_markseen_msg(dc_imap_t* ths, const char* folder, uint32_t server_uid
|
|||
}
|
||||
mailimap_fetch_list_free(fetch_result);
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, ((*ret_ms_flags)&MR_MS_MDNSent_JUST_SET)? "$MDNSent just set and MDN will be sent." : "$MDNSent already set and MDN already sent.");
|
||||
dc_log_info(ths->m_context, 0, ((*ret_ms_flags)&MR_MS_MDNSent_JUST_SET)? "$MDNSent just set and MDN will be sent." : "$MDNSent already set and MDN already sent.");
|
||||
}
|
||||
else
|
||||
{
|
||||
*ret_ms_flags |= MR_MS_MDNSent_JUST_SET;
|
||||
dc_log_info(ths->m_mailbox, 0, "Cannot store $MDNSent flags, risk sending duplicate MDN.");
|
||||
dc_log_info(ths->m_context, 0, "Cannot store $MDNSent flags, risk sending duplicate MDN.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1531,13 +1531,13 @@ int dc_imap_markseen_msg(dc_imap_t* ths, const char* folder, uint32_t server_uid
|
|||
init_chat_folders__(ths);
|
||||
if( ths->m_moveto_folder && strcmp(folder, ths->m_moveto_folder)==0 )
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "Message %s/%i is already in %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
dc_log_info(ths->m_context, 0, "Message %s/%i is already in %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
/* avoid deadlocks as moving messages in the same folder may be result in a new server_uid and the state "fresh" -
|
||||
we will catch these messages again on the next poll, try to move them away and so on, see also (***) in mrmailbox.c */
|
||||
}
|
||||
else if( ths->m_moveto_folder )
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "Moving message %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
dc_log_info(ths->m_context, 0, "Moving message %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
|
||||
/* TODO/TOCHECK: MOVE may not be supported on servers, if this is often the case, we should fallback to a COPY/DELETE implementation.
|
||||
Same for the UIDPLUS extension (if in doubt, we can find out the resulting UID using "imap_selection_info->sel_uidnext" then). */
|
||||
|
@ -1546,16 +1546,16 @@ int dc_imap_markseen_msg(dc_imap_t* ths, const char* folder, uint32_t server_uid
|
|||
struct mailimap_set* res_setdest = NULL;
|
||||
r = mailimap_uidplus_uid_move(ths->m_hEtpan, set, ths->m_moveto_folder, &res_uid, &res_setsrc, &res_setdest); /* the correct folder is already selected in add_flag__() above */
|
||||
if( is_error(ths, r) ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Cannot move message, fallback to COPY/DELETE %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
dc_log_info(ths->m_context, 0, "Cannot move message, fallback to COPY/DELETE %s/%i to %s...", folder, (int)server_uid, ths->m_moveto_folder);
|
||||
r = mailimap_uidplus_uid_copy(ths->m_hEtpan, set, ths->m_moveto_folder, &res_uid, &res_setsrc, &res_setdest);
|
||||
if (is_error(ths, r)) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Cannot copy message. Leaving in INBOX");
|
||||
dc_log_info(ths->m_context, 0, "Cannot copy message. Leaving in INBOX");
|
||||
goto cleanup;
|
||||
}
|
||||
else {
|
||||
dc_log_info(ths->m_mailbox, 0, "Deleting msg ...");
|
||||
dc_log_info(ths->m_context, 0, "Deleting msg ...");
|
||||
if( add_flag__(ths, server_uid, mailimap_flag_new_deleted())==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\".");/* maybe the message is already deleted */
|
||||
dc_log_warning(ths->m_context, 0, "Cannot mark message as \"Deleted\".");/* maybe the message is already deleted */
|
||||
}
|
||||
|
||||
/* force an EXPUNGE resp. CLOSE for the selected folder */
|
||||
|
@ -1582,7 +1582,7 @@ int dc_imap_markseen_msg(dc_imap_t* ths, const char* folder, uint32_t server_uid
|
|||
// TODO: If the new UID is equal to lastuid.Chats, we should increase lastuid.Chats by one
|
||||
// (otherwise, we'll download the mail in moment again from the chats folder ...)
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Message moved.");
|
||||
dc_log_info(ths->m_context, 0, "Message moved.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1606,10 +1606,10 @@ int dc_imap_delete_msg(dc_imap_t* ths, const char* rfc724_mid, const char* folde
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Marking message \"%s\", %s/%i for deletion...", rfc724_mid, folder, (int)server_uid);
|
||||
dc_log_info(ths->m_context, 0, "Marking message \"%s\", %s/%i for deletion...", rfc724_mid, folder, (int)server_uid);
|
||||
|
||||
if( select_folder__(ths, folder)==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot select folder \"%s\".", folder); /* maybe the folder does no longer exist */
|
||||
dc_log_warning(ths->m_context, 0, "Cannot select folder \"%s\".", folder); /* maybe the folder does no longer exist */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -1630,7 +1630,7 @@ int dc_imap_delete_msg(dc_imap_t* ths, const char* rfc724_mid, const char* folde
|
|||
|| (is_rfc724_mid=unquote_rfc724_mid(is_quoted_rfc724_mid))==NULL
|
||||
|| strcmp(is_rfc724_mid, rfc724_mid)!=0 )
|
||||
{
|
||||
dc_log_warning(ths->m_mailbox, 0, "UID not found in the given folder or does not match Message-ID.");
|
||||
dc_log_warning(ths->m_context, 0, "UID not found in the given folder or does not match Message-ID.");
|
||||
server_uid = 0;
|
||||
}
|
||||
}
|
||||
|
@ -1638,18 +1638,18 @@ int dc_imap_delete_msg(dc_imap_t* ths, const char* rfc724_mid, const char* folde
|
|||
/* server_uid is 0 now if it was not given or if it does not match the given message id;
|
||||
try to search for it in all folders (the message may be moved by another MUA to a folder we do not sync or the sync is a moment ago) */
|
||||
if( server_uid == 0 ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Searching UID by Message-ID \"%s\"...", rfc724_mid);
|
||||
dc_log_info(ths->m_context, 0, "Searching UID by Message-ID \"%s\"...", rfc724_mid);
|
||||
if( (server_uid=search_uid__(ths, rfc724_mid))==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Message-ID \"%s\" not found in any folder, cannot delete message.", rfc724_mid);
|
||||
dc_log_warning(ths->m_context, 0, "Message-ID \"%s\" not found in any folder, cannot delete message.", rfc724_mid);
|
||||
goto cleanup;
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, "Message-ID \"%s\" found in %s/%i", rfc724_mid, ths->m_selected_folder, server_uid);
|
||||
dc_log_info(ths->m_context, 0, "Message-ID \"%s\" found in %s/%i", rfc724_mid, ths->m_selected_folder, server_uid);
|
||||
}
|
||||
|
||||
|
||||
/* mark the message for deletion */
|
||||
if( add_flag__(ths, server_uid, mailimap_flag_new_deleted())==0 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot mark message as \"Deleted\"."); /* maybe the message is already deleted */
|
||||
dc_log_warning(ths->m_context, 0, "Cannot mark message as \"Deleted\"."); /* maybe the message is already deleted */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
|
||||
/* Purpose: Reading from IMAP servers with no dependencies to the database.
|
||||
mrmailbox_t is only used for logging and to get information about
|
||||
dc_context_t is only used for logging and to get information about
|
||||
the online state. */
|
||||
|
||||
|
||||
|
@ -86,7 +86,7 @@ typedef struct dc_imap_t
|
|||
mr_set_config_t m_set_config;
|
||||
mr_receive_imf_t m_receive_imf;
|
||||
void* m_userData;
|
||||
mrmailbox_t* m_mailbox;
|
||||
dc_context_t* m_context;
|
||||
|
||||
int m_log_connect_errors;
|
||||
int m_skip_log_capabilities;
|
||||
|
@ -94,7 +94,7 @@ typedef struct dc_imap_t
|
|||
} dc_imap_t;
|
||||
|
||||
|
||||
dc_imap_t* dc_imap_new (mr_get_config_t, mr_set_config_t, mr_receive_imf_t, void* userData, mrmailbox_t*);
|
||||
dc_imap_t* dc_imap_new (mr_get_config_t, mr_set_config_t, mr_receive_imf_t, void* userData, dc_context_t*);
|
||||
void dc_imap_unref (dc_imap_t*);
|
||||
|
||||
int dc_imap_connect (dc_imap_t*, const dc_loginparam_t*);
|
||||
|
|
|
@ -361,7 +361,7 @@ cleanup:
|
|||
*
|
||||
* @private @memberof dc_context_t
|
||||
*
|
||||
* @param mailbox Mailbox object as created by mrmailbox_new().
|
||||
* @param mailbox Mailbox object as created by dc_context_new().
|
||||
*
|
||||
* @return Setup code, must be free()'d after usage. NULL on errors.
|
||||
*/
|
||||
|
@ -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(mrmailbox_t* mailbox, const char* in)
|
||||
char* mrmailbox_normalize_setup_code(dc_context_t* mailbox, const char* in)
|
||||
{
|
||||
if( in == NULL ) {
|
||||
return NULL;
|
||||
|
@ -553,7 +553,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static int set_self_key(mrmailbox_t* mailbox, const char* armored, int set_default)
|
||||
static int set_self_key(dc_context_t* mailbox, const char* armored, int set_default)
|
||||
{
|
||||
int success = 0;
|
||||
int locked = 0;
|
||||
|
@ -667,7 +667,7 @@ int dc_continue_key_transfer(dc_context_t* mailbox, uint32_t msg_id, const char*
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if( !mr_read_file(filename, (void**)&filecontent, &filebytes, msg->m_mailbox) || filecontent == NULL || filebytes <= 0 ) {
|
||||
if( !mr_read_file(filename, (void**)&filecontent, &filebytes, msg->m_context) || filecontent == NULL || filebytes <= 0 ) {
|
||||
dc_log_error(mailbox, 0, "Cannot read Autocrypt Setup Message file.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -703,7 +703,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static void export_key_to_asc_file(mrmailbox_t* mailbox, const char* dir, int id, const dc_key_t* key, int is_default)
|
||||
static void export_key_to_asc_file(dc_context_t* mailbox, const char* dir, int id, const dc_key_t* key, int is_default)
|
||||
{
|
||||
char* file_name;
|
||||
if( is_default ) {
|
||||
|
@ -722,7 +722,7 @@ static void export_key_to_asc_file(mrmailbox_t* mailbox, const char* dir, int id
|
|||
}
|
||||
|
||||
|
||||
static int export_self_keys(mrmailbox_t* mailbox, const char* dir)
|
||||
static int export_self_keys(dc_context_t* mailbox, const char* dir)
|
||||
{
|
||||
int success = 0;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
@ -763,7 +763,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static int import_self_keys(mrmailbox_t* mailbox, const char* dir_name)
|
||||
static int import_self_keys(dc_context_t* mailbox, const char* dir_name)
|
||||
{
|
||||
/* hint: even if we switch to import Autocrypt Setup Files, we should leave the possibility to import
|
||||
plain ASC keys, at least keys without a password, if we do not want to implement a password entry function.
|
||||
|
@ -868,7 +868,7 @@ The macro avoids weird values of 0% or 100% while still working. */
|
|||
mailbox->m_cb(mailbox, DC_EVENT_IMEX_PROGRESS, permille, 0);
|
||||
|
||||
|
||||
static int export_backup(mrmailbox_t* mailbox, const char* dir)
|
||||
static int export_backup(dc_context_t* mailbox, const char* dir)
|
||||
{
|
||||
int success = 0, locked = 0, closed = 0;
|
||||
char* dest_pathNfilename = NULL;
|
||||
|
@ -1032,7 +1032,7 @@ static void ensure_no_slash(char* path)
|
|||
}
|
||||
|
||||
|
||||
static int import_backup(mrmailbox_t* mailbox, const char* backup_to_import)
|
||||
static int import_backup(dc_context_t* mailbox, const char* backup_to_import)
|
||||
{
|
||||
/* command for testing eg.
|
||||
imex import-backup /home/bpetersen/temp/delta-chat-2017-11-14.bak
|
||||
|
|
24
src/dc_job.c
24
src/dc_job.c
|
@ -35,7 +35,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static int connect_to_imap(mrmailbox_t* mailbox, dc_job_t* job /*may be NULL if the function is called directly!*/)
|
||||
static int connect_to_imap(dc_context_t* mailbox, dc_job_t* job /*may be NULL if the function is called directly!*/)
|
||||
{
|
||||
#define NOT_CONNECTED 0
|
||||
#define ALREADY_CONNECTED 1
|
||||
|
@ -81,7 +81,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_SEND_MSG_TO_IMAP(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_SEND_MSG_TO_IMAP(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
dc_mimefactory_t mimefactory;
|
||||
char* server_folder = NULL;
|
||||
|
@ -124,7 +124,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_DELETE_MSG_ON_IMAP(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
int locked = 0, delete_from_server = 1;
|
||||
dc_msg_t* msg = dc_msg_new();
|
||||
|
@ -226,7 +226,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_MARKSEEN_MSG_ON_IMAP(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
int locked = 0;
|
||||
dc_msg_t* msg = dc_msg_new();
|
||||
|
@ -296,7 +296,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_MARKSEEN_MDN_ON_IMAP(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
char* server_folder = mrparam_get (job->m_param, MRP_SERVER_FOLDER, NULL);
|
||||
uint32_t server_uid = mrparam_get_int(job->m_param, MRP_SERVER_UID, 0);
|
||||
|
@ -327,7 +327,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static void mark_as_error(mrmailbox_t* mailbox, dc_msg_t* msg)
|
||||
static void mark_as_error(dc_context_t* mailbox, dc_msg_t* msg)
|
||||
{
|
||||
if( mailbox==NULL || msg==NULL ) {
|
||||
return;
|
||||
|
@ -340,7 +340,7 @@ static void mark_as_error(mrmailbox_t* mailbox, dc_msg_t* msg)
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_SEND_MSG_TO_SMTP(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_SEND_MSG_TO_SMTP(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
dc_mimefactory_t mimefactory;
|
||||
|
||||
|
@ -438,7 +438,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_do_DC_JOB_SEND_MDN(mrmailbox_t* mailbox, dc_job_t* job)
|
||||
static void dc_job_do_DC_JOB_SEND_MDN(dc_context_t* mailbox, dc_job_t* job)
|
||||
{
|
||||
dc_mimefactory_t mimefactory;
|
||||
dc_mimefactory_init(&mimefactory, mailbox);
|
||||
|
@ -480,7 +480,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
void mrmailbox_suspend_smtp_thread(mrmailbox_t* mailbox, int suspend)
|
||||
void mrmailbox_suspend_smtp_thread(dc_context_t* mailbox, int suspend)
|
||||
{
|
||||
pthread_mutex_lock(&mailbox->m_smtpidle_condmutex);
|
||||
mailbox->m_smtpidle_suspend = suspend;
|
||||
|
@ -510,7 +510,7 @@ void mrmailbox_suspend_smtp_thread(mrmailbox_t* mailbox, int suspend)
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void dc_job_add(mrmailbox_t* mailbox, int action, int foreign_id, const char* param, int delay_seconds)
|
||||
void dc_job_add(dc_context_t* mailbox, int action, int foreign_id, const char* param, int delay_seconds)
|
||||
{
|
||||
time_t timestamp = time(NULL);
|
||||
sqlite3_stmt* stmt;
|
||||
|
@ -556,7 +556,7 @@ void dc_job_try_again_later(dc_job_t* job, int try_again)
|
|||
}
|
||||
|
||||
|
||||
void dc_job_kill_actions(mrmailbox_t* mailbox, int action1, int action2)
|
||||
void dc_job_kill_actions(dc_context_t* mailbox, int action1, int action2)
|
||||
{
|
||||
if( mailbox == NULL ) {
|
||||
return;
|
||||
|
@ -571,7 +571,7 @@ void dc_job_kill_actions(mrmailbox_t* mailbox, int action1, int action2)
|
|||
}
|
||||
|
||||
|
||||
static void dc_job_perform(mrmailbox_t* mailbox, int thread)
|
||||
static void dc_job_perform(dc_context_t* mailbox, int thread)
|
||||
{
|
||||
sqlite3_stmt* select_stmt = NULL;
|
||||
dc_job_t job;
|
||||
|
|
|
@ -72,8 +72,8 @@ typedef struct dc_job_t
|
|||
} dc_job_t;
|
||||
|
||||
|
||||
void dc_job_add (mrmailbox_t*, int action, int foreign_id, const char* param, int delay);
|
||||
void dc_job_kill_actions (mrmailbox_t*, int action1, int action2); /* delete all pending jobs with the given actions */
|
||||
void dc_job_add (dc_context_t*, int action, int foreign_id, const char* param, int delay);
|
||||
void dc_job_kill_actions (dc_context_t*, int action1, int action2); /* delete all pending jobs with the given actions */
|
||||
|
||||
#define DC_DONT_TRY_AGAIN 0
|
||||
#define DC_AT_ONCE -1
|
||||
|
|
|
@ -159,7 +159,7 @@ int dc_key_set_from_base64(dc_key_t* ths, const char* base64, int type)
|
|||
}
|
||||
|
||||
|
||||
int dc_key_set_from_file(dc_key_t* ths, const char* pathNfilename, mrmailbox_t* mailbox)
|
||||
int dc_key_set_from_file(dc_key_t* ths, const char* pathNfilename, dc_context_t* mailbox)
|
||||
{
|
||||
char* buf = NULL;
|
||||
const char *headerline, *base64; // just pointers inside buf, must not be freed
|
||||
|
@ -403,7 +403,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int dc_key_render_asc_to_file(const dc_key_t* key, const char* file, mrmailbox_t* mailbox /* for logging only */)
|
||||
int dc_key_render_asc_to_file(const dc_key_t* key, const char* file, dc_context_t* mailbox /* for logging only */)
|
||||
{
|
||||
int success = 0;
|
||||
char* file_content = NULL;
|
||||
|
|
|
@ -50,13 +50,13 @@ typedef struct dc_key_t
|
|||
|
||||
dc_key_t* dc_key_new ();
|
||||
dc_key_t* dc_key_ref (dc_key_t*);
|
||||
void dc_key_unref (dc_key_t*);
|
||||
void dc_key_unref (dc_key_t*);
|
||||
|
||||
int dc_key_set_from_binary (dc_key_t*, const void* data, int bytes, int type);
|
||||
int dc_key_set_from_key (dc_key_t*, const dc_key_t*);
|
||||
int dc_key_set_from_stmt (dc_key_t*, sqlite3_stmt*, int index, int type);
|
||||
int dc_key_set_from_base64 (dc_key_t*, const char* base64, int type);
|
||||
int dc_key_set_from_file (dc_key_t*, const char* file, mrmailbox_t* mailbox);
|
||||
int dc_key_set_from_file (dc_key_t*, const char* file, dc_context_t* mailbox);
|
||||
|
||||
int dc_key_equals (const dc_key_t*, const dc_key_t*);
|
||||
|
||||
|
@ -67,7 +67,7 @@ int dc_key_load_self_private__(dc_key_t*, const char* self_addr, dc_sqlite3_t*
|
|||
char* mr_render_base64 (const void* buf, size_t buf_bytes, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
|
||||
char* dc_key_render_base64(const dc_key_t* ths, int break_every, const char* break_chars, int add_checksum); /* the result must be freed */
|
||||
char* dc_key_render_asc (const dc_key_t*, const char* add_header_lines); /* each header line must be terminated by \r\n, the result must be freed */
|
||||
int dc_key_render_asc_to_file(const dc_key_t*, const char* file, mrmailbox_t* mailbox);
|
||||
int dc_key_render_asc_to_file(const dc_key_t*, const char* file, dc_context_t* mailbox);
|
||||
|
||||
char* mr_format_fingerprint (const char*);
|
||||
char* mr_normalize_fingerprint (const char*);
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
#include "dc_context.h"
|
||||
|
||||
|
||||
void mrmailbox_add_to_keyhistory__(mrmailbox_t* mailbox, const char* rfc724_mid, time_t sending_time, const char* addr, const char* fingerprint)
|
||||
void mrmailbox_add_to_keyhistory__(dc_context_t* mailbox, const char* rfc724_mid, time_t sending_time, const char* addr, const char* fingerprint)
|
||||
{
|
||||
// TODO
|
||||
}
|
||||
|
|
10
src/dc_log.c
10
src/dc_log.c
|
@ -39,7 +39,7 @@ are usually logged by dc_log_warning(). */
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static void log_vprintf(mrmailbox_t* mailbox, int event, int code, const char* msg_format, va_list va)
|
||||
static void log_vprintf(dc_context_t* mailbox, int event, int code, const char* msg_format, va_list va)
|
||||
{
|
||||
char* msg = NULL;
|
||||
|
||||
|
@ -84,7 +84,7 @@ static void log_vprintf(mrmailbox_t* mailbox, int event, int code, const char* m
|
|||
}
|
||||
|
||||
|
||||
void dc_log_info(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
||||
void dc_log_info(dc_context_t* mailbox, int code, const char* msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, msg); /* va_start() expects the last non-variable argument as the second parameter */
|
||||
|
@ -94,7 +94,7 @@ void dc_log_info(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
|||
|
||||
|
||||
|
||||
void dc_log_warning(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
||||
void dc_log_warning(dc_context_t* mailbox, int code, const char* msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, msg);
|
||||
|
@ -103,7 +103,7 @@ void dc_log_warning(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
|||
}
|
||||
|
||||
|
||||
void dc_log_error(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
||||
void dc_log_error(dc_context_t* mailbox, int code, const char* msg, ...)
|
||||
{
|
||||
va_list va;
|
||||
va_start(va, msg);
|
||||
|
@ -112,7 +112,7 @@ void dc_log_error(mrmailbox_t* mailbox, int code, const char* msg, ...)
|
|||
}
|
||||
|
||||
|
||||
void dc_log_error_if(int* condition, mrmailbox_t* mailbox, int code, const char* msg, ...)
|
||||
void dc_log_error_if(int* condition, dc_context_t* mailbox, int code, const char* msg, ...)
|
||||
{
|
||||
if( condition == NULL || mailbox==NULL || mailbox->m_magic != MR_MAILBOX_MAGIC ) {
|
||||
return;
|
||||
|
|
|
@ -34,14 +34,14 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void dc_mimefactory_init(dc_mimefactory_t* factory, mrmailbox_t* mailbox)
|
||||
void dc_mimefactory_init(dc_mimefactory_t* factory, dc_context_t* mailbox)
|
||||
{
|
||||
if( factory == NULL || mailbox == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(factory, 0, sizeof(dc_mimefactory_t));
|
||||
factory->m_mailbox = mailbox;
|
||||
factory->m_context = mailbox;
|
||||
}
|
||||
|
||||
|
||||
|
@ -91,10 +91,10 @@ void dc_mimefactory_empty(dc_mimefactory_t* factory)
|
|||
|
||||
static void load_from__(dc_mimefactory_t* factory)
|
||||
{
|
||||
factory->m_from_addr = dc_sqlite3_get_config__(factory->m_mailbox->m_sql, "configured_addr", NULL);
|
||||
factory->m_from_displayname = dc_sqlite3_get_config__(factory->m_mailbox->m_sql, "displayname", NULL);
|
||||
factory->m_from_addr = dc_sqlite3_get_config__(factory->m_context->m_sql, "configured_addr", NULL);
|
||||
factory->m_from_displayname = dc_sqlite3_get_config__(factory->m_context->m_sql, "displayname", NULL);
|
||||
|
||||
factory->m_selfstatus = dc_sqlite3_get_config__(factory->m_mailbox->m_sql, "selfstatus", NULL);
|
||||
factory->m_selfstatus = dc_sqlite3_get_config__(factory->m_context->m_sql, "selfstatus", NULL);
|
||||
if( factory->m_selfstatus == NULL ) {
|
||||
factory->m_selfstatus = mrstock_str(MR_STR_STATUSLINE);
|
||||
}
|
||||
|
@ -106,12 +106,12 @@ int dc_mimefactory_load_msg(dc_mimefactory_t* factory, uint32_t msg_id)
|
|||
int success = 0, locked = 0;
|
||||
|
||||
if( factory == NULL || msg_id <= MR_MSG_ID_LAST_SPECIAL
|
||||
|| factory->m_mailbox == NULL
|
||||
|| factory->m_context == NULL
|
||||
|| factory->m_msg /*call empty() before */ ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mrmailbox_t* mailbox = factory->m_mailbox;
|
||||
dc_context_t* mailbox = factory->m_context;
|
||||
|
||||
factory->m_recipients_names = clist_new();
|
||||
factory->m_recipients_addr = clist_new();
|
||||
|
@ -243,13 +243,13 @@ cleanup:
|
|||
int dc_mimefactory_load_mdn(dc_mimefactory_t* factory, uint32_t msg_id)
|
||||
{
|
||||
int success = 0, locked = 0;
|
||||
dc_contact_t* contact = dc_contact_new(factory->m_mailbox);
|
||||
dc_contact_t* contact = dc_contact_new(factory->m_context);
|
||||
|
||||
if( factory == NULL ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
mrmailbox_t* mailbox = factory->m_mailbox;
|
||||
dc_context_t* mailbox = factory->m_context;
|
||||
|
||||
factory->m_recipients_names = clist_new();
|
||||
factory->m_recipients_addr = clist_new();
|
||||
|
@ -478,13 +478,13 @@ int dc_mimefactory_render(dc_mimefactory_t* factory)
|
|||
int col = 0;
|
||||
int success = 0;
|
||||
int parts = 0;
|
||||
mrmailbox_e2ee_helper_t e2ee_helper;
|
||||
dc_e2ee_helper_t e2ee_helper;
|
||||
int e2ee_guaranteed = 0;
|
||||
int min_verified = MRV_NOT_VERIFIED;
|
||||
int force_plaintext = 0; // 1=add Autocrypt-header (needed eg. for handshaking), 2=no Autocrypte-header (used for MDN)
|
||||
char* grpimage = NULL;
|
||||
|
||||
memset(&e2ee_helper, 0, sizeof(mrmailbox_e2ee_helper_t));
|
||||
memset(&e2ee_helper, 0, sizeof(dc_e2ee_helper_t));
|
||||
|
||||
|
||||
/* create basic mail
|
||||
|
@ -522,8 +522,8 @@ int dc_mimefactory_render(dc_mimefactory_t* factory)
|
|||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("X-Mailer"),
|
||||
mr_mprintf("Delta Chat %s%s%s",
|
||||
DC_VERSION_STR,
|
||||
factory->m_mailbox->m_os_name? " for " : "",
|
||||
factory->m_mailbox->m_os_name? factory->m_mailbox->m_os_name : "")));
|
||||
factory->m_context->m_os_name? " for " : "",
|
||||
factory->m_context->m_os_name? factory->m_context->m_os_name : "")));
|
||||
|
||||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Chat-Version"), strdup("1.0"))); /* mark message as being sent by a messenger */
|
||||
if( factory->m_predecessor ) {
|
||||
|
@ -586,7 +586,7 @@ int dc_mimefactory_render(dc_mimefactory_t* factory)
|
|||
}
|
||||
|
||||
if( mrparam_get_int(msg->m_param, MRP_CMD_PARAM2, 0)&MR_FROM_HANDSHAKE ) {
|
||||
dc_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", "vg-member-added");
|
||||
dc_log_info(msg->m_context, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", "vg-member-added");
|
||||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Secure-Join"), strdup("vg-member-added")));
|
||||
}
|
||||
}
|
||||
|
@ -611,7 +611,7 @@ int dc_mimefactory_render(dc_mimefactory_t* factory)
|
|||
if( command == MR_CMD_SECUREJOIN_MESSAGE ) {
|
||||
char* step = mrparam_get(msg->m_param, MRP_CMD_PARAM, NULL);
|
||||
if( step ) {
|
||||
dc_log_info(msg->m_mailbox, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", step);
|
||||
dc_log_info(msg->m_context, 0, "sending secure-join message '%s' >>>>>>>>>>>>>>>>>>>>>>>>>", step);
|
||||
mailimf_fields_add(imf_fields, mailimf_field_new_custom(strdup("Secure-Join"), step/*mailimf takes ownership of string*/));
|
||||
|
||||
char* param2 = mrparam_get(msg->m_param, MRP_CMD_PARAM2, NULL);
|
||||
|
@ -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_mailbox, factory->m_recipients_addr, force_plaintext, e2ee_guaranteed, min_verified, message, &e2ee_helper);
|
||||
mrmailbox_e2ee_encrypt(factory->m_context, factory->m_recipients_addr, force_plaintext, e2ee_guaranteed, min_verified, message, &e2ee_helper);
|
||||
}
|
||||
|
||||
if( e2ee_helper.m_encryption_successfull ) {
|
||||
|
|
|
@ -74,12 +74,12 @@ typedef struct dc_mimefactory_t {
|
|||
int m_out_encrypted;
|
||||
|
||||
/* private */
|
||||
mrmailbox_t* m_mailbox;
|
||||
dc_context_t* m_context;
|
||||
|
||||
} dc_mimefactory_t;
|
||||
|
||||
|
||||
void dc_mimefactory_init (dc_mimefactory_t*, mrmailbox_t*);
|
||||
void dc_mimefactory_init (dc_mimefactory_t*, dc_context_t*);
|
||||
void dc_mimefactory_empty (dc_mimefactory_t*);
|
||||
int dc_mimefactory_load_msg (dc_mimefactory_t*, uint32_t msg_id);
|
||||
int dc_mimefactory_load_mdn (dc_mimefactory_t*, uint32_t msg_id);
|
||||
|
|
|
@ -835,7 +835,7 @@ static void mrmimepart_unref(mrmimepart_t* ths)
|
|||
*
|
||||
* @return The MIME-parser object.
|
||||
*/
|
||||
dc_mimeparser_t* dc_mimeparser_new(const char* blobdir, mrmailbox_t* mailbox)
|
||||
dc_mimeparser_t* dc_mimeparser_new(const char* blobdir, dc_context_t* mailbox)
|
||||
{
|
||||
dc_mimeparser_t* ths = NULL;
|
||||
|
||||
|
@ -843,11 +843,11 @@ dc_mimeparser_t* dc_mimeparser_new(const char* blobdir, mrmailbox_t* mailbox)
|
|||
exit(30);
|
||||
}
|
||||
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
ths->m_parts = carray_new(16);
|
||||
ths->m_blobdir = blobdir; /* no need to copy the string at the moment */
|
||||
ths->m_reports = carray_new(16);
|
||||
ths->m_e2ee_helper = calloc(1, sizeof(mrmailbox_e2ee_helper_t));
|
||||
ths->m_e2ee_helper = calloc(1, sizeof(dc_e2ee_helper_t));
|
||||
|
||||
dc_hash_init(&ths->m_header, MRHASH_STRING, 0/* do not copy key */);
|
||||
|
||||
|
@ -968,7 +968,7 @@ static void do_add_single_file_part(dc_mimeparser_t* parser, int msg_type, int m
|
|||
}
|
||||
|
||||
/* copy data to file */
|
||||
if( mr_write_file(pathNfilename, decoded_data, decoded_data_bytes, parser->m_mailbox)==0 ) {
|
||||
if( mr_write_file(pathNfilename, decoded_data, decoded_data_bytes, parser->m_context)==0 ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -1065,7 +1065,7 @@ static int dc_mimeparser_add_single_part_if_known(dc_mimeparser_t* ths, struct m
|
|||
size_t ret_bytes = 0;
|
||||
int r = charconv_buffer("utf-8", charset, decoded_data, decoded_data_bytes, &charset_buffer, &ret_bytes);
|
||||
if( r != MAIL_CHARCONV_NO_ERROR ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Cannot convert %i bytes from \"%s\" to \"utf-8\"; errorcode is %i.", /* if this warning comes up for usual character sets, maybe libetpan is compiled without iconv? */
|
||||
dc_log_warning(ths->m_context, 0, "Cannot convert %i bytes from \"%s\" to \"utf-8\"; errorcode is %i.", /* if this warning comes up for usual character sets, maybe libetpan is compiled without iconv? */
|
||||
(int)decoded_data_bytes, charset, (int)r); /* continue, however */
|
||||
}
|
||||
else if( charset_buffer==NULL || ret_bytes <= 0 ) {
|
||||
|
@ -1235,7 +1235,7 @@ static int dc_mimeparser_parse_mime_recursive(dc_mimeparser_t* ths, struct mailm
|
|||
&& mime->mm_content_type->ct_type->tp_data.tp_discrete_type->dt_type==MAILMIME_DISCRETE_TYPE_TEXT
|
||||
&& mime->mm_content_type->ct_subtype
|
||||
&& strcmp(mime->mm_content_type->ct_subtype, "rfc822-headers")==0 ) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Protected headers found in text/rfc822-headers attachment: Will be ignored."); /* we want the protected headers in the normal header of the payload */
|
||||
dc_log_info(ths->m_context, 0, "Protected headers found in text/rfc822-headers attachment: Will be ignored."); /* we want the protected headers in the normal header of the payload */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1243,11 +1243,11 @@ static int dc_mimeparser_parse_mime_recursive(dc_mimeparser_t* ths, struct mailm
|
|||
size_t dummy = 0;
|
||||
if( mailimf_envelope_and_optional_fields_parse(mime->mm_mime_start, mime->mm_length, &dummy, &ths->m_header_protected)!=MAILIMF_NO_ERROR
|
||||
|| ths->m_header_protected==NULL ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "Protected headers parsing error.");
|
||||
dc_log_warning(ths->m_context, 0, "Protected headers parsing error.");
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc_log_info(ths->m_mailbox, 0, "Protected headers found in MIME header: Will be ignored as we already found an outer one.");
|
||||
dc_log_info(ths->m_context, 0, "Protected headers found in MIME header: Will be ignored as we already found an outer one.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1365,7 +1365,7 @@ static int dc_mimeparser_parse_mime_recursive(dc_mimeparser_t* ths, struct mailm
|
|||
}
|
||||
}
|
||||
if( plain_cnt==1 && html_cnt==1 ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "HACK: multipart/mixed message found with PLAIN and HTML, we'll skip the HTML part as this seems to be unwanted.");
|
||||
dc_log_warning(ths->m_context, 0, "HACK: multipart/mixed message found with PLAIN and HTML, we'll skip the HTML part as this seems to be unwanted.");
|
||||
skip_part = html_part;
|
||||
}
|
||||
}
|
||||
|
@ -1401,7 +1401,7 @@ static int dc_mimeparser_parse_mime_recursive(dc_mimeparser_t* ths, struct mailm
|
|||
}
|
||||
|
||||
|
||||
static void hash_header(dc_hash_t* out, const struct mailimf_fields* in, mrmailbox_t* mailbox)
|
||||
static void hash_header(dc_hash_t* out, const struct mailimf_fields* in, dc_context_t* mailbox)
|
||||
{
|
||||
if( in == NULL ) {
|
||||
return;
|
||||
|
@ -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_mailbox, ths->m_mimeroot, ths->m_e2ee_helper);
|
||||
mrmailbox_e2ee_decrypt(ths->m_context, ths->m_mimeroot, ths->m_e2ee_helper);
|
||||
|
||||
//printf("after decryption:\n"); mailmime_print(ths->m_mimeroot);
|
||||
|
||||
|
@ -1507,8 +1507,8 @@ void dc_mimeparser_parse(dc_mimeparser_t* ths, const char* body_not_terminated,
|
|||
// may also be handy for extracting binaries from uuencoded text and just add the rest text after the binaries.
|
||||
|
||||
/* setup header */
|
||||
hash_header(&ths->m_header, ths->m_header_root, ths->m_mailbox);
|
||||
hash_header(&ths->m_header, ths->m_header_protected, ths->m_mailbox); /* overwrite the original header with the protected one */
|
||||
hash_header(&ths->m_header, ths->m_header_root, ths->m_context);
|
||||
hash_header(&ths->m_header, ths->m_header_protected, ths->m_context); /* overwrite the original header with the protected one */
|
||||
|
||||
/* set some basic data */
|
||||
{
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
|
||||
|
||||
/* Parse MIME body; this is the text part of an IMF, see https://tools.ietf.org/html/rfc5322
|
||||
dc_mimeparser_t has no deep dependencies to mrmailbox_t or to the database
|
||||
(mrmailbox_t is used for logging only). */
|
||||
dc_mimeparser_t has no deep dependencies to dc_context_t or to the database
|
||||
(dc_context_t is used for logging only). */
|
||||
|
||||
|
||||
#ifndef __MRMIMEPARSER_H__
|
||||
|
@ -36,7 +36,7 @@ extern "C" {
|
|||
#include "dc_param.h"
|
||||
|
||||
|
||||
typedef struct mrmailbox_e2ee_helper_t mrmailbox_e2ee_helper_t;
|
||||
typedef struct dc_e2ee_helper_t dc_e2ee_helper_t;
|
||||
|
||||
|
||||
typedef struct mrmimepart_t
|
||||
|
@ -70,13 +70,13 @@ typedef struct dc_mimeparser_t
|
|||
|
||||
int m_decrypting_failed; /* set, if there are multipart/encrypted parts left after decryption */
|
||||
|
||||
mrmailbox_e2ee_helper_t* m_e2ee_helper;
|
||||
dc_e2ee_helper_t* m_e2ee_helper;
|
||||
|
||||
const char* m_blobdir;
|
||||
|
||||
int m_is_forwarded;
|
||||
|
||||
mrmailbox_t* m_mailbox;
|
||||
dc_context_t* m_context;
|
||||
|
||||
carray* m_reports; /* array of mailmime objects */
|
||||
|
||||
|
@ -85,7 +85,7 @@ typedef struct dc_mimeparser_t
|
|||
} dc_mimeparser_t;
|
||||
|
||||
|
||||
dc_mimeparser_t* dc_mimeparser_new (const char* blobdir, mrmailbox_t*);
|
||||
dc_mimeparser_t* dc_mimeparser_new (const char* blobdir, dc_context_t*);
|
||||
void dc_mimeparser_unref (dc_mimeparser_t*);
|
||||
void dc_mimeparser_empty (dc_mimeparser_t*);
|
||||
|
||||
|
|
38
src/dc_msg.c
38
src/dc_msg.c
|
@ -105,7 +105,7 @@ void dc_msg_empty(dc_msg_t* msg)
|
|||
|
||||
mrparam_set_packed(msg->m_param, NULL);
|
||||
|
||||
msg->m_mailbox = NULL;
|
||||
msg->m_context = NULL;
|
||||
|
||||
msg->m_hidden = 0;
|
||||
}
|
||||
|
@ -457,13 +457,13 @@ dc_lot_t* dc_msg_get_mediainfo(const dc_msg_t* msg)
|
|||
char* pathNfilename = NULL;
|
||||
dc_contact_t* contact = NULL;
|
||||
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_mailbox == NULL ) {
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_context == NULL ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( msg->m_type == MR_MSG_VOICE )
|
||||
{
|
||||
if( (contact = mrmailbox_get_contact(msg->m_mailbox, msg->m_from_id))==NULL ) {
|
||||
if( (contact = mrmailbox_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);
|
||||
|
@ -582,15 +582,15 @@ int dc_msg_get_showpadlock(const dc_msg_t* msg)
|
|||
/* a padlock guarantees that the message is e2ee _and_ answers will be as well */
|
||||
int show_encryption_state = 0;
|
||||
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_mailbox == NULL ) {
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_context == NULL ) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( msg->m_mailbox->m_e2ee_enabled ) {
|
||||
if( msg->m_context->m_e2ee_enabled ) {
|
||||
show_encryption_state = 1;
|
||||
}
|
||||
else {
|
||||
dc_chat_t* chat = mrmailbox_get_chat(msg->m_mailbox, msg->m_chat_id);
|
||||
dc_chat_t* chat = mrmailbox_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_mailbox, msg->m_chat_id)) == NULL ) {
|
||||
if( (chat_to_delete=mrmailbox_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_mailbox, msg->m_from_id);
|
||||
contact = mrmailbox_get_contact(chat->m_context, msg->m_from_id);
|
||||
}
|
||||
|
||||
dc_lot_fill(ret, msg, chat, contact);
|
||||
|
@ -853,7 +853,7 @@ char* dc_msg_get_setupcodebegin(const dc_msg_t* msg)
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
if( !mr_read_file(filename, (void**)&buf, &buf_bytes, msg->m_mailbox) || buf == NULL || buf_bytes <= 0 ) {
|
||||
if( !mr_read_file(filename, (void**)&buf, &buf_bytes, msg->m_context) || buf == NULL || buf_bytes <= 0 ) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -923,7 +923,7 @@ static int dc_msg_set_from_stmt__(dc_msg_t* ths, sqlite3_stmt* row, int row_offs
|
|||
*
|
||||
* @private @memberof dc_msg_t
|
||||
*/
|
||||
int dc_msg_load_from_db__(dc_msg_t* ths, mrmailbox_t* mailbox, uint32_t id)
|
||||
int dc_msg_load_from_db__(dc_msg_t* ths, dc_context_t* mailbox, uint32_t id)
|
||||
{
|
||||
sqlite3_stmt* stmt;
|
||||
|
||||
|
@ -945,7 +945,7 @@ int dc_msg_load_from_db__(dc_msg_t* ths, mrmailbox_t* mailbox, uint32_t id)
|
|||
return 0;
|
||||
}
|
||||
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -1138,13 +1138,13 @@ int dc_msg_is_increation(const dc_msg_t* msg)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if( msg->m_mailbox && MR_MSG_NEEDS_ATTACHMENT(msg->m_type) /*additional check for speed reasons*/ )
|
||||
if( msg->m_context && MR_MSG_NEEDS_ATTACHMENT(msg->m_type) /*additional check for speed reasons*/ )
|
||||
{
|
||||
dc_sqlite3_lock(msg->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(msg->m_context->m_sql);
|
||||
|
||||
is_increation = dc_msg_is_increation__(msg);
|
||||
|
||||
dc_sqlite3_unlock(msg->m_mailbox->m_sql);
|
||||
dc_sqlite3_unlock(msg->m_context->m_sql);
|
||||
}
|
||||
|
||||
return is_increation;
|
||||
|
@ -1153,11 +1153,11 @@ int dc_msg_is_increation(const dc_msg_t* msg)
|
|||
|
||||
void dc_msg_save_param_to_disk__(dc_msg_t* msg)
|
||||
{
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_mailbox == NULL || msg->m_mailbox->m_sql == NULL ) {
|
||||
if( msg == NULL || msg->m_magic != MR_MSG_MAGIC || msg->m_context == NULL || msg->m_context->m_sql == NULL ) {
|
||||
return;
|
||||
}
|
||||
|
||||
sqlite3_stmt* stmt = dc_sqlite3_predefine__(msg->m_mailbox->m_sql, UPDATE_msgs_SET_param_WHERE_id,
|
||||
sqlite3_stmt* stmt = dc_sqlite3_predefine__(msg->m_context->m_sql, UPDATE_msgs_SET_param_WHERE_id,
|
||||
"UPDATE msgs SET param=? WHERE id=?;");
|
||||
sqlite3_bind_text(stmt, 1, msg->m_param->m_packed, -1, SQLITE_STATIC);
|
||||
sqlite3_bind_int (stmt, 2, msg->m_id);
|
||||
|
@ -1199,7 +1199,7 @@ void dc_msg_latefiling_mediasize(dc_msg_t* msg, int width, int height, int durat
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
dc_sqlite3_lock(msg->m_mailbox->m_sql);
|
||||
dc_sqlite3_lock(msg->m_context->m_sql);
|
||||
locked = 1;
|
||||
|
||||
if( width > 0 ) {
|
||||
|
@ -1216,9 +1216,9 @@ void dc_msg_latefiling_mediasize(dc_msg_t* msg, int width, int height, int durat
|
|||
|
||||
dc_msg_save_param_to_disk__(msg);
|
||||
|
||||
dc_sqlite3_unlock(msg->m_mailbox->m_sql);
|
||||
dc_sqlite3_unlock(msg->m_context->m_sql);
|
||||
locked = 0;
|
||||
|
||||
cleanup:
|
||||
if( locked ) { dc_sqlite3_unlock(msg->m_mailbox->m_sql); }
|
||||
if( locked ) { dc_sqlite3_unlock(msg->m_context->m_sql); }
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ struct _dc_msg
|
|||
/*
|
||||
* The mailbox object the chat belongs to. Never NULL.
|
||||
*/
|
||||
//mrmailbox_t* m_mailbox;
|
||||
//dc_context_t* m_context;
|
||||
|
||||
|
||||
int m_type; /**< Message type. It is recommended to use dc_msg_set_type() and dc_msg_get_type() to access this field. */
|
||||
|
@ -83,7 +83,7 @@ struct _dc_msg
|
|||
|
||||
char* m_text; /**< Message text. NULL if unset. It is recommended to use dc_msg_set_text() and dc_msg_get_text() to access this field. */
|
||||
|
||||
mrmailbox_t* m_mailbox; /**< may be NULL, set on loading from database and on sending */
|
||||
dc_context_t* m_context; /**< may be NULL, set on loading from database and on sending */
|
||||
char* m_rfc724_mid; /**< The RFC-742 Message-ID */
|
||||
char* m_server_folder; /**< Folder where the message was last seen on the server */
|
||||
uint32_t m_server_uid; /**< UID last seen on the server for this message */
|
||||
|
@ -94,7 +94,7 @@ struct _dc_msg
|
|||
};
|
||||
|
||||
|
||||
int dc_msg_load_from_db__ (dc_msg_t*, mrmailbox_t*, uint32_t id);
|
||||
int dc_msg_load_from_db__ (dc_msg_t*, dc_context_t*, uint32_t id);
|
||||
int dc_msg_is_increation__ (const dc_msg_t*);
|
||||
char* dc_msg_get_summarytext_by_raw (int type, const char* text, mrparam_t*, int approx_bytes); /* the returned value must be free()'d */
|
||||
void dc_msg_save_param_to_disk__ (dc_msg_t*);
|
||||
|
|
16
src/dc_pgp.c
16
src/dc_pgp.c
|
@ -51,7 +51,7 @@ one :-) */
|
|||
static pgp_io_t s_io;
|
||||
|
||||
|
||||
void dc_pgp_init(mrmailbox_t* mailbox)
|
||||
void dc_pgp_init(dc_context_t* mailbox)
|
||||
{
|
||||
#ifdef __APPLE__
|
||||
OPENSSL_init();
|
||||
|
@ -70,12 +70,12 @@ void dc_pgp_init(mrmailbox_t* mailbox)
|
|||
}
|
||||
|
||||
|
||||
void dc_pgp_exit(mrmailbox_t* mailbox)
|
||||
void dc_pgp_exit(dc_context_t* mailbox)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void dc_pgp_rand_seed(mrmailbox_t* mailbox, const void* buf, size_t bytes)
|
||||
void dc_pgp_rand_seed(dc_context_t* mailbox, const void* buf, size_t bytes)
|
||||
{
|
||||
if( buf == NULL || bytes <= 0 ) {
|
||||
return;
|
||||
|
@ -296,7 +296,7 @@ static void add_subkey_binding_signature(pgp_subkeysig_t* p, pgp_key_t* primaryk
|
|||
}
|
||||
|
||||
|
||||
int dc_pgp_create_keypair(mrmailbox_t* mailbox, const char* addr, dc_key_t* ret_public_key, dc_key_t* ret_private_key)
|
||||
int dc_pgp_create_keypair(dc_context_t* mailbox, const char* addr, dc_key_t* ret_public_key, dc_key_t* ret_private_key)
|
||||
{
|
||||
int success = 0;
|
||||
pgp_key_t seckey, pubkey, subkey;
|
||||
|
@ -411,7 +411,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
int dc_pgp_is_valid_key(mrmailbox_t* mailbox, const dc_key_t* raw_key)
|
||||
int dc_pgp_is_valid_key(dc_context_t* mailbox, const dc_key_t* raw_key)
|
||||
{
|
||||
int key_is_valid = 0;
|
||||
pgp_keyring_t* public_keys = calloc(1, sizeof(pgp_keyring_t));
|
||||
|
@ -482,7 +482,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int dc_pgp_split_key(mrmailbox_t* mailbox, const dc_key_t* private_in, dc_key_t* ret_public_key)
|
||||
int dc_pgp_split_key(dc_context_t* mailbox, const dc_key_t* private_in, dc_key_t* ret_public_key)
|
||||
{
|
||||
int success = 0;
|
||||
pgp_keyring_t* public_keys = calloc(1, sizeof(pgp_keyring_t));
|
||||
|
@ -534,7 +534,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
int dc_pgp_pk_encrypt( mrmailbox_t* mailbox,
|
||||
int dc_pgp_pk_encrypt( dc_context_t* mailbox,
|
||||
const void* plain_text,
|
||||
size_t plain_bytes,
|
||||
const dc_keyring_t* raw_public_keys_for_encryption,
|
||||
|
@ -625,7 +625,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int dc_pgp_pk_decrypt( mrmailbox_t* mailbox,
|
||||
int dc_pgp_pk_decrypt( dc_context_t* mailbox,
|
||||
const void* ctext,
|
||||
size_t ctext_bytes,
|
||||
const dc_keyring_t* raw_private_keys_for_decryption,
|
||||
|
|
16
src/dc_pgp.h
16
src/dc_pgp.h
|
@ -37,19 +37,19 @@ typedef struct dc_keyring_t dc_keyring_t;
|
|||
#define MRE2EE_NO_VALID_SIGNATURE 0x02
|
||||
|
||||
/* misc. */
|
||||
void dc_pgp_init (mrmailbox_t*);
|
||||
void dc_pgp_exit (mrmailbox_t*);
|
||||
void dc_pgp_rand_seed (mrmailbox_t*, const void* buf, size_t bytes);
|
||||
void dc_pgp_init (dc_context_t*);
|
||||
void dc_pgp_exit (dc_context_t*);
|
||||
void dc_pgp_rand_seed (dc_context_t*, const void* buf, size_t bytes);
|
||||
int dc_split_armored_data (char* buf, const char** ret_headerline, const char** ret_setupcodebegin, const char** ret_preferencrypt, const char** ret_base64);
|
||||
|
||||
/* public key encryption */
|
||||
int dc_pgp_create_keypair (mrmailbox_t*, const char* addr, dc_key_t* public_key, dc_key_t* private_key);
|
||||
int dc_pgp_is_valid_key (mrmailbox_t*, const dc_key_t*);
|
||||
int dc_pgp_create_keypair (dc_context_t*, const char* addr, dc_key_t* public_key, dc_key_t* private_key);
|
||||
int dc_pgp_is_valid_key (dc_context_t*, const dc_key_t*);
|
||||
int dc_pgp_calc_fingerprint (const dc_key_t*, uint8_t** fingerprint, size_t* fingerprint_bytes);
|
||||
int dc_pgp_split_key (mrmailbox_t*, const dc_key_t* private_in, dc_key_t* public_out);
|
||||
int dc_pgp_split_key (dc_context_t*, const dc_key_t* private_in, dc_key_t* public_out);
|
||||
|
||||
int dc_pgp_pk_encrypt (mrmailbox_t*, const void* plain, size_t plain_bytes, const dc_keyring_t*, const dc_key_t* sign_key, int use_armor, void** ret_ctext, size_t* ret_ctext_bytes);
|
||||
int dc_pgp_pk_decrypt (mrmailbox_t*, const void* ctext, size_t ctext_bytes, const dc_keyring_t*, const dc_keyring_t* validate_keys, int use_armor, void** plain, size_t* plain_bytes, dc_hash_t* ret_signature_fingerprints);
|
||||
int dc_pgp_pk_encrypt (dc_context_t*, const void* plain, size_t plain_bytes, const dc_keyring_t*, const dc_key_t* sign_key, int use_armor, void** ret_ctext, size_t* ret_ctext_bytes);
|
||||
int dc_pgp_pk_decrypt (dc_context_t*, const void* ctext, size_t ctext_bytes, const dc_keyring_t*, const dc_keyring_t* validate_keys, int use_armor, void** plain, size_t* plain_bytes, dc_hash_t* ret_signature_fingerprints);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static void add_or_lookup_contact_by_addr__(mrmailbox_t* mailbox, const char* display_name_enc, const char* addr_spec, int origin, dc_array_t* ids, int* check_self)
|
||||
static void add_or_lookup_contact_by_addr__(dc_context_t* mailbox, const char* display_name_enc, const char* addr_spec, int origin, dc_array_t* ids, int* check_self)
|
||||
{
|
||||
/* is addr_spec equal to SELF? */
|
||||
int dummy;
|
||||
|
@ -77,7 +77,7 @@ static void add_or_lookup_contact_by_addr__(mrmailbox_t* mailbox, const char* di
|
|||
}
|
||||
|
||||
|
||||
static void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mrmailbox_t* mailbox, const struct mailimf_mailbox_list* mb_list, int origin, dc_array_t* ids, int* check_self)
|
||||
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)
|
||||
{
|
||||
clistiter* cur;
|
||||
|
||||
|
@ -94,7 +94,7 @@ static void mrmailbox_add_or_lookup_contacts_by_mailbox_list__(mrmailbox_t* mail
|
|||
}
|
||||
|
||||
|
||||
static void mrmailbox_add_or_lookup_contacts_by_address_list__(mrmailbox_t* mailbox, const struct mailimf_address_list* adr_list, int origin, dc_array_t* ids, int* check_self)
|
||||
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)
|
||||
{
|
||||
clistiter* cur;
|
||||
|
||||
|
@ -127,7 +127,7 @@ static void mrmailbox_add_or_lookup_contacts_by_address_list__(mrmailbox_t* mail
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static int is_known_rfc724_mid__(mrmailbox_t* mailbox, const char* rfc724_mid)
|
||||
static int is_known_rfc724_mid__(dc_context_t* mailbox, const char* rfc724_mid)
|
||||
{
|
||||
if( rfc724_mid ) {
|
||||
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_msgs_WHERE_cm,
|
||||
|
@ -145,7 +145,7 @@ static int is_known_rfc724_mid__(mrmailbox_t* mailbox, const char* rfc724_mid)
|
|||
}
|
||||
|
||||
|
||||
static int is_known_rfc724_mid_in_list__(mrmailbox_t* mailbox, const clist* mid_list)
|
||||
static int is_known_rfc724_mid_in_list__(dc_context_t* mailbox, const clist* mid_list)
|
||||
{
|
||||
if( mid_list ) {
|
||||
clistiter* cur;
|
||||
|
@ -160,7 +160,7 @@ static int is_known_rfc724_mid_in_list__(mrmailbox_t* mailbox, const clist* mid_
|
|||
}
|
||||
|
||||
|
||||
static int mrmailbox_is_reply_to_known_message__(mrmailbox_t* mailbox, dc_mimeparser_t* mime_parser)
|
||||
static int mrmailbox_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) */
|
||||
|
@ -205,7 +205,7 @@ static int mrmailbox_is_reply_to_known_message__(mrmailbox_t* mailbox, dc_mimepa
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static int is_msgrmsg_rfc724_mid__(mrmailbox_t* mailbox, const char* rfc724_mid)
|
||||
static int is_msgrmsg_rfc724_mid__(dc_context_t* mailbox, const char* rfc724_mid)
|
||||
{
|
||||
if( rfc724_mid ) {
|
||||
sqlite3_stmt* stmt = dc_sqlite3_predefine__(mailbox->m_sql, SELECT_id_FROM_msgs_WHERE_mcm,
|
||||
|
@ -222,7 +222,7 @@ static int is_msgrmsg_rfc724_mid__(mrmailbox_t* mailbox, const char* rfc724_mid)
|
|||
}
|
||||
|
||||
|
||||
static int is_msgrmsg_rfc724_mid_in_list__(mrmailbox_t* mailbox, const clist* mid_list)
|
||||
static int is_msgrmsg_rfc724_mid_in_list__(dc_context_t* mailbox, const clist* mid_list)
|
||||
{
|
||||
if( mid_list ) {
|
||||
clistiter* cur;
|
||||
|
@ -237,7 +237,7 @@ static int is_msgrmsg_rfc724_mid_in_list__(mrmailbox_t* mailbox, const clist* mi
|
|||
}
|
||||
|
||||
|
||||
static int mrmailbox_is_reply_to_messenger_message__(mrmailbox_t* mailbox, dc_mimeparser_t* mime_parser)
|
||||
static int mrmailbox_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__(mrmailbox_t* mailbox, dc_mi
|
|||
|
||||
|
||||
|
||||
static void mrmailbox_calc_timestamps__(mrmailbox_t* mailbox, uint32_t chat_id, uint32_t from_id, time_t message_timestamp, int is_fresh_msg,
|
||||
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,
|
||||
time_t* sort_timestamp, time_t* sent_timestamp, time_t* rcvd_timestamp)
|
||||
{
|
||||
*rcvd_timestamp = time(NULL);
|
||||
|
@ -323,7 +323,7 @@ static void mrmailbox_calc_timestamps__(mrmailbox_t* mailbox, uint32_t chat_id,
|
|||
}
|
||||
|
||||
|
||||
static dc_array_t* search_chat_ids_by_contact_ids(mrmailbox_t* mailbox, const dc_array_t* unsorted_contact_ids)
|
||||
static dc_array_t* search_chat_ids_by_contact_ids(dc_context_t* mailbox, const dc_array_t* unsorted_contact_ids)
|
||||
{
|
||||
/* searches chat_id's by the given contact IDs, may return zero, one or more chat_id's */
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
@ -406,7 +406,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static char* create_adhoc_grp_id__(mrmailbox_t* mailbox, dc_array_t* member_ids /*including SELF*/)
|
||||
static char* create_adhoc_grp_id__(dc_context_t* mailbox, dc_array_t* member_ids /*including SELF*/)
|
||||
{
|
||||
/* algorithm:
|
||||
- sort normalized, lowercased, e-mail addresses alphabetically
|
||||
|
@ -473,7 +473,7 @@ static char* create_adhoc_grp_id__(mrmailbox_t* mailbox, dc_array_t* member_ids
|
|||
}
|
||||
|
||||
|
||||
static uint32_t create_group_record__(mrmailbox_t* mailbox, const char* grpid, const char* grpname, int create_blocked, int create_verified)
|
||||
static uint32_t create_group_record__(dc_context_t* mailbox, const char* grpid, const char* grpname, int create_blocked, int create_verified)
|
||||
{
|
||||
uint32_t chat_id = 0;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
@ -500,7 +500,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
static void create_or_lookup_adhoc_group__(mrmailbox_t* mailbox, dc_mimeparser_t* mime_parser, int create_blocked,
|
||||
static void create_or_lookup_adhoc_group__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser, int create_blocked,
|
||||
int32_t from_id, const dc_array_t* to_ids,/*does not contain SELF*/
|
||||
uint32_t* ret_chat_id, int* ret_chat_id_blocked)
|
||||
{
|
||||
|
@ -584,7 +584,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static int check_verified_properties__(mrmailbox_t* mailbox, dc_mimeparser_t* mimeparser,
|
||||
static int check_verified_properties__(dc_context_t* mailbox, dc_mimeparser_t* mimeparser,
|
||||
uint32_t from_id, const dc_array_t* to_ids)
|
||||
{
|
||||
int everythings_okay = 0;
|
||||
|
@ -680,7 +680,7 @@ which tries to create or find out the chat_id by:
|
|||
|
||||
So when the function returns, the caller has the group id matching the current
|
||||
state of the group. */
|
||||
static void create_or_lookup_group__(mrmailbox_t* mailbox, dc_mimeparser_t* mime_parser, int create_blocked,
|
||||
static void create_or_lookup_group__(dc_context_t* mailbox, dc_mimeparser_t* mime_parser, int create_blocked,
|
||||
int32_t from_id, const dc_array_t* to_ids,
|
||||
uint32_t* ret_chat_id, int* ret_chat_id_blocked)
|
||||
{
|
||||
|
@ -935,7 +935,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void mrmailbox_receive_imf(mrmailbox_t* mailbox, const char* imf_raw_not_terminated, size_t imf_raw_bytes,
|
||||
void mrmailbox_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 */
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
void mrmailbox_handle_degrade_event(mrmailbox_t* mailbox, dc_apeerstate_t* peerstate)
|
||||
void mrmailbox_handle_degrade_event(dc_context_t* mailbox, dc_apeerstate_t* peerstate)
|
||||
{
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
int locked = 0;
|
||||
|
@ -94,22 +94,22 @@ cleanup:
|
|||
static int encrypted_and_signed(dc_mimeparser_t* mimeparser, const char* expected_fingerprint)
|
||||
{
|
||||
if( !mimeparser->m_e2ee_helper->m_encrypted ) {
|
||||
dc_log_warning(mimeparser->m_mailbox, 0, "Message not encrypted.");
|
||||
dc_log_warning(mimeparser->m_context, 0, "Message not encrypted.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( dc_hash_count(mimeparser->m_e2ee_helper->m_signatures)<=0 ) {
|
||||
dc_log_warning(mimeparser->m_mailbox, 0, "Message not signed.");
|
||||
dc_log_warning(mimeparser->m_context, 0, "Message not signed.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( expected_fingerprint == NULL ) {
|
||||
dc_log_warning(mimeparser->m_mailbox, 0, "Fingerprint for comparison missing.");
|
||||
dc_log_warning(mimeparser->m_context, 0, "Fingerprint for comparison missing.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( dc_hash_find_str(mimeparser->m_e2ee_helper->m_signatures, expected_fingerprint) == NULL ) {
|
||||
dc_log_warning(mimeparser->m_mailbox, 0, "Message does not match expected fingerprint %s.", expected_fingerprint);
|
||||
dc_log_warning(mimeparser->m_context, 0, "Message does not match expected fingerprint %s.", expected_fingerprint);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ static int encrypted_and_signed(dc_mimeparser_t* mimeparser, const char* expecte
|
|||
}
|
||||
|
||||
|
||||
static char* get_self_fingerprint(mrmailbox_t* mailbox)
|
||||
static char* get_self_fingerprint(dc_context_t* mailbox)
|
||||
{
|
||||
int locked = 0;
|
||||
char* self_addr = NULL;
|
||||
|
@ -147,7 +147,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static uint32_t chat_id_2_contact_id(mrmailbox_t* mailbox, uint32_t contact_chat_id)
|
||||
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);
|
||||
|
@ -164,7 +164,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static int fingerprint_equals_sender(mrmailbox_t* mailbox, const char* fingerprint, uint32_t contact_chat_id)
|
||||
static int fingerprint_equals_sender(dc_context_t* mailbox, const char* fingerprint, uint32_t contact_chat_id)
|
||||
{
|
||||
int fingerprint_equal = 0;
|
||||
int locked = 0;
|
||||
|
@ -203,7 +203,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
static int mark_peer_as_verified__(mrmailbox_t* mailbox, const char* fingerprint)
|
||||
static int mark_peer_as_verified__(dc_context_t* mailbox, const char* fingerprint)
|
||||
{
|
||||
int success = 0;
|
||||
dc_apeerstate_t* peerstate = dc_apeerstate_new(mailbox);
|
||||
|
@ -243,7 +243,7 @@ static const char* lookup_field(dc_mimeparser_t* mimeparser, const char* key)
|
|||
}
|
||||
|
||||
|
||||
static void send_handshake_msg(mrmailbox_t* mailbox, uint32_t contact_chat_id, const char* step, const char* param2, const char* fingerprint, const char* grpid)
|
||||
static void send_handshake_msg(dc_context_t* mailbox, uint32_t contact_chat_id, const char* step, const char* param2, const char* fingerprint, const char* grpid)
|
||||
{
|
||||
dc_msg_t* msg = dc_msg_new();
|
||||
|
||||
|
@ -278,7 +278,7 @@ static void send_handshake_msg(mrmailbox_t* mailbox, uint32_t contact_chat_id, c
|
|||
}
|
||||
|
||||
|
||||
static void could_not_establish_secure_connection(mrmailbox_t* mailbox, uint32_t contact_chat_id, const char* details)
|
||||
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);
|
||||
|
@ -293,7 +293,7 @@ static void could_not_establish_secure_connection(mrmailbox_t* mailbox, uint32_t
|
|||
}
|
||||
|
||||
|
||||
static void secure_connection_established(mrmailbox_t* mailbox, uint32_t contact_chat_id)
|
||||
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);
|
||||
|
@ -320,7 +320,7 @@ static dc_lot_t* s_bobs_qr_scan = NULL; // should be surround eg. by dc_sqlite3_
|
|||
static int s_bobs_status = 0;
|
||||
|
||||
|
||||
static void end_bobs_joining(mrmailbox_t* mailbox, int status)
|
||||
static void end_bobs_joining(dc_context_t* mailbox, int status)
|
||||
{
|
||||
s_bobs_status = status;
|
||||
mrmailbox_stop_ongoing_process(mailbox);
|
||||
|
@ -565,7 +565,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrmailbox_handle_securejoin_handshake(mrmailbox_t* mailbox, dc_mimeparser_t* mimeparser, uint32_t contact_id)
|
||||
int mrmailbox_handle_securejoin_handshake(dc_context_t* mailbox, dc_mimeparser_t* mimeparser, uint32_t contact_id)
|
||||
{
|
||||
int locked = 0;
|
||||
const char* step = NULL;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
dc_smtp_t* dc_smtp_new(mrmailbox_t* mailbox)
|
||||
dc_smtp_t* dc_smtp_new(dc_context_t* mailbox)
|
||||
{
|
||||
dc_smtp_t* ths;
|
||||
if( (ths=calloc(1, sizeof(dc_smtp_t)))==NULL ) {
|
||||
|
@ -45,7 +45,7 @@ dc_smtp_t* dc_smtp_new(mrmailbox_t* mailbox)
|
|||
|
||||
ths->m_log_connect_errors = 1;
|
||||
|
||||
ths->m_mailbox = mailbox; /* should be used for logging only */
|
||||
ths->m_context = mailbox; /* should be used for logging only */
|
||||
return ths;
|
||||
}
|
||||
|
||||
|
@ -100,19 +100,19 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
return 0;
|
||||
}
|
||||
|
||||
if( ths->m_mailbox->m_cb(ths->m_mailbox, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, DC_ERROR_NO_NETWORK, NULL);
|
||||
if( ths->m_context->m_cb(ths->m_context, DC_EVENT_IS_OFFLINE, 0, 0)!=0 ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, DC_ERROR_NO_NETWORK, NULL);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( ths->m_hEtpan ) {
|
||||
dc_log_warning(ths->m_mailbox, 0, "SMTP already connected.");
|
||||
dc_log_warning(ths->m_context, 0, "SMTP already connected.");
|
||||
success = 1; /* otherwise, the handle would get deleted */
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( lp->m_addr == NULL || lp->m_send_server == NULL || lp->m_send_port == 0 ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP bad parameters.");
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP bad parameters.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,7 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
|
||||
ths->m_hEtpan = mailsmtp_new(0, NULL);
|
||||
if( ths->m_hEtpan == NULL ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "SMTP-object creation failed.");
|
||||
dc_log_error(ths->m_context, 0, "SMTP-object creation failed.");
|
||||
goto cleanup;
|
||||
}
|
||||
mailsmtp_set_timeout(ths->m_hEtpan, MR_SMTP_TIMEOUT_SEC);
|
||||
|
@ -134,14 +134,14 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
if( lp->m_server_flags&(MR_SMTP_SOCKET_STARTTLS|MR_SMTP_SOCKET_PLAIN) )
|
||||
{
|
||||
if( (r=mailsmtp_socket_connect(ths->m_hEtpan, lp->m_send_server, lp->m_send_port)) != MAILSMTP_NO_ERROR ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-Socket connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP-Socket connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( (r=mailsmtp_ssl_connect(ths->m_hEtpan, lp->m_send_server, lp->m_send_port)) != MAILSMTP_NO_ERROR ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMPT-SSL connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMPT-SSL connection to %s:%i failed (%s)", lp->m_send_server, (int)lp->m_send_port, mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -156,14 +156,14 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
}
|
||||
|
||||
if( r != MAILSMTP_NO_ERROR ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( lp->m_server_flags&MR_SMTP_SOCKET_STARTTLS )
|
||||
{
|
||||
if( (r=mailsmtp_socket_starttls(ths->m_hEtpan)) != MAILSMTP_NO_ERROR ) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-STARTTLS failed (%s)", mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP-STARTTLS failed (%s)", mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -176,18 +176,18 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
}
|
||||
|
||||
if (r != MAILSMTP_NO_ERROR) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP-helo failed (%s)", mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i STARTTLS-connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
dc_log_info(ths->m_context, 0, "SMTP-server %s:%i STARTTLS-connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
}
|
||||
else if( lp->m_server_flags&MR_SMTP_SOCKET_PLAIN )
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
dc_log_info(ths->m_context, 0, "SMTP-server %s:%i connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
}
|
||||
else
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "SMTP-server %s:%i SSL-connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
dc_log_info(ths->m_context, 0, "SMTP-server %s:%i SSL-connected.", lp->m_send_server, (int)lp->m_send_port);
|
||||
}
|
||||
|
||||
if( lp->m_send_user )
|
||||
|
@ -198,25 +198,25 @@ int dc_smtp_connect(dc_smtp_t* ths, const dc_loginparam_t* lp)
|
|||
* So here we try a workaround. See https://github.com/deltachat/deltachat-android/issues/67
|
||||
*/
|
||||
if (ths->m_hEtpan->auth & MAILSMTP_AUTH_PLAIN) {
|
||||
dc_log_info(ths->m_mailbox, 0, "Trying SMTP-Login workaround \"%s\"...", lp->m_send_user);
|
||||
dc_log_info(ths->m_context, 0, "Trying SMTP-Login workaround \"%s\"...", lp->m_send_user);
|
||||
int err;
|
||||
char hostname[513];
|
||||
|
||||
err = gethostname(hostname, sizeof(hostname));
|
||||
if (err < 0) {
|
||||
dc_log_error(ths->m_mailbox, 0, "SMTP-Login: Cannot get hostname.");
|
||||
dc_log_error(ths->m_context, 0, "SMTP-Login: Cannot get hostname.");
|
||||
goto cleanup;
|
||||
}
|
||||
r = mailesmtp_auth_sasl(ths->m_hEtpan, "PLAIN", hostname, NULL, NULL, NULL, lp->m_send_user, lp->m_send_pw, NULL);
|
||||
}
|
||||
if (r != MAILSMTP_NO_ERROR)
|
||||
{
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "SMTP-login failed for user %s (%s)", lp->m_send_user, mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "SMTP-login failed for user %s (%s)", lp->m_send_user, mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "SMTP-login as %s ok.", lp->m_send_user);
|
||||
dc_log_info(ths->m_context, 0, "SMTP-login as %s ok.", lp->m_send_user);
|
||||
}
|
||||
|
||||
success = 1;
|
||||
|
@ -276,7 +276,7 @@ int dc_smtp_send_msg(dc_smtp_t* ths, const clist* recipients, const char* data_n
|
|||
{
|
||||
// this error is very usual - we've simply lost the server connection and reconnect as soon as possible.
|
||||
// so, we do not log the first time this happens
|
||||
dc_log_error_if(&ths->m_log_usual_error, ths->m_mailbox, 0, "mailsmtp_mail: %s, %s (%i)", ths->m_from, mailsmtp_strerror(r), (int)r);
|
||||
dc_log_error_if(&ths->m_log_usual_error, ths->m_context, 0, "mailsmtp_mail: %s, %s (%i)", ths->m_from, mailsmtp_strerror(r), (int)r);
|
||||
ths->m_log_usual_error = 1;
|
||||
goto cleanup;
|
||||
}
|
||||
|
@ -289,7 +289,7 @@ int dc_smtp_send_msg(dc_smtp_t* ths, const clist* recipients, const char* data_n
|
|||
if( (r = (ths->m_esmtp?
|
||||
mailesmtp_rcpt(ths->m_hEtpan, rcpt, MAILSMTP_DSN_NOTIFY_FAILURE|MAILSMTP_DSN_NOTIFY_DELAY, NULL) :
|
||||
mailsmtp_rcpt(ths->m_hEtpan, rcpt))) != MAILSMTP_NO_ERROR) {
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_mailbox, 0, "mailsmtp_rcpt: %s: %s", rcpt, mailsmtp_strerror(r));
|
||||
dc_log_error_if(&ths->m_log_connect_errors, ths->m_context, 0, "mailsmtp_rcpt: %s: %s", rcpt, mailsmtp_strerror(r));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,10 +41,10 @@ typedef struct dc_smtp_t
|
|||
int m_log_connect_errors;
|
||||
int m_log_usual_error;
|
||||
|
||||
mrmailbox_t* m_mailbox; /* only for logging! */
|
||||
dc_context_t* m_context; /* only for logging! */
|
||||
} dc_smtp_t;
|
||||
|
||||
dc_smtp_t* dc_smtp_new (mrmailbox_t*);
|
||||
dc_smtp_t* dc_smtp_new (dc_context_t*);
|
||||
void dc_smtp_unref (dc_smtp_t*);
|
||||
int dc_smtp_is_connected (const dc_smtp_t*);
|
||||
int dc_smtp_connect (dc_smtp_t*, const dc_loginparam_t*);
|
||||
|
|
|
@ -52,8 +52,8 @@ void dc_sqlite3_log_error(dc_sqlite3_t* ths, const char* msg_format, ...)
|
|||
va_list va;
|
||||
|
||||
va_start(va, msg_format);
|
||||
msg = sqlite3_vmprintf(msg_format, va); if( msg == NULL ) { dc_log_error(ths->m_mailbox, 0, "Bad log format string \"%s\".", msg_format); }
|
||||
dc_log_error(ths->m_mailbox, 0, "%s SQLite says: %s", msg, ths->m_cobj? sqlite3_errmsg(ths->m_cobj) : notSetUp);
|
||||
msg = sqlite3_vmprintf(msg_format, va); if( msg == NULL ) { dc_log_error(ths->m_context, 0, "Bad log format string \"%s\".", msg_format); }
|
||||
dc_log_error(ths->m_context, 0, "%s SQLite says: %s", msg, ths->m_cobj? sqlite3_errmsg(ths->m_cobj) : notSetUp);
|
||||
sqlite3_free(msg);
|
||||
va_end(va);
|
||||
}
|
||||
|
@ -113,7 +113,7 @@ cleanup:
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
dc_sqlite3_t* dc_sqlite3_new(mrmailbox_t* mailbox)
|
||||
dc_sqlite3_t* dc_sqlite3_new(dc_context_t* mailbox)
|
||||
{
|
||||
dc_sqlite3_t* ths = NULL;
|
||||
int i;
|
||||
|
@ -122,7 +122,7 @@ dc_sqlite3_t* dc_sqlite3_new(mrmailbox_t* mailbox)
|
|||
exit(24); /* cannot allocate little memory, unrecoverable error */
|
||||
}
|
||||
|
||||
ths->m_mailbox = mailbox;
|
||||
ths->m_context = mailbox;
|
||||
|
||||
for( i = 0; i < PREDEFINED_CNT; i++ ) {
|
||||
ths->m_pd[i] = NULL;
|
||||
|
@ -158,18 +158,18 @@ int dc_sqlite3_open__(dc_sqlite3_t* ths, const char* dbfile, int flags)
|
|||
}
|
||||
|
||||
if( sqlite3_threadsafe() == 0 ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "Sqlite3 compiled thread-unsafe; this is not supported.");
|
||||
dc_log_error(ths->m_context, 0, "Sqlite3 compiled thread-unsafe; this is not supported.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if( ths->m_cobj ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "Cannot open, database \"%s\" already opened.", dbfile);
|
||||
dc_log_error(ths->m_context, 0, "Cannot open, database \"%s\" already opened.", dbfile);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// Force serialized mode (SQLITE_OPEN_FULLMUTEX) explicitly.
|
||||
// So, most of the explicit lock/unlocks on dc_sqlite3_t object are no longer needed.
|
||||
// However, locking is _also_ used for mrmailbox_t which _is_ still needed, so, we
|
||||
// However, locking is _also_ used for dc_context_t which _is_ still needed, so, we
|
||||
// should remove locks only if we're really sure.
|
||||
if( sqlite3_open_v2(dbfile, &ths->m_cobj,
|
||||
SQLITE_OPEN_FULLMUTEX | ((flags&MR_OPEN_READONLY)? SQLITE_OPEN_READONLY : (SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE)),
|
||||
|
@ -192,7 +192,7 @@ int dc_sqlite3_open__(dc_sqlite3_t* ths, const char* dbfile, int flags)
|
|||
/* Init tables to dbversion=0 */
|
||||
if( !dc_sqlite3_table_exists__(ths, "config") )
|
||||
{
|
||||
dc_log_info(ths->m_mailbox, 0, "First time init: creating tables in \"%s\".", dbfile);
|
||||
dc_log_info(ths->m_context, 0, "First time init: creating tables in \"%s\".", dbfile);
|
||||
|
||||
dc_sqlite3_execute__(ths, "CREATE TABLE config (id INTEGER PRIMARY KEY, keyname TEXT, value TEXT);");
|
||||
dc_sqlite3_execute__(ths, "CREATE INDEX config_index1 ON config (keyname);");
|
||||
|
@ -443,7 +443,7 @@ int dc_sqlite3_open__(dc_sqlite3_t* ths, const char* dbfile, int flags)
|
|||
{
|
||||
sqlite3_stmt* stmt = dc_sqlite3_prepare_v2_(ths, "SELECT addr FROM acpeerstates;");
|
||||
while( sqlite3_step(stmt) == SQLITE_ROW ) {
|
||||
dc_apeerstate_t* peerstate = dc_apeerstate_new(ths->m_mailbox);
|
||||
dc_apeerstate_t* peerstate = dc_apeerstate_new(ths->m_context);
|
||||
if( dc_apeerstate_load_by_addr__(peerstate, ths, (const char*)sqlite3_column_text(stmt, 0))
|
||||
&& dc_apeerstate_recalc_fingerprint(peerstate) ) {
|
||||
dc_apeerstate_save_to_db__(peerstate, ths, 0/*don't create*/);
|
||||
|
@ -454,7 +454,7 @@ int dc_sqlite3_open__(dc_sqlite3_t* ths, const char* dbfile, int flags)
|
|||
}
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Opened \"%s\" successfully.", dbfile);
|
||||
dc_log_info(ths->m_context, 0, "Opened \"%s\" successfully.", dbfile);
|
||||
return 1;
|
||||
|
||||
cleanup:
|
||||
|
@ -484,7 +484,7 @@ void dc_sqlite3_close__(dc_sqlite3_t* ths)
|
|||
ths->m_cobj = NULL;
|
||||
}
|
||||
|
||||
dc_log_info(ths->m_mailbox, 0, "Database closed."); /* We log the information even if not real closing took place; this is to detect logic errors. */
|
||||
dc_log_info(ths->m_context, 0, "Database closed."); /* We log the information even if not real closing took place; this is to detect logic errors. */
|
||||
}
|
||||
|
||||
|
||||
|
@ -550,7 +550,7 @@ int dc_sqlite3_table_exists__(dc_sqlite3_t* ths, const char* name)
|
|||
int sqlState;
|
||||
|
||||
if( (querystr=sqlite3_mprintf("PRAGMA table_info(%s)", name)) == NULL ) { /* this statement cannot be used with binded variables */
|
||||
dc_log_error(ths->m_mailbox, 0, "dc_sqlite3_table_exists_(): Out of memory.");
|
||||
dc_log_error(ths->m_context, 0, "dc_sqlite3_table_exists_(): Out of memory.");
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
|
@ -591,12 +591,12 @@ int dc_sqlite3_set_config__(dc_sqlite3_t* ths, const char* key, const char* valu
|
|||
sqlite3_stmt* stmt;
|
||||
|
||||
if( key == NULL ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "dc_sqlite3_set_config(): Bad parameter.");
|
||||
dc_log_error(ths->m_context, 0, "dc_sqlite3_set_config(): Bad parameter.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if( !dc_sqlite3_is_open(ths) ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "dc_sqlite3_set_config(): Database not ready.");
|
||||
dc_log_error(ths->m_context, 0, "dc_sqlite3_set_config(): Database not ready.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -621,7 +621,7 @@ int dc_sqlite3_set_config__(dc_sqlite3_t* ths, const char* key, const char* valu
|
|||
state=sqlite3_step(stmt);
|
||||
}
|
||||
else {
|
||||
dc_log_error(ths->m_mailbox, 0, "dc_sqlite3_set_config(): Cannot read value.");
|
||||
dc_log_error(ths->m_context, 0, "dc_sqlite3_set_config(): Cannot read value.");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -634,7 +634,7 @@ int dc_sqlite3_set_config__(dc_sqlite3_t* ths, const char* key, const char* valu
|
|||
}
|
||||
|
||||
if( state != SQLITE_DONE ) {
|
||||
dc_log_error(ths->m_mailbox, 0, "dc_sqlite3_set_config(): Cannot change value.");
|
||||
dc_log_error(ths->m_context, 0, "dc_sqlite3_set_config(): Cannot change value.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -704,13 +704,13 @@ void dc_sqlite3_lock(dc_sqlite3_t* ths) /* wait and lock */
|
|||
{
|
||||
#ifdef MR_USE_LOCK_DEBUG
|
||||
clock_t start = clock();
|
||||
dc_log_info(ths->m_mailbox, 0, " waiting for lock at %s#L%i", filename, linenum);
|
||||
dc_log_info(ths->m_context, 0, " waiting for lock at %s#L%i", filename, linenum);
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&ths->m_critical_);
|
||||
|
||||
#ifdef MR_USE_LOCK_DEBUG
|
||||
dc_log_info(ths->m_mailbox, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
||||
dc_log_info(ths->m_context, 0, "{{{ LOCK AT %s#L%i after %.3f ms", filename, linenum, (double)(clock()-start)*1000.0/CLOCKS_PER_SEC);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -722,7 +722,7 @@ void dc_sqlite3_unlock(dc_sqlite3_t* ths)
|
|||
#endif
|
||||
{
|
||||
#ifdef MR_USE_LOCK_DEBUG
|
||||
dc_log_info(ths->m_mailbox, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
|
||||
dc_log_info(ths->m_context, 0, " UNLOCK AT %s#L%i }}}", filename, linenum);
|
||||
#endif
|
||||
|
||||
pthread_mutex_unlock(&ths->m_critical_);
|
||||
|
|
|
@ -160,13 +160,13 @@ typedef struct dc_sqlite3_t
|
|||
sqlite3_stmt* m_pd[PREDEFINED_CNT]; /**< prepared statements - this is the favourite way for the caller to use SQLite */
|
||||
sqlite3* m_cobj; /**< is the database given as dbfile to Open() */
|
||||
int m_transactionCount; /**< helper for transactions */
|
||||
mrmailbox_t* m_mailbox; /**< used for logging and to acquire wakelocks, there may be N dc_sqlite3_t objects per mrmailbox! In practise, we use 2 on backup, 1 otherwise. */
|
||||
dc_context_t* m_context; /**< used for logging and to acquire wakelocks, there may be N dc_sqlite3_t objects per mrmailbox! In practise, we use 2 on backup, 1 otherwise. */
|
||||
pthread_mutex_t m_critical_; /**< the user must make sure, only one thread uses sqlite at the same time! for this purpose, all calls must be enclosed by a locked m_critical; use dc_sqlite3_lock() for this purpose */
|
||||
|
||||
} dc_sqlite3_t;
|
||||
|
||||
|
||||
dc_sqlite3_t* dc_sqlite3_new (mrmailbox_t*);
|
||||
dc_sqlite3_t* dc_sqlite3_new (dc_context_t*);
|
||||
void dc_sqlite3_unref (dc_sqlite3_t*);
|
||||
|
||||
#define MR_OPEN_READONLY 0x01
|
||||
|
|
|
@ -33,7 +33,7 @@ errors from here. */
|
|||
******************************************************************************/
|
||||
|
||||
|
||||
mrmailbox_t* s_localize_mb_obj = NULL;
|
||||
dc_context_t* s_localize_mb_obj = NULL;
|
||||
|
||||
|
||||
static char* default_string(int id, int qty)
|
||||
|
|
|
@ -72,8 +72,8 @@ extern "C" {
|
|||
#define MR_STR_SELFTALK_SUBTITLE 50
|
||||
|
||||
|
||||
/* should be set up by mrmailbox_new() */
|
||||
extern mrmailbox_t* s_localize_mb_obj;
|
||||
/* should be set up by dc_context_new() */
|
||||
extern dc_context_t* s_localize_mb_obj;
|
||||
|
||||
|
||||
/* Return the string with the given ID by calling DC_EVENT_GET_STRING.
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
#include "dc_token.h"
|
||||
|
||||
|
||||
void mrtoken_save__(mrmailbox_t* mailbox, mrtokennamespc_t namespc, uint32_t foreign_id, const char* token)
|
||||
void mrtoken_save__(dc_context_t* mailbox, mrtokennamespc_t namespc, uint32_t foreign_id, const char* token)
|
||||
{
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
||||
|
@ -45,7 +45,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
char* mrtoken_lookup__(mrmailbox_t* mailbox, mrtokennamespc_t namespc, uint32_t foreign_id)
|
||||
char* mrtoken_lookup__(dc_context_t* mailbox, mrtokennamespc_t namespc, uint32_t foreign_id)
|
||||
{
|
||||
char* token = NULL;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
@ -68,7 +68,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mrtoken_exists__(mrmailbox_t* mailbox, mrtokennamespc_t namespc, const char* token)
|
||||
int mrtoken_exists__(dc_context_t* mailbox, mrtokennamespc_t namespc, const char* token)
|
||||
{
|
||||
int exists = 0;
|
||||
sqlite3_stmt* stmt = NULL;
|
||||
|
|
|
@ -35,9 +35,9 @@ typedef enum {
|
|||
|
||||
|
||||
// Functions to read/write token from/to the database. A token is any string associated with a key.
|
||||
void mrtoken_save__ (mrmailbox_t*, mrtokennamespc_t, uint32_t foreign_id, const char* token);
|
||||
char* mrtoken_lookup__ (mrmailbox_t*, mrtokennamespc_t, uint32_t foreign_id);
|
||||
int mrtoken_exists__ (mrmailbox_t*, mrtokennamespc_t, const char* token);
|
||||
void mrtoken_save__ (dc_context_t*, mrtokennamespc_t, uint32_t foreign_id, const char* token);
|
||||
char* mrtoken_lookup__ (dc_context_t*, mrtokennamespc_t, uint32_t foreign_id);
|
||||
int mrtoken_exists__ (dc_context_t*, mrtokennamespc_t, const char* token);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
@ -1018,7 +1018,7 @@ char* mr_get_filename(const char* pathNfilename)
|
|||
}
|
||||
|
||||
|
||||
int mr_delete_file(const char* pathNfilename, mrmailbox_t* log/*may be NULL*/)
|
||||
int mr_delete_file(const char* pathNfilename, dc_context_t* log/*may be NULL*/)
|
||||
{
|
||||
if( pathNfilename==NULL ) {
|
||||
return 0;
|
||||
|
@ -1033,7 +1033,7 @@ int mr_delete_file(const char* pathNfilename, mrmailbox_t* log/*may be NULL*/)
|
|||
}
|
||||
|
||||
|
||||
int mr_copy_file(const char* src, const char* dest, mrmailbox_t* log/*may be NULL*/)
|
||||
int mr_copy_file(const char* src, const char* dest, dc_context_t* log/*may be NULL*/)
|
||||
{
|
||||
int success = 0, fd_src = -1, fd_dest = -1;
|
||||
#define MR_COPY_BUF_SIZE 4096
|
||||
|
@ -1081,7 +1081,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mr_create_folder(const char* pathNfilename, mrmailbox_t* log)
|
||||
int mr_create_folder(const char* pathNfilename, dc_context_t* log)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(pathNfilename, &st) == -1) {
|
||||
|
@ -1178,7 +1178,7 @@ cleanup:
|
|||
}
|
||||
|
||||
|
||||
int mr_write_file(const char* pathNfilename, const void* buf, size_t buf_bytes, mrmailbox_t* log)
|
||||
int mr_write_file(const char* pathNfilename, const void* buf, size_t buf_bytes, dc_context_t* log)
|
||||
{
|
||||
int success = 0;
|
||||
|
||||
|
@ -1200,7 +1200,7 @@ int mr_write_file(const char* pathNfilename, const void* buf, size_t buf_bytes,
|
|||
}
|
||||
|
||||
|
||||
int mr_read_file(const char* pathNfilename, void** buf, size_t* buf_bytes, mrmailbox_t* log)
|
||||
int mr_read_file(const char* pathNfilename, void** buf, size_t* buf_bytes, dc_context_t* log)
|
||||
{
|
||||
int success = 0;
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
|
||||
/* Some tools and enhancements to the used libraries, there should be
|
||||
no references to mrmailbox_t and other "larger" classes here. */
|
||||
no references to dc_context_t and other "larger" classes here. */
|
||||
|
||||
|
||||
#ifndef __MRTOOLS_H__
|
||||
|
@ -97,11 +97,11 @@ char* mr_extract_grpid_from_rfc724_mid_list(const clist* rfc724_mid_list);
|
|||
int mr_file_exist (const char* pathNfilename);
|
||||
uint64_t mr_get_filebytes (const char* pathNfilename);
|
||||
char* mr_get_filename (const char* pathNfilename); /* the return value must be free()'d */
|
||||
int mr_delete_file (const char* pathNFilename, mrmailbox_t* log);
|
||||
int mr_copy_file (const char* src_pathNFilename, const char* dest_pathNFilename, mrmailbox_t* log);
|
||||
int mr_create_folder (const char* pathNfilename, mrmailbox_t* log);
|
||||
int mr_write_file (const char* pathNfilename, const void* buf, size_t buf_bytes, mrmailbox_t* log);
|
||||
int mr_read_file (const char* pathNfilename, void** buf, size_t* buf_bytes, mrmailbox_t* log);
|
||||
int mr_delete_file (const char* pathNFilename, dc_context_t* log);
|
||||
int mr_copy_file (const char* src_pathNFilename, const char* dest_pathNFilename, dc_context_t* log);
|
||||
int mr_create_folder (const char* pathNfilename, dc_context_t* log);
|
||||
int mr_write_file (const char* pathNfilename, const void* buf, size_t buf_bytes, dc_context_t* log);
|
||||
int mr_read_file (const char* pathNfilename, void** buf, size_t* buf_bytes, dc_context_t* log);
|
||||
char* mr_get_filesuffix_lc (const char* pathNfilename); /* the returned suffix is lower-case */
|
||||
void mr_split_filename (const char* pathNfilename, char** ret_basename, char** ret_all_suffixes_incl_dot); /* the case of the suffix is preserved! */
|
||||
int mr_get_filemeta (const void* buf, size_t buf_bytes, uint32_t* ret_width, uint32_t *ret_height);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue