From a196513d2e6b194851cbeea7e01637aae015adc4 Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Thu, 26 Aug 2021 14:57:24 -0400 Subject: [PATCH] settings: refactor for SettingsView - stage one 1. Add account config QML properties and use them in settings directly to avoid manual update 2. Rough clean up for video/audio settings 3. Remove settingsAdapter entirely and split the responsibility Change-Id: Icf81b91d5a3a0dd9f2a52824159cd222367b801f --- CMakeLists.txt | 2 - src/MainApplicationWindow.qml | 4 +- src/accountadapter.cpp | 14 + src/accountadapter.h | 4 + src/avadapter.cpp | 51 + src/avadapter.h | 9 + src/commoncomponents/DeleteAccountDialog.qml | 27 +- src/constant/JamiStrings.qml | 2 + src/constant/JamiTheme.qml | 2 +- src/currentaccount.cpp | 155 ++- src/currentaccount.h | 179 ++- src/mainview/components/RecordBox.qml | 2 +- src/mediacodeclistmodel.cpp | 16 +- src/mediacodeclistmodel.h | 2 + src/messagesadapter.cpp | 16 + src/messagesadapter.h | 1 + src/qmlregister.cpp | 7 +- src/qtutils.h | 10 +- src/settingsadapter.cpp | 1191 ----------------- src/settingsadapter.h | 258 ---- src/settingsview/SettingsView.qml | 6 +- .../components/AccountProfile.qml | 5 +- .../components/AdvancedCallSettings.qml | 80 +- .../components/AdvancedChatSettings.qml | 10 +- .../AdvancedConnectivitySettings.qml | 99 +- .../AdvancedJamiSecuritySettings.qml | 97 +- .../components/AdvancedMediaSettings.qml | 10 +- .../components/AdvancedNameServerSettings.qml | 9 +- .../components/AdvancedOpenDHTSettings.qml | 32 +- .../AdvancedPublicAddressSettings.qml | 51 +- .../components/AdvancedSDPSettings.qml | 83 +- .../AdvancedSIPSecuritySettings.qml | 195 ++- .../components/AdvancedSettings.qml | 16 - .../components/AdvancedVoiceMailSettings.qml | 9 +- src/settingsview/components/AudioSettings.qml | 19 +- .../components/BannedContacts.qml | 8 +- .../components/ChatviewSettings.qml | 8 +- .../components/CurrentAccountSettings.qml | 18 +- .../components/DeviceItemDelegate.qml | 2 +- .../components/FileTransferSettings.qml | 20 +- .../components/GeneralSettingsPage.qml | 4 - .../components/JamiUserIdentity.qml | 45 +- src/settingsview/components/LinkedDevices.qml | 15 +- src/settingsview/components/LogsView.qml | 53 +- src/settingsview/components/MediaSettings.qml | 19 +- .../components/RecordingSettings.qml | 2 +- .../components/SIPUserIdentity.qml | 28 +- .../components/SettingSpinBox.qml | 1 + .../components/SettingsComboBox.qml | 16 +- .../components/SystemSettings.qml | 18 +- .../components/TroubleshootSettings.qml | 14 +- .../components/UpdateSettings.qml | 4 +- src/settingsview/components/UserIdentity.qml | 8 - src/settingsview/components/VideoSettings.qml | 133 +- src/utilsadapter.cpp | 82 +- src/utilsadapter.h | 23 +- tests/qml/src/tst_WizardView.qml | 16 +- 57 files changed, 1078 insertions(+), 2132 deletions(-) delete mode 100644 src/settingsadapter.cpp delete mode 100644 src/settingsadapter.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6017c7b68..84efca855 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,6 @@ set(COMMON_SOURCES ${SRC_DIR}/avadapter.cpp ${SRC_DIR}/contactadapter.cpp ${SRC_DIR}/pluginadapter.cpp - ${SRC_DIR}/settingsadapter.cpp ${SRC_DIR}/deviceitemlistmodel.cpp ${SRC_DIR}/pluginitemlistmodel.cpp ${SRC_DIR}/pluginhandleritemlistmodel.cpp @@ -117,7 +116,6 @@ set(COMMON_HEADERS ${SRC_DIR}/avadapter.h ${SRC_DIR}/contactadapter.h ${SRC_DIR}/pluginadapter.h - ${SRC_DIR}/settingsadapter.h ${SRC_DIR}/deviceitemlistmodel.h ${SRC_DIR}/pluginitemlistmodel.h ${SRC_DIR}/pluginhandleritemlistmodel.h diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index 29a01bcda..6e2504c04 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -116,7 +116,7 @@ ApplicationWindow { function close(force = false) { // If we're in the onboarding wizard or 'MinimizeOnClose' // is set, then we can quit - if (force || !SettingsAdapter.getAppValue(Settings.MinimizeOnClose) || + if (force || !UtilsAdapter.getAppValue(Settings.MinimizeOnClose) || !UtilsAdapter.getAccountListSize()) { Qt.quit() } else @@ -158,7 +158,7 @@ ApplicationWindow { onLoaded: { // Quiet check for updates on start if set to. - if (SettingsAdapter.getAppValue(Settings.AutoUpdate)) { + if (UtilsAdapter.getAppValue(Settings.AutoUpdate)) { UpdateManager.checkForUpdates(true) UpdateManager.setAutoUpdateCheck(true) } diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index 42f93be9b..1d62fe8ed 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -324,6 +324,20 @@ AccountAdapter::setCurrentAccountAvatarBase64(const QString& data) }); } +void +AccountAdapter::setDefaultModerator(const QString& accountId, + const QString& peerURI, + const bool& state) +{ + lrcInstance_->accountModel().setDefaultModerator(accountId, peerURI, state); +} + +QStringList +AccountAdapter::getDefaultModerators(const QString& accountId) +{ + return lrcInstance_->accountModel().getDefaultModerators(accountId); +} + bool AccountAdapter::hasPassword() { diff --git a/src/accountadapter.h b/src/accountadapter.h index 1096439b5..d85d1cbee 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -85,6 +85,10 @@ public: Q_INVOKABLE void setCurrAccDisplayName(const QString& text); Q_INVOKABLE void setCurrentAccountAvatarFile(const QString& source); Q_INVOKABLE void setCurrentAccountAvatarBase64(const QString& source = {}); + Q_INVOKABLE void setDefaultModerator(const QString& accountId, + const QString& peerURI, + const bool& state); + Q_INVOKABLE QStringList getDefaultModerators(const QString& accountId); Q_SIGNALS: // Trigger other components to reconnect account related signals. diff --git a/src/avadapter.cpp b/src/avadapter.cpp index a596a95a8..218b9a907 100644 --- a/src/avadapter.cpp +++ b/src/avadapter.cpp @@ -21,6 +21,9 @@ #include "avadapter.h" #include "qtutils.h" +#include "api/newcodecmodel.h" +#include "api/newdevicemodel.h" + #ifdef Q_OS_LINUX #include "xrectsel.h" #endif @@ -339,3 +342,51 @@ AvAdapter::getScreenNumber() const #endif return display; } + +void +AvAdapter::setDeviceName(const QString& deviceName) +{ + lrcInstance_->getCurrentAccountInfo().deviceModel->setCurrentDeviceName(deviceName); +} + +void +AvAdapter::setCurrentVideoDeviceRateAndResolution(qreal rate, const QString& resolution) +{ + auto settings = lrcInstance_->avModel().getDeviceSettings( + lrcInstance_->avModel().getCurrentVideoCaptureDevice()); + settings.rate = rate; + settings.size = resolution; + lrcInstance_->avModel().setDeviceSettings(settings); +} + +QString +AvAdapter::getVideoSettingsSize(const QString& deviceId) +{ + return lrcInstance_->avModel().getDeviceSettings(deviceId).size; +} + +int +AvAdapter::getCurrentVideoDeviceCapabilitiesSize() +{ + return lrcInstance_->avModel() + .getDeviceCapabilities(lrcInstance_->avModel().getCurrentVideoCaptureDevice()) + .size(); +} + +void +AvAdapter::enableCodec(unsigned int id, bool isToEnable) +{ + lrcInstance_->getCurrentAccountInfo().codecModel->enable(id, isToEnable); +} + +void +AvAdapter::increaseCodecPriority(unsigned int id, bool isVideo) +{ + lrcInstance_->getCurrentAccountInfo().codecModel->increasePriority(id, isVideo); +} + +void +AvAdapter::decreaseCodecPriority(unsigned int id, bool isVideo) +{ + lrcInstance_->getCurrentAccountInfo().codecModel->decreasePriority(id, isVideo); +} diff --git a/src/avadapter.h b/src/avadapter.h index 230d00721..a6ef42b32 100644 --- a/src/avadapter.h +++ b/src/avadapter.h @@ -75,6 +75,15 @@ protected: Q_INVOKABLE void startAudioMeter(); Q_INVOKABLE void stopAudioMeter(); + Q_INVOKABLE void setDeviceName(const QString& deviceName); + Q_INVOKABLE void setCurrentVideoDeviceRateAndResolution(qreal rate, const QString& resolution); + Q_INVOKABLE QString getVideoSettingsSize(const QString& deviceId); + Q_INVOKABLE int getCurrentVideoDeviceCapabilitiesSize(); + + Q_INVOKABLE void enableCodec(unsigned int id, bool isToEnable); + Q_INVOKABLE void increaseCodecPriority(unsigned int id, bool isVideo); + Q_INVOKABLE void decreaseCodecPriority(unsigned int id, bool isVideo); + private Q_SLOTS: void onAudioDeviceEvent(); void onVideoDeviceEvent(); diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index 40940e088..40565d931 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -29,10 +29,8 @@ import "../commoncomponents" BaseDialog { id: root - property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() - property bool isSIP: { - switch (profileType) { + switch (CurrentAccount.type) { case Profile.Type.SIP: return true; default: @@ -42,13 +40,6 @@ BaseDialog { signal accepted - function openDialog() { - profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() - labelBestId.text = SettingsAdapter.getAccountBestName() - labelAccountHash.text = SettingsAdapter.getCurrentAccount_Profile_Info_Uri() - open() - } - title: JamiStrings.deleteAccount contentItem: Rectangle { @@ -67,7 +58,8 @@ BaseDialog { id: labelDeletion Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + Layout.preferredWidth: deleteAccountContentRect.width - + JamiTheme.preferredMarginSize * 2 color: JamiTheme.textColor text: JamiStrings.confirmDeleteQuestion @@ -84,10 +76,11 @@ BaseDialog { id: labelBestId Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + Layout.preferredWidth: deleteAccountContentRect.width - + JamiTheme.preferredMarginSize * 2 color: JamiTheme.textColor - text: SettingsAdapter.getAccountBestName() + text: CurrentAccount.bestName font.pointSize: JamiTheme.textFontSize font.kerning: true @@ -102,10 +95,11 @@ BaseDialog { id: labelAccountHash Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + Layout.preferredWidth: deleteAccountContentRect.width - + JamiTheme.preferredMarginSize * 2 color: JamiTheme.textColor - text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() + text: CurrentAccount.uri font.pointSize: JamiTheme.textFontSize font.kerning: true @@ -121,7 +115,8 @@ BaseDialog { visible: !isSIP Layout.alignment: Qt.AlignHCenter - Layout.preferredWidth: deleteAccountContentRect.width - JamiTheme.preferredMarginSize * 2 + Layout.preferredWidth: deleteAccountContentRect.width - + JamiTheme.preferredMarginSize * 2 text: JamiStrings.deleteAccountInfos diff --git a/src/constant/JamiStrings.qml b/src/constant/JamiStrings.qml index b0d371e09..e668d8887 100644 --- a/src/constant/JamiStrings.qml +++ b/src/constant/JamiStrings.qml @@ -131,6 +131,8 @@ Item { // AdvancedMediaSettings property string media: qsTr("Media") property string enableVideo: qsTr("Enable video") + property string videoCodecs: qsTr("Video Codecs") + property string audioCodecs: qsTr("Audio Codecs") // AdvancedSDPSettings property string sdpSettingsTitle: qsTr("SDP Session Negotiation (ICE Fallback)") diff --git a/src/constant/JamiTheme.qml b/src/constant/JamiTheme.qml index 9e5661aec..ca3bc230f 100644 --- a/src/constant/JamiTheme.qml +++ b/src/constant/JamiTheme.qml @@ -25,7 +25,7 @@ import net.jami.Adapters 1.1 import net.jami.Enums 1.1 Item { - property bool darkTheme: SettingsAdapter.getAppValue(Settings.EnableDarkTheme) + property bool darkTheme: UtilsAdapter.getAppValue(Settings.EnableDarkTheme) // Jami theme colors function rgba256(r, g, b, a) { diff --git a/src/currentaccount.cpp b/src/currentaccount.cpp index ef0fb46c0..398dc1d33 100644 --- a/src/currentaccount.cpp +++ b/src/currentaccount.cpp @@ -18,8 +18,11 @@ #include "currentaccount.h" -CurrentAccount::CurrentAccount(LRCInstance* lrcInstance, QObject* parent) +CurrentAccount::CurrentAccount(LRCInstance* lrcInstance, + AppSettingsManager* settingsManager, + QObject* parent) : QObject(parent) + , settingsManager_(settingsManager) , lrcInstance_(lrcInstance) { connect(&lrcInstance_->accountModel(), @@ -33,9 +36,64 @@ CurrentAccount::CurrentAccount(LRCInstance* lrcInstance, QObject* parent) &CurrentAccount::onAccountUpdated); connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] { updateData(); }); + updateData(); } +void +CurrentAccount::set_enabled(bool enabled, bool initialize) +{ + if (enabled_ != enabled) { + enabled_ = enabled; + if (!initialize) + lrcInstance_->accountModel().setAccountEnabled(lrcInstance_->get_currentAccountId(), + enabled); + Q_EMIT enabledChanged(); + } +} + +bool +CurrentAccount::get_enabled() +{ + return enabled_; +} + +void +CurrentAccount::set_isAllModeratorsEnabled(bool enabled, bool initialize) +{ + if (enabled != isAllModeratorsEnabled_) { + isAllModeratorsEnabled_ = enabled; + if (!initialize) + lrcInstance_->accountModel().setAllModerators(lrcInstance_->get_currentAccountId(), + enabled); + Q_EMIT isAllModeratorsEnabledChanged(); + } +} + +bool +CurrentAccount::get_isAllModeratorsEnabled() +{ + return isAllModeratorsEnabled_; +} + +void +CurrentAccount::set_isLocalModeratorsEnabled(bool enabled, bool initialize) +{ + if (enabled != isLocalModeratorsEnabled_) { + isLocalModeratorsEnabled_ = enabled; + if (!initialize) + lrcInstance_->accountModel().enableLocalModerators(lrcInstance_->get_currentAccountId(), + enabled); + Q_EMIT isLocalModeratorsEnabledChanged(); + } +} + +bool +CurrentAccount::get_isLocalModeratorsEnabled() +{ + return isLocalModeratorsEnabled_; +} + void CurrentAccount::onAccountUpdated(const QString& id) { @@ -50,7 +108,9 @@ CurrentAccount::updateData() { set_id(lrcInstance_->get_currentAccountId()); try { - const auto& accInfo = lrcInstance_->getAccountInfo(id_); + const auto& accConfig = lrcInstance_->getCurrAccConfig(); + const auto& accInfo = lrcInstance_->getCurrentAccountInfo(); + set_uri(accInfo.profileInfo.uri); set_registeredName(accInfo.registeredName); set_alias(accInfo.profileInfo.alias); @@ -59,7 +119,96 @@ CurrentAccount::updateData() set_hasAvatarSet(!accInfo.profileInfo.avatar.isEmpty()); set_status(accInfo.status); set_type(accInfo.profileInfo.type); + + set_enabled(accInfo.enabled, true); + set_managerUri(accConfig.managerUri); + set_keepAliveEnabled(accConfig.keepAliveEnabled, true); + set_peerDiscovery(accConfig.peerDiscovery, true); + set_sendReadReceipt(accConfig.sendReadReceipt, true); + set_isRendezVous(accConfig.isRendezVous, true); + set_autoAnswer(accConfig.autoAnswer, true); + set_proxyEnabled(accConfig.proxyEnabled, true); + set_upnpEnabled(accConfig.upnpEnabled, true); + set_publishedSameAsLocal(accConfig.publishedSameAsLocal, true); + set_allowIPAutoRewrite(accConfig.allowIPAutoRewrite, true); + set_proxyServer(accConfig.proxyServer, true); + set_routeset(accConfig.routeset, true); + set_username(accConfig.username, true); + set_hostname(accConfig.hostname, true); + set_password(accConfig.password, true); + set_mailbox(accConfig.mailbox, true); + set_publishedAddress(accConfig.publishedAddress, true); + set_localPort(accConfig.localPort, true); + set_publishedPort(accConfig.publishedPort, true); + + // DHT + set_PublicInCallsDHT(accConfig.DHT.PublicInCalls, true); + + // RingNS + set_uriRingNS(accConfig.RingNS.uri, true); + + // TLS + set_enableTLS(accConfig.TLS.enable, true); + set_verifyServerTLS(accConfig.TLS.verifyServer, true); + set_verifyClientTLS(accConfig.TLS.verifyClient, true); + set_requireClientCertificateTLS(accConfig.TLS.requireClientCertificate, true); + set_certificateListFileTLS(accConfig.TLS.certificateListFile, true); + set_certificateFileTLS(accConfig.TLS.certificateFile, true); + set_privateKeyFileTLS(accConfig.TLS.privateKeyFile, true); + set_passwordTLS(accConfig.TLS.password, true); + set_serverNameTLS(accConfig.TLS.serverName, true); + set_methodTLS(accConfig.TLS.method, true); + set_negotiationTimeoutSecTLS(accConfig.TLS.negotiationTimeoutSec, true); + + // SRTP + set_enableSRTP(accConfig.SRTP.enable, true); + set_rtpFallbackSRTP(accConfig.SRTP.rtpFallback, true); + set_keyExchangeSRTP(accConfig.SRTP.keyExchange, true); + + // TURN + set_enableTURN(accConfig.TURN.enable, true); + set_serverTURN(accConfig.TURN.server, true); + set_usernameTURN(accConfig.TURN.username, true); + set_passwordTURN(accConfig.TURN.password, true); + set_realmTURN(accConfig.TURN.realm, true); + + // STUN + set_enableSTUN(accConfig.STUN.enable, true); + set_serverSTUN(accConfig.STUN.server, true); + + // Video & Audio + set_videoEnabledVideo(accConfig.Video.videoEnabled, true); + set_videoPortMinVideo(accConfig.Video.videoPortMin, true); + set_videoPortMaxVideo(accConfig.Video.videoPortMax, true); + set_audioPortMinAudio(accConfig.Audio.audioPortMin, true); + set_audioPortMaxAudio(accConfig.Audio.audioPortMax, true); + + // Ringtone + set_ringtoneEnabledRingtone(accConfig.Ringtone.ringtoneEnabled, true); + set_ringtonePathRingtone(accConfig.Ringtone.ringtonePath, true); + + // Registration + set_expireRegistration(accConfig.Registration.expire, true); + + // Moderators + set_isAllModeratorsEnabled(lrcInstance_->accountModel().isAllModerators( + lrcInstance_->get_currentAccountId()), + true); + set_isLocalModeratorsEnabled(lrcInstance_->accountModel().isLocalModeratorsEnabled( + lrcInstance_->get_currentAccountId()), + true); + + // NewAccount model + set_autoTransferFromTrusted(settingsManager_->getValue(Settings::Key::AutoAcceptFiles) + .toBool(), + true); + set_autoTransferFromUntrusted(settingsManager_->getValue(Settings::Key::AllowFromUntrusted) + .toBool(), + true); + set_autoTransferSizeThreshold(settingsManager_->getValue(Settings::Key::AcceptTransferBelow) + .toInt(), + true); } catch (...) { - qWarning() << "Can't update current account data for" << id_; + qWarning() << "Can't update current account info data for" << id_; } } diff --git a/src/currentaccount.h b/src/currentaccount.h index 30fbecbf2..baca74ecb 100644 --- a/src/currentaccount.h +++ b/src/currentaccount.h @@ -19,31 +19,208 @@ #pragma once #include "lrcinstance.h" +#include "qtutils.h" +#include "appsettingsmanager.h" #include <QObject> #include <QString> +#define ACCOUNT_CONFIG_SETTINGS_PROPERTY_BASE(type, prop) \ + PROPERTY_GETTER_BASE(type, prop) \ + void set_##prop(const type& x = {}, bool initialize = false) \ + { \ + if (prop##_ != x) { \ + prop##_ = x; \ + if (!initialize) { \ + auto confProps = lrcInstance_->getCurrAccConfig(); \ + confProps.prop = x; \ + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), \ + confProps); \ + } \ + Q_EMIT prop##Changed(); \ + } \ + } + +#define NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY_BASE(type, prop, appSettingName) \ + PROPERTY_GETTER_BASE(type, prop) \ + void set_##prop(const type& x = {}, bool initialize = false) \ + { \ + if (prop##_ != x) { \ + prop##_ = x; \ + lrcInstance_->accountModel().prop = x; \ + if (!initialize) { \ + settingsManager_->setValue(Settings::Key::appSettingName, x); \ + } \ + Q_EMIT prop##Changed(); \ + } \ + } + +#define ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY_BASE(type, prop, cate) \ + type prop##cate##_ {}; \ +\ +public: \ + Q_SIGNAL void prop##cate##Changed(); \ + type get_##prop##cate() \ + { \ + return prop##cate##_; \ + } \ + void set_##prop##cate(const type& x = {}, bool initialize = false) \ + { \ + if (prop##cate##_ != x) { \ + prop##cate##_ = x; \ + if (!initialize) { \ + auto confProps = lrcInstance_->getCurrAccConfig(); \ + confProps.cate.prop = x; \ + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), \ + confProps); \ + } \ + Q_EMIT prop##cate##Changed(); \ + } \ + } + +#define QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(type, prop) \ +private: \ + Q_PROPERTY(type prop READ get_##prop WRITE set_##prop NOTIFY prop##Changed); \ + ACCOUNT_CONFIG_SETTINGS_PROPERTY_BASE(type, prop) + +#define QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(type, prop, cate) \ +private: \ + Q_PROPERTY(type prop##_##cate READ get_##prop##cate WRITE set_##prop##cate NOTIFY \ + prop##cate##Changed); \ + ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY_BASE(type, prop, cate) + +#define QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(type, prop, appSettingName) \ +private: \ + Q_PROPERTY(type prop READ get_##prop WRITE set_##prop NOTIFY prop##Changed); \ + NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY_BASE(type, prop, appSettingName) + class CurrentAccount final : public QObject { Q_OBJECT + // Basic settings + Q_PROPERTY(bool enabled READ get_enabled WRITE set_enabled NOTIFY enabledChanged); + QML_RO_PROPERTY(QString, id) QML_RO_PROPERTY(QString, uri) QML_RO_PROPERTY(QString, registeredName) QML_RO_PROPERTY(QString, alias) QML_RO_PROPERTY(QString, bestId) QML_RO_PROPERTY(QString, bestName) + QML_RO_PROPERTY(QString, managerUri) QML_RO_PROPERTY(bool, hasAvatarSet) QML_RO_PROPERTY(lrc::api::account::Status, status) QML_RO_PROPERTY(lrc::api::profile::Type, type) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, keepAliveEnabled) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, peerDiscovery) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, sendReadReceipt) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, isRendezVous) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, autoAnswer) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, proxyEnabled) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, upnpEnabled) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, publishedSameAsLocal) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(bool, allowIPAutoRewrite) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, proxyServer) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, routeset) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, username) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, hostname) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, password) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, mailbox) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(QString, publishedAddress) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(int, localPort) + QML_ACCOUNT_CONFIG_SETTINGS_PROPERTY(int, publishedPort) + + // Moderator settings + Q_PROPERTY(bool isAllModeratorsEnabled READ get_isAllModeratorsEnabled WRITE + set_isAllModeratorsEnabled NOTIFY isAllModeratorsEnabledChanged) + Q_PROPERTY(bool isLocalModeratorsEnabled READ get_isLocalModeratorsEnabled WRITE + set_isLocalModeratorsEnabled NOTIFY isLocalModeratorsEnabledChanged) + + // RingNS setting + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, uri, RingNS) + + // DHT settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, PublicInCalls, DHT) + + // TLS settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, enable, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, verifyServer, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, verifyClient, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, requireClientCertificate, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, certificateListFile, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, certificateFile, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, privateKeyFile, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, password, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, serverName, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(lrc::api::account::TlsMethod, method, TLS) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, negotiationTimeoutSec, TLS) + + // SRTP settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, enable, SRTP) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, rtpFallback, SRTP) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(lrc::api::account::KeyExchangeProtocol, + keyExchange, + SRTP) + + // TURN settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, enable, TURN) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, server, TURN) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, username, TURN) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, password, TURN) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, realm, TURN) + + // STUN settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, enable, STUN) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, server, STUN) + + // Video & Audio settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, videoEnabled, Video) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, videoPortMin, Video) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, videoPortMax, Video) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, audioPortMin, Audio) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, audioPortMax, Audio) + + // Ringtone settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(bool, ringtoneEnabled, Ringtone) + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(QString, ringtonePath, Ringtone) + + // Registration settings + QML_ACCOUNT_CONFIG_CATEGORY_SETTINGS_PROPERTY(int, expire, Registration) + + // NewAccount model settings + QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(bool, autoTransferFromTrusted, AutoAcceptFiles) + QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(bool, autoTransferFromUntrusted, AllowFromUntrusted) + QML_NEW_ACCOUNT_MODEL_SETTINGS_PROPERTY(int, autoTransferSizeThreshold, AcceptTransferBelow) + public: - explicit CurrentAccount(LRCInstance* lrcInstance, QObject* parent = nullptr); + explicit CurrentAccount(LRCInstance* lrcInstance, + AppSettingsManager* settingsManager, + QObject* parent = nullptr); ~CurrentAccount() = default; + void set_enabled(bool enabled = false, bool initialize = false); + bool get_enabled(); + + void set_isAllModeratorsEnabled(bool enabled, bool initialize = false); + bool get_isAllModeratorsEnabled(); + + void set_isLocalModeratorsEnabled(bool enabled, bool initialize = false); + bool get_isLocalModeratorsEnabled(); + +Q_SIGNALS: + void enabledChanged(); + void isAllModeratorsEnabledChanged(); + void isLocalModeratorsEnabledChanged(); + private Q_SLOTS: void updateData(); void onAccountUpdated(const QString& id); private: + bool enabled_; + bool isAllModeratorsEnabled_; + bool isLocalModeratorsEnabled_; + + AppSettingsManager* settingsManager_; LRCInstance* lrcInstance_; }; diff --git a/src/mainview/components/RecordBox.qml b/src/mainview/components/RecordBox.qml index 6c546d8b0..b108e7ac8 100644 --- a/src/mainview/components/RecordBox.qml +++ b/src/mainview/components/RecordBox.qml @@ -68,7 +68,7 @@ Rectangle { height = preferredHeight if (isVideo) { var device = AVModel.getDefaultDevice() - var settings = SettingsAdapter.get_Video_Settings_Size(device) + var settings = AvAdapter.getVideoSettingsSize(device) var res = settings.split("x") var aspectRatio = res[1] / res[0] if (aspectRatio) { diff --git a/src/mediacodeclistmodel.cpp b/src/mediacodeclistmodel.cpp index fb4cec22a..d47f080c5 100644 --- a/src/mediacodeclistmodel.cpp +++ b/src/mediacodeclistmodel.cpp @@ -28,7 +28,14 @@ MediaCodecListModel::MediaCodecListModel(QObject* parent) : AbstractListModelBase(parent) -{} +{ + connect(this, &MediaCodecListModel::lrcInstanceChanged, [this]() { + connect(lrcInstance_, + &LRCInstance::currentAccountIdChanged, + this, + &MediaCodecListModel::reset); + }); +} MediaCodecListModel::~MediaCodecListModel() {} @@ -141,6 +148,13 @@ MediaCodecListModel::flags(const QModelIndex& index) const return flags; } +void +MediaCodecListModel::reset() +{ + beginResetModel(); + endResetModel(); +} + int MediaCodecListModel::mediaType() { diff --git a/src/mediacodeclistmodel.h b/src/mediacodeclistmodel.h index 81d81494d..b51247d93 100644 --- a/src/mediacodeclistmodel.h +++ b/src/mediacodeclistmodel.h @@ -46,6 +46,8 @@ public: QModelIndex parent(const QModelIndex& child) const; Qt::ItemFlags flags(const QModelIndex& index) const; + Q_INVOKABLE void reset(); + int mediaType(); void setMediaType(int mediaType); diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index e714306f1..c03bbd5ab 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -530,6 +530,22 @@ MessagesAdapter::blockConversation(const QString& convUid) lrcInstance_->getCurrentConversationModel()->removeConversation(currentConvUid, true); } +void +MessagesAdapter::unbanContact(int index) +{ + auto& accountInfo = lrcInstance_->getCurrentAccountInfo(); + auto bannedContactList = accountInfo.contactModel->getBannedContacts(); + auto it = bannedContactList.begin(); + std::advance(it, index); + + try { + auto contactInfo = accountInfo.contactModel->getContact(*it); + accountInfo.contactModel->addContact(contactInfo); + } catch (const std::out_of_range& e) { + qDebug() << e.what(); + } +} + void MessagesAdapter::clearConversationHistory(const QString& accountId, const QString& convUid) { diff --git a/src/messagesadapter.h b/src/messagesadapter.h index 6673651b6..278393d58 100644 --- a/src/messagesadapter.h +++ b/src/messagesadapter.h @@ -50,6 +50,7 @@ protected: Q_INVOKABLE void acceptInvitation(const QString& convId = {}); Q_INVOKABLE void refuseInvitation(const QString& convUid = ""); Q_INVOKABLE void blockConversation(const QString& convUid = ""); + Q_INVOKABLE void unbanContact(int index); // JS Q_INVOKABLE. Q_INVOKABLE void setDisplayLinks(); diff --git a/src/qmlregister.cpp b/src/qmlregister.cpp index d9342d49f..5f5f32c27 100644 --- a/src/qmlregister.cpp +++ b/src/qmlregister.cpp @@ -24,7 +24,6 @@ #include "contactadapter.h" #include "pluginadapter.h" #include "messagesadapter.h" -#include "settingsadapter.h" #include "utilsadapter.h" #include "conversationsadapter.h" #include "currentconversation.h" @@ -113,11 +112,10 @@ registerTypes(QQmlEngine* engine, auto avAdapter = new AvAdapter(lrcInstance, parent); auto contactAdapter = new ContactAdapter(lrcInstance, parent); auto accountAdapter = new AccountAdapter(appSettingsManager, lrcInstance, parent); - auto utilsAdapter = new UtilsAdapter(systemTray, lrcInstance, parent); - auto settingsAdapter = new SettingsAdapter(appSettingsManager, lrcInstance, parent); + auto utilsAdapter = new UtilsAdapter(appSettingsManager, systemTray, lrcInstance, parent); auto pluginAdapter = new PluginAdapter(lrcInstance, parent); auto currentConversation = new CurrentConversation(lrcInstance, parent); - auto currentAccount = new CurrentAccount(lrcInstance, parent); + auto currentAccount = new CurrentAccount(lrcInstance, appSettingsManager, parent); // qml adapter registration QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, callAdapter, "CallAdapter"); @@ -127,7 +125,6 @@ registerTypes(QQmlEngine* engine, QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, contactAdapter, "ContactAdapter"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, accountAdapter, "AccountAdapter"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, utilsAdapter, "UtilsAdapter"); - QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, settingsAdapter, "SettingsAdapter"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, pluginAdapter, "PluginAdapter"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, currentConversation, "CurrentConversation"); QML_REGISTERSINGLETONTYPE_POBJECT(NS_ADAPTERS, currentAccount, "CurrentAccount"); diff --git a/src/qtutils.h b/src/qtutils.h index 72a28ef90..725e2aa9b 100644 --- a/src/qtutils.h +++ b/src/qtutils.h @@ -24,7 +24,7 @@ #include <QObject> -#define PROPERTY_BASE(type, prop) \ +#define PROPERTY_GETTER_BASE(type, prop) \ type prop##_ {}; \ \ public: \ @@ -32,7 +32,9 @@ public: \ type get_##prop() \ { \ return prop##_; \ - } \ + } + +#define PROPERTY_SETTER_BASE(type, prop) \ void set_##prop(const type& x = {}) \ { \ if (prop##_ != x) { \ @@ -41,6 +43,10 @@ public: \ } \ } +#define PROPERTY_BASE(type, prop) \ + PROPERTY_GETTER_BASE(type, prop) \ + PROPERTY_SETTER_BASE(type, prop) + #define QML_RO_PROPERTY(type, prop) \ private: \ Q_PROPERTY(type prop READ get_##prop NOTIFY prop##Changed); \ diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp deleted file mode 100644 index 8b871a089..000000000 --- a/src/settingsadapter.cpp +++ /dev/null @@ -1,1191 +0,0 @@ -/* - * Copyright (C) 2020 by Savoir-faire Linux - * Author: Yang Wang <yang.wang@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "settingsadapter.h" - -#include "api/newcodecmodel.h" -#include "api/newdevicemodel.h" - -SettingsAdapter::SettingsAdapter(AppSettingsManager* settingsManager, - LRCInstance* instance, - QObject* parent) - : QmlAdapterBase(instance, parent) - , settingsManager_(settingsManager) -{} - -QString -SettingsAdapter::getDir_Document() -{ - return QDir::toNativeSeparators( - QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); -} - -QString -SettingsAdapter::getDir_Download() -{ - QString downloadPath = QDir::toNativeSeparators(lrcInstance_->accountModel().downloadDirectory); - if (downloadPath.isEmpty()) { - downloadPath = lrc::api::DataTransferModel::createDefaultDirectory(); - setDownloadPath(downloadPath); - lrcInstance_->accountModel().downloadDirectory = downloadPath; - } -#ifdef Q_OS_WIN - int pos = downloadPath.lastIndexOf(QChar('\\')); -#else - int pos = downloadPath.lastIndexOf(QChar('/')); -#endif - if (pos == downloadPath.length() - 1) - downloadPath.truncate(pos); - return downloadPath; -} - -QVariant -SettingsAdapter::getAppValue(const Settings::Key key) -{ - return settingsManager_->getValue(key); -} - -void -SettingsAdapter::setAppValue(const Settings::Key key, const QVariant& value) -{ - settingsManager_->setValue(key, value); -} - -void -SettingsAdapter::setRunOnStartUp(bool state) -{ - if (Utils::CheckStartupLink(L"Jami")) { - if (!state) { - Utils::DeleteStartupLink(L"Jami"); - } - } else if (state) { - Utils::CreateStartupLink(L"Jami"); - } -} - -void -SettingsAdapter::setDownloadPath(QString dir) -{ - setAppValue(Settings::Key::DownloadPath, dir); - lrcInstance_->accountModel().downloadDirectory = dir + "/"; -} - -lrc::api::video::ResRateList -SettingsAdapter::get_ResRateList(lrc::api::video::Channel channel, QString device) -{ - auto deviceCapabilities = get_DeviceCapabilities(device); - - return deviceCapabilities[channel]; -} - -int -SettingsAdapter::get_DeviceCapabilitiesSize(const QString& device) -{ - return get_DeviceCapabilities(device).size(); -} - -QVector<QString> -SettingsAdapter::getResolutions(const QString& device) -{ - QVector<QString> resolutions; - - auto currentSettings = lrcInstance_->avModel().getDeviceSettings(device); - - auto currentChannel = currentSettings.channel.isEmpty() ? "default" : currentSettings.channel; - auto channelCaps = get_ResRateList(currentChannel, device); - for (auto [resolution, frameRateList] : channelCaps) { - for (auto rate : frameRateList) { - (void) rate; - resolutions.append(resolution); - } - } - - return resolutions; -} - -QVector<int> -SettingsAdapter::getFrameRates(const QString& device) -{ - QVector<int> rates; - - auto currentSettings = lrcInstance_->avModel().getDeviceSettings(device); - - auto currentChannel = currentSettings.channel.isEmpty() ? "default" : currentSettings.channel; - auto channelCaps = get_ResRateList(currentChannel, device); - for (auto [resolution, frameRateList] : channelCaps) { - for (auto rate : frameRateList) { - rates.append((int) rate); - } - } - - return rates; -} - -lrc::api::video::Capabilities -SettingsAdapter::get_DeviceCapabilities(const QString& device) -{ - return lrcInstance_->avModel().getDeviceCapabilities(device); -} - -QString -SettingsAdapter::get_Video_Settings_Channel(const QString& deviceId) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - - return (QString) settings.channel; -} - -QString -SettingsAdapter::get_Video_Settings_Name(const QString& deviceId) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - - return (QString) settings.name; -} - -QString -SettingsAdapter::get_Video_Settings_Id(const QString& deviceId) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - - return (QString) settings.id; -} - -qreal -SettingsAdapter::get_Video_Settings_Rate(const QString& deviceId) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - - return (qreal) settings.rate; -} - -QString -SettingsAdapter::get_Video_Settings_Size(const QString& deviceId) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - - return (QString) settings.size; -} - -void -SettingsAdapter::set_Video_Settings_Rate_And_Resolution(const QString& deviceId, - qreal rate, - const QString& resolution) -{ - auto settings = lrcInstance_->avModel().getDeviceSettings(deviceId); - settings.rate = rate; - settings.size = resolution; - lrcInstance_->avModel().setDeviceSettings(settings); -} - -const lrc::api::account::Info& -SettingsAdapter::getCurrentAccountInfo() -{ - return lrcInstance_->getCurrentAccountInfo(); -} - -const Q_INVOKABLE lrc::api::profile::Info& -SettingsAdapter::getCurrentAccount_Profile_Info() -{ - return lrcInstance_->getCurrentAccountInfo().profileInfo; -} - -lrc::api::ContactModel* -SettingsAdapter::getContactModel() -{ - return getCurrentAccountInfo().contactModel.get(); -} - -lrc::api::NewDeviceModel* -SettingsAdapter::getDeviceModel() -{ - return getCurrentAccountInfo().deviceModel.get(); -} - -QString -SettingsAdapter::get_CurrentAccountInfo_RegisteredName() -{ - return lrcInstance_->getCurrentAccountInfo().registeredName; -} - -QString -SettingsAdapter::get_CurrentAccountInfo_Id() -{ - return lrcInstance_->getCurrentAccountInfo().id; -} - -bool -SettingsAdapter::get_CurrentAccountInfo_Enabled() -{ - return lrcInstance_->getCurrentAccountInfo().enabled; -} - -QString -SettingsAdapter::getCurrentAccount_Profile_Info_Uri() -{ - return getCurrentAccount_Profile_Info().uri; -} - -QString -SettingsAdapter::getCurrentAccount_Profile_Info_Alias() -{ - return getCurrentAccount_Profile_Info().alias; -} - -int -SettingsAdapter::getCurrentAccount_Profile_Info_Type() -{ - return (int) (getCurrentAccount_Profile_Info().type); -} - -QString -SettingsAdapter::getAccountBestName() -{ - return lrcInstance_->accountModel().bestNameForAccount(lrcInstance_->get_currentAccountId()); -} - -lrc::api::account::ConfProperties_t -SettingsAdapter::getAccountConfig() -{ - lrc::api::account::ConfProperties_t res; - try { - res = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->get_currentAccountId()); - } catch (...) { - } - return res; -} - -QString -SettingsAdapter::getAccountConfig_Manageruri() -{ - return getAccountConfig().managerUri; -} - -QString -SettingsAdapter::getAccountConfig_Username() -{ - return getAccountConfig().username; -} - -QString -SettingsAdapter::getAccountConfig_Hostname() -{ - return getAccountConfig().hostname; -} - -QString -SettingsAdapter::getAccountConfig_Password() -{ - return getAccountConfig().password; -} - -bool -SettingsAdapter::getAccountConfig_KeepAliveEnabled() -{ - return getAccountConfig().keepAliveEnabled; -} - -QString -SettingsAdapter::getAccountConfig_RouteSet() -{ - return getAccountConfig().routeset; -} - -QString -SettingsAdapter::getAccountConfig_ProxyServer() -{ - return getAccountConfig().proxyServer; -} - -bool -SettingsAdapter::getAccountConfig_PeerDiscovery() -{ - return getAccountConfig().peerDiscovery; -} - -bool -SettingsAdapter::getAccountConfig_DHT_PublicInCalls() -{ - return getAccountConfig().DHT.PublicInCalls; -} - -bool -SettingsAdapter::getAccountConfig_ReadReceipt() -{ - return getAccountConfig().sendReadReceipt; -} - -bool -SettingsAdapter::getAccountConfig_RendezVous() -{ - return getAccountConfig().isRendezVous; -} - -bool -SettingsAdapter::getAccountConfig_AutoAnswer() -{ - return getAccountConfig().autoAnswer; -} - -QString -SettingsAdapter::getAccountConfig_RingNS_Uri() -{ - return getAccountConfig().RingNS.uri; -} - -bool -SettingsAdapter::getAccountConfig_ProxyEnabled() -{ - return getAccountConfig().proxyEnabled; -} - -QString -SettingsAdapter::getAccountConfig_TLS_CertificateListFile() -{ - return getAccountConfig().TLS.certificateListFile; -} - -QString -SettingsAdapter::getAccountConfig_TLS_CertificateFile() -{ - return getAccountConfig().TLS.certificateFile; -} - -QString -SettingsAdapter::getAccountConfig_TLS_PrivateKeyFile() -{ - return getAccountConfig().TLS.privateKeyFile; -} - -bool -SettingsAdapter::getAccountConfig_TLS_Enable() -{ - return getAccountConfig().TLS.enable; -} - -QString -SettingsAdapter::getAccountConfig_TLS_Password() -{ - return getAccountConfig().TLS.password; -} - -bool -SettingsAdapter::getAccountConfig_TLS_VerifyServer() -{ - return getAccountConfig().TLS.verifyServer; -} - -bool -SettingsAdapter::getAccountConfig_TLS_VerifyClient() -{ - return getAccountConfig().TLS.verifyClient; -} - -bool -SettingsAdapter::getAccountConfig_TLS_RequireClientCertificate() -{ - return getAccountConfig().TLS.requireClientCertificate; -} - -int -SettingsAdapter::getAccountConfig_TLS_Method_inInt() -{ - return (int) getAccountConfig().TLS.method; -} - -QString -SettingsAdapter::getAccountConfig_TLS_Servername() -{ - return getAccountConfig().TLS.serverName; -} - -int -SettingsAdapter::getAccountConfig_TLS_NegotiationTimeoutSec() -{ - return getAccountConfig().TLS.negotiationTimeoutSec; -} - -bool -SettingsAdapter::getAccountConfig_SRTP_Enabled() -{ - return getAccountConfig().SRTP.enable; -} - -int -SettingsAdapter::getAccountConfig_SRTP_KeyExchange() -{ - return (int) getAccountConfig().SRTP.keyExchange; -} - -bool -SettingsAdapter::getAccountConfig_SRTP_RtpFallback() -{ - return getAccountConfig().SRTP.rtpFallback; -} - -bool -SettingsAdapter::getAccountConfig_UpnpEnabled() -{ - return getAccountConfig().upnpEnabled; -} - -bool -SettingsAdapter::getAccountConfig_TURN_Enabled() -{ - return getAccountConfig().TURN.enable; -} - -QString -SettingsAdapter::getAccountConfig_TURN_Server() -{ - return getAccountConfig().TURN.server; -} - -QString -SettingsAdapter::getAccountConfig_TURN_Username() -{ - return getAccountConfig().TURN.username; -} - -QString -SettingsAdapter::getAccountConfig_TURN_Password() -{ - return getAccountConfig().TURN.password; -} - -QString -SettingsAdapter::getAccountConfig_TURN_Realm() -{ - return getAccountConfig().TURN.realm; -} - -bool -SettingsAdapter::getAccountConfig_STUN_Enabled() -{ - return getAccountConfig().STUN.enable; -} - -QString -SettingsAdapter::getAccountConfig_STUN_Server() -{ - return getAccountConfig().STUN.server; -} - -bool -SettingsAdapter::getAccountConfig_Video_Enabled() -{ - return getAccountConfig().Video.videoEnabled; -} - -int -SettingsAdapter::getAccountConfig_Video_VideoPortMin() -{ - return getAccountConfig().Video.videoPortMin; -} - -int -SettingsAdapter::getAccountConfig_Video_VideoPortMax() -{ - return getAccountConfig().Video.videoPortMax; -} - -int -SettingsAdapter::getAccountConfig_Audio_AudioPortMin() -{ - return getAccountConfig().Audio.audioPortMin; -} - -int -SettingsAdapter::getAccountConfig_Audio_AudioPortMax() -{ - return getAccountConfig().Audio.audioPortMax; -} - -bool -SettingsAdapter::getAccountConfig_Ringtone_RingtoneEnabled() -{ - return getAccountConfig().Ringtone.ringtoneEnabled; -} - -QString -SettingsAdapter::getAccountConfig_Ringtone_RingtonePath() -{ - return getAccountConfig().Ringtone.ringtonePath; -} - -int -SettingsAdapter::getAccountConfig_Registration_Expire() -{ - return getAccountConfig().Registration.expire; -} - -int -SettingsAdapter::getAccountConfig_Localport() -{ - return getAccountConfig().localPort; -} - -bool -SettingsAdapter::getAccountConfig_PublishedSameAsLocal() -{ - return getAccountConfig().publishedSameAsLocal; -} - -QString -SettingsAdapter::getAccountConfig_PublishedAddress() -{ - return getAccountConfig().publishedAddress; -} - -int -SettingsAdapter::getAccountConfig_PublishedPort() -{ - return getAccountConfig().publishedPort; -} - -bool -SettingsAdapter::getAccountConfig_AllowIPAutoRewrite() -{ - return getAccountConfig().allowIPAutoRewrite; -} - -QString -SettingsAdapter::getAccountConfig_Mailbox() -{ - return getAccountConfig().mailbox; -} - -void -SettingsAdapter::setAccountConfig_Username(QString input) -{ - auto confProps = getAccountConfig(); - confProps.username = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAccountConfig_Hostname(QString input) -{ - auto confProps = getAccountConfig(); - confProps.hostname = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAccountConfig_Password(QString input) -{ - auto confProps = getAccountConfig(); - confProps.password = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAccountConfig_RouteSet(QString input) -{ - auto confProps = getAccountConfig(); - confProps.routeset = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAutoConnectOnLocalNetwork(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.peerDiscovery = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setCallsUntrusted(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.DHT.PublicInCalls = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setIsRendezVous(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.isRendezVous = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAutoAnswerCalls(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.autoAnswer = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setSendReadReceipt(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.sendReadReceipt = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setEnableRingtone(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Ringtone.ringtoneEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setEnableProxy(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.proxyEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setKeepAliveEnabled(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.keepAliveEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseUPnP(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.upnpEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseTURN(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TURN.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseSTUN(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.STUN.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setVideoState(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Video.videoEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseSRTP(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.SRTP.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseSDES(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.SRTP.keyExchange = state ? lrc::api::account::KeyExchangeProtocol::SDES - : lrc::api::account::KeyExchangeProtocol::NONE; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseRTPFallback(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.SRTP.rtpFallback = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseTLS(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setVerifyCertificatesServer(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.verifyServer = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setVerifyCertificatesClient(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.verifyClient = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setRequireCertificatesIncomingTLS(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.requireClientCertificate = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setUseCustomAddressAndPort(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.publishedSameAsLocal = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setAllowIPAutoRewrite(bool state) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.allowIPAutoRewrite = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setNameServer(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.RingNS.uri = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setProxyAddress(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.proxyServer = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setBootstrapAddress(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.hostname = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setTURNAddress(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TURN.server = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setTURNUsername(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TURN.username = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setTURNPassword(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TURN.password = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setTURNRealm(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TURN.realm = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setSTUNAddress(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.STUN.server = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::lineEditVoiceMailDialCodeEditFinished(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.mailbox = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::outgoingTLSServerNameLineEditTextChanged(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.serverName = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::lineEditSIPCertPasswordLineEditTextChanged(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.password = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::lineEditSIPCustomAddressLineEditTextChanged(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.publishedAddress = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::customPortSIPSpinBoxValueChanged(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.publishedPort = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::negotiationTimeoutSpinBoxValueChanged(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.negotiationTimeoutSec = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Registration.expire = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::autoAcceptFiles(bool value) -{ - lrcInstance_->accountModel().autoTransferFromTrusted = value; - setAppValue(Settings::Key::AutoAcceptFiles, value); -} - -void -SettingsAdapter::allowFromUntrusted(bool value) -{ - lrcInstance_->accountModel().autoTransferFromUntrusted = value; - setAppValue(Settings::Key::AllowFromUntrusted, value); -} - -void -SettingsAdapter::acceptTransferBelow(int value) -{ - lrcInstance_->accountModel().autoTransferSizeThreshold = value; - setAppValue(Settings::Key::AcceptTransferBelow, value); -} - -void -SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.localPort = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::audioRTPMinPortSpinBoxEditFinished(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Audio.audioPortMin = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::audioRTPMaxPortSpinBoxEditFinished(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Audio.audioPortMax = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::videoRTPMinPortSpinBoxEditFinished(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Video.videoPortMin = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::videoRTPMaxPortSpinBoxEditFinished(int value) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Video.videoPortMax = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - - if (static_cast<int>(confProps.TLS.method) != index) { - if (index == 0) { - confProps.TLS.method = lrc::api::account::TlsMethod::DEFAULT; - } else if (index == 1) { - confProps.TLS.method = lrc::api::account::TlsMethod::TLSv1; - } else if (index == 2) { - confProps.TLS.method = lrc::api::account::TlsMethod::TLSv1_1; - } else { - confProps.TLS.method = lrc::api::account::TlsMethod::TLSv1_2; - } - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), - confProps); - } -} - -void -SettingsAdapter::setDeviceName(QString text) -{ - lrcInstance_->getCurrentAccountInfo().deviceModel->setCurrentDeviceName(text); -} - -void -SettingsAdapter::unbanContact(int index) -{ - auto& accountInfo = lrcInstance_->getCurrentAccountInfo(); - auto bannedContactList = accountInfo.contactModel->getBannedContacts(); - auto it = bannedContactList.begin(); - std::advance(it, index); - - try { - auto contactInfo = accountInfo.contactModel->getContact(*it); - accountInfo.contactModel->addContact(contactInfo); - } catch (const std::out_of_range& e) { - qDebug() << e.what(); - } -} - -void -SettingsAdapter::audioCodecsStateChange(unsigned int id, bool isToEnable) -{ - auto audioCodecList = lrcInstance_->getCurrentAccountInfo().codecModel->getAudioCodecs(); - lrcInstance_->getCurrentAccountInfo().codecModel->enable(id, isToEnable); -} - -void -SettingsAdapter::videoCodecsStateChange(unsigned int id, bool isToEnable) -{ - auto videoCodecList = lrcInstance_->getCurrentAccountInfo().codecModel->getVideoCodecs(); - lrcInstance_->getCurrentAccountInfo().codecModel->enable(id, isToEnable); -} - -void -SettingsAdapter::decreaseAudioCodecPriority(unsigned int id) -{ - lrcInstance_->getCurrentAccountInfo().codecModel->decreasePriority(id, false); -} - -void -SettingsAdapter::increaseAudioCodecPriority(unsigned int id) -{ - lrcInstance_->getCurrentAccountInfo().codecModel->increasePriority(id, false); -} - -void -SettingsAdapter::decreaseVideoCodecPriority(unsigned int id) -{ - lrcInstance_->getCurrentAccountInfo().codecModel->decreasePriority(id, true); -} - -void -SettingsAdapter::increaseVideoCodecPriority(unsigned int id) -{ - lrcInstance_->getCurrentAccountInfo().codecModel->increasePriority(id, true); -} - -void -SettingsAdapter::set_RingtonePath(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.Ringtone.ringtonePath = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::set_FileCACert(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.certificateListFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::set_FileUserCert(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.certificateFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::set_FilePrivateKey(QString text) -{ - auto confProps = lrcInstance_->accountModel().getAccountConfig( - lrcInstance_->get_currentAccountId()); - confProps.TLS.privateKeyFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps); -} - -void -SettingsAdapter::setDefaultModerator(const QString& accountId, - const QString& peerURI, - const bool& state) -{ - lrcInstance_->accountModel().setDefaultModerator(accountId, peerURI, state); -} - -void -SettingsAdapter::setAllModeratorsEnabled(const QString& accountId, bool enabled) -{ - lrcInstance_->accountModel().setAllModerators(accountId, enabled); -} - -QStringList -SettingsAdapter::getDefaultModerators(const QString& accountId) -{ - return lrcInstance_->accountModel().getDefaultModerators(accountId); -} - -void -SettingsAdapter::enableLocalModerators(const QString& accountId, const bool& isModEnabled) -{ - lrcInstance_->accountModel().enableLocalModerators(accountId, isModEnabled); -} - -bool -SettingsAdapter::isLocalModeratorsEnabled(const QString& accountId) -{ - return lrcInstance_->accountModel().isLocalModeratorsEnabled(accountId); -} - -bool -SettingsAdapter::isAllModeratorsEnabled(const QString& accountId) -{ - return lrcInstance_->accountModel().isAllModerators(accountId); -} - -QString -SettingsAdapter::getLogs() const -{ - return logList_.join("\n"); -} - -int -SettingsAdapter::getSizeOfLogs() const -{ - return logList_.size(); -} - -int -SettingsAdapter::getFirstLogLength() const -{ - return logList_.isEmpty() ? 0 : (logList_.first()).length(); -} - -void -SettingsAdapter::clearLogs() -{ - logList_.clear(); -} - -void -SettingsAdapter::monitor(const bool& continuous) -{ - disconnect(debugMessageReceivedConnection_); - if (continuous) - debugMessageReceivedConnection_ - = QObject::connect(&lrcInstance_->behaviorController(), - &lrc::api::BehaviorController::debugMessageReceived, - [this](const QString& data) { - logList_.append(data); - if (logList_.size() >= LOGSLIMIT) { - logList_.removeFirst(); - } - Q_EMIT SettingsAdapter::debugMessageReceived(data); - }); - lrcInstance_->monitor(continuous); -} diff --git a/src/settingsadapter.h b/src/settingsadapter.h deleted file mode 100644 index 73ea02a76..000000000 --- a/src/settingsadapter.h +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright (C) 2020 by Savoir-faire Linux - * Author: Yang Wang <yang.wang@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include <QObject> - -#include "api/account.h" -#include "api/datatransfermodel.h" -#include "lrcinstance.h" -#include "typedefs.h" -#include "utils.h" -#include "qmladapterbase.h" -#include "appsettingsmanager.h" - -class SettingsAdapter : public QmlAdapterBase -{ - Q_OBJECT - -#define LOGSLIMIT 10000 - -public: - explicit SettingsAdapter(AppSettingsManager* settingsManager, - LRCInstance* instance, - QObject* parent = nullptr); - - void safeInit() override {} - - // Getters of directories - Q_INVOKABLE QString getDir_Document(); - Q_INVOKABLE QString getDir_Download(); - - Q_INVOKABLE QVariant getAppValue(const Settings::Key key); - Q_INVOKABLE void setAppValue(const Settings::Key key, const QVariant& value); - - Q_INVOKABLE void setRunOnStartUp(bool state); - Q_INVOKABLE void setDownloadPath(QString dir); - - // Getters of devices' Info and options - Q_INVOKABLE lrc::api::video::Capabilities get_DeviceCapabilities(const QString& device); - Q_INVOKABLE lrc::api::video::ResRateList get_ResRateList(lrc::api::video::Channel channel, - QString device); - Q_INVOKABLE int get_DeviceCapabilitiesSize(const QString& device); - - // Getters of resolution and frame rates of current device - Q_INVOKABLE QVector<QString> getResolutions(const QString& device); - Q_INVOKABLE QVector<int> getFrameRates(const QString& device); - - // Getters and setters: lrc video::setting - Q_INVOKABLE QString get_Video_Settings_Channel(const QString& deviceId); - Q_INVOKABLE QString get_Video_Settings_Name(const QString& deviceId); - Q_INVOKABLE QString get_Video_Settings_Id(const QString& deviceId); - Q_INVOKABLE qreal get_Video_Settings_Rate(const QString& deviceId); - Q_INVOKABLE QString get_Video_Settings_Size(const QString& deviceId); - - Q_INVOKABLE void set_Video_Settings_Rate_And_Resolution(const QString& deviceId, - qreal rate, - const QString& resolution); - - // Getters and setters of current account Info - const Q_INVOKABLE lrc::api::account::Info& getCurrentAccountInfo(); - const Q_INVOKABLE lrc::api::profile::Info& getCurrentAccount_Profile_Info(); - - Q_INVOKABLE lrc::api::ContactModel* getContactModel(); - Q_INVOKABLE lrc::api::NewDeviceModel* getDeviceModel(); - - Q_INVOKABLE QString get_CurrentAccountInfo_RegisteredName(); - Q_INVOKABLE QString get_CurrentAccountInfo_Id(); - Q_INVOKABLE bool get_CurrentAccountInfo_Enabled(); - - // Profile info - Q_INVOKABLE QString getCurrentAccount_Profile_Info_Uri(); - Q_INVOKABLE QString getCurrentAccount_Profile_Info_Alias(); - Q_INVOKABLE int getCurrentAccount_Profile_Info_Type(); - Q_INVOKABLE QString getAccountBestName(); - - // Getters and setters of ConfProperties_t - // Getters - Q_INVOKABLE lrc::api::account::ConfProperties_t getAccountConfig(); - Q_INVOKABLE QString getAccountConfig_Manageruri(); - Q_INVOKABLE QString getAccountConfig_Username(); - Q_INVOKABLE QString getAccountConfig_Hostname(); - Q_INVOKABLE QString getAccountConfig_Password(); - - Q_INVOKABLE bool getAccountConfig_KeepAliveEnabled(); - Q_INVOKABLE QString getAccountConfig_RouteSet(); - Q_INVOKABLE QString getAccountConfig_ProxyServer(); - Q_INVOKABLE bool getAccountConfig_ProxyEnabled(); - - Q_INVOKABLE bool getAccountConfig_PeerDiscovery(); - Q_INVOKABLE bool getAccountConfig_DHT_PublicInCalls(); - Q_INVOKABLE bool getAccountConfig_ReadReceipt(); - Q_INVOKABLE bool getAccountConfig_RendezVous(); - Q_INVOKABLE bool getAccountConfig_AutoAnswer(); - - Q_INVOKABLE QString getAccountConfig_RingNS_Uri(); - - Q_INVOKABLE QString getAccountConfig_TLS_CertificateListFile(); - Q_INVOKABLE QString getAccountConfig_TLS_CertificateFile(); - Q_INVOKABLE QString getAccountConfig_TLS_PrivateKeyFile(); - Q_INVOKABLE bool getAccountConfig_TLS_Enable(); - Q_INVOKABLE QString getAccountConfig_TLS_Password(); - Q_INVOKABLE bool getAccountConfig_TLS_VerifyServer(); - Q_INVOKABLE bool getAccountConfig_TLS_VerifyClient(); - Q_INVOKABLE bool getAccountConfig_TLS_RequireClientCertificate(); - Q_INVOKABLE int getAccountConfig_TLS_Method_inInt(); - Q_INVOKABLE QString getAccountConfig_TLS_Servername(); - Q_INVOKABLE int getAccountConfig_TLS_NegotiationTimeoutSec(); - - Q_INVOKABLE bool getAccountConfig_SRTP_Enabled(); - Q_INVOKABLE int getAccountConfig_SRTP_KeyExchange(); - Q_INVOKABLE bool getAccountConfig_SRTP_RtpFallback(); - - Q_INVOKABLE bool getAccountConfig_UpnpEnabled(); - Q_INVOKABLE bool getAccountConfig_TURN_Enabled(); - Q_INVOKABLE QString getAccountConfig_TURN_Server(); - Q_INVOKABLE QString getAccountConfig_TURN_Username(); - Q_INVOKABLE QString getAccountConfig_TURN_Password(); - Q_INVOKABLE QString getAccountConfig_TURN_Realm(); - - Q_INVOKABLE bool getAccountConfig_STUN_Enabled(); - Q_INVOKABLE QString getAccountConfig_STUN_Server(); - - Q_INVOKABLE bool getAccountConfig_Video_Enabled(); - Q_INVOKABLE int getAccountConfig_Video_VideoPortMin(); - Q_INVOKABLE int getAccountConfig_Video_VideoPortMax(); - - Q_INVOKABLE int getAccountConfig_Audio_AudioPortMin(); - Q_INVOKABLE int getAccountConfig_Audio_AudioPortMax(); - - Q_INVOKABLE bool getAccountConfig_Ringtone_RingtoneEnabled(); - Q_INVOKABLE QString getAccountConfig_Ringtone_RingtonePath(); - - Q_INVOKABLE int getAccountConfig_Registration_Expire(); - Q_INVOKABLE int getAccountConfig_Localport(); - Q_INVOKABLE bool getAccountConfig_PublishedSameAsLocal(); - Q_INVOKABLE QString getAccountConfig_PublishedAddress(); - Q_INVOKABLE int getAccountConfig_PublishedPort(); - Q_INVOKABLE bool getAccountConfig_AllowIPAutoRewrite(); - - Q_INVOKABLE QString getAccountConfig_Mailbox(); - - // Setters - Q_INVOKABLE void setAccountConfig_Username(QString input); - Q_INVOKABLE void setAccountConfig_Hostname(QString input); - Q_INVOKABLE void setAccountConfig_Password(QString input); - Q_INVOKABLE void setAccountConfig_RouteSet(QString input); - - Q_INVOKABLE void setAutoConnectOnLocalNetwork(bool state); - Q_INVOKABLE void setCallsUntrusted(bool state); - Q_INVOKABLE void setIsRendezVous(bool state); - Q_INVOKABLE void setAutoAnswerCalls(bool state); - Q_INVOKABLE void setSendReadReceipt(bool state); - Q_INVOKABLE void setEnableRingtone(bool state); - Q_INVOKABLE void setEnableProxy(bool state); - Q_INVOKABLE void setKeepAliveEnabled(bool state); - Q_INVOKABLE void setUseUPnP(bool state); - Q_INVOKABLE void setUseTURN(bool state); - Q_INVOKABLE void setUseSTUN(bool state); - Q_INVOKABLE void setVideoState(bool state); - Q_INVOKABLE void setUseSRTP(bool state); - Q_INVOKABLE void setUseSDES(bool state); - Q_INVOKABLE void setUseRTPFallback(bool state); - Q_INVOKABLE void setUseTLS(bool state); - Q_INVOKABLE void setVerifyCertificatesServer(bool state); - Q_INVOKABLE void setVerifyCertificatesClient(bool state); - Q_INVOKABLE void setRequireCertificatesIncomingTLS(bool state); - Q_INVOKABLE void setUseCustomAddressAndPort(bool state); - Q_INVOKABLE void setAllowIPAutoRewrite(bool state); - - Q_INVOKABLE void setNameServer(QString text); - Q_INVOKABLE void setProxyAddress(QString text); - Q_INVOKABLE void setBootstrapAddress(QString text); - Q_INVOKABLE void setTURNAddress(QString text); - Q_INVOKABLE void setTURNUsername(QString text); - Q_INVOKABLE void setTURNPassword(QString text); - Q_INVOKABLE void setTURNRealm(QString text); - Q_INVOKABLE void setSTUNAddress(QString text); - - Q_INVOKABLE void lineEditVoiceMailDialCodeEditFinished(QString text); - Q_INVOKABLE void outgoingTLSServerNameLineEditTextChanged(QString text); - Q_INVOKABLE void lineEditSIPCertPasswordLineEditTextChanged(QString text); - Q_INVOKABLE void lineEditSIPCustomAddressLineEditTextChanged(QString text); - - Q_INVOKABLE void customPortSIPSpinBoxValueChanged(int value); - Q_INVOKABLE void negotiationTimeoutSpinBoxValueChanged(int value); - Q_INVOKABLE void registrationExpirationTimeSpinBoxValueChanged(int value); - Q_INVOKABLE void networkInterfaceSpinBoxValueChanged(int value); - Q_INVOKABLE void audioRTPMinPortSpinBoxEditFinished(int value); - Q_INVOKABLE void audioRTPMaxPortSpinBoxEditFinished(int value); - Q_INVOKABLE void videoRTPMinPortSpinBoxEditFinished(int value); - Q_INVOKABLE void videoRTPMaxPortSpinBoxEditFinished(int value); - - Q_INVOKABLE void autoAcceptFiles(bool value); - Q_INVOKABLE void allowFromUntrusted(bool value); - Q_INVOKABLE void acceptTransferBelow(int value); - - Q_INVOKABLE void tlsProtocolComboBoxIndexChanged(const int& index); - - Q_INVOKABLE void setDeviceName(QString text); - - Q_INVOKABLE void unbanContact(int index); - - Q_INVOKABLE void audioCodecsStateChange(unsigned int id, bool isToEnable); - Q_INVOKABLE void videoCodecsStateChange(unsigned int id, bool isToEnable); - - Q_INVOKABLE void decreaseAudioCodecPriority(unsigned int id); - Q_INVOKABLE void increaseAudioCodecPriority(unsigned int id); - - Q_INVOKABLE void decreaseVideoCodecPriority(unsigned int id); - Q_INVOKABLE void increaseVideoCodecPriority(unsigned int id); - - Q_INVOKABLE void set_RingtonePath(QString text); - Q_INVOKABLE void set_FileCACert(QString text); - Q_INVOKABLE void set_FileUserCert(QString text); - Q_INVOKABLE void set_FilePrivateKey(QString text); - - Q_INVOKABLE void setDefaultModerator(const QString& accountID, - const QString& peerURI, - const bool& state); - Q_INVOKABLE void setAllModeratorsEnabled(const QString& accountId, bool enabled); - Q_INVOKABLE QStringList getDefaultModerators(const QString& accId); - Q_INVOKABLE void enableLocalModerators(const QString& accountID, const bool& isModEnabled); - Q_INVOKABLE bool isLocalModeratorsEnabled(const QString& accountId); - Q_INVOKABLE bool isAllModeratorsEnabled(const QString& accountId); - - Q_INVOKABLE void monitor(const bool& continuous); - Q_INVOKABLE QString getLogs() const; - Q_INVOKABLE int getSizeOfLogs() const; - Q_INVOKABLE int getFirstLogLength() const; - Q_INVOKABLE void clearLogs(); - -Q_SIGNALS: - void debugMessageReceived(const QString& message); - -private: - AppSettingsManager* settingsManager_; - - QMetaObject::Connection debugMessageReceivedConnection_; - - QStringList logList_; -}; -Q_DECLARE_METATYPE(SettingsAdapter*) diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index 176309a89..cad854e64 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -47,8 +47,6 @@ Rectangle { } function setSelected(sel, recovery = false) { - profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() - if(selectedMenu === sel && (!recovery)) { return } switch(sel) { case SettingsView.Account: @@ -57,7 +55,6 @@ Rectangle { pageIdCurrentAccountSettings.updateAccountInfoDisplayed() break case SettingsView.General: - generalSettings.updateValues() AccountAdapter.stopPreviewing() selectedMenu = sel break @@ -102,7 +99,6 @@ Rectangle { } } - property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() property int selectedMenu: SettingsView.Account // signal to redirect the page to main view signal settingsViewNeedToShowMainView() @@ -121,7 +117,7 @@ Rectangle { signal stopBooth property bool isSIP: { - switch (profileType) { + switch (CurrentAccount.type) { case Profile.Type.SIP: return true; default: diff --git a/src/settingsview/components/AccountProfile.qml b/src/settingsview/components/AccountProfile.qml index 3dcea71a3..9b1e3fb4b 100644 --- a/src/settingsview/components/AccountProfile.qml +++ b/src/settingsview/components/AccountProfile.qml @@ -36,10 +36,6 @@ ColumnLayout { } } - function updateAccountInfo() { - displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() - } - function stopBooth() { currentAccountAvatar.stopBooth() } @@ -77,6 +73,7 @@ ColumnLayout { font.pointSize: JamiTheme.textFontSize font.kerning: true + text: CurrentAccount.alias horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter diff --git a/src/settingsview/components/AdvancedCallSettings.qml b/src/settingsview/components/AdvancedCallSettings.qml index 39bfb3ff6..3e327280f 100644 --- a/src/settingsview/components/AdvancedCallSettings.qml +++ b/src/settingsview/components/AdvancedCallSettings.qml @@ -34,32 +34,9 @@ ColumnLayout { property bool isSIP property int itemWidth - function updateCallSettingsInfos() { - checkBoxUntrusted.checked = SettingsAdapter.getAccountConfig_DHT_PublicInCalls() - checkBoxRdv.checked = SettingsAdapter.getAccountConfig_RendezVous() - checkBoxAutoAnswer.checked = SettingsAdapter.getAccountConfig_AutoAnswer() - checkBoxCustomRingtone.checked = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() - checkboxAllModerators.checked = SettingsAdapter.isAllModeratorsEnabled(LRCInstance.currentAccountId) - - btnRingtone.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() - btnRingtone.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) - updateAndShowModeratorsSlot() - } - - function changeRingtonePath(url) { - if(url.length !== 0) { - SettingsAdapter.set_RingtonePath(url) - btnRingtone.textField = UtilsAdapter.toFileInfoName(url) - } else if (SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ - btnRingtone.textField = JamiStrings.addCustomRingtone - } - } - function updateAndShowModeratorsSlot() { - toggleLocalModerators.checked = SettingsAdapter.isLocalModeratorsEnabled( - LRCInstance.currentAccountId) moderatorListWidget.model.reset() - moderatorListWidget.visible = (moderatorListWidget.model.rowCount() > 0) + moderatorListWidget.visible = moderatorListWidget.model.rowCount() > 0 } Connections { @@ -76,14 +53,16 @@ ColumnLayout { mode: JamiFileDialog.OpenFile title: JamiStrings.selectNewRingtone folder: JamiQmlUtils.qmlFilePrefix + UtilsAdapter.toFileAbsolutepath( - SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) + CurrentAccount.ringtonePath_Ringtone) - nameFilters: [qsTr("Audio Files") + " (*.wav *.ogg *.opus *.mp3 *.aiff *.wma)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Audio Files") + " (*.wav *.ogg *.opus *.mp3 *.aiff *.wma)", + qsTr("All files") + " (*)"] onAccepted: { var url = UtilsAdapter.getAbsPath(file.toString()) - changeRingtonePath(url) + + if(url.length !== 0) + CurrentAccount.ringtonePath_Ringtone = url } } @@ -106,9 +85,9 @@ ColumnLayout { labelText: JamiStrings.allowCallsUnknownContacs fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setCallsUntrusted(checked) - } + checked: CurrentAccount.PublicInCalls_DHT + + onSwitchToggled: CurrentAccount.PublicInCalls_DHT = checked } ToggleSwitch { @@ -117,9 +96,9 @@ ColumnLayout { labelText: JamiStrings.autoAnswerCalls fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setAutoAnswerCalls(checked) - } + checked: CurrentAccount.autoAnswer + + onSwitchToggled: CurrentAccount.autoAnswer = checked } ToggleSwitch { @@ -128,17 +107,21 @@ ColumnLayout { labelText: JamiStrings.enableCustomRingtone fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setEnableRingtone(checked) - btnRingtone.enabled = checked - } + checked: CurrentAccount.ringtoneEnabled_Ringtone + + onSwitchToggled: CurrentAccount.ringtoneEnabled_Ringtone = checked } SettingMaterialButton { id: btnRingtone + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: checkBoxCustomRingtone.checked + + textField: UtilsAdapter.toFileInfoName(CurrentAccount.ringtonePath_Ringtone) + titleField: JamiStrings.selectCustomRingtone source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth @@ -147,14 +130,15 @@ ColumnLayout { ToggleSwitch { id: checkBoxRdv + visible: !isSIP labelText: JamiStrings.rendezVous fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setIsRendezVous(checked) - } + checked: CurrentAccount.isRendezVous + + onSwitchToggled: CurrentAccount.isRendezVous = checked } ToggleSwitch { @@ -163,8 +147,9 @@ ColumnLayout { labelText: JamiStrings.enableLocalModerators fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.enableLocalModerators( - LRCInstance.currentAccountId, checked) + checked: CurrentAccount.isLocalModeratorsEnabled + + onSwitchToggled: CurrentAccount.isLocalModeratorsEnabled = checked } ElidedTextLabel { @@ -182,6 +167,8 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: 160 + visible: model.rowCount() > 0 + model: ModeratorListModel { lrcInstance: LRCInstance } @@ -200,7 +187,7 @@ ColumnLayout { onClicked: moderatorListWidget.currentIndex = index onBtnContactClicked: { - SettingsAdapter.setDefaultModerator( + AccountAdapter.setDefaultModerator( LRCInstance.currentAccountId, contactID, false) updateAndShowModeratorsSlot() } @@ -239,8 +226,9 @@ ColumnLayout { labelText: JamiStrings.enableAllModerators fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.setAllModeratorsEnabled( - LRCInstance.currentAccountId, checked) + checked: CurrentAccount.isAllModeratorsEnabled + + onSwitchToggled: CurrentAccount.isAllModeratorsEnabled = checked } } } diff --git a/src/settingsview/components/AdvancedChatSettings.qml b/src/settingsview/components/AdvancedChatSettings.qml index fd902d11d..be7530758 100644 --- a/src/settingsview/components/AdvancedChatSettings.qml +++ b/src/settingsview/components/AdvancedChatSettings.qml @@ -29,10 +29,6 @@ ColumnLayout { property int itemWidth - function updateSettings() { - checkBoxSendDisplayed.checked = SettingsAdapter.getAccountConfig_ReadReceipt() - } - ElidedTextLabel { Layout.fillWidth: true @@ -52,9 +48,9 @@ ColumnLayout { labelText: JamiStrings.enableReadReceipts fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setSendReadReceipt(checked) - } + checked: CurrentAccount.sendReadReceipt + + onSwitchToggled: CurrentAccount.sendReadReceipt = checked } } } diff --git a/src/settingsview/components/AdvancedConnectivitySettings.qml b/src/settingsview/components/AdvancedConnectivitySettings.qml index c033abf74..144a90888 100644 --- a/src/settingsview/components/AdvancedConnectivitySettings.qml +++ b/src/settingsview/components/AdvancedConnectivitySettings.qml @@ -31,23 +31,6 @@ ColumnLayout { property int itemWidth property bool isSIP - function updateConnectivityAccountInfos() { - autoRegistrationAfterExpired.checked = SettingsAdapter.getAccountConfig_KeepAliveEnabled() - registrationExpireTimeoutSpinBox.valueField = SettingsAdapter.getAccountConfig_Registration_Expire() - networkInterfaceSpinBox.valueField = SettingsAdapter.getAccountConfig_Localport() - checkBoxUPnP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled() - checkBoxTurnEnable.checked = SettingsAdapter.getAccountConfig_TURN_Enabled() - lineEditTurnAddress.textField = SettingsAdapter.getAccountConfig_TURN_Server() - lineEditTurnUsername.textField = SettingsAdapter.getAccountConfig_TURN_Username() - lineEditTurnPassword.textField = SettingsAdapter.getAccountConfig_TURN_Password() - checkBoxSTUNEnable.checked = SettingsAdapter.getAccountConfig_STUN_Enabled() - lineEditSTUNAddress.textField = SettingsAdapter.getAccountConfig_STUN_Server() - lineEditTurnRealmSIP.textField = SettingsAdapter.getAccountConfig_TURN_Realm() - lineEditTurnRealmSIP.enabled = SettingsAdapter.getAccountConfig_TURN_Enabled() - lineEditSTUNAddress.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() - - } - ElidedTextLabel { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight @@ -70,11 +53,14 @@ ColumnLayout { labelText: JamiStrings.autoRegistration fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.setKeepAliveEnabled(checked) + checked: CurrentAccount.keepAliveEnabled + + onSwitchToggled: CurrentAccount.keepAliveEnabled = checked } SettingSpinBox { id: registrationExpireTimeoutSpinBox + visible: isSIP title: JamiStrings.registrationExpirationTime @@ -82,11 +68,14 @@ ColumnLayout { bottomValue: 0 topValue: 7*24*3600 - onNewValue: SettingsAdapter.registrationExpirationTimeSpinBoxValueChanged(valueField) + valueField: CurrentAccount.expire_Registration + + onNewValue: CurrentAccount.expire_Registration = valueField } SettingSpinBox { id: networkInterfaceSpinBox + visible: isSIP title: JamiStrings.networkInterface @@ -94,7 +83,14 @@ ColumnLayout { bottomValue: 0 topValue: 65535 - onNewValue: SettingsAdapter.networkInterfaceSpinBoxValueChanged(valueField) + valueField: CurrentAccount.localPort + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.localPort }) + } + + onNewValue: CurrentAccount.localPort = valueField } ToggleSwitch { @@ -105,7 +101,9 @@ ColumnLayout { labelText: JamiStrings.useUPnP fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.setUseUPnP(checked) + checked: CurrentAccount.upnpEnabled + + onSwitchToggled: CurrentAccount.upnpEnabled = checked } ToggleSwitch { @@ -116,15 +114,9 @@ ColumnLayout { labelText: JamiStrings.useTURN fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseTURN(checked) - if (isSIP) { - lineEditTurnAddress.enabled = checked - lineEditTurnUsername.enabled = checked - lineEditTurnPassword.enabled = checked - lineEditTurnRealmSIP.enabled = checked - } - } + checked: CurrentAccount.enable_TURN + + onSwitchToggled: CurrentAccount.enable_TURN = checked } SettingsMaterialLineEdit { @@ -132,9 +124,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxTurnEnable.checked + + textField: CurrentAccount.server_TURN + itemWidth: root.itemWidth titleField: JamiStrings.turnAdress - onEditFinished: SettingsAdapter.setTURNAddress(textField) + + onEditFinished: CurrentAccount.server_TURN = textField } SettingsMaterialLineEdit { @@ -142,9 +140,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxTurnEnable.checked + + textField: CurrentAccount.username_TURN + itemWidth: root.itemWidth titleField: JamiStrings.turnUsername - onEditFinished: SettingsAdapter.setTURNUsername(textField) + + onEditFinished: CurrentAccount.username_TURN = textField } SettingsMaterialLineEdit { @@ -152,9 +156,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxTurnEnable.checked + + textField: CurrentAccount.password_TURN + itemWidth: root.itemWidth titleField: JamiStrings.turnPassword - onEditFinished: SettingsAdapter.setTURNPassword(textField) + + onEditFinished: CurrentAccount.password_TURN = textField } SettingsMaterialLineEdit { @@ -162,9 +172,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxTurnEnable.checked + + textField: CurrentAccount.realm_TURN + itemWidth: root.itemWidth titleField: JamiStrings.turnRealm - onEditFinished: SettingsAdapter.setTURNRealm(textField) + + onEditFinished: CurrentAccount.realm_TURN = textField } ToggleSwitch { @@ -175,10 +191,9 @@ ColumnLayout { labelText: JamiStrings.useSTUN fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseSTUN(checked) - lineEditSTUNAddress.enabled = checked - } + checked: CurrentAccount.enable_STUN + + onSwitchToggled: CurrentAccount.enable_STUN = checked } SettingsMaterialLineEdit { @@ -186,9 +201,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxSTUNEnable.checked + + textField: CurrentAccount.server_STUN + itemWidth: root.itemWidth titleField: JamiStrings.stunAdress - onEditFinished: SettingsAdapter.setSTUNAddress(textField) + + onEditFinished: CurrentAccount.server_STUN = textField } } } diff --git a/src/settingsview/components/AdvancedJamiSecuritySettings.qml b/src/settingsview/components/AdvancedJamiSecuritySettings.qml index 049f6c6bd..4e68c9457 100644 --- a/src/settingsview/components/AdvancedJamiSecuritySettings.qml +++ b/src/settingsview/components/AdvancedJamiSecuritySettings.qml @@ -30,90 +30,58 @@ ColumnLayout { property int itemWidth - function updateSecurityAccountInfos() { - btnCACert.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) - btnCACert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - btnUserCert.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile()) - btnUserCert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - btnPrivateKey.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) - btnPrivateKey.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - } - - function changeFileCACert(url){ - if(url.length !== 0) { - SettingsAdapter.set_FileCACert(url) - btnCACert.textField = UtilsAdapter.toFileInfoName(url) - } - } - - function changeFileUserCert(url){ - if(url.length !== 0) { - SettingsAdapter.set_FileUserCert(url) - btnUserCert.textField = UtilsAdapter.toFileInfoName(url) - } - } - - function changeFilePrivateKey(url){ - if(url.length !== 0) { - SettingsAdapter.set_FilePrivateKey(url) - btnPrivateKey.textField = UtilsAdapter.toFileInfoName(url) - } - } - JamiFileDialog { id: caCert_Dialog - property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateListFile() - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.certificateListFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectCACert folder: openPath - nameFilters: [qsTr("Certificate File") + " (*.crt)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Certificate File") + " (*.crt)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFileCACert(url) - } + onAccepted: CurrentAccount.certificateListFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } JamiFileDialog { id: userCert_Dialog - property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateFile() - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.certificateFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectUserCert folder: openPath - nameFilters: [qsTr("Certificate File") + " (*.crt)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Certificate File") + " (*.crt)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFileUserCert(url) - } + onAccepted: CurrentAccount.certificateFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } JamiFileDialog { id: privateKey_Dialog - property string oldPath : { - return SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() - } - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.privateKeyFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectPrivateKey folder: openPath - nameFilters: [qsTr("Key File") + " (*.key)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Key File") + " (*.key)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFilePrivateKey(url) - } + onAccepted: CurrentAccount.privateKeyFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } ElidedTextLabel { @@ -131,34 +99,46 @@ ColumnLayout { SettingMaterialButton { id: btnCACert + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + textField: UtilsAdapter.toFileInfoName(CurrentAccount.certificateListFile_TLS) titleField: JamiStrings.caCertificate source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + onClick: caCert_Dialog.open() } SettingMaterialButton { id: btnUserCert + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + textField: UtilsAdapter.toFileInfoName(CurrentAccount.certificateFile_TLS) titleField: JamiStrings.userCertificate source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + onClick: userCert_Dialog.open() } SettingMaterialButton { id: btnPrivateKey + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + textField: UtilsAdapter.toFileInfoName(CurrentAccount.privateKeyFile_TLS) titleField: JamiStrings.privateKey source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + onClick: privateKey_Dialog.open() } @@ -167,8 +147,13 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + itemWidth: root.itemWidth titleField: JamiStrings.privateKeyPassword + + textField: CurrentAccount.password_TLS + + onEditFinished: CurrentAccount.password_TLS = textField } } } diff --git a/src/settingsview/components/AdvancedMediaSettings.qml b/src/settingsview/components/AdvancedMediaSettings.qml index 9833a6aa1..cc2e01e67 100644 --- a/src/settingsview/components/AdvancedMediaSettings.qml +++ b/src/settingsview/components/AdvancedMediaSettings.qml @@ -29,12 +29,6 @@ import "../../commoncomponents" ColumnLayout { id: root - function updateMediaConnectivityAccountInfos() { - videoCheckBox.checked = SettingsAdapter.getAccountConfig_Video_Enabled() - videoSettings.updateCodecs(); - audioSettings.updateCodecs(); - } - Label { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight @@ -58,7 +52,9 @@ ColumnLayout { labelText: JamiStrings.enableVideo fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.setVideoState(checked) + checked: CurrentAccount.videoEnabled_Video + + onSwitchToggled: CurrentAccount.videoEnabled_Video = checked } RowLayout { diff --git a/src/settingsview/components/AdvancedNameServerSettings.qml b/src/settingsview/components/AdvancedNameServerSettings.qml index 02fbfe2fd..0843ba31a 100644 --- a/src/settingsview/components/AdvancedNameServerSettings.qml +++ b/src/settingsview/components/AdvancedNameServerSettings.qml @@ -30,10 +30,6 @@ ColumnLayout { property int itemWidth - function updateNameServerInfos() { - lineEditNameServer.textField = SettingsAdapter.getAccountConfig_RingNS_Uri() - } - Text { Layout.fillWidth: true Layout.rightMargin: JamiTheme.preferredMarginSize / 2 @@ -55,9 +51,12 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize Layout.preferredHeight: JamiTheme.preferredFieldHeight + itemWidth: root.itemWidth titleField: qsTr("Address") - onEditFinished: SettingsAdapter.setNameServer(textField) + textField: CurrentAccount.uri_RingNS + + onEditFinished: CurrentAccount.uri_RingNS = textField } } diff --git a/src/settingsview/components/AdvancedOpenDHTSettings.qml b/src/settingsview/components/AdvancedOpenDHTSettings.qml index 561896df6..f8b076185 100644 --- a/src/settingsview/components/AdvancedOpenDHTSettings.qml +++ b/src/settingsview/components/AdvancedOpenDHTSettings.qml @@ -30,13 +30,6 @@ ColumnLayout { property int itemWidth - function updateOpenDHTSettingsInfos() { - checkAutoConnectOnLocalNetwork.checked = SettingsAdapter.getAccountConfig_PeerDiscovery() - checkBoxEnableProxy.checked = SettingsAdapter.getAccountConfig_ProxyEnabled() - lineEditProxy.textField = SettingsAdapter.getAccountConfig_ProxyServer() - lineEditBootstrap.textField = SettingsAdapter.getAccountConfig_Hostname() - } - Text { Layout.fillWidth: true Layout.rightMargin: JamiTheme.preferredMarginSize / 2 @@ -65,9 +58,9 @@ ColumnLayout { tooltipText: JamiStrings.tooltipPeerDiscovery fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setAutoConnectOnLocalNetwork(checked) - } + checked: CurrentAccount.peerDiscovery + + onSwitchToggled: CurrentAccount.peerDiscovery = checked } ToggleSwitch { @@ -76,10 +69,9 @@ ColumnLayout { labelText: JamiStrings.enableProxy fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setEnableProxy(checked) - lineEditProxy.enabled = checked - } + checked: CurrentAccount.proxyEnabled + + onSwitchToggled: CurrentAccount.proxyEnabled = checked } SettingsMaterialLineEdit { @@ -87,10 +79,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: checkBoxEnableProxy.checked + + textField: CurrentAccount.proxyServer + itemWidth: root.itemWidth titleField: JamiStrings.proxyAddress - onEditFinished: SettingsAdapter.setProxyAddress(textField) + onEditFinished: CurrentAccount.proxyServer = textField } SettingsMaterialLineEdit { @@ -98,10 +95,13 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + textField: CurrentAccount.hostname + itemWidth: root.itemWidth titleField: JamiStrings.bootstrap - onEditFinished: SettingsAdapter.setBootstrapAddress(textField) + onEditFinished: CurrentAccount.hostname = textField } } } diff --git a/src/settingsview/components/AdvancedPublicAddressSettings.qml b/src/settingsview/components/AdvancedPublicAddressSettings.qml index c0209878b..552cb8657 100644 --- a/src/settingsview/components/AdvancedPublicAddressSettings.qml +++ b/src/settingsview/components/AdvancedPublicAddressSettings.qml @@ -30,19 +30,6 @@ ColumnLayout { property int itemWidth - function updatePublicAddressAccountInfos() { - checkBoxAllowIPAutoRewrite.checked = SettingsAdapter.getAccountConfig_AllowIPAutoRewrite() - checkBoxCustomAddressPort.checked = !SettingsAdapter.getAccountConfig_PublishedSameAsLocal() - lineEditSIPCustomAddress.textField = SettingsAdapter.getAccountConfig_PublishedAddress() - customPortSIPSpinBox.valueField = SettingsAdapter.getAccountConfig_PublishedPort() - - if (checkBoxAllowIPAutoRewrite.checked) { - checkBoxCustomAddressPort.visible = false - lineEditSIPCustomAddress.visible = false - customPortSIPSpinBox.visible = false - } - } - Text { Layout.fillWidth: true @@ -67,12 +54,9 @@ ColumnLayout { labelText: JamiStrings.allowIPAutoRewrite fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setAllowIPAutoRewrite(checked) - checkBoxCustomAddressPort.visible = !checked - lineEditSIPCustomAddress.visible = !checked - customPortSIPSpinBox.visible = !checked - } + checked: CurrentAccount.allowIPAutoRewrite + + onSwitchToggled: CurrentAccount.allowIPAutoRewrite = checked } ToggleSwitch { @@ -81,11 +65,10 @@ ColumnLayout { labelText: JamiStrings.useCustomAddress fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseCustomAddressAndPort(!checked) - lineEditSIPCustomAddress.enabled = checked - customPortSIPSpinBox.enabled = checked - } + visible: !checkBoxAllowIPAutoRewrite.checked + checked: CurrentAccount.publishedSameAsLocal + + onSwitchToggled: CurrentAccount.publishedSameAsLocal = checked } SettingsMaterialLineEdit { @@ -93,10 +76,16 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + visible: !checkBoxAllowIPAutoRewrite.checked + enabled: checkBoxCustomAddressPort.checked + itemWidth: root.itemWidth titleField: JamiStrings.address - onEditFinished: SettingsAdapter.lineEditSIPCustomAddressLineEditTextChanged(textField) + textField: CurrentAccount.publishedAddress + + onEditFinished: CurrentAccount.publishedAddress = textField } SettingSpinBox { @@ -107,7 +96,17 @@ ColumnLayout { bottomValue: 0 topValue: 65535 - onNewValue: SettingsAdapter.customPortSIPSpinBoxValueChanged(valueField) + visible: !checkBoxAllowIPAutoRewrite.checked + enabled: checkBoxCustomAddressPort.checked + + valueField: CurrentAccount.publishedPort + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.publishedPort }) + } + + onNewValue: CurrentAccount.publishedPort = valueField } } } diff --git a/src/settingsview/components/AdvancedSDPSettings.qml b/src/settingsview/components/AdvancedSDPSettings.qml index ac776617c..59862b54e 100644 --- a/src/settingsview/components/AdvancedSDPSettings.qml +++ b/src/settingsview/components/AdvancedSDPSettings.qml @@ -30,45 +30,6 @@ ColumnLayout { property int itemWidth - function updateSDPAccountInfos(){ - audioRTPMinPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() - audioRTPMaxPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Audio_AudioPortMax() - videoRTPMinPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Video_VideoPortMin() - videoRTPMaxPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Video_VideoPortMax() - } - - function audioRTPMinPortSpinBoxEditFinished(value) { - if (SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) { - audioRTPMinPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() - return - } - SettingsAdapter.audioRTPMinPortSpinBoxEditFinished(value) - } - - function audioRTPMaxPortSpinBoxEditFinished(value) { - if (value <SettingsAdapter.getAccountConfig_Audio_AudioPortMin()) { - audioRTPMaxPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Audio_AudioPortMax() - return - } - SettingsAdapter.audioRTPMaxPortSpinBoxEditFinished(value) - } - - function videoRTPMinPortSpinBoxEditFinished(value) { - if (SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) { - videoRTPMinPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Video_VideoPortMin() - return - } - SettingsAdapter.videoRTPMinPortSpinBoxEditFinished(value) - } - - function videoRTPMaxPortSpinBoxEditFinished(value) { - if (value <SettingsAdapter.getAccountConfig_Video_VideoPortMin()) { - videoRTPMinPortSpinBox.valueField = SettingsAdapter.getAccountConfig_Video_VideoPortMin() - return - } - SettingsAdapter.videoRTPMaxPortSpinBoxEditFinished(value) - } - ElidedTextLabel { Layout.preferredWidth: textWidth Layout.preferredHeight: JamiTheme.preferredFieldHeight @@ -97,9 +58,16 @@ ColumnLayout { title: JamiStrings.audioRTPMinPort itemWidth: root.itemWidth bottomValue: 0 - topValue: 65535 + topValue: audioRTPMaxPortSpinBox.valueField - 1 + + valueField: CurrentAccount.audioPortMin_Audio + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.audioPortMin_Audio }) + } - onNewValue: audioRTPMinPortSpinBoxEditFinished(valueField) + onNewValue: CurrentAccount.audioPortMin_Audio = valueField } SettingSpinBox { @@ -107,10 +75,17 @@ ColumnLayout { title: JamiStrings.audioRTPMaxPort itemWidth: root.itemWidth - bottomValue: 0 + bottomValue: audioRTPMinPortSpinBox.valueField + 1 topValue: 65535 - onNewValue: audioRTPMaxPortSpinBoxEditFinished(valueField) + valueField: CurrentAccount.audioPortMax_Audio + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.audioPortMax_Audio }) + } + + onNewValue: CurrentAccount.audioPortMax_Audio = valueField } SettingSpinBox { @@ -119,9 +94,16 @@ ColumnLayout { title: JamiStrings.videoRTPMinPort itemWidth: root.itemWidth bottomValue: 0 - topValue: 65535 + topValue: videoRTPMaxPortSpinBox.valueField - 1 + + valueField: CurrentAccount.videoPortMin_Video + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.videoPortMin_Video }) + } - onNewValue: videoRTPMinPortSpinBoxEditFinished(valueField) + onNewValue: CurrentAccount.videoPortMin_Video = valueField } SettingSpinBox { @@ -129,10 +111,17 @@ ColumnLayout { title: JamiStrings.videoRTPMaxPort itemWidth: root.itemWidth - bottomValue: 0 + bottomValue: videoRTPMinPortSpinBox.valueField + 1 topValue: 65535 - onNewValue: videoRTPMaxPortSpinBoxEditFinished(valueField) + valueField: CurrentAccount.videoPortMax_Video + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.videoPortMax_Video }) + } + + onNewValue: CurrentAccount.videoPortMax_Video = valueField } } } diff --git a/src/settingsview/components/AdvancedSIPSecuritySettings.qml b/src/settingsview/components/AdvancedSIPSecuritySettings.qml index 2c8bbaa75..475253fde 100644 --- a/src/settingsview/components/AdvancedSIPSecuritySettings.qml +++ b/src/settingsview/components/AdvancedSIPSecuritySettings.qml @@ -31,107 +31,58 @@ ColumnLayout { property int itemWidth - function updateSecurityAccountInfos() { - enableSDESToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() - fallbackRTPToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() - btnSIPCACert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - btnSIPUserCert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - btnSIPPrivateKey.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - lineEditSIPCertPassword.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() - - btnSIPCACert.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) - btnSIPUserCert.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile()) - btnSIPPrivateKey.textField = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) - lineEditSIPCertPassword.textField = SettingsAdapter.getAccountConfig_TLS_Password() - - encryptMediaStreamsToggle.checked = SettingsAdapter.getAccountConfig_SRTP_Enabled() - enableSDESToggle.checked = (SettingsAdapter.getAccountConfig_SRTP_KeyExchange() === Account.KeyExchangeProtocol.SDES) - fallbackRTPToggle.checked = SettingsAdapter.getAccountConfig_SRTP_RtpFallback() - encryptNegotitationToggle.checked = SettingsAdapter.getAccountConfig_TLS_Enable() - verifyIncomingCertificatesServerToggle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyServer() - verifyIncomingCertificatesClientToggle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyClient() - requireCeritificateForTLSIncomingToggle.checked = SettingsAdapter.getAccountConfig_TLS_RequireClientCertificate() - - var method = SettingsAdapter.getAccountConfig_TLS_Method_inInt() - tlsProtocolComboBox.setCurrentIndex(method) - - outgoingTLSServerNameLineEdit.textField = SettingsAdapter.getAccountConfig_TLS_Servername() - negotiationTimeoutSpinBox.valueField = SettingsAdapter.getAccountConfig_TLS_NegotiationTimeoutSec() - } - - function changeFileCACert(url){ - if(url.length !== 0) { - SettingsAdapter.set_FileCACert(url) - btnSIPCACert.textField = UtilsAdapter.toFileInfoName(url) - } - } - - function changeFileUserCert(url){ - if(url.length !== 0) { - SettingsAdapter.set_FileUserCert(url) - btnSIPUserCert.textField = UtilsAdapter.toFileInfoName(url) - } - } - - function changeFilePrivateKey(url){ - if(url.length !== 0) { - SettingsAdapter.set_FilePrivateKey(url) - btnSIPPrivateKey.textField = UtilsAdapter.toFileInfoName(url) - } - } - JamiFileDialog { id: caCert_Dialog_SIP - property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateListFile() - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.certificateListFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectCACert folder: openPath - nameFilters: [qsTr("Certificate File") + " (*.crt)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Certificate File") + " (*.crt)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFileCACert(url) - } + onAccepted: CurrentAccount.certificateListFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } JamiFileDialog { id: userCert_Dialog_SIP - property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateFile() - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.certificateFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectUserCert folder: openPath - nameFilters: [qsTr("Certificate File") + " (*.crt)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Certificate File") + " (*.crt)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFileUserCert(url) - } + onAccepted: CurrentAccount.certificateFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } JamiFileDialog { id: privateKey_Dialog_SIP - property string oldPath : SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() - property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) + property string oldPath: CurrentAccount.privateKeyFile_TLS + property string openPath: oldPath === "" ? + (UtilsAdapter.getCurrentPath() + "/ringtones/") : + (UtilsAdapter.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile title: JamiStrings.selectPrivateKey folder: openPath - nameFilters: [qsTr("Key File") + " (*.key)", qsTr( - "All files") + " (*)"] + nameFilters: [qsTr("Key File") + " (*.key)", + qsTr("All files") + " (*)"] - onAccepted: { - var url = UtilsAdapter.getAbsPath(file.toString()) - changeFilePrivateKey(url) - } + onAccepted: CurrentAccount.privateKeyFile_TLS = + UtilsAdapter.getAbsPath(file.toString()) } ElidedTextLabel { @@ -153,33 +104,35 @@ ColumnLayout { labelText: JamiStrings.encryptMediaStream fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseSRTP(checked) - enableSDESToggle.enabled = checked - fallbackRTPToggle.enabled = checked - } + checked: CurrentAccount.enable_SRTP + + onSwitchToggled: CurrentAccount.enable_SRTP = checked } ToggleSwitch { id: enableSDESToggle + enabled: CurrentAccount.enable_SRTP + labelText: JamiStrings.enableSDES fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseSDES(checked) - } + checked: CurrentAccount.keyExchange_SRTP + + onSwitchToggled: CurrentAccount.keyExchange_SRTP = Number(checked) } ToggleSwitch { id: fallbackRTPToggle + enabled: CurrentAccount.enable_SRTP + labelText: JamiStrings.fallbackRTP fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseRTPFallback(checked) - } + checked: CurrentAccount.rtpFallback_SRTP + + onSwitchToggled: CurrentAccount.rtpFallback_SRTP = checked } ToggleSwitch { @@ -188,45 +141,59 @@ ColumnLayout { labelText: JamiStrings.encryptNegotiation fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setUseTLS(checked) - btnSIPCACert.enabled = checked - btnSIPUserCert.enabled = checked - btnSIPPrivateKey.enabled = checked - lineEditSIPCertPassword.enabled = checked - } + checked: CurrentAccount.enable_TLS + + onSwitchToggled: CurrentAccount.enable_TLS = checked } SettingMaterialButton { id: btnSIPCACert + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + titleField: JamiStrings.caCertificate source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + + textField: UtilsAdapter.toFileInfoName(CurrentAccount.certificateListFile_TLS) + onClick: caCert_Dialog_SIP.open() } SettingMaterialButton { id: btnSIPUserCert + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + titleField: JamiStrings.userCertificate source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + + textField: UtilsAdapter.toFileInfoName(CurrentAccount.certificateFile_TLS) + onClick: userCert_Dialog_SIP.open() } SettingMaterialButton { id: btnSIPPrivateKey + Layout.fillWidth: true Layout.minimumHeight: JamiTheme.preferredFieldHeight + enabled: CurrentAccount.enable_TLS + titleField: JamiStrings.privateKey source: JamiResources.round_folder_24dp_svg itemWidth: root.itemWidth + + textField: UtilsAdapter.toFileInfoName(CurrentAccount.privateKeyFile_TLS) + onClick: privateKey_Dialog_SIP.open() } @@ -236,10 +203,15 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + + enabled: CurrentAccount.enable_TLS + itemWidth: root.itemWidth titleField: JamiStrings.privateKeyPassword - onEditFinished: SettingsAdapter.lineEditSIPCertPasswordLineEditTextChanged(textField) + textField: CurrentAccount.password_TLS + + onEditFinished: CurrentAccount.password_TLS = textField } ToggleSwitch { @@ -248,9 +220,9 @@ ColumnLayout { labelText: JamiStrings.verifyCertificatesServer fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setVerifyCertificatesServer(checked) - } + checked: CurrentAccount.verifyServer_TLS + + onSwitchToggled: CurrentAccount.verifyServer_TLS = checked } ToggleSwitch { @@ -259,9 +231,9 @@ ColumnLayout { labelText: JamiStrings.verifyCertificatesClient fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setVerifyCertificatesClient(checked) - } + checked: CurrentAccount.verifyClient_TLS + + onSwitchToggled: CurrentAccount.verifyClient_TLS = checked } ToggleSwitch { @@ -270,9 +242,9 @@ ColumnLayout { labelText: JamiStrings.tlsRequireConnections fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: { - SettingsAdapter.setRequireCertificatesIncomingTLS(checked) - } + checked: CurrentAccount.requireClientCertificate_TLS + + onSwitchToggled: CurrentAccount.requireClientCertificate_TLS = checked } SettingsComboBox { @@ -293,10 +265,10 @@ ColumnLayout { tipText: JamiStrings.audioDeviceSelector role: "textDisplay" - onIndexChanged: { - var indexOfOption = comboModel.get(modelIndex).secondArg - SettingsAdapter.tlsProtocolComboBoxIndexChanged(parseInt(indexOfOption)) - } + modelIndex: CurrentAccount.method_TLS + + onModelIndexChanged: CurrentAccount.method_TLS = + parseInt(comboModel.get(modelIndex).secondArg) } SettingsMaterialLineEdit { @@ -307,7 +279,9 @@ ColumnLayout { itemWidth: root.itemWidth titleField: JamiStrings.tlsServerName - onEditFinished: SettingsAdapter.outgoingTLSServerNameLineEditTextChanged(textField) + textField: CurrentAccount.serverName_TLS + + onEditFinished: CurrentAccount.serverName_TLS = textField } SettingSpinBox { @@ -319,7 +293,14 @@ ColumnLayout { bottomValue: 0 topValue: 3000 - onNewValue: SettingsAdapter.negotiationTimeoutSpinBoxValueChanged(valueField) + valueField: CurrentAccount.negotiationTimeoutSec_TLS + + onInputAcceptableChanged: { + if (!inputAcceptable && valueField.length !== 0) + valueField = Qt.binding(function() { return CurrentAccount.negotiationTimeoutSec_TLS }) + } + + onNewValue: CurrentAccount.negotiationTimeoutSec_TLS = valueField } } } diff --git a/src/settingsview/components/AdvancedSettings.qml b/src/settingsview/components/AdvancedSettings.qml index 82b06109b..980979f22 100644 --- a/src/settingsview/components/AdvancedSettings.qml +++ b/src/settingsview/components/AdvancedSettings.qml @@ -33,20 +33,6 @@ ColumnLayout { property alias settingsVisible: advancedSettingsView.visible signal showAdvancedSettingsRequest - function updateAdvancedAccountInfos() { - advancedCallSettings.updateCallSettingsInfos() - advancedChatSettings.updateSettings() - advancedVoiceMailSettings.updateVoiceMailSettingsInfos() - advancedSIPSecuritySettings.updateSecurityAccountInfos() - advancedNameServerSettings.updateNameServerInfos() - advancedOpenDHTSettings.updateOpenDHTSettingsInfos() - advancedJamiSecuritySettings.updateSecurityAccountInfos() - advancedConnectivitySettings.updateConnectivityAccountInfos() - advancedPublicAddressSettings.updatePublicAddressAccountInfos() - advancedMediaSettings.updateMediaConnectivityAccountInfos() - advancedSDPStettings.updateSDPAccountInfos() - } - RowLayout { id: rowAdvancedSettingsBtn Layout.fillWidth: true @@ -82,8 +68,6 @@ ColumnLayout { onClicked: { advancedSettingsView.visible = !advancedSettingsView.visible - if(advancedSettingsView.visible) - updateAdvancedAccountInfos() showAdvancedSettingsRequest() } } diff --git a/src/settingsview/components/AdvancedVoiceMailSettings.qml b/src/settingsview/components/AdvancedVoiceMailSettings.qml index 293cd2cb3..b01269878 100644 --- a/src/settingsview/components/AdvancedVoiceMailSettings.qml +++ b/src/settingsview/components/AdvancedVoiceMailSettings.qml @@ -31,10 +31,6 @@ ColumnLayout { property int itemWidth - function updateVoiceMailSettingsInfos() { - lineEditVoiceMailDialCode.textField = SettingsAdapter.getAccountConfig_Mailbox() - } - ElidedTextLabel { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight @@ -50,9 +46,12 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize Layout.preferredHeight: JamiTheme.preferredFieldHeight + itemWidth: root.itemWidth titleField: JamiStrings.voiceMailDialCode - onEditFinished: SettingsAdapter.lineEditVoiceMailDialCodeEditFinished(textField) + textField: CurrentAccount.mailbox + + onEditFinished: CurrentAccount.mailbox = textField } } diff --git a/src/settingsview/components/AudioSettings.qml b/src/settingsview/components/AudioSettings.qml index e84a12135..da1d57a9c 100644 --- a/src/settingsview/components/AudioSettings.qml +++ b/src/settingsview/components/AudioSettings.qml @@ -39,13 +39,14 @@ ColumnLayout { } function populateAudioSettings() { - inputComboBoxSetting.setCurrentIndex(inputComboBoxSetting.comboModel.getCurrentIndex()) - outputComboBoxSetting.setCurrentIndex(outputComboBoxSetting.comboModel.getCurrentIndex()) - ringtoneComboBoxSetting.setCurrentIndex(outputComboBoxSetting.comboModel.getCurrentIndex()) + inputComboBoxSetting.modelIndex = inputComboBoxSetting.comboModel.getCurrentIndex() + outputComboBoxSetting.modelIndex = outputComboBoxSetting.comboModel.getCurrentIndex() + ringtoneComboBoxSetting.modelIndex = outputComboBoxSetting.comboModel.getCurrentIndex() if(audioManagerComboBoxSetting.comboModel.rowCount() > 0) { - audioManagerComboBoxSetting.setCurrentIndex(audioManagerComboBoxSetting.comboModel.getCurrentSettingIndex()) + audioManagerComboBoxSetting.modelIndex = + audioManagerComboBoxSetting.comboModel.getCurrentSettingIndex() } - audioManagerComboBoxSetting.visible = (audioManagerComboBoxSetting.comboModel.rowCount() > 0) + audioManagerComboBoxSetting.visible = audioManagerComboBoxSetting.comboModel.rowCount() > 0 } ElidedTextLabel { @@ -74,7 +75,7 @@ ColumnLayout { tipText: JamiStrings.selectAudioInputDevice role: "DeviceName" - onIndexChanged: { + onModelIndexChanged: { AvAdapter.stopAudioMeter() AVModel.setInputDevice(comboModel.data( comboModel.index(modelIndex, 0), @@ -113,7 +114,7 @@ ColumnLayout { tipText: JamiStrings.selectAudioOutputDevice role: "DeviceName" - onIndexChanged: { + onModelIndexChanged: { AvAdapter.stopAudioMeter() AVModel.setOutputDevice(comboModel.data( comboModel.index(modelIndex, 0), @@ -139,7 +140,7 @@ ColumnLayout { tipText: JamiStrings.selectRingtoneOutputDevice role: "DeviceName" - onIndexChanged: { + onModelIndexChanged: { AvAdapter.stopAudioMeter() AVModel.setRingtoneDevice(comboModel.data( comboModel.index(modelIndex, 0), @@ -163,7 +164,7 @@ ColumnLayout { widthOfComboBox: itemWidth role: "ID_UTF8" - onIndexChanged: { + onModelIndexChanged: { AvAdapter.stopAudioMeter() var selectedAudioManager = comboModel.data( comboModel.index(modelIndex, 0), AudioManagerListModel.AudioManagerID) diff --git a/src/settingsview/components/BannedContacts.qml b/src/settingsview/components/BannedContacts.qml index c220a38de..405b0ad89 100644 --- a/src/settingsview/components/BannedContacts.qml +++ b/src/settingsview/components/BannedContacts.qml @@ -33,7 +33,7 @@ ColumnLayout { visible: { if (bannedListWidget.model.rowCount() <= 0) return false - return true && !isSIP && SettingsAdapter.getAccountConfig_Manageruri() === "" + return true && !isSIP && CurrentAccount.managerUri === "" } Connections { @@ -68,10 +68,6 @@ ColumnLayout { } } - function unban(index) { - SettingsAdapter.unbanContact(index) - } - RowLayout { id: bannedContactsBtn @@ -127,7 +123,7 @@ ColumnLayout { btnToolTip: JamiStrings.reinstateContact onClicked: bannedListWidget.currentIndex = index - onBtnContactClicked: unban(index) + onBtnContactClicked: MessagesAdapter.unbanContact(index) } } } diff --git a/src/settingsview/components/ChatviewSettings.qml b/src/settingsview/components/ChatviewSettings.qml index 6876930b7..344bb4c5d 100644 --- a/src/settingsview/components/ChatviewSettings.qml +++ b/src/settingsview/components/ChatviewSettings.qml @@ -50,14 +50,14 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.EnableTypingIndicator) + checked: UtilsAdapter.getAppValue(Settings.EnableTypingIndicator) labelText: JamiStrings.enableTypingIndicator fontPointSize: JamiTheme.settingsFontSize tooltipText: JamiStrings.enableTypingIndicator - onSwitchToggled: SettingsAdapter.setAppValue(Settings.Key.EnableTypingIndicator, checked) + onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.EnableTypingIndicator, checked) } ToggleSwitch { @@ -66,7 +66,7 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews) + checked: UtilsAdapter.getAppValue(Settings.DisplayHyperlinkPreviews) labelText: JamiStrings.displayHyperlinkPreviews fontPointSize: JamiTheme.settingsFontSize @@ -74,7 +74,7 @@ ColumnLayout { tooltipText: JamiStrings.displayHyperlinkPreviews onSwitchToggled: { - SettingsAdapter.setAppValue(Settings.Key.DisplayHyperlinkPreviews, checked) + UtilsAdapter.setAppValue(Settings.Key.DisplayHyperlinkPreviews, checked) MessagesAdapter.setDisplayLinks() } } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index bb73b7474..d1189acb1 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -41,14 +41,7 @@ Rectangle { signal advancedSettingsToggled(bool settingsVisible) function updateAccountInfoDisplayed() { - accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() - accountProfile.updateAccountInfo() - userIdentity.updateAccountInfo() bannedContacts.updateAndShowBannedContactsSlot() - advancedSettings.updateAdvancedAccountInfos() - var isJams = !isSIP && SettingsAdapter.getAccountConfig_Manageruri() !== "" - passwdPushButton.visible = !isJams - btnExportAccount.visible = !isJams setPasswordButtonText() } @@ -65,7 +58,7 @@ Rectangle { } function delAccountSlot() { - deleteAccountDialog.openDialog() + deleteAccountDialog.open() } function getAdvancedSettingsScrollPosition() { @@ -176,8 +169,9 @@ Rectangle { labelText: JamiStrings.enableAccount fontPointSize: JamiTheme.headerFontSize - onSwitchToggled: AccountAdapter.model.setAccountEnabled( - LRCInstance.currentAccountId, checked) + checked: CurrentAccount.enabled + + onSwitchToggled: CurrentAccount.enabled = checked } AccountProfile { @@ -204,7 +198,7 @@ Rectangle { MaterialButton { id: passwdPushButton - visible: !isSIP && SettingsAdapter.getAccountConfig_Manageruri() === "" + visible: !isSIP && CurrentAccount.managerUri === "" Layout.alignment: Qt.AlignHCenter Layout.topMargin: JamiTheme.preferredMarginSize @@ -231,7 +225,7 @@ Rectangle { MaterialButton { id: btnExportAccount - visible: !isSIP && SettingsAdapter.getAccountConfig_Manageruri() === "" + visible: !isSIP && CurrentAccount.managerUri === "" Layout.alignment: Qt.AlignHCenter preferredWidth: JamiTheme.preferredFieldWidth diff --git a/src/settingsview/components/DeviceItemDelegate.qml b/src/settingsview/components/DeviceItemDelegate.qml index fcb1337ff..b209c4fd2 100644 --- a/src/settingsview/components/DeviceItemDelegate.qml +++ b/src/settingsview/components/DeviceItemDelegate.qml @@ -90,7 +90,7 @@ ItemDelegate { backgroundColor: JamiTheme.editBackgroundColor onEditingFinished: { - SettingsAdapter.setDeviceName(editDeviceName.text) + AvAdapter.setDeviceName(editDeviceName.text) editable = !editable } onReadOnlyChanged: { diff --git a/src/settingsview/components/FileTransferSettings.qml b/src/settingsview/components/FileTransferSettings.qml index b1e4cceac..31b015ba3 100644 --- a/src/settingsview/components/FileTransferSettings.qml +++ b/src/settingsview/components/FileTransferSettings.qml @@ -29,12 +29,6 @@ ColumnLayout { property int itemWidth - function updateValues() { - acceptTransferBelowSpinBox.valueField = SettingsAdapter.getAppValue(Settings.AcceptTransferBelow) - allowFromUntrustedCheckbox.checked = SettingsAdapter.getAppValue(Settings.AllowFromUntrusted) - autoAcceptFilesCheckbox.checked = SettingsAdapter.getAppValue(Settings.AutoAcceptFiles) - } - Label { Layout.fillWidth: true @@ -52,14 +46,14 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.AllowFromUntrusted) + checked: CurrentAccount.autoTransferFromUntrusted labelText: JamiStrings.allowFromUntrusted fontPointSize: JamiTheme.settingsFontSize tooltipText: JamiStrings.allowFromUntrusted - onSwitchToggled: SettingsAdapter.allowFromUntrusted(checked) + onSwitchToggled: CurrentAccount.autoTransferFromUntrusted = checked } ToggleSwitch { @@ -67,14 +61,14 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.AutoAcceptFiles) + checked: CurrentAccount.autoTransferFromTrusted labelText: JamiStrings.autoAcceptFiles fontPointSize: JamiTheme.settingsFontSize tooltipText: JamiStrings.autoAcceptFiles - onSwitchToggled: SettingsAdapter.autoAcceptFiles(checked) + onSwitchToggled: CurrentAccount.autoTransferFromTrusted = checked } SettingSpinBox { @@ -86,8 +80,10 @@ ColumnLayout { tooltipText: JamiStrings.acceptTransferTooltip itemWidth: root.itemWidth bottomValue: 0 - topValue: 99999999 + topValue: Number.MAX_VALUE + + valueField: CurrentAccount.autoTransferSizeThreshold - onNewValue: SettingsAdapter.acceptTransferBelow(valueField) + onNewValue: CurrentAccount.autoTransferSizeThreshold = valueField } } diff --git a/src/settingsview/components/GeneralSettingsPage.qml b/src/settingsview/components/GeneralSettingsPage.qml index 4bb3a005f..0b913dc49 100644 --- a/src/settingsview/components/GeneralSettingsPage.qml +++ b/src/settingsview/components/GeneralSettingsPage.qml @@ -35,10 +35,6 @@ Rectangle { color: JamiTheme.secondaryBackgroundColor - function updateValues() { - fileTransferSettings.updateValues() - } - ColumnLayout { id: generalSettingsColumnLayout diff --git a/src/settingsview/components/JamiUserIdentity.qml b/src/settingsview/components/JamiUserIdentity.qml index 3adcc21ec..29f2b05df 100644 --- a/src/settingsview/components/JamiUserIdentity.qml +++ b/src/settingsview/components/JamiUserIdentity.qml @@ -30,27 +30,12 @@ ColumnLayout { id: root property int itemWidth - property bool registeredIdNeedsSet: false - - function updateAccountInfo() { - currentRingIDText.text = SettingsAdapter.getCurrentAccount_Profile_Info_Uri() - registeredIdNeedsSet = (SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "") - - if(!registeredIdNeedsSet) { - currentRegisteredID.text = SettingsAdapter.get_CurrentAccountInfo_RegisteredName() - } else { - currentRegisteredID.text = "" - } - } NameRegistrationDialog { id : nameRegistrationDialog - onAccepted: { - registeredIdNeedsSet = false - currentRegisteredID.nameRegistrationState = + onAccepted: currentRegisteredID.nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK - } } // Identity @@ -106,7 +91,7 @@ ColumnLayout { elideWidth: root.width - idLabel.width - JamiTheme.preferredMarginSize * 4 - text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() + text: CurrentAccount.uri } } } @@ -145,21 +130,15 @@ ColumnLayout { } padding: 8 - horizontalAlignment: registeredIdNeedsSet ? - Text.AlignLeft : - Text.AlignRight + horizontalAlignment: CurrentAccount.registeredName === "" ? Text.AlignLeft : + Text.AlignRight verticalAlignment: Text.AlignVCenter wrapMode: Text.NoWrap - placeholderText: registeredIdNeedsSet ? - JamiStrings.registerAUsername : "" - text: { - if (!registeredIdNeedsSet) - return SettingsAdapter.get_CurrentAccountInfo_RegisteredName() - else - return "" - } - readOnly: !registeredIdNeedsSet - font.bold: !registeredIdNeedsSet + placeholderText: CurrentAccount.registeredName === "" ? + JamiStrings.registerAUsername : "" + text: CurrentAccount.registeredName + readOnly: CurrentAccount.registeredName !== "" + font.bold: CurrentAccount.registeredName !== "" loseFocusWhenEnterPressed: btnRegisterName.visible onAccepted: { @@ -178,9 +157,9 @@ ColumnLayout { preferredWidth: 120 preferredHeight: 30 - visible: registeredIdNeedsSet && - currentRegisteredID.nameRegistrationState === - UsernameLineEdit.NameRegistrationState.FREE + visible: CurrentAccount.registeredName === "" && + currentRegisteredID.nameRegistrationState === + UsernameLineEdit.NameRegistrationState.FREE text: JamiStrings.register toolTipText: JamiStrings.registerUsername diff --git a/src/settingsview/components/LinkedDevices.qml b/src/settingsview/components/LinkedDevices.qml index f1b9f2c18..f091f467b 100644 --- a/src/settingsview/components/LinkedDevices.qml +++ b/src/settingsview/components/LinkedDevices.qml @@ -30,19 +30,6 @@ import "../../commoncomponents" ColumnLayout { id:root - Connections { - id: accountConnections - - target: AccountAdapter - enabled: root.visible - - function onAccountStatusChanged(id) { - if (SettingsAdapter.getAccountConfig_Manageruri() === ""){ - linkDevPushButton.visible = SettingsAdapter.get_CurrentAccountInfo_Enabled() - } - } - } - function removeDeviceSlot(index){ var idOfDevice = settingsListView.model.data(settingsListView.model.index(index,0), DeviceItemListModel.DeviceID) @@ -122,6 +109,8 @@ ColumnLayout { preferredWidth: JamiTheme.preferredFieldWidth + visible: CurrentAccount.managerUri === "" && CurrentAccount.enabled + color: JamiTheme.buttonTintedBlack hoveredColor: JamiTheme.buttonTintedBlackHovered pressedColor: JamiTheme.buttonTintedBlackPressed diff --git a/src/settingsview/components/LogsView.qml b/src/settingsview/components/LogsView.qml index 7cdbce347..bd28ef848 100644 --- a/src/settingsview/components/LogsView.qml +++ b/src/settingsview/components/LogsView.qml @@ -43,38 +43,41 @@ Dialog { property var lineSize: [] property var lineCounter: 0 - function monitor(continuous) { - SettingsAdapter.monitor(continuous) + UtilsAdapter.monitor(continuous) } - Connections{ - target: SettingsAdapter + Connections { + target: UtilsAdapter + function onDebugMessageReceived(message) { if (!root.visible) { - return; + return } var initialPosition = scrollView.ScrollBar.vertical.position lineCounter += 1 lineSize.push(message.length) if (!root.cancelPressed) { - logsText.append(message); + logsText.append(message) } - if (lineCounter >= 10000){ + if (lineCounter >= 10000) { lineCounter -= 1 logsText.remove(0, lineSize[0]) lineSize.shift() } - scrollView.ScrollBar.vertical.position = initialPosition > (.8*(1.0 - scrollView.ScrollBar.vertical.size)) ? 1.0 - scrollView.ScrollBar.vertical.size : initialPosition + scrollView.ScrollBar.vertical.position = initialPosition + > (.8 * (1.0 - scrollView.ScrollBar.vertical.size)) ? + 1.0 - scrollView.ScrollBar.vertical.size : initialPosition } } onVisibleChanged: { if (visible && startStopToggle.checked) { if (hasOpened && lineCounter == 0) { - logsText.append(SettingsAdapter.getLogs()) - lineCounter = SettingsAdapter.getSizeOfLogs() - lineSize.push(SettingsAdapter.getFirstLogLength()) + var logList = UtilsAdapter.logList + logsText.append(logList.join('\n')) + lineCounter = logList.length + lineSize.push(lineCounter ? logList[0].length : 0) } } else { logsText.clear() @@ -111,12 +114,12 @@ Dialog { border.color: color border.width: 0 - height: JamiTheme.preferredFieldHeight*2 + height: JamiTheme.preferredFieldHeight * 2 RowLayout { id: buttons - Layout.alignment: Qt.AlignTop| Qt.AlignHCenter + Layout.alignment: Qt.AlignTop | Qt.AlignHCenter anchors.centerIn: parent ToggleSwitch { @@ -132,7 +135,7 @@ Dialog { onSwitchToggled: { logging = !logging - if (logging){ + if (logging) { isStopped = false root.cancelPressed = false monitor(true) @@ -165,7 +168,7 @@ Dialog { logging = false startStopToggle.checked = false root.cancelPressed = true - SettingsAdapter.clearLogs() + UtilsAdapter.logList = [] monitor(false) } } @@ -185,7 +188,7 @@ Dialog { outlined: true text: JamiStrings.logsViewCopy - onClicked:{ + onClicked: { logsText.selectAll() logsText.copy() logsText.deselect() @@ -196,11 +199,11 @@ Dialog { id: copiedToolTip height: JamiTheme.preferredFieldHeight - TextArea{ + TextArea { text: JamiStrings.logsViewCopied color: JamiTheme.textColor } - background: Rectangle{ + background: Rectangle { color: JamiTheme.primaryBackgroundColor } } @@ -223,7 +226,8 @@ Dialog { text: JamiStrings.logsViewReport outlined: true - onClicked: Qt.openUrlExternally("https://jami.net/bugs-and-improvements/") + onClicked: Qt.openUrlExternally( + "https://jami.net/bugs-and-improvements/") } } } @@ -236,20 +240,19 @@ Dialog { Layout.fillWidth: true Layout.fillHeight: true - color: JamiTheme.primaryBackgroundColor + color: JamiTheme.primaryBackgroundColor border.color: color border.width: 6 height: root.height - buttonRectangleBackground.height - - ScrollView{ + ScrollView { id: scrollView Layout.fillHeight: true Layout.fillWidth: true anchors.fill: flickableRectangleBackground - TextArea{ + TextArea { id: logsText readOnly: true @@ -286,7 +289,3 @@ Dialog { } } } - - - - diff --git a/src/settingsview/components/MediaSettings.qml b/src/settingsview/components/MediaSettings.qml index 41d338d61..614133db9 100644 --- a/src/settingsview/components/MediaSettings.qml +++ b/src/settingsview/components/MediaSettings.qml @@ -43,10 +43,7 @@ ColumnLayout { var codecId = mediaListWidget.model.data(mediaListWidget.model.index(index,0), MediaCodecListModel.MediaCodecID) - if (mediaType === MediaSettings.VIDEO) - SettingsAdapter.decreaseVideoCodecPriority(codecId) - else if (mediaType === MediaSettings.AUDIO) - SettingsAdapter.decreaseAudioCodecPriority(codecId) + AvAdapter.decreaseCodecPriority(codecId, mediaType === MediaSettings.VIDEO) mediaListWidget.currentIndex = index + 1 updateCodecs() } @@ -66,10 +63,7 @@ ColumnLayout { var codecId = mediaListWidget.model.data(mediaListWidget.model.index(index,0), MediaCodecListModel.MediaCodecID) - if (mediaType === MediaSettings.VIDEO) - SettingsAdapter.increaseVideoCodecPriority(codecId) - else if (mediaType === MediaSettings.AUDIO) - SettingsAdapter.increaseAudioCodecPriority(codecId) + AvAdapter.increaseCodecPriority(codecId, mediaType === MediaSettings.VIDEO) mediaListWidget.currentIndex = index - 1 updateCodecs() } @@ -86,9 +80,9 @@ ColumnLayout { maxWidth: width eText: { if (mediaType === MediaSettings.VIDEO) - return "Video Codecs" + return JamiStrings.videoCodecs else if (mediaType === MediaSettings.AUDIO) - return "Audio Codecs" + return JamiStrings.audioCodecs } fontSize: JamiTheme.settingsFontSize } @@ -134,10 +128,7 @@ ColumnLayout { } onMediaCodecStateChange: { - if (mediaType === MediaSettings.VIDEO) - SettingsAdapter.videoCodecsStateChange(idToSet, isToBeEnabled) - if (mediaType === MediaSettings.AUDIO) - SettingsAdapter.audioCodecsStateChange(idToSet, isToBeEnabled) + AvAdapter.enableCodec(idToSet, isToBeEnabled) updateCodecs() } } diff --git a/src/settingsview/components/RecordingSettings.qml b/src/settingsview/components/RecordingSettings.qml index 81033bb83..e22a6ed9e 100644 --- a/src/settingsview/components/RecordingSettings.qml +++ b/src/settingsview/components/RecordingSettings.qml @@ -31,7 +31,7 @@ ColumnLayout { id:root property int itemWidth - property string recordPath: SettingsAdapter.getDir_Document() + property string recordPath: UtilsAdapter.getDirDocument() onRecordPathChanged: { if(recordPath === "") return diff --git a/src/settingsview/components/SIPUserIdentity.qml b/src/settingsview/components/SIPUserIdentity.qml index 64e74d189..08f0b5540 100644 --- a/src/settingsview/components/SIPUserIdentity.qml +++ b/src/settingsview/components/SIPUserIdentity.qml @@ -30,22 +30,18 @@ ColumnLayout { property int itemWidth - function updateAccountInfo() { - usernameSIP.textField = SettingsAdapter.getAccountConfig_Username() - hostnameSIP.textField = SettingsAdapter.getAccountConfig_Hostname() - passSIPlineEdit.textField = SettingsAdapter.getAccountConfig_Password() - proxySIP.textField = SettingsAdapter.getAccountConfig_RouteSet() - } - SettingsMaterialLineEdit { id: usernameSIP Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + textField: CurrentAccount.username + titleField: JamiStrings.username itemWidth: root.itemWidth - onEditFinished: SettingsAdapter.setAccountConfig_Username(textField) + + onEditFinished: CurrentAccount.username = textField } SettingsMaterialLineEdit { @@ -54,9 +50,12 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + textField: CurrentAccount.hostname + titleField: JamiStrings.server itemWidth: root.itemWidth - onEditFinished: SettingsAdapter.setAccountConfig_Hostname(textField) + + onEditFinished: CurrentAccount.hostname = textField } SettingsMaterialLineEdit { @@ -65,20 +64,27 @@ ColumnLayout { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight + textField: CurrentAccount.routeset + titleField: JamiStrings.proxy itemWidth: root.itemWidth - onEditFinished: SettingsAdapter.setAccountConfig_RouteSet(textField) + + onEditFinished: CurrentAccount.routeset = textField } SettingsMaterialLineEdit { id: passSIPlineEdit + textField: CurrentAccount.password + Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight titleField: JamiStrings.password + itemWidth: root.itemWidth - onEditFinished: SettingsAdapter.setAccountConfig_Password(textField) echoMode: TextInput.Password + + onEditFinished:nCurrentAccount.password = textField } } diff --git a/src/settingsview/components/SettingSpinBox.qml b/src/settingsview/components/SettingSpinBox.qml index b59bee170..eb03538de 100644 --- a/src/settingsview/components/SettingSpinBox.qml +++ b/src/settingsview/components/SettingSpinBox.qml @@ -35,6 +35,7 @@ RowLayout { property alias topValue: textFieldValidator.top property alias valueField: textField.text property alias tooltipText: toolTip.text + property alias inputAcceptable: textField.acceptableInput property string borderColor: JamiTheme.greyBorderColor property int itemWidth diff --git a/src/settingsview/components/SettingsComboBox.qml b/src/settingsview/components/SettingsComboBox.qml index d2cb27fed..1b7752270 100644 --- a/src/settingsview/components/SettingsComboBox.qml +++ b/src/settingsview/components/SettingsComboBox.qml @@ -33,19 +33,10 @@ RowLayout { property alias placeholderText: comboBoxOfLayout.placeholderText property alias enabled: comboBoxOfLayout.enabled property alias fontPointSize: comboBoxOfLayout.font.pointSize + property alias modelIndex: comboBoxOfLayout.currentIndex property int heightOfLayout: 30 property int widthOfComboBox: 50 - property int modelIndex - - signal indexChanged - - function setCurrentIndex(index, emitIndexChanged = false) { - comboBoxOfLayout.currentIndex = index - modelIndex = index - if (emitIndexChanged) - indexChanged() - } ElidedTextLabel { id: label @@ -71,10 +62,5 @@ RowLayout { textRole: role tooltipText: tipText - - onActivated: { - root.modelIndex = index - indexChanged() - } } } diff --git a/src/settingsview/components/SystemSettings.qml b/src/settingsview/components/SystemSettings.qml index 5d22b12d9..038385550 100644 --- a/src/settingsview/components/SystemSettings.qml +++ b/src/settingsview/components/SystemSettings.qml @@ -32,11 +32,11 @@ ColumnLayout { id:root property int itemWidth - property string downloadPath: SettingsAdapter.getDir_Download() + property string downloadPath: UtilsAdapter.getDirDownload() onDownloadPathChanged: { if(downloadPath === "") return - SettingsAdapter.setDownloadPath(downloadPath) + UtilsAdapter.setDownloadPath(downloadPath) } FolderDialog { @@ -68,7 +68,7 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.EnableDarkTheme) + checked: UtilsAdapter.getAppValue(Settings.EnableDarkTheme) labelText: qsTr("Enable dark theme") fontPointSize: JamiTheme.settingsFontSize @@ -77,7 +77,7 @@ ColumnLayout { onSwitchToggled: { JamiTheme.setTheme(checked) - SettingsAdapter.setAppValue(Settings.Key.EnableDarkTheme, checked) + UtilsAdapter.setAppValue(Settings.Key.EnableDarkTheme, checked) } } @@ -86,26 +86,26 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.EnableNotifications) + checked: UtilsAdapter.getAppValue(Settings.EnableNotifications) labelText: qsTr("Enable desktop notifications") fontPointSize: JamiTheme.settingsFontSize tooltipText: JamiStrings.enableNotifications - onSwitchToggled: SettingsAdapter.setAppValue(Settings.Key.EnableNotifications, checked) + onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.EnableNotifications, checked) } ToggleSwitch { id: closeOrMinCheckBox Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.MinimizeOnClose) + checked: UtilsAdapter.getAppValue(Settings.MinimizeOnClose) labelText: JamiStrings.keepMinimized fontPointSize: JamiTheme.settingsFontSize - onSwitchToggled: SettingsAdapter.setAppValue(Settings.Key.MinimizeOnClose, checked) + onSwitchToggled: UtilsAdapter.setAppValue(Settings.Key.MinimizeOnClose, checked) } ToggleSwitch { @@ -120,7 +120,7 @@ ColumnLayout { tooltipText: JamiStrings.tipRunStartup - onSwitchToggled: SettingsAdapter.setRunOnStartUp(checked) + onSwitchToggled: UtilsAdapter.setRunOnStartUp(checked) } RowLayout { diff --git a/src/settingsview/components/TroubleshootSettings.qml b/src/settingsview/components/TroubleshootSettings.qml index 84490839a..a8bec519c 100644 --- a/src/settingsview/components/TroubleshootSettings.qml +++ b/src/settingsview/components/TroubleshootSettings.qml @@ -26,15 +26,16 @@ import net.jami.Constants 1.1 import "../../commoncomponents" -ColumnLayout{ - id:root +ColumnLayout { + id: root + property int itemWidth - LogsView{ + LogsView { id: logsView } - Label{ + Label { Layout.fillWidth: true text: JamiStrings.troubleshootTitle @@ -47,7 +48,9 @@ ColumnLayout{ } RowLayout { - Text{ + Layout.leftMargin: JamiTheme.preferredMarginSize + + Text { Layout.fillWidth: true Layout.preferredHeight: 30 Layout.rightMargin: JamiTheme.preferredMarginSize @@ -81,4 +84,3 @@ ColumnLayout{ } } } - diff --git a/src/settingsview/components/UpdateSettings.qml b/src/settingsview/components/UpdateSettings.qml index 0c440970f..3793783e3 100644 --- a/src/settingsview/components/UpdateSettings.qml +++ b/src/settingsview/components/UpdateSettings.qml @@ -50,14 +50,14 @@ ColumnLayout { Layout.fillWidth: true Layout.leftMargin: JamiTheme.preferredMarginSize - checked: SettingsAdapter.getAppValue(Settings.Key.AutoUpdate) + checked: UtilsAdapter.getAppValue(Settings.Key.AutoUpdate) labelText: JamiStrings.update tooltipText: JamiStrings.enableAutoUpdates fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - SettingsAdapter.setAppValue(Settings.Key.AutoUpdate, checked) + UtilsAdapter.setAppValue(Settings.Key.AutoUpdate, checked) UpdateManager.setAutoUpdateCheck(checked) } } diff --git a/src/settingsview/components/UserIdentity.qml b/src/settingsview/components/UserIdentity.qml index 03688b186..5e573bece 100644 --- a/src/settingsview/components/UserIdentity.qml +++ b/src/settingsview/components/UserIdentity.qml @@ -31,14 +31,6 @@ ColumnLayout { property int itemWidth property bool isSIP - function updateAccountInfo() { - if (!isSIP) { - jamiUserIdentity.updateAccountInfo() - } else { - sipUserIdentity.updateAccountInfo() - } - } - ElidedTextLabel { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight diff --git a/src/settingsview/components/VideoSettings.qml b/src/settingsview/components/VideoSettings.qml index 91966a5c5..7307fb75d 100644 --- a/src/settingsview/components/VideoSettings.qml +++ b/src/settingsview/components/VideoSettings.qml @@ -37,13 +37,19 @@ ColumnLayout { Connections { target: AvAdapter - enabled: root.visible function onVideoDeviceListChanged() { populateVideoSettings() } } + function startPreviewing(force = false) { + if (root.visible) { + AccountAdapter.startPreviewing(force) + previewAvailable = true + } + } + function populateVideoSettings() { deviceComboBoxSetting.comboModel.reset() @@ -55,22 +61,26 @@ ColumnLayout { fpsComboBoxSetting.enabled = count > 0 if (count === 0) { - resolutionComboBoxSetting.comboModel.reset() - fpsComboBoxSetting.comboModel.reset() + resolutionComboBoxSetting.reset() + fpsComboBoxSetting.reset() } else { - deviceComboBoxSetting.setCurrentIndex( - deviceComboBoxSetting.comboModel.getCurrentIndex(), true) + deviceComboBoxSetting.modelIndex = + deviceComboBoxSetting.comboModel.getCurrentIndex() } hardwareAccelControl.checked = AVModel.getHardwareAcceleration() } function slotDeviceBoxCurrentIndexChanged(index) { - if(deviceComboBoxSetting.comboModel.deviceCount() <= 0) + if (deviceComboBoxSetting.comboModel.deviceCount() <= 0) return try { - var deviceId = deviceComboBoxSetting.comboModel.data(deviceComboBoxSetting.comboModel.index(index, 0), VideoInputDeviceModel.DeviceId) - var deviceName = deviceComboBoxSetting.comboModel.data(deviceComboBoxSetting.comboModel.index(index, 0), VideoInputDeviceModel.DeviceName) + var deviceId = deviceComboBoxSetting.comboModel.data( + deviceComboBoxSetting.comboModel.index(index, 0), + VideoInputDeviceModel.DeviceId) + var deviceName = deviceComboBoxSetting.comboModel.data( + deviceComboBoxSetting.comboModel.index(index, 0), + VideoInputDeviceModel.DeviceName) if(deviceId.length === 0) { console.warn("Couldn't find device: " + deviceName) return @@ -81,60 +91,10 @@ ColumnLayout { AVModel.setDefaultDevice(deviceId) } - setFormatListForCurrentDevice() - startPreviewing() + resolutionComboBoxSetting.reset() } catch(err){ console.warn(err.message) } } - function startPreviewing(force = false) { - AccountAdapter.startPreviewing(force) - previewAvailable = true - } - - function setFormatListForCurrentDevice() { - var device = AVModel.getCurrentVideoCaptureDevice() - try { - if (SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0) - return - - resolutionComboBoxSetting.comboModel.reset() - resolutionComboBoxSetting.setCurrentIndex( - resolutionComboBoxSetting.comboModel.getCurrentSettingIndex(), true) - } catch(err) { console.warn("Exception: " + err.message) } - } - - function slotFormatCurrentIndexChanged(index, isResolutionIndex) { - var resolution - var rate - if(isResolutionIndex) { - fpsComboBoxSetting.comboModel.reset() - resolution = resolutionComboBoxSetting.comboModel.data( - resolutionComboBoxSetting.comboModel.index(index, 0), - VideoFormatResolutionModel.Resolution) - fpsComboBoxSetting.comboModel.currentResolution = resolution - fpsComboBoxSetting.setCurrentIndex( - fpsComboBoxSetting.comboModel.getCurrentSettingIndex(), true) - rate = fpsComboBoxSetting.comboModel.data( - fpsComboBoxSetting.comboModel.index(0, 0), - VideoFormatFpsModel.FPS) - } else { - resolution = resolutionComboBoxSetting.comboModel.data( - resolutionComboBoxSetting.comboModel.index( - resolutionComboBoxSetting.modelIndex, 0), - VideoFormatResolutionModel.Resolution) - fpsComboBoxSetting.comboModel.currentResolution = resolution - rate = fpsComboBoxSetting.comboModel.data( - fpsComboBoxSetting.comboModel.index(index, 0), - VideoFormatFpsModel.FPS) - } - - try { - SettingsAdapter.set_Video_Settings_Rate_And_Resolution( - AVModel.getCurrentVideoCaptureDevice(),rate, resolution) - updatePreviewRatio(resolution) - } catch(error){ console.warn(error.message) } - } - function updatePreviewRatio(resolution) { var res = resolution.split("x") var ratio = res[1] / res[0] @@ -145,6 +105,11 @@ ColumnLayout { } } + onVisibleChanged: { + if (visible) + startPreviewing(true) + } + ElidedTextLabel { Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight @@ -170,9 +135,7 @@ ColumnLayout { tipText: JamiStrings.selectVideoDevice role: "DeviceName_UTF8" - onIndexChanged: { - slotDeviceBoxCurrentIndexChanged(modelIndex) - } + onModelIndexChanged: slotDeviceBoxCurrentIndexChanged(modelIndex) placeholderText: JamiStrings.noVideoDevice } @@ -180,6 +143,12 @@ ColumnLayout { SettingsComboBox { id: resolutionComboBoxSetting + function reset() { + modelIndex = -1 + comboModel.reset() + modelIndex = 0 + } + Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.leftMargin: JamiTheme.preferredMarginSize @@ -193,14 +162,34 @@ ColumnLayout { tipText: JamiStrings.selectVideoResolution role: "Resolution_UTF8" - onIndexChanged: { - slotFormatCurrentIndexChanged(modelIndex, true) + modelIndex: -1 + + onModelIndexChanged: { + if (modelIndex === -1) + return + var resolution = comboModel.data(comboModel.index(modelIndex, 0), + VideoFormatResolutionModel.Resolution) + fpsComboBoxSetting.comboModel.currentResolution = resolution + fpsComboBoxSetting.modelIndex = 0 + + var rate = fpsComboBoxSetting.comboModel.data( + fpsComboBoxSetting.comboModel.index(0, 0), + VideoFormatFpsModel.FPS) + + AvAdapter.setCurrentVideoDeviceRateAndResolution(rate, resolution) + updatePreviewRatio(resolution) } } SettingsComboBox { id: fpsComboBoxSetting + function reset() { + modelIndex = -1 + comboModel.reset() + modelIndex = 0 + } + Layout.fillWidth: true Layout.preferredHeight: JamiTheme.preferredFieldHeight Layout.leftMargin: JamiTheme.preferredMarginSize @@ -214,8 +203,20 @@ ColumnLayout { tipText: JamiStrings.selectFPS role: "FPS_ToDisplay_UTF8" - onIndexChanged: { - slotFormatCurrentIndexChanged(modelIndex, false) + modelIndex: -1 + + onModelIndexChanged: { + if (modelIndex === -1) + return + var resolution = resolutionComboBoxSetting.comboModel.data( + resolutionComboBoxSetting.comboModel.index( + resolutionComboBoxSetting.modelIndex, 0), + VideoFormatResolutionModel.Resolution) + + var rate = comboModel.data(comboModel.index(modelIndex, 0), + VideoFormatFpsModel.FPS) + + AvAdapter.setCurrentVideoDeviceRateAndResolution(rate, resolution) } } diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index bdcb20c7a..d90d4a0d5 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -28,15 +28,20 @@ #include "version.h" #include "api/pluginmodel.h" +#include "api/datatransfermodel.h" #include <QApplication> #include <QClipboard> #include <QFileInfo> -UtilsAdapter::UtilsAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* parent) +UtilsAdapter::UtilsAdapter(AppSettingsManager* settingsManager, + SystemTray* systemTray, + LRCInstance* instance, + QObject* parent) : QmlAdapterBase(instance, parent) , clipboard_(QApplication::clipboard()) , systemTray_(systemTray) + , settingsManager_(settingsManager) {} const QString @@ -319,3 +324,78 @@ UtilsAdapter::setSystemTrayIconVisible(bool visible) { systemTray_->setVisible(visible); } + +QVariant +UtilsAdapter::getAppValue(const Settings::Key key) +{ + return settingsManager_->getValue(key); +} + +void +UtilsAdapter::setAppValue(const Settings::Key key, const QVariant& value) +{ + settingsManager_->setValue(key, value); +} + +QString +UtilsAdapter::getDirDocument() +{ + return QDir::toNativeSeparators( + QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); +} + +QString +UtilsAdapter::getDirDownload() +{ + QString downloadPath = QDir::toNativeSeparators(lrcInstance_->accountModel().downloadDirectory); + if (downloadPath.isEmpty()) { + downloadPath = lrc::api::DataTransferModel::createDefaultDirectory(); + setDownloadPath(downloadPath); + lrcInstance_->accountModel().downloadDirectory = downloadPath; + } +#ifdef Q_OS_WIN + int pos = downloadPath.lastIndexOf(QChar('\\')); +#else + int pos = downloadPath.lastIndexOf(QChar('/')); +#endif + if (pos == downloadPath.length() - 1) + downloadPath.truncate(pos); + return downloadPath; +} + +void +UtilsAdapter::setRunOnStartUp(bool state) +{ + if (Utils::CheckStartupLink(L"Jami")) { + if (!state) { + Utils::DeleteStartupLink(L"Jami"); + } + } else if (state) { + Utils::CreateStartupLink(L"Jami"); + } +} + +void +UtilsAdapter::setDownloadPath(QString dir) +{ + setAppValue(Settings::Key::DownloadPath, dir); + lrcInstance_->accountModel().downloadDirectory = dir + "/"; +} + +void +UtilsAdapter::monitor(const bool& continuous) +{ + disconnect(debugMessageReceivedConnection_); + if (continuous) + debugMessageReceivedConnection_ + = QObject::connect(&lrcInstance_->behaviorController(), + &lrc::api::BehaviorController::debugMessageReceived, + [this](const QString& data) { + logList_.append(data); + if (logList_.size() >= LOGSLIMIT) { + logList_.removeFirst(); + } + Q_EMIT debugMessageReceived(data); + }); + lrcInstance_->monitor(continuous); +} \ No newline at end of file diff --git a/src/utilsadapter.h b/src/utilsadapter.h index e80fee7db..2f595bab4 100644 --- a/src/utilsadapter.h +++ b/src/utilsadapter.h @@ -26,15 +26,23 @@ #include <QObject> #include "qmladapterbase.h" +#include "appsettingsmanager.h" +#include "qtutils.h" class QClipboard; class SystemTray; +#define LOGSLIMIT 10000 + class UtilsAdapter final : public QmlAdapterBase { Q_OBJECT + QML_PROPERTY(QStringList, logList) public: - explicit UtilsAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* parent = nullptr); + explicit UtilsAdapter(AppSettingsManager* settingsManager, + SystemTray* systemTray, + LRCInstance* instance, + QObject* parent = nullptr); ~UtilsAdapter() = default; void safeInit() override {} @@ -74,9 +82,22 @@ public: Q_INVOKABLE bool isImage(const QString& fileExt); Q_INVOKABLE QString humanFileSize(qint64 fileSize); Q_INVOKABLE void setSystemTrayIconVisible(bool visible); + Q_INVOKABLE QVariant getAppValue(const Settings::Key key); + Q_INVOKABLE void setAppValue(const Settings::Key key, const QVariant& value); + Q_INVOKABLE QString getDirDocument(); + Q_INVOKABLE QString getDirDownload(); + Q_INVOKABLE void setRunOnStartUp(bool state); + Q_INVOKABLE void setDownloadPath(QString dir); + Q_INVOKABLE void monitor(const bool& continuous); + +Q_SIGNALS: + void debugMessageReceived(const QString& message); private: QClipboard* clipboard_; SystemTray* systemTray_; + AppSettingsManager* settingsManager_; + + QMetaObject::Connection debugMessageReceivedConnection_; }; Q_DECLARE_METATYPE(UtilsAdapter*) diff --git a/tests/qml/src/tst_WizardView.qml b/tests/qml/src/tst_WizardView.qml index 35b7105c9..cac2e4b7f 100644 --- a/tests/qml/src/tst_WizardView.qml +++ b/tests/qml/src/tst_WizardView.qml @@ -290,7 +290,7 @@ WizardView { compare(spyCloseWizardView.count, 1) // Check alias text - compare(SettingsAdapter.getCurrentAccount_Profile_Info_Alias(), aliasText) + compare(CurrentAccount.alias, aliasText) spyAccountStatusChanged.clear() @@ -364,7 +364,7 @@ WizardView { compare(spyAccountConfigFinalized.count, 1) // Check if it is a RendezVous acc - compare(SettingsAdapter.getAccountConfig_RendezVous(), true) + compare(CurrentAccount.isRendezVous, true) aliasEdit.text = aliasText saveProfileBtn.clicked() @@ -384,7 +384,7 @@ WizardView { compare(spyCloseWizardView.count, 1) // Check alias text - compare(SettingsAdapter.getCurrentAccount_Profile_Info_Alias(), aliasText) + compare(CurrentAccount.alias, aliasText) spyAccountStatusChanged.clear() @@ -459,10 +459,10 @@ WizardView { compare(spyAccountConfigFinalized.count, 1) // Check if paras match with setup - compare(SettingsAdapter.getAccountConfig_RouteSet(), proxy) - compare(SettingsAdapter.getAccountConfig_Username(), userName) - compare(SettingsAdapter.getAccountConfig_Hostname(), serverName) - compare(SettingsAdapter.getAccountConfig_Password(), password) + compare(CurrentAccount.routeset, proxy) + compare(CurrentAccount.username, userName) + compare(CurrentAccount.hostname, serverName) + compare(CurrentAccount.password, password) WizardViewStepModel.nextStep() @@ -1530,7 +1530,7 @@ WizardView { compare(spyCloseWizardView.count, 1) // Check alias text - compare(SettingsAdapter.getCurrentAccount_Profile_Info_Alias(), aliasName) + compare(CurrentAccount.alias, aliasName) AccountAdapter.deleteCurrentAccount() -- GitLab