From 28b403383d745273aeb881c9ecc00ba9338b0e0a Mon Sep 17 00:00:00 2001 From: Brieuc Viel Date: Mon, 13 Nov 2017 16:59:47 +0100 Subject: [PATCH] [CNContact] CNContact fix multiple contact edition crashes --- Classes/Contact.m | 20 ++++++++++------ Classes/ContactDetailsView.m | 5 +--- Classes/LinphoneManager.m | 10 ++++---- .../Base.lproj/UIChatBubblePhotoCell.strings | Bin 2366 -> 2870 bytes .../Base.lproj/UIChatBubbleTextCell.strings | Bin 1620 -> 2104 bytes Classes/Utils/FastAddressBook.m | 22 +++++++++++------- Resources/en.lproj/Localizable.strings | Bin 63436 -> 63890 bytes 7 files changed, 33 insertions(+), 24 deletions(-) diff --git a/Classes/Contact.m b/Classes/Contact.m index 8ee7bbf82..8fde471f9 100644 --- a/Classes/Contact.m +++ b/Classes/Contact.m @@ -468,12 +468,14 @@ - (BOOL)removeSipAddressAtIndex:(NSInteger)index { BOOL ret = FALSE; - if (_person) { + if (_person ) { NSMutableArray *> *tmpSipAddress = [_person.instantMessageAddresses mutableCopy]; - [tmpSipAddress removeObjectAtIndex:index]; - [_person setValue:tmpSipAddress - forKey:CNContactInstantMessageAddressesKey]; + if([tmpSipAddress count] > index){ + [tmpSipAddress removeObjectAtIndex:index]; + [_person setValue:tmpSipAddress + forKey:CNContactInstantMessageAddressesKey]; + } ret = TRUE; } else { LinphoneAddress *addr = linphone_core_interpret_url( @@ -498,8 +500,10 @@ if (_person && _person.phoneNumbers.count > 0) { NSMutableArray *> *tmpPhoneNumbers = [_person.phoneNumbers mutableCopy]; - [tmpPhoneNumbers removeObjectAtIndex:index]; - [_person setValue:tmpPhoneNumbers forKey:CNContactPhoneNumbersKey]; + if([tmpPhoneNumbers count] > index){ + [tmpPhoneNumbers removeObjectAtIndex:index]; + [_person setValue:tmpPhoneNumbers forKey:CNContactPhoneNumbersKey]; + } ret = TRUE; } else { const char *phone = ((NSString *)_phones[index]).UTF8String; @@ -517,12 +521,14 @@ - (BOOL)removeEmailAtIndex:(NSInteger)index { BOOL ret = FALSE; - if (_person) { + if (_person && _person.phoneNumbers.count > 0) { NSMutableArray *> *tmpEmailAddresses = [_person.emailAddresses mutableCopy]; + if([tmpEmailAddresses count] > index){ [tmpEmailAddresses removeObjectAtIndex:index]; [_person setValue:tmpEmailAddresses forKey:CNContactEmailAddressesKey]; + } ret = TRUE; } else { LOGW(@"%s: Cannot do it when using LinphoneFriend, skipping", diff --git a/Classes/ContactDetailsView.m b/Classes/ContactDetailsView.m index 16bccb61d..6d704500c 100644 --- a/Classes/ContactDetailsView.m +++ b/Classes/ContactDetailsView.m @@ -430,13 +430,10 @@ static UICompositeViewDescription *compositeDescription = nil; if (_tmpContact.emails != NULL) { while (_tmpContact.emails.count > nbEmail) { [_contact addEmail:_tmpContact.emails[nbEmail]]; - // [_contact - // addPhoneNumber:((CNLabeledValue*)_tmpContact.phoneNumbers[nbPhone]).value.stringValue]; nbEmail++; } } - [self saveData]; - //[self.tableController.tableView reloadData]; + // [self saveData]; } else { [LinphoneManager.instance.fastAddressBook deleteContact:_contact]; } diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index c0375b55e..8cdddd532 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -2361,10 +2361,12 @@ static int comp_call_state_paused(const LinphoneCall *call, const void *param) { } const MSList *lists = linphone_core_get_friends_lists(LC); - while (lists) { - linphone_friend_list_enable_subscriptions( - lists->data, enabled && [LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence"]); - lists = lists->next; + if(lists != nil){ + while (lists) { + linphone_friend_list_enable_subscriptions( + lists->data, enabled && [LinphoneManager.instance lpConfigBoolForKey:@"use_rls_presence"]); + lists = lists->next; + } } } diff --git a/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.strings b/Classes/LinphoneUI/Base.lproj/UIChatBubblePhotoCell.strings index bbc940d424f499501ce57e88299bea3e270ecca8..ba11c1c509fadfe0b855ac67bed4276d1b2b2433 100644 GIT binary patch delta 179 zcmdldv`uV+!sGxJfypJT0+XLH@lB3nQnEK;Fk#4I&}GPFNClFf422At3`z{v3ylW#LgPGZ*BsGz|%iK)TdhamuLS{OqJ&@=;vGzJee)3B+~ dn`o#yS%95qvH*+2L|UhEO2s$WY2q!l1-p&7i=b#h}l?1!QAUF?l1i;ba3g zmCZV=8jO>5Smh>5F)6SHF{CmiPHtpTjHqPrW^e%-SHR#5B>fmNfX1R4icN(c(CSo% X3a|qd7;J$~P+|a^$&dop&BXu!BKIEi delta 15 WcmdlXaD`{XDb~p%>>`ud*vkMfKm`B* diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index 29b101c92..d8fd9e41a 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -388,16 +388,20 @@ [[store unifiedContactWithIdentifier:contact.identifier keysToFetch:keysToFetch error:nil] mutableCopy]; - [mCNContact setGivenName:contact.firstName]; - [mCNContact setFamilyName:contact.lastName]; - [mCNContact setNickname:contact.displayName]; - [mCNContact setPhoneNumbers:contact.person.phoneNumbers]; - [mCNContact setEmailAddresses:contact.person.emailAddresses]; - [mCNContact - setInstantMessageAddresses:contact.person.instantMessageAddresses]; - [mCNContact setImageData:UIImageJPEGRepresentation(contact.avatar, 0.9f)]; + if(mCNContact == NULL){ + [saveRequest addContact:[cNContact mutableCopy] toContainerWithIdentifier:nil]; + }else{ + [mCNContact setGivenName:contact.firstName]; + [mCNContact setFamilyName:contact.lastName]; + [mCNContact setNickname:contact.displayName]; + [mCNContact setPhoneNumbers:contact.person.phoneNumbers]; + [mCNContact setEmailAddresses:contact.person.emailAddresses]; + [mCNContact + setInstantMessageAddresses:contact.person.instantMessageAddresses]; + [mCNContact setImageData:UIImageJPEGRepresentation(contact.avatar, 0.9f)]; - [saveRequest updateContact:mCNContact]; + [saveRequest updateContact:mCNContact]; + } NSError *saveError; @try { NSLog(@"Success %d", diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 27ff2b32b38781752408000925d581107a031c30..2154467a9b397cc1617197233ede16f7ed315270 100644 GIT binary patch delta 1177 zcmbVLO=uHQ5PoZ7sc90E5VuK8H3q7e2(ePV)KZ}b4?*-`YE5mLKQWkYODY8+ioJ;F zMf^m15Y0)UcnCfZ;-P{<@en+UhZ5Q*mYkYuvY~i#-fC)UPYKI1J8!=E=FNPw`HJpw zRhRpE!Zgg1Y=%v<6pOH1_;Eapp;H6M_u2TpKKTG&I=5v+VAKu&B?k|T)+N3inw8*C zjVO$mF{WO@^thgHTz%T*j1fhOo+#NEyFs*G=3!@;2jOJz{{N!5XbSOY@~sWZ?InKa z?qvrq;5^@)cXZ&(;s6%1W;}W^2){ds&F5yk%es-bcJhVno5S4q>9q$#xsH7bn_@Sq zNCeW)-h*RIVIwR-z9^=UZNy`+dXHhPB4e;Cx=0)_s!2wer`=OVb-8T!N(`m3pvVw}|}yHuBjFR(nD`R~nY^e$Iu!OBpWJ4*z#O z7UyKmA6KIyrXxLJ{n!m(rV|?#Lj&{od=j~mS>$N`hs=>(m`Y}fFa|t$Xh)VG;z!p% zOKtY-Jey#X+MH6_R9c?fpT4#0$Yn3|dk?EMRib$Qgz_G;8=(&;2s z&**Rvq@SoZ?@2V+$vWHByl*++3jgs%yBH;6dm+bd2a(PZcGqb z^eWCvrr0$qI)U}adk~JfF_)8eU|#=>A)1pgRCWAql@r?)ws5M@#Hj|4<}#A!0?ji; zUy5nG