mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
continue integration of magic search bar
This commit is contained in:
parent
a16577eafd
commit
42b09ad3ef
1 changed files with 20 additions and 20 deletions
|
|
@ -15,8 +15,6 @@
|
|||
@interface ChatConversationCreateTableView ()
|
||||
|
||||
@property(nonatomic, strong) NSMutableArray *addresses;
|
||||
@property(nonatomic, strong) NSDictionary *allContacts;
|
||||
@property(nonatomic, strong) NSArray *sortedAddresses;
|
||||
@end
|
||||
|
||||
@implementation ChatConversationCreateTableView
|
||||
|
|
@ -69,29 +67,31 @@
|
|||
if (!_magicSearch)
|
||||
return;
|
||||
|
||||
bctbx_list_t *results = linphone_magic_search_get_contact_list_from_filter(_magicSearch, filter.UTF8String, "");
|
||||
bctbx_list_t *results = linphone_magic_search_get_contact_list_from_filter(_magicSearch, filter.UTF8String, _allFilter ? "" : "*");
|
||||
while (results) {
|
||||
LinphoneSearchResult *result = results->data;
|
||||
const LinphoneAddress *addr = linphone_search_result_get_address(result);
|
||||
const char *phoneNumber = linphone_search_result_get_phone_number(result);
|
||||
if (addr) {
|
||||
char *uri = linphone_address_as_string_uri_only(addr);
|
||||
NSString *address = [NSString stringWithUTF8String:uri];
|
||||
ms_free(uri);
|
||||
Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:address];
|
||||
NSString *name = [FastAddressBook displayNameForContact:contact];
|
||||
Boolean linphoneContact = [FastAddressBook contactHasValidSipDomain:contact]
|
||||
|| (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen);
|
||||
BOOL add = _allFilter || linphoneContact;
|
||||
|
||||
if (((filter.length == 0)
|
||||
|| ([name.lowercaseString containsSubstring:filter.lowercaseString])
|
||||
|| ([address.lowercaseString containsSubstring:filter.lowercaseString]))
|
||||
&& add)
|
||||
[_addresses addObject:address];
|
||||
} else if (phoneNumber) {
|
||||
|
||||
if (!addr) {
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char *normalizedPhoneNumber = linphone_proxy_config_normalize_phone_number(cfg, phoneNumber);
|
||||
addr = linphone_proxy_config_normalize_sip_uri(cfg, normalizedPhoneNumber);
|
||||
}
|
||||
char *uri = linphone_address_as_string_uri_only(addr);
|
||||
NSString *address = [NSString stringWithUTF8String:uri];
|
||||
ms_free(uri);
|
||||
Contact *contact = [LinphoneManager.instance.fastAddressBook.addressBookMap objectForKey:address];
|
||||
NSString *name = [FastAddressBook displayNameForContact:contact];
|
||||
Boolean linphoneContact = [FastAddressBook contactHasValidSipDomain:contact]
|
||||
|| (contact.friend && linphone_presence_model_get_basic_status(linphone_friend_get_presence_model(contact.friend)) == LinphonePresenceBasicStatusOpen);
|
||||
BOOL add = _allFilter || linphoneContact;
|
||||
|
||||
if (((filter.length == 0)
|
||||
|| ([name.lowercaseString containsSubstring:filter.lowercaseString])
|
||||
|| ([address.lowercaseString containsSubstring:filter.lowercaseString]))
|
||||
&& add)
|
||||
[_addresses addObject:address];
|
||||
|
||||
results = results->next;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue