text stringlengths 0 357 |
|---|
* @memberof dc_context_t |
* @param context The context object as created by dc_context_new() |
* @param msg_ids an array of uint32_t containing all message IDs that should be deleted |
* @param msg_cnt The number of messages IDs in the msg_ids array |
* @return None. |
*/ |
void dc_delete_msgs(dc_context_t* context, const uint32_t* msg_ids, int msg_cnt) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || msg_ids==NULL || msg_cnt<=0) { |
return; |
} |
dc_sqlite3_begin_transaction(context->sql); |
for (int i = 0; i < msg_cnt; i++) |
{ |
dc_update_msg_chat_id(context, msg_ids[i], DC_CHAT_ID_TRASH); |
dc_job_add(context, DC_JOB_DELETE_MSG_ON_IMAP, msg_ids[i], NULL, 0); |
} |
dc_sqlite3_commit(context->sql); |
if (msg_cnt) { |
context->cb(context, DC_EVENT_MSGS_CHANGED, 0, 0); |
dc_job_kill_action(context, DC_JOB_HOUSEKEEPING); |
dc_job_add(context, DC_JOB_HOUSEKEEPING, 0, NULL, DC_HOUSEKEEPING_DELAY_SEC); |
} |
} |
/******************************************************************************* |
* mark message as seen |
******************************************************************************/ |
/** |
* Mark a message as _seen_, updates the IMAP state and |
* sends MDNs. If the message is not in a real chat (eg. a contact request), the |
* message is only marked as NOTICED and no IMAP/MDNs is done. See also |
* dc_marknoticed_chat() and dc_marknoticed_contact() |
* |
* @memberof dc_context_t |
* @param context The context object. |
* @param msg_ids An array of uint32_t containing all the messages IDs that should be marked as seen. |
* @param msg_cnt The number of message IDs in msg_ids. |
* @return None. |
*/ |
void dc_markseen_msgs(dc_context_t* context, const uint32_t* msg_ids, int msg_cnt) |
{ |
int transaction_pending = 0; |
int i = 0; |
int send_event = 0; |
int curr_state = 0; |
int curr_blocked = 0; |
sqlite3_stmt* stmt = NULL; |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || msg_ids==NULL || msg_cnt<=0) { |
goto cleanup; |
} |
dc_sqlite3_begin_transaction(context->sql); |
transaction_pending = 1; |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT m.state, c.blocked " |
" FROM msgs m " |
" LEFT JOIN chats c ON c.id=m.chat_id " |
" WHERE m.id=? AND m.chat_id>" DC_STRINGIFY(DC_CHAT_ID_LAST_SPECIAL)); |
for (i = 0; i < msg_cnt; i++) |
{ |
sqlite3_reset(stmt); |
sqlite3_bind_int(stmt, 1, msg_ids[i]); |
if (sqlite3_step(stmt)!=SQLITE_ROW) { |
continue; |
} |
curr_state = sqlite3_column_int(stmt, 0); |
curr_blocked = sqlite3_column_int(stmt, 1); |
if (curr_blocked==0) |
{ |
if (curr_state==DC_STATE_IN_FRESH || curr_state==DC_STATE_IN_NOTICED) { |
dc_update_msg_state(context, msg_ids[i], DC_STATE_IN_SEEN); |
dc_log_info(context, 0, "Seen message #%i.", msg_ids[i]); |
dc_job_add(context, DC_JOB_MARKSEEN_MSG_ON_IMAP, msg_ids[i], NULL, 0); |
send_event = 1; |
} |
} |
else |
{ |
/* message may be in contact requests, mark as NOTICED, this does not force IMAP updated nor send MDNs */ |
if (curr_state==DC_STATE_IN_FRESH) { |
dc_update_msg_state(context, msg_ids[i], DC_STATE_IN_NOTICED); |
send_event = 1; |
} |
} |
} |
dc_sqlite3_commit(context->sql); |
transaction_pending = 0; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.