From 84dec083e27d523551f49f4cae83560ce4282e30 Mon Sep 17 00:00:00 2001 From: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> Date: Tue, 1 Sep 2020 14:31:31 -0400 Subject: [PATCH] mainview: support close to systray - Introduces a C++/Qml common mechanic for accessing system settings - Refactors a good chunk of application wide settings management code - Refactors the onboarding and quit-suppression logic - Makes a first stab at cleaning the Qml object registration - Removes some 'ClientWrapper' use - Fixes some file name spelling errors and inconsistencies Gitlab: #51 Gitlab: #53 Change-Id: I3dd1085aca72a38827ec004e347bd91106be2bcb --- jami-qt.pro | 16 +- ressources.qrc => resources.qrc | 0 src/MainApplicationWindow.qml | 30 +- src/accountadapter.cpp | 15 +- src/accountadapter.h | 1 - src/appsettingsmanager.h | 136 +++++++ src/clientwrapper.cpp | 10 +- src/clientwrapper.h | 8 +- src/commoncomponents/DeleteAccountDialog.qml | 13 +- src/globalsystemtray.h | 1 - src/lrcinstance.h | 6 +- src/main.cpp | 53 ++- src/mainapplication.cpp | 355 +++++------------- src/mainapplication.h | 25 +- src/mainview/components/RecordBox.qml | 2 +- src/qmlregister.cpp | 183 +++++++++ src/qmlregister.h | 21 ++ ...ettingsadaptor.cpp => settingsadapter.cpp} | 319 +++++++--------- src/{settingsadaptor.h => settingsadapter.h} | 20 +- src/settingskey.h | 34 -- src/settingsview/SettingsView.qml | 5 +- .../components/AdvancedSIPSettingsView.qml | 219 +++++------ .../components/AdvancedSettingsView.qml | 113 +++--- src/settingsview/components/AvSettingPage.qml | 4 +- .../CurrentAccountSettingsScrollPage.qml | 39 +- .../CurrentSIPAccountSettingScrollPage.qml | 28 +- .../components/DeviceItemDelegate.qml | 2 +- .../components/GeneralSettingsPage.qml | 36 +- src/utils.cpp | 31 +- src/utils.h | 47 --- src/wizardview/WizardView.qml | 5 +- 31 files changed, 927 insertions(+), 850 deletions(-) rename ressources.qrc => resources.qrc (100%) create mode 100644 src/appsettingsmanager.h create mode 100644 src/qmlregister.cpp create mode 100644 src/qmlregister.h rename src/{settingsadaptor.cpp => settingsadapter.cpp} (72%) rename src/{settingsadaptor.h => settingsadapter.h} (94%) delete mode 100644 src/settingskey.h diff --git a/jami-qt.pro b/jami-qt.pro index 11ef9e98e..84817dc65 100644 --- a/jami-qt.pro +++ b/jami-qt.pro @@ -6,7 +6,7 @@ win32-msvc { CONFIG += suppress_vcproj_warnings c++17 qtquickcompiler - QTQUICK_COMPILER_SKIPPED_RESOURCES += ./ressources.qrc + QTQUICK_COMPILER_SKIPPED_RESOURCES += ./resources.qrc # compiler options QMAKE_CXXFLAGS += /wd"4068" /wd"4099" /wd"4189" /wd"4267" /wd"4577" /wd"4467" /wd"4715" /wd"4828" @@ -118,7 +118,7 @@ HEADERS += ./src/smartlistmodel.h \ ./src/runguard.h \ ./src/lrcinstance.h \ ./src/globalsystemtray.h \ - ./src/settingskey.h \ + ./src/appsettingsmanager.h \ ./src/webchathelpers.h \ ./src/pixbufmanipulator.h \ ./src/rendermanager.h \ @@ -137,7 +137,7 @@ HEADERS += ./src/smartlistmodel.h \ ./src/avadapter.h \ ./src/contactadapter.h \ ./src/mediahandleradapter.h \ - ./src/settingsadaptor.h \ + ./src/settingsadapter.h \ ./src/deviceitemlistmodel.h \ ./src/pluginitemlistmodel.h \ ./src/mediahandleritemlistmodel.h \ @@ -153,7 +153,8 @@ HEADERS += ./src/smartlistmodel.h \ ./src/mediahandlerlistpreferencemodel.h \ ./src/videoformatfpsmodel.h \ ./src/videoformatresolutionmodel.h \ - ./src/audiomanagerlistmodel.h + ./src/audiomanagerlistmodel.h \ + src/qmlregister.h SOURCES += ./src/bannedlistmodel.cpp \ ./src/accountlistmodel.cpp \ @@ -177,7 +178,7 @@ SOURCES += ./src/bannedlistmodel.cpp \ ./src/avadapter.cpp \ ./src/contactadapter.cpp \ ./src/mediahandleradapter.cpp \ - ./src/settingsadaptor.cpp \ + ./src/settingsadapter.cpp \ ./src/deviceitemlistmodel.cpp \ ./src/pluginitemlistmodel.cpp \ ./src/mediahandleritemlistmodel.cpp \ @@ -193,7 +194,8 @@ SOURCES += ./src/bannedlistmodel.cpp \ ./src/mediahandlerlistpreferencemodel.cpp \ ./src/videoformatfpsmodel.cpp \ ./src/videoformatresolutionmodel.cpp \ - ./src/audiomanagerlistmodel.cpp + ./src/audiomanagerlistmodel.cpp \ + src/qmlregister.cpp -RESOURCES += ./ressources.qrc \ +RESOURCES += ./resources.qrc \ ./qml.qrc diff --git a/ressources.qrc b/resources.qrc similarity index 100% rename from ressources.qrc rename to resources.qrc diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index ed266a450..8fb5cbb64 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -5,13 +5,15 @@ import QtQuick.Layouts 1.14 import QtQuick.Controls.Universal 2.12 import QtGraphicalEffects 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 +import net.jami.Enums 1.0 import "mainview" import "wizardview" import "commoncomponents" ApplicationWindow { - id: mainApplicationWindow + id: root AccountMigrationDialog{ id: accountMigrationDialog @@ -23,6 +25,21 @@ ApplicationWindow { } } + function close() { + // If we're in the onboarding wizard or 'MinimizeOnClose' + // is set, then we can quit + if (!SettingsAdapter.getAppValue(Settings.MinimizeOnClose) || + !ClientWrapper.utilsAdaptor.getAccountListSize()) { + Qt.quit() + } else { + // hide to the systray + if (mainViewLoader.item) + mainViewLoader.item.hide() + else + wizardView.hide() + } + } + function slotNewAccountAdded() { if(mainViewLoader.newAddedAccountIndex !== -1) mainViewLoader.item.newAccountAdded(mainViewLoader.newAddedAccountIndex) @@ -60,7 +77,7 @@ ApplicationWindow { target: mainViewLoader.item function onCloseApp() { - Qt.quit() + root.close() } function onNoAccountIsAvailable() { @@ -98,14 +115,15 @@ ApplicationWindow { onWizardViewIsClosed: parent.close() } + // @disable-check M16 onClosing: { if (mainViewLoader.source.toString() !== "qrc:/src/mainview/MainView.qml") { - Qt.quit() + root.close() } } + // @enable-check M16 } - Component.onCompleted: { if(!startAccountMigration()){ startClientByMainview() @@ -113,10 +131,9 @@ ApplicationWindow { } overlay.modal: ColorOverlay { - source: mainApplicationWindow.contentItem + source: root.contentItem color: "transparent" - /* * Color animation for overlay when pop up is shown. */ @@ -128,6 +145,7 @@ ApplicationWindow { Connections { target: ClientWrapper.lrcInstance + onRestoreAppRequested: { if (mainViewLoader.item) mainViewLoader.item.show() diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index edeb1a6bd..00923de5e 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -82,12 +82,8 @@ AccountAdapter::createJamiAccount(QString registeredName, &LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded, [this, registeredName, settings, isCreating, photoBoothImgBase64](const QString &accountId) { - QSettings qSettings("jami.net", "Jami"); - if (not qSettings.contains(SettingsKey::neverShowMeAgain)) { - qSettings.setValue(SettingsKey::neverShowMeAgain, false); - } - auto showBackup = isCreating && !settings.value(SettingsKey::neverShowMeAgain).toBool(); - + auto showBackup = isCreating && + !AppSettingsManager::getValue(Settings::Key::NeverShowMeAgain).toBool(); if (!registeredName.isEmpty()) { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::nameRegistrationEnded, @@ -313,13 +309,6 @@ AccountAdapter::setArchivePasswordAsync(const QString &accountID, const QString }); } -void -AccountAdapter::settingsNeverShowAgain(bool checked) -{ - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::neverShowMeAgain, checked); -} - void AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay) { diff --git a/src/accountadapter.h b/src/accountadapter.h index 34aee818f..d2e9844d7 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -57,7 +57,6 @@ public: /* * Setting related */ - Q_INVOKABLE void settingsNeverShowAgain(bool checked); Q_INVOKABLE void passwordSetStatusMessageBox(bool success, QString title, QString infoToDisplay); /* * conf property diff --git a/src/appsettingsmanager.h b/src/appsettingsmanager.h new file mode 100644 index 000000000..86766f458 --- /dev/null +++ b/src/appsettingsmanager.h @@ -0,0 +1,136 @@ +/*! + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Andreas Traczyk <andreas.traczyk@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 <https://www.gnu.org/licenses/>. + * + * \file appsettingsmanager.h + */ + +#pragma once + +#include "utils.h" + +#include <QMetaEnum> +#include <QObject> +#include <QString> +#include <QStandardPaths> + +const QString defaultDownloadPath = + QStandardPaths::writableLocation(QStandardPaths::DownloadLocation); + +#define KEYS \ + X(MinimizeOnClose, true) \ + X(DownloadPath, defaultDownloadPath) \ + X(EnableNotifications, true) \ + X(AutoUpdate, true) \ + X(NeverShowMeAgain, false) + +/* + * A class to expose settings keys in both c++ and QML. + * Note: this using a non-constructable class instead of a + * namespace allows for QML enum auto-completion in QtCreator. + * This works well when there is only one enum class. Otherwise, + * to prevent element name collision when defining multiple enums, + * use a namespace with: + * + * Q_NAMESPACE + * Q_CLASSINFO("RegisterEnumClassesUnscoped", "false") + */ +class Settings : public QObject +{ + Q_OBJECT +public: + enum class Key { +#define X(key, defaultValue) key, + KEYS +#undef X + COUNT__ + }; + Q_ENUM(Key) + static QString toString(Key key) + { + return QMetaEnum::fromType<Key>().valueToKey( + Utils::toUnderlyingValue(key)); + } + static QVariant defaultValue(const Key key) + { + switch (key) { +#define X(key, defaultValue) \ + case Key::key: return defaultValue; + KEYS +#undef X + default: return {}; + } + } +private: + Settings() = delete; +}; +Q_DECLARE_METATYPE(Settings::Key) + +/* + * A singleton object to manage settings access. + */ +class AppSettingsManager : public QObject +{ + Q_OBJECT +public: + virtual ~AppSettingsManager() = default; + + static AppSettingsManager& + instance() + { + static AppSettingsManager *instance_ = + new AppSettingsManager(nullptr); + return *instance_; + } + + static QVariant + getValue(const Settings::Key key) + { + auto settings = instance().settings_; + auto value = settings->value(Settings::toString(key), + Settings::defaultValue(key)); + + if (QString(value.typeName()) == "QString" && + (value.toString() == "false" || value.toString() == "true")) + return value.toBool(); + + return value; + } + + static void + setValue(const Settings::Key key, const QVariant& value) + { + instance().settings_->setValue(Settings::toString(key), value); + } + + static void + initValues() + { + for (int i = 0; + i < Utils::toUnderlyingValue(Settings::Key::COUNT__); + ++i) { + auto key = Utils::toEnum<Settings::Key>(i); + if (!instance().settings_->contains(Settings::toString(key))) + setValue(key, Settings::defaultValue(key)); + } + } + +private: + explicit AppSettingsManager(QObject *) + : settings_(new QSettings("jami.net", "Jami", this)) {} + + QSettings *settings_; +}; diff --git a/src/clientwrapper.cpp b/src/clientwrapper.cpp index f099de654..ec61ffd8d 100644 --- a/src/clientwrapper.cpp +++ b/src/clientwrapper.cpp @@ -42,10 +42,10 @@ ClientWrapper::getUtilsAdapter() return &(UtilsAdapter::instance()); } -SettingsAdaptor * -ClientWrapper::getSettingsAdaptor() +SettingsAdapter * +ClientWrapper::getSettingsAdapter() { - return &(SettingsAdaptor::instance()); + return &(SettingsAdapter::instance()); } LRCInstance * @@ -93,11 +93,11 @@ ClientWrapper::getDataTransferModel() lrc::api::ContactModel * ClientWrapper::getContactModel() { - return getSettingsAdaptor()->getCurrentAccountInfo().contactModel.get(); + return getSettingsAdapter()->getCurrentAccountInfo().contactModel.get(); } lrc::api::NewDeviceModel * ClientWrapper::getDeviceModel() { - return getSettingsAdaptor()->getCurrentAccountInfo().deviceModel.get(); + return getSettingsAdapter()->getCurrentAccountInfo().deviceModel.get(); } diff --git a/src/clientwrapper.h b/src/clientwrapper.h index 0ca94f1d9..790e6e8e3 100644 --- a/src/clientwrapper.h +++ b/src/clientwrapper.h @@ -40,7 +40,7 @@ #include "pixbufmanipulator.h" #include "previewrenderer.h" #include "qrimageprovider.h" -#include "settingsadaptor.h" +#include "settingsadapter.h" #include "utils.h" #include "version.h" #include "videocodeclistmodel.h" @@ -52,7 +52,7 @@ class ClientWrapper : public QObject Q_OBJECT Q_PROPERTY(UtilsAdapter *utilsAdaptor READ getUtilsAdapter NOTIFY utilsAdaptorChanged) - Q_PROPERTY(SettingsAdaptor *settingsAdaptor READ getSettingsAdaptor NOTIFY settingsAdaptorChanged) + Q_PROPERTY(SettingsAdapter *SettingsAdapter READ getSettingsAdapter NOTIFY SettingsAdapterChanged) Q_PROPERTY(NameDirectory *nameDirectory READ getNameDirectory NOTIFY nameDirectoryChanged) Q_PROPERTY(LRCInstance *lrcInstance READ getLRCInstance NOTIFY lrcInstanceChanged) Q_PROPERTY(AccountAdapter *accountAdaptor READ getAccountAdapter NOTIFY accountAdaptorChanged) @@ -68,7 +68,7 @@ public: NameDirectory *getNameDirectory(); UtilsAdapter *getUtilsAdapter(); - SettingsAdaptor *getSettingsAdaptor(); + SettingsAdapter *getSettingsAdapter(); LRCInstance *getLRCInstance(); AccountAdapter *getAccountAdapter(); @@ -83,7 +83,7 @@ public: signals: void utilsAdaptorChanged(); - void settingsAdaptorChanged(); + void SettingsAdapterChanged(); void nameDirectoryChanged(); void lrcInstanceChanged(); void accountAdaptorChanged(); diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index 1db2813b0..bc42048d3 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -21,11 +21,12 @@ import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls.Styles 1.4 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 Dialog { id: deleteAccountDialog - property int profileType: ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Type() + property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() property bool isSIP: { switch (profileType) { @@ -37,9 +38,9 @@ Dialog { } onOpened: { - profileType = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Type() - labelBestId.text = ClientWrapper.settingsAdaptor.getAccountBestName() - labelAccountHash.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri() + profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() + labelBestId.text = SettingsAdapter.getAccountBestName() + labelAccountHash.text = SettingsAdapter.getCurrentAccount_Profile_Info_Uri() } onVisibleChanged: { @@ -91,7 +92,7 @@ Dialog { verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: ClientWrapper.settingsAdaptor.getAccountBestName() + text: SettingsAdapter.getAccountBestName() } Label{ @@ -106,7 +107,7 @@ Dialog { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter wrapMode: Text.Wrap - text: ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri() + text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() } Item{ diff --git a/src/globalsystemtray.h b/src/globalsystemtray.h index e72713cb7..5f14abccd 100644 --- a/src/globalsystemtray.h +++ b/src/globalsystemtray.h @@ -31,7 +31,6 @@ public: instance() { static GlobalSystemTray *instance_ = new GlobalSystemTray(); - return *instance_; } diff --git a/src/lrcinstance.h b/src/lrcinstance.h index 776c3a1f5..8e7a618e6 100644 --- a/src/lrcinstance.h +++ b/src/lrcinstance.h @@ -26,7 +26,7 @@ #include "accountlistmodel.h" #include "rendermanager.h" -#include "settingskey.h" +#include "appsettingsmanager.h" #include "utils.h" #include "api/account.h" @@ -271,8 +271,6 @@ public: setSelectedAccountId(const QString &accountId = {}) { instance().selectedAccountId_ = accountId; - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::selectedAccount, accountId); // Last selected account should be set as preferred. accountModel().setTopAccount(accountId); @@ -304,7 +302,7 @@ public: } }; - static const int + static int getCurrentAccountIndex() { for (int i = 0; i < accountModel().getAccountList().size(); i++) { diff --git a/src/main.cpp b/src/main.cpp index 2b1349ce5..d4b2debe1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -/* +/*! * Copyright (C) 2015-2020 by Savoir-faire Linux * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com> * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> @@ -21,11 +21,28 @@ #include "mainapplication.h" #include "runguard.h" -#include <clocale> #include <QCryptographicHash> +#include <QtWebEngine> #include <clocale> +static char** +parseInputArgument(int& argc, char* argv[], char* argToParse) +{ + /* + * Forcefully append argToParse. + */ + int oldArgc = argc; + argc = argc + 1 + 1; + char** newArgv = new char*[argc]; + for (int i = 0; i < oldArgc; i++) { + newArgv[i] = argv[i]; + } + newArgv[oldArgc] = argToParse; + newArgv[oldArgc + 1] = nullptr; + return newArgv; +} + int main(int argc, char *argv[]) { @@ -33,13 +50,24 @@ main(int argc, char *argv[]) #ifdef Q_OS_LINUX setenv("QT_QPA_PLATFORMTHEME", "gtk3", true); #endif +#ifdef Q_OS_WIN + QApplication::setApplicationName("Ring"); +#else + QApplication::setApplicationName("Jami"); +#endif + QApplication::setOrganizationDomain("jami.net"); + QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); + QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); + QApplication::setQuitOnLastWindowClosed(false); + QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); + QApplication::setHighDpiScaleFactorRoundingPolicy( + Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor); + QtWebEngine::initialize(); - MainApplication::applicationInitialization(); - + // Allow QtWebEngine to load local resources. char ARG_DISABLE_WEB_SECURITY[] = "--disable-web-security"; - auto newArgv = MainApplication::parseInputArgument(argc, argv, ARG_DISABLE_WEB_SECURITY); - - MainApplication a(argc, newArgv); + auto newArgv = parseInputArgument(argc, argv, ARG_DISABLE_WEB_SECURITY); + MainApplication app(argc, newArgv); /* * Runguard to make sure that only one instance runs at a time. @@ -50,22 +78,15 @@ main(int argc, char *argv[]) appData.addData(QApplication::organizationDomain().toUtf8()); RunGuard guard(appData.result()); if (!guard.tryToRun()) { - /* - * No need to exitApp since app is not set up. - */ return 0; } - if (!a.applicationSetup()) { - guard.release(); - a.exitApp(); - return 0; - } + app.init(); /* * Exec the application. */ - auto ret = a.exec(); + auto ret = app.exec(); guard.release(); return ret; diff --git a/src/mainapplication.cpp b/src/mainapplication.cpp index d3d6a68b5..198a810a9 100644 --- a/src/mainapplication.cpp +++ b/src/mainapplication.cpp @@ -1,4 +1,4 @@ -/** +/*! * Copyright (C) 2015-2020 by Savoir-faire Linux * Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com> * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> @@ -21,48 +21,18 @@ #include "mainapplication.h" -#include "accountadapter.h" -#include "accountlistmodel.h" -#include "accountstomigratelistmodel.h" -#include "audiocodeclistmodel.h" -#include "audioinputdevicemodel.h" -#include "audiomanagerlistmodel.h" -#include "audiooutputdevicemodel.h" -#include "pluginlistpreferencemodel.h" -#include "mediahandlerlistpreferencemodel.h" -#include "avadapter.h" -#include "bannedlistmodel.h" -#include "calladapter.h" -#include "clientwrapper.h" -#include "contactadapter.h" -#include "mediahandleradapter.h" -#include "conversationsadapter.h" -#include "deviceitemlistmodel.h" -#include "pluginitemlistmodel.h" -#include "mediahandleritemlistmodel.h" -#include "preferenceitemlistmodel.h" -#include "distantrenderer.h" +#include "appsettingsmanager.h" #include "globalinstances.h" #include "globalsystemtray.h" -#include "messagesadapter.h" -#include "namedirectory.h" -#include "pixbufmanipulator.h" -#include "previewrenderer.h" +#include "qmlregister.h" #include "qrimageprovider.h" -#include "settingsadaptor.h" +#include "pixbufmanipulator.h" #include "tintedbuttonimageprovider.h" -#include "utils.h" -#include "version.h" -#include "videocodeclistmodel.h" -#include "videoformatfpsmodel.h" -#include "videoformatresolutionmodel.h" -#include "videoinputdevicemodel.h" #include <QAction> #include <QFontDatabase> #include <QMenu> #include <QQmlContext> -#include <QtWebEngine> #include <locale.h> @@ -74,44 +44,17 @@ #include <gnutls/gnutls.h> #endif -MainApplication::MainApplication(int& argc, char** argv) - : QApplication(argc, argv) - , engine_(new QQmlApplicationEngine()) -{ - QObject::connect(this, &QApplication::aboutToQuit, [this] { exitApp(); }); -} - -void -MainApplication::applicationInitialization() -{ - /* - * Some attributes are needed to be set before the creation of the application. - */ - QApplication::setApplicationName("Ring"); - QApplication::setOrganizationDomain("jami.net"); - QApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true); - QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps); - QApplication::setQuitOnLastWindowClosed(false); - QCoreApplication::setAttribute(Qt::AA_UseOpenGLES); -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) - QApplication::setHighDpiScaleFactorRoundingPolicy( - Qt::HighDpiScaleFactorRoundingPolicy::RoundPreferFloor); - /* - * Initialize QtWebEngine. - */ - QtWebEngine::initialize(); -#endif -} - -void -MainApplication::consoleDebug() +static void +consoleDebug() { #ifdef Q_OS_WIN AllocConsole(); SetConsoleCP(CP_UTF8); - freopen("CONOUT$", "w", stdout); - freopen("CONOUT$", "w", stderr); + FILE* fpstdout = stdout; + freopen_s(&fpstdout, "CONOUT$", "w", stdout); + FILE* fpstderr = stderr; + freopen_s(&fpstderr, "CONOUT$", "w", stderr); COORD coordInfo; coordInfo.X = 130; @@ -122,8 +65,8 @@ MainApplication::consoleDebug() #endif } -void -MainApplication::vsConsoleDebug() +static void +vsConsoleDebug() { #ifdef _MSC_VER /* @@ -137,8 +80,16 @@ MainApplication::vsConsoleDebug() #endif } -void -MainApplication::fileDebug(QFile* debugFile) +static QString +getDebugFilePath() +{ + QDir logPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); + logPath.cdUp(); + return QString(logPath.absolutePath() + "/jami/jami.log"); +} + +static void +fileDebug(QFile* debugFile) { QObject::connect(&LRCInstance::behaviorController(), &lrc::api::BehaviorController::debugMessageReceived, @@ -151,41 +102,44 @@ MainApplication::fileDebug(QFile* debugFile) }); } -void -MainApplication::exitApp() +MainApplication::MainApplication(int& argc, char** argv) + : QApplication(argc, argv) + , engine_(new QQmlApplicationEngine()) { - GlobalSystemTray::instance().hide(); -#ifdef Q_OS_WIN - FreeConsole(); -#endif + QObject::connect(this, &QApplication::aboutToQuit, [this] { cleanup(); }); } -char** -MainApplication::parseInputArgument(int& argc, char* argv[], char* argToParse) +void +MainApplication::init() { - /* - * Forcefully append argToParse. - */ - int oldArgc = argc; - argc = argc + 1 + 1; - char** newArgv = new char*[argc]; - for (int i = 0; i < oldArgc; i++) { - newArgv[i] = argv[i]; +#ifdef Q_OS_LINUX + if (!getenv("QT_QPA_PLATFORMTHEME")) + setenv("QT_QPA_PLATFORMTHEME", "gtk3", true); +#endif + + for (auto string : QCoreApplication::arguments()) { + if (string == "-d" || string == "--debug") { + consoleDebug(); + } } - newArgv[oldArgc] = argToParse; - newArgv[oldArgc + 1] = nullptr; - return newArgv; -} -QString -MainApplication::getDebugFilePath() -{ - QDir logPath(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); - /* - * Since logPath will be .../Ring, we use cdUp to remove it. - */ - logPath.cdUp(); - return QString(logPath.absolutePath() + "/jami/jami.log"); + Utils::removeOldVersions(); + loadTranslations(); + setApplicationFont(); + +#if defined _MSC_VER && !COMPILE_ONLY + gnutls_global_init(); +#endif + + GlobalInstances::setPixmapManipulator(std::make_unique<PixbufManipulator>()); + initLrc(); + + bool startMinimized {false}; + parseArguments(startMinimized); + + initSettings(); + initSystray(); + initQmlEngine(); } void @@ -244,7 +198,7 @@ MainApplication::initLrc() this->processEvents(); } }, - [this, &isMigrating] { + [&isMigrating] { while (!isMigrating) { std::this_thread::sleep_for(std::chrono::milliseconds(10)); } @@ -255,9 +209,8 @@ MainApplication::initLrc() } void -MainApplication::processInputArgument(bool& startMinimized) +MainApplication::parseArguments(bool& startMinimized) { - debugFile_ = std::make_unique<QFile>(getDebugFilePath()); QString uri = ""; for (auto string : QCoreApplication::arguments()) { @@ -267,6 +220,8 @@ MainApplication::processInputArgument(bool& startMinimized) if (string == "-m" || string == "--minimized") { startMinimized = true; } +#ifdef Q_OS_WINDOWS + debugFile_.reset(new QFile(getDebugFilePath())); auto dbgFile = string == "-f" || string == "--file"; auto dbgConsole = string == "-c" || string == "--vsconsole"; if (dbgFile || dbgConsole) { @@ -275,12 +230,11 @@ MainApplication::processInputArgument(bool& startMinimized) debugFile_->close(); fileDebug(debugFile_.get()); } -#ifdef _MSC_VER if (dbgConsole) { vsConsoleDebug(); } -#endif } +#endif } } } @@ -295,171 +249,27 @@ MainApplication::setApplicationFont() } void -MainApplication::qmlInitialization() +MainApplication::initQmlEngine() { - /* - * Register accountListModel type. - */ - QML_REGISTERTYPE(AccountListModel, 1, 0); - QML_REGISTERTYPE(DeviceItemListModel, 1, 0); - QML_REGISTERTYPE(PluginItemListModel, 1, 0); - QML_REGISTERTYPE(MediaHandlerItemListModel, 1, 0); - QML_REGISTERTYPE(PreferenceItemListModel, 1, 0); - QML_REGISTERTYPE(BannedListModel, 1, 0); - QML_REGISTERTYPE(VideoCodecListModel, 1, 0); - QML_REGISTERTYPE(AudioCodecListModel, 1, 0); - QML_REGISTERTYPE(AccountsToMigrateListModel, 1, 0); - QML_REGISTERTYPE(AudioInputDeviceModel, 1, 0); - QML_REGISTERTYPE(AudioOutputDeviceModel, 1, 0); - QML_REGISTERTYPE(AudioManagerListModel, 1, 0); - QML_REGISTERTYPE(VideoInputDeviceModel, 1, 0); - QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0); - QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0); - QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0); - QML_REGISTERTYPE(MediaHandlerListPreferenceModel, 1, 0); - /* - * Register QQuickItem type. - */ - QML_REGISTERTYPE(PreviewRenderer, 1, 0); - QML_REGISTERTYPE(VideoCallPreviewRenderer, 1, 0); - QML_REGISTERTYPE(DistantRenderer, 1, 0); - QML_REGISTERTYPE(PhotoboothPreviewRender, 1, 0) - - /* - * Adapter - qmlRegisterSingletonType. - * Note: in future, if lrc is fully compatible with qml (C++ struct - * is readable in qml), the adapters can be optimized away. - */ - QML_REGISTERSINGLETONTYPE_URL(QStringLiteral("qrc:/src/constant/JamiTheme.qml"), - JamiTheme, - 1, - 0); - QML_REGISTERSINGLETONTYPE(CallAdapter, 1, 0); - - QML_REGISTERSINGLETONTYPE(MessagesAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE(ConversationsAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE(AvAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE(ContactAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE(MediaHandlerAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE(ClientWrapper, 1, 0); - - // QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(AccountAdapter, 1, 0); - // QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(UtilsAdapter, 1, 0); - QML_REGISTERUNCREATABLE(AccountAdapter, 1, 0); - QML_REGISTERUNCREATABLE(UtilsAdapter, 1, 0); - QML_REGISTERUNCREATABLE(SettingsAdaptor, 1, 0); - QML_REGISTERUNCREATABLE(NameDirectory, 1, 0); - QML_REGISTERUNCREATABLE(LRCInstance, 1, 0); - - /* - * Lrc models - qmlRegisterUncreatableType & Q_DECLARE_METATYPE. - * This to make lrc models recognizable in qml. - */ - QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewAccountModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(BehaviorController, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(DataTransferModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(AVModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(ContactModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(ConversationModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCallModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(PluginModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewDeviceModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCodecModel, lrc::api, 1, 0); - QML_REGISTERUNCREATABLE_IN_NAMESPACE(PeerDiscoveryModel, lrc::api, 1, 0); + registerTypes(); - /* - * Client models - qmlRegisterUncreatableType & Q_DECLARE_METATYPE. - * This to make client models recognizable in qml. - */ - QML_REGISTERUNCREATABLE(RenderManager, 1, 0); - - /* - * Namespaces - qmlRegisterUncreatableMetaObject. - */ - QML_REGISTERNAMESPACE(lrc::api::staticMetaObject, "Lrc", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::account::staticMetaObject, "Account", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::call::staticMetaObject, "Call", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::datatransfer::staticMetaObject, "Datatransfer", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::interaction::staticMetaObject, "Interaction", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::video::staticMetaObject, "Video", 1, 0); - QML_REGISTERNAMESPACE(lrc::api::profile::staticMetaObject, "Profile", 1, 0); - - /* - * Add image provider. - */ engine_->addImageProvider(QLatin1String("qrImage"), new QrImageProvider()); engine_->addImageProvider(QLatin1String("tintedPixmap"), new TintedButtonImageProvider()); engine_->load(QUrl(QStringLiteral("qrc:/src/MainApplicationWindow.qml"))); } -MainApplication::~MainApplication() {} - -bool -MainApplication::applicationSetup() +void +MainApplication::initSettings() { -#ifdef Q_OS_LINUX - if (!getenv("QT_QPA_PLATFORMTHEME")) - setenv("QT_QPA_PLATFORMTHEME", "gtk3", true); -#endif - - /* - * Start debug console. - */ - for (auto string : QCoreApplication::arguments()) { - if (string == "-d" || string == "--debug") { - consoleDebug(); - } - } - - /* - * Remove old version files. - */ - Utils::removeOldVersions(); - - /* - * Load translations. - */ - loadTranslations(); - - /* - * Set font. - */ - setApplicationFont(); - -#if defined _MSC_VER && !COMPILE_ONLY - gnutls_global_init(); -#endif - - /* - * Init pixmap manipulator. - */ - GlobalInstances::setPixmapManipulator(std::make_unique<PixbufManipulator>()); - - /* - * Init lrc and its possible migration ui. - */ - initLrc(); - - /* - * Process input argument. - */ - bool startMinimized {false}; - processInputArgument(startMinimized); - - /* - * Create jami.net settings in Registry if it is not presented. - */ - QSettings settings("jami.net", "Jami"); - - /* - * Initialize qml components. - */ - qmlInitialization(); + AppSettingsManager::instance().initValues(); + auto downloadPath = AppSettingsManager::instance().getValue(Settings::Key::DownloadPath); + LRCInstance::dataTransferModel().downloadDirectory = downloadPath.toString() + "/"; +} - /* - * Systray menu. - */ +void +MainApplication::initSystray() +{ GlobalSystemTray& sysIcon = GlobalSystemTray::instance(); sysIcon.setIcon(QIcon(":images/jami.png")); @@ -467,18 +277,27 @@ MainApplication::applicationSetup() QAction* exitAction = new QAction(tr("Exit"), this); connect(exitAction, &QAction::triggered, - [this] { - QCoreApplication::exit(); + [this]{ + engine_->quit(); + cleanup(); + }); + connect(&sysIcon, &QSystemTrayIcon::activated, + [](QSystemTrayIcon::ActivationReason reason) { + if (reason != QSystemTrayIcon::ActivationReason::Context) + emit LRCInstance::instance().restoreAppRequested(); }); - - connect(&sysIcon, &QSystemTrayIcon::activated, - [this](QSystemTrayIcon::ActivationReason reason) { - emit LRCInstance::instance().restoreAppRequested(); - }); systrayMenu->addAction(exitAction); sysIcon.setContextMenu(systrayMenu); sysIcon.show(); +} - return true; +void +MainApplication::cleanup() +{ + GlobalSystemTray::instance().hide(); +#ifdef Q_OS_WIN + FreeConsole(); +#endif + QApplication::exit(0); } diff --git a/src/mainapplication.h b/src/mainapplication.h index ae51ac6a7..9723ca070 100644 --- a/src/mainapplication.h +++ b/src/mainapplication.h @@ -33,27 +33,22 @@ class MainApplication : public QApplication public: explicit MainApplication(int &argc, char **argv); - ~MainApplication(); + ~MainApplication() = default; - bool applicationSetup(); - void exitApp(); - - static void applicationInitialization(); - static QString getDebugFilePath(); - static char **parseInputArgument(int &argc, char *argv[], char *argToParse); - -protected: - void consoleDebug(); - void vsConsoleDebug(); - void fileDebug(QFile *debugFile); + void init(); private: void loadTranslations(); void initLrc(); - void processInputArgument(bool &startMinimized); + void parseArguments(bool &startMinimized); void setApplicationFont(); - void qmlInitialization(); + void initQmlEngine(); + void initSettings(); + void initSystray(); + void cleanup(); - std::unique_ptr<QFile> debugFile_; +private: + QScopedPointer<QFile> debugFile_; QQmlApplicationEngine *engine_; + }; diff --git a/src/mainview/components/RecordBox.qml b/src/mainview/components/RecordBox.qml index a7e94e530..730abc2df 100644 --- a/src/mainview/components/RecordBox.qml +++ b/src/mainview/components/RecordBox.qml @@ -80,7 +80,7 @@ Rectangle { height = preferredHeight if (isVideo) { var device = ClientWrapper.avmodel.getDefaultDevice() - var settings = ClientWrapper.settingsAdaptor.get_Video_Settings_Size(device) + var settings = SettingsAdapter.get_Video_Settings_Size(device) var res = settings.split("x") var aspectRatio = res[1] / res[0] if (aspectRatio) { diff --git a/src/qmlregister.cpp b/src/qmlregister.cpp new file mode 100644 index 000000000..0155378e0 --- /dev/null +++ b/src/qmlregister.cpp @@ -0,0 +1,183 @@ +/*! + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Andreas Traczyk <andreas.traczyk@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 <https://www.gnu.org/licenses/>. + */ + +#include "qmlregister.h" + +#include "accountadapter.h" +#include "accountstomigratelistmodel.h" +#include "audiocodeclistmodel.h" +#include "audioinputdevicemodel.h" +#include "audiomanagerlistmodel.h" +#include "audiooutputdevicemodel.h" +#include "avadapter.h" +#include "bannedlistmodel.h" +#include "calladapter.h" +#include "clientwrapper.h" +#include "contactadapter.h" +#include "conversationsadapter.h" +#include "deviceitemlistmodel.h" +#include "distantrenderer.h" +#include "mediahandleradapter.h" +#include "mediahandleritemlistmodel.h" +#include "mediahandlerlistpreferencemodel.h" +#include "messagesadapter.h" +#include "namedirectory.h" +#include "preferenceitemlistmodel.h" +#include "pluginitemlistmodel.h" +#include "pluginlistpreferencemodel.h" +#include "previewrenderer.h" +#include "settingsadapter.h" +#include "utils.h" +#include "version.h" +#include "videocodeclistmodel.h" +#include "videoformatfpsmodel.h" +#include "videoformatresolutionmodel.h" +#include "videoinputdevicemodel.h" + +#include <QMetaType> +#include <QQmlEngine> + +#define QML_REGISTERSINGLETONTYPE(N, T, MAJ, MIN) \ + qmlRegisterSingletonType<T>(N, MAJ, MIN, #T, \ + [](QQmlEngine *e, QJSEngine *se) -> QObject * { \ + Q_UNUSED(e); \ + Q_UNUSED(se); \ + T *obj = new T(); \ + return obj; \ + }); +#define QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(T, MAJ, MIN) \ + qmlRegisterSingletonType<T>("net.jami.Models", \ + MAJ, \ + MIN, \ + #T, \ + [](QQmlEngine *e, QJSEngine *se) -> QObject * { \ + Q_UNUSED(e); \ + Q_UNUSED(se); \ + return &(T::instance()); \ + }); + +#define QML_REGISTERSINGLETONTYPE_URL(URL, T, MAJ, MIN) \ + qmlRegisterSingletonType(QUrl(URL), "net.jami.Models", MAJ, MIN, #T); + +#define QML_REGISTERTYPE(T, MAJ, MIN) qmlRegisterType<T>("net.jami.Models", MAJ, MIN, #T); + +#define QML_REGISTERNAMESPACE(T, NAME, MAJ, MIN) \ + qmlRegisterUncreatableMetaObject(T, "net.jami.Models", MAJ, MIN, NAME, "") + +#define QML_REGISTERUNCREATABLE(N, T, MAJ, MIN) \ + qmlRegisterUncreatableType<T>(N, \ + MAJ, \ + MIN, \ + #T, \ + "Don't try to add to a qml definition of " #T); + +#define QML_REGISTERUNCREATABLE_IN_NAMESPACE(T, NAMESPACE, MAJ, MIN) \ + qmlRegisterUncreatableType<NAMESPACE::T>("net.jami.Models", \ + MAJ, \ + MIN, \ + #T, \ + "Don't try to add to a qml definition of " #T); + +/*! + * This function will expose custom types to the QML engine. + */ +void registerTypes() +{ + /* + * Register QAbstractListModel type. + */ + QML_REGISTERTYPE(AccountListModel, 1, 0); + QML_REGISTERTYPE(DeviceItemListModel, 1, 0); + QML_REGISTERTYPE(PluginItemListModel, 1, 0); + QML_REGISTERTYPE(MediaHandlerItemListModel, 1, 0); + QML_REGISTERTYPE(PreferenceItemListModel, 1, 0); + QML_REGISTERTYPE(BannedListModel, 1, 0); + QML_REGISTERTYPE(VideoCodecListModel, 1, 0); + QML_REGISTERTYPE(AudioCodecListModel, 1, 0); + QML_REGISTERTYPE(AccountsToMigrateListModel, 1, 0); + QML_REGISTERTYPE(AudioInputDeviceModel, 1, 0); + QML_REGISTERTYPE(AudioOutputDeviceModel, 1, 0); + QML_REGISTERTYPE(AudioManagerListModel, 1, 0); + QML_REGISTERTYPE(VideoInputDeviceModel, 1, 0); + QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0); + QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0); + QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0); + QML_REGISTERTYPE(MediaHandlerListPreferenceModel, 1, 0); + + /* + * Register QQuickItem type. + */ + QML_REGISTERTYPE(PreviewRenderer, 1, 0); + QML_REGISTERTYPE(VideoCallPreviewRenderer, 1, 0); + QML_REGISTERTYPE(DistantRenderer, 1, 0); + QML_REGISTERTYPE(PhotoboothPreviewRender, 1, 0) + + /* + * Adaptors - qmlRegisterSingletonType. + */ + QML_REGISTERSINGLETONTYPE_URL(QStringLiteral("qrc:/src/constant/JamiTheme.qml"), + JamiTheme, 1, 0); + + QML_REGISTERSINGLETONTYPE("net.jami.Models", CallAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", MessagesAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", ContactAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", MediaHandlerAdapter, 1, 0); + QML_REGISTERSINGLETONTYPE("net.jami.Models", ClientWrapper, 1, 0); + + + QML_REGISTERSINGLETONTYPE("net.jami.Adapters", SettingsAdapter, 1, 0); + QML_REGISTERUNCREATABLE("net.jami.Enums", Settings, 1, 0); + + /* + * Lrc models - qmlRegisterUncreatableType & Q_DECLARE_METATYPE. + * This to make lrc models recognizable in qml. + */ + QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewAccountModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(BehaviorController, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(DataTransferModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(AVModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(ContactModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(ConversationModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCallModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(PluginModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewDeviceModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCodecModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(PeerDiscoveryModel, lrc::api, 1, 0); + + /* + * qmlRegisterUncreatableType & Q_DECLARE_METATYPE to expose models in qml. + */ + QML_REGISTERUNCREATABLE("net.jami.Models", RenderManager, 1, 0); + QML_REGISTERUNCREATABLE("net.jami.Models", AccountAdapter, 1, 0); + QML_REGISTERUNCREATABLE("net.jami.Models", UtilsAdapter, 1, 0); + QML_REGISTERUNCREATABLE("net.jami.Models", NameDirectory, 1, 0); + QML_REGISTERUNCREATABLE("net.jami.Models", LRCInstance, 1, 0); + + /* + * qmlRegisterUncreatableMetaObject to expose namespaces in qml + */ + QML_REGISTERNAMESPACE(lrc::api::staticMetaObject, "Lrc", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::account::staticMetaObject, "Account", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::call::staticMetaObject, "Call", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::datatransfer::staticMetaObject, "Datatransfer", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::interaction::staticMetaObject, "Interaction", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::video::staticMetaObject, "Video", 1, 0); + QML_REGISTERNAMESPACE(lrc::api::profile::staticMetaObject, "Profile", 1, 0); +} diff --git a/src/qmlregister.h b/src/qmlregister.h new file mode 100644 index 000000000..0da93c8dc --- /dev/null +++ b/src/qmlregister.h @@ -0,0 +1,21 @@ +/*! + * Copyright (C) 2020 by Savoir-faire Linux + * Author: Andreas Traczyk <andreas.traczyk@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 <https://www.gnu.org/licenses/>. + */ + +#pragma once + +void registerTypes(); diff --git a/src/settingsadaptor.cpp b/src/settingsadapter.cpp similarity index 72% rename from src/settingsadaptor.cpp rename to src/settingsadapter.cpp index e0571a8a5..3e025f931 100644 --- a/src/settingsadaptor.cpp +++ b/src/settingsadapter.cpp @@ -16,31 +16,31 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "settingsadaptor.h" +#include "settingsadapter.h" #include "api/newdevicemodel.h" -SettingsAdaptor::SettingsAdaptor(QObject *parent) +SettingsAdapter::SettingsAdapter(QObject *parent) : QObject(parent) {} ///Singleton -SettingsAdaptor & -SettingsAdaptor::instance() +SettingsAdapter & +SettingsAdapter::instance() { - static auto instance = new SettingsAdaptor; + static auto instance = new SettingsAdapter; return *instance; } QString -SettingsAdaptor::getDir_Document() +SettingsAdapter::getDir_Document() { return QDir::toNativeSeparators( QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); } QString -SettingsAdaptor::getDir_Download() +SettingsAdapter::getDir_Download() { QString downloadPath = QDir::toNativeSeparators(LRCInstance::dataTransferModel().downloadDirectory); if (downloadPath.isEmpty()) { @@ -58,52 +58,20 @@ SettingsAdaptor::getDir_Download() return downloadPath; } -bool -SettingsAdaptor::getSettingsValue_CloseOrMinimized() -{ - QSettings settings("jami.net", "Jami"); - return settings.value(SettingsKey::closeOrMinimized).toBool(); -} - -bool -SettingsAdaptor::getSettingsValue_EnableNotifications() +QVariant +SettingsAdapter::getAppValue(const Settings::Key key) { - QSettings settings("jami.net", "Jami"); - return settings.value(SettingsKey::enableNotifications).toBool(); -} - -bool -SettingsAdaptor::getSettingsValue_AutoUpdate() -{ - QSettings settings("jami.net", "Jami"); - return settings.value(SettingsKey::autoUpdate).toBool(); + return AppSettingsManager::getValue(key); } void -SettingsAdaptor::setClosedOrMin(bool state) +SettingsAdapter::setAppValue(const Settings::Key key, const QVariant& value) { - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::closeOrMinimized, state); -} - -void -SettingsAdaptor::setNotifications(bool state) -{ - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::enableNotifications, state); -} - -void -SettingsAdaptor::setUpdateAutomatic(bool state) -{ -#ifdef Q_OS_WIN - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::autoUpdate, state); -#endif + AppSettingsManager::setValue(key, value); } void -SettingsAdaptor::setRunOnStartUp(bool state) +SettingsAdapter::setRunOnStartUp(bool state) { if (Utils::CheckStartupLink(L"Jami")) { if (!state) { @@ -115,15 +83,14 @@ SettingsAdaptor::setRunOnStartUp(bool state) } void -SettingsAdaptor::setDownloadPath(QString dir) +SettingsAdapter::setDownloadPath(QString dir) { - QSettings settings("jami.net", "Jami"); - settings.setValue(SettingsKey::downloadPath, dir); + setAppValue(Settings::Key::DownloadPath, dir); LRCInstance::dataTransferModel().downloadDirectory = dir + "/"; } lrc::api::video::ResRateList -SettingsAdaptor::get_ResRateList(lrc::api::video::Channel channel, QString device) +SettingsAdapter::get_ResRateList(lrc::api::video::Channel channel, QString device) { auto deviceCapabilities = get_DeviceCapabilities(device); @@ -131,13 +98,13 @@ SettingsAdaptor::get_ResRateList(lrc::api::video::Channel channel, QString devic } int -SettingsAdaptor::get_DeviceCapabilitiesSize(const QString &device) +SettingsAdapter::get_DeviceCapabilitiesSize(const QString &device) { return get_DeviceCapabilities(device).size(); } QVector<QString> -SettingsAdaptor::getResolutions(const QString &device) +SettingsAdapter::getResolutions(const QString &device) { QVector<QString> resolutions; @@ -155,7 +122,7 @@ SettingsAdaptor::getResolutions(const QString &device) } QVector<int> -SettingsAdaptor::getFrameRates(const QString &device) +SettingsAdapter::getFrameRates(const QString &device) { QVector<int> rates; @@ -173,13 +140,13 @@ SettingsAdaptor::getFrameRates(const QString &device) } lrc::api::video::Capabilities -SettingsAdaptor::get_DeviceCapabilities(const QString &device) +SettingsAdapter::get_DeviceCapabilities(const QString &device) { return LRCInstance::avModel().getDeviceCapabilities(device); } QString -SettingsAdaptor::get_Video_Settings_Channel(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Channel(const QString &deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -187,7 +154,7 @@ SettingsAdaptor::get_Video_Settings_Channel(const QString &deviceId) } QString -SettingsAdaptor::get_Video_Settings_Name(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Name(const QString &deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -195,7 +162,7 @@ SettingsAdaptor::get_Video_Settings_Name(const QString &deviceId) } QString -SettingsAdaptor::get_Video_Settings_Id(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Id(const QString &deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -203,7 +170,7 @@ SettingsAdaptor::get_Video_Settings_Id(const QString &deviceId) } qreal -SettingsAdaptor::get_Video_Settings_Rate(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Rate(const QString &deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -211,7 +178,7 @@ SettingsAdaptor::get_Video_Settings_Rate(const QString &deviceId) } QString -SettingsAdaptor::get_Video_Settings_Size(const QString &deviceId) +SettingsAdapter::get_Video_Settings_Size(const QString &deviceId) { auto settings = LRCInstance::avModel().getDeviceSettings(deviceId); @@ -219,7 +186,7 @@ SettingsAdaptor::get_Video_Settings_Size(const QString &deviceId) } void -SettingsAdaptor::set_Video_Settings_Rate_And_Resolution(const QString &deviceId, +SettingsAdapter::set_Video_Settings_Rate_And_Resolution(const QString &deviceId, qreal rate, const QString &resolution) { @@ -230,73 +197,73 @@ SettingsAdaptor::set_Video_Settings_Rate_And_Resolution(const QString &deviceId, } const lrc::api::account::Info & -SettingsAdaptor::getCurrentAccountInfo() +SettingsAdapter::getCurrentAccountInfo() { return LRCInstance::getCurrentAccountInfo(); } const Q_INVOKABLE lrc::api::profile::Info & -SettingsAdaptor::getCurrentAccount_Profile_Info() +SettingsAdapter::getCurrentAccount_Profile_Info() { return LRCInstance::getCurrentAccountInfo().profileInfo; } lrc::api::ContactModel * -SettingsAdaptor::getContactModel() +SettingsAdapter::getContactModel() { return getCurrentAccountInfo().contactModel.get(); } lrc::api::NewDeviceModel * -SettingsAdaptor::getDeviceModel() +SettingsAdapter::getDeviceModel() { return getCurrentAccountInfo().deviceModel.get(); } QString -SettingsAdaptor::get_CurrentAccountInfo_RegisteredName() +SettingsAdapter::get_CurrentAccountInfo_RegisteredName() { return LRCInstance::getCurrentAccountInfo().registeredName; } QString -SettingsAdaptor::get_CurrentAccountInfo_Id() +SettingsAdapter::get_CurrentAccountInfo_Id() { return LRCInstance::getCurrentAccountInfo().id; } bool -SettingsAdaptor::get_CurrentAccountInfo_Enabled() +SettingsAdapter::get_CurrentAccountInfo_Enabled() { return LRCInstance::getCurrentAccountInfo().enabled; } QString -SettingsAdaptor::getCurrentAccount_Profile_Info_Uri() +SettingsAdapter::getCurrentAccount_Profile_Info_Uri() { return getCurrentAccount_Profile_Info().uri; } QString -SettingsAdaptor::getCurrentAccount_Profile_Info_Alias() +SettingsAdapter::getCurrentAccount_Profile_Info_Alias() { return getCurrentAccount_Profile_Info().alias; } int -SettingsAdaptor::getCurrentAccount_Profile_Info_Type() +SettingsAdapter::getCurrentAccount_Profile_Info_Type() { return (int) (getCurrentAccount_Profile_Info().type); } QString -SettingsAdaptor::getAccountBestName() +SettingsAdapter::getAccountBestName() { return Utils::bestNameForAccount(LRCInstance::getCurrentAccountInfo()); } QString -SettingsAdaptor::getAvatarImage_Base64(int avatarSize) +SettingsAdapter::getAvatarImage_Base64(int avatarSize) { auto &accountInfo = LRCInstance::getCurrentAccountInfo(); auto avatar = Utils::accountPhoto(accountInfo, {avatarSize, avatarSize}); @@ -305,7 +272,7 @@ SettingsAdaptor::getAvatarImage_Base64(int avatarSize) } bool -SettingsAdaptor::getIsDefaultAvatar() +SettingsAdapter::getIsDefaultAvatar() { auto &accountInfo = LRCInstance::getCurrentAccountInfo(); @@ -313,7 +280,7 @@ SettingsAdaptor::getIsDefaultAvatar() } bool -SettingsAdaptor::setCurrAccAvatar(QString avatarImgBase64) +SettingsAdapter::setCurrAccAvatar(QString avatarImgBase64) { QImage avatarImg; const bool ret = avatarImg.loadFromData(QByteArray::fromBase64(avatarImgBase64.toLatin1())); @@ -327,13 +294,13 @@ SettingsAdaptor::setCurrAccAvatar(QString avatarImgBase64) } void -SettingsAdaptor::clearCurrentAvatar() +SettingsAdapter::clearCurrentAvatar() { LRCInstance::setCurrAccAvatar(QPixmap()); } lrc::api::account::ConfProperties_t -SettingsAdaptor::getAccountConfig() +SettingsAdapter::getAccountConfig() { lrc::api::account::ConfProperties_t res; try { @@ -343,283 +310,283 @@ SettingsAdaptor::getAccountConfig() } QString -SettingsAdaptor::getAccountConfig_Manageruri() +SettingsAdapter::getAccountConfig_Manageruri() { return getAccountConfig().managerUri; } QString -SettingsAdaptor::getAccountConfig_Username() +SettingsAdapter::getAccountConfig_Username() { return getAccountConfig().username; } QString -SettingsAdaptor::getAccountConfig_Hostname() +SettingsAdapter::getAccountConfig_Hostname() { return getAccountConfig().hostname; } QString -SettingsAdaptor::getAccountConfig_Password() +SettingsAdapter::getAccountConfig_Password() { return getAccountConfig().password; } QString -SettingsAdaptor::getAccountConfig_ProxyServer() +SettingsAdapter::getAccountConfig_ProxyServer() { return getAccountConfig().proxyServer; } bool -SettingsAdaptor::getAccountConfig_PeerDiscovery() +SettingsAdapter::getAccountConfig_PeerDiscovery() { return getAccountConfig().peerDiscovery; } bool -SettingsAdaptor::getAccountConfig_DHT_PublicInCalls() +SettingsAdapter::getAccountConfig_DHT_PublicInCalls() { return getAccountConfig().DHT.PublicInCalls; } bool -SettingsAdaptor::getAccountConfig_RendezVous() +SettingsAdapter::getAccountConfig_RendezVous() { return getAccountConfig().isRendezVous; } bool -SettingsAdaptor::getAccountConfig_AutoAnswer() +SettingsAdapter::getAccountConfig_AutoAnswer() { return getAccountConfig().autoAnswer; } QString -SettingsAdaptor::getAccountConfig_RingNS_Uri() +SettingsAdapter::getAccountConfig_RingNS_Uri() { return getAccountConfig().RingNS.uri; } bool -SettingsAdaptor::getAccountConfig_ProxyEnabled() +SettingsAdapter::getAccountConfig_ProxyEnabled() { return getAccountConfig().proxyEnabled; } QString -SettingsAdaptor::getAccountConfig_TLS_CertificateListFile() +SettingsAdapter::getAccountConfig_TLS_CertificateListFile() { return getAccountConfig().TLS.certificateListFile; } QString -SettingsAdaptor::getAccountConfig_TLS_CertificateFile() +SettingsAdapter::getAccountConfig_TLS_CertificateFile() { return getAccountConfig().TLS.certificateFile; } QString -SettingsAdaptor::getAccountConfig_TLS_PrivateKeyFile() +SettingsAdapter::getAccountConfig_TLS_PrivateKeyFile() { return getAccountConfig().TLS.privateKeyFile; } bool -SettingsAdaptor::getAccountConfig_TLS_Enable() +SettingsAdapter::getAccountConfig_TLS_Enable() { return getAccountConfig().TLS.enable; } QString -SettingsAdaptor::getAccountConfig_TLS_Password() +SettingsAdapter::getAccountConfig_TLS_Password() { return getAccountConfig().TLS.password; } bool -SettingsAdaptor::getAccountConfig_TLS_VerifyServer() +SettingsAdapter::getAccountConfig_TLS_VerifyServer() { return getAccountConfig().TLS.verifyServer; } bool -SettingsAdaptor::getAccountConfig_TLS_VerifyClient() +SettingsAdapter::getAccountConfig_TLS_VerifyClient() { return getAccountConfig().TLS.verifyClient; } bool -SettingsAdaptor::getAccountConfig_TLS_RequireClientCertificate() +SettingsAdapter::getAccountConfig_TLS_RequireClientCertificate() { return getAccountConfig().TLS.requireClientCertificate; } int -SettingsAdaptor::getAccountConfig_TLS_Method_inInt() +SettingsAdapter::getAccountConfig_TLS_Method_inInt() { return (int) getAccountConfig().TLS.method; } QString -SettingsAdaptor::getAccountConfig_TLS_Servername() +SettingsAdapter::getAccountConfig_TLS_Servername() { return getAccountConfig().TLS.serverName; } int -SettingsAdaptor::getAccountConfig_TLS_NegotiationTimeoutSec() +SettingsAdapter::getAccountConfig_TLS_NegotiationTimeoutSec() { return getAccountConfig().TLS.negotiationTimeoutSec; } bool -SettingsAdaptor::getAccountConfig_SRTP_Enabled() +SettingsAdapter::getAccountConfig_SRTP_Enabled() { return getAccountConfig().SRTP.enable; } int -SettingsAdaptor::getAccountConfig_SRTP_KeyExchange() +SettingsAdapter::getAccountConfig_SRTP_KeyExchange() { return (int) getAccountConfig().SRTP.keyExchange; } bool -SettingsAdaptor::getAccountConfig_SRTP_RtpFallback() +SettingsAdapter::getAccountConfig_SRTP_RtpFallback() { return getAccountConfig().SRTP.rtpFallback; } bool -SettingsAdaptor::getAccountConfig_UpnpEnabled() +SettingsAdapter::getAccountConfig_UpnpEnabled() { return getAccountConfig().upnpEnabled; } bool -SettingsAdaptor::getAccountConfig_TURN_Enabled() +SettingsAdapter::getAccountConfig_TURN_Enabled() { return getAccountConfig().TURN.enable; } QString -SettingsAdaptor::getAccountConfig_TURN_Server() +SettingsAdapter::getAccountConfig_TURN_Server() { return getAccountConfig().TURN.server; } QString -SettingsAdaptor::getAccountConfig_TURN_Username() +SettingsAdapter::getAccountConfig_TURN_Username() { return getAccountConfig().TURN.username; } QString -SettingsAdaptor::getAccountConfig_TURN_Password() +SettingsAdapter::getAccountConfig_TURN_Password() { return getAccountConfig().TURN.password; } QString -SettingsAdaptor::getAccountConfig_TURN_Realm() +SettingsAdapter::getAccountConfig_TURN_Realm() { return getAccountConfig().TURN.realm; } bool -SettingsAdaptor::getAccountConfig_STUN_Enabled() +SettingsAdapter::getAccountConfig_STUN_Enabled() { return getAccountConfig().STUN.enable; } QString -SettingsAdaptor::getAccountConfig_STUN_Server() +SettingsAdapter::getAccountConfig_STUN_Server() { return getAccountConfig().STUN.server; } bool -SettingsAdaptor::getAccountConfig_Video_Enabled() +SettingsAdapter::getAccountConfig_Video_Enabled() { return getAccountConfig().Video.videoEnabled; } int -SettingsAdaptor::getAccountConfig_Video_VideoPortMin() +SettingsAdapter::getAccountConfig_Video_VideoPortMin() { return getAccountConfig().Video.videoPortMin; } int -SettingsAdaptor::getAccountConfig_Video_VideoPortMax() +SettingsAdapter::getAccountConfig_Video_VideoPortMax() { return getAccountConfig().Video.videoPortMax; } int -SettingsAdaptor::getAccountConfig_Audio_AudioPortMin() +SettingsAdapter::getAccountConfig_Audio_AudioPortMin() { return getAccountConfig().Audio.audioPortMin; } int -SettingsAdaptor::getAccountConfig_Audio_AudioPortMax() +SettingsAdapter::getAccountConfig_Audio_AudioPortMax() { return getAccountConfig().Audio.audioPortMax; } bool -SettingsAdaptor::getAccountConfig_Ringtone_RingtoneEnabled() +SettingsAdapter::getAccountConfig_Ringtone_RingtoneEnabled() { return getAccountConfig().Ringtone.ringtoneEnabled; } QString -SettingsAdaptor::getAccountConfig_Ringtone_RingtonePath() +SettingsAdapter::getAccountConfig_Ringtone_RingtonePath() { return getAccountConfig().Ringtone.ringtonePath; } int -SettingsAdaptor::getAccountConfig_Registration_Expire() +SettingsAdapter::getAccountConfig_Registration_Expire() { return getAccountConfig().Registration.expire; } int -SettingsAdaptor::getAccountConfig_Localport() +SettingsAdapter::getAccountConfig_Localport() { return getAccountConfig().localPort; } bool -SettingsAdaptor::getAccountConfig_PublishedSameAsLocal() +SettingsAdapter::getAccountConfig_PublishedSameAsLocal() { return getAccountConfig().publishedSameAsLocal; } QString -SettingsAdaptor::getAccountConfig_PublishedAddress() +SettingsAdapter::getAccountConfig_PublishedAddress() { return getAccountConfig().publishedAddress; } int -SettingsAdaptor::getAccountConfig_PublishedPort() +SettingsAdapter::getAccountConfig_PublishedPort() { return getAccountConfig().publishedPort; } QString -SettingsAdaptor::getAccountConfig_Mailbox() +SettingsAdapter::getAccountConfig_Mailbox() { return getAccountConfig().mailbox; } void -SettingsAdaptor::setAccountConfig_Username(QString input) +SettingsAdapter::setAccountConfig_Username(QString input) { auto confProps = getAccountConfig(); confProps.username = input; @@ -627,7 +594,7 @@ SettingsAdaptor::setAccountConfig_Username(QString input) } void -SettingsAdaptor::setAccountConfig_Hostname(QString input) +SettingsAdapter::setAccountConfig_Hostname(QString input) { auto confProps = getAccountConfig(); confProps.hostname = input; @@ -635,7 +602,7 @@ SettingsAdaptor::setAccountConfig_Hostname(QString input) } void -SettingsAdaptor::setAccountConfig_Password(QString input) +SettingsAdapter::setAccountConfig_Password(QString input) { auto confProps = getAccountConfig(); confProps.password = input; @@ -643,7 +610,7 @@ SettingsAdaptor::setAccountConfig_Password(QString input) } void -SettingsAdaptor::setAccountConfig_ProxyServer(QString input) +SettingsAdapter::setAccountConfig_ProxyServer(QString input) { auto confProps = getAccountConfig(); confProps.proxyServer = input; @@ -651,7 +618,7 @@ SettingsAdaptor::setAccountConfig_ProxyServer(QString input) } void -SettingsAdaptor::setAutoConnectOnLocalNetwork(bool state) +SettingsAdapter::setAutoConnectOnLocalNetwork(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.peerDiscovery = state; @@ -659,7 +626,7 @@ SettingsAdaptor::setAutoConnectOnLocalNetwork(bool state) } void -SettingsAdaptor::setCallsUntrusted(bool state) +SettingsAdapter::setCallsUntrusted(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.DHT.PublicInCalls = state; @@ -667,7 +634,7 @@ SettingsAdaptor::setCallsUntrusted(bool state) } void -SettingsAdaptor::setIsRendezVous(bool state) +SettingsAdapter::setIsRendezVous(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.isRendezVous = state; @@ -676,7 +643,7 @@ SettingsAdaptor::setIsRendezVous(bool state) void -SettingsAdaptor::setAutoAnswerCalls(bool state) +SettingsAdapter::setAutoAnswerCalls(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.autoAnswer = state; @@ -684,7 +651,7 @@ SettingsAdaptor::setAutoAnswerCalls(bool state) } void -SettingsAdaptor::setEnableRingtone(bool state) +SettingsAdapter::setEnableRingtone(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Ringtone.ringtoneEnabled = state; @@ -692,7 +659,7 @@ SettingsAdaptor::setEnableRingtone(bool state) } void -SettingsAdaptor::setEnableProxy(bool state) +SettingsAdapter::setEnableProxy(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.proxyEnabled = state; @@ -700,7 +667,7 @@ SettingsAdaptor::setEnableProxy(bool state) } void -SettingsAdaptor::setUseUPnP(bool state) +SettingsAdapter::setUseUPnP(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.upnpEnabled = state; @@ -708,7 +675,7 @@ SettingsAdaptor::setUseUPnP(bool state) } void -SettingsAdaptor::setUseTURN(bool state) +SettingsAdapter::setUseTURN(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TURN.enable = state; @@ -716,7 +683,7 @@ SettingsAdaptor::setUseTURN(bool state) } void -SettingsAdaptor::setUseSTUN(bool state) +SettingsAdapter::setUseSTUN(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.STUN.enable = state; @@ -724,7 +691,7 @@ SettingsAdaptor::setUseSTUN(bool state) } void -SettingsAdaptor::setVideoState(bool state) +SettingsAdapter::setVideoState(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Video.videoEnabled = state; @@ -732,7 +699,7 @@ SettingsAdaptor::setVideoState(bool state) } void -SettingsAdaptor::setUseSRTP(bool state) +SettingsAdapter::setUseSRTP(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.SRTP.enable = state; @@ -740,7 +707,7 @@ SettingsAdaptor::setUseSRTP(bool state) } void -SettingsAdaptor::setUseSDES(bool state) +SettingsAdapter::setUseSDES(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.SRTP.keyExchange = state ? lrc::api::account::KeyExchangeProtocol::SDES @@ -749,7 +716,7 @@ SettingsAdaptor::setUseSDES(bool state) } void -SettingsAdaptor::setUseRTPFallback(bool state) +SettingsAdapter::setUseRTPFallback(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.SRTP.rtpFallback = state; @@ -757,7 +724,7 @@ SettingsAdaptor::setUseRTPFallback(bool state) } void -SettingsAdaptor::setUseTLS(bool state) +SettingsAdapter::setUseTLS(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.enable = state; @@ -765,7 +732,7 @@ SettingsAdaptor::setUseTLS(bool state) } void -SettingsAdaptor::setVerifyCertificatesServer(bool state) +SettingsAdapter::setVerifyCertificatesServer(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.verifyServer = state; @@ -773,7 +740,7 @@ SettingsAdaptor::setVerifyCertificatesServer(bool state) } void -SettingsAdaptor::setVerifyCertificatesClient(bool state) +SettingsAdapter::setVerifyCertificatesClient(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.verifyClient = state; @@ -781,7 +748,7 @@ SettingsAdaptor::setVerifyCertificatesClient(bool state) } void -SettingsAdaptor::setRequireCertificatesIncomingTLS(bool state) +SettingsAdapter::setRequireCertificatesIncomingTLS(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.requireClientCertificate = state; @@ -789,7 +756,7 @@ SettingsAdaptor::setRequireCertificatesIncomingTLS(bool state) } void -SettingsAdaptor::setUseCustomAddressAndPort(bool state) +SettingsAdapter::setUseCustomAddressAndPort(bool state) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.publishedSameAsLocal = state; @@ -797,7 +764,7 @@ SettingsAdaptor::setUseCustomAddressAndPort(bool state) } void -SettingsAdaptor::setNameServer(QString text) +SettingsAdapter::setNameServer(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.RingNS.uri = text; @@ -805,7 +772,7 @@ SettingsAdaptor::setNameServer(QString text) } void -SettingsAdaptor::setProxyAddress(QString text) +SettingsAdapter::setProxyAddress(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.proxyServer = text; @@ -813,7 +780,7 @@ SettingsAdaptor::setProxyAddress(QString text) } void -SettingsAdaptor::setBootstrapAddress(QString text) +SettingsAdapter::setBootstrapAddress(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.hostname = text; @@ -821,7 +788,7 @@ SettingsAdaptor::setBootstrapAddress(QString text) } void -SettingsAdaptor::setTURNAddress(QString text) +SettingsAdapter::setTURNAddress(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TURN.server = text; @@ -829,7 +796,7 @@ SettingsAdaptor::setTURNAddress(QString text) } void -SettingsAdaptor::setTURNUsername(QString text) +SettingsAdapter::setTURNUsername(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TURN.username = text; @@ -837,7 +804,7 @@ SettingsAdaptor::setTURNUsername(QString text) } void -SettingsAdaptor::setTURNPassword(QString text) +SettingsAdapter::setTURNPassword(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TURN.password = text; @@ -845,7 +812,7 @@ SettingsAdaptor::setTURNPassword(QString text) } void -SettingsAdaptor::setTURNRealm(QString text) +SettingsAdapter::setTURNRealm(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TURN.realm = text; @@ -853,7 +820,7 @@ SettingsAdaptor::setTURNRealm(QString text) } void -SettingsAdaptor::setSTUNAddress(QString text) +SettingsAdapter::setSTUNAddress(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.STUN.server = text; @@ -861,7 +828,7 @@ SettingsAdaptor::setSTUNAddress(QString text) } void -SettingsAdaptor::lineEditVoiceMailDialCodeEditFinished(QString text) +SettingsAdapter::lineEditVoiceMailDialCodeEditFinished(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.mailbox = text; @@ -869,7 +836,7 @@ SettingsAdaptor::lineEditVoiceMailDialCodeEditFinished(QString text) } void -SettingsAdaptor::outgoingTLSServerNameLineEditTextChanged(QString text) +SettingsAdapter::outgoingTLSServerNameLineEditTextChanged(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.serverName = text; @@ -877,7 +844,7 @@ SettingsAdaptor::outgoingTLSServerNameLineEditTextChanged(QString text) } void -SettingsAdaptor::lineEditSIPCertPasswordLineEditTextChanged(QString text) +SettingsAdapter::lineEditSIPCertPasswordLineEditTextChanged(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.password = text; @@ -885,7 +852,7 @@ SettingsAdaptor::lineEditSIPCertPasswordLineEditTextChanged(QString text) } void -SettingsAdaptor::lineEditSIPCustomAddressLineEditTextChanged(QString text) +SettingsAdapter::lineEditSIPCustomAddressLineEditTextChanged(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.publishedAddress = text; @@ -893,7 +860,7 @@ SettingsAdaptor::lineEditSIPCustomAddressLineEditTextChanged(QString text) } void -SettingsAdaptor::customPortSIPSpinBoxValueChanged(int value) +SettingsAdapter::customPortSIPSpinBoxValueChanged(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.publishedPort = value; @@ -901,7 +868,7 @@ SettingsAdaptor::customPortSIPSpinBoxValueChanged(int value) } void -SettingsAdaptor::negotiationTimeoutSpinBoxValueChanged(int value) +SettingsAdapter::negotiationTimeoutSpinBoxValueChanged(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.negotiationTimeoutSec = value; @@ -909,7 +876,7 @@ SettingsAdaptor::negotiationTimeoutSpinBoxValueChanged(int value) } void -SettingsAdaptor::registrationTimeoutSpinBoxValueChanged(int value) +SettingsAdapter::registrationTimeoutSpinBoxValueChanged(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Registration.expire = value; @@ -917,7 +884,7 @@ SettingsAdaptor::registrationTimeoutSpinBoxValueChanged(int value) } void -SettingsAdaptor::networkInterfaceSpinBoxValueChanged(int value) +SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.localPort = value; @@ -925,7 +892,7 @@ SettingsAdaptor::networkInterfaceSpinBoxValueChanged(int value) } void -SettingsAdaptor::audioRTPMinPortSpinBoxEditFinished(int value) +SettingsAdapter::audioRTPMinPortSpinBoxEditFinished(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Audio.audioPortMin = value; @@ -933,7 +900,7 @@ SettingsAdaptor::audioRTPMinPortSpinBoxEditFinished(int value) } void -SettingsAdaptor::audioRTPMaxPortSpinBoxEditFinished(int value) +SettingsAdapter::audioRTPMaxPortSpinBoxEditFinished(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Audio.audioPortMax = value; @@ -941,7 +908,7 @@ SettingsAdaptor::audioRTPMaxPortSpinBoxEditFinished(int value) } void -SettingsAdaptor::videoRTPMinPortSpinBoxEditFinished(int value) +SettingsAdapter::videoRTPMinPortSpinBoxEditFinished(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Video.videoPortMin = value; @@ -949,7 +916,7 @@ SettingsAdaptor::videoRTPMinPortSpinBoxEditFinished(int value) } void -SettingsAdaptor::videoRTPMaxPortSpinBoxEditFinished(int value) +SettingsAdapter::videoRTPMaxPortSpinBoxEditFinished(int value) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Video.videoPortMax = value; @@ -957,7 +924,7 @@ SettingsAdaptor::videoRTPMaxPortSpinBoxEditFinished(int value) } void -SettingsAdaptor::tlsProtocolComboBoxIndexChanged(const int &index) +SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int &index) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); @@ -976,7 +943,7 @@ SettingsAdaptor::tlsProtocolComboBoxIndexChanged(const int &index) } void -SettingsAdaptor::setDeviceName(QString text) +SettingsAdapter::setDeviceName(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.deviceName = text; @@ -984,7 +951,7 @@ SettingsAdaptor::setDeviceName(QString text) } void -SettingsAdaptor::unbanContact(int index) +SettingsAdapter::unbanContact(int index) { auto bannedContactList = LRCInstance::getCurrentAccountInfo().contactModel->getBannedContacts(); auto it = bannedContactList.begin(); @@ -996,45 +963,45 @@ SettingsAdaptor::unbanContact(int index) } void -SettingsAdaptor::audioCodecsStateChange(unsigned int id, bool isToEnable) +SettingsAdapter::audioCodecsStateChange(unsigned int id, bool isToEnable) { auto audioCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getAudioCodecs(); LRCInstance::getCurrentAccountInfo().codecModel->enable(id, isToEnable); } void -SettingsAdaptor::videoCodecsStateChange(unsigned int id, bool isToEnable) +SettingsAdapter::videoCodecsStateChange(unsigned int id, bool isToEnable) { auto videoCodecList = LRCInstance::getCurrentAccountInfo().codecModel->getVideoCodecs(); LRCInstance::getCurrentAccountInfo().codecModel->enable(id, isToEnable); } void -SettingsAdaptor::decreaseAudioCodecPriority(unsigned int id) +SettingsAdapter::decreaseAudioCodecPriority(unsigned int id) { LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(id, false); } void -SettingsAdaptor::increaseAudioCodecPriority(unsigned int id) +SettingsAdapter::increaseAudioCodecPriority(unsigned int id) { LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(id, false); } void -SettingsAdaptor::decreaseVideoCodecPriority(unsigned int id) +SettingsAdapter::decreaseVideoCodecPriority(unsigned int id) { LRCInstance::getCurrentAccountInfo().codecModel->decreasePriority(id, true); } void -SettingsAdaptor::increaseVideoCodecPriority(unsigned int id) +SettingsAdapter::increaseVideoCodecPriority(unsigned int id) { LRCInstance::getCurrentAccountInfo().codecModel->increasePriority(id, true); } void -SettingsAdaptor::set_RingtonePath(QString text) +SettingsAdapter::set_RingtonePath(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.Ringtone.ringtonePath = text; @@ -1042,7 +1009,7 @@ SettingsAdaptor::set_RingtonePath(QString text) } void -SettingsAdaptor::set_FileCACert(QString text) +SettingsAdapter::set_FileCACert(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.certificateListFile = text; @@ -1050,7 +1017,7 @@ SettingsAdaptor::set_FileCACert(QString text) } void -SettingsAdaptor::set_FileUserCert(QString text) +SettingsAdapter::set_FileUserCert(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.certificateFile = text; @@ -1058,7 +1025,7 @@ SettingsAdaptor::set_FileUserCert(QString text) } void -SettingsAdaptor::set_FilePrivateKey(QString text) +SettingsAdapter::set_FilePrivateKey(QString text) { auto confProps = LRCInstance::accountModel().getAccountConfig(LRCInstance::getCurrAccId()); confProps.TLS.privateKeyFile = text; diff --git a/src/settingsadaptor.h b/src/settingsadapter.h similarity index 94% rename from src/settingsadaptor.h rename to src/settingsadapter.h index b342b9bfd..9532160ed 100644 --- a/src/settingsadaptor.h +++ b/src/settingsadapter.h @@ -27,30 +27,23 @@ #include "typedefs.h" #include "utils.h" -class SettingsAdaptor : public QObject +class SettingsAdapter : public QObject { Q_OBJECT public: - explicit SettingsAdaptor(QObject *parent = nullptr); + explicit SettingsAdapter(QObject *parent = nullptr); //Singleton - static SettingsAdaptor &instance(); + static SettingsAdapter &instance(); /* * getters of directories */ Q_INVOKABLE QString getDir_Document(); Q_INVOKABLE QString getDir_Download(); - /* - * getters and setters of app settings options - */ - Q_INVOKABLE bool getSettingsValue_CloseOrMinimized(); - Q_INVOKABLE bool getSettingsValue_EnableNotifications(); - Q_INVOKABLE bool getSettingsValue_AutoUpdate(); + Q_INVOKABLE QVariant getAppValue(const Settings::Key key); + Q_INVOKABLE void setAppValue(const Settings::Key key, const QVariant& value); - Q_INVOKABLE void setClosedOrMin(bool state); - Q_INVOKABLE void setNotifications(bool state); - Q_INVOKABLE void setUpdateAutomatic(bool state); Q_INVOKABLE void setRunOnStartUp(bool state); Q_INVOKABLE void setDownloadPath(QString dir); @@ -237,5 +230,6 @@ public: Q_INVOKABLE void set_FileCACert(QString text); Q_INVOKABLE void set_FileUserCert(QString text); Q_INVOKABLE void set_FilePrivateKey(QString text); + }; -Q_DECLARE_METATYPE(SettingsAdaptor *) +Q_DECLARE_METATYPE(SettingsAdapter *) diff --git a/src/settingskey.h b/src/settingskey.h deleted file mode 100644 index 6c82598f4..000000000 --- a/src/settingskey.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (C) 2015-2020 by Savoir-faire Linux - * Author: Edric Ladent Milaret <edric.ladent-milaret@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 <https://www.gnu.org/licenses/>. - */ - -#pragma once - -namespace SettingsKey { - -constexpr static char closeOrMinimized[] = "closeOrMin"; -constexpr static char downloadPath[] = "downloadPath"; -constexpr static char enableNotifications[] = "enableNotifications"; -constexpr static char geometry[] = "geometry"; -constexpr static char selectedAccount[] = "selectedAccount"; -constexpr static char mainSplitterState[] = "mainSplitterState"; -constexpr static char smartListToWebviewSplitterState[] = "smartListToWebviewSplitterState"; -constexpr static char windowState[] = "windowState"; -constexpr static char autoUpdate[] = "autoUpdate"; -constexpr static char neverShowMeAgain[] = "neverShowMeAgain"; -constexpr static char hasRun[] = "hasRun"; -} // namespace SettingsKey diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index d502c773f..6b368a05f 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -23,6 +23,7 @@ import QtQuick.Controls.Universal 2.12 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "components" @@ -44,7 +45,7 @@ Rectangle { } function setSelected(sel, recovery = false){ - profileType = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Type() + profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() if(selectedMenu === sel && (!recovery)){return} switch(sel){ @@ -135,7 +136,7 @@ Rectangle { ClientWrapper.avmodel.setCurrentVideoCaptureDevice(device) } } - property int profileType: ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Type() + property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() property int selectedMenu: SettingsView.Account diff --git a/src/settingsview/components/AdvancedSIPSettingsView.qml b/src/settingsview/components/AdvancedSIPSettingsView.qml index 140a40876..98280a16e 100644 --- a/src/settingsview/components/AdvancedSIPSettingsView.qml +++ b/src/settingsview/components/AdvancedSIPSettingsView.qml @@ -26,82 +26,83 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.3 import Qt.labs.platform 1.1 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" ColumnLayout { function updateAccountInfoDisplayedAdvanceSIP(){ // Call Settings - checkBoxAutoAnswerSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_AutoAnswer() - checkBoxCustomRingtoneSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtoneEnabled() + checkBoxAutoAnswerSIP.checked = SettingsAdapter.getAccountConfig_AutoAnswer() + checkBoxCustomRingtoneSIP.checked = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() // security - btnSIPCACert.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Enable() - btnSIPUserCert.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Enable() - btnSIPPrivateKey.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Enable() - lineEditSIPCertPassword.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Enable() - enableSDESToggle.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_SRTP_Enabled() - fallbackRTPToggle.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_SRTP_Enabled() - - btnSIPCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateListFile()) - btnSIPUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateFile()) - btnSIPPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_PrivateKeyFile()) - lineEditSIPCertPassword.text = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Password() - - encryptMediaStreamsToggle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_SRTP_Enabled() - enableSDESToggle.checked = (ClientWrapper.settingsAdaptor.getAccountConfig_SRTP_KeyExchange() === Account.KeyExchangeProtocol.SDES) - fallbackRTPToggle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_SRTP_RtpFallback() - encryptNegotitationToggle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Enable() - verifyIncomingCertificatesServerToogle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_VerifyServer() - verifyIncomingCertificatesClientToogle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_VerifyClient() - requireCeritificateForTLSIncomingToggle.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_RequireClientCertificate() - - var method = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Method_inInt() + btnSIPCACert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() + btnSIPUserCert.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() + btnSIPPrivateKey.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() + lineEditSIPCertPassword.enabled = SettingsAdapter.getAccountConfig_TLS_Enable() + enableSDESToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() + fallbackRTPToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() + + btnSIPCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) + btnSIPUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) + btnSIPPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) + lineEditSIPCertPassword.text = SettingsAdapter.getAccountConfig_TLS_Password() + + encryptMediaStreamsToggle.checked = SettingsAdapter.getAccountConfig_SRTP_Enabled() + enableSDESToggle.checked = (ClientWrapper.SettingsAdapter.getAccountConfig_SRTP_KeyExchange() === Account.KeyExchangeProtocol.SDES) + fallbackRTPToggle.checked = SettingsAdapter.getAccountConfig_SRTP_RtpFallback() + encryptNegotitationToggle.checked = SettingsAdapter.getAccountConfig_TLS_Enable() + verifyIncomingCertificatesServerToogle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyServer() + verifyIncomingCertificatesClientToogle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyClient() + requireCeritificateForTLSIncomingToggle.checked = SettingsAdapter.getAccountConfig_TLS_RequireClientCertificate() + + var method = SettingsAdapter.getAccountConfig_TLS_Method_inInt() tlsProtocolComboBox.currentIndex = method - outgoingTLSServerNameLineEdit.text = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_Servername() - negotiationTimeoutSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_TLS_NegotiationTimeoutSec() + outgoingTLSServerNameLineEdit.text = SettingsAdapter.getAccountConfig_TLS_Servername() + negotiationTimeoutSpinBox.value = SettingsAdapter.getAccountConfig_TLS_NegotiationTimeoutSec() // Connectivity - checkBoxUPnPSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_UpnpEnabled() - checkBoxTurnEnableSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - lineEditTurnAddressSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Server() - lineEditTurnUsernameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Username() - lineEditTurnPsswdSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Password() - lineEditTurnRealmSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Realm() - lineEditTurnAddressSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - lineEditTurnUsernameSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - lineEditTurnPsswdSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - lineEditTurnRealmSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - - checkBoxSTUNEnableSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Enabled() - lineEditSTUNAddressSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Server() - lineEditSTUNAddressSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Enabled() - - registrationExpireTimeoutSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Registration_Expire() - networkInterfaceSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Localport() + checkBoxUPnPSIP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled() + checkBoxTurnEnableSIP.checked = SettingsAdapter.getAccountConfig_TURN_Enabled() + lineEditTurnAddressSIP.text = SettingsAdapter.getAccountConfig_TURN_Server() + lineEditTurnUsernameSIP.text = SettingsAdapter.getAccountConfig_TURN_Username() + lineEditTurnPsswdSIP.text = SettingsAdapter.getAccountConfig_TURN_Password() + lineEditTurnRealmSIP.text = SettingsAdapter.getAccountConfig_TURN_Realm() + lineEditTurnAddressSIP.enabled = SettingsAdapter.getAccountConfig_TURN_Enabled() + lineEditTurnUsernameSIP.enabled = SettingsAdapter.getAccountConfig_TURN_Enabled() + lineEditTurnPsswdSIP.enabled = SettingsAdapter.getAccountConfig_TURN_Enabled() + lineEditTurnRealmSIP.enabled = SettingsAdapter.getAccountConfig_TURN_Enabled() + + checkBoxSTUNEnableSIP.checked = SettingsAdapter.getAccountConfig_STUN_Enabled() + lineEditSTUNAddressSIP.text = SettingsAdapter.getAccountConfig_STUN_Server() + lineEditSTUNAddressSIP.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() + + registrationExpireTimeoutSpinBox.value = SettingsAdapter.getAccountConfig_Registration_Expire() + networkInterfaceSpinBox.value = SettingsAdapter.getAccountConfig_Localport() // published address - checkBoxCustomAddressPort.checked = ClientWrapper.settingsAdaptor.getAccountConfig_PublishedSameAsLocal() - lineEditSIPCustomAddress.text = ClientWrapper.settingsAdaptor.getAccountConfig_PublishedAddress() - customPortSIPSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_PublishedPort() + checkBoxCustomAddressPort.checked = SettingsAdapter.getAccountConfig_PublishedSameAsLocal() + lineEditSIPCustomAddress.text = SettingsAdapter.getAccountConfig_PublishedAddress() + customPortSIPSpinBox.value = SettingsAdapter.getAccountConfig_PublishedPort() // codecs - videoCheckBoxSIP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_Video_Enabled() + videoCheckBoxSIP.checked = SettingsAdapter.getAccountConfig_Video_Enabled() updateAudioCodecs() updateVideoCodecs() - btnRingtoneSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtoneEnabled() - btnRingtoneSIP.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath()) - lineEditSTUNAddressSIP.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Enabled() + btnRingtoneSIP.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() + btnRingtoneSIP.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) + lineEditSTUNAddressSIP.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() // SDP session negotiation ports - audioRTPMinPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMin() - audioRTPMaxPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMax() - videoRTPMinPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMin() - videoRTPMaxPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMax() + audioRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() + audioRTPMaxPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMax() + videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin() + videoRTPMaxPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMax() // voicemail - lineEditVoiceMailDialCode.text = ClientWrapper.settingsAdaptor.getAccountConfig_Mailbox() + lineEditVoiceMailDialCode.text = SettingsAdapter.getAccountConfig_Mailbox() } function updateAudioCodecs(){ @@ -122,7 +123,7 @@ ColumnLayout { var index = audioListWidgetSIP.currentIndex var codecId = audioCodecListModelSIP.data(audioCodecListModelSIP.index(index,0), AudioCodecListModel.AudioCodecID) - ClientWrapper.settingsAdaptor.decreaseAudioCodecPriority(codecId) + SettingsAdapter.decreaseAudioCodecPriority(codecId) audioListWidgetSIP.currentIndex = index + 1 updateAudioCodecs() } @@ -131,7 +132,7 @@ ColumnLayout { var index = audioListWidgetSIP.currentIndex var codecId = audioCodecListModelSIP.data(audioCodecListModelSIP.index(index,0), AudioCodecListModel.AudioCodecID) - ClientWrapper.settingsAdaptor.increaseAudioCodecPriority(codecId) + SettingsAdapter.increaseAudioCodecPriority(codecId) audioListWidgetSIP.currentIndex = index - 1 updateAudioCodecs() } @@ -140,7 +141,7 @@ ColumnLayout { var index = videoListWidgetSIP.currentIndex var codecId = videoCodecListModelSIP.data(videoCodecListModelSIP.index(index,0), VideoCodecListModel.VideoCodecID) - ClientWrapper.settingsAdaptor.decreaseVideoCodecPriority(codecId) + SettingsAdapter.decreaseVideoCodecPriority(codecId) videoListWidgetSIP.currentIndex = index + 1 updateVideoCodecs() } @@ -149,7 +150,7 @@ ColumnLayout { var index = videoListWidgetSIP.currentIndex var codecId = videoCodecListModelSIP.data(videoCodecListModelSIP.index(index,0), VideoCodecListModel.VideoCodecID) - ClientWrapper.settingsAdaptor.increaseVideoCodecPriority(codecId) + SettingsAdapter.increaseVideoCodecPriority(codecId) videoListWidgetSIP.currentIndex = index - 1 updateVideoCodecs() } @@ -165,64 +166,64 @@ ColumnLayout { // slots function audioRTPMinPortSpinBoxEditFinished(value){ - if (ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMax() < value) { - audioRTPMinPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMin() + if (ClientWrapper.SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) { + audioRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() return } - ClientWrapper.settingsAdaptor.audioRTPMinPortSpinBoxEditFinished(value) + SettingsAdapter.audioRTPMinPortSpinBoxEditFinished(value) } function audioRTPMaxPortSpinBoxEditFinished(value){ - if (value < ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMin()) { - audioRTPMaxPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Audio_AudioPortMax() + if (value <SettingsAdapter.getAccountConfig_Audio_AudioPortMin()) { + audioRTPMaxPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMax() return } - ClientWrapper.settingsAdaptor.audioRTPMaxPortSpinBoxEditFinished(value) + SettingsAdapter.audioRTPMaxPortSpinBoxEditFinished(value) } function videoRTPMinPortSpinBoxEditFinished(value){ - if (ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMax() < value) { - videoRTPMinPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMin() + if (ClientWrapper.SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) { + videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin() return } - ClientWrapper.settingsAdaptor.videoRTPMinPortSpinBoxEditFinished(value) + SettingsAdapter.videoRTPMinPortSpinBoxEditFinished(value) } function videoRTPMaxPortSpinBoxEditFinished(value){ - if (value < ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMin()) { - videoRTPMinPortSpinBox.value = ClientWrapper.settingsAdaptor.getAccountConfig_Video_VideoPortMin() + if (value <SettingsAdapter.getAccountConfig_Video_VideoPortMin()) { + videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin() return } - ClientWrapper.settingsAdaptor.videoRTPMaxPortSpinBoxEditFinished(value) + SettingsAdapter.videoRTPMaxPortSpinBoxEditFinished(value) } function changeRingtonePath(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_RingtonePath(url) + SettingsAdapter.set_RingtonePath(url) btnRingtoneSIP.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) - } else if (ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath().length === 0){ + } else if (ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ btnRingtoneSIP.text = qsTr("Add a custom ringtone") } } function changeFileCACert(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FileCACert(url) + SettingsAdapter.set_FileCACert(url) btnSIPCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } function changeFileUserCert(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FileUserCert(url) + SettingsAdapter.set_FileUserCert(url) btnSIPUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } function changeFilePrivateKey(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FilePrivateKey(url) + SettingsAdapter.set_FilePrivateKey(url) btnSIPPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } @@ -230,7 +231,7 @@ ColumnLayout { JamiFileDialog { id: ringtonePath_Dialog_SIP - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath() + property string oldPath : SettingsAdapter.getAccountConfig_Ringtone_RingtonePath() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -257,7 +258,7 @@ ColumnLayout { JamiFileDialog { id: caCert_Dialog_SIP - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateListFile() + property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateListFile() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -283,7 +284,7 @@ ColumnLayout { JamiFileDialog { id: userCert_Dialog_SIP - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateFile() + property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateFile() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -309,7 +310,7 @@ ColumnLayout { JamiFileDialog { id: privateKey_Dialog_SIP - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_TLS_PrivateKeyFile() + property string oldPath : SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -368,7 +369,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setAutoAnswerCalls(checked) + SettingsAdapter.setAutoAnswerCalls(checked) } } @@ -386,7 +387,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setEnableRingtone(checked) + SettingsAdapter.setEnableRingtone(checked) btnRingtoneSIP.enabled = checked } } @@ -489,7 +490,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.lineEditVoiceMailDialCodeEditFinished(text) + SettingsAdapter.lineEditVoiceMailDialCodeEditFinished(text) } } } @@ -523,7 +524,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseSRTP(checked) + SettingsAdapter.setUseSRTP(checked) enableSDESToggle.enabled = checked fallbackRTPToggle.enabled = checked } @@ -543,7 +544,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseSDES(checked) + SettingsAdapter.setUseSDES(checked) } } @@ -561,7 +562,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseRTPFallback(checked) + SettingsAdapter.setUseRTPFallback(checked) } } @@ -579,7 +580,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseTLS(checked) + SettingsAdapter.setUseTLS(checked) btnSIPCACert.enabled = checked btnSIPUserCert.enabled = checked btnSIPPrivateKey.enabled = checked @@ -730,7 +731,7 @@ ColumnLayout { echoMode: TextInput.Password onEditingFinished: { - ClientWrapper.settingsAdaptor.lineEditSIPCertPasswordLineEditTextChanged(text) + SettingsAdapter.lineEditSIPCertPasswordLineEditTextChanged(text) } } } @@ -742,7 +743,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setVerifyCertificatesServer(checked) + SettingsAdapter.setVerifyCertificatesServer(checked) } } @@ -760,7 +761,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setVerifyCertificatesClient(checked) + SettingsAdapter.setVerifyCertificatesClient(checked) } } @@ -778,7 +779,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setRequireCertificatesIncomingTLS(checked) + SettingsAdapter.setRequireCertificatesIncomingTLS(checked) } } @@ -834,7 +835,7 @@ ColumnLayout { onActivated: { var indexOfOption = tlsProtocolComboBox.model.get(index).secondArg - ClientWrapper.settingsAdaptor.tlsProtocolComboBoxIndexChanged(parseInt(indexOfOption)) + SettingsAdapter.tlsProtocolComboBoxIndexChanged(parseInt(indexOfOption)) } } @@ -863,7 +864,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.outgoingTLSServerNameLineEditTextChanged(text) + SettingsAdapter.outgoingTLSServerNameLineEditTextChanged(text) } } @@ -899,7 +900,7 @@ ColumnLayout { down.indicator.width: (width < 200) ? (width / 5) : 40 onValueModified: { - ClientWrapper.settingsAdaptor.negotiationTimeoutSpinBoxValueChanged(value) + SettingsAdapter.negotiationTimeoutSpinBoxValueChanged(value) } } } @@ -968,7 +969,7 @@ ColumnLayout { down.indicator.width: (width < 200) ? (width / 5) : 40 onValueModified: { - ClientWrapper.settingsAdaptor.registrationTimeoutSpinBoxValueChanged(value) + SettingsAdapter.registrationTimeoutSpinBoxValueChanged(value) } } @@ -1007,7 +1008,7 @@ ColumnLayout { down.indicator.width: (width < 200) ? (width / 5) : 40 onValueModified: { - ClientWrapper.settingsAdaptor.networkInterfaceSpinBoxValueChanged(value) + SettingsAdapter.networkInterfaceSpinBoxValueChanged(value) } } @@ -1021,7 +1022,7 @@ ColumnLayout { Layout.columnSpan: 2 onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseUPnP(checked) + SettingsAdapter.setUseUPnP(checked) } } @@ -1035,7 +1036,7 @@ ColumnLayout { Layout.columnSpan: 2 onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseTURN(checked) + SettingsAdapter.setUseTURN(checked) lineEditTurnAddressSIP.enabled = checked lineEditTurnUsernameSIP.enabled = checked lineEditTurnPsswdSIP.enabled = checked @@ -1069,7 +1070,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNAddress(text) + SettingsAdapter.setTURNAddress(text) } } @@ -1099,7 +1100,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNUsername(text) + SettingsAdapter.setTURNUsername(text) } } @@ -1130,7 +1131,7 @@ ColumnLayout { echoMode: TextInput.Password onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNPassword(text) + SettingsAdapter.setTURNPassword(text) } } @@ -1160,7 +1161,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNRealm(text) + SettingsAdapter.setTURNRealm(text) } } @@ -1174,7 +1175,7 @@ ColumnLayout { Layout.columnSpan: 2 onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseSTUN(checked) + SettingsAdapter.setUseSTUN(checked) lineEditSTUNAddressSIP.enabled = checked } } @@ -1205,7 +1206,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setSTUNAddress(text) + SettingsAdapter.setSTUNAddress(text) } } } @@ -1248,7 +1249,7 @@ ColumnLayout { Layout.columnSpan: 2 onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseCustomAddressAndPort(checked) + SettingsAdapter.setUseCustomAddressAndPort(checked) lineEditSIPCustomAddress.enabled = checked customPortSIPSpinBox.enabled = checked } @@ -1289,7 +1290,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.lineEditSIPCustomAddressLineEditTextChanged(text) + SettingsAdapter.lineEditSIPCustomAddressLineEditTextChanged(text) } } @@ -1330,7 +1331,7 @@ ColumnLayout { down.indicator.width: (width < 200) ? (width / 5) : 40 onValueModified: { - ClientWrapper.settingsAdaptor.customPortSIPSpinBoxValueChanged(value) + SettingsAdapter.customPortSIPSpinBoxValueChanged(value) } } } @@ -1368,7 +1369,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setVideoState(checked) + SettingsAdapter.setVideoState(checked) } } @@ -1483,7 +1484,7 @@ ColumnLayout { } onVideoCodecStateChange:{ - ClientWrapper.settingsAdaptor.videoCodecsStateChange(idToSet , isToBeEnabled) + SettingsAdapter.videoCodecsStateChange(idToSet , isToBeEnabled) updateVideoCodecs() } } @@ -1591,7 +1592,7 @@ ColumnLayout { } onAudioCodecStateChange:{ - ClientWrapper.settingsAdaptor.audioCodecsStateChange(idToSet , isToBeEnabled) + SettingsAdapter.audioCodecsStateChange(idToSet , isToBeEnabled) updateAudioCodecs() } } diff --git a/src/settingsview/components/AdvancedSettingsView.qml b/src/settingsview/components/AdvancedSettingsView.qml index 8ea60f8b7..a75306ddc 100644 --- a/src/settingsview/components/AdvancedSettingsView.qml +++ b/src/settingsview/components/AdvancedSettingsView.qml @@ -26,48 +26,49 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.3 import Qt.labs.platform 1.1 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" ColumnLayout { function updateAccountInfoDisplayedAdvance() { //Call Settings - checkAutoConnectOnLocalNetwork.checked = ClientWrapper.settingsAdaptor.getAccountConfig_PeerDiscovery() - checkBoxUntrusted.checked = ClientWrapper.settingsAdaptor.getAccountConfig_DHT_PublicInCalls() - checkBoxRdv.checked = ClientWrapper.settingsAdaptor.getAccountConfig_RendezVous() - checkBoxAutoAnswer.checked = ClientWrapper.settingsAdaptor.getAccountConfig_AutoAnswer() - checkBoxCustomRingtone.checked = ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtoneEnabled() + checkAutoConnectOnLocalNetwork.checked = SettingsAdapter.getAccountConfig_PeerDiscovery() + checkBoxUntrusted.checked = SettingsAdapter.getAccountConfig_DHT_PublicInCalls() + checkBoxRdv.checked = SettingsAdapter.getAccountConfig_RendezVous() + checkBoxAutoAnswer.checked = SettingsAdapter.getAccountConfig_AutoAnswer() + checkBoxCustomRingtone.checked = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() // Name Server - lineEditNameServer.text = ClientWrapper.settingsAdaptor.getAccountConfig_RingNS_Uri() + lineEditNameServer.text = SettingsAdapter.getAccountConfig_RingNS_Uri() //OpenDHT Config - checkBoxEnableProxy.checked = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyEnabled() - lineEditProxy.text = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyServer() - lineEditBootstrap.text = ClientWrapper.settingsAdaptor.getAccountConfig_Hostname() + checkBoxEnableProxy.checked = SettingsAdapter.getAccountConfig_ProxyEnabled() + lineEditProxy.text = SettingsAdapter.getAccountConfig_ProxyServer() + lineEditBootstrap.text = SettingsAdapter.getAccountConfig_Hostname() // Security - btnCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateListFile()) - btnUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateFile()) - btnPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_TLS_PrivateKeyFile()) + btnCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) + btnUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) + btnPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) // Connectivity - checkBoxUPnP.checked = ClientWrapper.settingsAdaptor.getAccountConfig_UpnpEnabled() - checkBoxTurnEnable.checked = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Enabled() - lineEditTurnAddress.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Server() - lineEditTurnUsername.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Username() - lineEditTurnPassword.text = ClientWrapper.settingsAdaptor.getAccountConfig_TURN_Password() - checkBoxSTUNEnable.checked = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Enabled() - lineEditSTUNAddress.text = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Server() + checkBoxUPnP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled() + checkBoxTurnEnable.checked = SettingsAdapter.getAccountConfig_TURN_Enabled() + lineEditTurnAddress.text = SettingsAdapter.getAccountConfig_TURN_Server() + lineEditTurnUsername.text = SettingsAdapter.getAccountConfig_TURN_Username() + lineEditTurnPassword.text = SettingsAdapter.getAccountConfig_TURN_Password() + checkBoxSTUNEnable.checked = SettingsAdapter.getAccountConfig_STUN_Enabled() + lineEditSTUNAddress.text = SettingsAdapter.getAccountConfig_STUN_Server() // codecs - videoCheckBox.checked = ClientWrapper.settingsAdaptor.getAccountConfig_Video_Enabled() + videoCheckBox.checked = SettingsAdapter.getAccountConfig_Video_Enabled() // update audio and video codec, make sure this change does not trigger item change events updateAudioCodecs(); updateVideoCodecs(); - btnRingtone.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtoneEnabled() - btnRingtone.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath()) - lineEditProxy.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyEnabled() - lineEditSTUNAddress.enabled = ClientWrapper.settingsAdaptor.getAccountConfig_STUN_Enabled() + btnRingtone.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() + btnRingtone.text = ClientWrapper.utilsAdaptor.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) + lineEditProxy.enabled = SettingsAdapter.getAccountConfig_ProxyEnabled() + lineEditSTUNAddress.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() } function updateAudioCodecs(){ @@ -88,7 +89,7 @@ ColumnLayout { var index = audioListWidget.currentIndex var codecId = audioCodecListModel.data(audioCodecListModel.index(index,0), AudioCodecListModel.AudioCodecID) - ClientWrapper.settingsAdaptor.decreaseAudioCodecPriority(codecId) + SettingsAdapter.decreaseAudioCodecPriority(codecId) audioListWidget.currentIndex = index + 1 updateAudioCodecs() } @@ -97,7 +98,7 @@ ColumnLayout { var index = audioListWidget.currentIndex var codecId = audioCodecListModel.data(audioCodecListModel.index(index,0), AudioCodecListModel.AudioCodecID) - ClientWrapper.settingsAdaptor.increaseAudioCodecPriority(codecId) + SettingsAdapter.increaseAudioCodecPriority(codecId) audioListWidget.currentIndex = index - 1 updateAudioCodecs() } @@ -106,7 +107,7 @@ ColumnLayout { var index = videoListWidget.currentIndex var codecId = videoCodecListModel.data(videoCodecListModel.index(index,0), VideoCodecListModel.VideoCodecID) - ClientWrapper.settingsAdaptor.decreaseVideoCodecPriority(codecId) + SettingsAdapter.decreaseVideoCodecPriority(codecId) videoListWidget.currentIndex = index + 1 updateVideoCodecs() } @@ -115,7 +116,7 @@ ColumnLayout { var index = videoListWidget.currentIndex var codecId = videoCodecListModel.data(videoCodecListModel.index(index,0), VideoCodecListModel.VideoCodecID) - ClientWrapper.settingsAdaptor.increaseVideoCodecPriority(codecId) + SettingsAdapter.increaseVideoCodecPriority(codecId) videoListWidget.currentIndex = index - 1 updateVideoCodecs() } @@ -130,30 +131,30 @@ ColumnLayout { function changeRingtonePath(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_RingtonePath(url) + SettingsAdapter.set_RingtonePath(url) btnRingtone.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) - } else if (ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath().length === 0){ + } else if (ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ btnRingtone.text = qsTr("Add a custom ringtone") } } function changeFileCACert(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FileCACert(url) + SettingsAdapter.set_FileCACert(url) btnCACert.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } function changeFileUserCert(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FileUserCert(url) + SettingsAdapter.set_FileUserCert(url) btnUserCert.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } function changeFilePrivateKey(url){ if(url.length !== 0) { - ClientWrapper.settingsAdaptor.set_FilePrivateKey(url) + SettingsAdapter.set_FilePrivateKey(url) btnPrivateKey.text = ClientWrapper.utilsAdaptor.toFileInfoName(url) } } @@ -161,7 +162,7 @@ ColumnLayout { JamiFileDialog { id: ringtonePath_Dialog - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_Ringtone_RingtonePath() + property string oldPath : SettingsAdapter.getAccountConfig_Ringtone_RingtonePath() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -188,7 +189,7 @@ ColumnLayout { JamiFileDialog { id: caCert_Dialog - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateListFile() + property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateListFile() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -214,7 +215,7 @@ ColumnLayout { JamiFileDialog { id: userCert_Dialog - property string oldPath : ClientWrapper.settingsAdaptor.getAccountConfig_TLS_CertificateFile() + property string oldPath : SettingsAdapter.getAccountConfig_TLS_CertificateFile() property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) mode: JamiFileDialog.OpenFile @@ -241,7 +242,7 @@ ColumnLayout { id: privateKey_Dialog property string oldPath : { - return ClientWrapper.settingsAdaptor.getAccountConfig_TLS_PrivateKeyFile() + return ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() } property string openPath : oldPath === "" ? (ClientWrapper.utilsAdaptor.getCurrentPath() + "/ringtones/") : (ClientWrapper.utilsAdaptor.toFileAbsolutepath(oldPath)) @@ -298,7 +299,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setCallsUntrusted(checked) + SettingsAdapter.setCallsUntrusted(checked) } } @@ -318,7 +319,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setAutoAnswerCalls(checked) + SettingsAdapter.setAutoAnswerCalls(checked) } } @@ -336,7 +337,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setEnableRingtone(checked) + SettingsAdapter.setEnableRingtone(checked) btnRingtone.enabled = checked } } @@ -390,7 +391,7 @@ ColumnLayout { fontPointSize: 10 onSwitchToggled: { - ClientWrapper.settingsAdaptor.setIsRendezVous(checked) + SettingsAdapter.setIsRendezVous(checked) } } } @@ -445,7 +446,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setNameServer(text) + SettingsAdapter.setNameServer(text) } } } @@ -478,7 +479,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setEnableProxy(checked) + SettingsAdapter.setEnableProxy(checked) lineEditProxy.enabled = checked } } @@ -511,7 +512,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setProxyAddress(text) + SettingsAdapter.setProxyAddress(text) } } } @@ -549,7 +550,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setBootstrapAddress(text) + SettingsAdapter.setBootstrapAddress(text) } } } @@ -743,7 +744,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setAutoConnectOnLocalNetwork(checked) + SettingsAdapter.setAutoConnectOnLocalNetwork(checked) } } @@ -763,7 +764,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseUPnP(checked) + SettingsAdapter.setUseUPnP(checked) } } @@ -776,7 +777,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseTURN(checked) + SettingsAdapter.setUseTURN(checked) } } @@ -808,7 +809,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNAddress(text) + SettingsAdapter.setTURNAddress(text) } } } @@ -842,7 +843,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNUsername(text) + SettingsAdapter.setTURNUsername(text) } } } @@ -877,7 +878,7 @@ ColumnLayout { echoMode: TextInput.Password onEditingFinished: { - ClientWrapper.settingsAdaptor.setTURNPassword(text) + SettingsAdapter.setTURNPassword(text) } } } @@ -892,7 +893,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setUseSTUN(checked) + SettingsAdapter.setUseSTUN(checked) lineEditSTUNAddress.enabled = checked } } @@ -930,7 +931,7 @@ ColumnLayout { verticalAlignment: Text.AlignVCenter onEditingFinished: { - ClientWrapper.settingsAdaptor.setSTUNAddress(text) + SettingsAdapter.setSTUNAddress(text) } } } @@ -966,7 +967,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: { - ClientWrapper.settingsAdaptor.setVideoState(checked) + SettingsAdapter.setVideoState(checked) } } @@ -1068,7 +1069,7 @@ ColumnLayout { } onVideoCodecStateChange:{ - ClientWrapper.settingsAdaptor.videoCodecsStateChange(idToSet , isToBeEnabled) + SettingsAdapter.videoCodecsStateChange(idToSet , isToBeEnabled) updateVideoCodecs() } } @@ -1171,7 +1172,7 @@ ColumnLayout { } onAudioCodecStateChange:{ - ClientWrapper.settingsAdaptor.audioCodecsStateChange(idToSet , isToBeEnabled) + SettingsAdapter.audioCodecsStateChange(idToSet , isToBeEnabled) updateAudioCodecs() } } diff --git a/src/settingsview/components/AvSettingPage.qml b/src/settingsview/components/AvSettingPage.qml index 41b54f9aa..89403b99b 100644 --- a/src/settingsview/components/AvSettingPage.qml +++ b/src/settingsview/components/AvSettingPage.qml @@ -92,7 +92,7 @@ Rectangle { function setFormatListForCurrentDevice(){ var device = ClientWrapper.avmodel.getCurrentVideoCaptureDevice() - if(ClientWrapper.settingsAdaptor.get_DeviceCapabilitiesSize(device) === 0){ + if(ClientWrapper.SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0){ return } @@ -208,7 +208,7 @@ Rectangle { } try{ - ClientWrapper.settingsAdaptor.set_Video_Settings_Rate_And_Resolution(ClientWrapper.avmodel.getCurrentVideoCaptureDevice(),rate,resolution) + SettingsAdapter.set_Video_Settings_Rate_And_Resolution(ClientWrapper.avmodel.getCurrentVideoCaptureDevice(),rate,resolution) updatePreviewRatio(resolution) } catch(error){console.warn(error.message)} } diff --git a/src/settingsview/components/CurrentAccountSettingsScrollPage.qml b/src/settingsview/components/CurrentAccountSettingsScrollPage.qml index a8edcbe73..cefcc09de 100644 --- a/src/settingsview/components/CurrentAccountSettingsScrollPage.qml +++ b/src/settingsview/components/CurrentAccountSettingsScrollPage.qml @@ -26,6 +26,7 @@ import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.3 import Qt.labs.platform 1.1 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" @@ -59,23 +60,23 @@ Rectangle { function updateAccountInfoDisplayed() { setAvatar() - accountEnableCheckBox.checked = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_Enabled() - displayNameLineEdit.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Alias() + accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() + displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() - var showLocalAccountConfig = (ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === "") + var showLocalAccountConfig = (ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === "") passwdPushButton.visible = showLocalAccountConfig btnExportAccount.visible = showLocalAccountConfig linkDevPushButton.visible = showLocalAccountConfig - registeredIdNeedsSet = (ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() === "") + registeredIdNeedsSet = (ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "") if(!registeredIdNeedsSet){ - currentRegisteredID.text = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() + currentRegisteredID.text = SettingsAdapter.get_CurrentAccountInfo_RegisteredName() } else { currentRegisteredID.text = "" } - currentRingIDText.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri() + currentRingIDText.text = SettingsAdapter.getCurrentAccount_Profile_Info_Uri() // update device list view updateAndShowDevicesSlot() @@ -104,9 +105,9 @@ Rectangle { function setAvatar() { currentAccountAvatar.setAvatarPixmap( - ClientWrapper.settingsAdaptor.getAvatarImage_Base64( + SettingsAdapter.getAvatarImage_Base64( currentAccountAvatar.boothWidth), - ClientWrapper.settingsAdaptor.getIsDefaultAvatar()) + SettingsAdapter.getIsDefaultAvatar()) } function stopBooth() { @@ -120,7 +121,7 @@ Rectangle { } function unban(index) { - ClientWrapper.settingsAdaptor.unbanContact(index) + SettingsAdapter.unbanContact(index) updateAndShowBannedContactsSlot() } @@ -160,7 +161,7 @@ Rectangle { // slots function verifyRegisteredNameSlot() { - if (ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() !== "") { + if (ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() !== "") { regNameUi = CurrentAccountSettingsScrollPage.BLANK } else { registeredName = ClientWrapper.utilsAdaptor.stringSimplifier( @@ -410,7 +411,7 @@ Rectangle { } function updateAndShowDevicesSlot() { - if(ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === ""){ + if(ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === ""){ linkDevPushButton.visible = true } @@ -560,11 +561,11 @@ Rectangle { Layout.minimumHeight: boothWidth+50 onImageAcquired: { - ClientWrapper.settingsAdaptor.setCurrAccAvatar(imgBase64) + SettingsAdapter.setCurrAccAvatar(imgBase64) } onImageCleared: { - ClientWrapper.settingsAdaptor.clearCurrentAvatar() + SettingsAdapter.clearCurrentAvatar() setAvatar() } } @@ -673,7 +674,7 @@ Rectangle { elideWidth: accountViewRect.width - idLabel.width -JamiTheme.preferredMarginSize*4 text: { refreshVariable - return ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Uri() + return ClientWrapper.SettingsAdapter.getCurrentAccount_Profile_Info_Uri() } } } @@ -716,7 +717,7 @@ Rectangle { text: { refreshVariable if (!registeredIdNeedsSet){ - return ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_RegisteredName() + return ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() } else { return "" } @@ -775,7 +776,8 @@ Rectangle { MaterialButton { id: passwdPushButton - visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === "" + + visible: SettingsAdapter.getAccountConfig_Manageruri() === "" color: JamiTheme.buttonTintedBlack hoveredColor: JamiTheme.buttonTintedBlackHovered @@ -805,7 +807,8 @@ Rectangle { MaterialButton { id: btnExportAccount - visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === "" + + visible: SettingsAdapter.getAccountConfig_Manageruri() === "" color: JamiTheme.buttonTintedBlack hoveredColor: JamiTheme.buttonTintedBlackHovered @@ -913,7 +916,7 @@ Rectangle { MaterialButton { id: linkDevPushButton - visible: ClientWrapper.settingsAdaptor.getAccountConfig_Manageruri() === "" + visible: SettingsAdapter.getAccountConfig_Manageruri() === "" Layout.minimumHeight: JamiTheme.preferredFieldHeight Layout.preferredHeight: JamiTheme.preferredFieldHeight diff --git a/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml b/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml index e3dc44bd4..9d93bbfe2 100644 --- a/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml +++ b/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml @@ -35,13 +35,13 @@ Rectangle { property int preferredColumnWidth : sipAccountViewRect.width / 2 - 50 function updateAccountInfoDisplayed() { - displaySIPNameLineEdit.text = ClientWrapper.settingsAdaptor.getCurrentAccount_Profile_Info_Alias() - usernameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Username() - hostnameSIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_Hostname() - passSIPlineEdit.text = ClientWrapper.settingsAdaptor.getAccountConfig_Password() - proxySIP.text = ClientWrapper.settingsAdaptor.getAccountConfig_ProxyServer() + displaySIPNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() + usernameSIP.text = SettingsAdapter.getAccountConfig_Username() + hostnameSIP.text = SettingsAdapter.getAccountConfig_Hostname() + passSIPlineEdit.text = SettingsAdapter.getAccountConfig_Password() + proxySIP.text = SettingsAdapter.getAccountConfig_ProxyServer() - accountSIPEnableCheckBox.checked = ClientWrapper.settingsAdaptor.get_CurrentAccountInfo_Enabled() + accountSIPEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() setAvatar() @@ -56,9 +56,9 @@ Rectangle { function setAvatar() { currentSIPAccountAvatar.setAvatarPixmap( - ClientWrapper.settingsAdaptor.getAvatarImage_Base64( + SettingsAdapter.getAvatarImage_Base64( currentSIPAccountAvatar.boothWidth), - ClientWrapper.settingsAdaptor.getIsDefaultAvatar()) + SettingsAdapter.getIsDefaultAvatar()) } function stopBooth() { @@ -220,11 +220,11 @@ Rectangle { Layout.minimumHeight: boothWidth+50 onImageAcquired: { - ClientWrapper.settingsAdaptor.setCurrAccAvatar(imgBase64) + SettingsAdapter.setCurrAccAvatar(imgBase64) } onImageCleared: { - ClientWrapper.settingsAdaptor.clearCurrentAvatar() + SettingsAdapter.clearCurrentAvatar() setAvatar() } } @@ -313,7 +313,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.settingsAdaptor.setAccountConfig_Username( + SettingsAdapter.setAccountConfig_Username( usernameSIP.text) } } @@ -348,7 +348,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.settingsAdaptor.setAccountConfig_Hostname( + SettingsAdapter.setAccountConfig_Hostname( hostnameSIP.text) } } @@ -383,7 +383,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.settingsAdaptor.setAccountConfig_ProxyServer( + SettingsAdapter.setAccountConfig_ProxyServer( proxySIP.text) } } @@ -419,7 +419,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.settingsAdaptor.setAccountConfig_Password( + SettingsAdapter.setAccountConfig_Password( passSIPlineEdit.text) } } diff --git a/src/settingsview/components/DeviceItemDelegate.qml b/src/settingsview/components/DeviceItemDelegate.qml index c5028d5c3..32084d288 100644 --- a/src/settingsview/components/DeviceItemDelegate.qml +++ b/src/settingsview/components/DeviceItemDelegate.qml @@ -57,7 +57,7 @@ ItemDelegate { function toggleEditable() { editable = !editable if (editable) { - ClientWrapper.settingsAdaptor.setDeviceName(elidedTextDeviceName.text) + SettingsAdapter.setDeviceName(elidedTextDeviceName.text) } } diff --git a/src/settingsview/components/GeneralSettingsPage.qml b/src/settingsview/components/GeneralSettingsPage.qml index c36148ff8..2b36cad1a 100644 --- a/src/settingsview/components/GeneralSettingsPage.qml +++ b/src/settingsview/components/GeneralSettingsPage.qml @@ -24,6 +24,8 @@ import QtQuick.Layouts 1.3 import Qt.labs.platform 1.1 import QtGraphicalEffects 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 +import net.jami.Enums 1.0 import "../../commoncomponents" Rectangle { @@ -31,34 +33,34 @@ Rectangle { function populateGeneralSettings(){ // settings - closeOrMinCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_CloseOrMinimized() + closeOrMinCheckBox.checked = SettingsAdapter.getAppValue(Settings.MinimizeOnClose) applicationOnStartUpCheckBox.checked = ClientWrapper.utilsAdaptor.checkStartupLink() - notificationCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_EnableNotifications() + notificationCheckBox.checked = SettingsAdapter.getAppValue(Settings.EnableNotifications) alwaysRecordingCheckBox.checked = ClientWrapper.avmodel.getAlwaysRecord() recordPreviewCheckBox.checked = ClientWrapper.avmodel.getRecordPreview() recordQualityValueLabel.text = ClientWrapper.utilsAdaptor.getRecordQualityString(ClientWrapper.avmodel.getRecordQuality() / 100) recordQualitySlider.value = ClientWrapper.avmodel.getRecordQuality() / 100 - ClientWrapper.avmodel.setRecordPath(ClientWrapper.settingsAdaptor.getDir_Document()) + ClientWrapper.avmodel.setRecordPath(ClientWrapper.SettingsAdapter.getDir_Document()) - autoUpdateCheckBox.checked = ClientWrapper.settingsAdaptor.getSettingsValue_AutoUpdate() + autoUpdateCheckBox.checked = SettingsAdapter.getAppValue(Settings.Key.AutoUpdate) } - function slotSetNotifications(state){ - ClientWrapper.settingsAdaptor.setNotifications(state) + function setEnableNotifications(state) { + SettingsAdapter.setAppValue(Settings.Key.EnableNotifications, state) } - function slotSetClosedOrMin(state){ - ClientWrapper.settingsAdaptor.setClosedOrMin(state) + function setMinimizeOnClose(state) { + SettingsAdapter.setAppValue(Settings.Key.MinimizeOnClose, state) } function slotSetRunOnStartUp(state){ - ClientWrapper.settingsAdaptor.setRunOnStartUp(state) + SettingsAdapter.setRunOnStartUp(state) } - function slotSetUpdateAutomatic(state){ - ClientWrapper.settingsAdaptor.setUpdateAutomatic(state) + function setAutoUpdate(state) { + SettingsAdapter.setAppValue(Settings.Key.AutoUpdate, state) } function slotAlwaysRecordingClicked(state){ @@ -142,10 +144,10 @@ Rectangle { function installBetaSlot(){} // settings - property string downloadPath: ClientWrapper.settingsAdaptor.getDir_Download() + property string downloadPath: SettingsAdapter.getDir_Download() // recording - property string recordPath: ClientWrapper.settingsAdaptor.getDir_Document() + property string recordPath: SettingsAdapter.getDir_Document() property int preferredColumnWidth : generalSettingsScrollView.width / 2 - 50 property int preferredSettingsWidth : generalSettingsScrollView.width - 100 @@ -154,7 +156,7 @@ Rectangle { onDownloadPathChanged: { if(downloadPath === "") return - ClientWrapper.settingsAdaptor.setDownloadPath(downloadPath) + SettingsAdapter.setDownloadPath(downloadPath) } onRecordPathChanged: { @@ -276,7 +278,7 @@ Rectangle { tooltipText: qsTr("toggle enable notifications") onSwitchToggled: { - slotSetNotifications(checked) + setEnableNotifications(checked) } } @@ -297,7 +299,7 @@ Rectangle { tooltipText: qsTr("toggle keep minimized on close") onSwitchToggled: { - slotSetClosedOrMin(checked) + setMinimizeOnClose(checked) } } @@ -575,7 +577,7 @@ Rectangle { tooltipText: qsTr("toggle automatic updates") onSwitchToggled: { - slotSetUpdateAutomatic(checked) + setAutoUpdate(checked) } } diff --git a/src/utils.cpp b/src/utils.cpp index edfbbef50..f54318a50 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -176,14 +176,19 @@ Utils::removeOldVersions() */ QSettings(hkcuSoftwareKey + "jami.net\\Ring", QSettings::NativeFormat).remove(""); QSettings(hkcuSoftwareKey + "ring.cx", QSettings::NativeFormat).remove(""); + /* * 2. Unset Ring as a startup application. */ if (Utils::CheckStartupLink(TEXT("Ring"))) { qDebug() << "Found startup link for Ring. Removing it and killing Ring.exe."; Utils::DeleteStartupLink(TEXT("Ring")); - QProcess::execute("taskkill /im Ring.exe /f"); + QProcess process; + process.start("taskkill", QStringList() + << "/im" << "Ring.exe" << "/f"); + process.waitForFinished(); } + /* * 3. Remove registry entries for winsparkle(both Jami-x64 and Ring-x64). */ @@ -306,12 +311,13 @@ Utils::showSystemNotification(QWidget *widget, long delay, const QString &triggeredAccountId) { - QSettings settings("jami.net", "Jami"); - if (settings.value(SettingsKey::enableNotifications).toBool()) { - GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId); - GlobalSystemTray::instance().showMessage(message, "", QIcon(":images/jami.png")); - QApplication::alert(widget, delay); + if (!AppSettingsManager::getValue(Settings::Key::EnableNotifications).toBool()) { + qWarning() << "Notifications are disabled"; + return; } + GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId); + GlobalSystemTray::instance().showMessage(message, "", QIcon(":images/jami.png")); + QApplication::alert(widget, delay); } void @@ -321,12 +327,13 @@ Utils::showSystemNotification(QWidget *widget, long delay, const QString &triggeredAccountId) { - QSettings settings("jami.net", "Jami"); - if (settings.value(SettingsKey::enableNotifications).toBool()) { - GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId); - GlobalSystemTray::instance().showMessage(sender, message, QIcon(":images/jami.png")); - QApplication::alert(widget, delay); + if (!AppSettingsManager::getValue(Settings::Key::EnableNotifications).toBool()) { + qWarning() << "Notifications are disabled"; + return; } + GlobalSystemTray::instance().setTriggeredAccountId(triggeredAccountId); + GlobalSystemTray::instance().showMessage(sender, message, QIcon(":images/jami.png")); + QApplication::alert(widget, delay); } QSize @@ -1103,4 +1110,4 @@ UtilsAdapter::checkShowPluginsButton() { return LRCInstance::pluginModel().getPluginsEnabled() && (LRCInstance::pluginModel().listLoadedPlugins().size() > 0); -} \ No newline at end of file +} diff --git a/src/utils.h b/src/utils.h index 584662f0d..f3d785340 100644 --- a/src/utils.h +++ b/src/utils.h @@ -68,53 +68,6 @@ static constexpr bool isBeta = false; namespace Utils { -/* - * Qml type register. - */ -#define QML_REGISTERSINGLETONTYPE(T, MAJ, MIN) \ - qmlRegisterSingletonType<T>("net.jami.Models", \ - MAJ, \ - MIN, \ - #T, \ - [](QQmlEngine *e, QJSEngine *se) -> QObject * { \ - Q_UNUSED(e); \ - Q_UNUSED(se); \ - T *obj = new T(); \ - return obj; \ - }); -#define QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(T, MAJ, MIN) \ - qmlRegisterSingletonType<T>("net.jami.Models", \ - MAJ, \ - MIN, \ - #T, \ - [](QQmlEngine *e, QJSEngine *se) -> QObject * { \ - Q_UNUSED(e); \ - Q_UNUSED(se); \ - return &(T::instance()); \ - }); - -#define QML_REGISTERSINGLETONTYPE_URL(URL, T, MAJ, MIN) \ - qmlRegisterSingletonType(QUrl(URL), "net.jami.Models", MAJ, MIN, #T); - -#define QML_REGISTERTYPE(T, MAJ, MIN) qmlRegisterType<T>("net.jami.Models", MAJ, MIN, #T); - -#define QML_REGISTERNAMESPACE(T, NAME, MAJ, MIN) \ - qmlRegisterUncreatableMetaObject(T, "net.jami.Models", MAJ, MIN, NAME, "") - -#define QML_REGISTERUNCREATABLE(T, MAJ, MIN) \ - qmlRegisterUncreatableType<T>("net.jami.Models", \ - MAJ, \ - MIN, \ - #T, \ - "Don't try to add to a qml definition of " #T); - -#define QML_REGISTERUNCREATABLE_IN_NAMESPACE(T, NAMESPACE, MAJ, MIN) \ - qmlRegisterUncreatableType<NAMESPACE::T>("net.jami.Models", \ - MAJ, \ - MIN, \ - #T, \ - "Don't try to add to a qml definition of " #T); - /* * System. */ diff --git a/src/wizardview/WizardView.qml b/src/wizardview/WizardView.qml index 8f61a654a..653f5ef3d 100644 --- a/src/wizardview/WizardView.qml +++ b/src/wizardview/WizardView.qml @@ -23,6 +23,7 @@ import QtQuick.Controls.Universal 2.12 import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../commoncomponents" import "../constant" @@ -330,7 +331,7 @@ Rectangle { id: backupKeysPage onNeverShowAgainBoxClicked: { - ClientWrapper.accountAdaptor.settingsNeverShowAgain(isChecked) + SettingsAdapter.setValue(Settings.NeverShowMeAgain, isChecked) } onExport_Btn_FileDialogAccepted: { @@ -422,7 +423,7 @@ Rectangle { } onSaveProfile: { - ClientWrapper.settingsAdaptor.setCurrAccAvatar(profilePage.boothImgBase64) + SettingsAdapter.setCurrAccAvatar(profilePage.boothImgBase64) ClientWrapper.accountAdaptor.setCurrAccDisplayName(profilePage.displayName) leave() } -- GitLab