text stringlengths 0 357 |
|---|
if (add_archived_link_item && dc_get_archived_cnt(chatlist->context)>0) |
{ |
if (dc_array_get_cnt(chatlist->chatNlastmsg_ids)==0 && (listflags & DC_GCL_ADD_ALLDONE_HINT)) { |
dc_array_add_id(chatlist->chatNlastmsg_ids, DC_CHAT_ID_ALLDONE_HINT); |
dc_array_add_id(chatlist->chatNlastmsg_ids, 0); |
} |
dc_array_add_id(chatlist->chatNlastmsg_ids, DC_CHAT_ID_ARCHIVED_LINK); |
dc_array_add_id(chatlist->chatNlastmsg_ids, 0); |
} |
chatlist->cnt = dc_array_get_cnt(chatlist->chatNlastmsg_ids)/DC_CHATLIST_IDS_PER_RESULT; |
success = 1; |
cleanup: |
//dc_log_info(chatlist->context, 0, "Chatlist for search \"%s\" created in %.3f ms.", query__?query__:"", (double)(clock()-start)*1000.0/CLOCKS_PER_SEC); |
sqlite3_finalize(stmt); |
free(query); |
free(strLikeCmd); |
return success; |
} |
/******************************************************************************* |
* Context functions to work with chatlists |
******************************************************************************/ |
int dc_get_archived_cnt(dc_context_t* context) |
{ |
int ret = 0; |
sqlite3_stmt* stmt = dc_sqlite3_prepare(context->sql, |
"SELECT COUNT(*) FROM chats WHERE blocked=0 AND archived=1;"); |
if (sqlite3_step(stmt)==SQLITE_ROW) { |
ret = sqlite3_column_int(stmt, 0); |
} |
sqlite3_finalize(stmt); |
return ret; |
} |
/** |
* Get a list of chats. |
* The list can be filtered by query parameters. |
* |
* The list is already sorted and starts with the most recent chat in use. |
* The sorting takes care of invalid sending dates, drafts and chats without messages. |
* Clients should not try to re-sort the list as this would be an expensive action |
* and would result in inconsistencies between clients. |
* |
* To get information about each entry, use eg. dc_chatlist_get_summary(). |
* |
* By default, the function adds some special entries to the list. |
* These special entries can be identified by the ID returned by dc_chatlist_get_chat_id(): |
* - DC_CHAT_ID_DEADDROP (1) - this special chat is present if there are |
* messages from addresses that have no relationship to the configured account. |
* The last of these messages is represented by DC_CHAT_ID_DEADDROP and you can retrieve details |
* about it with dc_chatlist_get_msg_id(). Typically, the UI asks the user "Do you want to chat with NAME?" |
* and offers the options "Yes" (call dc_create_chat_by_msg_id()), "Never" (call dc_block_contact()) |
* or "Not now". |
* The UI can also offer a "Close" button that calls dc_marknoticed_contact() then. |
* - DC_CHAT_ID_ARCHIVED_LINK (6) - this special chat is present if the user has |
* archived _any_ chat using dc_archive_chat(). The UI should show a link as |
* "Show archived chats", if the user clicks this item, the UI should show a |
* list of all archived chats that can be created by this function hen using |
* the DC_GCL_ARCHIVED_ONLY flag. |
* - DC_CHAT_ID_ALLDONE_HINT (7) - this special chat is present |
* if DC_GCL_ADD_ALLDONE_HINT is added to listflags |
* and if there are only archived chats. |
* |
* @memberof dc_context_t |
* @param context The context object as returned by dc_context_new() |
* @param listflags A combination of flags: |
* - if the flag DC_GCL_ARCHIVED_ONLY is set, only archived chats are returned. |
* if DC_GCL_ARCHIVED_ONLY is not set, only unarchived chats are returned and |
* the pseudo-chat DC_CHAT_ID_ARCHIVED_LINK is added if there are _any_ archived |
* chats |
* - if the flag DC_GCL_NO_SPECIALS is set, deaddrop and archive link are not added |
* to the list (may be used eg. for selecting chats on forwarding, the flag is |
* not needed when DC_GCL_ARCHIVED_ONLY is already set) |
* - if the flag DC_GCL_ADD_ALLDONE_HINT is set, DC_CHAT_ID_ALLDONE_HINT |
* is added as needed. |
* @param query_str An optional query for filtering the list. Only chats matching this query |
* are returned. Give NULL for no filtering. |
* @param query_id An optional contact ID for filtering the list. Only chats including this contact ID |
* are returned. Give 0 for no filtering. |
* @return A chatlist as an dc_chatlist_t object. |
* On errors, NULL is returned. |
* Must be freed using dc_chatlist_unref() when no longer used. |
* |
* See also: dc_get_chat_msgs() to get the messages of a single chat. |
*/ |
dc_chatlist_t* dc_get_chatlist(dc_context_t* context, int listflags, const char* query_str, uint32_t query_id) |
{ |
int success = 0; |
dc_chatlist_t* obj = dc_chatlist_new(context); |
if (context==NULL || context->magic!=DC_CONTEXT_MAGIC) { |
goto cleanup; |
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.