text stringlengths 0 357 |
|---|
* @param height The new height to store in the message object. 0 if you do not want to change width and height. |
* @param duration The new duration to store in the message object. 0 if you do not want to change it. |
* @return None. |
*/ |
void dc_msg_latefiling_mediasize(dc_msg_t* msg, int width, int height, int duration) |
{ |
if (msg==NULL || msg->magic!=DC_MSG_MAGIC) { |
goto cleanup; |
} |
if (width>0 && height>0) { |
dc_param_set_int(msg->param, DC_PARAM_WIDTH, width); |
dc_param_set_int(msg->param, DC_PARAM_HEIGHT, height); |
} |
if (duration>0) { |
dc_param_set_int(msg->param, DC_PARAM_DURATION, duration); |
} |
dc_msg_save_param_to_disk(msg); |
cleanup: |
; |
} |
/******************************************************************************* |
* Context functions to work with messages |
******************************************************************************/ |
/* |
* Check if there is a record for the given msg_id |
* and that the record is not about to be deleted. |
*/ |
int dc_msg_exists(dc_context_t* context, uint32_t msg_id) |
{ |
int msg_exists = 0; |
sqlite3_stmt* stmt = NULL; |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC |
|| msg_id<=DC_MSG_ID_LAST_SPECIAL) { |
goto cleanup; |
} |
stmt = dc_sqlite3_prepare(context->sql, |
"SELECT chat_id FROM msgs WHERE id=?;"); |
sqlite3_bind_int(stmt, 1, msg_id); |
if (sqlite3_step(stmt)==SQLITE_ROW) |
{ |
uint32_t chat_id = sqlite3_column_int(stmt, 0); |
if (chat_id!=DC_CHAT_ID_TRASH) |
{ |
msg_exists = 1; |
} |
} |
cleanup: |
sqlite3_finalize(stmt); |
return msg_exists; |
} |
void dc_update_msg_chat_id(dc_context_t* context, uint32_t msg_id, uint32_t chat_id) |
{ |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"UPDATE msgs SET chat_id=? WHERE id=?;"); |
sqlite3_bind_int(stmt, 1, chat_id); |
sqlite3_bind_int(stmt, 2, msg_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
void dc_update_msg_state(dc_context_t* context, uint32_t msg_id, int state) |
{ |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"UPDATE msgs SET state=? WHERE id=?;"); |
sqlite3_bind_int(stmt, 1, state); |
sqlite3_bind_int(stmt, 2, msg_id); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
void dc_update_msg_move_state(dc_context_t* context, const char* rfc724_mid, dc_move_state_t state) |
{ |
// we update the move_state for all messages belonging to a given Message-ID |
// so that the state stay intact when parts are deleted |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"UPDATE msgs SET move_state=? WHERE rfc724_mid=?;"); |
sqlite3_bind_int (stmt, 1, state); |
sqlite3_bind_text(stmt, 2, rfc724_mid, -1, SQLITE_STATIC); |
sqlite3_step(stmt); |
sqlite3_finalize(stmt); |
} |
/** |
* Changes the state of PREPARING, PENDING or DELIVERED messages to DC_STATE_OUT_FAILED. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.