text stringlengths 0 357 |
|---|
char* old_fwd = dc_param_get(msg->param, DC_PARAM_PREP_FORWARDS, ""); |
char* new_fwd = dc_mprintf("%s %d", old_fwd, new_msg_id); |
dc_param_set(msg->param, DC_PARAM_PREP_FORWARDS, new_fwd); |
dc_msg_save_param_to_disk(msg); |
free(new_fwd); |
free(old_fwd); |
} |
msg->param = save_param; |
} |
else { |
msg->state = DC_STATE_OUT_PENDING; |
new_msg_id = prepare_msg_raw(context, chat, msg, curr_timestamp++); |
dc_job_send_msg(context, new_msg_id); |
} |
carray_add(created_db_entries, (void*)(uintptr_t)chat_id, NULL); |
carray_add(created_db_entries, (void*)(uintptr_t)new_msg_id, NULL); |
} |
dc_sqlite3_commit(context->sql); |
transaction_pending = 0; |
cleanup: |
if (transaction_pending) { dc_sqlite3_rollback(context->sql); } |
if (created_db_entries) { |
size_t i, icnt = carray_count(created_db_entries); |
for (i = 0; i < icnt; i += 2) { |
context->cb(context, DC_EVENT_MSGS_CHANGED, (uintptr_t)carray_get(created_db_entries, i), (uintptr_t)carray_get(created_db_entries, i+1)); |
} |
carray_free(created_db_entries); |
} |
dc_contact_unref(contact); |
dc_msg_unref(msg); |
dc_chat_unref(chat); |
sqlite3_finalize(stmt); |
free(idsstr); |
sqlite3_free(q3); |
dc_param_unref(original_param); |
} |
``` |
Filename: dc_chatlist.c |
```c |
#include "dc_context.h" |
#define DC_CHATLIST_MAGIC 0xc4a71157 |
/** |
* Create a chatlist object in memory. |
* |
* @private @memberof dc_chatlist_t |
* @param context The context that should be stored in the chatlist object. |
* @return New and empty chatlist object, must be freed using dc_chatlist_unref(). |
*/ |
dc_chatlist_t* dc_chatlist_new(dc_context_t* context) |
{ |
dc_chatlist_t* chatlist = NULL; |
if ((chatlist=calloc(1, sizeof(dc_chatlist_t)))==NULL) { |
exit(20); |
} |
chatlist->magic = DC_CHATLIST_MAGIC; |
chatlist->context = context; |
if ((chatlist->chatNlastmsg_ids=dc_array_new(context, 128))==NULL) { |
exit(32); |
} |
return chatlist; |
} |
/** |
* Free a chatlist object. |
* |
* @memberof dc_chatlist_t |
* @param chatlist The chatlist object to free, created eg. by dc_get_chatlist(), dc_search_msgs(). |
* If NULL is given, nothing is done. |
* @return None. |
*/ |
void dc_chatlist_unref(dc_chatlist_t* chatlist) |
{ |
if (chatlist==NULL || chatlist->magic!=DC_CHATLIST_MAGIC) { |
return; |
} |
dc_chatlist_empty(chatlist); |
dc_array_unref(chatlist->chatNlastmsg_ids); |
chatlist->magic = 0; |
free(chatlist); |
} |
/** |
* Empty a chatlist object. |
* |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.