diff --git a/jami-qt.pro b/jami-qt.pro index 3af3746fe9137a86ba1d4deb6f223a0e57b256cb..14bbf37d80a327203373b119020baddc219c5862 100644 --- a/jami-qt.pro +++ b/jami-qt.pro @@ -110,92 +110,93 @@ unix { } # Input -HEADERS += ./src/smartlistmodel.h \ - ./src/utils.h \ - ./src/bannedlistmodel.h \ - ./src/version.h \ - ./src/accountlistmodel.h \ - ./src/runguard.h \ - ./src/lrcinstance.h \ - ./src/globalsystemtray.h \ - ./src/appsettingsmanager.h \ - ./src/webchathelpers.h \ - ./src/pixbufmanipulator.h \ - ./src/rendermanager.h \ - ./src/connectivitymonitor.h \ - ./src/jamiavatartheme.h \ - ./src/mainapplication.h \ - ./src/qrimageprovider.h \ - ./src/messagesadapter.h \ - ./src/accountadapter.h \ - ./src/tintedbuttonimageprovider.h \ - ./src/calladapter.h \ - ./src/conversationsadapter.h \ - ./src/distantrenderer.h \ - ./src/previewrenderer.h \ - ./src/qmladapterbase.h \ - ./src/avadapter.h \ - ./src/contactadapter.h \ - ./src/pluginadapter.h \ - ./src/settingsadapter.h \ - ./src/deviceitemlistmodel.h \ - ./src/pluginitemlistmodel.h \ - ./src/mediahandleritemlistmodel.h \ - ./src/preferenceitemlistmodel.h \ - ./src/audiocodeclistmodel.h \ - ./src/videocodeclistmodel.h \ - ./src/accountstomigratelistmodel.h \ - ./src/clientwrapper.h \ - ./src/audioinputdevicemodel.h \ - ./src/videoinputdevicemodel.h \ - ./src/audiooutputdevicemodel.h \ - ./src/pluginlistpreferencemodel.h \ - ./src/videoformatfpsmodel.h \ - ./src/videoformatresolutionmodel.h \ - ./src/audiomanagerlistmodel.h \ +HEADERS += \ + src/smartlistmodel.h \ + src/utils.h \ + src/bannedlistmodel.h \ + src/version.h \ + src/accountlistmodel.h \ + src/runguard.h \ + src/lrcinstance.h \ + src/globalsystemtray.h \ + src/appsettingsmanager.h \ + src/webchathelpers.h \ + src/pixbufmanipulator.h \ + src/rendermanager.h \ + src/connectivitymonitor.h \ + src/jamiavatartheme.h \ + src/mainapplication.h \ + src/qrimageprovider.h \ + src/messagesadapter.h \ + src/accountadapter.h \ + src/tintedbuttonimageprovider.h \ + src/calladapter.h \ + src/conversationsadapter.h \ + src/distantrenderer.h \ + src/previewrenderer.h \ + src/qmladapterbase.h \ + src/avadapter.h \ + src/contactadapter.h \ + src/pluginadapter.h \ + src/settingsadapter.h \ + src/deviceitemlistmodel.h \ + src/pluginitemlistmodel.h \ + src/mediahandleritemlistmodel.h \ + src/preferenceitemlistmodel.h \ + src/audiocodeclistmodel.h \ + src/videocodeclistmodel.h \ + src/accountstomigratelistmodel.h \ + src/audioinputdevicemodel.h \ + src/videoinputdevicemodel.h \ + src/audiooutputdevicemodel.h \ + src/pluginlistpreferencemodel.h \ + src/videoformatfpsmodel.h \ + src/videoformatresolutionmodel.h \ + src/audiomanagerlistmodel.h \ src/qmlregister.h \ src/qtutils.h \ src/utilsadapter.h -SOURCES += ./src/bannedlistmodel.cpp \ - ./src/accountlistmodel.cpp \ - ./src/runguard.cpp \ - ./src/webchathelpers.cpp \ - ./src/main.cpp \ - ./src/globalsystemtray.cpp \ - ./src/smartlistmodel.cpp \ - ./src/utils.cpp \ - ./src/pixbufmanipulator.cpp \ - ./src/rendermanager.cpp \ - ./src/connectivitymonitor.cpp \ - ./src/mainapplication.cpp \ - ./src/messagesadapter.cpp \ - ./src/accountadapter.cpp \ - ./src/calladapter.cpp \ - ./src/conversationsadapter.cpp \ - ./src/distantrenderer.cpp \ - ./src/previewrenderer.cpp \ - ./src/avadapter.cpp \ - ./src/contactadapter.cpp \ - ./src/pluginadapter.cpp \ - ./src/settingsadapter.cpp \ - ./src/deviceitemlistmodel.cpp \ - ./src/pluginitemlistmodel.cpp \ - ./src/mediahandleritemlistmodel.cpp \ - ./src/preferenceitemlistmodel.cpp \ - ./src/audiocodeclistmodel.cpp \ - ./src/videocodeclistmodel.cpp \ - ./src/accountstomigratelistmodel.cpp \ - ./src/clientwrapper.cpp \ - ./src/audioinputdevicemodel.cpp \ - ./src/videoinputdevicemodel.cpp \ - ./src/audiooutputdevicemodel.cpp \ - ./src/pluginlistpreferencemodel.cpp \ - ./src/videoformatfpsmodel.cpp \ - ./src/videoformatresolutionmodel.cpp \ - ./src/audiomanagerlistmodel.cpp \ +SOURCES += \ + src/bannedlistmodel.cpp \ + src/accountlistmodel.cpp \ + src/runguard.cpp \ + src/webchathelpers.cpp \ + src/main.cpp \ + src/globalsystemtray.cpp \ + src/smartlistmodel.cpp \ + src/utils.cpp \ + src/pixbufmanipulator.cpp \ + src/rendermanager.cpp \ + src/connectivitymonitor.cpp \ + src/mainapplication.cpp \ + src/messagesadapter.cpp \ + src/accountadapter.cpp \ + src/calladapter.cpp \ + src/conversationsadapter.cpp \ + src/distantrenderer.cpp \ + src/previewrenderer.cpp \ + src/avadapter.cpp \ + src/contactadapter.cpp \ + src/pluginadapter.cpp \ + src/settingsadapter.cpp \ + src/deviceitemlistmodel.cpp \ + src/pluginitemlistmodel.cpp \ + src/mediahandleritemlistmodel.cpp \ + src/preferenceitemlistmodel.cpp \ + src/audiocodeclistmodel.cpp \ + src/videocodeclistmodel.cpp \ + src/accountstomigratelistmodel.cpp \ + src/audioinputdevicemodel.cpp \ + src/videoinputdevicemodel.cpp \ + src/audiooutputdevicemodel.cpp \ + src/pluginlistpreferencemodel.cpp \ + src/videoformatfpsmodel.cpp \ + src/videoformatresolutionmodel.cpp \ + src/audiomanagerlistmodel.cpp \ src/qmlregister.cpp \ src/utilsadapter.cpp -RESOURCES += ./resources.qrc \ - ./qml.qrc +RESOURCES += \ + resources.qrc \ + qml.qrc diff --git a/src/MainApplicationWindow.qml b/src/MainApplicationWindow.qml index 04f83fb72f292a93b504c6379fe7b508bf555ce3..695328f9cf74a32865b12b03a4b016e4212d1f52 100644 --- a/src/MainApplicationWindow.qml +++ b/src/MainApplicationWindow.qml @@ -143,7 +143,7 @@ ApplicationWindow { } Connections { - target: ClientWrapper.lrcInstance + target: LRCInstance function onRestoreAppRequested() { if (mainViewLoader.item) diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index cae123c91f4239a6a76c6cf27fc8606b9e92970a..7305d7516b910958198560a59bfd1a8fdeeeb1cd 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -28,21 +28,32 @@ #undef REGISTERED #include "../daemon/src/dring/account_const.h" -AccountAdapter::AccountAdapter(QObject *parent) +AccountAdapter::AccountAdapter(QObject* parent) : QmlAdapterBase(parent) {} -AccountAdapter & -AccountAdapter::instance() +void +AccountAdapter::safeInit() { - static auto instance = new AccountAdapter; - return *instance; + setSelectedAccountId(LRCInstance::getCurrAccId()); } -void -AccountAdapter::safeInit() +lrc::api::NewAccountModel* +AccountAdapter::getModel() +{ + return &(LRCInstance::accountModel()); +} + +lrc::api::ContactModel* +AccountAdapter::getContactModel() +{ + return LRCInstance::getCurrentAccountInfo().contactModel.get(); +} + +lrc::api::NewDeviceModel* +AccountAdapter::getDeviceModel() { - setSelectedAccount(LRCInstance::getCurrAccId()); + return LRCInstance::getCurrentAccountInfo().deviceModel.get(); } void @@ -50,7 +61,7 @@ AccountAdapter::accountChanged(int index) { auto accountList = LRCInstance::accountModel().getAccountList(); if (accountList.size() > index) - setSelectedAccount(accountList.at(index)); + setSelectedAccountId(accountList.at(index)); } void @@ -58,13 +69,13 @@ AccountAdapter::connectFailure() { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountRemoved, - [this](const QString &accountId) { + [this](const QString& accountId) { Q_UNUSED(accountId); emit reportFailure(); }); Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::invalidAccountDetected, - [this](const QString &accountId) { + [this](const QString& accountId) { Q_UNUSED(accountId); emit reportFailure(); }); @@ -72,16 +83,17 @@ AccountAdapter::connectFailure() void AccountAdapter::createJamiAccount(QString registeredName, - const QVariantMap &settings, + const QVariantMap& settings, QString photoBoothImgBase64, bool isCreating) { Utils::oneShotConnect( &LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded, - [this, registeredName, settings, isCreating, photoBoothImgBase64](const QString &accountId) { - auto showBackup = isCreating && - !AppSettingsManager::getValue(Settings::Key::NeverShowMeAgain).toBool(); + [this, registeredName, settings, isCreating, photoBoothImgBase64](const QString& accountId) { + auto showBackup = isCreating + && !AppSettingsManager::getValue(Settings::Key::NeverShowMeAgain) + .toBool(); if (!registeredName.isEmpty()) { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::nameRegistrationEnded, @@ -129,11 +141,11 @@ AccountAdapter::createJamiAccount(QString registeredName, } void -AccountAdapter::createSIPAccount(const QVariantMap &settings, QString photoBoothImgBase64) +AccountAdapter::createSIPAccount(const QVariantMap& settings, QString photoBoothImgBase64) { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded, - [this, settings, photoBoothImgBase64](const QString &accountId) { + [this, settings, photoBoothImgBase64](const QString& accountId) { auto confProps = LRCInstance::accountModel().getAccountConfig( accountId); // set SIP details @@ -178,11 +190,11 @@ AccountAdapter::createSIPAccount(const QVariantMap &settings, QString photoBooth } void -AccountAdapter::createJAMSAccount(const QVariantMap &settings) +AccountAdapter::createJAMSAccount(const QVariantMap& settings) { Utils::oneShotConnect(&LRCInstance::accountModel(), &lrc::api::NewAccountModel::accountAdded, - [this](const QString &accountId) { + [this](const QString& accountId) { Q_UNUSED(accountId) if (!LRCInstance::accountModel().getAccountList().size()) return; @@ -214,9 +226,9 @@ AccountAdapter::deleteCurrentAccount() } bool -AccountAdapter::savePassword(const QString accountId, - const QString oldPassword, - const QString newPassword) +AccountAdapter::savePassword(const QString& accountId, + const QString& oldPassword, + const QString& newPassword) { return LRCInstance::accountModel().changeAccountPassword(accountId, oldPassword, newPassword); } @@ -260,21 +272,15 @@ AccountAdapter::isPreviewing() } void -AccountAdapter::setCurrAccDisplayName(QString text) +AccountAdapter::setCurrAccDisplayName(const QString& text) { LRCInstance::setCurrAccDisplayName(text); } void -AccountAdapter::setSelectedAccountId(QString accountId) +AccountAdapter::setSelectedConvId(const QString& convId) { - LRCInstance::setSelectedAccountId(accountId); -} - -void -AccountAdapter::setSelectedConvId(QString accountId) -{ - LRCInstance::setSelectedConvId(accountId); + LRCInstance::setSelectedConvId(convId); } bool @@ -292,15 +298,15 @@ AccountAdapter::setArchiveHasPassword(bool isHavePassword) LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); } bool -AccountAdapter::exportToFile(const QString &accountId, - const QString &path, - const QString &password) const +AccountAdapter::exportToFile(const QString& accountId, + const QString& path, + const QString& password) const { return LRCInstance::accountModel().exportToFile(accountId, path, password); } void -AccountAdapter::setArchivePasswordAsync(const QString &accountID, const QString &password) +AccountAdapter::setArchivePasswordAsync(const QString& accountID, const QString& password) { QtConcurrent::run([accountID, password] { auto config = LRCInstance::accountModel().getAccountConfig(accountID); @@ -320,12 +326,18 @@ AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString } void -AccountAdapter::setSelectedAccount(const QString &accountId) +AccountAdapter::setSelectedAccountId(const QString& accountId) { LRCInstance::setSelectedAccountId(accountId); + setProperty("currentAccountId", accountId); + auto accountType = LRCInstance::getAccountInfo(accountId).profileInfo.type; + setProperty("currentAccountType", lrc::api::profile::to_string(accountType)); + connectAccount(accountId); - emit accountSignalsReconnect(accountId); + + emit contactModelChanged(); + emit deviceModelChanged(); backToWelcomePage(); } @@ -355,10 +367,10 @@ AccountAdapter::deselectConversation() } void -AccountAdapter::connectAccount(const QString &accountId) +AccountAdapter::connectAccount(const QString& accountId) { try { - auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); + auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId); QObject::disconnect(accountStatusChangedConnection_); QObject::disconnect(contactAddedConnection_); @@ -367,11 +379,11 @@ AccountAdapter::connectAccount(const QString &accountId) accountProfileChangedConnection_ = QObject::connect(&LRCInstance::accountModel(), - &lrc::api::NewAccountModel::profileUpdated, - [this](const QString& accountId) { - if (LRCInstance::getCurrAccId() == accountId) - emit accountStatusChanged(); - }); + &lrc::api::NewAccountModel::profileUpdated, + [this](const QString& accountId) { + if (LRCInstance::getCurrAccId() == accountId) + emit accountStatusChanged(); + }); accountStatusChangedConnection_ = QObject::connect(accInfo.accountModel, @@ -381,8 +393,8 @@ AccountAdapter::connectAccount(const QString &accountId) contactAddedConnection_ = QObject::connect(accInfo.contactModel.get(), &lrc::api::ContactModel::contactAdded, - [this, accountId](const QString &contactUri) { - auto &accInfo = LRCInstance::accountModel().getAccountInfo( + [this, accountId](const QString& contactUri) { + auto& accInfo = LRCInstance::accountModel().getAccountInfo( accountId); auto* convModel = LRCInstance::getCurrentConversationModel(); const auto conversation = convModel->getConversationForUID( @@ -404,7 +416,7 @@ AccountAdapter::connectAccount(const QString &accountId) addedToConferenceConnection_ = QObject::connect(accInfo.callModel.get(), &NewCallModel::callAddedToConference, - [](const QString &callId, const QString &confId) { + [](const QString& callId, const QString& confId) { Q_UNUSED(callId); LRCInstance::renderer()->addDistantRenderer(confId); }); diff --git a/src/accountadapter.h b/src/accountadapter.h index e28cec893d1d191c4a335d0b7982c16f64a45ec3..da7d0949f7007c0a478dad90c821d96a5ae4e1f5 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -31,17 +31,37 @@ class AccountAdapter final : public QmlAdapterBase { Q_OBJECT + Q_PROPERTY(lrc::api::NewAccountModel* model READ getModel NOTIFY modelChanged) + + Q_PROPERTY(lrc::api::ContactModel* contactModel READ getContactModel NOTIFY contactModelChanged) + Q_PROPERTY(lrc::api::NewDeviceModel* deviceModel READ getDeviceModel NOTIFY deviceModelChanged) + + Q_PROPERTY(QString currentAccountId MEMBER currentAccountId_ NOTIFY currentAccountIdChanged) + Q_PROPERTY(lrc::api::profile::Type currentAccountType MEMBER currentAccountType_ NOTIFY + currentAccountTypeChanged) + Q_PROPERTY(int accountListSize MEMBER accountListSize_ NOTIFY accountListSizeChanged) + +public: + lrc::api::NewAccountModel* getModel(); + lrc::api::ContactModel* getContactModel(); + lrc::api::NewDeviceModel* getDeviceModel(); + +signals: + void modelChanged(); + void contactModelChanged(); + void deviceModelChanged(); + + void currentAccountIdChanged(); + void currentAccountTypeChanged(); + void accountListSizeChanged(); + public: - explicit AccountAdapter(QObject *parent = 0); + explicit AccountAdapter(QObject* parent = 0); ~AccountAdapter() = default; protected: void safeInit() override; -public: - //Singleton - static AccountAdapter &instance(); - /* * Change to account corresponding to combox box index. */ @@ -50,11 +70,11 @@ public: * Create normal Jami account, SIP account and JAMS accounts. */ Q_INVOKABLE void createJamiAccount(QString registeredName, - const QVariantMap &settings, + const QVariantMap& settings, QString photoBoothImgBase64, bool isCreating); - Q_INVOKABLE void createSIPAccount(const QVariantMap &settings, QString photoBoothImgBase64); - Q_INVOKABLE void createJAMSAccount(const QVariantMap &settings); + Q_INVOKABLE void createSIPAccount(const QVariantMap& settings, QString photoBoothImgBase64); + Q_INVOKABLE void createJAMSAccount(const QVariantMap& settings); /* * Delete current account */ @@ -68,48 +88,51 @@ public: */ Q_INVOKABLE bool hasPassword(); Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword); - Q_INVOKABLE bool exportToFile(const QString &accountId, - const QString &path, - const QString &password = {}) const; - Q_INVOKABLE void setArchivePasswordAsync(const QString &accountID, const QString &password); + Q_INVOKABLE bool exportToFile(const QString& accountId, + const QString& path, + const QString& password = {}) const; + Q_INVOKABLE void setArchivePasswordAsync(const QString& accountID, const QString& password); /* * lrc instances functions wrappers */ - Q_INVOKABLE bool savePassword(QString accountId, QString oldPassword, QString newPassword); + Q_INVOKABLE bool savePassword(const QString& accountId, + const QString& oldPassword, + const QString& newPassword); Q_INVOKABLE void startAudioMeter(bool async); Q_INVOKABLE void stopAudioMeter(bool async); Q_INVOKABLE void startPreviewing(bool force = false, bool async = true); Q_INVOKABLE void stopPreviewing(bool async = true); Q_INVOKABLE bool hasVideoCall(); Q_INVOKABLE bool isPreviewing(); - Q_INVOKABLE void setCurrAccDisplayName(QString text); - Q_INVOKABLE void setSelectedAccountId(QString accountId = {}); - Q_INVOKABLE void setSelectedConvId(QString accountId = {}); + Q_INVOKABLE void setCurrAccDisplayName(const QString& text); + Q_INVOKABLE void setSelectedAccountId(const QString& accountId = {}); + Q_INVOKABLE void setSelectedConvId(const QString& convId = {}); signals: - /* * Trigger other components to reconnect account related signals. */ - void accountSignalsReconnect(const QString &accountId); void accountStatusChanged(); void updateConversationForAddedContact(); /* * send report failure to QML to make it show the right UI state . */ void reportFailure(); - void accountAdded(bool showBackUp, int index); void navigateToWelcomePageRequested(); + void accountAdded(bool showBackUp, int index); private: - void setSelectedAccount(const QString &accountId); + QString currentAccountId_; + lrc::api::profile::Type currentAccountType_; + int accountListSize_; + void backToWelcomePage(); void deselectConversation(); /* * Make account signal connections. */ - void connectAccount(const QString &accountId); + void connectAccount(const QString& accountId); /* * Implement what to do when creat accout fails. */ @@ -120,4 +143,4 @@ private: QMetaObject::Connection addedToConferenceConnection_; QMetaObject::Connection accountProfileChangedConnection_; }; -Q_DECLARE_METATYPE(AccountAdapter *) +Q_DECLARE_METATYPE(AccountAdapter*) diff --git a/src/avadapter.h b/src/avadapter.h index ec64067aff8ab328c74da1de911f550d4df6c899..cda3382d517eb45d3c4b43fd3c0c633ddc867044 100644 --- a/src/avadapter.h +++ b/src/avadapter.h @@ -1,4 +1,4 @@ -/* +/*! * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * diff --git a/src/clientwrapper.cpp b/src/clientwrapper.cpp deleted file mode 100644 index f72bd1af9e32e307b77ae22384237a0a53f83281..0000000000000000000000000000000000000000 --- a/src/clientwrapper.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (C) 2019-2020 by Savoir-faire Linux - * Author: Yang Wang <yang.wang@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "clientwrapper.h" - -ClientWrapper::ClientWrapper(QObject *parent) - : QObject(parent) -{ - connect(getAccountAdapter(), &AccountAdapter::accountSignalsReconnect, [this]() { - emit accountModelChanged(); - emit avmodelChanged(); - emit dataTransferModelChanged(); - emit contactModelChanged(); - emit deviceModelChanged(); - }); -} - -NameDirectory * -ClientWrapper::getNameDirectory() -{ - return &(NameDirectory::instance()); -} - -SettingsAdapter * -ClientWrapper::getSettingsAdapter() -{ - return &(SettingsAdapter::instance()); -} - -LRCInstance * -ClientWrapper::getLRCInstance() -{ - return &(LRCInstance::instance()); -} - -AccountAdapter * -ClientWrapper::getAccountAdapter() -{ - return &(AccountAdapter::instance()); -} - -RenderManager * -ClientWrapper::getRenderManager() -{ - return LRCInstance::renderer(); -} - -lrc::api::NewAccountModel * -ClientWrapper::getAccountModel() -{ - return &(LRCInstance::accountModel()); -} - -lrc::api::AVModel * -ClientWrapper::getAvModel() -{ - return &(LRCInstance::avModel()); -} - -lrc::api::PluginModel * -ClientWrapper::getPluginModel() -{ - return &(LRCInstance::pluginModel()); -} - -lrc::api::DataTransferModel * -ClientWrapper::getDataTransferModel() -{ - return &(LRCInstance::dataTransferModel()); -} - -lrc::api::ContactModel * -ClientWrapper::getContactModel() -{ - return getSettingsAdapter()->getCurrentAccountInfo().contactModel.get(); -} - -lrc::api::NewDeviceModel * -ClientWrapper::getDeviceModel() -{ - return getSettingsAdapter()->getCurrentAccountInfo().deviceModel.get(); -} diff --git a/src/clientwrapper.h b/src/clientwrapper.h deleted file mode 100644 index 514affe7dfa8a7278da2c51be52a1ee6de71e069..0000000000000000000000000000000000000000 --- a/src/clientwrapper.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (C) 2019-2020 by Savoir-faire Linux - * Author: Yang Wang <yang.wang@savoirfairelinux.com> - * Author: Aline Gondim Santos <aline.gondimsantos@savoirfairelinux.com> - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#pragma once - -#include "accountadapter.h" -#include "accountlistmodel.h" -#include "audiocodeclistmodel.h" -#include "avadapter.h" -#include "bannedlistmodel.h" -#include "calladapter.h" -#include "contactadapter.h" -#include "pluginadapter.h" -#include "conversationsadapter.h" -#include "deviceitemlistmodel.h" -#include "pluginitemlistmodel.h" -#include "mediahandleritemlistmodel.h" -#include "preferenceitemlistmodel.h" -#include "distantrenderer.h" -#include "globalinstances.h" -#include "globalsystemtray.h" -#include "messagesadapter.h" -#include "namedirectory.h" -#include "pixbufmanipulator.h" -#include "previewrenderer.h" -#include "qrimageprovider.h" -#include "settingsadapter.h" -#include "version.h" -#include "videocodeclistmodel.h" - -#include <QObject> - -class ClientWrapper : public QObject -{ - Q_OBJECT - - 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) - Q_PROPERTY(RenderManager *renderManager READ getRenderManager NOTIFY renderManagerChanged) - Q_PROPERTY(lrc::api::NewAccountModel *accountModel READ getAccountModel NOTIFY accountModelChanged) - Q_PROPERTY(lrc::api::AVModel *avmodel READ getAvModel NOTIFY avmodelChanged) - Q_PROPERTY(lrc::api::DataTransferModel *dataTransferModel READ getDataTransferModel NOTIFY dataTransferModelChanged) - Q_PROPERTY(lrc::api::ContactModel *contactModel READ getContactModel NOTIFY contactModelChanged) - Q_PROPERTY(lrc::api::NewDeviceModel *deviceModel READ getDeviceModel NOTIFY deviceModelChanged) - Q_PROPERTY(lrc::api::PluginModel *pluginModel READ getPluginModel) -public: - explicit ClientWrapper(QObject *parent = nullptr); - - NameDirectory *getNameDirectory(); - SettingsAdapter *getSettingsAdapter(); - LRCInstance *getLRCInstance(); - AccountAdapter *getAccountAdapter(); - - RenderManager *getRenderManager(); - lrc::api::NewAccountModel *getAccountModel(); - lrc::api::AVModel *getAvModel(); - lrc::api::DataTransferModel *getDataTransferModel(); - - lrc::api::ContactModel *getContactModel(); - lrc::api::NewDeviceModel *getDeviceModel(); - lrc::api::PluginModel *getPluginModel(); - -signals: - void SettingsAdapterChanged(); - void nameDirectoryChanged(); - void lrcInstanceChanged(); - void accountAdaptorChanged(); - void renderManagerChanged(); - void accountModelChanged(); - void avmodelChanged(); - void dataTransferModelChanged(); - void contactModelChanged(); - void deviceModelChanged(); -}; -Q_DECLARE_METATYPE(ClientWrapper *) diff --git a/src/commoncomponents/AccountMigrationDialog.qml b/src/commoncomponents/AccountMigrationDialog.qml index 01e301833d5dd8ca21d66d28d24719cf41348ca0..6373f187d2a807efe7acd5122204c777b6a766f6 100644 --- a/src/commoncomponents/AccountMigrationDialog.qml +++ b/src/commoncomponents/AccountMigrationDialog.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 "../constant" import "../wizardview/components" @@ -123,7 +124,7 @@ Window{ } function refuseMigrationAndDeleteAccount(){ - ClientWrapper.accountModel.removeAccount(accountID) + AccountAdapter.model.removeAccount(accountID) acceptMigration() } @@ -147,7 +148,7 @@ Window{ Connections{ id: connectionMigrationEnded enabled: false - target: ClientWrapper.accountModel + target: AccountAdapter.model function onMigrationEnded(accountIdIn, ok){ nonOperationClosing = true @@ -169,7 +170,7 @@ Window{ stackedWidget.currentIndex = 1 connectionMigrationEnded.enabled = true - ClientWrapper.accountAdaptor.setArchivePasswordAsync(accountID,password) + AccountAdapter.setArchivePasswordAsync(accountID,password) } function slotDeleteButtonClicked(){ diff --git a/src/commoncomponents/DeleteAccountDialog.qml b/src/commoncomponents/DeleteAccountDialog.qml index 92b6e44ce7c344c50956304e28ef77aadd25a16d..1cd6fbe065a94aec251ed9acaa734c90aae00623 100644 --- a/src/commoncomponents/DeleteAccountDialog.qml +++ b/src/commoncomponents/DeleteAccountDialog.qml @@ -160,7 +160,7 @@ Dialog { font.kerning: true onClicked: { - ClientWrapper.accountAdaptor.deleteCurrentAccount() + AccountAdapter.deleteCurrentAccount() accept() } } diff --git a/src/commoncomponents/PasswordDialog.qml b/src/commoncomponents/PasswordDialog.qml index 4ef46e05ca0efaab3e63fdda3501fbb9b33b54d0..d655abbd0978e8301267cd0cb3328a005c8fb44b 100644 --- a/src/commoncomponents/PasswordDialog.qml +++ b/src/commoncomponents/PasswordDialog.qml @@ -21,6 +21,7 @@ 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 import "../constant" @@ -113,7 +114,7 @@ Dialog { function exportAccountQML() { var success = false if (path.length > 0) { - success = ClientWrapper.accountAdaptor.exportToFile( + success = AccountAdapter.exportToFile( UtilsAdapter.getCurrAccId(), path, currentPasswordEdit.text) @@ -129,13 +130,13 @@ Dialog { function savePasswordQML() { var success = false - success = ClientWrapper.accountAdaptor.savePassword( + success = AccountAdapter.savePassword( UtilsAdapter.getCurrAccId(), currentPasswordEdit.text, passwordEdit.text) if (success) { - ClientWrapper.accountAdaptor.setArchiveHasPassword(passwordEdit.text.length !== 0) - haveDone(successCode, root.purpose) + AccountAdapter.setArchiveHasPassword(passwordEdit.text.length !== 0) + haveDone(successCode, passwordDialog.purpose) } else { currentPasswordEdit.borderColorMode = InfoLineEdit.ERROR btnChangePasswordConfirm.enabled = false diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml index 9c0469633251bd7e9f88e0438e9a7fc9c93580c7..c5783e7bd36082fb93ae9434960b845bb3efe026 100644 --- a/src/commoncomponents/PhotoboothView.qml +++ b/src/commoncomponents/PhotoboothView.qml @@ -5,6 +5,7 @@ import QtQuick.Controls.Styles 1.4 import Qt.labs.platform 1.1 import QtGraphicalEffects 1.0 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 ColumnLayout { property bool takePhotoState: false @@ -21,14 +22,14 @@ ColumnLayout { function startBooth(force = false){ hasAvatar = false - ClientWrapper.accountAdaptor.startPreviewing(force) + AccountAdapter.startPreviewing(force) takePhotoState = true } function stopBooth(){ try{ - if(!ClientWrapper.accountAdaptor.hasVideoCall()) { - ClientWrapper.accountAdaptor.stopPreviewing() + if(!AccountAdapter.hasVideoCall()) { + AccountAdapter.stopPreviewing() } } catch(erro){console.log("Exception: " + erro.message)} diff --git a/src/commoncomponents/PreferenceItemDelegate.qml b/src/commoncomponents/PreferenceItemDelegate.qml index 5515ae2c01830125f0cbffa86761b7d2455c04a6..b6dbdd0feeeabc37ed3fe026a512b5d5b43671ed 100644 --- a/src/commoncomponents/PreferenceItemDelegate.qml +++ b/src/commoncomponents/PreferenceItemDelegate.qml @@ -26,6 +26,7 @@ import QtQuick.Controls.Styles 1.4 import Qt.labs.platform 1.1 import QtQuick.Dialogs 1.3 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../commoncomponents" @@ -162,9 +163,7 @@ ItemDelegate { icon.width: 24 toolTipText: qsTr("Press to choose an image file") - text: { - return ClientWrapper.utilsAdaptor.fileName(preferenceCurrentValue) - } + text: UtilsAdapter.fileName(preferenceCurrentValue) fontPointSize: JamiTheme.buttonFontSize onClicked: { diff --git a/src/commoncomponents/UsernameLineEdit.qml b/src/commoncomponents/UsernameLineEdit.qml index a2834d94cc24fd7a2832ccb98eb19d779aabb65b..5b85f7429a88795a0cdd0362029eb4b970d10b0e 100644 --- a/src/commoncomponents/UsernameLineEdit.qml +++ b/src/commoncomponents/UsernameLineEdit.qml @@ -36,7 +36,7 @@ MaterialLineEdit { Connections { id: registeredNameFoundConnection - target: ClientWrapper.nameDirectory + target: NameDirectory function onRegisteredNameFound(status, address, name) { if (text === name) { @@ -66,7 +66,7 @@ MaterialLineEdit { onTriggered: { if (text.length !== 0 && readOnly === false) { nameRegistrationState = UsernameLineEdit.NameRegistrationState.SEARCHING - ClientWrapper.nameDirectory.lookupName("", text) + NameDirectory.lookupName("", text) } else { nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK } diff --git a/src/conversationsadapter.cpp b/src/conversationsadapter.cpp index 1c979a547ac8db09843f7bfb843768157b718c8f..8eedc4b9fb3a632dd6db59394bd5d4c37deff058 100644 --- a/src/conversationsadapter.cpp +++ b/src/conversationsadapter.cpp @@ -25,7 +25,7 @@ #include "utils.h" -ConversationsAdapter::ConversationsAdapter(QObject *parent) +ConversationsAdapter::ConversationsAdapter(QObject* parent) : QmlAdapterBase(parent) {} @@ -38,14 +38,14 @@ ConversationsAdapter::safeInit() connect(&LRCInstance::behaviorController(), &BehaviorController::showChatView, - [this](const QString &accountId, lrc::api::conversation::Info convInfo) { + [this](const QString& accountId, lrc::api::conversation::Info convInfo) { emit showChatView(accountId, convInfo.uid); }); - connect(&LRCInstance::instance(), &LRCInstance::currentAccountChanged, - [this]() { - accountChangedSetUp(LRCInstance::getCurrAccId()); - }); + connect(&LRCInstance::instance(), + &LRCInstance::currentAccountChanged, + this, + &ConversationsAdapter::onCurrentAccountIdChanged); connectConversationModel(); } @@ -58,28 +58,27 @@ ConversationsAdapter::backToWelcomePage() } void -ConversationsAdapter::selectConversation(const QString &accountId, - const QString &convUid, +ConversationsAdapter::selectConversation(const QString& accountId, + const QString& convUid, bool preventSendingSignal) { - auto &accInfo = LRCInstance::getAccountInfo(accountId); + auto& accInfo = LRCInstance::getAccountInfo(accountId); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); selectConversation(convInfo, preventSendingSignal); } void -ConversationsAdapter::selectConversation(const QString &convUid) +ConversationsAdapter::selectConversation(const QString& convUid) { auto* convModel = LRCInstance::getCurrentConversationModel(); if (convModel == nullptr) { return; } - const auto &conversation = convModel->getConversationForUID(convUid); + const auto& conversation = convModel->getConversationForUID(convUid); if (selectConversation(conversation, false)) { - // If it is calling, show callview (can use showChatView signal, since it will be determined on qml). if (!conversation.uid.isEmpty() && LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) { @@ -89,7 +88,7 @@ ConversationsAdapter::selectConversation(const QString &convUid) } bool -ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &item, +ConversationsAdapter::selectConversation(const lrc::api::conversation::Info& item, bool preventSendingSignal) { // accInfo.conversationModel->selectConversation(item.uid) only emit ui @@ -98,7 +97,7 @@ ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &ite if (LRCInstance::getCurrentConvUid() == item.uid) { return false; } else if (item.participants.size() > 0) { - auto &accInfo = LRCInstance::getAccountInfo(item.accountId); + auto& accInfo = LRCInstance::getAccountInfo(item.accountId); LRCInstance::setSelectedConvId(item.uid); if (!preventSendingSignal) accInfo.conversationModel->selectConversation(item.uid); @@ -125,8 +124,9 @@ ConversationsAdapter::deselectConversation() } void -ConversationsAdapter::accountChangedSetUp(const QString &accountId) +ConversationsAdapter::onCurrentAccountIdChanged() { + auto accountId = LRCInstance::getCurrAccId(); // Should be called when current account is changed. conversationSmartListModel_->setAccount(accountId); @@ -152,7 +152,7 @@ ConversationsAdapter::updateConversationsFilterWidget() } void -ConversationsAdapter::setConversationFilter(const QString &type) +ConversationsAdapter::setConversationFilter(const QString& type) { // Set conversation filter according to type, // type needs to be recognizable by lrc::api::profile::to_type. @@ -183,92 +183,97 @@ ConversationsAdapter::refill() conversationSmartListModel_->fillConversationsList(); } - bool ConversationsAdapter::connectConversationModel(bool updateFilter) { // Signal connections auto currentConversationModel = LRCInstance::getCurrentConversationModel(); - modelSortedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::modelSorted, - [this]() { - conversationSmartListModel_->fillConversationsList(); - updateConversationsFilterWidget(); - emit updateListViewRequested(); - auto* convModel = LRCInstance::getCurrentConversationModel(); - const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid()); - - if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) { - return; - } - const auto contactURI = conversation.participants[0]; - if (contactURI.isEmpty() - || convModel->owner.contactModel->getContact(contactURI).profileInfo.type - == lrc::api::profile::Type::TEMPORARY) { - return; - } - emit modelSorted(QVariant::fromValue(contactURI)); - }); + modelSortedConnection_ = QObject::connect( + currentConversationModel, &lrc::api::ConversationModel::modelSorted, [this]() { + conversationSmartListModel_->fillConversationsList(); + updateConversationsFilterWidget(); + emit updateListViewRequested(); + auto* convModel = LRCInstance::getCurrentConversationModel(); + const auto conversation = convModel->getConversationForUID( + LRCInstance::getCurrentConvUid()); + + if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) { + return; + } + const auto contactURI = conversation.participants[0]; + if (contactURI.isEmpty() + || convModel->owner.contactModel->getContact(contactURI).profileInfo.type + == lrc::api::profile::Type::TEMPORARY) { + return; + } + emit modelSorted(QVariant::fromValue(contactURI)); + }); modelUpdatedConnection_ = QObject::connect(currentConversationModel, &lrc::api::ConversationModel::conversationUpdated, - [this](const QString &convUid) { - conversationSmartListModel_->updateConversation(convUid); - updateConversationsFilterWidget(); - emit updateListViewRequested(); - }); - - filterChangedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::filterChanged, - [this]() { - conversationSmartListModel_->fillConversationsList(); - conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); - updateConversationsFilterWidget(); - emit updateListViewRequested(); - }); - - newConversationConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::newConversation, - [this](const QString &convUid) { - conversationSmartListModel_->fillConversationsList(); - conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); - updateConversationForNewContact(convUid); - }); - - conversationRemovedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::conversationRemoved, - [this]() { - conversationSmartListModel_->fillConversationsList(); - backToWelcomePage(); - }); - - conversationClearedConnection = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::conversationCleared, - [this](const QString &convUid) { - // If currently selected, switch to welcome screen (deselecting current smartlist item ). - if (convUid != LRCInstance::getCurrentConvUid()) { - return; - } - backToWelcomePage(); - }); - - searchStatusChangedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::searchStatusChanged, - [this](const QString &status) { - emit showSearchStatus(status); - }); - - searchResultUpdatedConnection_ = QObject::connect(currentConversationModel, - &lrc::api::ConversationModel::searchResultUpdated, - [this]() { - - conversationSmartListModel_->fillConversationsList(); - conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); - emit updateListViewRequested(); - }); - - if (updateFilter) currentConversationModel->setFilter(""); + [this](const QString& convUid) { + conversationSmartListModel_->updateConversation( + convUid); + updateConversationsFilterWidget(); + emit updateListViewRequested(); + }); + + filterChangedConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::filterChanged, + [this]() { + conversationSmartListModel_->fillConversationsList(); + conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); + updateConversationsFilterWidget(); + emit updateListViewRequested(); + }); + + newConversationConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::newConversation, + [this](const QString& convUid) { + conversationSmartListModel_->fillConversationsList(); + conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); + updateConversationForNewContact(convUid); + }); + + conversationRemovedConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::conversationRemoved, + [this]() { + conversationSmartListModel_->fillConversationsList(); + backToWelcomePage(); + }); + + conversationClearedConnection + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::conversationCleared, + [this](const QString& convUid) { + // If currently selected, switch to welcome screen (deselecting + // current smartlist item ). + if (convUid != LRCInstance::getCurrentConvUid()) { + return; + } + backToWelcomePage(); + }); + + searchStatusChangedConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::searchStatusChanged, + [this](const QString& status) { emit showSearchStatus(status); }); + + searchResultUpdatedConnection_ + = QObject::connect(currentConversationModel, + &lrc::api::ConversationModel::searchResultUpdated, + [this]() { + conversationSmartListModel_->fillConversationsList(); + conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); + emit updateListViewRequested(); + }); + + if (updateFilter) + currentConversationModel->setFilter(""); return true; } @@ -286,7 +291,7 @@ ConversationsAdapter::disconnectConversationModel() } void -ConversationsAdapter::updateConversationForNewContact(const QString &convUid) +ConversationsAdapter::updateConversationForNewContact(const QString& convUid) { auto* convModel = LRCInstance::getCurrentConversationModel(); if (convModel == nullptr) { @@ -296,7 +301,8 @@ ConversationsAdapter::updateConversationForNewContact(const QString &convUid) const auto conversation = convModel->getConversationForUID(convUid); if (!conversation.uid.isEmpty() && !conversation.participants.isEmpty()) { try { - const auto contact = convModel->owner.contactModel->getContact(conversation.participants[0]); + const auto contact = convModel->owner.contactModel->getContact( + conversation.participants[0]); if (!contact.profileInfo.uri.isEmpty() && contact.profileInfo.uri == selectedUid) { LRCInstance::setSelectedConvId(convUid); convModel->selectConversation(convUid); diff --git a/src/conversationsadapter.h b/src/conversationsadapter.h index 56f3462682a65907c1df9cf587583511212d9520..a2b962459ff8a0153186b187a7ca0892043ce664 100644 --- a/src/conversationsadapter.h +++ b/src/conversationsadapter.h @@ -29,7 +29,7 @@ class ConversationsAdapter final : public QmlAdapterBase { Q_OBJECT public: - explicit ConversationsAdapter(QObject *parent = nullptr); + explicit ConversationsAdapter(QObject* parent = nullptr); ~ConversationsAdapter() = default; protected: @@ -38,36 +38,38 @@ protected: public: Q_INVOKABLE bool connectConversationModel(bool updateFilter = true); Q_INVOKABLE void disconnectConversationModel(); - Q_INVOKABLE void selectConversation(const QString &accountId, - const QString &convUid, + Q_INVOKABLE void selectConversation(const QString& accountId, + const QString& convUid, bool preventSendingSignal = true); - Q_INVOKABLE void selectConversation(const QString &uid); + Q_INVOKABLE void selectConversation(const QString& uid); Q_INVOKABLE void deselectConversation(); Q_INVOKABLE void refill(); - Q_INVOKABLE void accountChangedSetUp(const QString &accountId); Q_INVOKABLE void updateConversationsFilterWidget(); - Q_INVOKABLE void setConversationFilter(const QString &type); + Q_INVOKABLE void setConversationFilter(const QString& type); signals: - void showChatView(const QString &accountId, const QString &convUid); + void showChatView(const QString& accountId, const QString& convUid); void showConversationTabs(bool visible); - void showSearchStatus(const QString &status); + void showSearchStatus(const QString& status); void modelChanged(const QVariant& model); void modelSorted(const QVariant& uri); void updateListViewRequested(); void navigateToWelcomePageRequested(); +private slots: + void onCurrentAccountIdChanged(); + private: void setConversationFilter(lrc::api::profile::Type filter); void backToWelcomePage(); - bool selectConversation(const lrc::api::conversation::Info &item, + bool selectConversation(const lrc::api::conversation::Info& item, bool preventSendingSignal = true); - void updateConversationForNewContact(const QString &convUid); + void updateConversationForNewContact(const QString& convUid); - SmartListModel *conversationSmartListModel_; + SmartListModel* conversationSmartListModel_; - lrc::api::profile::Type currentTypeFilter_{}; + lrc::api::profile::Type currentTypeFilter_ {}; /* * Connections. diff --git a/src/lrcinstance.h b/src/lrcinstance.h index b49f8bc38b9c2ac9c7cf6995eeded7c1a210b05c..e66cdac96f69fab68e6498cd9252f784acaa05b2 100644 --- a/src/lrcinstance.h +++ b/src/lrcinstance.h @@ -1,4 +1,4 @@ -/* +/*! * Copyright (C) 2019-2020 by Savoir-faire Linux * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> * Author: Isa Nanic <isa.nanic@savoirfairelinux.com> @@ -58,93 +58,88 @@ using namespace lrc::api; using migrateCallback = std::function<void()>; -using getConvPredicate = std::function<bool(const conversation::Info &conv)>; +using getConvPredicate = std::function<bool(const conversation::Info& conv)>; class LRCInstance : public QObject { Q_OBJECT public: - static LRCInstance & - instance(migrateCallback willMigrate = {}, migrateCallback didMigrate = {}) + static LRCInstance& instance(migrateCallback willMigrate = {}, migrateCallback didMigrate = {}) { static LRCInstance instance_(willMigrate, didMigrate); return instance_; - }; - static void - init(migrateCallback willMigrate = {}, migrateCallback didMigrate = {}) + } + + static void init(migrateCallback willMigrate = {}, migrateCallback didMigrate = {}) { instance(willMigrate, didMigrate); - }; - static Lrc & - getAPI() - { + } + + static Lrc& getAPI() { return *(instance().lrc_); - }; - static RenderManager * - renderer() - { + } + + static RenderManager* renderer() { return instance().renderer_.get(); } - static void - connectivityChanged() - { + + static void connectivityChanged() { instance().lrc_->connectivityChanged(); - }; - static NewAccountModel & - accountModel() - { + } + + static NewAccountModel& accountModel() { return instance().lrc_->getAccountModel(); - }; - static BehaviorController & - behaviorController() + } + + static BehaviorController& behaviorController() { return instance().lrc_->getBehaviorController(); - }; - static DataTransferModel & - dataTransferModel() + } + + static DataTransferModel& dataTransferModel() { return instance().lrc_->getDataTransferModel(); - }; - static AVModel & - avModel() + } + + static AVModel& avModel() { return instance().lrc_->getAVModel(); - }; - static PluginModel & - pluginModel() + } + + static PluginModel& pluginModel() { return instance().lrc_->getPluginModel(); - }; - static bool - isConnected() + } + + static bool isConnected() { return instance().lrc_->isConnected(); - }; - static VectorString - getActiveCalls() + } + + static VectorString getActiveCalls() { return instance().lrc_->activeCalls(); - }; - static const account::Info & - getAccountInfo(const QString &accountId) + } + + static const account::Info& getAccountInfo(const QString& accountId) { return accountModel().getAccountInfo(accountId); - }; - static const account::Info & - getCurrentAccountInfo() + } + + static const account::Info& getCurrentAccountInfo() { return getAccountInfo(getCurrAccId()); - }; - static bool - hasVideoCall() + } + + static bool hasVideoCall() { auto activeCalls = instance().lrc_->activeCalls(); auto accountList = accountModel().getAccountList(); bool result = false; - for (const auto &callId : activeCalls) { - for (const auto &accountId : accountList) { - auto &accountInfo = accountModel().getAccountInfo(accountId); + for (const auto& callId : activeCalls) { + for (const auto& accountId : accountList) { + auto& accountInfo = accountModel().getAccountInfo(accountId); if (accountInfo.callModel->hasCall(callId)) { auto call = accountInfo.callModel->getCall(callId); result |= !(call.isAudioOnly || call.videoMuted); @@ -152,22 +147,22 @@ public: } } return result; - }; - static QString - getCallIdForConversationUid(const QString &convUid, const QString &accountId) + } + + static QString getCallIdForConversationUid(const QString& convUid, const QString& accountId) { - auto &accInfo = LRCInstance::getAccountInfo(accountId); + auto& accInfo = LRCInstance::getAccountInfo(accountId); auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); if (convInfo.uid.isEmpty()) { return {}; } return convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId; } - static const call::Info * - getCallInfo(const QString &callId, const QString &accountId) + + static const call::Info* getCallInfo(const QString& callId, const QString& accountId) { try { - auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); + auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId); if (!accInfo.callModel->hasCall(callId)) { return nullptr; } @@ -176,12 +171,13 @@ public: return nullptr; } } - static const call::Info * - getCallInfoForConversation(const conversation::Info &convInfo, bool forceCallOnly = {}) + + static const call::Info* getCallInfoForConversation(const conversation::Info& convInfo, + bool forceCallOnly = {}) { try { auto accountId = convInfo.accountId; - auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); + auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto callId = forceCallOnly ? convInfo.callId : (convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId); @@ -193,16 +189,18 @@ public: return nullptr; } } - static const conversation::Info & - getConversation(const QString &accountId, getConvPredicate pred = {}, bool filtered = false) + + static const conversation::Info& getConversation(const QString& accountId, + getConvPredicate pred = {}, + bool filtered = false) { using namespace lrc::api; static conversation::Info invalid = {}; try { - auto &accInfo = LRCInstance::getAccountInfo(accountId); - auto &convModel = accInfo.conversationModel; + auto& accInfo = LRCInstance::getAccountInfo(accountId); + auto& convModel = accInfo.conversationModel; if (filtered) { - auto &convs = convModel->allFilteredConversations(); + auto& convs = convModel->allFilteredConversations(); auto conv = std::find_if(convs.begin(), convs.end(), pred); if (conv != convs.end()) { return *conv; @@ -212,7 +210,7 @@ public: i <= static_cast<int>(profile::Type::TEMPORARY); ++i) { auto filter = static_cast<profile::Type>(i); - auto &convs = convModel->getFilteredConversations(filter); + auto& convs = convModel->getFilteredConversations(filter); auto conv = std::find_if(convs.begin(), convs.end(), pred); if (conv != convs.end()) { return *conv; @@ -223,41 +221,40 @@ public: } return invalid; } - static const conversation::Info & - getConversationFromCallId(const QString &callId, - const QString &accountId = {}, - bool filtered = false) + + static const conversation::Info& getConversationFromCallId(const QString& callId, + const QString& accountId = {}, + bool filtered = false) { return getConversation( !accountId.isEmpty() ? accountId : getCurrAccId(), - [&](const conversation::Info &conv) -> bool { return callId == conv.callId or callId == conv.confId; }, + [&](const conversation::Info& conv) -> bool { + return callId == conv.callId or callId == conv.confId; + }, filtered); } - static const conversation::Info & - getConversationFromPeerUri(const QString &peerUri, - const QString &accountId = {}, - bool filtered = false) + + static const conversation::Info& getConversationFromPeerUri(const QString& peerUri, + const QString& accountId = {}, + bool filtered = false) { return getConversation( !accountId.isEmpty() ? accountId : getCurrAccId(), - [&](const conversation::Info &conv) -> bool { return peerUri == conv.participants[0]; }, + [&](const conversation::Info& conv) -> bool { return peerUri == conv.participants[0]; }, filtered); } - static ConversationModel * - getCurrentConversationModel() + static ConversationModel* getCurrentConversationModel() { return getCurrentAccountInfo().conversationModel.get(); - }; + } - static NewCallModel * - getCurrentCallModel() + static NewCallModel* getCurrentCallModel() { return getCurrentAccountInfo().callModel.get(); - }; + } - static const QString & - getCurrAccId() + static const QString& getCurrAccId() { if (instance().selectedAccountId_.isEmpty()) { auto accountList = accountModel().getAccountList(); @@ -265,35 +262,32 @@ public: instance().selectedAccountId_ = accountList.at(0); } return instance().selectedAccountId_; - }; + } - static void - setSelectedAccountId(const QString &accountId = {}) + static void setSelectedAccountId(const QString& accountId = {}) { if (accountId == instance().selectedAccountId_) return; // No need to select current selected account + instance().selectedAccountId_ = accountId; // Last selected account should be set as preferred. accountModel().setTopAccount(accountId); emit instance().currentAccountChanged(); - }; + } - static const QString & - getCurrentConvUid() + static const QString& getCurrentConvUid() { return instance().selectedConvUid_; - }; + } - static void - setSelectedConvId(const QString &convUid = {}) + static void setSelectedConvId(const QString& convUid = {}) { instance().selectedConvUid_ = convUid; - }; + } - static void - reset(bool newInstance = false) + static void reset(bool newInstance = false) { if (newInstance) { instance().renderer_.reset(new RenderManager(avModel())); @@ -302,10 +296,9 @@ public: instance().renderer_.reset(); instance().lrc_.reset(); } - }; + } - static int - getCurrentAccountIndex() + static int getCurrentAccountIndex() { for (int i = 0; i < accountModel().getAccountList().size(); i++) { if (accountModel().getAccountList()[i] == getCurrAccId()) { @@ -313,20 +306,18 @@ public: } } return -1; - }; + } - static const QPixmap - getCurrAccPixmap() + static const QPixmap getCurrAccPixmap() { return instance() .accountListModel_ .data(instance().accountListModel_.index(getCurrentAccountIndex()), AccountListModel::Role::Picture) .value<QPixmap>(); - }; + } - static void - setAvatarForAccount(const QPixmap &avatarPixmap, const QString &accountID) + static void setAvatarForAccount(const QPixmap& avatarPixmap, const QString& accountID) { QByteArray ba; QBuffer bu(&ba); @@ -334,10 +325,9 @@ public: avatarPixmap.save(&bu, "PNG"); auto str = QString::fromLocal8Bit(ba.toBase64()); accountModel().setAvatar(accountID, str); - }; + } - static void - setCurrAccAvatar(const QPixmap &avatarPixmap) + static void setCurrAccAvatar(const QPixmap& avatarPixmap) { QByteArray ba; QBuffer bu(&ba); @@ -345,16 +335,14 @@ public: avatarPixmap.save(&bu, "PNG"); auto str = QString::fromLocal8Bit(ba.toBase64()); accountModel().setAvatar(getCurrAccId(), str); - }; + } - static void - setCurrAccAvatar(const QString &avatar) + static void setCurrAccAvatar(const QString& avatar) { accountModel().setAvatar(getCurrAccId(), avatar); - }; + } - static void - setCurrAccDisplayName(const QString &displayName) + static void setCurrAccDisplayName(const QString& displayName) { auto accountId = LRCInstance::getCurrAccId(); accountModel().setAlias(accountId, displayName); @@ -363,22 +351,19 @@ public: */ auto confProps = LRCInstance::accountModel().getAccountConfig(accountId); LRCInstance::accountModel().setAccountConfig(accountId, confProps); - }; + } - static const account::ConfProperties_t & - getCurrAccConfig() + static const account::ConfProperties_t& getCurrAccConfig() { return instance().getCurrentAccountInfo().confProperties; } - static void - subscribeToDebugReceived() + static void subscribeToDebugReceived() { instance().lrc_->subscribeToDebugReceived(); } - static void - startAudioMeter(bool async) + static void startAudioMeter(bool async) { auto f = [] { if (!LRCInstance::getActiveCalls().size()) { @@ -393,8 +378,7 @@ public: } } - static void - stopAudioMeter(bool async) + static void stopAudioMeter(bool async) { auto f = [] { if (!LRCInstance::getActiveCalls().size()) { @@ -409,28 +393,26 @@ public: } } - static QString - getContentDraft(const QString &convUid, const QString &accountId) + static QString getContentDraft(const QString& convUid, const QString& accountId) { auto draftKey = accountId + "_" + convUid; return instance().contentDrafts_[draftKey]; } - static void - setContentDraft(const QString &convUid, const QString &accountId, const QString &content) + static void setContentDraft(const QString& convUid, + const QString& accountId, + const QString& content) { auto draftKey = accountId + "_" + convUid; instance().contentDrafts_[draftKey] = content; } - static void - pushLastConferencee(const QString &confId, const QString &callId) + static void pushLastConferencee(const QString& confId, const QString& callId) { instance().lastConferencees_[confId] = callId; } - static QString - popLastConferencee(const QString &confId) + static QString popLastConferencee(const QString& confId) { QString callId = {}; auto iter = instance().lastConferencees_.find(confId); @@ -461,4 +443,4 @@ private: MapStringString contentDrafts_; MapStringString lastConferencees_; }; -Q_DECLARE_METATYPE(LRCInstance *) +Q_DECLARE_METATYPE(LRCInstance*) diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index eee9b8d3b9d68e7546d83a20c1051e7a978028d7..26f66a91fa1a2c1fd54d13ec4aad9ecb3ade926e 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -288,7 +288,7 @@ Window { currentIndex: 0 Connections { - target: ClientWrapper.accountAdaptor + target: AccountAdapter function onUpdateConversationForAddedContact() { mainViewWindowSidePanel.needToUpdateConversationForAddedContact() @@ -310,7 +310,7 @@ Window { if (needToShowCallStack && callStackView.responsibleAccountId === UtilsAdapter.getCurrAccId()){ - if (!ClientWrapper.accountAdaptor.hasVideoCall()) { + if (!AccountAdapter.hasVideoCall()) { pushCommunicationMessageWebView() needToShowCallStack = false } else if (needToShowCallStack) { @@ -329,7 +329,7 @@ Window { } Component.onCompleted: { - ClientWrapper.accountAdaptor.setQmlObject(this) + AccountAdapter.setQmlObject(this) } } @@ -485,15 +485,11 @@ Window { // If the item argument is specified, all items down to (but not including) item will be popped. if (!inSettingsView) { mainViewStack.pop(welcomePage) - welcomePage.updateWelcomePage() - qrDialog.updateQrDialog() } } onConversationSmartListViewNeedToShowWelcomePage: { mainViewStack.pop(welcomePage) - welcomePage.updateWelcomePage() - qrDialog.updateQrDialog() } onNeedToUpdateConversationForAddedContact: { diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index b1bc5029f5a2e44dba323594704f940f2932bceb..4edd0ab1f2360410c6b74553538a19b9d945a25e 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -20,6 +20,7 @@ import QtQuick 2.14 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" @@ -50,7 +51,7 @@ ComboBox { } Connections { - target: ClientWrapper.accountAdaptor + target: AccountAdapter function onNavigateToWelcomePageRequested() { needToBackToWelcomePage() diff --git a/src/mainview/components/CallStackView.qml b/src/mainview/components/CallStackView.qml index e93bd78b966cdc80d4670dec231a82a8ef4f7cc7..5b20feef8d83f401f83b45dcea3410120bcf25de 100644 --- a/src/mainview/components/CallStackView.qml +++ b/src/mainview/components/CallStackView.qml @@ -22,6 +22,7 @@ import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls.Universal 2.12 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../js/incomingcallpagecreation.js" as IncomingCallPageCreation import "../js/videocallfullscreenwindowcontainercreation.js" as VideoCallFullScreenWindowContainerCreation diff --git a/src/mainview/components/MediaHandlerPicker.qml b/src/mainview/components/MediaHandlerPicker.qml index 56f9e45f37a1c373b9e036a564284c27938595f5..cfe08b80e861f04608cb4c9123edeac78f72d365 100644 --- a/src/mainview/components/MediaHandlerPicker.qml +++ b/src/mainview/components/MediaHandlerPicker.qml @@ -26,7 +26,7 @@ import "../../commoncomponents" Popup { id: root function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) { - ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded) + PluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded) mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel() } @@ -102,7 +102,7 @@ Popup { delegate: MediaHandlerItemDelegate { id: mediaHandlerItemDelegate - visible: ClientWrapper.pluginModel.getPluginsEnabled() + visible: PluginModel.getPluginsEnabled() width: mediahandlerPickerListView.width height: 50 @@ -231,7 +231,7 @@ Popup { onClicked: mediahandlerPreferencePickerListView.currentIndex = index onBtnPreferenceClicked: { - ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) + PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName) } } diff --git a/src/mainview/components/RecordBox.qml b/src/mainview/components/RecordBox.qml index 730abc2dfb7d6a54861f429a4d13770014d96d42..4e6737f60a56511ecf3de3be411170ad074ad584 100644 --- a/src/mainview/components/RecordBox.qml +++ b/src/mainview/components/RecordBox.qml @@ -21,9 +21,10 @@ import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import QtQuick.Controls.Styles 1.4 import QtQuick.Dialogs 1.3 -import net.jami.Models 1.0 import QtGraphicalEffects 1.15 import QtQuick.Shapes 1.15 +import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" @@ -71,7 +72,7 @@ Rectangle { updateState(RecordBox.States.INIT) if (isVideo){ - ClientWrapper.accountAdaptor.startPreviewing(false) + AccountAdapter.startPreviewing(false) previewAvailable = true } } @@ -79,7 +80,7 @@ Rectangle { function scaleHeight(){ height = preferredHeight if (isVideo) { - var device = ClientWrapper.avmodel.getDefaultDevice() + var device = AVModel.getDefaultDevice() var settings = SettingsAdapter.get_Video_Settings_Size(device) var res = settings.split("x") var aspectRatio = res[1] / res[0] @@ -104,8 +105,8 @@ Rectangle { } function closeRecorder() { - if (isVideo && ClientWrapper.accountAdaptor.isPreviewing()) { - ClientWrapper.accountAdaptor.stopPreviewing() + if (isVideo && AccountAdapter.isPreviewing()) { + AccountAdapter.stopPreviewing() } stopRecording() visible = false @@ -129,7 +130,7 @@ Rectangle { function startRecording() { timer.start() - pathRecorder = ClientWrapper.avmodel.startLocalRecorder(!isVideo) + pathRecorder = AVModel.startLocalRecorder(!isVideo) if (pathRecorder == "") { timer.stop() } @@ -137,7 +138,7 @@ Rectangle { function stopRecording() { if (pathRecorder !== "") { - ClientWrapper.avmodel.stopLocalRecorder(pathRecorder) + AVModel.stopLocalRecorder(pathRecorder) } } @@ -160,11 +161,6 @@ Rectangle { time.text = min + ":" + sec; } - - Connections{ - target: ClientWrapper.renderManager - } - Shape { id: backgroundShape width: recBox.width diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml index e1fd9a310c3d32680e4023de44796de2078ea537..c7e169c32c2e06ed75c11679f94263563536c217 100644 --- a/src/mainview/components/SidePanel.qml +++ b/src/mainview/components/SidePanel.qml @@ -75,7 +75,7 @@ Rectangle { } function refreshAccountComboBox(index) { - ClientWrapper.accountAdaptor.accountChanged(index) + AccountAdapter.accountChanged(index) accountComboBox.update() accountChangedUIReset() diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml index 7d57e82fd6f899b2b92c75a1dfbf13ca55a4d5e5..46e19297baec353c929761d71db8d51c1d3c6c36 100644 --- a/src/mainview/components/VideoCallPage.qml +++ b/src/mainview/components/VideoCallPage.qml @@ -246,7 +246,9 @@ Rectangle { Connections { target: CallAdapter - onPreviewVisibilityNeedToChange: previewRenderer.visible = visible + function onPreviewVisibilityNeedToChange(visible) { + previewRenderer.visible = visible + } } width: videoCallPageMainRect.width / 4 diff --git a/src/mainview/components/WelcomePage.qml b/src/mainview/components/WelcomePage.qml index 7e68015e196950e9f3b318231da7e3b67d869386..f4cd5006e4ec24382ad48546ead2b3fca48ac16b 100644 --- a/src/mainview/components/WelcomePage.qml +++ b/src/mainview/components/WelcomePage.qml @@ -1,4 +1,3 @@ - /* * Copyright (C) 2020 by Savoir-faire Linux * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> @@ -16,23 +15,21 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see <https://www.gnu.org/licenses/>. */ + import QtQuick 2.14 import QtQuick.Controls 2.14 import QtQuick.Layouts 1.14 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 import "../../commoncomponents" Rectangle { id: welcomeRect - property int buttonPreferredSize: 30 + anchors.fill: parent - function updateWelcomePage(){ - jamiShareWithFriendText.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 - jamiRegisteredNameRect.visible = accountListModel.data(accountListModel.index(0, 0), 260) === 1 - textMetricsjamiRegisteredNameText.text = accountListModel.data(accountListModel.index(0, 0), 258) - } + property int buttonPreferredSize: 30 Rectangle { id: welcomeRectComponentsGroup @@ -89,9 +86,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - visible: accountListModel.data(accountListModel.index( - 0, 0), - 260) === 1 + visible: AccountAdapter.currentAccountType === Profile.Type.RING text: qsTr("This is your ID.\nCopy and share it with your friends") color: JamiTheme.faddedFontColor @@ -99,13 +94,14 @@ Rectangle { Rectangle { id: jamiRegisteredNameRect + Layout.alignment: Qt.AlignCenter Layout.preferredWidth: welcomeRectComponentsGroup.width Layout.preferredHeight: 65 Layout.bottomMargin: 5 - visible: accountListModel.data(accountListModel.index( - 0, 0), - 260) === 1 + + visible: AccountAdapter.currentAccountType === Profile.Type.RING + ColumnLayout { id: jamiRegisteredNameRectColumnLayout spacing: 0 @@ -121,9 +117,7 @@ Rectangle { TextMetrics { id: textMetricsjamiRegisteredNameText font: jamiRegisteredNameText.font - text: accountListModel.data( - accountListModel.index( - currentAccountIndex, 0), 258) + text: UtilsAdapter.getBestId(AccountAdapter.currentAccountId) elideWidth: welcomeRectComponentsGroup.width elide: Qt.ElideMiddle } @@ -171,8 +165,4 @@ Rectangle { bBorderwidth: 0 borderColor: JamiTheme.tabbarBorderColor } - - Component.onCompleted: { - updateWelcomePage() - } } diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index 2cc91c0d6a2001bcdec9f68deaeaee130455cd6e..313c7d4e28d6ab31fd3ecd6b4822388e8d108251 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -25,12 +25,6 @@ import net.jami.Adapters 1.0 Dialog { id: userQrImageDialog - property string accountIdStr: UtilsAdapter.getCurrAccId() - - function updateQrDialog() { - accountIdStr = UtilsAdapter.getCurrAccId() - } - // When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model. // (model : true is necessary) modal: true @@ -43,14 +37,12 @@ Dialog { anchors.centerIn: parent - width: 250 - height: 250 + width: 256 + height: 256 + smooth: false fillMode: Image.PreserveAspectFit - source: "image://qrImage/account_" + accountIdStr - sourceSize.width: 260 - sourceSize.height: 260 - mipmap: true + source: "image://qrImage/account_" + AccountAdapter.currentAccountId } background: Rectangle { diff --git a/src/qmlregister.cpp b/src/qmlregister.cpp index 1ab11c63b259e4b1e008fc365b5650848675cdbc..8b51964195b3735fc42af5353f98cc9641f73354 100644 --- a/src/qmlregister.cpp +++ b/src/qmlregister.cpp @@ -27,7 +27,6 @@ #include "avadapter.h" #include "bannedlistmodel.h" #include "calladapter.h" -#include "clientwrapper.h" #include "contactadapter.h" #include "conversationsadapter.h" #include "deviceitemlistmodel.h" @@ -51,127 +50,109 @@ #include <QMetaType> #include <QQmlEngine> +// clang-format off #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; \ + [](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); \ + 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_CUSTOM(N, T, MAJ, MIN, P) \ + qmlRegisterSingletonType<T>(N, MAJ, MIN, #T, \ + [](QQmlEngine* e, QJSEngine* se) -> QObject* { \ + Q_UNUSED(e); Q_UNUSED(se); \ + return P; \ + }); + #define QML_REGISTERSINGLETONTYPE_URL(URL, T, MAJ, MIN) \ - qmlRegisterSingletonType(QUrl(URL), "net.jami.Models", MAJ, MIN, #T); + qmlRegisterSingletonType(QUrl(QStringLiteral(URL)), "net.jami.Models", MAJ, MIN, #T); -#define QML_REGISTERTYPE(T, MAJ, MIN) qmlRegisterType<T>("net.jami.Models", MAJ, MIN, #T); +#define QML_REGISTERTYPE(N, T, MAJ, MIN) qmlRegisterType<T>(N, 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); + 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, \ + 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() +void +registerTypes() { /* - * Register QAbstractListModel type. + * QAbstractListModels */ - 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("net.jami.Models", AccountListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", DeviceItemListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", PluginItemListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", MediaHandlerItemListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", PreferenceItemListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", BannedListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", VideoCodecListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", AudioCodecListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", AccountsToMigrateListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", AudioInputDeviceModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", AudioOutputDeviceModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", AudioManagerListModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", VideoInputDeviceModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", VideoFormatResolutionModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", VideoFormatFpsModel, 1, 0); + QML_REGISTERTYPE("net.jami.Models", PluginListPreferenceModel, 1, 0); /* - * Register QQuickItem type. + * QQuickItems */ - QML_REGISTERTYPE(PreviewRenderer, 1, 0); - QML_REGISTERTYPE(VideoCallPreviewRenderer, 1, 0); - QML_REGISTERTYPE(DistantRenderer, 1, 0); - QML_REGISTERTYPE(PhotoboothPreviewRender, 1, 0) + QML_REGISTERTYPE("net.jami.Models", PreviewRenderer, 1, 0); + QML_REGISTERTYPE("net.jami.Models", VideoCallPreviewRenderer, 1, 0); + QML_REGISTERTYPE("net.jami.Models", DistantRenderer, 1, 0); + QML_REGISTERTYPE("net.jami.Models", PhotoboothPreviewRender, 1, 0) /* - * Adaptors and qml singleton components - qmlRegisterSingletonType. + * Adaptors */ - QML_REGISTERSINGLETONTYPE_URL(QStringLiteral("qrc:/src/constant/JamiTheme.qml"), - JamiTheme, 1, 0); - QML_REGISTERSINGLETONTYPE_URL(QStringLiteral("qrc:/src/constant/JamiQmlUtils.qml"), - JamiQmlUtils, 1, 0); - - QML_REGISTERSINGLETONTYPE("net.jami.Models", AccountAdapter, 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", PluginAdapter, 1, 0); - QML_REGISTERSINGLETONTYPE("net.jami.Models", ClientWrapper, 1, 0); - + QML_REGISTERSINGLETONTYPE("net.jami.Adapters", AccountAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Adapters", UtilsAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Adapters", SettingsAdapter, 1, 0); - QML_REGISTERUNCREATABLE("net.jami.Enums", Settings, 1, 0); + QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", AVModel, 1, 0, &LRCInstance::avModel()) + QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", PluginModel, 1, 0, &LRCInstance::pluginModel()) + QML_REGISTERSINGLETONTYPE_CUSTOM("net.jami.Models", RenderManager, 1, 0, LRCInstance::renderer()) /* - * Lrc models - qmlRegisterUncreatableType & Q_DECLARE_METATYPE. - * This to make lrc models recognizable in qml. + * Qml singleton components */ - 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); + QML_REGISTERSINGLETONTYPE_URL("qrc:/src/constant/JamiTheme.qml", JamiTheme, 1, 0); + QML_REGISTERSINGLETONTYPE_URL("qrc:/src/constant/JamiQmlUtils.qml", JamiQmlUtils, 1, 0); /* - * qmlRegisterUncreatableType & Q_DECLARE_METATYPE to expose models in qml. + * C++ singletons */ - QML_REGISTERUNCREATABLE("net.jami.Models", RenderManager, 1, 0); - QML_REGISTERUNCREATABLE("net.jami.Models", NameDirectory, 1, 0); - QML_REGISTERUNCREATABLE("net.jami.Models", LRCInstance, 1, 0); + QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(LRCInstance, 1, 0); + QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(NameDirectory, 1, 0); /* - * qmlRegisterUncreatableMetaObject to expose namespaces in qml + * lrc namespaces, models, and singletons */ QML_REGISTERNAMESPACE(lrc::api::staticMetaObject, "Lrc", 1, 0); QML_REGISTERNAMESPACE(lrc::api::account::staticMetaObject, "Account", 1, 0); @@ -180,4 +161,23 @@ void registerTypes() 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); + + /* + * same as QML_REGISTERUNCREATABLE but omit the namespace 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(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(NewDeviceModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCodecModel, lrc::api, 1, 0); + QML_REGISTERUNCREATABLE_IN_NAMESPACE(PeerDiscoveryModel, lrc::api, 1, 0); + + /* + * Enums + */ + QML_REGISTERUNCREATABLE("net.jami.Enums", Settings, 1, 0); } +// clang-format on diff --git a/src/qrimageprovider.h b/src/qrimageprovider.h index 90cbf908267f9229909ddc280a106372b24f2049..24bb2577240f999cd5e730795fea48958c9b0242 100644 --- a/src/qrimageprovider.h +++ b/src/qrimageprovider.h @@ -38,15 +38,14 @@ public: enum class QrType { Account, Contact }; /* - * Id should be string like account_0 (account index), - * or contact_xxx (uid). - * Cannot use getCurrentAccId to replace account index, - * since we need to keep each image id unique. - */ - QPair<QrType, QString> - getIndexFromID(const QString &id) + * Id should be string like account_0 (account index), + * or contact_xxx (uid). + * Cannot use getCurrentAccId to replace account index, + * since we need to keep each image id unique. + */ + QPair<QrType, QString> getIndexFromID(const QString& id) { - auto list = id.split('_', QString::SkipEmptyParts); + auto list = id.split('_', Qt::SkipEmptyParts); if (list.size() < 2) return QPair(QrType::Account, ""); if (list.contains("account") && list.size() > 1) { @@ -65,8 +64,7 @@ public: return QPair(QrType::Account, ""); } - QImage - requestImage(const QString &id, QSize *size, const QSize &requestedSize) override + QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) override { Q_UNUSED(size); @@ -84,7 +82,7 @@ public: if (accountList.size() <= accountIndex) return QImage(); - auto &accountInfo = LRCInstance::accountModel().getAccountInfo( + auto& accountInfo = LRCInstance::accountModel().getAccountInfo( accountList.at(accountIndex)); uri = accountInfo.profileInfo.uri; } diff --git a/src/rendermanager.h b/src/rendermanager.h index c3c3f1642eba407720ca094f845ee3ee611d479f..f93e5e613a0952534f225c3be214ac50dd295ca2 100644 --- a/src/rendermanager.h +++ b/src/rendermanager.h @@ -46,7 +46,8 @@ class FrameWrapper final : public QObject Q_OBJECT; public: - FrameWrapper(AVModel &avModel, const QString &id = video::PREVIEW_RENDERER_ID); + FrameWrapper(AVModel &avModel, + const QString &id = video::PREVIEW_RENDERER_ID); ~FrameWrapper(); /* diff --git a/src/settingsview/SettingsView.qml b/src/settingsview/SettingsView.qml index 62cb2cb602ebb224c7ccb8ae0edef6b2714a7bc3..f4b785928a3f25e9cb2b9ef99a2e762098919e6b 100644 --- a/src/settingsview/SettingsView.qml +++ b/src/settingsview/SettingsView.qml @@ -30,7 +30,6 @@ import "components" Rectangle { id: root - enum SettingsMenu{ Account, General, @@ -48,7 +47,7 @@ Rectangle { profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() if(selectedMenu === sel && (!recovery)){return} - switch(sel){ + switch(sel) { case SettingsView.Account: currentAccountSettingsScrollWidget.connectCurrentAccount() @@ -57,7 +56,7 @@ Rectangle { selectedMenu = sel - if(!settingsViewRect.isSIP){ + if(!settingsViewRect.isSIP) { if(currentAccountSettingsScrollWidget.isPhotoBoothOpened()) { currentAccountSettingsScrollWidget.setAvatar() @@ -75,7 +74,7 @@ Rectangle { try{ avSettings.stopAudioMeter() avSettings.stopPreviewing() - } catch(erro){} + } catch(erro) {} selectedMenu = sel generalSettings.populateGeneralSettings() @@ -91,7 +90,7 @@ Rectangle { try{ avSettings.stopAudioMeter() avSettings.stopPreviewing() - } catch(erro){} + } catch(erro) {} selectedMenu = sel pluginSettings.populatePluginSettings() @@ -99,9 +98,9 @@ Rectangle { } } - Connections{ + Connections { id: accountListChangedConnection - target: ClientWrapper.lrcInstance + target: LRCInstance function onAccountListChanged(){ slotAccountListChanged() @@ -124,14 +123,13 @@ Rectangle { } function slotAccountListChanged(){ - var accountList = ClientWrapper.accountModel.getAccountList() + var accountList = AccountAdapter.model.getAccountList() if(accountList.length === 0) - return - + return currentAccountSettingsScrollWidget.disconnectAccountConnections() - var device = ClientWrapper.avmodel.getDefaultDevice() + var device = AVModel.getDefaultDevice() if(device.length === 0){ - ClientWrapper.avmodel.setCurrentVideoCaptureDevice(device) + AVModel.setCurrentVideoCaptureDevice(device) } } property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() diff --git a/src/settingsview/components/AdvancedSIPSettingsView.qml b/src/settingsview/components/AdvancedSIPSettingsView.qml index f499fe3e6655f9c15996630ed9529c343d2d1985..ae28a8639329bf70b8d48849ecedfa05af49bc8d 100644 --- a/src/settingsview/components/AdvancedSIPSettingsView.qml +++ b/src/settingsview/components/AdvancedSIPSettingsView.qml @@ -48,13 +48,13 @@ ColumnLayout { enableSDESToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() fallbackRTPToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() - btnSIPCACert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) - btnSIPUserCert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) - btnSIPPrivateKey.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) + btnSIPCACert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) + btnSIPUserCert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile()) + btnSIPPrivateKey.text = UtilsAdapter.toFileInfoName(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) + enableSDESToggle.checked = (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() @@ -96,7 +96,7 @@ ColumnLayout { updateAudioCodecs() updateVideoCodecs() btnRingtoneSIP.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() - btnRingtoneSIP.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) + btnRingtoneSIP.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) lineEditSTUNAddressSIP.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() // SDP session negotiation ports @@ -161,7 +161,7 @@ ColumnLayout { // slots function audioRTPMinPortSpinBoxEditFinished(value){ - if (ClientWrapper.SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) { + if (SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) { audioRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() return } @@ -177,7 +177,7 @@ ColumnLayout { } function videoRTPMinPortSpinBoxEditFinished(value){ - if (ClientWrapper.SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) { + if (SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) { videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin() return } @@ -197,7 +197,7 @@ ColumnLayout { if(url.length !== 0) { SettingsAdapter.set_RingtonePath(url) btnRingtoneSIP.text = UtilsAdapter.toFileInfoName(url) - } else if (ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ + } else if (SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ btnRingtoneSIP.text = qsTr("Add a custom ringtone") } } diff --git a/src/settingsview/components/AdvancedSettingsView.qml b/src/settingsview/components/AdvancedSettingsView.qml index a969b9f3797500100053b881985da1bda65f2f1b..6a70cd9fd8dcd1ac86127632c8acecd6cdb4cc25 100644 --- a/src/settingsview/components/AdvancedSettingsView.qml +++ b/src/settingsview/components/AdvancedSettingsView.qml @@ -52,9 +52,9 @@ ColumnLayout { lineEditBootstrap.text = SettingsAdapter.getAccountConfig_Hostname() // Security - btnCACert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) - btnUserCert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) - btnPrivateKey.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) + btnCACert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) + btnUserCert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile()) + btnPrivateKey.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) // Connectivity checkBoxUPnP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled() @@ -70,7 +70,7 @@ ColumnLayout { updateAudioCodecs(); updateVideoCodecs(); btnRingtone.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() - btnRingtone.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) + btnRingtone.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_Ringtone_RingtonePath()) lineEditProxy.enabled = SettingsAdapter.getAccountConfig_ProxyEnabled() lineEditSTUNAddress.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() } @@ -129,7 +129,7 @@ ColumnLayout { if(url.length !== 0) { SettingsAdapter.set_RingtonePath(url) btnRingtone.text = UtilsAdapter.toFileInfoName(url) - } else if (ClientWrapper.SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ + } else if (SettingsAdapter.getAccountConfig_Ringtone_RingtonePath().length === 0){ btnRingtone.text = qsTr("Add a custom ringtone") } } @@ -214,7 +214,7 @@ ColumnLayout { id: privateKey_Dialog property string oldPath : { - return ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() + return SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() } property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) diff --git a/src/settingsview/components/AvSettingPage.qml b/src/settingsview/components/AvSettingPage.qml index 2a46abf4f5f62d51d968111bec1e59caac1e6194..72ac98b9a73936061905579bf9cf15994b34ba7d 100644 --- a/src/settingsview/components/AvSettingPage.qml +++ b/src/settingsview/components/AvSettingPage.qml @@ -24,6 +24,8 @@ import QtQuick.Layouts 1.3 import QtGraphicalEffects 1.14 import QtQuick.Controls.Styles 1.4 import net.jami.Models 1.0 +import net.jami.Adapters 1.0 + import "../../commoncomponents" Rectangle { @@ -37,7 +39,7 @@ Rectangle { signal backArrowClicked Connections{ - target: ClientWrapper.avmodel + target: AVModel enabled: root.visible function onAudioMeter(id, level){ @@ -46,7 +48,7 @@ Rectangle { } Connections{ - target: ClientWrapper.renderManager + target: RenderManager enabled: root.visible function onVideoDeviceListChanged(){ @@ -75,7 +77,7 @@ Rectangle { } populateVideoSettings() - var encodeAccel = ClientWrapper.avmodel.getHardwareAcceleration() + var encodeAccel = AVModel.getHardwareAcceleration() hardwareAccelControl.checked = encodeAccel } @@ -99,8 +101,8 @@ Rectangle { } function setFormatListForCurrentDevice(){ - var device = ClientWrapper.avmodel.getCurrentVideoCaptureDevice() - if(ClientWrapper.SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0){ + var device = AVModel.getCurrentVideoCaptureDevice() + if(SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0){ return } @@ -112,22 +114,22 @@ Rectangle { } function startPreviewing(force = false, async = true){ - ClientWrapper.accountAdaptor.startPreviewing(force, async) + AccountAdapter.startPreviewing(force, async) previewAvailable = true } function stopPreviewing(async = true){ - ClientWrapper.accountAdaptor.stopPreviewing(async) + AccountAdapter.stopPreviewing(async) } function startAudioMeter(async = true){ audioInputMeter.start() - ClientWrapper.accountAdaptor.startAudioMeter(async) + AccountAdapter.startAudioMeter(async) } function stopAudioMeter(async = true){ audioInputMeter.stop() - ClientWrapper.accountAdaptor.stopAudioMeter(async) + AccountAdapter.stopAudioMeter(async) } // slots for av page @@ -138,7 +140,7 @@ Rectangle { } function slotSetHardwareAccel(state){ - ClientWrapper.avmodel.setHardwareAcceleration(state) + AVModel.setHardwareAcceleration(state) startPreviewing(true) } @@ -146,7 +148,7 @@ Rectangle { stopAudioMeter(false) var selectedAudioManager = audioManagerComboBox.model.data(audioManagerComboBox.model.index( index, 0), AudioManagerListModel.AudioManagerID) - ClientWrapper.avmodel.setAudioManager(selectedAudioManager) + AVModel.setAudioManager(selectedAudioManager) startAudioMeter(false) } @@ -154,7 +156,7 @@ Rectangle { stopAudioMeter(false) var selectedRingtoneDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index( index, 0), AudioOutputDeviceModel.Device_ID) - ClientWrapper.avmodel.setRingtoneDevice(selectedRingtoneDeviceName) + AVModel.setRingtoneDevice(selectedRingtoneDeviceName) startAudioMeter(false) } @@ -162,7 +164,7 @@ Rectangle { stopAudioMeter(false) var selectedOutputDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index( index, 0), AudioOutputDeviceModel.Device_ID) - ClientWrapper.avmodel.setOutputDevice(selectedOutputDeviceName) + AVModel.setOutputDevice(selectedOutputDeviceName) startAudioMeter(false) } @@ -171,7 +173,7 @@ Rectangle { var selectedInputDeviceName = audioInputComboBox.model.data(audioInputComboBox.model.index( index, 0), AudioInputDeviceModel.Device_ID) - ClientWrapper.avmodel.setInputDevice(selectedInputDeviceName) + AVModel.setInputDevice(selectedInputDeviceName) startAudioMeter(false) } @@ -190,8 +192,8 @@ Rectangle { return } - ClientWrapper.avmodel.setCurrentVideoCaptureDevice(deviceId) - ClientWrapper.avmodel.setDefaultDevice(deviceId) + AVModel.setCurrentVideoCaptureDevice(deviceId) + AVModel.setDefaultDevice(deviceId) setFormatListForCurrentDevice() startPreviewing(true) } catch(err){console.warn(err.message)} @@ -216,7 +218,7 @@ Rectangle { } try{ - SettingsAdapter.set_Video_Settings_Rate_And_Resolution(ClientWrapper.avmodel.getCurrentVideoCaptureDevice(),rate,resolution) + SettingsAdapter.set_Video_Settings_Rate_And_Resolution(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 8a945b0654ae4f2033b24108ec6723d8a100364c..3370563954fe72f134fec13334f90a4158936708 100644 --- a/src/settingsview/components/CurrentAccountSettingsScrollPage.qml +++ b/src/settingsview/components/CurrentAccountSettingsScrollPage.qml @@ -48,12 +48,12 @@ Rectangle { accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() - var showLocalAccountConfig = (ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === "") + var showLocalAccountConfig = (SettingsAdapter.getAccountConfig_Manageruri() === "") passwdPushButton.visible = showLocalAccountConfig btnExportAccount.visible = showLocalAccountConfig linkDevPushButton.visible = showLocalAccountConfig - registeredIdNeedsSet = (ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "") + registeredIdNeedsSet = (SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "") if(!registeredIdNeedsSet){ currentRegisteredID.text = SettingsAdapter.get_CurrentAccountInfo_RegisteredName() @@ -111,8 +111,8 @@ Rectangle { Connections { id: accountConnections_ContactModel - target: ClientWrapper.contactModel - enabled: root.visible + target: AccountAdapter.contactModel + enabled: accountViewRect.visible function onModelUpdated(uri, needsSorted) { updateAndShowBannedContactsSlot() @@ -129,8 +129,8 @@ Rectangle { Connections { id: accountConnections_DeviceModel - target: ClientWrapper.deviceModel - enabled: root.visible + target: AccountAdapter.deviceModel + enabled: accountViewRect.visible function onDeviceAdded(id) { updateAndShowDevicesSlot() @@ -146,7 +146,7 @@ Rectangle { } function setAccEnableSlot(state) { - ClientWrapper.accountModel.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) + AccountAdapter.model.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) } // JamiFileDialog for exporting account @@ -164,12 +164,12 @@ Rectangle { onAccepted: { // is there password? If so, go to password dialog, else, go to following directly var exportPath = UtilsAdapter.getAbsPath(file.toString()) - if (ClientWrapper.accountAdaptor.hasPassword()) { + if (AccountAdapter.hasPassword()) { passwordDialog.openDialog(PasswordDialog.ExportAccount,exportPath) return } else { if (exportPath.length > 0) { - var isSuccessful = ClientWrapper.accountModel.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"") + var isSuccessful = AccountAdapter.model.exportToFile(UtilsAdapter.getCurrAccId(), exportPath,"") var title = isSuccessful ? qsTr("Success") : qsTr("Error") var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical var info = isSuccessful ? qsTr("Export Successful") : qsTr("Export Failed") @@ -212,7 +212,7 @@ Rectangle { } function passwordClicked() { - if (ClientWrapper.accountAdaptor.hasPassword()){ + if (AccountAdapter.hasPassword()){ passwordDialog.openDialog(PasswordDialog.ChangePassword) } else { passwordDialog.openDialog(PasswordDialog.SetPassword) @@ -229,7 +229,7 @@ Rectangle { anchors.centerIn: parent.Center onAccepted: { - ClientWrapper.accountAdaptor.setSelectedConvId() + AccountAdapter.setSelectedConvId() if(UtilsAdapter.getAccountListSize() > 0){ navigateToMainView() @@ -289,8 +289,8 @@ Rectangle { } function removeDeviceSlot(index){ - var idOfDevice = settingsListView.model.data(settingsListView.model.index(index,0), DeviceItemListModel.DeviceID) - if(ClientWrapper.accountAdaptor.hasPassword()){ + var idOfDevice = deviceItemListModel.data(deviceItemListModel.index(index,0), DeviceItemListModel.DeviceID) + if(AccountAdapter.hasPassword()){ revokeDevicePasswordDialog.openRevokeDeviceDialog(idOfDevice) } else { revokeDeviceMessageBox.idOfDev = idOfDevice @@ -299,7 +299,7 @@ Rectangle { } function revokeDeviceWithIDAndPassword(idDevice, password){ - ClientWrapper.deviceModel.revokeDevice(idDevice, password) + AccountAdapter.deviceModel.revokeDevice(idDevice, password) updateAndShowDevicesSlot() } @@ -313,7 +313,7 @@ Rectangle { } function updateAndShowDevicesSlot() { - if(ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === ""){ + if(SettingsAdapter.getAccountConfig_Manageruri() === ""){ linkDevPushButton.visible = true } @@ -450,7 +450,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.accountAdaptor.setCurrAccDisplayName( + AccountAdapter.setCurrAccDisplayName( displayNameLineEdit.text) } } @@ -525,7 +525,7 @@ Rectangle { elide: Text.ElideRight elideWidth: root.width - idLabel.width -JamiTheme.preferredMarginSize*4 - text: ClientWrapper.SettingsAdapter.getCurrentAccount_Profile_Info_Uri() + text: SettingsAdapter.getCurrentAccount_Profile_Info_Uri() } } } @@ -556,7 +556,7 @@ Rectangle { qsTr("Type here to register a username") : "" text: { if (!registeredIdNeedsSet) - return ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() + return SettingsAdapter.get_CurrentAccountInfo_RegisteredName() else return "" } @@ -615,10 +615,10 @@ Rectangle { pressedColor: JamiTheme.buttonTintedBlackPressed outlined: true - toolTipText: ClientWrapper.accountAdaptor.hasPassword() ? + toolTipText: AccountAdapter.hasPassword() ? qsTr("Change the current password") : qsTr("Currently no password, press this button to set a password") - text: ClientWrapper.accountAdaptor.hasPassword() ? qsTr("Change Password") : + text: AccountAdapter.hasPassword() ? qsTr("Change Password") : qsTr("Set Password") source: "qrc:/images/icons/round-edit-24px.svg" diff --git a/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml b/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml index 6896893e9bb032ab73983a75059d0fa6beb28761..34d21a6569df259c06374dcd9978e362a206ee5e 100644 --- a/src/settingsview/components/CurrentSIPAccountSettingScrollPage.qml +++ b/src/settingsview/components/CurrentSIPAccountSettingScrollPage.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" @@ -67,7 +68,7 @@ Rectangle { // slots function setAccEnableSlot(state) { - ClientWrapper.accountModel.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) + AccountAdapter.model.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) } function delAccountSlot() { @@ -80,7 +81,7 @@ Rectangle { anchors.centerIn: parent.Center onAccepted: { - ClientWrapper.accountAdaptor.setSelectedConvId() + AccountAdapter.setSelectedConvId() if(UtilsAdapter.getAccountListSize() > 0){ navigateToMainView() @@ -212,7 +213,7 @@ Rectangle { padding: 8 onEditingFinished: { - ClientWrapper.accountAdaptor.setCurrAccDisplayName( + AccountAdapter.setCurrAccDisplayName( displaySIPNameLineEdit.text) } } diff --git a/src/settingsview/components/GeneralSettingsPage.qml b/src/settingsview/components/GeneralSettingsPage.qml index 48e6558ab6b7c88b47782641d7764e6d0d08eece..68cc60117813794723ddd95e1ede86b036292953 100644 --- a/src/settingsview/components/GeneralSettingsPage.qml +++ b/src/settingsview/components/GeneralSettingsPage.qml @@ -37,12 +37,12 @@ Rectangle { applicationOnStartUpCheckBox.checked = UtilsAdapter.checkStartupLink() notificationCheckBox.checked = SettingsAdapter.getAppValue(Settings.EnableNotifications) - alwaysRecordingCheckBox.checked = ClientWrapper.avmodel.getAlwaysRecord() - recordPreviewCheckBox.checked = ClientWrapper.avmodel.getRecordPreview() - recordQualityValueLabel.text = UtilsAdapter.getRecordQualityString(ClientWrapper.avmodel.getRecordQuality() / 100) - recordQualitySlider.value = ClientWrapper.avmodel.getRecordQuality() / 100 + alwaysRecordingCheckBox.checked = AVModel.getAlwaysRecord() + recordPreviewCheckBox.checked = AVModel.getRecordPreview() + recordQualityValueLabel.text = UtilsAdapter.getRecordQualityString(AVModel.getRecordQuality() / 100) + recordQualitySlider.value = AVModel.getRecordQuality() / 100 - ClientWrapper.avmodel.setRecordPath(ClientWrapper.SettingsAdapter.getDir_Document()) + AVModel.setRecordPath(SettingsAdapter.getDir_Document()) autoUpdateCheckBox.checked = SettingsAdapter.getAppValue(Settings.Key.AutoUpdate) } @@ -64,11 +64,11 @@ Rectangle { } function slotAlwaysRecordingClicked(state){ - ClientWrapper.avmodel.setAlwaysRecord(state) + AVModel.setAlwaysRecord(state) } function slotRecordPreviewClicked(state){ - ClientWrapper.avmodel.setRecordPreview(state) + AVModel.setRecordPreview(state) } function slotRecordQualitySliderValueChanged(value){ @@ -88,7 +88,7 @@ Rectangle { function slotRecordQualitySliderSliderReleased(){ var value = recordQualitySlider.value - ClientWrapper.avmodel.setRecordQuality(value * 100) + AVModel.setRecordQuality(value * 100) } function openDownloadFolderSlot(){ @@ -146,8 +146,8 @@ Rectangle { onRecordPathChanged: { if(recordPath === "") return - if(ClientWrapper.avmodel){ - ClientWrapper.avmodel.setRecordPath(recordPath) + if(AVModel){ + AVModel.setRecordPath(recordPath) } } diff --git a/src/settingsview/components/LinkDeviceDialog.qml b/src/settingsview/components/LinkDeviceDialog.qml index a2e40a90c9037d68e7194c5f1dd5c3d33e5cc620..57f2f1b28717c0d339537f15a01634d8b79aecfa 100644 --- a/src/settingsview/components/LinkDeviceDialog.qml +++ b/src/settingsview/components/LinkDeviceDialog.qml @@ -21,6 +21,7 @@ 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 import "../../commoncomponents" @@ -31,7 +32,7 @@ Dialog { infoLabel.text = qsTr("This pin and the account password should be entered in your device within 10 minutes.") passwordEdit.clear() root.open() - if(ClientWrapper.accountAdaptor.hasPassword()) { + if(AccountAdapter.hasPassword()) { stackedWidget.currentIndex = 0 } else { setGeneratingPage() @@ -39,7 +40,7 @@ Dialog { } function setGeneratingPage() { - if(passwordEdit.length === 0 && ClientWrapper.accountAdaptor.hasPassword()){ + if(passwordEdit.length === 0 && AccountAdapter.hasPassword()){ setExportPage(NameDirectory.ExportOnRingStatus.WRONG_PASSWORD, "") return } @@ -51,7 +52,7 @@ Dialog { } function slotExportOnRing(){ - ClientWrapper.accountModel.exportOnRing(UtilsAdapter.getCurrAccId(),passwordEdit.text) + AccountAdapter.model.exportOnRing(UtilsAdapter.getCurrAccId(),passwordEdit.text) } Timer{ @@ -111,8 +112,8 @@ Dialog { property int exportTimeout : 20000 - Connections{ - target: ClientWrapper.nameDirectory + Connections { + target: NameDirectory function onExportOnRingEnded(status, pin) { setExportPage(status, pin) diff --git a/src/settingsview/components/NameRegistrationDialog.qml b/src/settingsview/components/NameRegistrationDialog.qml index 3fd188af224f32876ad401a850b07ccccbbc9e46..7658033198953bbf57b8a5de487b4e46270f31fc 100644 --- a/src/settingsview/components/NameRegistrationDialog.qml +++ b/src/settingsview/components/NameRegistrationDialog.qml @@ -21,6 +21,7 @@ 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 import "../../commoncomponents" @@ -33,7 +34,7 @@ Dialog { registerdName = registerNameIn lblRegistrationError.text = qsTr("Something went wrong") passwordEdit.clear() - if(ClientWrapper.accountAdaptor.hasPassword()){ + if(AccountAdapter.hasPassword()){ stackedWidget.currentIndex = 0 } else { startRegistration() @@ -49,7 +50,7 @@ Dialog { function slotStartNameRegistration(){ var password = passwordEdit.text - ClientWrapper.accountModel.registerName(UtilsAdapter.getCurrAccId(), password, registerdName) + AccountAdapter.model.registerName(UtilsAdapter.getCurrAccId(), password, registerdName) } function startSpinner(){ @@ -70,7 +71,7 @@ Dialog { } Connections{ - target: ClientWrapper.nameDirectory + target: NameDirectory function onNameRegistrationEnded(status, name){ if(status === NameDirectory.RegisterNameStatus.SUCCESS){ diff --git a/src/settingsview/components/PluginListPreferencesView.qml b/src/settingsview/components/PluginListPreferencesView.qml index f35149130aa73092771f474ece7348f29fc83cb7..872d3950b21af0f0f56e92f7368e36afcf08e132 100644 --- a/src/settingsview/components/PluginListPreferencesView.qml +++ b/src/settingsview/components/PluginListPreferencesView.qml @@ -49,11 +49,11 @@ Rectangle { function resetPlugin(){ if (isLoaded){ - ClientWrapper.pluginModel.unloadPlugin(pluginId) - ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId) - ClientWrapper.pluginModel.loadPlugin(pluginId) + PluginModel.unloadPlugin(pluginId) + PluginModel.resetPluginPreferencesValues(pluginId) + PluginModel.loadPlugin(pluginId) } else { - ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId) + PluginModel.resetPluginPreferencesValues(pluginId) } pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId) } @@ -63,18 +63,18 @@ Rectangle { } function uninstallPlugin(){ - ClientWrapper.pluginModel.uninstallPlugin(pluginId) + PluginModel.uninstallPlugin(pluginId) } function setPreference(pluginId, preferenceKey, preferenceNewValue) { if (isLoaded){ - ClientWrapper.pluginModel.unloadPlugin(pluginId) - ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) - ClientWrapper.pluginModel.loadPlugin(pluginId) + PluginModel.unloadPlugin(pluginId) + PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) + PluginModel.loadPlugin(pluginId) } else { - ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) + PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) } } diff --git a/src/settingsview/components/PluginListSettingsView.qml b/src/settingsview/components/PluginListSettingsView.qml index a0edd1268b0583dfab7c101cf04e48316bc14e0f..5dec9fbdbbba4ca03971643b5d1ab8993d02762b 100644 --- a/src/settingsview/components/PluginListSettingsView.qml +++ b/src/settingsview/components/PluginListSettingsView.qml @@ -40,9 +40,9 @@ Rectangle { function loadPluginSlot(pluginId, isLoaded){ var loaded = false if (isLoaded) - ClientWrapper.pluginModel.unloadPlugin(pluginId) + PluginModel.unloadPlugin(pluginId) else - loaded = ClientWrapper.pluginModel.loadPlugin(pluginId) + loaded = PluginModel.loadPlugin(pluginId) if(pluginListPreferencesView.pluginId === pluginId) pluginListPreferencesView.isLoaded = loaded } @@ -78,7 +78,7 @@ Rectangle { onAccepted: { var url = UtilsAdapter.getAbsPath(file.toString()) - ClientWrapper.pluginModel.installPlugin(url, true) + PluginModel.installPlugin(url, true) } } diff --git a/src/settingsview/components/PluginSettingsPage.qml b/src/settingsview/components/PluginSettingsPage.qml index 85d5fba4586c4fdfce1c2351ae55c76fc26e4bb9..c61024e1761dfc160adc46a51dc14d3b3ff579a5 100644 --- a/src/settingsview/components/PluginSettingsPage.qml +++ b/src/settingsview/components/PluginSettingsPage.qml @@ -31,12 +31,12 @@ Rectangle { function populatePluginSettings(){ // settings - enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled() + enabledplugin.checked = PluginModel.getPluginsEnabled() pluginListSettingsView.visible = enabledplugin.checked } function slotSetPluginEnabled(state){ - ClientWrapper.pluginModel.setPluginsEnabled(state) + PluginModel.setPluginsEnabled(state) } signal backArrowClicked @@ -110,7 +110,7 @@ Rectangle { pluginListSettingsView.visible = checked if (!pluginListSettingsView.visible) { - ClientWrapper.pluginModel.toggleCallMediaHandler("", true) + PluginModel.toggleCallMediaHandler("", true) pluginListSettingsView.hidePreferences() } } diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index 66d423a9097419bbc396257abdb82932ab921469..88dee99e4017c5bd07958516a62d088ba8749d5f 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -60,13 +60,13 @@ UtilsAdapter::setText(QString text) } const QString -UtilsAdapter::qStringFromFile(const QString &filename) +UtilsAdapter::qStringFromFile(const QString& filename) { return Utils::QByteArrayFromFile(filename); } const QString -UtilsAdapter::getStyleSheet(const QString &name, const QString &source) +UtilsAdapter::getStyleSheet(const QString& name, const QString& source) { auto simplifiedCSS = source.simplified().replace("'", "\""); QString s = QString::fromLatin1("(function() {" @@ -106,20 +106,29 @@ UtilsAdapter::checkStartupLink() } const QString -UtilsAdapter::getContactImageString(const QString &accountId, const QString &uid) +UtilsAdapter::getContactImageString(const QString& accountId, const QString& uid) { return Utils::getContactImageString(accountId, uid); } const QString -UtilsAdapter::getBestName(const QString &accountId, const QString &uid) +UtilsAdapter::getBestName(const QString& accountId, const QString& uid) { auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get(); return Utils::bestNameForConversation(convModel->getConversationForUID(uid), *convModel); } +QString +UtilsAdapter::getBestId(const QString& accountId) +{ + if (accountId.isEmpty()) + return {}; + auto& accountInfo = LRCInstance::getAccountInfo(accountId); + return Utils::bestIdForAccount(accountInfo); +} + const QString -UtilsAdapter::getBestId(const QString &accountId, const QString &uid) +UtilsAdapter::getBestId(const QString& accountId, const QString& uid) { auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get(); return Utils::bestIdForConversation(convModel->getConversationForUID(uid), *convModel); @@ -128,13 +137,13 @@ UtilsAdapter::getBestId(const QString &accountId, const QString &uid) int UtilsAdapter::getTotalUnreadMessages() { - int totalUnreadMessages{0}; + int totalUnreadMessages {0}; if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) { auto* convModel = LRCInstance::getCurrentConversationModel(); auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING); std::for_each(ringConversations.begin(), ringConversations.end(), - [&totalUnreadMessages](const auto &conversation) { + [&totalUnreadMessages](const auto& conversation) { totalUnreadMessages += conversation.unreadMessages; }); } @@ -144,24 +153,24 @@ UtilsAdapter::getTotalUnreadMessages() int UtilsAdapter::getTotalPendingRequest() { - auto &accountInfo = LRCInstance::getCurrentAccountInfo(); + auto& accountInfo = LRCInstance::getCurrentAccountInfo(); return accountInfo.contactModel->pendingRequestCount(); } void -UtilsAdapter::setConversationFilter(const QString &filter) +UtilsAdapter::setConversationFilter(const QString& filter) { LRCInstance::getCurrentConversationModel()->setFilter(filter); } void -UtilsAdapter::clearConversationHistory(const QString &accountId, const QString &uid) +UtilsAdapter::clearConversationHistory(const QString& accountId, const QString& uid) { LRCInstance::getAccountInfo(accountId).conversationModel->clearHistory(uid); } void -UtilsAdapter::removeConversation(const QString &accountId, const QString &uid, bool banContact) +UtilsAdapter::removeConversation(const QString& accountId, const QString& uid, bool banContact) { LRCInstance::getAccountInfo(accountId).conversationModel->removeConversation(uid, banContact); } @@ -197,9 +206,9 @@ UtilsAdapter::getAccountListSize() } void -UtilsAdapter::setCurrentCall(const QString &accountId, const QString &convUid) +UtilsAdapter::setCurrentCall(const QString& accountId, const QString& convUid) { - auto &accInfo = LRCInstance::getAccountInfo(accountId); + auto& accInfo = LRCInstance::getAccountInfo(accountId); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); accInfo.callModel->setCurrentCall(convInfo.callId); } @@ -225,9 +234,9 @@ UtilsAdapter::hasVideoCall() } const QString -UtilsAdapter::getCallId(const QString &accountId, const QString &convUid) +UtilsAdapter::getCallId(const QString& accountId, const QString& convUid) { - auto &accInfo = LRCInstance::getAccountInfo(accountId); + auto& accInfo = LRCInstance::getAccountInfo(accountId); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); if (convInfo.uid.isEmpty()) { @@ -249,10 +258,9 @@ UtilsAdapter::getCallStatusStr(int statusInt) return lrc::api::call::to_string(status); } - // returns true if name is valid registered name bool -UtilsAdapter::validateRegNameForm(const QString ®Name) +UtilsAdapter::validateRegNameForm(const QString& regName) { QRegularExpression regExp(" "); diff --git a/src/utilsadapter.h b/src/utilsadapter.h index 6704e43a7610bb262a1afb11d1e5fbf6601ec3e0..4210fcfb7bde5d28a88651031d43f8c6fb000fce 100644 --- a/src/utilsadapter.h +++ b/src/utilsadapter.h @@ -31,47 +31,43 @@ class UtilsAdapter final : public QObject { Q_OBJECT public: - explicit UtilsAdapter(QObject *parent = nullptr); + explicit UtilsAdapter(QObject* parent = nullptr); ~UtilsAdapter() = default; Q_INVOKABLE const QString getChangeLog(); Q_INVOKABLE const QString getProjectCredits(); Q_INVOKABLE const QString getVersionStr(); Q_INVOKABLE void setText(QString text); - Q_INVOKABLE const QString qStringFromFile(const QString &filename); - Q_INVOKABLE const QString getStyleSheet(const QString &name, - const QString &source); + Q_INVOKABLE const QString qStringFromFile(const QString& filename); + Q_INVOKABLE const QString getStyleSheet(const QString& name, const QString& source); Q_INVOKABLE const QString getCachePath(); Q_INVOKABLE bool createStartupLink(); Q_INVOKABLE QString GetRingtonePath(); Q_INVOKABLE bool checkStartupLink(); - Q_INVOKABLE const QString getContactImageString(const QString &accountId, - const QString &uid); - Q_INVOKABLE void removeConversation(const QString &accountId, - const QString &uid, + Q_INVOKABLE const QString getContactImageString(const QString& accountId, const QString& uid); + Q_INVOKABLE void removeConversation(const QString& accountId, + const QString& uid, bool banContact = false); - Q_INVOKABLE void clearConversationHistory(const QString &accountId, - const QString &uid); - Q_INVOKABLE void setConversationFilter(const QString &filter); + Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& uid); + Q_INVOKABLE void setConversationFilter(const QString& filter); Q_INVOKABLE int getTotalUnreadMessages(); Q_INVOKABLE int getTotalPendingRequest(); - Q_INVOKABLE const QString getBestName(const QString &accountId, - const QString &uid); - Q_INVOKABLE const QString getBestId(const QString &accountId, - const QString &uid); + Q_INVOKABLE const QString getBestName(const QString& accountId, const QString& uid); + Q_INVOKABLE QString getBestId(const QString& accountId); + Q_INVOKABLE const QString getBestId(const QString& accountId, const QString& uid); Q_INVOKABLE const QString getCurrAccId(); Q_INVOKABLE const QString getCurrConvId(); Q_INVOKABLE void makePermanentCurrentConv(); Q_INVOKABLE const QStringList getCurrAccList(); Q_INVOKABLE int getAccountListSize(); - Q_INVOKABLE void setCurrentCall(const QString &accountId, const QString &convUid); + Q_INVOKABLE void setCurrentCall(const QString& accountId, const QString& convUid); Q_INVOKABLE void startPreviewing(bool force); Q_INVOKABLE void stopPreviewing(); Q_INVOKABLE bool hasVideoCall(); - Q_INVOKABLE const QString getCallId(const QString &accountId, const QString &convUid); + Q_INVOKABLE const QString getCallId(const QString& accountId, const QString& convUid); Q_INVOKABLE const QString getCallStatusStr(int statusInt); Q_INVOKABLE QString getStringUTF8(QString string); - Q_INVOKABLE bool validateRegNameForm(const QString ®Name); + Q_INVOKABLE bool validateRegNameForm(const QString& regName); Q_INVOKABLE QString getRecordQualityString(int value); Q_INVOKABLE QString getCurrentPath(); Q_INVOKABLE QString stringSimplifier(QString input); @@ -86,6 +82,6 @@ public: Q_INVOKABLE bool isImage(const QString& fileExt); private: - QClipboard *clipboard_; + QClipboard* clipboard_; }; -Q_DECLARE_METATYPE(UtilsAdapter *) +Q_DECLARE_METATYPE(UtilsAdapter*) diff --git a/src/wizardview/WizardView.qml b/src/wizardview/WizardView.qml index fbd98cb0c6f46cb7d97eed15e686a6a2b23f2149..e2fe298c5b4c4287f254a73df77da0c75020aaf2 100644 --- a/src/wizardview/WizardView.qml +++ b/src/wizardview/WizardView.qml @@ -76,11 +76,11 @@ Rectangle { } Connections{ - target: ClientWrapper.accountAdaptor + target: AccountAdapter function onAccountAdded(showBackUp, index) { addedAccountIndex = index - ClientWrapper.accountAdaptor.accountChanged(index) + AccountAdapter.accountChanged(index) if (showProfile) { changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE) profilePage.readyToSaveDetails() @@ -150,7 +150,7 @@ Rectangle { var info = success ? qsTr("Export Successful") : qsTr( "Export Failed") - ClientWrapper.accountAdaptor.passwordSetStatusMessageBox(success, + AccountAdapter.passwordSetStatusMessageBox(success, title, info) if (success) { console.log("Account Export Succeed") @@ -190,7 +190,7 @@ Rectangle { onCreateAccount: { inputParaObject = {} inputParaObject["password"] = text_passwordEditAlias - ClientWrapper.accountAdaptor.createJamiAccount( + AccountAdapter.createJamiAccount( createAccountPage.text_usernameEditAlias, inputParaObject, createAccountPage.boothImgBase64, @@ -220,7 +220,7 @@ Rectangle { inputParaObject["proxy"] = createSIPAccountPage.text_sipProxyEditAlias createSIPAccountPage.clearAllTextFields() - ClientWrapper.accountAdaptor.createSIPAccount(inputParaObject, "") + AccountAdapter.createSIPAccount(inputParaObject, "") showBackUp = false showBottom = false changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE) @@ -242,7 +242,7 @@ Rectangle { showBackUp = false showBottom = false showProfile = true - ClientWrapper.accountAdaptor.createJamiAccount( + AccountAdapter.createJamiAccount( "", inputParaObject, "", false) } } @@ -257,13 +257,13 @@ Rectangle { onExport_Btn_FileDialogAccepted: { if (accepted) { // is there password? If so, go to password dialog, else, go to following directly - if (ClientWrapper.accountAdaptor.hasPassword()) { + if (AccountAdapter.hasPassword()) { passwordDialog.path = UtilsAdapter.getAbsPath(folderDir) passwordDialog.open() return } else { if (folderDir.length > 0) { - ClientWrapper.accountAdaptor.exportToFile( + AccountAdapter.exportToFile( UtilsAdapter.getCurrAccId(), UtilsAdapter.getAbsPath(folderDir)) } @@ -295,7 +295,7 @@ Rectangle { showProfile = true showBackUp = false showBottom = false - ClientWrapper.accountAdaptor.createJamiAccount( + AccountAdapter.createJamiAccount( "", inputParaObject, "", false) } } @@ -311,7 +311,7 @@ Rectangle { = connectToAccountManagerPage.text_passwordManagerEditAlias inputParaObject["manager"] = connectToAccountManagerPage.text_accountManagerEditAlias - ClientWrapper.accountAdaptor.createJAMSAccount(inputParaObject) + AccountAdapter.createJAMSAccount(inputParaObject) } onLeavePage: { @@ -333,7 +333,7 @@ Rectangle { onSaveProfile: { SettingsAdapter.setCurrAccAvatar(profilePage.boothImgBase64) - ClientWrapper.accountAdaptor.setCurrAccDisplayName(profilePage.displayName) + AccountAdapter.setCurrAccDisplayName(profilePage.displayName) leave() } diff --git a/src/wizardview/components/WelcomePage.qml b/src/wizardview/components/WelcomePage.qml index 542a6b13c2127dc01c3101e5e46537e735d61bf2..6434df0e535e0e28745454b2dda1e59b501fab97 100644 --- a/src/wizardview/components/WelcomePage.qml +++ b/src/wizardview/components/WelcomePage.qml @@ -210,7 +210,7 @@ Rectangle { anchors.margins: 20 Connections { - target: ClientWrapper.lrcInstance + target: LRCInstance function onAccountListChanged() { backButton.visible = UtilsAdapter.getAccountListSize()