1
0
Fork 0
mirror of https://github.com/deltachat/deltachat-core.git synced 2025-10-04 18:29:19 +02:00

add a flag paramter to the get_contacts function

This commit is contained in:
B. Petersen 2018-04-18 16:54:01 +02:00
parent fe126f9628
commit 374f790b02
5 changed files with 18 additions and 7 deletions

View file

@ -1110,7 +1110,7 @@ char* mrmailbox_cmdline(mrmailbox_t* mailbox, const char* cmdline)
else if( strcmp(cmd, "listcontacts")==0 || strcmp(cmd, "contacts")==0 )
{
mrarray_t* contacts = mrmailbox_get_known_contacts(mailbox, arg1);
mrarray_t* contacts = mrmailbox_get_contacts(mailbox, 0, arg1);
if( contacts ) {
log_contactlist(mailbox, contacts);
ret = mr_mprintf("%i contacts.", (int)mrarray_get_cnt(contacts));

View file

@ -63,7 +63,7 @@ mrarray_t* mrarray_new(mrmailbox_t* mailbox, size_t initsize)
*
* @memberof mrarray_t
*
* @param array The array object to free, created eg. by mrmailbox_get_chatlist(), mrmailbox_get_known_contacts() and so on.
* @param array The array object to free, created eg. by mrmailbox_get_chatlist(), mrmailbox_get_contacts() and so on.
*
* @return None.
*

View file

@ -830,8 +830,8 @@ void mrmailbox_heartbeat(mrmailbox_t* mailbox)
* chats
* - if the flag MR_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
* F not needed when MR_GCL_ARCHIVED_ONLY is already set)
* not needed when MR_GCL_ARCHIVED_ONLY is already set)
*
* @param query An optional query for filtering the list. Only chats matching this query
* are returned. Give NULL for no filtering.
*
@ -3729,13 +3729,17 @@ cleanup:
*
* @param mailbox The mailbox object as created by mrmailbox_new().
*
* @param listflags A combination of flags:
* - if the flag MR_GCL_VERIFIED_ONLY is set, only verified contacts are returned.
* if MR_GCL_VERIFIED_ONLY is not set, verified and unverified contacts are returned.
*
* @param query A string to filter the list. Typically used to implement an
* incremental search. NULL for no filtering.
*
* @return An array containing all contact IDs. Must be mrarray_unref()'d
* after usage.
*/
mrarray_t* mrmailbox_get_known_contacts(mrmailbox_t* mailbox, const char* query)
mrarray_t* mrmailbox_get_contacts(mrmailbox_t* mailbox, uint32_t listflags, const char* query)
{
int locked = 0;
char* self_addr = NULL;
@ -3882,7 +3886,7 @@ cleanup:
/**
* Get a single contact object. For a list, see eg. mrmailbox_get_known_contacts().
* Get a single contact object. For a list, see eg. mrmailbox_get_contacts().
*
* For contact MR_CONTACT_ID_SELF (1), the function returns the name
* MR_STR_SELF (typically "Me" in the selected language) and the email address

View file

@ -278,7 +278,10 @@ mrmsg_t* mrmailbox_get_msg (mrmailbox_t*, uint32_t msg_id);
/* Handle contacts */
uint32_t mrmailbox_create_contact (mrmailbox_t*, const char* name, const char* addr);
int mrmailbox_add_address_book (mrmailbox_t*, const char*);
mrarray_t* mrmailbox_get_known_contacts (mrmailbox_t*, const char* query);
#define MR_GCL_VERIFIED_ONLY 0x01
mrarray_t* mrmailbox_get_contacts (mrmailbox_t*, uint32_t flags, const char* query);
int mrmailbox_get_blocked_count (mrmailbox_t*);
mrarray_t* mrmailbox_get_blocked_contacts (mrmailbox_t*);
void mrmailbox_block_contact (mrmailbox_t*, uint32_t contact_id, int block);

View file

@ -179,6 +179,10 @@ int mr_str_replace(char** haystack, const char* needle, const char* replacement)
int mr_str_contains(const char* haystack, const const char* needle)
{
/* case-insensitive search of needle in haystack, return 1 if found, 0 if not */
if( haystack==NULL || needle == NULL ) {
return 0;
}
if( strstr(haystack, needle)!=NULL ) {
return 1;
}