1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-03 22:35:45 +02:00

qml interop: remove clientwrapper

The clientwrapper class masks granular object registration within
qml, and encourages code duplication between viewmodels(adapters)
and code lasagnafication and the misuse of declarative Qml.

Change-Id: I85fef214363e62e54fc0681282323ea4861000d6
Gitlab: #66
This commit is contained in:
Andreas Traczyk 2020-09-04 17:53:24 -04:00
parent 88816940fb
commit ae058405a5
44 changed files with 712 additions and 890 deletions

View file

@ -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

View file

@ -143,7 +143,7 @@ ApplicationWindow {
}
Connections {
target: ClientWrapper.lrcInstance
target: LRCInstance
function onRestoreAppRequested() {
if (mainViewLoader.item)

View file

@ -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()
{
static auto instance = new AccountAdapter;
return *instance;
}
void
AccountAdapter::safeInit()
{
setSelectedAccount(LRCInstance::getCurrAccId());
setSelectedAccountId(LRCInstance::getCurrAccId());
}
lrc::api::NewAccountModel*
AccountAdapter::getModel()
{
return &(LRCInstance::accountModel());
}
lrc::api::ContactModel*
AccountAdapter::getContactModel()
{
return LRCInstance::getCurrentAccountInfo().contactModel.get();
}
lrc::api::NewDeviceModel*
AccountAdapter::getDeviceModel()
{
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);
});

View file

@ -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:
explicit AccountAdapter(QObject *parent = 0);
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);
~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*)

View file

@ -1,4 +1,4 @@
/*
/*!
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
*

View file

@ -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();
}

View file

@ -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 *)

View file

@ -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(){

View file

@ -160,7 +160,7 @@ Dialog {
font.kerning: true
onClicked: {
ClientWrapper.accountAdaptor.deleteCurrentAccount()
AccountAdapter.deleteCurrentAccount()
accept()
}
}

View file

@ -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

View file

@ -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)}

View file

@ -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: {

View file

@ -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
}

View file

@ -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());
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));
});
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();
});
[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();
});
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);
});
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();
});
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();
});
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);
});
searchStatusChangedConnection_
= QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchStatusChanged,
[this](const QString& status) { emit showSearchStatus(status); });
searchResultUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchResultUpdated,
[this]() {
searchResultUpdatedConnection_
= QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::searchResultUpdated,
[this]() {
conversationSmartListModel_->fillConversationsList();
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId());
emit updateListViewRequested();
});
conversationSmartListModel_->fillConversationsList();
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId());
emit updateListViewRequested();
});
if (updateFilter) currentConversationModel->setFilter("");
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);

View file

@ -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.

View file

@ -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; },
filtered);
}
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 callId == conv.callId or callId == conv.confId;
},
filtered);
}
static ConversationModel *
getCurrentConversationModel()
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]; },
filtered);
}
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*)

View file

@ -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: {

View file

@ -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()

View file

@ -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

View file

@ -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)
}
}

View file

@ -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

View file

@ -75,7 +75,7 @@ Rectangle {
}
function refreshAccountComboBox(index) {
ClientWrapper.accountAdaptor.accountChanged(index)
AccountAdapter.accountChanged(index)
accountComboBox.update()
accountChangedUIReset()

View file

@ -246,7 +246,9 @@ Rectangle {
Connections {
target: CallAdapter
onPreviewVisibilityNeedToChange: previewRenderer.visible = visible
function onPreviewVisibilityNeedToChange(visible) {
previewRenderer.visible = visible
}
}
width: videoCallPageMainRect.width / 4

View file

@ -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()
}
}

View file

@ -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 {

View file

@ -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_URL(URL, T, MAJ, MIN) \
qmlRegisterSingletonType(QUrl(URL), "net.jami.Models", MAJ, MIN, #T);
#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_REGISTERTYPE(T, MAJ, MIN) qmlRegisterType<T>("net.jami.Models", MAJ, MIN, #T);
#define QML_REGISTERSINGLETONTYPE_URL(URL, T, MAJ, MIN) \
qmlRegisterSingletonType(QUrl(QStringLiteral(URL)), "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

View file

@ -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;
}

View file

@ -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();
/*

View file

@ -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()

View file

@ -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")
}
}

View file

@ -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))

View file

@ -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)}
}

View file

@ -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"

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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)

View file

@ -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){

View file

@ -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)
}
}

View file

@ -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)
}
}

View file

@ -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()
}
}

View file

@ -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 &regName)
UtilsAdapter::validateRegNameForm(const QString& regName)
{
QRegularExpression regExp(" ");

View file

@ -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 &regName);
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*)

View file

@ -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()
}

View file

@ -210,7 +210,7 @@ Rectangle {
anchors.margins: 20
Connections {
target: ClientWrapper.lrcInstance
target: LRCInstance
function onAccountListChanged() {
backButton.visible = UtilsAdapter.getAccountListSize()