diff --git a/Classes/ChatViewController.m b/Classes/ChatViewController.m index 453f11927..1bc923dbc 100644 --- a/Classes/ChatViewController.m +++ b/Classes/ChatViewController.m @@ -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 { diff --git a/Classes/ContactDetailsTableViewController.m b/Classes/ContactDetailsTableViewController.m index f43280bdc..7b64c2990 100644 --- a/Classes/ContactDetailsTableViewController.m +++ b/Classes/ContactDetailsTableViewController.m @@ -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]; } diff --git a/Classes/ContactsTableViewController.m b/Classes/ContactsTableViewController.m index 866b247ce..c424b1ea5 100644 --- a/Classes/ContactsTableViewController.m +++ b/Classes/ContactsTableViewController.m @@ -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); diff --git a/Classes/ContactsViewController.m b/Classes/ContactsViewController.m index 342ee059f..d3b54c122 100644 --- a/Classes/ContactsViewController.m +++ b/Classes/ContactsViewController.m @@ -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; diff --git a/Classes/DialerViewController.m b/Classes/DialerViewController.m index 0263d8138..cb28fefaa 100644 --- a/Classes/DialerViewController.m +++ b/Classes/DialerViewController.m @@ -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) { diff --git a/Classes/HistoryDetailsViewController.m b/Classes/HistoryDetailsViewController.m index 16454d126..ec172566a 100644 --- a/Classes/HistoryDetailsViewController.m +++ b/Classes/HistoryDetailsViewController.m @@ -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) { diff --git a/Classes/LinphoneManager.h b/Classes/LinphoneManager.h index 4f9a27d06..da64fca6c 100644 --- a/Classes/LinphoneManager.h +++ b/Classes/LinphoneManager.h @@ -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 diff --git a/Classes/LinphoneManager.m b/Classes/LinphoneManager.m index c24357942..882dae154 100644 --- a/Classes/LinphoneManager.m +++ b/Classes/LinphoneManager.m @@ -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 diff --git a/Classes/LinphoneUI/UIMainBar.m b/Classes/LinphoneUI/UIMainBar.m index 5e7cbe771..18d750620 100644 --- a/Classes/LinphoneUI/UIMainBar.m +++ b/Classes/LinphoneUI/UIMainBar.m @@ -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]]; } diff --git a/Resources/linphonerc-factory b/Resources/linphonerc-factory index ec3d25d96..cc6384010 100644 --- a/Resources/linphonerc-factory +++ b/Resources/linphonerc-factory @@ -50,3 +50,4 @@ display_filter_auto_rotate=0 [app] #contact_display_username_only=1 +#contact_filter_on_default_domain=1 diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index c029ee1e5..a585e11ca 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -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"; };