Apply hack of exchange to new contacts

This commit is contained in:
Benjamin Reis 2017-02-14 17:16:46 +01:00
parent c229ea3f0f
commit 6f109a3fc0
3 changed files with 26 additions and 6 deletions

View file

@ -21,6 +21,7 @@
@property(nonatomic, strong) NSMutableArray *sipAddresses;
@property(nonatomic, strong) NSMutableArray *emails;
@property(nonatomic, strong) NSMutableArray *phoneNumbers;
@property BOOL added;
- (void)setAvatar:(UIImage *)avatar;
- (UIImage *)avatar:(BOOL)thumbnail;

View file

@ -23,7 +23,7 @@
self = [super init];
_person = aperson;
_friend = afriend ? linphone_friend_ref(afriend) : NULL;
_added = FALSE;
if (_person) {
[self loadProperties];
@ -355,11 +355,8 @@
(NSString *)kABPersonInstantMessageUsernameKey : value,
(NSString *)kABPersonInstantMessageServiceKey : [LinphoneManager instance].contactSipField
};
// CFStringRef label = (__bridge CFStringRef)[[NSBundle mainBundle]
// objectForInfoDictionaryKey:@"CFBundleDisplayName"];
// ABMultiValueAddValueAndLabel(lMap, (__bridge CFTypeRef)lDict, label, nil);
ABMultiValueReplaceLabelAtIndex(lMap, (__bridge CFTypeRef)(lDict), index);
if (!ABRecordSetValue(_person, kABPersonInstantMessageProperty, lMap, &error)) {
if (![self replaceInProperty:kABPersonInstantMessageProperty value:(__bridge CFTypeRef)(lDict) atIndex:index]) {
LOGI(@"Can't set contact with value [%@] cause [%@]", value, [(__bridge NSError *)error localizedDescription]);
CFRelease(lMap);
} else {
@ -374,6 +371,9 @@
if ([lDict objectForKey:(__bridge NSString *)kABPersonInstantMessageServiceKey] == nil) {
/*too bad probably a gtalk number, storing uri*/
ret = [FastAddressBook normalizeSipURI:value];
} else if (!_added) {
_added = TRUE;
[LinphoneManager.instance.fastAddressBook saveContact:self];
}
CFRelease(lMap);
}

View file

@ -384,6 +384,25 @@ static UICompositeViewDescription *compositeDescription = nil;
}
[self saveData];
[self.tableController.tableView reloadData];
} else {
BOOL rm = TRUE;
for (NSString *sip in _contact.sipAddresses) {
if (![sip isEqualToString:@""]) {
rm = FALSE;
break;
}
}
if (rm) {
for (NSString *phone in _contact.phoneNumbers) {
if (![phone isEqualToString:@""]) {
rm = FALSE;
break;
}
}
}
if (rm) {
[LinphoneManager.instance.fastAddressBook removeContact:_contact];
}
}
[self setEditing:FALSE];