forked from mirrors/linphone-iphone
Rework of non-native contacts: fix bug that would not display sip adresses in detail view, and fix bug that would lose the “createdFromLdapOrProvisioning” tag of non-native contacts after first launch.
This commit is contained in:
parent
06cbe9fa1d
commit
50f656d1ee
5 changed files with 43 additions and 25 deletions
|
|
@ -58,4 +58,6 @@
|
|||
- (BOOL)removeSipAddressAtIndex:(NSInteger)index;
|
||||
- (BOOL)removePhoneNumberAtIndex:(NSInteger)index;
|
||||
- (BOOL)removeEmailAtIndex:(NSInteger)index;
|
||||
|
||||
- (NSMutableArray*)getSipAddressesWithoutDuplicatePhoneNumbers;
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -488,4 +488,23 @@
|
|||
_friend = NULL;
|
||||
}
|
||||
|
||||
- (NSMutableArray*)getSipAddressesWithoutDuplicatePhoneNumbers {
|
||||
NSMutableArray* resAdresses = [[NSMutableArray alloc] init];
|
||||
|
||||
for (NSString *address in _sipAddresses) {
|
||||
LinphoneAddress *addr = linphone_core_interpret_url_2(LC, [address UTF8String], YES);
|
||||
bool isFoundInPhones = false;
|
||||
if (addr) {
|
||||
for (NSString *phoneNb in _phones) {
|
||||
if ([phoneNb isEqualToString:[NSString stringWithUTF8String:linphone_address_get_username(addr)]]) {
|
||||
isFoundInPhones = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!isFoundInPhones) [resAdresses addObject:address];
|
||||
}
|
||||
|
||||
return resAdresses;
|
||||
}
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -160,15 +160,15 @@
|
|||
/*first and last name only when editting */
|
||||
return (self.tableView.isEditing) ? 1 : 0;
|
||||
} else if (section == ContactSections_Sip) {
|
||||
return _contact.createdFromLdapOrProvisioning ? 0 : _contact.sipAddresses.count;
|
||||
return [_contact getSipAddressesWithoutDuplicatePhoneNumbers].count;
|
||||
} else if (section == ContactSections_Number) {
|
||||
return _contact.phones.count;
|
||||
} else if (section == ContactSections_Email) {
|
||||
BOOL showEmails = [LinphoneManager.instance
|
||||
lpConfigBoolForKey:@"show_contacts_emails_preference"];
|
||||
return showEmails ? _contact.emails.count : 0;
|
||||
}
|
||||
return 0;
|
||||
return _contact.phones.count;
|
||||
} else if (section == ContactSections_Email) {
|
||||
BOOL showEmails = [LinphoneManager.instance
|
||||
lpConfigBoolForKey:@"show_contacts_emails_preference"];
|
||||
return showEmails ? _contact.emails.count : 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
|
||||
|
|
|
|||
|
|
@ -57,22 +57,26 @@
|
|||
[NSString stringWithFormat:NSLocalizedString(@"Chat with %@", nil), _addressLabel.text];
|
||||
_callButton.accessibilityLabel = [NSString stringWithFormat:NSLocalizedString(@"Call %@", nil), _addressLabel.text];
|
||||
// Test presence
|
||||
Contact *contact;
|
||||
contact = addr ? [FastAddressBook getContactWithAddress:(addr)] : NULL;
|
||||
|
||||
Contact *contact = addr ? [FastAddressBook getContactWithAddress:(addr)] : NULL;
|
||||
LinphoneFriend *contactFriend = NULL;
|
||||
if (contact && contact.friend) {
|
||||
contactFriend = contact.friend;
|
||||
} else if (addr) {
|
||||
contactFriend = linphone_core_find_friend(LC, addr);
|
||||
}
|
||||
|
||||
ContactDetailsView *contactDetailsView = VIEW(ContactDetailsView);
|
||||
_linphoneImage.hidden = TRUE;
|
||||
if (contact) {
|
||||
const LinphonePresenceModel *model = contact.friend ? linphone_friend_get_presence_model_for_uri_or_tel(contact.friend, _addressLabel.text.UTF8String) : NULL;
|
||||
|
||||
if (contactFriend) {
|
||||
const LinphonePresenceModel *model = contactFriend ? linphone_friend_get_presence_model_for_uri_or_tel(contactFriend, _addressLabel.text.UTF8String) : NULL;
|
||||
|
||||
self.linphoneImage.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"hide_linphone_contacts" inSection:@"app"] ||
|
||||
!((model && linphone_presence_model_get_basic_status(model) == LinphonePresenceBasicStatusOpen) ||
|
||||
(account && !linphone_account_is_phone_number(account,
|
||||
_addressLabel.text.UTF8String) &&
|
||||
[FastAddressBook isSipURIValid:_addressLabel.text]));
|
||||
ContactDetailsView *contactDetailsView = VIEW(ContactDetailsView);
|
||||
self.inviteButton.hidden = !ENABLE_SMS_INVITE || [[contactDetailsView.contact sipAddresses] count] > 0 || !self.linphoneImage.hidden;
|
||||
self.inviteButton.hidden = !ENABLE_SMS_INVITE || [[contactDetailsView.contact sipAddresses] count] > 0 || !self.linphoneImage.hidden;
|
||||
[self shouldHideEncryptedChatView:account && linphone_account_params_get_conference_factory_uri(linphone_account_get_params(account)) && model && linphone_presence_model_has_capability(model, LinphoneFriendCapabilityLimeX3dh)];
|
||||
|
||||
_chatButton.hidden = [LinphoneManager.instance lpConfigBoolForKey:@"force_lime_chat_rooms"];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@
|
|||
// above)
|
||||
if (linphone_friend_get_ref_key(f) == NULL) {
|
||||
Contact *contact = [[Contact alloc] initWithFriend:f];
|
||||
contact.createdFromLdapOrProvisioning = true;
|
||||
[self registerAddrsFor:contact];
|
||||
}
|
||||
friends = friends->next;
|
||||
|
|
@ -210,14 +211,6 @@
|
|||
[_addressBookMap removeAllObjects];
|
||||
_addressBookMap = [NSMutableDictionary dictionary];
|
||||
|
||||
LinphoneFriend *testFriend = linphone_core_create_friend(LC);
|
||||
linphone_friend_set_name(testFriend, "Moi Maisentest");
|
||||
linphone_friend_set_native_uri(testFriend, "sip:pouetpouet@sip.linphone.org");
|
||||
const MSList *lists = linphone_core_get_friends_lists(LC);
|
||||
LinphoneFriendList *fl = lists->data;
|
||||
linphone_friend_list_add_friend(fl, testFriend);
|
||||
const MSList *friends = linphone_friend_list_get_friends(fl);
|
||||
|
||||
if ([LinphoneManager.instance lpConfigBoolForKey:@"enable_native_address_book"]) {
|
||||
CNEntityType entityType = CNEntityTypeContacts;
|
||||
[store requestAccessForEntityType:entityType completionHandler:^(BOOL granted, NSError *_Nullable error) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue