From b709a6af693da82ce659999751ca6f268c71a53a Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 21 Jan 2022 11:47:48 +0100 Subject: [PATCH] - change user agent for device name. - add a settings to change device name (default is machine hostname) - fix table layout : no more empty line at top (eg. in network protocol and ports settings) --- CHANGELOG.md | 2 + linphone-app/assets/languages/da.ts | 5 + linphone-app/assets/languages/de.ts | 5 + linphone-app/assets/languages/en.ts | 5 + linphone-app/assets/languages/es.ts | 5 + linphone-app/assets/languages/fr_FR.ts | 5 + linphone-app/assets/languages/hu.ts | 5 + linphone-app/assets/languages/it.ts | 5 + linphone-app/assets/languages/ja.ts | 5 + linphone-app/assets/languages/lt.ts | 5 + linphone-app/assets/languages/pt_BR.ts | 5 + linphone-app/assets/languages/ru.ts | 5 + linphone-app/assets/languages/sv.ts | 5 + linphone-app/assets/languages/tr.ts | 5 + linphone-app/assets/languages/uk.ts | 5 + linphone-app/assets/languages/zh_CN.ts | 5 + .../src/components/core/CoreManager.cpp | 16 +- .../src/components/core/CoreManager.hpp | 1 + .../settings/AccountSettingsModel.hpp | 18 +- .../src/components/settings/SettingsModel.cpp | 18 + .../src/components/settings/SettingsModel.hpp | 14 + linphone-app/src/utils/Utils.cpp | 10 + linphone-app/src/utils/Utils.hpp | 1 + .../Common/Form/Placements/FormTable.qml | 4 +- .../App/Settings/SettingsSipAccounts.qml | 425 +++++++++--------- 25 files changed, 357 insertions(+), 227 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6a4488e41..7e2ecb348 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Option to enable message notifications. - CPIM on basic chat rooms. - New event on new messages in chat and a shortcut to go to the end of chat if last message is not shown. +- Device name can be changed from settings. - Based on Linphone SDK 5.1 ### Fixed @@ -23,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Enable G729 on public builds. - Take account of return key on Numpad - Huge messages are better shown and with less flickering. +- Adapt UserAgent with device name. ## 4.3.2 diff --git a/linphone-app/assets/languages/da.ts b/linphone-app/assets/languages/da.ts index a7a8a4729..2f608288c 100644 --- a/linphone-app/assets/languages/da.ts +++ b/linphone-app/assets/languages/da.ts @@ -2288,6 +2288,11 @@ Klik her: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Understøtter telefonnumre + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/de.ts b/linphone-app/assets/languages/de.ts index 9de301108..d9e88d513 100644 --- a/linphone-app/assets/languages/de.ts +++ b/linphone-app/assets/languages/de.ts @@ -2288,6 +2288,11 @@ Klicken Sie hier: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Telefonnummern werden unterstützt + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/en.ts b/linphone-app/assets/languages/en.ts index dc86ade3b..66291e80b 100644 --- a/linphone-app/assets/languages/en.ts +++ b/linphone-app/assets/languages/en.ts @@ -2311,6 +2311,11 @@ Click here: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Supports phone numbers + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + Device name + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/es.ts b/linphone-app/assets/languages/es.ts index 890e35e9a..c1ff1207e 100644 --- a/linphone-app/assets/languages/es.ts +++ b/linphone-app/assets/languages/es.ts @@ -2288,6 +2288,11 @@ Haga clic aquí: <a href="%1">%1 </a> assistantSupportsPhoneNumbersLabel Soportar números de teléfono + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/fr_FR.ts b/linphone-app/assets/languages/fr_FR.ts index d0301f742..5f579423b 100644 --- a/linphone-app/assets/languages/fr_FR.ts +++ b/linphone-app/assets/languages/fr_FR.ts @@ -2288,6 +2288,11 @@ Cliquez ici : <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Supporter les numéros de tél. + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/hu.ts b/linphone-app/assets/languages/hu.ts index 7f13d0865..10ae6502c 100644 --- a/linphone-app/assets/languages/hu.ts +++ b/linphone-app/assets/languages/hu.ts @@ -2277,6 +2277,11 @@ Kattintson ide: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Támogatja a telefonszámokat + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/it.ts b/linphone-app/assets/languages/it.ts index b4827eaf4..9523a6328 100644 --- a/linphone-app/assets/languages/it.ts +++ b/linphone-app/assets/languages/it.ts @@ -2288,6 +2288,11 @@ Clicca: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Supporta i numeri di telefono + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/ja.ts b/linphone-app/assets/languages/ja.ts index 26e901267..ffd90056d 100644 --- a/linphone-app/assets/languages/ja.ts +++ b/linphone-app/assets/languages/ja.ts @@ -2277,6 +2277,11 @@ assistantSupportsPhoneNumbersLabel 電話番号をサポート + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/lt.ts b/linphone-app/assets/languages/lt.ts index 6cc17f357..a308aadee 100644 --- a/linphone-app/assets/languages/lt.ts +++ b/linphone-app/assets/languages/lt.ts @@ -2299,6 +2299,11 @@ Spustelėkite čia: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Palaiko telefonų numerius + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/pt_BR.ts b/linphone-app/assets/languages/pt_BR.ts index cec6e1212..9e5e396c7 100644 --- a/linphone-app/assets/languages/pt_BR.ts +++ b/linphone-app/assets/languages/pt_BR.ts @@ -2288,6 +2288,11 @@ Clique aqui: <a href="%1">%1 </a> assistantSupportsPhoneNumbersLabel Suporta números de telefone + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/ru.ts b/linphone-app/assets/languages/ru.ts index aa9359dcb..e7eb5370a 100644 --- a/linphone-app/assets/languages/ru.ts +++ b/linphone-app/assets/languages/ru.ts @@ -2299,6 +2299,11 @@ assistantSupportsPhoneNumbersLabel Поддерживает номера телефонов + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/sv.ts b/linphone-app/assets/languages/sv.ts index f67814d9a..15ee30a4d 100644 --- a/linphone-app/assets/languages/sv.ts +++ b/linphone-app/assets/languages/sv.ts @@ -2288,6 +2288,11 @@ Klicka här: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Stöder telefonnummer + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/tr.ts b/linphone-app/assets/languages/tr.ts index 62b4c5ce4..2fcc10a20 100644 --- a/linphone-app/assets/languages/tr.ts +++ b/linphone-app/assets/languages/tr.ts @@ -2277,6 +2277,11 @@ Buraya tıklayın: <a href="%1">%1</a> assistantSupportsPhoneNumbersLabel Telefon numaralarını destekler + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/uk.ts b/linphone-app/assets/languages/uk.ts index 9804deabc..7c73bfc5c 100644 --- a/linphone-app/assets/languages/uk.ts +++ b/linphone-app/assets/languages/uk.ts @@ -2299,6 +2299,11 @@ assistantSupportsPhoneNumbersLabel Підтримує номери телефонів + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/assets/languages/zh_CN.ts b/linphone-app/assets/languages/zh_CN.ts index 43f3d1856..c95631dad 100644 --- a/linphone-app/assets/languages/zh_CN.ts +++ b/linphone-app/assets/languages/zh_CN.ts @@ -2277,6 +2277,11 @@ assistantSupportsPhoneNumbersLabel 支持电话号码 + + defaultDeviceNameLabel + 'Device Name' : Label for setting the device name. + + SettingsSipAccountsEdit diff --git a/linphone-app/src/components/core/CoreManager.cpp b/linphone-app/src/components/core/CoreManager.cpp index 41c3752ee..099cef8b5 100644 --- a/linphone-app/src/components/core/CoreManager.cpp +++ b/linphone-app/src/components/core/CoreManager.cpp @@ -261,15 +261,6 @@ void CoreManager::createLinphoneCore (const QString &configPath) { mCore->setVideoDisplayFilter("MSQOGL"); mCore->usePreviewWindow(true); mCore->enableVideoPreview(false); - mCore->setUserAgent( - Utils::appStringToCoreString( - QStringLiteral(APPLICATION_NAME" Desktop/%1 (%2, Qt %3) LinphoneCore") - .arg(QCoreApplication::applicationVersion()) - .arg(QSysInfo::prettyProductName()) - .arg(qVersion()) - ), - mCore->getVersion() - ); // Force capture/display. // Useful if the app was built without video support. // (The capture/display attributes are reset by the core in this case.) @@ -278,12 +269,19 @@ void CoreManager::createLinphoneCore (const QString &configPath) { config->setInt("video", "capture", 1); config->setInt("video", "display", 1); } + QString userAgent = Utils::computeUserAgent(config); + mCore->setUserAgent(Utils::appStringToCoreString(userAgent), mCore->getVersion()); mCore->start(); setDatabasesPaths(); setOtherPaths(); mCore->enableFriendListSubscription(true); } +void CoreManager::updateUserAgent(){ + mCore->setUserAgent(Utils::appStringToCoreString(Utils::computeUserAgent(mCore->getConfig())), mCore->getVersion()); + forceRefreshRegisters(); // After setting a new device name, REGISTER need to take account it. +} + void CoreManager::handleChatRoomCreated(const std::shared_ptr &chatRoomModel){ emit chatRoomModelCreated(chatRoomModel); } diff --git a/linphone-app/src/components/core/CoreManager.hpp b/linphone-app/src/components/core/CoreManager.hpp index 27a9a1676..541759053 100644 --- a/linphone-app/src/components/core/CoreManager.hpp +++ b/linphone-app/src/components/core/CoreManager.hpp @@ -168,6 +168,7 @@ public: Q_INVOKABLE bool isLastRemoteProvisioningGood(); Q_INVOKABLE QString getUserAgent()const; + void updateUserAgent(); public slots: void initCoreManager(); diff --git a/linphone-app/src/components/settings/AccountSettingsModel.hpp b/linphone-app/src/components/settings/AccountSettingsModel.hpp index 95d07a935..e509e0864 100644 --- a/linphone-app/src/components/settings/AccountSettingsModel.hpp +++ b/linphone-app/src/components/settings/AccountSettingsModel.hpp @@ -31,22 +31,22 @@ // ============================================================================= class AccountSettingsModel : public QObject { - Q_OBJECT; + Q_OBJECT // Selected proxy config. - Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountSettingsUpdated); - Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsStringUriOnly NOTIFY accountSettingsUpdated); - Q_PROPERTY(QString fullSipAddress READ getUsedSipAddressAsString); - Q_PROPERTY(RegistrationState registrationState READ getRegistrationState NOTIFY accountSettingsUpdated); + Q_PROPERTY(QString username READ getUsername WRITE setUsername NOTIFY accountSettingsUpdated) + Q_PROPERTY(QString sipAddress READ getUsedSipAddressAsStringUriOnly NOTIFY accountSettingsUpdated) + Q_PROPERTY(QString fullSipAddress READ getUsedSipAddressAsString) + Q_PROPERTY(RegistrationState registrationState READ getRegistrationState NOTIFY accountSettingsUpdated) Q_PROPERTY(QString conferenceURI READ getConferenceURI NOTIFY accountSettingsUpdated) // Default info. - Q_PROPERTY(QString primaryDisplayName READ getPrimaryDisplayName WRITE setPrimaryDisplayName NOTIFY accountSettingsUpdated); - Q_PROPERTY(QString primaryUsername READ getPrimaryUsername WRITE setPrimaryUsername NOTIFY accountSettingsUpdated); - Q_PROPERTY(QString primarySipAddress READ getPrimarySipAddress NOTIFY accountSettingsUpdated); + Q_PROPERTY(QString primaryDisplayName READ getPrimaryDisplayName WRITE setPrimaryDisplayName NOTIFY accountSettingsUpdated) + Q_PROPERTY(QString primaryUsername READ getPrimaryUsername WRITE setPrimaryUsername NOTIFY accountSettingsUpdated) + Q_PROPERTY(QString primarySipAddress READ getPrimarySipAddress NOTIFY accountSettingsUpdated) - Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountSettingsUpdated); + Q_PROPERTY(QVariantList accounts READ getAccounts NOTIFY accountSettingsUpdated) public: enum RegistrationState { diff --git a/linphone-app/src/components/settings/SettingsModel.cpp b/linphone-app/src/components/settings/SettingsModel.cpp index 156f021ff..59f20c643 100644 --- a/linphone-app/src/components/settings/SettingsModel.cpp +++ b/linphone-app/src/components/settings/SettingsModel.cpp @@ -190,6 +190,24 @@ void SettingsModel::setAssistantLogoutUrl (QString url) { emit assistantLogoutUrlChanged(url); } +// ============================================================================= +// SIP Accounts. +// ============================================================================= + +QString SettingsModel::getDeviceName(const std::shared_ptr& config){ + return Utils::coreStringToAppString(config->getString(UiSection, "device_name", Utils::appStringToCoreString(QSysInfo::machineHostName()))); +} + +QString SettingsModel::getDeviceName() const{ + return getDeviceName(mConfig); +} + +void SettingsModel::setDeviceName(const QString& deviceName){ + mConfig->setString(UiSection, "device_name", Utils::appStringToCoreString(deviceName)); + emit deviceNameChanged(); + CoreManager::getInstance()->updateUserAgent(); +} + // ============================================================================= // Audio. // ============================================================================= diff --git a/linphone-app/src/components/settings/SettingsModel.hpp b/linphone-app/src/components/settings/SettingsModel.hpp index fa70471ee..746377155 100644 --- a/linphone-app/src/components/settings/SettingsModel.hpp +++ b/linphone-app/src/components/settings/SettingsModel.hpp @@ -51,6 +51,10 @@ class SettingsModel : public QObject { Q_PROPERTY(QString assistantRegistrationUrl READ getAssistantRegistrationUrl WRITE setAssistantRegistrationUrl NOTIFY assistantRegistrationUrlChanged) Q_PROPERTY(QString assistantLoginUrl READ getAssistantLoginUrl WRITE setAssistantLoginUrl NOTIFY assistantLoginUrlChanged) Q_PROPERTY(QString assistantLogoutUrl READ getAssistantLogoutUrl WRITE setAssistantLogoutUrl NOTIFY assistantLogoutUrlChanged) + + // SIP Accounts. ------------------------------------------------------------- + + Q_PROPERTY(QString deviceName READ getDeviceName WRITE setDeviceName NOTIFY deviceNameChanged) // Audio. -------------------------------------------------------------------- @@ -248,6 +252,12 @@ public: QString getAssistantLogoutUrl () const; void setAssistantLogoutUrl (QString url); + + // SIP Accounts. ------------------------------------------------------------- + + static QString getDeviceName(const std::shared_ptr& config); + QString getDeviceName() const; + void setDeviceName(const QString& deviceName); // Audio. -------------------------------------------------------------------- @@ -550,6 +560,10 @@ signals: void assistantRegistrationUrlChanged (QString url); void assistantLoginUrlChanged (QString url); void assistantLogoutUrlChanged (QString url); + + // SIP Accounts. ------------------------------------------------------------- + + void deviceNameChanged(); // Audio. -------------------------------------------------------------------- diff --git a/linphone-app/src/utils/Utils.cpp b/linphone-app/src/utils/Utils.cpp index 0e00de26c..da7a38d3a 100644 --- a/linphone-app/src/utils/Utils.cpp +++ b/linphone-app/src/utils/Utils.cpp @@ -25,11 +25,13 @@ #include #include +#include "config.h" #include "Utils.hpp" #include "components/core/CoreManager.hpp" #include "components/contacts/ContactsListModel.hpp" #include "components/contact/ContactModel.hpp" #include "components/contact/VcardModel.hpp" +#include "components/settings/SettingsModel.hpp" #include "app/paths/Paths.hpp" // ============================================================================= @@ -514,4 +516,12 @@ std::shared_ptr Utils::getConfigIfExists (const QString &confi factoryPath.clear(); return linphone::Config::newWithFactory(configPath.toStdString(), factoryPath); +} + +QString Utils::computeUserAgent(const std::shared_ptr& config){ + return QStringLiteral(APPLICATION_NAME" Desktop/%1 (%2) %3, Qt %4 LinphoneCore") + .arg(QCoreApplication::applicationVersion()) + .arg(SettingsModel::getDeviceName(config)) + .arg(QSysInfo::prettyProductName()) + .arg(qVersion()); } \ No newline at end of file diff --git a/linphone-app/src/utils/Utils.hpp b/linphone-app/src/utils/Utils.hpp index 710033544..282f16162 100644 --- a/linphone-app/src/utils/Utils.hpp +++ b/linphone-app/src/utils/Utils.hpp @@ -127,6 +127,7 @@ public: static void copyDir(QString from, QString to);// Copy a folder recursively without erasing old file static QString getDisplayName(const std::shared_ptr& address); // Get the displayname from addres in this order : Friends, Contact, Display address, Username address static std::shared_ptr getConfigIfExists (const QString& configPath); + static QString computeUserAgent(const std::shared_ptr& config); }; #endif // UTILS_H_ diff --git a/linphone-app/ui/modules/Common/Form/Placements/FormTable.qml b/linphone-app/ui/modules/Common/Form/Placements/FormTable.qml index 2228133ed..c43490a0c 100644 --- a/linphone-app/ui/modules/Common/Form/Placements/FormTable.qml +++ b/linphone-app/ui/modules/Common/Form/Placements/FormTable.qml @@ -43,10 +43,10 @@ Column { Row { spacing: FormTableLineStyle.spacing width: parent.width - + // No title for the titles column. Item { - height: FormTableStyle.entry.height + height: header.model.count > 0 ? FormTableStyle.entry.height : 0 width: formTable.legendLineWidth visible: !formTable.disableLineTitle diff --git a/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml b/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml index 4569b93e0..68cbb2e02 100644 --- a/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml +++ b/linphone-app/ui/views/App/Settings/SettingsSipAccounts.qml @@ -11,211 +11,222 @@ import 'SettingsSipAccounts.js' as Logic // ============================================================================= TabContainer { - Column { - spacing: SettingsWindowStyle.forms.spacing - width: parent.width - - // ------------------------------------------------------------------------- - // Default identity. - // ------------------------------------------------------------------------- - - Form { - title: qsTr('defaultIdentityTitle') - width: parent.width - - FormLine { - FormGroup { - label: qsTr('defaultDisplayNameLabel') - - TextField { - text: AccountSettingsModel.primaryDisplayName - - onEditingFinished: AccountSettingsModel.primaryDisplayName = text - } - } - } - - FormLine { - FormGroup { - label: qsTr('defaultUsernameLabel') - - TextField { - text: AccountSettingsModel.primaryUsername - - onEditingFinished: AccountSettingsModel.primaryUsername = text - } - } - } - - FormLine { - FormGroup { - label: qsTr('defaultSipAddressLabel') - - TextField { - readOnly: true - text: AccountSettingsModel.primarySipAddress - } - } - } - } - - // ------------------------------------------------------------------------- - // Proxy accounts. - // ------------------------------------------------------------------------- - - Form { - title: qsTr('proxyAccountsTitle') - width: parent.width - - FormTable { - legendLineWidth: SettingsWindowStyle.sipAccounts.legendLineWidth - - titles: [ - qsTr('editHeader'), - qsTr('deleteHeader') - ] - - Repeater { - model: SettingsModel.showLocalSipAccount ? AccountSettingsModel.accounts.slice(1) : AccountSettingsModel.accounts - - delegate: FormTableLine { - title: modelData.sipAddress - - FormTableEntry { - ActionButton { - isCustom: true - backgroundRadius: 4 - colorSet: SettingsWindowStyle.buttons.editProxy - - onClicked: Logic.editAccount(modelData) - } - } - - FormTableEntry { - ActionButton { - isCustom: true - backgroundRadius: 4 - colorSet: SettingsWindowStyle.buttons.deleteProxy - - onClicked: Logic.deleteAccount(modelData) - } - } - } - } - } - - FormEmptyLine {} - } - - Row { - anchors.right: parent.right - - spacing: SettingsWindowStyle.sipAccounts.buttonsSpacing - - TextButtonB { - text: qsTr('eraseAllPasswords') - - onClicked: Logic.eraseAllPasswords() - } - - TextButtonB { - text: qsTr('addAccount') - - onClicked: Logic.editAccount() - } - } - - // ------------------------------------------------------------------------- - // Assistant. - // ------------------------------------------------------------------------- - - Form { - title: qsTr('assistantTitle') - - width: parent.width - - FormLine { - FormGroup { - label: 'Registration URL' - - TextField { - text: SettingsModel.assistantRegistrationUrl - - onEditingFinished: SettingsModel.assistantRegistrationUrl = text - } - } - } - - FormLine { - FormGroup { - label: 'Login URL' - - TextField { - text: SettingsModel.assistantLoginUrl - - onEditingFinished: SettingsModel.assistantLoginUrl = text - } - } - } - - FormLine { - visible: SettingsModel.developerSettingsEnabled - FormGroup { - label: qsTr('createAppSipAccountEnabledLabel') - - Switch { - checked: SettingsModel.createAppSipAccountEnabled - - onClicked: SettingsModel.createAppSipAccountEnabled = !checked - } - } - - FormGroup { - label: qsTr('useAppSipAccountEnabledLabel') - - Switch { - checked: SettingsModel.useAppSipAccountEnabled - - onClicked: SettingsModel.useAppSipAccountEnabled = !checked - } - } - } - - FormLine { - visible: SettingsModel.developerSettingsEnabled - FormGroup { - label: qsTr('useOtherSipAccountEnabledLabel') - - Switch { - checked: SettingsModel.useOtherSipAccountEnabled - - onClicked: SettingsModel.useOtherSipAccountEnabled = !checked - } - } - - FormGroup { - label: qsTr('fetchRemoteConfigurationEnabledLabel') - - Switch { - checked: SettingsModel.fetchRemoteConfigurationEnabled - - onClicked: SettingsModel.fetchRemoteConfigurationEnabled = !checked - } - } - } - - FormLine { - visible: SettingsModel.developerSettingsEnabled - FormGroup { - label: qsTr('assistantSupportsPhoneNumbersLabel') - - Switch { - checked: SettingsModel.assistantSupportsPhoneNumbers - - onClicked: SettingsModel.assistantSupportsPhoneNumbers = !checked - } - } - } - } - } + Column { + spacing: SettingsWindowStyle.forms.spacing + width: parent.width + + // ------------------------------------------------------------------------- + // Default identity. + // ------------------------------------------------------------------------- + + Form { + title: qsTr('defaultIdentityTitle') + width: parent.width + + FormLine { + FormGroup { + label: qsTr('defaultDisplayNameLabel') + + TextField { + text: AccountSettingsModel.primaryDisplayName + + onEditingFinished: AccountSettingsModel.primaryDisplayName = text + } + } + } + + FormLine { + FormGroup { + label: qsTr('defaultUsernameLabel') + + TextField { + text: AccountSettingsModel.primaryUsername + + onEditingFinished: AccountSettingsModel.primaryUsername = text + } + } + } + + FormLine { + FormGroup { + label: qsTr('defaultSipAddressLabel') + + TextField { + readOnly: true + text: AccountSettingsModel.primarySipAddress + } + } + } + FormLine { + FormGroup { + //: 'Device Name' : Label for setting the device name. + label: qsTr('defaultDeviceNameLabel') + + TextField { + text: SettingsModel.deviceName + onEditingFinished: SettingsModel.deviceName = text + } + } + } + } + + // ------------------------------------------------------------------------- + // Proxy accounts. + // ------------------------------------------------------------------------- + + Form { + title: qsTr('proxyAccountsTitle') + width: parent.width + + FormTable { + legendLineWidth: SettingsWindowStyle.sipAccounts.legendLineWidth + + titles: [ + qsTr('editHeader'), + qsTr('deleteHeader') + ] + + Repeater { + model: SettingsModel.showLocalSipAccount ? AccountSettingsModel.accounts.slice(1) : AccountSettingsModel.accounts + + delegate: FormTableLine { + title: modelData.sipAddress + + FormTableEntry { + ActionButton { + isCustom: true + backgroundRadius: 4 + colorSet: SettingsWindowStyle.buttons.editProxy + + onClicked: Logic.editAccount(modelData) + } + } + + FormTableEntry { + ActionButton { + isCustom: true + backgroundRadius: 4 + colorSet: SettingsWindowStyle.buttons.deleteProxy + + onClicked: Logic.deleteAccount(modelData) + } + } + } + } + } + + FormEmptyLine {} + } + + Row { + anchors.right: parent.right + + spacing: SettingsWindowStyle.sipAccounts.buttonsSpacing + + TextButtonB { + text: qsTr('eraseAllPasswords') + + onClicked: Logic.eraseAllPasswords() + } + + TextButtonB { + text: qsTr('addAccount') + + onClicked: Logic.editAccount() + } + } + + // ------------------------------------------------------------------------- + // Assistant. + // ------------------------------------------------------------------------- + + Form { + title: qsTr('assistantTitle') + + width: parent.width + + FormLine { + FormGroup { + label: 'Registration URL' + + TextField { + text: SettingsModel.assistantRegistrationUrl + + onEditingFinished: SettingsModel.assistantRegistrationUrl = text + } + } + } + + FormLine { + FormGroup { + label: 'Login URL' + + TextField { + text: SettingsModel.assistantLoginUrl + + onEditingFinished: SettingsModel.assistantLoginUrl = text + } + } + } + + FormLine { + visible: SettingsModel.developerSettingsEnabled + FormGroup { + label: qsTr('createAppSipAccountEnabledLabel') + + Switch { + checked: SettingsModel.createAppSipAccountEnabled + + onClicked: SettingsModel.createAppSipAccountEnabled = !checked + } + } + + FormGroup { + label: qsTr('useAppSipAccountEnabledLabel') + + Switch { + checked: SettingsModel.useAppSipAccountEnabled + + onClicked: SettingsModel.useAppSipAccountEnabled = !checked + } + } + } + + FormLine { + visible: SettingsModel.developerSettingsEnabled + FormGroup { + label: qsTr('useOtherSipAccountEnabledLabel') + + Switch { + checked: SettingsModel.useOtherSipAccountEnabled + + onClicked: SettingsModel.useOtherSipAccountEnabled = !checked + } + } + + FormGroup { + label: qsTr('fetchRemoteConfigurationEnabledLabel') + + Switch { + checked: SettingsModel.fetchRemoteConfigurationEnabled + + onClicked: SettingsModel.fetchRemoteConfigurationEnabled = !checked + } + } + } + + FormLine { + visible: SettingsModel.developerSettingsEnabled + FormGroup { + label: qsTr('assistantSupportsPhoneNumbersLabel') + + Switch { + checked: SettingsModel.assistantSupportsPhoneNumbers + + onClicked: SettingsModel.assistantSupportsPhoneNumbers = !checked + } + } + } + } + } }