diff --git a/Classes/Base.lproj/DialerView.xib b/Classes/Base.lproj/DialerView.xib index a09ba2413..75b555ecc 100644 --- a/Classes/Base.lproj/DialerView.xib +++ b/Classes/Base.lproj/DialerView.xib @@ -1,8 +1,8 @@ - + - + @@ -51,7 +51,7 @@ - + diff --git a/Classes/Base.lproj/DialerView~ipad.xib b/Classes/Base.lproj/DialerView~ipad.xib index 6f5746b62..dbb19c419 100644 --- a/Classes/Base.lproj/DialerView~ipad.xib +++ b/Classes/Base.lproj/DialerView~ipad.xib @@ -1,8 +1,8 @@ - + - + @@ -68,7 +68,7 @@ - + @@ -366,7 +366,7 @@ - + diff --git a/Classes/ChatConversationCreateTableView.m b/Classes/ChatConversationCreateTableView.m index 9c07f4a2d..293bbf167 100644 --- a/Classes/ChatConversationCreateTableView.m +++ b/Classes/ChatConversationCreateTableView.m @@ -45,7 +45,7 @@ }]; // also add current entry, if not listed NSString *nsuri = filter.lowercaseString; - LinphoneAddress *addr = linphone_core_interpret_url(LC, nsuri.UTF8String); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:nsuri]; if (addr) { char *uri = linphone_address_as_string(addr); nsuri = [NSString stringWithUTF8String:uri]; diff --git a/Classes/DialerView.m b/Classes/DialerView.m index a62631219..48c63d7e5 100644 --- a/Classes/DialerView.m +++ b/Classes/DialerView.m @@ -328,7 +328,7 @@ static UICompositeViewDescription *compositeDescription = nil; [_addressField resignFirstResponder]; } if (textField.text.length > 0) { - LinphoneAddress *addr = linphone_core_interpret_url(LC, textField.text.UTF8String); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:textField.text]; [LinphoneManager.instance call:addr]; if (addr) linphone_address_destroy(addr); @@ -390,7 +390,7 @@ static UICompositeViewDescription *compositeDescription = nil; - (void)onOneLongClick:(id)sender { LinphoneManager *lm = LinphoneManager.instance; NSString *voiceMail = [lm lpConfigStringForKey:@"voice_mail_uri"]; - LinphoneAddress *addr = linphone_core_interpret_url(LC, voiceMail ? voiceMail.UTF8String : NULL); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:voiceMail]; if (addr) { linphone_address_set_display_name(addr, NSLocalizedString(@"Voice mail", nil).UTF8String); [lm call:addr]; diff --git a/Classes/LinphoneUI/UICallButton.m b/Classes/LinphoneUI/UICallButton.m index 560415d0e..4cf7991a7 100644 --- a/Classes/LinphoneUI/UICallButton.m +++ b/Classes/LinphoneUI/UICallButton.m @@ -86,7 +86,7 @@ } if ([address length] > 0) { - LinphoneAddress *addr = linphone_core_interpret_url(LC, address.UTF8String); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:address]; [LinphoneManager.instance call:addr]; if (addr) linphone_address_destroy(addr); diff --git a/Classes/LinphoneUI/UIContactDetailsCell.m b/Classes/LinphoneUI/UIContactDetailsCell.m index 03d1a3631..14325e32c 100644 --- a/Classes/LinphoneUI/UIContactDetailsCell.m +++ b/Classes/LinphoneUI/UIContactDetailsCell.m @@ -90,14 +90,14 @@ } - (IBAction)onCallClick:(id)event { - LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text]; [LinphoneManager.instance call:addr]; if (addr) linphone_address_destroy(addr); } - (IBAction)onChatClick:(id)event { - LinphoneAddress *addr = linphone_core_interpret_url(LC, _addressLabel.text.UTF8String); + LinphoneAddress *addr = [LinphoneUtils normalizeSipOrPhoneAddress:_addressLabel.text]; if (addr == NULL) return; ChatConversationView *view = VIEW(ChatConversationView); diff --git a/Classes/Utils/FastAddressBook.m b/Classes/Utils/FastAddressBook.m index ac6923118..5ebc98349 100644 --- a/Classes/Utils/FastAddressBook.m +++ b/Classes/Utils/FastAddressBook.m @@ -76,22 +76,15 @@ static void sync_address_book(ABAddressBookRef addressBook, CFDictionaryRef info + (NSString *)normalizeSipURI:(NSString *)address { // replace all whitespaces (non-breakable, utf8 nbsp etc.) by the "classical" whitespace - address = [[address componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] - componentsJoinedByString:@" "]; - NSString *normalizedSipAddress = nil; - LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, [address UTF8String]); - if (linphoneAddress != NULL) { - char *tmp = linphone_address_as_string_uri_only(linphoneAddress); - if (tmp != NULL) { - normalizedSipAddress = [NSString stringWithUTF8String:tmp]; - // remove transport, if any - NSRange pos = [normalizedSipAddress rangeOfString:@";"]; - if (pos.location != NSNotFound) { - normalizedSipAddress = [normalizedSipAddress substringToIndex:pos.location]; - } - ms_free(tmp); - } - linphone_address_destroy(linphoneAddress); + NSString *normalizedSipAddress = [[address + componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]] componentsJoinedByString:@" "]; + LinphoneAddress *addr = linphone_core_interpret_url(LC, [address UTF8String]); + if (addr != NULL) { + linphone_address_clean(addr); + char *tmp = linphone_address_as_string(addr); + normalizedSipAddress = [NSString stringWithUTF8String:tmp]; + ms_free(tmp); + linphone_address_destroy(addr); } return normalizedSipAddress; } diff --git a/Classes/Utils/Utils.h b/Classes/Utils/Utils.h index 7b738d6d3..2f337533c 100644 --- a/Classes/Utils/Utils.h +++ b/Classes/Utils/Utils.h @@ -32,6 +32,8 @@ + (void)buttonMultiViewApplyAttributes:(NSDictionary*)attributes button:(UIButton*)button; + (NSString *)deviceName; ++ (LinphoneAddress *)normalizeSipOrPhoneAddress:(NSString *)addr; + typedef enum { LinphoneDateHistoryList, LinphoneDateHistoryDetails, diff --git a/Classes/Utils/Utils.m b/Classes/Utils/Utils.m index 7d02ffd6f..e29bdcccb 100644 --- a/Classes/Utils/Utils.m +++ b/Classes/Utils/Utils.m @@ -339,6 +339,26 @@ return [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; } ++ (LinphoneAddress *)normalizeSipOrPhoneAddress:(NSString *)value { + if (!value) { + return NULL; + } + + LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); + LinphoneAddress *addr = linphone_proxy_config_normalize_sip_uri(cfg, value.UTF8String); + + // since user wants to escape plus, we assume it expects to have phone numbers by default + if (addr && cfg && linphone_proxy_config_get_dial_escape_plus(cfg)) { + char *phone = linphone_proxy_config_normalize_phone_number(cfg, value.UTF8String); + if (phone) { + linphone_address_set_username(addr, phone); + ms_free(phone); + } + } + + return addr; +} + @end @implementation NSNumber (HumanReadableSize) diff --git a/Settings/InAppSettings.bundle/Account.plist b/Settings/InAppSettings.bundle/Account.plist index 52d668dfa..4dd0e4f48 100644 --- a/Settings/InAppSettings.bundle/Account.plist +++ b/Settings/InAppSettings.bundle/Account.plist @@ -4,7 +4,6 @@ PreferenceSpecifiers - Type PSToggleSwitchSpecifier @@ -205,7 +204,7 @@ Key account_prefix_preference Title - Prefix + Country code prefix Type PSTextFieldSpecifier IASKTextAlignment @@ -217,11 +216,11 @@ Key account_substitute_+_by_00_preference Title - Substitute + by 00 + Substitute + in phone numbers Type PSToggleSwitchSpecifier - + Type PSToggleSwitchSpecifier Title @@ -231,7 +230,7 @@ DefaultValue - + Key account_mandatory_remove_button Title diff --git a/TestsUI/CallTester.h b/TestsUI/CallTester.h index 9f89b98e3..0ae418841 100644 --- a/TestsUI/CallTester.h +++ b/TestsUI/CallTester.h @@ -2,7 +2,7 @@ // CallTester.h // linphone // -// Created by Gautier Pelloux-Prayer on 24/08/15. +// Created by Gautier Pelloux-Prayer on 04/04/16. // // diff --git a/TestsUI/CallTester.m b/TestsUI/CallTester.m index bc2085602..ae1c92d5c 100644 --- a/TestsUI/CallTester.m +++ b/TestsUI/CallTester.m @@ -2,17 +2,17 @@ // CallTester.m // linphone // -// Created by Gautier Pelloux-Prayer on 24/08/15. +// Created by Gautier Pelloux-Prayer on 04/04/16. // // #import "CallTester.h" -#include "LinphoneManager.h" @implementation CallTester +#pragma mark - Setup + - (void)beforeAll { - [super beforeAll]; [self switchToValidAccountIfNeeded]; } @@ -24,40 +24,27 @@ [tester tapViewWithAccessibilityLabel:@"Dialer"]; } -- (void)afterEach { - if ([tester tryFindingTappableViewWithAccessibilityLabel:@"Hangup" error:nil]) { - [tester tapViewWithAccessibilityLabel:@"Hangup"]; - } - [super afterEach]; -} -#pragma mark - Tools - -- (void)callURI:(NSString *)address { - [tester enterText:address intoViewWithAccessibilityLabel:@"Enter an address"]; - [tester tapViewWithAccessibilityLabel:@"Call" traits:UIAccessibilityTraitButton]; -} - #pragma mark - Tests -- (void)testCallMeBusy { - [self callURI:[self me]]; - [tester waitForViewWithAccessibilityLabel:[NSString stringWithFormat:@"%@ is busy.", [self me]]]; - [tester tapViewWithAccessibilityLabel:@"Cancel" traits:UIAccessibilityTraitButton]; +- (void)testCallPhoneNumberEscaped { + LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); + linphone_proxy_config_set_dial_escape_plus(cfg, TRUE); + NSString *num = @"+3312345-6789"; + [tester enterText:num intoViewWithAccessibilityLabel:@"Enter an address"]; + [tester tapViewWithAccessibilityLabel:@"Call" traits:UIAccessibilityTraitButton]; + [tester waitForViewWithAccessibilityLabel:@"0033123456789 is not registered."]; + [tester tapViewWithAccessibilityLabel:@"Cancel"]; + linphone_proxy_config_set_dial_escape_plus(cfg, FALSE); } -- (void)testCallUnregisteredUser { - NSString *unregisteredUser = [self getUUID]; - [self callURI:unregisteredUser]; - [tester waitForViewWithAccessibilityLabel:[NSString stringWithFormat:@"%@ is not registered.", unregisteredUser]]; - [tester tapViewWithAccessibilityLabel:@"Cancel" traits:UIAccessibilityTraitButton]; -} - -- (void)testDialInvalidSIPURI { - NSString *user = @"123 😀"; - [self callURI:user]; - [tester waitForViewWithAccessibilityLabel:[NSString - stringWithFormat:@"Cannot call %@.\nReason was: Call failed", user]]; - [tester tapViewWithAccessibilityLabel:@"Cancel" traits:UIAccessibilityTraitButton]; +- (void)testCallSIPNotEscaped { + LinphoneProxyConfig *cfg = linphone_core_get_default_proxy_config(LC); + linphone_proxy_config_set_dial_escape_plus(cfg, FALSE); + NSString *num = @"+3312345-6789"; + [tester enterText:num intoViewWithAccessibilityLabel:@"Enter an address"]; + [tester tapViewWithAccessibilityLabel:@"Call" traits:UIAccessibilityTraitButton]; + [tester waitForViewWithAccessibilityLabel:@"+3312345-6789 is not registered."]; + [tester tapViewWithAccessibilityLabel:@"Cancel"]; } @end diff --git a/linphone.xcodeproj/project.pbxproj b/linphone.xcodeproj/project.pbxproj index e6872d770..371bd5c36 100755 --- a/linphone.xcodeproj/project.pbxproj +++ b/linphone.xcodeproj/project.pbxproj @@ -532,6 +532,7 @@ 634610061B61330300548952 /* UILabel+Boldify.m in Sources */ = {isa = PBXBuildFile; fileRef = 634610051B61330300548952 /* UILabel+Boldify.m */; }; 6346100F1B61409800548952 /* CallOutgoingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6346100E1B61409800548952 /* CallOutgoingView.m */; }; 634610121B6140A500548952 /* CallOutgoingView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 634610101B6140A500548952 /* CallOutgoingView.xib */; }; + 63510D9E1CB2757300FB5E90 /* CallTester.m in Sources */ = {isa = PBXBuildFile; fileRef = 63510D981CB2752600FB5E90 /* CallTester.m */; }; 635173F91BA082A40095EB0A /* UIChatBubblePhotoCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 635173F81BA082A40095EB0A /* UIChatBubblePhotoCell.m */; }; 6352A5751BE0D4B800594C1C /* CallSideMenuView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6352A5731BE0D4B800594C1C /* CallSideMenuView.m */; }; 6352A5761BE0D4B800594C1C /* CallSideMenuView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6352A5741BE0D4B800594C1C /* CallSideMenuView.xib */; }; @@ -1436,6 +1437,8 @@ 6346100D1B61409800548952 /* CallOutgoingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallOutgoingView.h; sourceTree = ""; }; 6346100E1B61409800548952 /* CallOutgoingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallOutgoingView.m; sourceTree = ""; }; 634610111B6140A500548952 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/CallOutgoingView.xib; sourceTree = ""; }; + 63510D971CB2752600FB5E90 /* CallTester.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallTester.h; sourceTree = ""; }; + 63510D981CB2752600FB5E90 /* CallTester.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CallTester.m; sourceTree = ""; }; 635173F71BA082A40095EB0A /* UIChatBubblePhotoCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIChatBubblePhotoCell.h; sourceTree = ""; }; 635173F81BA082A40095EB0A /* UIChatBubblePhotoCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UIChatBubblePhotoCell.m; sourceTree = ""; }; 6352A5721BE0D4B800594C1C /* CallSideMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CallSideMenuView.h; sourceTree = ""; }; @@ -2261,6 +2264,8 @@ 630589E61B4E810900EFAE36 /* AssistantTester.m */, 63CAACD41C91D0D100216F8D /* NotificationTester.h */, 63CAACD51C91D0D100216F8D /* NotificationTester.m */, + 63510D971CB2752600FB5E90 /* CallTester.h */, + 63510D981CB2752600FB5E90 /* CallTester.m */, ); path = TestsUI; sourceTree = ""; @@ -3891,6 +3896,7 @@ 630589EB1B4E810900EFAE36 /* AssistantTester.m in Sources */, 630589E71B4E810900EFAE36 /* ChatTester.m in Sources */, 630589E81B4E810900EFAE36 /* ContactsTester.m in Sources */, + 63510D9E1CB2757300FB5E90 /* CallTester.m in Sources */, 63CAACDB1C91D10200216F8D /* NotificationTester.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/submodules/linphone b/submodules/linphone index cff024b8f..3f495448e 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit cff024b8f9f73b6f708b5f50ad86128cb7dd8607 +Subproject commit 3f495448e11a973f7d5c7cadebd646f9ae76dde2