From 1e1c0fd3d3e00a58e53338087d0e8bf92dd61da5 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Thu, 3 Nov 2022 11:44:30 +0100 Subject: [PATCH] Fix magic search to also display contacts that were created through remote provisioning, not just LDAP or native --- Classes/ChatConversationCreateTableView.m | 4 ++-- Classes/Contact.h | 2 +- Classes/Contact.m | 2 +- Classes/ContactDetailsTableView.m | 4 ++-- Classes/ContactDetailsView.m | 8 ++++---- Classes/MagicSearch.swift | 7 ++++++- 6 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index e89c084f6..d50e94d39 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -136,7 +136,7 @@ address = [NSString stringWithUTF8String:uri]; contact = [[Contact alloc] initWithFriend:friend]; - [contact setCreatedFromLdap:TRUE]; + [contact setCreatedFromLdapOrProvisioning:TRUE]; [_ldapContactAddressBookMap setObject:contact forKey:address]; } @@ -221,7 +221,7 @@ BOOL greyCellForEncryptedChat = _isEncrypted ? capabilities > 1 : TRUE; BOOL greyCellForGroupChat = _isGroupChat ? capabilities > 0 : TRUE; cell.userInteractionEnabled = cell.greyView.hidden = greyCellForEncryptedChat && greyCellForGroupChat; - cell.displayNameLabel.text = [contact createdFromLdap] ? [contact displayName] : [FastAddressBook displayNameForAddress:addr]; + cell.displayNameLabel.text = [contact createdFromLdapOrProvisioning] ? [contact displayName] : [FastAddressBook displayNameForAddress:addr]; char *str = linphone_address_as_string(addr); cell.addressLabel.text = linphoneContact ? [NSString stringWithUTF8String:str] : phoneOrAddr; ms_free(str); diff --git a/Classes/Contact.h b/Classes/Contact.h index 603e66014..579a6ffa4 100644 --- a/Classes/Contact.h +++ b/Classes/Contact.h @@ -35,7 +35,7 @@ @property(nonatomic, strong) NSMutableArray *sipAddresses; @property(nonatomic, strong) NSMutableArray *emails; @property(nonatomic, strong) NSMutableArray *phones; -@property BOOL createdFromLdap; +@property BOOL createdFromLdapOrProvisioning; @property BOOL added; - (void)setAvatar:(UIImage *)avatar; diff --git a/Classes/Contact.m b/Classes/Contact.m index baa6d9ccd..5f289b1da 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -36,7 +36,7 @@ _person = acncontact; _friend = afriend ? linphone_friend_ref(afriend) : NULL; _added = FALSE; - _createdFromLdap = FALSE; + _createdFromLdapOrProvisioning = FALSE; _phones = [[NSMutableArray alloc] init]; _sipAddresses = [[NSMutableArray alloc] init]; _emails = [[NSMutableArray alloc] init]; diff --git a/Classes/ContactDetailsTableView.m b/Classes/ContactDetailsTableView.m index 81df785df..1e3037752 100644 --- a/Classes/ContactDetailsTableView.m +++ b/Classes/ContactDetailsTableView.m @@ -160,7 +160,7 @@ /*first and last name only when editting */ return (self.tableView.isEditing) ? 1 : 0; } else if (section == ContactSections_Sip) { - return _contact.createdFromLdap ? 0 : _contact.sipAddresses.count; + return _contact.createdFromLdapOrProvisioning ? 0 : _contact.sipAddresses.count; } else if (section == ContactSections_Number) { return _contact.phones.count; } else if (section == ContactSections_Email) { @@ -283,7 +283,7 @@ if (section == ContactSections_Number) { text = NSLocalizedString(@"Phone numbers", nil); addEntryName = NSLocalizedString(@"Add new phone number", nil); - } else if (section == ContactSections_Sip && !_contact.createdFromLdap) { + } else if (section == ContactSections_Sip && !_contact.createdFromLdapOrProvisioning) { text = NSLocalizedString(@"SIP addresses", nil); addEntryName = NSLocalizedString(@"Add new SIP address", nil); } else if (section == ContactSections_Email && diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 845f15134..7975b7e4c 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -119,8 +119,8 @@ _contact = acontact; _emptyLabel.hidden = (_contact != NULL); _avatarImage.hidden = !_emptyLabel.hidden; - _deleteButton.hidden = !_emptyLabel.hidden || [_contact createdFromLdap]; - _editButton.hidden = !_emptyLabel.hidden || [_contact createdFromLdap]; + _deleteButton.hidden = !_emptyLabel.hidden || [_contact createdFromLdapOrProvisioning]; + _editButton.hidden = !_emptyLabel.hidden || [_contact createdFromLdapOrProvisioning]; [_avatarImage setImage:[FastAddressBook imageForContact:_contact] bordered:NO withRoundedRadius:YES]; [ContactDisplay setDisplayNameLabel:_nameLabel forContact:_contact]; @@ -284,7 +284,7 @@ if (IPAD && self.contact == NULL) { _editButton.hidden = TRUE; _deleteButton.hidden = TRUE; - } else if (self.contact != NULL && self.contact.createdFromLdap) { + } else if (self.contact != NULL && self.contact.createdFromLdapOrProvisioning) { _editButton.hidden = TRUE; _deleteButton.hidden = TRUE; } @@ -314,7 +314,7 @@ } } - if (self.contact != NULL && self.contact.createdFromLdap) { + if (self.contact != NULL && self.contact.createdFromLdapOrProvisioning) { _editButton.hidden = TRUE; _deleteButton.hidden = TRUE; } diff --git a/Classes/MagicSearch.swift b/Classes/MagicSearch.swift index fb0629e8e..ae31303dc 100644 --- a/Classes/MagicSearch.swift +++ b/Classes/MagicSearch.swift @@ -65,7 +65,7 @@ import linphonesw if let friend = searchResult.friend { if (searchResult.sourceFlags == MagicSearchSource.LdapServers.rawValue), let newContact = Contact(friend: friend.getCobject) { // Contact comes from LDAP, creating a new one - newContact.createdFromLdap = true + newContact.createdFromLdapOrProvisioning = true return newContact } if let addr = friend.address, let foundContact = getContactFromAddr(addr: addr) { @@ -86,6 +86,11 @@ import linphonesw return foundContact } + // Friend comes from provisioning + if let addr = searchResult.address, let friend = searchResult.friend, let newContact = Contact(friend: friend.getCobject) { + newContact.createdFromLdapOrProvisioning = true + return newContact + } return nil }