mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-23 06:08:07 +00:00
[CNContact] CNContact fix ChatConversationTableView crash on click new
This commit is contained in:
parent
8c0f1d2315
commit
ef10b65b12
2 changed files with 29 additions and 46 deletions
|
|
@ -156,27 +156,11 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
/*- (void)saveAddressBook {
|
||||
if (addressBook != nil) {
|
||||
if (!ABAddressBookSave(addressBook, nil)) {
|
||||
LOGW(@"Couldn't save Address Book");
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
-(void) updateAddressBook:(NSNotification*) notif {
|
||||
LOGD(@"address book has changed");
|
||||
self.needToUpdate = TRUE;
|
||||
//[self reloadAllContacts];
|
||||
}
|
||||
|
||||
/*- (void)reload {
|
||||
[self getAllContacts];
|
||||
LOGE(@"Create AddressBook failed");
|
||||
|
||||
}
|
||||
*/
|
||||
- (BOOL)reloadAllContacts {
|
||||
BOOL success = FALSE;
|
||||
if ([CNContactStore class]) {
|
||||
|
|
@ -209,8 +193,6 @@
|
|||
} else {
|
||||
Contact *newContact = [[Contact alloc]
|
||||
initWithCNContact:contact];
|
||||
[_addressBookMap setObject:newContact
|
||||
forKey:contact];
|
||||
[self registerAddrsFor:newContact];
|
||||
}
|
||||
}];
|
||||
|
|
|
|||
|
|
@ -454,35 +454,36 @@
|
|||
}
|
||||
|
||||
+ (LinphoneAddress *)normalizeSipOrPhoneAddress:(NSString *)value {
|
||||
if (!value) {
|
||||
return NULL;
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char * normvalue;
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
normvalue = linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String);
|
||||
} else {
|
||||
normvalue = value.UTF8String;
|
||||
}
|
||||
LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri(cfg, normvalue);
|
||||
// first try to find a friend with the given address
|
||||
Contact *c = [FastAddressBook getContactWithAddress:addr];
|
||||
if (!value || [value isEqualToString:@""]) {
|
||||
return NULL;
|
||||
}
|
||||
LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC);
|
||||
const char *normvalue;
|
||||
if (linphone_proxy_config_is_phone_number(cfg, value.UTF8String)) {
|
||||
normvalue =
|
||||
linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String);
|
||||
} else {
|
||||
normvalue = value.UTF8String;
|
||||
}
|
||||
LinphoneAddress *addr =
|
||||
linphone_proxy_config_normalize_sip_uri(cfg, normvalue);
|
||||
// first try to find a friend with the given address
|
||||
Contact *c = [FastAddressBook getContactWithAddress:addr];
|
||||
|
||||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
const LinphonePresenceModel *m =
|
||||
f ? linphone_friend_get_presence_model_for_uri_or_tel(
|
||||
f, value.UTF8String)
|
||||
: NULL;
|
||||
const char *contact =
|
||||
m ? linphone_presence_model_get_contact(m) : NULL;
|
||||
if (contact) {
|
||||
LinphoneAddress *contact_addr = linphone_address_new(contact);
|
||||
if (contact_addr) {
|
||||
linphone_address_destroy(addr);
|
||||
return contact_addr;
|
||||
}
|
||||
}
|
||||
if (c && c.friend) {
|
||||
LinphoneFriend *f = c.friend;
|
||||
const LinphonePresenceModel *m =
|
||||
f ? linphone_friend_get_presence_model_for_uri_or_tel(f,
|
||||
value.UTF8String)
|
||||
: NULL;
|
||||
const char *contact = m ? linphone_presence_model_get_contact(m) : NULL;
|
||||
if (contact) {
|
||||
LinphoneAddress *contact_addr = linphone_address_new(contact);
|
||||
if (contact_addr) {
|
||||
linphone_address_destroy(addr);
|
||||
return contact_addr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// since user wants to escape plus, we assume it expects to have phone
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue