diff --git a/Classes/LinphoneUI/FastAddressBook.h b/Classes/LinphoneUI/FastAddressBook.h new file mode 100644 index 000000000..780ceb33c --- /dev/null +++ b/Classes/LinphoneUI/FastAddressBook.h @@ -0,0 +1,41 @@ +/* FastAddressBook.h + * + * Copyright (C) 2011 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import +#import + +@interface Contact : NSObject { + ABRecordRef record; + NSString* numberType; +} +-(id) initWithRecord:(ABRecordRef) record ofType:(NSString*) type; +@property (nonatomic, readonly) ABRecordRef record; +@property (nonatomic, readonly) NSString* numberType; +@end + +@interface FastAddressBook : NSObject { + NSMutableDictionary* mAddressBookMap; +} + +-(Contact*) getMatchingRecord:(NSString*) number ; ++(NSString*) appendCountryCodeIfPossible:(NSString*) number ; ++(NSString*) normalizePhoneNumber:(NSString*) number ; +-(id) init ; + +@end diff --git a/Classes/LinphoneUI/FastAddressBook.m b/Classes/LinphoneUI/FastAddressBook.m new file mode 100644 index 000000000..ffb7e4336 --- /dev/null +++ b/Classes/LinphoneUI/FastAddressBook.m @@ -0,0 +1,98 @@ +/* FastAddressBook.h + * + * Copyright (C) 2011 Belledonne Comunications, Grenoble, France + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Library General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#import "FastAddressBook.h" +@implementation FastAddressBook + + -(Contact*) getMatchingRecord:(NSString*) number { + @synchronized (mAddressBookMap){ + return (Contact*) [mAddressBookMap objectForKey:number]; + } +} + ++(NSString*) appendCountryCodeIfPossible:(NSString*) number { + if (![number hasPrefix:@"+"] && ![number hasPrefix:@"00"]) { + NSString* lCountryCode = [[NSUserDefaults standardUserDefaults] stringForKey:@"countrycode_preference"]; + if (lCountryCode && [lCountryCode length]>0) { + //append country code + return [lCountryCode stringByAppendingString:number]; + } + } + return number; +} ++(NSString*) normalizePhoneNumber:(NSString*) number { + NSString* lNormalizedNumber = [(NSString*)number stringByReplacingOccurrencesOfString:@" " withString:@""]; + lNormalizedNumber = [lNormalizedNumber stringByReplacingOccurrencesOfString:@"(" withString:@""]; + lNormalizedNumber = [lNormalizedNumber stringByReplacingOccurrencesOfString:@")" withString:@""]; + lNormalizedNumber = [lNormalizedNumber stringByReplacingOccurrencesOfString:@"-" withString:@""]; + lNormalizedNumber = [FastAddressBook appendCountryCodeIfPossible:lNormalizedNumber]; + return lNormalizedNumber; +} +void sync_address_book (ABAddressBookRef addressBook, CFDictionaryRef info, void *context) { + NSMutableDictionary* lAddressBookMap = (NSMutableDictionary*)context; + @synchronized (lAddressBookMap) { + [lAddressBookMap removeAllObjects]; + + NSArray *lContacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(addressBook); + for (id lPerson in lContacts) { + ABMutableMultiValueRef lPhoneNumbers = ABRecordCopyValue((ABRecordRef)lPerson, kABPersonPhoneProperty); + for ( int i=0; i registrationDelegate; @property Connectivity connectivity; @end + + diff --git a/Classes/LinphoneUI/LinphoneManager.m b/Classes/LinphoneUI/LinphoneManager.m index c02416116..e94f0002c 100644 --- a/Classes/LinphoneUI/LinphoneManager.m +++ b/Classes/LinphoneUI/LinphoneManager.m @@ -25,6 +25,7 @@ #include #import #import +#import "FastAddressBook.h" #include "tunnel/TunnelManager.hh" #import @@ -44,14 +45,19 @@ extern void libmsamr_init(); @synthesize registrationDelegate; @synthesize connectivity; - - +-(id) init { + if ((self= [super init])) { + mFastAddressBook = [[FastAddressBook alloc] init]; + } + return self; +} +(LinphoneManager*) instance { if (theLinphoneManager==nil) { - theLinphoneManager = [LinphoneManager alloc]; + theLinphoneManager = [[LinphoneManager alloc] init]; } return theLinphoneManager; } + -(NSString*) appendCountryCodeIfPossible:(NSString*) number { if (![number hasPrefix:@"+"] && ![number hasPrefix:@"00"]) { NSString* lCountryCode = [[NSUserDefaults standardUserDefaults] stringForKey:@"countrycode_preference"]; @@ -64,41 +70,24 @@ extern void libmsamr_init(); } -(NSString*) getDisplayNameFromAddressBook:(NSString*) number andUpdateCallLog:(LinphoneCallLog*)log { - ABAddressBookRef lAddressBook = ABAddressBookCreate(); - NSArray *lContacts = (NSArray *)ABAddressBookCopyArrayOfAllPeople(lAddressBook); - for (id lContact in lContacts) { - ABMutableMultiValueRef lPhoneNumbers = ABRecordCopyValue((ABRecordRef)lContact, kABPersonPhoneProperty); - for ( int i=0; i0) { linphone_proxy_config_set_dial_prefix(proxyCfg, [prefix cStringUsingEncoding:[NSString defaultCStringEncoding]]); } - linphone_proxy_config_set_dial_escape_plus(proxyCfg,TRUE); + linphone_proxy_config_set_dial_escape_plus(proxyCfg,substitute_plus_by_00); linphone_core_add_proxy_config(theLinphoneCore,proxyCfg); //set to default proxy diff --git a/Settings.bundle/Root.plist b/Settings.bundle/Root.plist index 858233213..666d19d6e 100644 --- a/Settings.bundle/Root.plist +++ b/Settings.bundle/Root.plist @@ -2,167 +2,163 @@ - StringsTable - Root PreferenceSpecifiers - Type - PSGroupSpecifier Title SIP account + Type + PSGroupSpecifier - Type - PSTextFieldSpecifier - Title - User name + AutocapitalizationType + None + AutocorrectionType + No + DefaultValue + + IsSecure + Key username_preference - DefaultValue - - IsSecure - KeyboardType Alphabet + Title + User name + Type + PSTextFieldSpecifier + + AutocapitalizationType None AutocorrectionType No - - - Type - PSTextFieldSpecifier - Title - Password + DefaultValue + + IsSecure + Key password_preference - DefaultValue - - IsSecure - KeyboardType Alphabet + Title + Password + Type + PSTextFieldSpecifier + + AutocapitalizationType None AutocorrectionType No - - - Type - PSTextFieldSpecifier - Title - Domain + DefaultValue + + IsSecure + Key domain_preference - DefaultValue - - IsSecure - KeyboardType URL - AutocapitalizationType - None - AutocorrectionType - No - - + Title + Domain Type PSTextFieldSpecifier - Title - Proxy - Key - proxy_preference - DefaultValue - - IsSecure - - KeyboardType - URL + + AutocapitalizationType None AutocorrectionType No + DefaultValue + + IsSecure + + Key + proxy_preference + KeyboardType + URL + Title + Proxy + Type + PSTextFieldSpecifier - Type - PSToggleSwitchSpecifier - Title - Outbound proxy - Key - outbound_proxy_preference DefaultValue + Key + outbound_proxy_preference + Title + Outbound proxy + Type + PSToggleSwitchSpecifier - Type - PSGroupSpecifier Title Codecs - - - Type - PSToggleSwitchSpecifier - Title - Speex 16Khz - Key - speex_16k_preference - DefaultValue - - - - Type - PSToggleSwitchSpecifier - Title - Speex 8Khz - Key - speex_8k_preference - DefaultValue - - - - Type - PSToggleSwitchSpecifier - Title - GSM - Key - gsm_8k_preference - DefaultValue - - - - Type - PSToggleSwitchSpecifier - Title - ILBC - Key - ilbc_preference - DefaultValue - - - - Type - PSToggleSwitchSpecifier - Title - PCMU - Key - pcmu_preference - DefaultValue - - - - Type - PSToggleSwitchSpecifier - Title - PCMA - Key - pcma_preference - DefaultValue - - - Type PSGroupSpecifier + + + DefaultValue + + Key + speex_16k_preference + Title + Speex 16Khz + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + speex_8k_preference + Title + Speex 8Khz + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + gsm_8k_preference + Title + GSM + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + ilbc_preference + Title + ILBC + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + pcmu_preference + Title + PCMU + Type + PSToggleSwitchSpecifier + + + DefaultValue + + Key + pcma_preference + Title + PCMA + Type + PSToggleSwitchSpecifier + + Title Tunnel @@ -197,36 +193,59 @@ PSGroupSpecifier Title Advanced + Type + PSGroupSpecifier - Type - PSToggleSwitchSpecifier - Title - Debug + DefaultValue + Key debugenable_preference - DefaultValue - + Title + Debug + Type + PSToggleSwitchSpecifier - Type - PSTextFieldSpecifier - Title - Prefix - Key - prefix_preference - DefaultValue - - IsSecure - - KeyboardType - NumberPad AutocapitalizationType None AutocorrectionType No + DefaultValue + + IsSecure + + Key + prefix_preference + KeyboardType + NumberPad + Title + Prefix + Type + PSTextFieldSpecifier + DefaultValue + + Key + substitute_+_by_00_preference + Title + Substitue + by 00 + Type + PSToggleSwitchSpecifier + + + DefaultValue + udp + Key + transport_preference + Title + Transport + Titles + + udp + tcp + Type PSMultiValueSpecifier Values @@ -234,28 +253,19 @@ udp tcp - Titles - - udp - tcp - - Title - Transport - Key - transport_preference - DefaultValue - udp - Type - PSToggleSwitchSpecifier - Title - Background mode - Key - backgroundmode_preference DefaultValue + Key + backgroundmode_preference + Title + Background mode + Type + PSToggleSwitchSpecifier + StringsTable + Root diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index 1d8d6513b..86115ee99 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -80,6 +80,7 @@ 22E0A824111C44E100B04932 /* ConsoleViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E0A81F111C44E100B04932 /* ConsoleViewController.m */; }; 22E19E1E1386AFB900FBFE87 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 22E19E1C1386AFB900FBFE87 /* Localizable.strings */; }; 22E19E5A138A89F800FBFE87 /* missed_call.png in Resources */ = {isa = PBXBuildFile; fileRef = 22E19E59138A89F800FBFE87 /* missed_call.png */; }; + 22E5AF6F1393F01800E4B43D /* FastAddressBook.m in Sources */ = {isa = PBXBuildFile; fileRef = 22E5AF6D1393F01800E4B43D /* FastAddressBook.m */; }; 22F2508E107141E100AC9B3F /* PhoneViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 22F2508C107141E100AC9B3F /* PhoneViewController.m */; }; 22F2508F107141E100AC9B3F /* PhoneViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 22F2508D107141E100AC9B3F /* PhoneViewController.xib */; }; 22F254811073D99800AC9B3F /* ringback.wav in Resources */ = {isa = PBXBuildFile; fileRef = 22F254801073D99800AC9B3F /* ringback.wav */; }; @@ -393,6 +394,8 @@ 22E0A820111C44E100B04932 /* ConsoleViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ConsoleViewController.h; sourceTree = ""; }; 22E19E1D1386AFB900FBFE87 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = Resources/en.lproj/Localizable.strings; sourceTree = ""; }; 22E19E59138A89F800FBFE87 /* missed_call.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = missed_call.png; path = Resources/missed_call.png; sourceTree = ""; }; + 22E5AF6D1393F01800E4B43D /* FastAddressBook.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FastAddressBook.m; sourceTree = ""; }; + 22E5AF6E1393F01800E4B43D /* FastAddressBook.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FastAddressBook.h; sourceTree = ""; }; 22F2508B107141E100AC9B3F /* PhoneViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PhoneViewController.h; sourceTree = ""; }; 22F2508C107141E100AC9B3F /* PhoneViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PhoneViewController.m; sourceTree = ""; }; 22F2508D107141E100AC9B3F /* PhoneViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = PhoneViewController.xib; sourceTree = ""; }; @@ -673,6 +676,8 @@ 2214EB7012F84668002A5394 /* LinphoneUI */ = { isa = PBXGroup; children = ( + 22E5AF6D1393F01800E4B43D /* FastAddressBook.m */, + 22E5AF6E1393F01800E4B43D /* FastAddressBook.h */, 22BB1D3413322A58005CD7AA /* UIEraseButton.m */, 22BB1D3513322A58005CD7AA /* UIEraseButton.h */, 2248E90C12F7E4CF00220D9C /* UIDigitButton.h */, @@ -1032,6 +1037,7 @@ 22C755601317E59C007BC101 /* UIBluetoothButton.m in Sources */, 22323037132A28AE00F10886 /* TunnelManager.cc in Sources */, 22BB1D3613322A58005CD7AA /* UIEraseButton.m in Sources */, + 22E5AF6F1393F01800E4B43D /* FastAddressBook.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; };