diff --git a/Linphone/GeneratedGit.swift b/Linphone/GeneratedGit.swift index e00dcda90..4d93f7b95 100644 --- a/Linphone/GeneratedGit.swift +++ b/Linphone/GeneratedGit.swift @@ -2,6 +2,6 @@ import Foundation public enum AppGitInfo { public static let branch = "master" - public static let commit = "d39e4a0e3" + public static let commit = "0f6d8b129" public static let tag = "6.1.0-alpha" } diff --git a/Linphone/Localizable/en.lproj/Localizable.strings b/Linphone/Localizable/en.lproj/Localizable.strings index d9764e85b..6683c717d 100644 --- a/Linphone/Localizable/en.lproj/Localizable.strings +++ b/Linphone/Localizable/en.lproj/Localizable.strings @@ -53,7 +53,8 @@ "account_settings_outbound_proxy_title" = "Outbound proxy"; "account_settings_push_notification_not_available_title" = "Push notifications aren't available!"; "account_settings_push_notification_title" = "Allow push notifications"; -"account_settings_sip_proxy_url_title" = "SIP proxy server URL"; +"account_settings_sip_proxy_url_title" = "Registrar URI"; +"account_settings_outbound_proxy_title" = "Outbound SIP Proxy URI"; "account_settings_stun_server_url_title" = "STUN/TURN server URL"; "account_settings_title" = "Account settings"; "account_settings_turn_password_title" = "TURN password"; diff --git a/Linphone/Localizable/fr.lproj/Localizable.strings b/Linphone/Localizable/fr.lproj/Localizable.strings index 682daf555..efcaf761b 100644 --- a/Linphone/Localizable/fr.lproj/Localizable.strings +++ b/Linphone/Localizable/fr.lproj/Localizable.strings @@ -53,7 +53,8 @@ "account_settings_outbound_proxy_title" = "Serveur mandataire sortant"; "account_settings_push_notification_not_available_title" = "Notifications push non disponibles"; "account_settings_push_notification_title" = "Activer les notifications"; -"account_settings_sip_proxy_url_title" = "URL du serveur mandataire"; +"account_settings_sip_proxy_url_title" = "Registrar URI"; +"account_settings_outbound_proxy_title" = "URI du proxy SIP sortant"; "account_settings_stun_server_url_title" = "URL du serveur STUN/TURN"; "account_settings_title" = "Paramètres de compte"; "account_settings_turn_password_title" = "Mot de passe TURN"; diff --git a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift index bc49fc824..336c0a0a5 100644 --- a/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift +++ b/Linphone/UI/Assistant/Fragments/ThirdPartySipAccountLoginFragment.swift @@ -35,8 +35,8 @@ struct ThirdPartySipAccountLoginFragment: View { @FocusState var isPasswordFocused: Bool @FocusState var isDomainFocused: Bool @FocusState var isDisplayNameFocused: Bool - @FocusState var isSipProxyUrlFocused: Bool @FocusState var isAuthIdFocused: Bool + @FocusState var isSipProxyUrlFocused: Bool @FocusState var isOutboundProxyFocused: Bool var body: some View { @@ -289,13 +289,14 @@ struct ThirdPartySipAccountLoginFragment: View { ) .focused($isAuthIdFocused) } + .padding(.bottom) VStack(alignment: .leading) { Text("account_settings_sip_proxy_url_title") .default_text_style_700(styleSize: 15) .padding(.bottom, -5) - TextField("account_settings_sip_proxy_url_title", text: $accountLoginViewModel.outboundProxy) + TextField("account_settings_sip_proxy_url_title", text: $accountLoginViewModel.sipProxyUrl) .id(2) .default_text_style(styleSize: 15) .frame(height: 25) @@ -306,11 +307,33 @@ struct ThirdPartySipAccountLoginFragment: View { .overlay( RoundedRectangle(cornerRadius: 60) .inset(by: 0.5) - .stroke(isOutboundProxyFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) + .stroke(isSipProxyUrlFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) ) - .focused($isOutboundProxyFocused) + .focused($isSipProxyUrlFocused) } .padding(.bottom) + + VStack(alignment: .leading) { + Text("account_settings_outbound_proxy_title") + .default_text_style_700(styleSize: 15) + .padding(.bottom, -5) + + TextField("account_settings_outbound_proxy_title", text: $accountLoginViewModel.outboundProxy) + .id(3) + .default_text_style(styleSize: 15) + .frame(height: 25) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .background(.white) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(isOutboundProxyFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) + ) + .focused($isOutboundProxyFocused) + } + .padding(.bottom) } } .frame(maxWidth: SharedMainViewModel.shared.maxWidth) diff --git a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift index f3839352d..cd557a89c 100644 --- a/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift +++ b/Linphone/UI/Assistant/Viewmodel/AccountLoginViewModel.swift @@ -30,6 +30,7 @@ class AccountLoginViewModel: ObservableObject { @Published var displayName: String = "" @Published var transportType: String = "TLS" @Published var authId: String = "" + @Published var sipProxyUrl: String = "" @Published var outboundProxy: String = "" private var mCoreDelegate: CoreDelegate! @@ -102,18 +103,27 @@ class AccountLoginViewModel: ObservableObject { // We also need to configure where the proxy server is located var serverAddress: Address - if (!self.outboundProxy.isEmpty) { - let server = self.outboundProxy.starts(with: "sip:") ? self.outboundProxy : String("sip:" + self.outboundProxy) + if (!self.sipProxyUrl.isEmpty) { + let server = self.sipProxyUrl.starts(with: "sip:") ? self.sipProxyUrl : String("sip:" + self.sipProxyUrl) serverAddress = try Factory.Instance.createAddress(addr: server) } else { serverAddress = try Factory.Instance.createAddress(addr: String("sip:" + self.domain)) } - let address = serverAddress - // We use the Address object to easily set the transport protocol - try address.setTransport(newValue: transport) - try accountParams.setServeraddress(newValue: address) + try serverAddress.setTransport(newValue: transport) + try accountParams.setServeraddress(newValue: serverAddress) + + var routeAddress: Address + if (!self.outboundProxy.isEmpty) { + let server = self.outboundProxy.starts(with: "sip:") ? self.outboundProxy : String("sip:" + self.outboundProxy) + routeAddress = try Factory.Instance.createAddress(addr: server) + try routeAddress.setTransport(newValue: transport) + try accountParams.setRoutesaddresses(newValue: [routeAddress]) + } else { + try accountParams.setRoutesaddresses(newValue: []) + } + // And we ensure the account will start the registration process accountParams.registerEnabled = true diff --git a/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift b/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift index 82ac76af4..6b0e596e3 100644 --- a/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift +++ b/Linphone/UI/Main/Settings/Fragments/AccountSettingsFragment.swift @@ -36,6 +36,7 @@ struct AccountSettingsFragment: View { @FocusState var isTurnUsernameFocused: Bool @FocusState var isTurnPasswordFocused: Bool @FocusState var isSipProxyUrlFocused: Bool + @FocusState var isOutboundProxyFocused: Bool @FocusState var isSettingsExpireFocused: Bool @FocusState var isConferenceFactoryUriFocused: Bool @FocusState var isAudioVideoConferenceFactoryUriFocused: Bool @@ -354,8 +355,25 @@ struct AccountSettingsFragment: View { .focused($isSipProxyUrlFocused) } - Toggle("account_settings_outbound_proxy_title", isOn: $accountSettingsViewModel.outboundProxy) - .default_text_style_700(styleSize: 15) + VStack(alignment: .leading) { + Text("account_settings_outbound_proxy_title") + .default_text_style_700(styleSize: 15) + .padding(.bottom, -5) + + TextField("account_settings_outbound_proxy_title", text: $accountSettingsViewModel.outboundProxy) + .default_text_style(styleSize: 15) + .frame(height: 25) + .padding(.horizontal, 20) + .padding(.vertical, 15) + .background(.white) + .cornerRadius(60) + .overlay( + RoundedRectangle(cornerRadius: 60) + .inset(by: 0.5) + .stroke(isOutboundProxyFocused ? Color.orangeMain500 : Color.gray200, lineWidth: 1) + ) + .focused($isOutboundProxyFocused) + } Toggle("account_settings_avpf_title", isOn: $accountSettingsViewModel.avpf) .default_text_style_700(styleSize: 15) diff --git a/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift b/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift index 2670e4ec5..af91613cf 100644 --- a/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift +++ b/Linphone/UI/Main/Settings/ViewModel/AccountSettingsViewModel.swift @@ -39,7 +39,7 @@ class AccountSettingsViewModel: ObservableObject { @Published var turnPassword: String @Published var transport: String @Published var sipProxyUrl: String - @Published var outboundProxy: Bool + @Published var outboundProxy: String @Published var avpf: Bool @Published var bundleMode: Bool @Published var cpimInBasicConversations: Bool @@ -82,7 +82,7 @@ class AccountSettingsViewModel: ObservableObject { } self.sipProxyUrl = accountModel.account.params?.serverAddress?.asStringUriOnly() ?? "" - self.outboundProxy = accountModel.account.params?.outboundProxyEnabled ?? false + self.outboundProxy = accountModel.account.params?.routesAddresses.first?.asStringUriOnly() ?? "" self.avpf = accountModel.account.avpfEnabled self.bundleMode = accountModel.account.params?.rtpBundleEnabled ?? false self.cpimInBasicConversations = accountModel.account.params?.cpimInBasicChatRoomEnabled ?? false @@ -140,7 +140,29 @@ class AccountSettingsViewModel: ObservableObject { try? newParams.setServeraddress(newValue: serverAddress) } } - newParams.outboundProxyEnabled = self.outboundProxy + + if !self.outboundProxy.isEmpty { + Log.info("\(AccountSettingsViewModel.TAG) Outbound proxy server set to \(self.outboundProxy)") + if let outboundProxyAddress = core.interpretUrl(url: self.outboundProxy, applyInternationalPrefix: false) { + var transportTmp: TransportType = .Tls + if self.transport == "TLS" { + transportTmp = .Tls + } else if self.transport == "TCP" { + transportTmp = .Tcp + } else if self.transport == "UDP" { + transportTmp = .Udp + } else { + transportTmp = .Dtls + } + + try? outboundProxyAddress.setTransport(newValue: transportTmp) + try? newParams.setRoutesaddresses(newValue: [outboundProxyAddress]) + } else { + Log.error("\(AccountSettingsViewModel.TAG) Failed to parse outbound proxy server!") + } + } else { + try? newParams.setRoutesaddresses(newValue: []) + } if let natPolicy = self.natPolicy { print("\(AccountSettingsViewModel.TAG) Also applying changes to NAT policy")