forked from mirrors/linphone-iphone
better address book sip address handling/filtering
This commit is contained in:
parent
a305436e08
commit
8553bac55d
8 changed files with 61 additions and 18 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:TRUE];
|
||||
[ContactSelection setSipFilter:@"*"];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[[PhoneMainView instance] changeCurrentView:[ContactsViewController compositeViewDescription] push:TRUE];
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_None, C
|
|||
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, i);
|
||||
BOOL add = false;
|
||||
if(CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
|
||||
if(CFStringCompare((CFStringRef)kContactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) {
|
||||
if(CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -285,7 +285,7 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_None, C
|
|||
lMap = ABMultiValueCreateMutable(kABDictionaryPropertyType);
|
||||
}
|
||||
CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey };
|
||||
CFTypeRef values[] = { [value copy], kContactSipField };
|
||||
CFTypeRef values[] = { [value copy], [LinphoneManager instance].contactSipField };
|
||||
CFDictionaryRef lDict = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 1, NULL, NULL);
|
||||
CFStringRef label = (CFStringRef)[labelArray objectAtIndex:0];
|
||||
if(!ABMultiValueAddValueAndLabel(lMap, lDict, label, &identifier)) {
|
||||
|
|
@ -497,7 +497,17 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_None, C
|
|||
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, index);
|
||||
CFStringRef valueRef = CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey);
|
||||
if(valueRef != NULL) {
|
||||
value = [NSString stringWithString:(NSString*) valueRef];
|
||||
LinphoneAddress* addr=NULL;
|
||||
if ([[LinphoneManager instance] lpConfigBoolForKey:@"contact_display_username_only"]
|
||||
&& (addr=linphone_address_new([(NSString *)valueRef UTF8String]))) {
|
||||
if (linphone_address_get_username(addr)) {
|
||||
value = [NSString stringWithCString:linphone_address_get_username(addr)
|
||||
encoding:[NSString defaultCStringEncoding]];
|
||||
} /*else value=@""*/
|
||||
} else {
|
||||
value = [NSString stringWithString:(NSString*) valueRef];
|
||||
}
|
||||
if (addr) linphone_address_destroy(addr);
|
||||
}
|
||||
CFRelease(lDict);
|
||||
CFRelease(lMap);
|
||||
|
|
@ -825,11 +835,33 @@ static const int contactSections[ContactSections_MAX] = {ContactSections_None, C
|
|||
CFRelease(lcMap);
|
||||
int index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]);
|
||||
CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey};
|
||||
CFTypeRef values[] = { [value copy], kContactSipField };
|
||||
CFTypeRef values[] = { [value copy], [LinphoneManager instance].contactSipField };
|
||||
CFDictionaryRef lDict = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, NULL, NULL);
|
||||
ABMultiValueReplaceValueAtIndex(lMap, lDict, index);
|
||||
CFRelease(lDict);
|
||||
ABRecordSetValue(contact, kABPersonInstantMessageProperty, lMap, nil);
|
||||
ABRecordSetValue(contact, kABPersonInstantMessageProperty, lMap, nil);
|
||||
CFRelease(lDict);
|
||||
/*check if message type is kept or not*/
|
||||
lcMap = ABRecordCopyValue(contact, kABPersonInstantMessageProperty);
|
||||
lMap = ABMultiValueCreateMutableCopy(lcMap);
|
||||
CFRelease(lcMap);
|
||||
index = ABMultiValueGetIndexForIdentifier(lMap, [entry identifier]);
|
||||
lDict = ABMultiValueCopyValueAtIndex(lMap,index);
|
||||
if(!CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
|
||||
/*too bad probably a gtalk number, storing uri*/
|
||||
NSString* username = CFDictionaryGetValue(lDict, kABPersonInstantMessageUsernameKey);
|
||||
LinphoneAddress* address = linphone_core_interpret_url([LinphoneManager getLc]
|
||||
,[username UTF8String]);
|
||||
char* uri = linphone_address_as_string_uri_only(address);
|
||||
CFStringRef keys[] = { kABPersonInstantMessageUsernameKey, kABPersonInstantMessageServiceKey};
|
||||
CFTypeRef values[] = { [NSString stringWithCString:uri encoding:[NSString defaultCStringEncoding]], [LinphoneManager instance].contactSipField };
|
||||
CFDictionaryRef lDict2 = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, 2, NULL, NULL);
|
||||
ABMultiValueReplaceValueAtIndex(lMap, lDict2, index);
|
||||
ABRecordSetValue(contact, kABPersonInstantMessageProperty, lMap, nil);
|
||||
CFRelease(lDict2);
|
||||
linphone_address_destroy(address);
|
||||
ms_free(uri);
|
||||
}
|
||||
CFRelease(lDict);
|
||||
CFRelease(lMap);
|
||||
} else if(contactSections[[path section]] == ContactSections_Email) {
|
||||
ABMultiValueRef lcMap = ABRecordCopyValue(contact, kABPersonEmailProperty);
|
||||
|
|
|
|||
|
|
@ -36,8 +36,9 @@ typedef enum _ContactSelectionMode {
|
|||
+ (ContactSelectionMode)getSelectionMode;
|
||||
+ (void)setAddAddress:(NSString*)address;
|
||||
+ (NSString*)getAddAddress;
|
||||
+ (void)setSipFilter:(BOOL)enable;
|
||||
+ (BOOL)getSipFilter;
|
||||
/* define sip filter, can be * or sip domain*/
|
||||
+ (void)setSipFilter:(NSString*) domain;
|
||||
+ (NSString*)getSipFilter;
|
||||
+ (void)setEmailFilter:(BOOL)enable;
|
||||
+ (BOOL)getEmailFilter;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@
|
|||
|
||||
static ContactSelectionMode sSelectionMode = ContactSelectionModeNone;
|
||||
static NSString* sAddAddress = nil;
|
||||
static BOOL sSipFilter = FALSE;
|
||||
static NSString* sSipFilter = nil;
|
||||
static BOOL sEmailFilter = FALSE;
|
||||
|
||||
+ (void)setSelectionMode:(ContactSelectionMode)selectionMode {
|
||||
|
|
@ -52,11 +52,11 @@ static BOOL sEmailFilter = FALSE;
|
|||
return sAddAddress;
|
||||
}
|
||||
|
||||
+ (void)setSipFilter:(BOOL)enable {
|
||||
sSipFilter = enable;
|
||||
+ (void)setSipFilter:(NSString*)domain {
|
||||
sSipFilter = domain;
|
||||
}
|
||||
|
||||
+ (BOOL)getSipFilter {
|
||||
+ (NSString*)getSipFilter {
|
||||
return sSipFilter;
|
||||
}
|
||||
|
||||
|
|
@ -206,7 +206,7 @@ static UICompositeViewDescription *compositeDescription = nil;
|
|||
}
|
||||
|
||||
if(view == History_Linphone) {
|
||||
[ContactSelection setSipFilter:TRUE];
|
||||
[ContactSelection setSipFilter:@"*"];
|
||||
[ContactSelection setEmailFilter:FALSE];
|
||||
[tableController loadData];
|
||||
linphoneButton.selected = TRUE;
|
||||
|
|
|
|||
|
|
@ -47,8 +47,6 @@ extern NSString *const kLinphoneLogsUpdate;
|
|||
extern NSString *const kLinphoneSettingsUpdate;
|
||||
extern NSString *const kLinphoneBluetoothAvailabilityUpdate;
|
||||
|
||||
extern NSString *const kContactSipField;
|
||||
|
||||
typedef enum _NetworkType {
|
||||
network_none = 0,
|
||||
network_2g,
|
||||
|
|
@ -117,6 +115,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
+ (NSSet *)unsupportedCodecs;
|
||||
+ (NSString *)getUserAgent;
|
||||
|
||||
|
||||
- (void)startLibLinphone;
|
||||
- (void)destroyLibLinphone;
|
||||
- (BOOL)resignActive;
|
||||
|
|
@ -155,6 +154,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
- (void)lpConfigSetBool:(BOOL)value forKey:(NSString*)key forSection:(NSString*)section;
|
||||
- (BOOL)lpConfigBoolForKey:(NSString*)key forSection:(NSString*)section;
|
||||
|
||||
|
||||
@property (readonly) FastAddressBook* fastAddressBook;
|
||||
@property Connectivity connectivity;
|
||||
@property (readonly) NetworkType network;
|
||||
|
|
@ -168,6 +168,7 @@ typedef struct _LinphoneManagerSounds {
|
|||
@property (nonatomic, assign) BOOL bluetoothAvailable;
|
||||
@property (nonatomic, assign) BOOL bluetoothEnabled;
|
||||
@property (readonly) ALAssetsLibrary *photoLibrary;
|
||||
@property (readonly) NSString* contactSipField;
|
||||
|
||||
@end
|
||||
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ NSString *const kLinphoneMainViewChange = @"LinphoneMainViewChange";
|
|||
NSString *const kLinphoneLogsUpdate = @"LinphoneLogsUpdate";
|
||||
NSString *const kLinphoneSettingsUpdate = @"LinphoneSettingsUpdate";
|
||||
NSString *const kLinphoneBluetoothAvailabilityUpdate = @"LinphoneBluetoothAvailabilityUpdate";
|
||||
NSString *const kContactSipField = @"SIP";
|
||||
|
||||
|
||||
|
||||
extern void libmsilbc_init();
|
||||
|
|
@ -246,6 +246,7 @@ struct codec_name_pref_table codec_pref_table[]={
|
|||
[self copyDefaultSettings];
|
||||
pendindCallIdFromRemoteNotif = [[NSMutableArray alloc] init ];
|
||||
photoLibrary = [[ALAssetsLibrary alloc] init];
|
||||
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
|
@ -925,6 +926,11 @@ 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"];
|
||||
|
|
|
|||
|
|
@ -179,7 +179,7 @@ static void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef inf
|
|||
CFDictionaryRef lDict = ABMultiValueCopyValueAtIndex(lMap, i);
|
||||
BOOL add = false;
|
||||
if(CFDictionaryContainsKey(lDict, kABPersonInstantMessageServiceKey)) {
|
||||
if(CFStringCompare((CFStringRef)kContactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) {
|
||||
if(CFStringCompare((CFStringRef)[LinphoneManager instance].contactSipField, CFDictionaryGetValue(lDict, kABPersonInstantMessageServiceKey), kCFCompareCaseInsensitive) == 0) {
|
||||
add = true;
|
||||
}
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -47,3 +47,6 @@ stun=stun.linphone.org
|
|||
|
||||
[video]
|
||||
display_filter_auto_rotate=0
|
||||
|
||||
[app]
|
||||
#contact_display_username_only=1
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue