[Contact] fix fetch Contact -> SIP service only ++

This commit is contained in:
Brieuc Viel 2018-01-17 15:59:38 +01:00
parent aa6587f92e
commit 321b3550be
3 changed files with 33 additions and 17 deletions

View file

@ -40,11 +40,14 @@
if (_person.instantMessageAddresses != NULL) {
for (CNLabeledValue<CNInstantMessageAddress *> *sipAddr in _person.instantMessageAddresses) {
NSString *username = sipAddr.value.username;
if (username)
[_sipAddresses addObject:username];
NSString *service = sipAddr.value.service;
if (username && ([service isEqualToString:LinphoneManager.instance.contactSipField] || ([service isEqualToString:@"INSTANT_MESSAGING_NAME"] && [FastAddressBook isSipURI:username]))){
[_sipAddresses addObject:username];
}
}
}
}
for (CNLabeledValue<NSString *> *email in _person.emailAddresses) {
[_emails addObject:email.value];
}
@ -225,11 +228,11 @@
CNInstantMessageAddress *cNSipMsgAddr;
if ([normSip containsString:@"@"])
cNSipMsgAddr = [[CNInstantMessageAddress alloc]
initWithUsername:normSip service:[normSip componentsSeparatedByString:@"@"][1]];
initWithUsername:normSip service:@"SIP"];//service:[normSip componentsSeparatedByString:@"@"][1]];
else
cNSipMsgAddr =
[[CNInstantMessageAddress alloc] initWithUsername:normSip
service:normSip];
service:@"SIP"];
CNLabeledValue *sipAddress =
[CNLabeledValue labeledValueWithLabel:NULL value:cNSipMsgAddr];
NSMutableArray<CNLabeledValue<CNInstantMessageAddress *> *>
@ -244,13 +247,13 @@
CNInstantMessageAddress *cNSipMsgAddr;
if ([[FastAddressBook normalizeSipURI:normSip] containsString:@"@"])
cNSipMsgAddr = [[CNInstantMessageAddress alloc]
initWithUsername:sip
service:[[FastAddressBook normalizeSipURI:normSip]
componentsSeparatedByString:@"@"][1]];
initWithUsername:sip service:@"SIP"];
//service:[[FastAddressBook normalizeSipURI:normSip]
// componentsSeparatedByString:@"@"][1]];
else
cNSipMsgAddr =
[[CNInstantMessageAddress alloc] initWithUsername:normSip
service:normSip];
[[CNInstantMessageAddress alloc] initWithUsername:normSip service:@"SIP"];
//service:normSip];
CNLabeledValue *sipAddress =
[CNLabeledValue labeledValueWithLabel:NULL value:cNSipMsgAddr];
NSMutableArray<CNLabeledValue<CNInstantMessageAddress *> *>
@ -351,12 +354,12 @@
cNSipMsgAddr = [[CNInstantMessageAddress alloc]
initWithUsername:[normSip
componentsSeparatedByString:@"@"][0]
service:[normSip
componentsSeparatedByString:@"@"][1]];
service:@"SIP"];
//service:[normSip componentsSeparatedByString:@"@"][1]];
else
cNSipMsgAddr =
[[CNInstantMessageAddress alloc] initWithUsername:normSip
service:normSip];
service:@"SIP"];
CNLabeledValue *sipAddress =
[CNLabeledValue labeledValueWithLabel:NULL
value:cNSipMsgAddr];

View file

@ -75,12 +75,10 @@
- (void)addEntry:(UITableView *)tableview section:(NSInteger)section animated:(BOOL)animated value:(NSString *)value {
bool added = FALSE;
if (section == ContactSections_Number) {
if ([_contact.phones count] ==
[_contact.person.phoneNumbers count])
if ([_contact.phones count] == [_contact.person.phoneNumbers count])
added = [_contact addPhoneNumber:value];
} else if (section == ContactSections_Sip) {
if ([_contact.sipAddresses count] ==
[_contact.person.instantMessageAddresses count])
if ([_contact.sipAddresses count] == [self countSipAddressFromCNContact:_contact.person]) //[_contact.person.instantMessageAddresses count])
added = [_contact addSipAddress:value];
} else if (section == ContactSections_Email) {
if ([_contact.emails count] ==
@ -100,6 +98,21 @@
}
}
-(NSInteger)countSipAddressFromCNContact:(CNContact*) mCNContact{
NSInteger count = 0;
if (mCNContact.instantMessageAddresses != NULL) {
for (CNLabeledValue<CNInstantMessageAddress *> *sipAddr in mCNContact.instantMessageAddresses) {
NSString *username = sipAddr.value.username;
NSString *service = sipAddr.value.service;
if (username && ([service isEqualToString:LinphoneManager.instance.contactSipField] || ([service isEqualToString:@"INSTANT_MESSAGING_NAME"] && [FastAddressBook isSipURI:username]))){
count ++;
}
}
}
return count;
}
- (void)setContact:(Contact *)acontact {
// if (acontact == _contact)
// return;

View file

@ -1855,7 +1855,7 @@ void networkReachabilityCallBack(SCNetworkReachabilityRef target, SCNetworkReach
device = [device stringByReplacingOccurrencesOfString:@" " withString:@"."];
linphone_core_set_user_agent(theLinphoneCore, device.UTF8String, LINPHONE_IOS_VERSION);
_contactSipField = [self lpConfigStringForKey:@"contact_im_type_value" withDefault:@"SIP"];
_contactSipField = [self lpConfigStringForKey:@"contact_im_type_value" inSection:@"sip" withDefault:@"SIP"];
if (_fastAddressBook == nil) {
_fastAddressBook = [[FastAddressBook alloc] init];