forked from mirrors/linphone-iphone
enhanced management of sip uri in contact
This commit is contained in:
parent
8553bac55d
commit
bea35b0ac3
11 changed files with 86 additions and 36 deletions
|
|
@ -122,7 +122,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
if ([[addressField text ]length] == 0) { // if no address is manually set, lauch address book
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeMessage];
|
||||
[ContactSelection setAddAddress:nil];
|
||||
[ContactSelection setSipFilter:@"*"];
|
||||
[ContactSelection setSipFilter: [LinphoneManager instance].contactFilter];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -201,17 +201,29 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_None, C
|
|||
if(CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
}
|
||||
} else {
|
||||
add = true;
|
||||
}
|
||||
if(add) {
|
||||
Entry *entry = [[Entry alloc] initWithData:identifier];
|
||||
[subArray addObject: entry];
|
||||
[entry release];
|
||||
}
|
||||
CFRelease(lDict);
|
||||
}
|
||||
CFRelease(lMap);
|
||||
} else { //check domain
|
||||
LinphoneAddress* address = linphone_address_new([(NSString*)CFDictionaryGetValue(lDict,kABPersonInstantMessageUsernameKey) UTF8String]);
|
||||
if (address) {
|
||||
if ([[ContactSelection getSipFilter] compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
|
||||
add = true;
|
||||
} else {
|
||||
NSString* domain = [NSString stringWithCString:linphone_address_get_domain(address)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
add = [domain compare:[ContactSelection getSipFilter] options:NSCaseInsensitiveSearch] == NSOrderedSame;
|
||||
}
|
||||
linphone_address_destroy(address);
|
||||
} else {
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
if(add) {
|
||||
Entry *entry = [[Entry alloc] initWithData:identifier];
|
||||
[subArray addObject: entry];
|
||||
[entry release];
|
||||
}
|
||||
CFRelease(lDict);
|
||||
}
|
||||
CFRelease(lMap);
|
||||
}
|
||||
[dataCache addObject:subArray];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,13 +87,26 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf
|
|||
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, i);
|
||||
if(CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
|
||||
CFStringRef serviceKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey);
|
||||
if(CFStringCompare((CFStringRef)@"SIP", serviceKey, kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
}
|
||||
} else {
|
||||
NSString* usernameKey = CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey);
|
||||
if([usernameKey hasPrefix:@"sip:"]) {
|
||||
CFStringRef username = username=CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey);
|
||||
if(CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, serviceKey, kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
} else {
|
||||
add=false;
|
||||
}
|
||||
} else {
|
||||
//check domain
|
||||
LinphoneAddress* address = linphone_address_new([(NSString*)CFDictionaryGetValue(lDict,kABPersonInstantMessageUsernameKey) UTF8String]);
|
||||
if (address) {
|
||||
if ([[ContactSelection getSipFilter] compare:@"*" options:NSCaseInsensitiveSearch] == NSOrderedSame) {
|
||||
add = true;
|
||||
} else {
|
||||
NSString* domain = [NSString stringWithCString:linphone_address_get_domain(address)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
add = [domain compare:[ContactSelection getSipFilter] options:NSCaseInsensitiveSearch] == NSOrderedSame;
|
||||
}
|
||||
linphone_address_destroy(address);
|
||||
} else {
|
||||
add = false;
|
||||
}
|
||||
}
|
||||
CFRelease(lDict);
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ static BOOL sEmailFilter = FALSE;
|
|||
}
|
||||
|
||||
+ (void)setSipFilter:(NSString*)domain {
|
||||
sSipFilter = domain;
|
||||
[sSipFilter release];
|
||||
sSipFilter = [domain retain];
|
||||
}
|
||||
|
||||
+ (NSString*)getSipFilter {
|
||||
|
|
@ -197,7 +198,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
|
||||
- (void)changeView:(HistoryView)view {
|
||||
if(view == History_All) {
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[ContactSelection setSipFilter:nil];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[tableController loadData];
|
||||
allButton.selected = TRUE;
|
||||
|
|
@ -206,7 +207,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
if(view == History_Linphone) {
|
||||
[ContactSelection setSipFilter:@"*"];
|
||||
[ContactSelection setSipFilter:[LinphoneManager instance].contactFilter];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[tableController loadData];
|
||||
linphoneButton.selected = TRUE;
|
||||
|
|
|
|||
|
|
@ -317,7 +317,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
- (IBAction)onAddContactClick: (id) event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeEdit];
|
||||
[ContactSelection setAddAddress:[addressField text]];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[ContactSelection setSipFilter:nil];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
ContactsViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE], ContactsViewController);
|
||||
if(controller != nil) {
|
||||
|
|
|
|||
|
|
@ -281,13 +281,15 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
// contact name
|
||||
[plainAddressLabel setText:@""];
|
||||
if (addr != NULL) {
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress != NULL) {
|
||||
[plainAddressLabel setText:[NSString stringWithUTF8String:lAddress]];
|
||||
ms_free(lAddress);
|
||||
} else {
|
||||
|
||||
}
|
||||
if ([[LinphoneManager instance] lpConfigBoolForKey:@"contact_display_username_only"]) {
|
||||
[plainAddressLabel setText:[NSString stringWithUTF8String:linphone_address_get_username(addr)?linphone_address_get_username(addr):""]];
|
||||
} else {
|
||||
char* lAddress = linphone_address_as_string_uri_only(addr);
|
||||
if(lAddress != NULL) {
|
||||
[plainAddressLabel setText:[NSString stringWithUTF8String:lAddress]];
|
||||
ms_free(lAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (addr != NULL) {
|
||||
|
|
@ -327,7 +329,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
[ContactSelection setAddAddress:[NSString stringWithUTF8String:lAddress]];
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeEdit];
|
||||
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[ContactSelection setSipFilter:nil];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
ContactsViewController *controller = DYNAMIC_CAST([[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE], ContactsViewController);
|
||||
if(controller != nil) {
|
||||
|
|
|
|||
|
|
@ -143,6 +143,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
|
||||
- (void)lpConfigSetString:(NSString*)value forKey:(NSString*)key;
|
||||
- (NSString*)lpConfigStringForKey:(NSString*)key;
|
||||
- (NSString*)lpConfigStringForKey:(NSString*)key withDefault:(NSString*)value;
|
||||
- (void)lpConfigSetString:(NSString*)value forKey:(NSString*)key forSection:(NSString*)section;
|
||||
- (NSString*)lpConfigStringForKey:(NSString*)key forSection:(NSString*)section;
|
||||
- (void)lpConfigSetInt:(NSInteger)value forKey:(NSString*)key;
|
||||
|
|
@ -169,6 +170,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
@property (nonatomic, assign) BOOL bluetoothEnabled;
|
||||
@property (readonly) ALAssetsLibrary *photoLibrary;
|
||||
@property (readonly) NSString* contactSipField;
|
||||
@property (readonly,copy) NSString* contactFilter;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -842,6 +842,11 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
,self);
|
||||
linphone_core_set_user_agent(theLinphoneCore,"LinphoneIPhone",
|
||||
[[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString*)kCFBundleVersionKey] UTF8String]);
|
||||
|
||||
_contactSipField = [self lpConfigStringForKey:@"contact_im_type_value"];
|
||||
if (_contactSipField == nil)
|
||||
_contactSipField =@"SIP";
|
||||
|
||||
fastAddressBook = [[FastAddressBook alloc] init];
|
||||
|
||||
linphone_core_set_root_ca(theLinphoneCore, lRootCa);
|
||||
|
|
@ -926,11 +931,7 @@ static LinphoneCoreVTable linphonec_vtable = {
|
|||
//go directly to bg mode
|
||||
[self resignActive];
|
||||
}
|
||||
|
||||
_contactSipField = [self lpConfigStringForKey:@"contact_im_type_value"];
|
||||
if (_contactSipField == nil)
|
||||
_contactSipField =@"SIP";
|
||||
|
||||
|
||||
|
||||
// Post event
|
||||
NSDictionary *dict = [NSDictionary dictionaryWithObject:[NSValue valueWithPointer:theLinphoneCore] forKey:@"core"];
|
||||
|
|
@ -1420,6 +1421,10 @@ static void audioRouteChangeListenerCallback (
|
|||
- (NSString*)lpConfigStringForKey:(NSString*)key {
|
||||
return [self lpConfigStringForKey:key forSection:[NSString stringWithUTF8String:LINPHONERC_APPLICATION_KEY]];
|
||||
}
|
||||
- (NSString*)lpConfigStringForKey:(NSString*)key withDefault:(NSString*)defaultValue {
|
||||
NSString* value = [self lpConfigStringForKey:key];
|
||||
return value?value:defaultValue;
|
||||
}
|
||||
|
||||
- (NSString*)lpConfigStringForKey:(NSString*)key forSection:(NSString *)section {
|
||||
if (!key) return nil;
|
||||
|
|
@ -1504,4 +1509,16 @@ static void audioRouteChangeListenerCallback (
|
|||
}
|
||||
} //else nop, keep call in paused state
|
||||
}
|
||||
-(NSString*) contactFilter {
|
||||
NSString* filter=@"*";
|
||||
if ( [self lpConfigBoolForKey:@"contact_filter_on_default_domain"]) {
|
||||
LinphoneProxyConfig* proxy_cfg;
|
||||
linphone_core_get_default_proxy(theLinphoneCore, &proxy_cfg);
|
||||
if (proxy_cfg && linphone_proxy_config_get_addr(proxy_cfg)) {
|
||||
return [NSString stringWithCString:linphone_proxy_config_get_domain(proxy_cfg)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
}
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
@end
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ static NSString * const kDisappearAnimation = @"disappear";
|
|||
- (IBAction)onContactsClick:(id)event {
|
||||
[ContactSelection setSelectionMode:ContactSelectionModeNone];
|
||||
[ContactSelection setAddAddress:nil];
|
||||
[ContactSelection setSipFilter:FALSE];
|
||||
[ContactSelection setSipFilter:nil];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription]];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,3 +50,4 @@ display_filter_auto_rotate=0
|
|||
|
||||
[app]
|
||||
#contact_display_username_only=1
|
||||
#contact_filter_on_default_domain=1
|
||||
|
|
|
|||
|
|
@ -5529,6 +5529,7 @@
|
|||
buildSettings = {
|
||||
ALWAYS_SEARCH_USER_PATHS = NO;
|
||||
CODE_SIGN_ENTITLEMENTS = "";
|
||||
CODE_SIGN_IDENTITY = "iPhone Distribution: jehan monnier";
|
||||
COMPRESS_PNG_FILES = NO;
|
||||
COPY_PHASE_STRIP = NO;
|
||||
FRAMEWORK_SEARCH_PATHS = "";
|
||||
|
|
@ -5567,6 +5568,7 @@
|
|||
ORDER_FILE = "";
|
||||
OTHER_LDFLAGS = "-ObjC";
|
||||
PRODUCT_NAME = linphone;
|
||||
PROVISIONING_PROFILE = "B0005B58-1160-4269-B1FC-C5BA54ACBA65";
|
||||
SKIP_INSTALL = NO;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue