forked from mirrors/linphone-iphone
factorize test of sip service
This commit is contained in:
parent
4271d6a978
commit
51bf02f8d7
4 changed files with 23 additions and 11 deletions
|
|
@ -39,10 +39,9 @@
|
|||
if ([_person respondsToSelector:NSSelectorFromString( CNInstantMessageAddressUsernameKey)] || [_person respondsToSelector:NSSelectorFromString(CNContactInstantMessageAddressesKey)]) {
|
||||
if (_person.instantMessageAddresses != NULL) {
|
||||
for (CNLabeledValue<CNInstantMessageAddress *> *sipAddr in _person.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]))){
|
||||
[_sipAddresses addObject:username];
|
||||
if ([FastAddressBook isSipAddress:sipAddr]) {
|
||||
NSString *username = sipAddr.value.username;
|
||||
[_sipAddresses addObject:username];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,11 +102,8 @@
|
|||
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 ++;
|
||||
}
|
||||
if ([FastAddressBook isSipAddress:sipAddr])
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
|
|
|
|||
|
|
@ -51,8 +51,9 @@
|
|||
+ (NSString *)displayNameForContact:(Contact *)person;
|
||||
+ (NSString *)displayNameForAddress:(const LinphoneAddress *)addr;
|
||||
|
||||
+ (BOOL)isSipURI:(NSString *)address; // should be removed
|
||||
+ (NSString *)normalizeSipURI:(NSString *)address; // should be removed
|
||||
+ (BOOL)isSipURI:(NSString *)address;
|
||||
+ (BOOL)isSipAddress:(CNLabeledValue<CNInstantMessageAddress *> *)sipAddr;
|
||||
+ (NSString *)normalizeSipURI:(NSString *)address;
|
||||
|
||||
+ (NSString *)localizedLabel:(NSString *)label;
|
||||
- (void)registerAddrsFor:(Contact *)contact;
|
||||
|
|
|
|||
|
|
@ -89,6 +89,21 @@
|
|||
return [address hasPrefix:@"sip:"] || [address hasPrefix:@"sips:"];
|
||||
}
|
||||
|
||||
+ (BOOL)isSipAddress:(CNLabeledValue<CNInstantMessageAddress *> *)sipAddr {
|
||||
NSString *username = sipAddr.value.username;
|
||||
NSString *service = sipAddr.value.service;
|
||||
if (!username)
|
||||
return FALSE;
|
||||
|
||||
if ([service isEqualToString:LinphoneManager.instance.contactSipField])
|
||||
return TRUE;
|
||||
|
||||
if (([service isEqualToString:@"INSTANT_MESSAGING_NAME"] || [service isEqualToString:@"IM_SERVICE_NAME"]) && [FastAddressBook isSipURI:username])
|
||||
return TRUE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+ (NSString *)normalizeSipURI:(NSString *)address {
|
||||
// replace all whitespaces (non-breakable, utf8 nbsp etc.) by the "classical" whitespace
|
||||
NSString *normalizedSipAddress = nil;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue