mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-17 11:08:06 +00:00
Fix address book UserDefaults
This commit is contained in:
parent
a286d457db
commit
e98469ec9c
2 changed files with 20 additions and 4 deletions
|
|
@ -510,7 +510,7 @@
|
|||
LinphoneAddress *addr = linphone_address_new(name.UTF8String);
|
||||
|
||||
if (linphone_proxy_config_is_phone_number(cfg, linphone_address_get_username(addr))) {
|
||||
if (oldDisplayNames[name] != nil && oldDisplayNames[name] != [contact displayName]) {
|
||||
if (oldDisplayNames[name] != nil && [FastAddressBook isSipURI:oldDisplayNames[name]]) {
|
||||
NSString *addrForTel = [NSString stringWithString:oldDisplayNames[name]];
|
||||
/* we keep the link between tel number and sip addr to have the information quickly.
|
||||
If we don't do that, between the startup and presence callback we don't have the dispay name for this address */
|
||||
|
|
@ -533,6 +533,23 @@
|
|||
NSMutableDictionary *displayNames = [[NSMutableDictionary alloc] initWithDictionary:[defaults dictionaryForKey:@"addressBook"]];
|
||||
if (displayNames == nil) return;
|
||||
|
||||
LinphoneProxyConfig *cfg = linphone_core_create_proxy_config(LC);
|
||||
for (NSString *phone in contact.phones) {
|
||||
char *normalizedPhone = cfg? linphone_proxy_config_normalize_phone_number(linphone_core_get_default_proxy_config(LC), phone.UTF8String) : nil;
|
||||
NSString *name = [FastAddressBook normalizeSipURI:normalizedPhone ? [NSString stringWithUTF8String:normalizedPhone] : phone];
|
||||
if (phone != NULL) {
|
||||
if ([FastAddressBook isSipURI:displayNames[name]]) {
|
||||
LOGD(@"removed %s from userdefaults addressBook", ((NSString *)displayNames[name]).UTF8String);
|
||||
[displayNames removeObjectForKey:displayNames[name]];
|
||||
}
|
||||
[displayNames removeObjectForKey:name];
|
||||
LOGD(@"removed %s from userdefaults addressBook", ((NSString *)name).UTF8String);
|
||||
}
|
||||
|
||||
if (normalizedPhone)
|
||||
ms_free(normalizedPhone);
|
||||
}
|
||||
|
||||
NSMutableArray *addresses = contact.sipAddresses;
|
||||
for (id addr in addresses) {
|
||||
[displayNames removeObjectForKey:addr];
|
||||
|
|
@ -543,7 +560,6 @@
|
|||
}
|
||||
|
||||
- (void)onPresenceChanged:(NSNotification *)k {
|
||||
LinphoneFriend *f = [[k.userInfo valueForKey:@"friend"] pointerValue];
|
||||
NSString *uri = [NSString stringWithUTF8String:[[k.userInfo valueForKey:@"uri"] pointerValue]];
|
||||
if (![FastAddressBook isSipURI:uri]) {
|
||||
LOGD(@"presence changed for tel [%s]", uri.UTF8String);
|
||||
|
|
|
|||
|
|
@ -216,7 +216,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
let addressBook = defaults?.dictionary(forKey: "addressBook")
|
||||
|
||||
if (addressBook == nil) {
|
||||
NotificationService.log.message(msg: "address book not found in user defaults")
|
||||
NotificationService.log.message(msg: "address book not found in userDefaults")
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -224,7 +224,7 @@ class NotificationService: UNNotificationServiceExtension {
|
|||
NotificationService.log.message(msg: "display name for \(sipAddr): \(displayName)")
|
||||
return displayName
|
||||
} else {
|
||||
NotificationService.log.message(msg: "address book not found in user defaults")
|
||||
NotificationService.log.message(msg: "display name for \(sipAddr) not found in userDefaults")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue