From 479369bab0bdffd94e311d9636d865e6f3d09644 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Wed, 16 Feb 2022 14:00:31 +0100 Subject: [PATCH] Fix SIP settings : - Deletion of account where registration has not been enabled. - Crash on new account. - Route error message on creation. --- .../settings/AccountSettingsModel.cpp | 7 +++- .../Dialogs/SettingsSipAccountsEdit.js | 41 ++++++++++--------- .../Dialogs/SettingsSipAccountsEdit.qml | 4 +- .../App/Settings/SettingsSipAccounts.qml | 2 +- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/linphone-app/src/components/settings/AccountSettingsModel.cpp b/linphone-app/src/components/settings/AccountSettingsModel.cpp index 481791f15..4fb322e08 100644 --- a/linphone-app/src/components/settings/AccountSettingsModel.cpp +++ b/linphone-app/src/components/settings/AccountSettingsModel.cpp @@ -231,8 +231,10 @@ void AccountSettingsModel::removeProxyConfig (const shared_ptrdone() == -1) { qWarning() << QStringLiteral("Unable to reset message-expiry property before removing proxy config: `%1`.") .arg(QString::fromStdString(proxyConfig->getIdentityAddress()->asString())); - }else { // Wait for update + }else if(proxyConfig->registerEnabled()) { // Wait for update mRemovingProxies.push_back(proxyConfig); + }else{// Registration is not enabled : Removing without wait. + CoreManager::getInstance()->getCore()->removeProxyConfig(proxyConfig); } emit accountSettingsUpdated(); @@ -504,8 +506,9 @@ void AccountSettingsModel::handleRegistrationStateChanged ( coreManager->getSettingsModel()->configureRlsUri(); }else if(mRemovingProxies.contains(proxy)){ mRemovingProxies.removeAll(proxy); - QTimer::singleShot(100, [proxy](){// removeProxyConfig cannot be called from callback + QTimer::singleShot(100, [proxy, this](){// removeProxyConfig cannot be called from callback CoreManager::getInstance()->getCore()->removeProxyConfig(proxy); + emit accountSettingsUpdated(); }); } if(defaultProxyConfig == proxy) diff --git a/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js b/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js index 4f503429e..14efafd61 100644 --- a/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js +++ b/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.js @@ -76,25 +76,28 @@ function formIsValid () { // ----------------------------------------------------------------------------- -function validProxyConfig () { - if (Linphone.AccountSettingsModel.addOrUpdateProxyConfig(proxyConfig, { - sipAddress: sipAddress.text, - serverAddress: serverAddress.text, - registrationDuration: registrationDuration.text, - transport: transport.currentText, - route: route.text, - conferenceUri: conferenceUri.text, - contactParams: contactParams.text, - avpfInterval: avpfInterval.text, - registerEnabled: registerEnabled.checked, - publishPresence: publishPresence.checked, - avpfEnabled: avpfEnabled.checked, - iceEnabled: iceEnabled.checked, - turnEnabled: turnEnabled.checked, - stunServer: stunServer.text, - turnUser: turnUser.text, - turnPassword: turnPassword.text - })) { +function validProxyConfig (proxyConfig) { + var data = { + sipAddress: sipAddress.text, + serverAddress: serverAddress.text, + registrationDuration: registrationDuration.text, + transport: transport.currentText, + route: route.text, + conferenceUri: conferenceUri.text, + contactParams: contactParams.text, + avpfInterval: avpfInterval.text, + registerEnabled: registerEnabled.checked, + publishPresence: publishPresence.checked, + avpfEnabled: avpfEnabled.checked, + iceEnabled: iceEnabled.checked, + turnEnabled: turnEnabled.checked, + stunServer: stunServer.text, + turnUser: turnUser.text, + turnPassword: turnPassword.text + } + + if (proxyConfig && Linphone.AccountSettingsModel.addOrUpdateProxyConfig(proxyConfig, data) + || !proxyConfig && Linphone.AccountSettingsModel.addOrUpdateProxyConfig(data)) { dialog.exit(1) } else { // TODO: Display errors on the form (if necessary). diff --git a/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml b/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml index 24cfb0cec..2b2ec6830 100644 --- a/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml +++ b/linphone-app/ui/views/App/Settings/Dialogs/SettingsSipAccountsEdit.qml @@ -15,7 +15,7 @@ DialogPlus { property bool _sipAddressOk: false property bool _serverAddressOk: false - property bool _routeOk: false + property bool _routeOk: true property bool _conferenceUriOk: true buttons: [ @@ -28,7 +28,7 @@ DialogPlus { enabled: Logic.formIsValid() text: qsTr('confirm') - onClicked: Logic.validProxyConfig() + onClicked: Logic.validProxyConfig(dialog.account ? dialog.account.proxyConfig : null) } ] diff --git a/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml b/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml index 68cbb2e02..579a7c2f7 100644 --- a/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml +++ b/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml @@ -132,7 +132,7 @@ TabContainer { TextButtonB { text: qsTr('addAccount') - onClicked: Logic.editAccount() + onClicked: Logic.editAccount(null) } }