Fix the prefix handling in interpretUrl when calling a phone number and add this in Settings

This commit is contained in:
Benoit Martins 2025-11-17 15:29:45 +01:00
parent 4fbb43f38c
commit e748a001bf
8 changed files with 23 additions and 6 deletions

View file

@ -318,7 +318,7 @@ final class ContactsManager: ObservableObject {
// Clear existing addresses and add new ones // Clear existing addresses and add new ones
friend.addresses.forEach { friend.removeAddress(address: $0) } friend.addresses.forEach { friend.removeAddress(address: $0) }
for sipAddress in contact.sipAddresses where !sipAddress.isEmpty { for sipAddress in contact.sipAddresses where !sipAddress.isEmpty {
if let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: true), if let address = core.interpretUrl(url: sipAddress, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)),
!friend.addresses.contains(where: { $0.asString() == address.asString() }) { !friend.addresses.contains(where: { $0.asString() == address.asString() }) {
friend.addAddress(address: address) friend.addAddress(address: address)
} }

View file

@ -47,6 +47,8 @@
"account_settings_im_encryption_mandatory_title" = "IM encryption mandatory"; "account_settings_im_encryption_mandatory_title" = "IM encryption mandatory";
"account_settings_lime_server_url_title" = "E2E encryption keys server URL"; "account_settings_lime_server_url_title" = "E2E encryption keys server URL";
"account_settings_mwi_uri_title" = "MWI server URI (Message Waiting Indicator)"; "account_settings_mwi_uri_title" = "MWI server URI (Message Waiting Indicator)";
"account_settings_apply_international_prefix_title" = "Format phone numbers using international prefix";
"account_settings_replace_plus_by_00_title" = "Replace + by 00 when formatting phone numbers";
"account_settings_nat_policy_title" = "NAT policy settings"; "account_settings_nat_policy_title" = "NAT policy settings";
"account_settings_outbound_proxy_title" = "Outbound proxy"; "account_settings_outbound_proxy_title" = "Outbound proxy";
"account_settings_push_notification_not_available_title" = "Push notifications aren't available!"; "account_settings_push_notification_not_available_title" = "Push notifications aren't available!";

View file

@ -47,6 +47,8 @@
"account_settings_im_encryption_mandatory_title" = "Chiffrement obligatoire des conversations"; "account_settings_im_encryption_mandatory_title" = "Chiffrement obligatoire des conversations";
"account_settings_lime_server_url_title" = "URL du serveur d'échange de clés de chiffrement"; "account_settings_lime_server_url_title" = "URL du serveur d'échange de clés de chiffrement";
"account_settings_mwi_uri_title" = "URI du serveur MWI (Message Waiting Indicator)"; "account_settings_mwi_uri_title" = "URI du serveur MWI (Message Waiting Indicator)";
"account_settings_apply_international_prefix_title" = "Formater les numéros en utilisant l'indicatif international";
"account_settings_replace_plus_by_00_title" = "Remplacer + par 00 lors du formatage des numéros de téléphone";
"account_settings_nat_policy_title" = "Paramètres de politique NAT"; "account_settings_nat_policy_title" = "Paramètres de politique NAT";
"account_settings_outbound_proxy_title" = "Serveur mandataire sortant"; "account_settings_outbound_proxy_title" = "Serveur mandataire sortant";
"account_settings_push_notification_not_available_title" = "Notifications push non disponibles"; "account_settings_push_notification_not_available_title" = "Notifications push non disponibles";

View file

@ -156,7 +156,7 @@ struct ContactInnerActionsFragment: View {
.background(.white) .background(.white)
.onTapGesture { .onTapGesture {
CoreContext.shared.doOnCoreQueue { core in CoreContext.shared.doOnCoreQueue { core in
let address = core.interpretUrl(url: contactAvatarModel.phoneNumbersWithLabel[index].phoneNumber, applyInternationalPrefix: true) let address = core.interpretUrl(url: contactAvatarModel.phoneNumbersWithLabel[index].phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core))
if address != nil { if address != nil {
TelecomManager.shared.doCallOrJoinConf(address: address!) TelecomManager.shared.doCallOrJoinConf(address: address!)
} }

View file

@ -153,7 +153,7 @@ struct ContactInnerFragment: View {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
} }
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) {
telecomManager.doCallOrJoinConf(address: address, isVideo: false) telecomManager.doCallOrJoinConf(address: address, isVideo: false)
} }
} else { } else {
@ -194,7 +194,7 @@ struct ContactInnerFragment: View {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
} }
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) {
contactsListViewModel.createOneToOneChatRoomWith(remote: address) contactsListViewModel.createOneToOneChatRoomWith(remote: address)
} }
} else { } else {
@ -235,7 +235,7 @@ struct ContactInnerFragment: View {
Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ") Log.error("[ContactInnerFragment] unable to create address for a new outgoing call : \(contactAvatarModel.address) \(error) ")
} }
} else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 { } else if contactAvatarModel.addresses.count < 1 && contactAvatarModel.phoneNumbersWithLabel.count == 1 {
if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: true) { if let firstPhoneNumbersWithLabel = contactAvatarModel.phoneNumbersWithLabel.first, let address = core.interpretUrl(url: firstPhoneNumbersWithLabel.phoneNumber, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core)) {
telecomManager.doCallOrJoinConf(address: address, isVideo: true) telecomManager.doCallOrJoinConf(address: address, isVideo: true)
} }
} else { } else {

View file

@ -157,7 +157,7 @@ class StartCallViewModel: ObservableObject {
func interpretAndStartCall() { func interpretAndStartCall() {
CoreContext.shared.doOnCoreQueue { core in CoreContext.shared.doOnCoreQueue { core in
let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: true) let address = core.interpretUrl(url: self.searchField, applyInternationalPrefix: LinphoneUtils.applyInternationalPrefix(core: core))
if address != nil { if address != nil {
TelecomManager.shared.doCallOrJoinConf(address: address!) TelecomManager.shared.doCallOrJoinConf(address: address!)
} }

View file

@ -132,6 +132,12 @@ struct AccountSettingsFragment: View {
) )
.focused($isMwiUriFocused) .focused($isMwiUriFocused)
} }
Toggle("account_settings_apply_international_prefix_title", isOn: $accountSettingsViewModel.applyInternationalPrefix)
.default_text_style_700(styleSize: 15)
Toggle("account_settings_replace_plus_by_00_title", isOn: $accountSettingsViewModel.replacePlusBy00)
.default_text_style_700(styleSize: 15)
} }
.padding(.vertical, 30) .padding(.vertical, 30)
.padding(.horizontal, 20) .padding(.horizontal, 20)

View file

@ -30,6 +30,8 @@ class AccountSettingsViewModel: ObservableObject {
@Published var imEncryptionMandatory: Bool @Published var imEncryptionMandatory: Bool
@Published var voicemailUri: String @Published var voicemailUri: String
@Published var mwiUri: String @Published var mwiUri: String
@Published var applyInternationalPrefix: Bool
@Published var replacePlusBy00: Bool
@Published var stunServerUrl: String @Published var stunServerUrl: String
@Published var enableIce: Bool @Published var enableIce: Bool
@Published var enableTurn: Bool @Published var enableTurn: Bool
@ -57,6 +59,8 @@ class AccountSettingsViewModel: ObservableObject {
self.imEncryptionMandatory = accountModel.account.params?.instantMessagingEncryptionMandatory ?? false self.imEncryptionMandatory = accountModel.account.params?.instantMessagingEncryptionMandatory ?? false
self.voicemailUri = accountModel.account.params?.voicemailAddress?.asStringUriOnly() ?? "" self.voicemailUri = accountModel.account.params?.voicemailAddress?.asStringUriOnly() ?? ""
self.mwiUri = accountModel.account.params?.mwiServerAddress?.asStringUriOnly() ?? "" self.mwiUri = accountModel.account.params?.mwiServerAddress?.asStringUriOnly() ?? ""
self.applyInternationalPrefix = accountModel.account.params?.useInternationalPrefixForCallsAndChats ?? false
self.replacePlusBy00 = accountModel.account.params?.dialEscapePlusEnabled ?? false
self.natPolicy = accountModel.account.params?.natPolicy self.natPolicy = accountModel.account.params?.natPolicy
self.stunServerUrl = accountModel.account.params?.natPolicy?.stunServer ?? "" self.stunServerUrl = accountModel.account.params?.natPolicy?.stunServer ?? ""
@ -190,6 +194,9 @@ class AccountSettingsViewModel: ObservableObject {
newParams.voicemailAddress = nil newParams.voicemailAddress = nil
} }
newParams.useInternationalPrefixForCallsAndChats = self.applyInternationalPrefix
newParams.dialEscapePlusEnabled = self.replacePlusBy00
let expireInt: Int = { let expireInt: Int = {
if !self.expire.isEmpty { if !self.expire.isEmpty {
return Int(self.expire) ?? 31536000 return Int(self.expire) ?? 31536000