From c2849ddb562abd37a092a295d03c95a2ea50e2f2 Mon Sep 17 00:00:00 2001 From: QuentinArguillere Date: Tue, 21 Sep 2021 15:07:31 +0200 Subject: [PATCH] =?UTF-8?q?Add=20an=20equivalence=20between=20=E2=80=9Csip?= =?UTF-8?q?s:=E2=80=9D=20uri=20and=20TLS=20transport=20in=20the=20account?= =?UTF-8?q?=20settings?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Classes/LinphoneCoreSettingsStore.m | 38 ++++++++++++++++++----------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/Classes/LinphoneCoreSettingsStore.m b/Classes/LinphoneCoreSettingsStore.m index 7a6193432..219841b65 100644 --- a/Classes/LinphoneCoreSettingsStore.m +++ b/Classes/LinphoneCoreSettingsStore.m @@ -202,15 +202,19 @@ [self setCString:tmp forKey:@"account_proxy_preference"]; } const char *tname = "udp"; - switch (linphone_address_get_transport(proxy_addr)) { - case LinphoneTransportTcp: - tname = "tcp"; - break; - case LinphoneTransportTls: - tname = "tls"; - break; - default: - break; + if (linphone_address_get_secure(proxy_addr)) { + tname = "tls"; + } else { + switch (linphone_address_get_transport(proxy_addr)) { + case LinphoneTransportTcp: + tname = "tcp"; + break; + case LinphoneTransportTls: + tname = "tls"; + break; + default: + break; + } } linphone_address_unref(proxy_addr); [self setCString:tname forKey:@"account_transport_preference"]; @@ -495,6 +499,7 @@ NSString *userID = [self stringForKey:@"account_userid_preference"]; NSString *domain = [self stringForKey:@"account_mandatory_domain_preference"]; NSString *transport = [self stringForKey:@"account_transport_preference"]; + BOOL isTransportTls = [transport isEqualToString:@"tls"]; NSString *accountHa1 = [self stringForKey:@"ha1_preference"]; NSString *accountPassword = [self stringForKey:@"account_mandatory_password_preference"]; NSString *accountAlgoPreference = [self stringForKey:@"ha1_algo_preference"]; @@ -515,8 +520,12 @@ proxyAddress = domain; } - if (![proxyAddress hasPrefix:@"sip:"] && ![proxyAddress hasPrefix:@"sips:"]) { - proxyAddress = [NSString stringWithFormat:@"sip:%@", proxyAddress]; + if (![proxyAddress hasPrefix:@"sip:"] && ![proxyAddress hasPrefix:@"sips:"]) { + if (isTransportTls) { + proxyAddress = [NSString stringWithFormat:@"sips:%@", proxyAddress]; + } else { + proxyAddress = [NSString stringWithFormat:@"sip:%@", proxyAddress]; + } } LinphoneAddress *proxy_addr = linphone_core_interpret_url(LC, proxyAddress.UTF8String); @@ -525,7 +534,7 @@ LinphoneTransportType type = LinphoneTransportUdp; if ([transport isEqualToString:@"tcp"]) type = LinphoneTransportTcp; - else if ([transport isEqualToString:@"tls"]) + else if (isTransportTls) type = LinphoneTransportTls; linphone_address_set_transport(proxy_addr, type); @@ -538,8 +547,9 @@ if (account == NULL) goto bad_proxy; - - LinphoneAddress *linphoneAddress = linphone_core_interpret_url(LC, "sip:user@domain.com"); + + LinphoneAddress *linphoneAddress; + linphoneAddress = linphone_core_interpret_url(LC, isTransportTls ? "sips:user@domain.com" : "sip:user@domain.com"); linphone_address_set_username(linphoneAddress, username.UTF8String); if ([LinphoneManager.instance lpConfigBoolForKey:@"use_phone_number" inSection:@"assistant"]) { char *user = linphone_account_normalize_phone_number(account, username.UTF8String);