text stringlengths 0 357 |
|---|
{ |
char* eml = NULL; |
sqlite3_stmt* stmt = NULL; |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
goto cleanup; |
} |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT mime_headers FROM msgs WHERE id=?;"); |
sqlite3_bind_int(stmt, 1, msg_id); |
if (sqlite3_step(stmt)==SQLITE_ROW) { |
eml = dc_strdup_keep_null((const char*)sqlite3_column_text(stmt, 0)); |
} |
cleanup: |
sqlite3_finalize(stmt); |
return eml; |
} |
/** |
* Star/unstar messages by setting the last parameter to 0 (unstar) or 1 (star). |
* Starred messages are collected in a virtual chat that can be shown using |
* dc_get_chat_msgs() using the chat_id DC_CHAT_ID_STARRED. |
* |
* @memberof dc_context_t |
* @param context The context object as created by dc_context_new() |
* @param msg_ids An array of uint32_t message IDs defining the messages to star or unstar |
* @param msg_cnt The number of IDs in msg_ids |
* @param star 0=unstar the messages in msg_ids, 1=star them |
* @return None. |
*/ |
void dc_star_msgs(dc_context_t* context, const uint32_t* msg_ids, int msg_cnt, int star) |
{ |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC || msg_ids==NULL || msg_cnt<=0 || (star!=0 && star!=1)) { |
return; |
} |
dc_sqlite3_begin_transaction(context->sql); |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"UPDATE msgs SET starred=? WHERE id=?;"); |
for (int i = 0; i < msg_cnt; i++) |
{ |
sqlite3_reset(stmt); |
sqlite3_bind_int(stmt, 1, star); |
sqlite3_bind_int(stmt, 2, msg_ids[i]); |
sqlite3_step(stmt); |
} |
sqlite3_finalize(stmt); |
dc_sqlite3_commit(context->sql); |
} |
/******************************************************************************* |
* Delete messages |
******************************************************************************/ |
/** |
* Low-level function to delete a message from the database. |
* This does not delete the messages from the server. |
* |
* @private @memberof dc_context_t |
*/ |
void dc_delete_msg_from_db(dc_context_t* context, uint32_t msg_id) |
{ |
dc_msg_t* msg = dc_msg_new_untyped(context); |
sqlite3_stmt* stmt = NULL; |
if (!dc_msg_load_from_db(msg, context, msg_id)) { |
goto cleanup; |
} |
stmt = dc_sqlite3_prepare(context->sql, |
"DELETE FROM msgs WHERE id=?;"); |
sqlite3_bind_int(stmt, 1, msg->id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
stmt = NULL; |
stmt = dc_sqlite3_prepare(context->sql, |
"DELETE FROM msgs_mdns WHERE msg_id=?;"); |
sqlite3_bind_int(stmt, 1, msg->id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
stmt = NULL; |
cleanup: |
sqlite3_finalize(stmt); |
dc_msg_unref(msg); |
} |
/** |
* Delete messages. The messages are deleted on the current device and |
* on the IMAP server. |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.