1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-08-04 06:45: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 # Input
HEADERS += ./src/smartlistmodel.h \ HEADERS += \
./src/utils.h \ src/smartlistmodel.h \
./src/bannedlistmodel.h \ src/utils.h \
./src/version.h \ src/bannedlistmodel.h \
./src/accountlistmodel.h \ src/version.h \
./src/runguard.h \ src/accountlistmodel.h \
./src/lrcinstance.h \ src/runguard.h \
./src/globalsystemtray.h \ src/lrcinstance.h \
./src/appsettingsmanager.h \ src/globalsystemtray.h \
./src/webchathelpers.h \ src/appsettingsmanager.h \
./src/pixbufmanipulator.h \ src/webchathelpers.h \
./src/rendermanager.h \ src/pixbufmanipulator.h \
./src/connectivitymonitor.h \ src/rendermanager.h \
./src/jamiavatartheme.h \ src/connectivitymonitor.h \
./src/mainapplication.h \ src/jamiavatartheme.h \
./src/qrimageprovider.h \ src/mainapplication.h \
./src/messagesadapter.h \ src/qrimageprovider.h \
./src/accountadapter.h \ src/messagesadapter.h \
./src/tintedbuttonimageprovider.h \ src/accountadapter.h \
./src/calladapter.h \ src/tintedbuttonimageprovider.h \
./src/conversationsadapter.h \ src/calladapter.h \
./src/distantrenderer.h \ src/conversationsadapter.h \
./src/previewrenderer.h \ src/distantrenderer.h \
./src/qmladapterbase.h \ src/previewrenderer.h \
./src/avadapter.h \ src/qmladapterbase.h \
./src/contactadapter.h \ src/avadapter.h \
./src/pluginadapter.h \ src/contactadapter.h \
./src/settingsadapter.h \ src/pluginadapter.h \
./src/deviceitemlistmodel.h \ src/settingsadapter.h \
./src/pluginitemlistmodel.h \ src/deviceitemlistmodel.h \
./src/mediahandleritemlistmodel.h \ src/pluginitemlistmodel.h \
./src/preferenceitemlistmodel.h \ src/mediahandleritemlistmodel.h \
./src/audiocodeclistmodel.h \ src/preferenceitemlistmodel.h \
./src/videocodeclistmodel.h \ src/audiocodeclistmodel.h \
./src/accountstomigratelistmodel.h \ src/videocodeclistmodel.h \
./src/clientwrapper.h \ src/accountstomigratelistmodel.h \
./src/audioinputdevicemodel.h \ src/audioinputdevicemodel.h \
./src/videoinputdevicemodel.h \ src/videoinputdevicemodel.h \
./src/audiooutputdevicemodel.h \ src/audiooutputdevicemodel.h \
./src/pluginlistpreferencemodel.h \ src/pluginlistpreferencemodel.h \
./src/videoformatfpsmodel.h \ src/videoformatfpsmodel.h \
./src/videoformatresolutionmodel.h \ src/videoformatresolutionmodel.h \
./src/audiomanagerlistmodel.h \ src/audiomanagerlistmodel.h \
src/qmlregister.h \ src/qmlregister.h \
src/qtutils.h \ src/qtutils.h \
src/utilsadapter.h src/utilsadapter.h
SOURCES += ./src/bannedlistmodel.cpp \ SOURCES += \
./src/accountlistmodel.cpp \ src/bannedlistmodel.cpp \
./src/runguard.cpp \ src/accountlistmodel.cpp \
./src/webchathelpers.cpp \ src/runguard.cpp \
./src/main.cpp \ src/webchathelpers.cpp \
./src/globalsystemtray.cpp \ src/main.cpp \
./src/smartlistmodel.cpp \ src/globalsystemtray.cpp \
./src/utils.cpp \ src/smartlistmodel.cpp \
./src/pixbufmanipulator.cpp \ src/utils.cpp \
./src/rendermanager.cpp \ src/pixbufmanipulator.cpp \
./src/connectivitymonitor.cpp \ src/rendermanager.cpp \
./src/mainapplication.cpp \ src/connectivitymonitor.cpp \
./src/messagesadapter.cpp \ src/mainapplication.cpp \
./src/accountadapter.cpp \ src/messagesadapter.cpp \
./src/calladapter.cpp \ src/accountadapter.cpp \
./src/conversationsadapter.cpp \ src/calladapter.cpp \
./src/distantrenderer.cpp \ src/conversationsadapter.cpp \
./src/previewrenderer.cpp \ src/distantrenderer.cpp \
./src/avadapter.cpp \ src/previewrenderer.cpp \
./src/contactadapter.cpp \ src/avadapter.cpp \
./src/pluginadapter.cpp \ src/contactadapter.cpp \
./src/settingsadapter.cpp \ src/pluginadapter.cpp \
./src/deviceitemlistmodel.cpp \ src/settingsadapter.cpp \
./src/pluginitemlistmodel.cpp \ src/deviceitemlistmodel.cpp \
./src/mediahandleritemlistmodel.cpp \ src/pluginitemlistmodel.cpp \
./src/preferenceitemlistmodel.cpp \ src/mediahandleritemlistmodel.cpp \
./src/audiocodeclistmodel.cpp \ src/preferenceitemlistmodel.cpp \
./src/videocodeclistmodel.cpp \ src/audiocodeclistmodel.cpp \
./src/accountstomigratelistmodel.cpp \ src/videocodeclistmodel.cpp \
./src/clientwrapper.cpp \ src/accountstomigratelistmodel.cpp \
./src/audioinputdevicemodel.cpp \ src/audioinputdevicemodel.cpp \
./src/videoinputdevicemodel.cpp \ src/videoinputdevicemodel.cpp \
./src/audiooutputdevicemodel.cpp \ src/audiooutputdevicemodel.cpp \
./src/pluginlistpreferencemodel.cpp \ src/pluginlistpreferencemodel.cpp \
./src/videoformatfpsmodel.cpp \ src/videoformatfpsmodel.cpp \
./src/videoformatresolutionmodel.cpp \ src/videoformatresolutionmodel.cpp \
./src/audiomanagerlistmodel.cpp \ src/audiomanagerlistmodel.cpp \
src/qmlregister.cpp \ src/qmlregister.cpp \
src/utilsadapter.cpp src/utilsadapter.cpp
RESOURCES += ./resources.qrc \ RESOURCES += \
./qml.qrc resources.qrc \
qml.qrc

View file

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

View file

@ -28,21 +28,32 @@
#undef REGISTERED #undef REGISTERED
#include "../daemon/src/dring/account_const.h" #include "../daemon/src/dring/account_const.h"
AccountAdapter::AccountAdapter(QObject *parent) AccountAdapter::AccountAdapter(QObject* parent)
: QmlAdapterBase(parent) : QmlAdapterBase(parent)
{} {}
AccountAdapter &
AccountAdapter::instance()
{
static auto instance = new AccountAdapter;
return *instance;
}
void void
AccountAdapter::safeInit() 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 void
@ -50,7 +61,7 @@ AccountAdapter::accountChanged(int index)
{ {
auto accountList = LRCInstance::accountModel().getAccountList(); auto accountList = LRCInstance::accountModel().getAccountList();
if (accountList.size() > index) if (accountList.size() > index)
setSelectedAccount(accountList.at(index)); setSelectedAccountId(accountList.at(index));
} }
void void
@ -58,13 +69,13 @@ AccountAdapter::connectFailure()
{ {
Utils::oneShotConnect(&LRCInstance::accountModel(), Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountRemoved, &lrc::api::NewAccountModel::accountRemoved,
[this](const QString &accountId) { [this](const QString& accountId) {
Q_UNUSED(accountId); Q_UNUSED(accountId);
emit reportFailure(); emit reportFailure();
}); });
Utils::oneShotConnect(&LRCInstance::accountModel(), Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::invalidAccountDetected, &lrc::api::NewAccountModel::invalidAccountDetected,
[this](const QString &accountId) { [this](const QString& accountId) {
Q_UNUSED(accountId); Q_UNUSED(accountId);
emit reportFailure(); emit reportFailure();
}); });
@ -72,16 +83,17 @@ AccountAdapter::connectFailure()
void void
AccountAdapter::createJamiAccount(QString registeredName, AccountAdapter::createJamiAccount(QString registeredName,
const QVariantMap &settings, const QVariantMap& settings,
QString photoBoothImgBase64, QString photoBoothImgBase64,
bool isCreating) bool isCreating)
{ {
Utils::oneShotConnect( Utils::oneShotConnect(
&LRCInstance::accountModel(), &LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountAdded, &lrc::api::NewAccountModel::accountAdded,
[this, registeredName, settings, isCreating, photoBoothImgBase64](const QString &accountId) { [this, registeredName, settings, isCreating, photoBoothImgBase64](const QString& accountId) {
auto showBackup = isCreating && auto showBackup = isCreating
!AppSettingsManager::getValue(Settings::Key::NeverShowMeAgain).toBool(); && !AppSettingsManager::getValue(Settings::Key::NeverShowMeAgain)
.toBool();
if (!registeredName.isEmpty()) { if (!registeredName.isEmpty()) {
Utils::oneShotConnect(&LRCInstance::accountModel(), Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::nameRegistrationEnded, &lrc::api::NewAccountModel::nameRegistrationEnded,
@ -129,11 +141,11 @@ AccountAdapter::createJamiAccount(QString registeredName,
} }
void void
AccountAdapter::createSIPAccount(const QVariantMap &settings, QString photoBoothImgBase64) AccountAdapter::createSIPAccount(const QVariantMap& settings, QString photoBoothImgBase64)
{ {
Utils::oneShotConnect(&LRCInstance::accountModel(), Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountAdded, &lrc::api::NewAccountModel::accountAdded,
[this, settings, photoBoothImgBase64](const QString &accountId) { [this, settings, photoBoothImgBase64](const QString& accountId) {
auto confProps = LRCInstance::accountModel().getAccountConfig( auto confProps = LRCInstance::accountModel().getAccountConfig(
accountId); accountId);
// set SIP details // set SIP details
@ -178,11 +190,11 @@ AccountAdapter::createSIPAccount(const QVariantMap &settings, QString photoBooth
} }
void void
AccountAdapter::createJAMSAccount(const QVariantMap &settings) AccountAdapter::createJAMSAccount(const QVariantMap& settings)
{ {
Utils::oneShotConnect(&LRCInstance::accountModel(), Utils::oneShotConnect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::accountAdded, &lrc::api::NewAccountModel::accountAdded,
[this](const QString &accountId) { [this](const QString& accountId) {
Q_UNUSED(accountId) Q_UNUSED(accountId)
if (!LRCInstance::accountModel().getAccountList().size()) if (!LRCInstance::accountModel().getAccountList().size())
return; return;
@ -214,9 +226,9 @@ AccountAdapter::deleteCurrentAccount()
} }
bool bool
AccountAdapter::savePassword(const QString accountId, AccountAdapter::savePassword(const QString& accountId,
const QString oldPassword, const QString& oldPassword,
const QString newPassword) const QString& newPassword)
{ {
return LRCInstance::accountModel().changeAccountPassword(accountId, oldPassword, newPassword); return LRCInstance::accountModel().changeAccountPassword(accountId, oldPassword, newPassword);
} }
@ -260,21 +272,15 @@ AccountAdapter::isPreviewing()
} }
void void
AccountAdapter::setCurrAccDisplayName(QString text) AccountAdapter::setCurrAccDisplayName(const QString& text)
{ {
LRCInstance::setCurrAccDisplayName(text); LRCInstance::setCurrAccDisplayName(text);
} }
void void
AccountAdapter::setSelectedAccountId(QString accountId) AccountAdapter::setSelectedConvId(const QString& convId)
{ {
LRCInstance::setSelectedAccountId(accountId); LRCInstance::setSelectedConvId(convId);
}
void
AccountAdapter::setSelectedConvId(QString accountId)
{
LRCInstance::setSelectedConvId(accountId);
} }
bool bool
@ -292,15 +298,15 @@ AccountAdapter::setArchiveHasPassword(bool isHavePassword)
LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps); LRCInstance::accountModel().setAccountConfig(LRCInstance::getCurrAccId(), confProps);
} }
bool bool
AccountAdapter::exportToFile(const QString &accountId, AccountAdapter::exportToFile(const QString& accountId,
const QString &path, const QString& path,
const QString &password) const const QString& password) const
{ {
return LRCInstance::accountModel().exportToFile(accountId, path, password); return LRCInstance::accountModel().exportToFile(accountId, path, password);
} }
void void
AccountAdapter::setArchivePasswordAsync(const QString &accountID, const QString &password) AccountAdapter::setArchivePasswordAsync(const QString& accountID, const QString& password)
{ {
QtConcurrent::run([accountID, password] { QtConcurrent::run([accountID, password] {
auto config = LRCInstance::accountModel().getAccountConfig(accountID); auto config = LRCInstance::accountModel().getAccountConfig(accountID);
@ -320,12 +326,18 @@ AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString
} }
void void
AccountAdapter::setSelectedAccount(const QString &accountId) AccountAdapter::setSelectedAccountId(const QString& accountId)
{ {
LRCInstance::setSelectedAccountId(accountId); LRCInstance::setSelectedAccountId(accountId);
setProperty("currentAccountId", accountId);
auto accountType = LRCInstance::getAccountInfo(accountId).profileInfo.type;
setProperty("currentAccountType", lrc::api::profile::to_string(accountType));
connectAccount(accountId); connectAccount(accountId);
emit accountSignalsReconnect(accountId);
emit contactModelChanged();
emit deviceModelChanged();
backToWelcomePage(); backToWelcomePage();
} }
@ -355,10 +367,10 @@ AccountAdapter::deselectConversation()
} }
void void
AccountAdapter::connectAccount(const QString &accountId) AccountAdapter::connectAccount(const QString& accountId)
{ {
try { try {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
QObject::disconnect(accountStatusChangedConnection_); QObject::disconnect(accountStatusChangedConnection_);
QObject::disconnect(contactAddedConnection_); QObject::disconnect(contactAddedConnection_);
@ -367,11 +379,11 @@ AccountAdapter::connectAccount(const QString &accountId)
accountProfileChangedConnection_ accountProfileChangedConnection_
= QObject::connect(&LRCInstance::accountModel(), = QObject::connect(&LRCInstance::accountModel(),
&lrc::api::NewAccountModel::profileUpdated, &lrc::api::NewAccountModel::profileUpdated,
[this](const QString& accountId) { [this](const QString& accountId) {
if (LRCInstance::getCurrAccId() == accountId) if (LRCInstance::getCurrAccId() == accountId)
emit accountStatusChanged(); emit accountStatusChanged();
}); });
accountStatusChangedConnection_ accountStatusChangedConnection_
= QObject::connect(accInfo.accountModel, = QObject::connect(accInfo.accountModel,
@ -381,8 +393,8 @@ AccountAdapter::connectAccount(const QString &accountId)
contactAddedConnection_ contactAddedConnection_
= QObject::connect(accInfo.contactModel.get(), = QObject::connect(accInfo.contactModel.get(),
&lrc::api::ContactModel::contactAdded, &lrc::api::ContactModel::contactAdded,
[this, accountId](const QString &contactUri) { [this, accountId](const QString& contactUri) {
auto &accInfo = LRCInstance::accountModel().getAccountInfo( auto& accInfo = LRCInstance::accountModel().getAccountInfo(
accountId); accountId);
auto* convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
const auto conversation = convModel->getConversationForUID( const auto conversation = convModel->getConversationForUID(
@ -404,7 +416,7 @@ AccountAdapter::connectAccount(const QString &accountId)
addedToConferenceConnection_ addedToConferenceConnection_
= QObject::connect(accInfo.callModel.get(), = QObject::connect(accInfo.callModel.get(),
&NewCallModel::callAddedToConference, &NewCallModel::callAddedToConference,
[](const QString &callId, const QString &confId) { [](const QString& callId, const QString& confId) {
Q_UNUSED(callId); Q_UNUSED(callId);
LRCInstance::renderer()->addDistantRenderer(confId); LRCInstance::renderer()->addDistantRenderer(confId);
}); });

View file

@ -31,17 +31,37 @@ class AccountAdapter final : public QmlAdapterBase
{ {
Q_OBJECT 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: 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; ~AccountAdapter() = default;
protected: protected:
void safeInit() override; void safeInit() override;
public:
//Singleton
static AccountAdapter &instance();
/* /*
* Change to account corresponding to combox box index. * Change to account corresponding to combox box index.
*/ */
@ -50,11 +70,11 @@ public:
* Create normal Jami account, SIP account and JAMS accounts. * Create normal Jami account, SIP account and JAMS accounts.
*/ */
Q_INVOKABLE void createJamiAccount(QString registeredName, Q_INVOKABLE void createJamiAccount(QString registeredName,
const QVariantMap &settings, const QVariantMap& settings,
QString photoBoothImgBase64, QString photoBoothImgBase64,
bool isCreating); bool isCreating);
Q_INVOKABLE void createSIPAccount(const QVariantMap &settings, QString photoBoothImgBase64); Q_INVOKABLE void createSIPAccount(const QVariantMap& settings, QString photoBoothImgBase64);
Q_INVOKABLE void createJAMSAccount(const QVariantMap &settings); Q_INVOKABLE void createJAMSAccount(const QVariantMap& settings);
/* /*
* Delete current account * Delete current account
*/ */
@ -68,48 +88,51 @@ public:
*/ */
Q_INVOKABLE bool hasPassword(); Q_INVOKABLE bool hasPassword();
Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword); Q_INVOKABLE void setArchiveHasPassword(bool isHavePassword);
Q_INVOKABLE bool exportToFile(const QString &accountId, Q_INVOKABLE bool exportToFile(const QString& accountId,
const QString &path, const QString& path,
const QString &password = {}) const; const QString& password = {}) const;
Q_INVOKABLE void setArchivePasswordAsync(const QString &accountID, const QString &password); Q_INVOKABLE void setArchivePasswordAsync(const QString& accountID, const QString& password);
/* /*
* lrc instances functions wrappers * 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 startAudioMeter(bool async);
Q_INVOKABLE void stopAudioMeter(bool async); Q_INVOKABLE void stopAudioMeter(bool async);
Q_INVOKABLE void startPreviewing(bool force = false, bool async = true); Q_INVOKABLE void startPreviewing(bool force = false, bool async = true);
Q_INVOKABLE void stopPreviewing(bool async = true); Q_INVOKABLE void stopPreviewing(bool async = true);
Q_INVOKABLE bool hasVideoCall(); Q_INVOKABLE bool hasVideoCall();
Q_INVOKABLE bool isPreviewing(); Q_INVOKABLE bool isPreviewing();
Q_INVOKABLE void setCurrAccDisplayName(QString text); Q_INVOKABLE void setCurrAccDisplayName(const QString& text);
Q_INVOKABLE void setSelectedAccountId(QString accountId = {}); Q_INVOKABLE void setSelectedAccountId(const QString& accountId = {});
Q_INVOKABLE void setSelectedConvId(QString accountId = {}); Q_INVOKABLE void setSelectedConvId(const QString& convId = {});
signals: signals:
/* /*
* Trigger other components to reconnect account related signals. * Trigger other components to reconnect account related signals.
*/ */
void accountSignalsReconnect(const QString &accountId);
void accountStatusChanged(); void accountStatusChanged();
void updateConversationForAddedContact(); void updateConversationForAddedContact();
/* /*
* send report failure to QML to make it show the right UI state . * send report failure to QML to make it show the right UI state .
*/ */
void reportFailure(); void reportFailure();
void accountAdded(bool showBackUp, int index);
void navigateToWelcomePageRequested(); void navigateToWelcomePageRequested();
void accountAdded(bool showBackUp, int index);
private: private:
void setSelectedAccount(const QString &accountId); QString currentAccountId_;
lrc::api::profile::Type currentAccountType_;
int accountListSize_;
void backToWelcomePage(); void backToWelcomePage();
void deselectConversation(); void deselectConversation();
/* /*
* Make account signal connections. * Make account signal connections.
*/ */
void connectAccount(const QString &accountId); void connectAccount(const QString& accountId);
/* /*
* Implement what to do when creat accout fails. * Implement what to do when creat accout fails.
*/ */
@ -120,4 +143,4 @@ private:
QMetaObject::Connection addedToConferenceConnection_; QMetaObject::Connection addedToConferenceConnection_;
QMetaObject::Connection accountProfileChangedConnection_; QMetaObject::Connection accountProfileChangedConnection_;
}; };
Q_DECLARE_METATYPE(AccountAdapter *) Q_DECLARE_METATYPE(AccountAdapter*)

View file

@ -1,4 +1,4 @@
/* /*!
* Copyright (C) 2020 by Savoir-faire Linux * Copyright (C) 2020 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * 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 QtQuick.Layouts 1.3
import QtGraphicalEffects 1.14 import QtGraphicalEffects 1.14
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../constant" import "../constant"
import "../wizardview/components" import "../wizardview/components"
@ -123,7 +124,7 @@ Window{
} }
function refuseMigrationAndDeleteAccount(){ function refuseMigrationAndDeleteAccount(){
ClientWrapper.accountModel.removeAccount(accountID) AccountAdapter.model.removeAccount(accountID)
acceptMigration() acceptMigration()
} }
@ -147,7 +148,7 @@ Window{
Connections{ Connections{
id: connectionMigrationEnded id: connectionMigrationEnded
enabled: false enabled: false
target: ClientWrapper.accountModel target: AccountAdapter.model
function onMigrationEnded(accountIdIn, ok){ function onMigrationEnded(accountIdIn, ok){
nonOperationClosing = true nonOperationClosing = true
@ -169,7 +170,7 @@ Window{
stackedWidget.currentIndex = 1 stackedWidget.currentIndex = 1
connectionMigrationEnded.enabled = true connectionMigrationEnded.enabled = true
ClientWrapper.accountAdaptor.setArchivePasswordAsync(accountID,password) AccountAdapter.setArchivePasswordAsync(accountID,password)
} }
function slotDeleteButtonClicked(){ function slotDeleteButtonClicked(){

View file

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

View file

@ -21,6 +21,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../constant" import "../constant"
@ -113,7 +114,7 @@ Dialog {
function exportAccountQML() { function exportAccountQML() {
var success = false var success = false
if (path.length > 0) { if (path.length > 0) {
success = ClientWrapper.accountAdaptor.exportToFile( success = AccountAdapter.exportToFile(
UtilsAdapter.getCurrAccId(), UtilsAdapter.getCurrAccId(),
path, path,
currentPasswordEdit.text) currentPasswordEdit.text)
@ -129,13 +130,13 @@ Dialog {
function savePasswordQML() { function savePasswordQML() {
var success = false var success = false
success = ClientWrapper.accountAdaptor.savePassword( success = AccountAdapter.savePassword(
UtilsAdapter.getCurrAccId(), UtilsAdapter.getCurrAccId(),
currentPasswordEdit.text, currentPasswordEdit.text,
passwordEdit.text) passwordEdit.text)
if (success) { if (success) {
ClientWrapper.accountAdaptor.setArchiveHasPassword(passwordEdit.text.length !== 0) AccountAdapter.setArchiveHasPassword(passwordEdit.text.length !== 0)
haveDone(successCode, root.purpose) haveDone(successCode, passwordDialog.purpose)
} else { } else {
currentPasswordEdit.borderColorMode = InfoLineEdit.ERROR currentPasswordEdit.borderColorMode = InfoLineEdit.ERROR
btnChangePasswordConfirm.enabled = false btnChangePasswordConfirm.enabled = false

View file

@ -5,6 +5,7 @@ import QtQuick.Controls.Styles 1.4
import Qt.labs.platform 1.1 import Qt.labs.platform 1.1
import QtGraphicalEffects 1.0 import QtGraphicalEffects 1.0
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
ColumnLayout { ColumnLayout {
property bool takePhotoState: false property bool takePhotoState: false
@ -21,14 +22,14 @@ ColumnLayout {
function startBooth(force = false){ function startBooth(force = false){
hasAvatar = false hasAvatar = false
ClientWrapper.accountAdaptor.startPreviewing(force) AccountAdapter.startPreviewing(force)
takePhotoState = true takePhotoState = true
} }
function stopBooth(){ function stopBooth(){
try{ try{
if(!ClientWrapper.accountAdaptor.hasVideoCall()) { if(!AccountAdapter.hasVideoCall()) {
ClientWrapper.accountAdaptor.stopPreviewing() AccountAdapter.stopPreviewing()
} }
} catch(erro){console.log("Exception: " + erro.message)} } 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 Qt.labs.platform 1.1
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../commoncomponents" import "../commoncomponents"
@ -162,9 +163,7 @@ ItemDelegate {
icon.width: 24 icon.width: 24
toolTipText: qsTr("Press to choose an image file") toolTipText: qsTr("Press to choose an image file")
text: { text: UtilsAdapter.fileName(preferenceCurrentValue)
return ClientWrapper.utilsAdaptor.fileName(preferenceCurrentValue)
}
fontPointSize: JamiTheme.buttonFontSize fontPointSize: JamiTheme.buttonFontSize
onClicked: { onClicked: {

View file

@ -36,7 +36,7 @@ MaterialLineEdit {
Connections { Connections {
id: registeredNameFoundConnection id: registeredNameFoundConnection
target: ClientWrapper.nameDirectory target: NameDirectory
function onRegisteredNameFound(status, address, name) { function onRegisteredNameFound(status, address, name) {
if (text === name) { if (text === name) {
@ -66,7 +66,7 @@ MaterialLineEdit {
onTriggered: { onTriggered: {
if (text.length !== 0 && readOnly === false) { if (text.length !== 0 && readOnly === false) {
nameRegistrationState = UsernameLineEdit.NameRegistrationState.SEARCHING nameRegistrationState = UsernameLineEdit.NameRegistrationState.SEARCHING
ClientWrapper.nameDirectory.lookupName("", text) NameDirectory.lookupName("", text)
} else { } else {
nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK nameRegistrationState = UsernameLineEdit.NameRegistrationState.BLANK
} }

View file

@ -25,7 +25,7 @@
#include "utils.h" #include "utils.h"
ConversationsAdapter::ConversationsAdapter(QObject *parent) ConversationsAdapter::ConversationsAdapter(QObject* parent)
: QmlAdapterBase(parent) : QmlAdapterBase(parent)
{} {}
@ -38,14 +38,14 @@ ConversationsAdapter::safeInit()
connect(&LRCInstance::behaviorController(), connect(&LRCInstance::behaviorController(),
&BehaviorController::showChatView, &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); emit showChatView(accountId, convInfo.uid);
}); });
connect(&LRCInstance::instance(), &LRCInstance::currentAccountChanged, connect(&LRCInstance::instance(),
[this]() { &LRCInstance::currentAccountChanged,
accountChangedSetUp(LRCInstance::getCurrAccId()); this,
}); &ConversationsAdapter::onCurrentAccountIdChanged);
connectConversationModel(); connectConversationModel();
} }
@ -58,28 +58,27 @@ ConversationsAdapter::backToWelcomePage()
} }
void void
ConversationsAdapter::selectConversation(const QString &accountId, ConversationsAdapter::selectConversation(const QString& accountId,
const QString &convUid, const QString& convUid,
bool preventSendingSignal) bool preventSendingSignal)
{ {
auto &accInfo = LRCInstance::getAccountInfo(accountId); auto& accInfo = LRCInstance::getAccountInfo(accountId);
const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
selectConversation(convInfo, preventSendingSignal); selectConversation(convInfo, preventSendingSignal);
} }
void void
ConversationsAdapter::selectConversation(const QString &convUid) ConversationsAdapter::selectConversation(const QString& convUid)
{ {
auto* convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) { if (convModel == nullptr) {
return; return;
} }
const auto &conversation = convModel->getConversationForUID(convUid); const auto& conversation = convModel->getConversationForUID(convUid);
if (selectConversation(conversation, false)) { if (selectConversation(conversation, false)) {
// If it is calling, show callview (can use showChatView signal, since it will be determined on qml). // If it is calling, show callview (can use showChatView signal, since it will be determined on qml).
if (!conversation.uid.isEmpty() if (!conversation.uid.isEmpty()
&& LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) { && LRCInstance::getCurrentCallModel()->hasCall(conversation.callId)) {
@ -89,7 +88,7 @@ ConversationsAdapter::selectConversation(const QString &convUid)
} }
bool bool
ConversationsAdapter::selectConversation(const lrc::api::conversation::Info &item, ConversationsAdapter::selectConversation(const lrc::api::conversation::Info& item,
bool preventSendingSignal) bool preventSendingSignal)
{ {
// accInfo.conversationModel->selectConversation(item.uid) only emit ui // 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) { if (LRCInstance::getCurrentConvUid() == item.uid) {
return false; return false;
} else if (item.participants.size() > 0) { } else if (item.participants.size() > 0) {
auto &accInfo = LRCInstance::getAccountInfo(item.accountId); auto& accInfo = LRCInstance::getAccountInfo(item.accountId);
LRCInstance::setSelectedConvId(item.uid); LRCInstance::setSelectedConvId(item.uid);
if (!preventSendingSignal) if (!preventSendingSignal)
accInfo.conversationModel->selectConversation(item.uid); accInfo.conversationModel->selectConversation(item.uid);
@ -125,8 +124,9 @@ ConversationsAdapter::deselectConversation()
} }
void void
ConversationsAdapter::accountChangedSetUp(const QString &accountId) ConversationsAdapter::onCurrentAccountIdChanged()
{ {
auto accountId = LRCInstance::getCurrAccId();
// Should be called when current account is changed. // Should be called when current account is changed.
conversationSmartListModel_->setAccount(accountId); conversationSmartListModel_->setAccount(accountId);
@ -152,7 +152,7 @@ ConversationsAdapter::updateConversationsFilterWidget()
} }
void void
ConversationsAdapter::setConversationFilter(const QString &type) ConversationsAdapter::setConversationFilter(const QString& type)
{ {
// Set conversation filter according to type, // Set conversation filter according to type,
// type needs to be recognizable by lrc::api::profile::to_type. // type needs to be recognizable by lrc::api::profile::to_type.
@ -183,92 +183,97 @@ ConversationsAdapter::refill()
conversationSmartListModel_->fillConversationsList(); conversationSmartListModel_->fillConversationsList();
} }
bool bool
ConversationsAdapter::connectConversationModel(bool updateFilter) ConversationsAdapter::connectConversationModel(bool updateFilter)
{ {
// Signal connections // Signal connections
auto currentConversationModel = LRCInstance::getCurrentConversationModel(); auto currentConversationModel = LRCInstance::getCurrentConversationModel();
modelSortedConnection_ = QObject::connect(currentConversationModel, modelSortedConnection_ = QObject::connect(
&lrc::api::ConversationModel::modelSorted, currentConversationModel, &lrc::api::ConversationModel::modelSorted, [this]() {
[this]() { conversationSmartListModel_->fillConversationsList();
conversationSmartListModel_->fillConversationsList(); updateConversationsFilterWidget();
updateConversationsFilterWidget(); emit updateListViewRequested();
emit updateListViewRequested(); auto* convModel = LRCInstance::getCurrentConversationModel();
auto* convModel = LRCInstance::getCurrentConversationModel(); const auto conversation = convModel->getConversationForUID(
const auto conversation = convModel->getConversationForUID(LRCInstance::getCurrentConvUid()); LRCInstance::getCurrentConvUid());
if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) { if (conversation.uid.isEmpty() || conversation.participants.isEmpty()) {
return; return;
} }
const auto contactURI = conversation.participants[0]; const auto contactURI = conversation.participants[0];
if (contactURI.isEmpty() if (contactURI.isEmpty()
|| convModel->owner.contactModel->getContact(contactURI).profileInfo.type || convModel->owner.contactModel->getContact(contactURI).profileInfo.type
== lrc::api::profile::Type::TEMPORARY) { == lrc::api::profile::Type::TEMPORARY) {
return; return;
} }
emit modelSorted(QVariant::fromValue(contactURI)); emit modelSorted(QVariant::fromValue(contactURI));
}); });
modelUpdatedConnection_ = QObject::connect(currentConversationModel, modelUpdatedConnection_ = QObject::connect(currentConversationModel,
&lrc::api::ConversationModel::conversationUpdated, &lrc::api::ConversationModel::conversationUpdated,
[this](const QString &convUid) { [this](const QString& convUid) {
conversationSmartListModel_->updateConversation(convUid); conversationSmartListModel_->updateConversation(
updateConversationsFilterWidget(); convUid);
emit updateListViewRequested(); updateConversationsFilterWidget();
}); emit updateListViewRequested();
});
filterChangedConnection_ = QObject::connect(currentConversationModel, filterChangedConnection_
&lrc::api::ConversationModel::filterChanged, = QObject::connect(currentConversationModel,
[this]() { &lrc::api::ConversationModel::filterChanged,
conversationSmartListModel_->fillConversationsList(); [this]() {
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); conversationSmartListModel_->fillConversationsList();
updateConversationsFilterWidget(); conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId());
emit updateListViewRequested(); updateConversationsFilterWidget();
}); emit updateListViewRequested();
});
newConversationConnection_ = QObject::connect(currentConversationModel, newConversationConnection_
&lrc::api::ConversationModel::newConversation, = QObject::connect(currentConversationModel,
[this](const QString &convUid) { &lrc::api::ConversationModel::newConversation,
conversationSmartListModel_->fillConversationsList(); [this](const QString& convUid) {
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); conversationSmartListModel_->fillConversationsList();
updateConversationForNewContact(convUid); conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId());
}); updateConversationForNewContact(convUid);
});
conversationRemovedConnection_ = QObject::connect(currentConversationModel, conversationRemovedConnection_
&lrc::api::ConversationModel::conversationRemoved, = QObject::connect(currentConversationModel,
[this]() { &lrc::api::ConversationModel::conversationRemoved,
conversationSmartListModel_->fillConversationsList(); [this]() {
backToWelcomePage(); conversationSmartListModel_->fillConversationsList();
}); backToWelcomePage();
});
conversationClearedConnection = QObject::connect(currentConversationModel, conversationClearedConnection
&lrc::api::ConversationModel::conversationCleared, = QObject::connect(currentConversationModel,
[this](const QString &convUid) { &lrc::api::ConversationModel::conversationCleared,
// If currently selected, switch to welcome screen (deselecting current smartlist item ). [this](const QString& convUid) {
if (convUid != LRCInstance::getCurrentConvUid()) { // If currently selected, switch to welcome screen (deselecting
return; // current smartlist item ).
} if (convUid != LRCInstance::getCurrentConvUid()) {
backToWelcomePage(); return;
}); }
backToWelcomePage();
});
searchStatusChangedConnection_ = QObject::connect(currentConversationModel, searchStatusChangedConnection_
&lrc::api::ConversationModel::searchStatusChanged, = QObject::connect(currentConversationModel,
[this](const QString &status) { &lrc::api::ConversationModel::searchStatusChanged,
emit showSearchStatus(status); [this](const QString& status) { emit showSearchStatus(status); });
});
searchResultUpdatedConnection_ = QObject::connect(currentConversationModel, searchResultUpdatedConnection_
&lrc::api::ConversationModel::searchResultUpdated, = QObject::connect(currentConversationModel,
[this]() { &lrc::api::ConversationModel::searchResultUpdated,
[this]() {
conversationSmartListModel_->fillConversationsList();
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId());
emit updateListViewRequested();
});
conversationSmartListModel_->fillConversationsList(); if (updateFilter)
conversationSmartListModel_->setAccount(LRCInstance::getCurrAccId()); currentConversationModel->setFilter("");
emit updateListViewRequested();
});
if (updateFilter) currentConversationModel->setFilter("");
return true; return true;
} }
@ -286,7 +291,7 @@ ConversationsAdapter::disconnectConversationModel()
} }
void void
ConversationsAdapter::updateConversationForNewContact(const QString &convUid) ConversationsAdapter::updateConversationForNewContact(const QString& convUid)
{ {
auto* convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
if (convModel == nullptr) { if (convModel == nullptr) {
@ -296,7 +301,8 @@ ConversationsAdapter::updateConversationForNewContact(const QString &convUid)
const auto conversation = convModel->getConversationForUID(convUid); const auto conversation = convModel->getConversationForUID(convUid);
if (!conversation.uid.isEmpty() && !conversation.participants.isEmpty()) { if (!conversation.uid.isEmpty() && !conversation.participants.isEmpty()) {
try { 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) { if (!contact.profileInfo.uri.isEmpty() && contact.profileInfo.uri == selectedUid) {
LRCInstance::setSelectedConvId(convUid); LRCInstance::setSelectedConvId(convUid);
convModel->selectConversation(convUid); convModel->selectConversation(convUid);

View file

@ -29,7 +29,7 @@ class ConversationsAdapter final : public QmlAdapterBase
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit ConversationsAdapter(QObject *parent = nullptr); explicit ConversationsAdapter(QObject* parent = nullptr);
~ConversationsAdapter() = default; ~ConversationsAdapter() = default;
protected: protected:
@ -38,36 +38,38 @@ protected:
public: public:
Q_INVOKABLE bool connectConversationModel(bool updateFilter = true); Q_INVOKABLE bool connectConversationModel(bool updateFilter = true);
Q_INVOKABLE void disconnectConversationModel(); Q_INVOKABLE void disconnectConversationModel();
Q_INVOKABLE void selectConversation(const QString &accountId, Q_INVOKABLE void selectConversation(const QString& accountId,
const QString &convUid, const QString& convUid,
bool preventSendingSignal = true); bool preventSendingSignal = true);
Q_INVOKABLE void selectConversation(const QString &uid); Q_INVOKABLE void selectConversation(const QString& uid);
Q_INVOKABLE void deselectConversation(); Q_INVOKABLE void deselectConversation();
Q_INVOKABLE void refill(); Q_INVOKABLE void refill();
Q_INVOKABLE void accountChangedSetUp(const QString &accountId);
Q_INVOKABLE void updateConversationsFilterWidget(); Q_INVOKABLE void updateConversationsFilterWidget();
Q_INVOKABLE void setConversationFilter(const QString &type); Q_INVOKABLE void setConversationFilter(const QString& type);
signals: signals:
void showChatView(const QString &accountId, const QString &convUid); void showChatView(const QString& accountId, const QString& convUid);
void showConversationTabs(bool visible); void showConversationTabs(bool visible);
void showSearchStatus(const QString &status); void showSearchStatus(const QString& status);
void modelChanged(const QVariant& model); void modelChanged(const QVariant& model);
void modelSorted(const QVariant& uri); void modelSorted(const QVariant& uri);
void updateListViewRequested(); void updateListViewRequested();
void navigateToWelcomePageRequested(); void navigateToWelcomePageRequested();
private slots:
void onCurrentAccountIdChanged();
private: private:
void setConversationFilter(lrc::api::profile::Type filter); void setConversationFilter(lrc::api::profile::Type filter);
void backToWelcomePage(); void backToWelcomePage();
bool selectConversation(const lrc::api::conversation::Info &item, bool selectConversation(const lrc::api::conversation::Info& item,
bool preventSendingSignal = true); 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. * Connections.

View file

@ -1,4 +1,4 @@
/* /*!
* Copyright (C) 2019-2020 by Savoir-faire Linux * Copyright (C) 2019-2020 by Savoir-faire Linux
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com> * Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com> * Author: Isa Nanic <isa.nanic@savoirfairelinux.com>
@ -58,93 +58,88 @@
using namespace lrc::api; using namespace lrc::api;
using migrateCallback = std::function<void()>; 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 class LRCInstance : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
static LRCInstance & static LRCInstance& instance(migrateCallback willMigrate = {}, migrateCallback didMigrate = {})
instance(migrateCallback willMigrate = {}, migrateCallback didMigrate = {})
{ {
static LRCInstance instance_(willMigrate, didMigrate); static LRCInstance instance_(willMigrate, didMigrate);
return instance_; return instance_;
}; }
static void
init(migrateCallback willMigrate = {}, migrateCallback didMigrate = {}) static void init(migrateCallback willMigrate = {}, migrateCallback didMigrate = {})
{ {
instance(willMigrate, didMigrate); instance(willMigrate, didMigrate);
}; }
static Lrc &
getAPI() static Lrc& getAPI() {
{
return *(instance().lrc_); return *(instance().lrc_);
}; }
static RenderManager *
renderer() static RenderManager* renderer() {
{
return instance().renderer_.get(); return instance().renderer_.get();
} }
static void
connectivityChanged() static void connectivityChanged() {
{
instance().lrc_->connectivityChanged(); instance().lrc_->connectivityChanged();
}; }
static NewAccountModel &
accountModel() static NewAccountModel& accountModel() {
{
return instance().lrc_->getAccountModel(); return instance().lrc_->getAccountModel();
}; }
static BehaviorController &
behaviorController() static BehaviorController& behaviorController()
{ {
return instance().lrc_->getBehaviorController(); return instance().lrc_->getBehaviorController();
}; }
static DataTransferModel &
dataTransferModel() static DataTransferModel& dataTransferModel()
{ {
return instance().lrc_->getDataTransferModel(); return instance().lrc_->getDataTransferModel();
}; }
static AVModel &
avModel() static AVModel& avModel()
{ {
return instance().lrc_->getAVModel(); return instance().lrc_->getAVModel();
}; }
static PluginModel &
pluginModel() static PluginModel& pluginModel()
{ {
return instance().lrc_->getPluginModel(); return instance().lrc_->getPluginModel();
}; }
static bool
isConnected() static bool isConnected()
{ {
return instance().lrc_->isConnected(); return instance().lrc_->isConnected();
}; }
static VectorString
getActiveCalls() static VectorString getActiveCalls()
{ {
return instance().lrc_->activeCalls(); return instance().lrc_->activeCalls();
}; }
static const account::Info &
getAccountInfo(const QString &accountId) static const account::Info& getAccountInfo(const QString& accountId)
{ {
return accountModel().getAccountInfo(accountId); return accountModel().getAccountInfo(accountId);
}; }
static const account::Info &
getCurrentAccountInfo() static const account::Info& getCurrentAccountInfo()
{ {
return getAccountInfo(getCurrAccId()); return getAccountInfo(getCurrAccId());
}; }
static bool
hasVideoCall() static bool hasVideoCall()
{ {
auto activeCalls = instance().lrc_->activeCalls(); auto activeCalls = instance().lrc_->activeCalls();
auto accountList = accountModel().getAccountList(); auto accountList = accountModel().getAccountList();
bool result = false; bool result = false;
for (const auto &callId : activeCalls) { for (const auto& callId : activeCalls) {
for (const auto &accountId : accountList) { for (const auto& accountId : accountList) {
auto &accountInfo = accountModel().getAccountInfo(accountId); auto& accountInfo = accountModel().getAccountInfo(accountId);
if (accountInfo.callModel->hasCall(callId)) { if (accountInfo.callModel->hasCall(callId)) {
auto call = accountInfo.callModel->getCall(callId); auto call = accountInfo.callModel->getCall(callId);
result |= !(call.isAudioOnly || call.videoMuted); result |= !(call.isAudioOnly || call.videoMuted);
@ -152,22 +147,22 @@ public:
} }
} }
return result; 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); auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
return {}; return {};
} }
return convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId; 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 { try {
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
if (!accInfo.callModel->hasCall(callId)) { if (!accInfo.callModel->hasCall(callId)) {
return nullptr; return nullptr;
} }
@ -176,12 +171,13 @@ public:
return nullptr; 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 { try {
auto accountId = convInfo.accountId; auto accountId = convInfo.accountId;
auto &accInfo = LRCInstance::accountModel().getAccountInfo(accountId); auto& accInfo = LRCInstance::accountModel().getAccountInfo(accountId);
auto callId = forceCallOnly auto callId = forceCallOnly
? convInfo.callId ? convInfo.callId
: (convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId); : (convInfo.confId.isEmpty() ? convInfo.callId : convInfo.confId);
@ -193,16 +189,18 @@ public:
return nullptr; 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; using namespace lrc::api;
static conversation::Info invalid = {}; static conversation::Info invalid = {};
try { try {
auto &accInfo = LRCInstance::getAccountInfo(accountId); auto& accInfo = LRCInstance::getAccountInfo(accountId);
auto &convModel = accInfo.conversationModel; auto& convModel = accInfo.conversationModel;
if (filtered) { if (filtered) {
auto &convs = convModel->allFilteredConversations(); auto& convs = convModel->allFilteredConversations();
auto conv = std::find_if(convs.begin(), convs.end(), pred); auto conv = std::find_if(convs.begin(), convs.end(), pred);
if (conv != convs.end()) { if (conv != convs.end()) {
return *conv; return *conv;
@ -212,7 +210,7 @@ public:
i <= static_cast<int>(profile::Type::TEMPORARY); i <= static_cast<int>(profile::Type::TEMPORARY);
++i) { ++i) {
auto filter = static_cast<profile::Type>(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); auto conv = std::find_if(convs.begin(), convs.end(), pred);
if (conv != convs.end()) { if (conv != convs.end()) {
return *conv; return *conv;
@ -223,41 +221,40 @@ public:
} }
return invalid; return invalid;
} }
static const conversation::Info &
getConversationFromCallId(const QString &callId, static const conversation::Info& getConversationFromCallId(const QString& callId,
const QString &accountId = {}, const QString& accountId = {},
bool filtered = false) bool filtered = false)
{ {
return getConversation( return getConversation(
!accountId.isEmpty() ? accountId : getCurrAccId(), !accountId.isEmpty() ? accountId : getCurrAccId(),
[&](const conversation::Info &conv) -> bool { return callId == conv.callId or callId == conv.confId; }, [&](const conversation::Info& conv) -> bool {
filtered); return callId == conv.callId or callId == conv.confId;
} },
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); filtered);
} }
static ConversationModel * static const conversation::Info& getConversationFromPeerUri(const QString& peerUri,
getCurrentConversationModel() 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(); return getCurrentAccountInfo().conversationModel.get();
}; }
static NewCallModel * static NewCallModel* getCurrentCallModel()
getCurrentCallModel()
{ {
return getCurrentAccountInfo().callModel.get(); return getCurrentAccountInfo().callModel.get();
}; }
static const QString & static const QString& getCurrAccId()
getCurrAccId()
{ {
if (instance().selectedAccountId_.isEmpty()) { if (instance().selectedAccountId_.isEmpty()) {
auto accountList = accountModel().getAccountList(); auto accountList = accountModel().getAccountList();
@ -265,35 +262,32 @@ public:
instance().selectedAccountId_ = accountList.at(0); instance().selectedAccountId_ = accountList.at(0);
} }
return instance().selectedAccountId_; return instance().selectedAccountId_;
}; }
static void static void setSelectedAccountId(const QString& accountId = {})
setSelectedAccountId(const QString &accountId = {})
{ {
if (accountId == instance().selectedAccountId_) if (accountId == instance().selectedAccountId_)
return; // No need to select current selected account return; // No need to select current selected account
instance().selectedAccountId_ = accountId; instance().selectedAccountId_ = accountId;
// Last selected account should be set as preferred. // Last selected account should be set as preferred.
accountModel().setTopAccount(accountId); accountModel().setTopAccount(accountId);
emit instance().currentAccountChanged(); emit instance().currentAccountChanged();
}; }
static const QString & static const QString& getCurrentConvUid()
getCurrentConvUid()
{ {
return instance().selectedConvUid_; return instance().selectedConvUid_;
}; }
static void static void setSelectedConvId(const QString& convUid = {})
setSelectedConvId(const QString &convUid = {})
{ {
instance().selectedConvUid_ = convUid; instance().selectedConvUid_ = convUid;
}; }
static void static void reset(bool newInstance = false)
reset(bool newInstance = false)
{ {
if (newInstance) { if (newInstance) {
instance().renderer_.reset(new RenderManager(avModel())); instance().renderer_.reset(new RenderManager(avModel()));
@ -302,10 +296,9 @@ public:
instance().renderer_.reset(); instance().renderer_.reset();
instance().lrc_.reset(); instance().lrc_.reset();
} }
}; }
static int static int getCurrentAccountIndex()
getCurrentAccountIndex()
{ {
for (int i = 0; i < accountModel().getAccountList().size(); i++) { for (int i = 0; i < accountModel().getAccountList().size(); i++) {
if (accountModel().getAccountList()[i] == getCurrAccId()) { if (accountModel().getAccountList()[i] == getCurrAccId()) {
@ -313,20 +306,18 @@ public:
} }
} }
return -1; return -1;
}; }
static const QPixmap static const QPixmap getCurrAccPixmap()
getCurrAccPixmap()
{ {
return instance() return instance()
.accountListModel_ .accountListModel_
.data(instance().accountListModel_.index(getCurrentAccountIndex()), .data(instance().accountListModel_.index(getCurrentAccountIndex()),
AccountListModel::Role::Picture) AccountListModel::Role::Picture)
.value<QPixmap>(); .value<QPixmap>();
}; }
static void static void setAvatarForAccount(const QPixmap& avatarPixmap, const QString& accountID)
setAvatarForAccount(const QPixmap &avatarPixmap, const QString &accountID)
{ {
QByteArray ba; QByteArray ba;
QBuffer bu(&ba); QBuffer bu(&ba);
@ -334,10 +325,9 @@ public:
avatarPixmap.save(&bu, "PNG"); avatarPixmap.save(&bu, "PNG");
auto str = QString::fromLocal8Bit(ba.toBase64()); auto str = QString::fromLocal8Bit(ba.toBase64());
accountModel().setAvatar(accountID, str); accountModel().setAvatar(accountID, str);
}; }
static void static void setCurrAccAvatar(const QPixmap& avatarPixmap)
setCurrAccAvatar(const QPixmap &avatarPixmap)
{ {
QByteArray ba; QByteArray ba;
QBuffer bu(&ba); QBuffer bu(&ba);
@ -345,16 +335,14 @@ public:
avatarPixmap.save(&bu, "PNG"); avatarPixmap.save(&bu, "PNG");
auto str = QString::fromLocal8Bit(ba.toBase64()); auto str = QString::fromLocal8Bit(ba.toBase64());
accountModel().setAvatar(getCurrAccId(), str); accountModel().setAvatar(getCurrAccId(), str);
}; }
static void static void setCurrAccAvatar(const QString& avatar)
setCurrAccAvatar(const QString &avatar)
{ {
accountModel().setAvatar(getCurrAccId(), avatar); accountModel().setAvatar(getCurrAccId(), avatar);
}; }
static void static void setCurrAccDisplayName(const QString& displayName)
setCurrAccDisplayName(const QString &displayName)
{ {
auto accountId = LRCInstance::getCurrAccId(); auto accountId = LRCInstance::getCurrAccId();
accountModel().setAlias(accountId, displayName); accountModel().setAlias(accountId, displayName);
@ -363,22 +351,19 @@ public:
*/ */
auto confProps = LRCInstance::accountModel().getAccountConfig(accountId); auto confProps = LRCInstance::accountModel().getAccountConfig(accountId);
LRCInstance::accountModel().setAccountConfig(accountId, confProps); LRCInstance::accountModel().setAccountConfig(accountId, confProps);
}; }
static const account::ConfProperties_t & static const account::ConfProperties_t& getCurrAccConfig()
getCurrAccConfig()
{ {
return instance().getCurrentAccountInfo().confProperties; return instance().getCurrentAccountInfo().confProperties;
} }
static void static void subscribeToDebugReceived()
subscribeToDebugReceived()
{ {
instance().lrc_->subscribeToDebugReceived(); instance().lrc_->subscribeToDebugReceived();
} }
static void static void startAudioMeter(bool async)
startAudioMeter(bool async)
{ {
auto f = [] { auto f = [] {
if (!LRCInstance::getActiveCalls().size()) { if (!LRCInstance::getActiveCalls().size()) {
@ -393,8 +378,7 @@ public:
} }
} }
static void static void stopAudioMeter(bool async)
stopAudioMeter(bool async)
{ {
auto f = [] { auto f = [] {
if (!LRCInstance::getActiveCalls().size()) { if (!LRCInstance::getActiveCalls().size()) {
@ -409,28 +393,26 @@ public:
} }
} }
static QString static QString getContentDraft(const QString& convUid, const QString& accountId)
getContentDraft(const QString &convUid, const QString &accountId)
{ {
auto draftKey = accountId + "_" + convUid; auto draftKey = accountId + "_" + convUid;
return instance().contentDrafts_[draftKey]; return instance().contentDrafts_[draftKey];
} }
static void static void setContentDraft(const QString& convUid,
setContentDraft(const QString &convUid, const QString &accountId, const QString &content) const QString& accountId,
const QString& content)
{ {
auto draftKey = accountId + "_" + convUid; auto draftKey = accountId + "_" + convUid;
instance().contentDrafts_[draftKey] = content; instance().contentDrafts_[draftKey] = content;
} }
static void static void pushLastConferencee(const QString& confId, const QString& callId)
pushLastConferencee(const QString &confId, const QString &callId)
{ {
instance().lastConferencees_[confId] = callId; instance().lastConferencees_[confId] = callId;
} }
static QString static QString popLastConferencee(const QString& confId)
popLastConferencee(const QString &confId)
{ {
QString callId = {}; QString callId = {};
auto iter = instance().lastConferencees_.find(confId); auto iter = instance().lastConferencees_.find(confId);
@ -461,4 +443,4 @@ private:
MapStringString contentDrafts_; MapStringString contentDrafts_;
MapStringString lastConferencees_; MapStringString lastConferencees_;
}; };
Q_DECLARE_METATYPE(LRCInstance *) Q_DECLARE_METATYPE(LRCInstance*)

View file

@ -288,7 +288,7 @@ Window {
currentIndex: 0 currentIndex: 0
Connections { Connections {
target: ClientWrapper.accountAdaptor target: AccountAdapter
function onUpdateConversationForAddedContact() { function onUpdateConversationForAddedContact() {
mainViewWindowSidePanel.needToUpdateConversationForAddedContact() mainViewWindowSidePanel.needToUpdateConversationForAddedContact()
@ -310,7 +310,7 @@ Window {
if (needToShowCallStack if (needToShowCallStack
&& callStackView.responsibleAccountId === UtilsAdapter.getCurrAccId()){ && callStackView.responsibleAccountId === UtilsAdapter.getCurrAccId()){
if (!ClientWrapper.accountAdaptor.hasVideoCall()) { if (!AccountAdapter.hasVideoCall()) {
pushCommunicationMessageWebView() pushCommunicationMessageWebView()
needToShowCallStack = false needToShowCallStack = false
} else if (needToShowCallStack) { } else if (needToShowCallStack) {
@ -329,7 +329,7 @@ Window {
} }
Component.onCompleted: { 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 the item argument is specified, all items down to (but not including) item will be popped.
if (!inSettingsView) { if (!inSettingsView) {
mainViewStack.pop(welcomePage) mainViewStack.pop(welcomePage)
welcomePage.updateWelcomePage()
qrDialog.updateQrDialog()
} }
} }
onConversationSmartListViewNeedToShowWelcomePage: { onConversationSmartListViewNeedToShowWelcomePage: {
mainViewStack.pop(welcomePage) mainViewStack.pop(welcomePage)
welcomePage.updateWelcomePage()
qrDialog.updateQrDialog()
} }
onNeedToUpdateConversationForAddedContact: { onNeedToUpdateConversationForAddedContact: {

View file

@ -20,6 +20,7 @@ import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
@ -50,7 +51,7 @@ ComboBox {
} }
Connections { Connections {
target: ClientWrapper.accountAdaptor target: AccountAdapter
function onNavigateToWelcomePageRequested() { function onNavigateToWelcomePageRequested() {
needToBackToWelcomePage() needToBackToWelcomePage()

View file

@ -22,6 +22,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQuick.Controls.Universal 2.12 import QtQuick.Controls.Universal 2.12
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../js/incomingcallpagecreation.js" as IncomingCallPageCreation import "../js/incomingcallpagecreation.js" as IncomingCallPageCreation
import "../js/videocallfullscreenwindowcontainercreation.js" as VideoCallFullScreenWindowContainerCreation import "../js/videocallfullscreenwindowcontainercreation.js" as VideoCallFullScreenWindowContainerCreation

View file

@ -26,7 +26,7 @@ import "../../commoncomponents"
Popup { Popup {
id: root id: root
function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) { function toggleMediaHandlerSlot(mediaHandlerId, isLoaded) {
ClientWrapper.pluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded) PluginModel.toggleCallMediaHandler(mediaHandlerId, !isLoaded)
mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel() mediahandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel()
} }
@ -102,7 +102,7 @@ Popup {
delegate: MediaHandlerItemDelegate { delegate: MediaHandlerItemDelegate {
id: mediaHandlerItemDelegate id: mediaHandlerItemDelegate
visible: ClientWrapper.pluginModel.getPluginsEnabled() visible: PluginModel.getPluginsEnabled()
width: mediahandlerPickerListView.width width: mediahandlerPickerListView.width
height: 50 height: 50
@ -231,7 +231,7 @@ Popup {
onClicked: mediahandlerPreferencePickerListView.currentIndex = index onClicked: mediahandlerPreferencePickerListView.currentIndex = index
onBtnPreferenceClicked: { onBtnPreferenceClicked: {
ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
mediahandlerPreferencePickerListView.model = PluginAdapter.getPluginPreferencesModel(pluginId, mediahandlerPreferencePickerListView.mediaHandlerName) 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.Layouts 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import QtQuick.Dialogs 1.3 import QtQuick.Dialogs 1.3
import net.jami.Models 1.0
import QtGraphicalEffects 1.15 import QtGraphicalEffects 1.15
import QtQuick.Shapes 1.15 import QtQuick.Shapes 1.15
import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
@ -71,7 +72,7 @@ Rectangle {
updateState(RecordBox.States.INIT) updateState(RecordBox.States.INIT)
if (isVideo){ if (isVideo){
ClientWrapper.accountAdaptor.startPreviewing(false) AccountAdapter.startPreviewing(false)
previewAvailable = true previewAvailable = true
} }
} }
@ -79,7 +80,7 @@ Rectangle {
function scaleHeight(){ function scaleHeight(){
height = preferredHeight height = preferredHeight
if (isVideo) { if (isVideo) {
var device = ClientWrapper.avmodel.getDefaultDevice() var device = AVModel.getDefaultDevice()
var settings = SettingsAdapter.get_Video_Settings_Size(device) var settings = SettingsAdapter.get_Video_Settings_Size(device)
var res = settings.split("x") var res = settings.split("x")
var aspectRatio = res[1] / res[0] var aspectRatio = res[1] / res[0]
@ -104,8 +105,8 @@ Rectangle {
} }
function closeRecorder() { function closeRecorder() {
if (isVideo && ClientWrapper.accountAdaptor.isPreviewing()) { if (isVideo && AccountAdapter.isPreviewing()) {
ClientWrapper.accountAdaptor.stopPreviewing() AccountAdapter.stopPreviewing()
} }
stopRecording() stopRecording()
visible = false visible = false
@ -129,7 +130,7 @@ Rectangle {
function startRecording() { function startRecording() {
timer.start() timer.start()
pathRecorder = ClientWrapper.avmodel.startLocalRecorder(!isVideo) pathRecorder = AVModel.startLocalRecorder(!isVideo)
if (pathRecorder == "") { if (pathRecorder == "") {
timer.stop() timer.stop()
} }
@ -137,7 +138,7 @@ Rectangle {
function stopRecording() { function stopRecording() {
if (pathRecorder !== "") { if (pathRecorder !== "") {
ClientWrapper.avmodel.stopLocalRecorder(pathRecorder) AVModel.stopLocalRecorder(pathRecorder)
} }
} }
@ -160,11 +161,6 @@ Rectangle {
time.text = min + ":" + sec; time.text = min + ":" + sec;
} }
Connections{
target: ClientWrapper.renderManager
}
Shape { Shape {
id: backgroundShape id: backgroundShape
width: recBox.width width: recBox.width

View file

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

View file

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

View file

@ -1,4 +1,3 @@
/* /*
* Copyright (C) 2020 by Savoir-faire Linux * Copyright (C) 2020 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com> * Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
@ -16,23 +15,21 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
import QtQuick 2.14 import QtQuick 2.14
import QtQuick.Controls 2.14 import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
Rectangle { Rectangle {
id: welcomeRect id: welcomeRect
property int buttonPreferredSize: 30
anchors.fill: parent anchors.fill: parent
function updateWelcomePage(){ property int buttonPreferredSize: 30
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)
}
Rectangle { Rectangle {
id: welcomeRectComponentsGroup id: welcomeRectComponentsGroup
@ -89,9 +86,7 @@ Rectangle {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
visible: accountListModel.data(accountListModel.index( visible: AccountAdapter.currentAccountType === Profile.Type.RING
0, 0),
260) === 1
text: qsTr("This is your ID.\nCopy and share it with your friends") text: qsTr("This is your ID.\nCopy and share it with your friends")
color: JamiTheme.faddedFontColor color: JamiTheme.faddedFontColor
@ -99,13 +94,14 @@ Rectangle {
Rectangle { Rectangle {
id: jamiRegisteredNameRect id: jamiRegisteredNameRect
Layout.alignment: Qt.AlignCenter Layout.alignment: Qt.AlignCenter
Layout.preferredWidth: welcomeRectComponentsGroup.width Layout.preferredWidth: welcomeRectComponentsGroup.width
Layout.preferredHeight: 65 Layout.preferredHeight: 65
Layout.bottomMargin: 5 Layout.bottomMargin: 5
visible: accountListModel.data(accountListModel.index(
0, 0), visible: AccountAdapter.currentAccountType === Profile.Type.RING
260) === 1
ColumnLayout { ColumnLayout {
id: jamiRegisteredNameRectColumnLayout id: jamiRegisteredNameRectColumnLayout
spacing: 0 spacing: 0
@ -121,9 +117,7 @@ Rectangle {
TextMetrics { TextMetrics {
id: textMetricsjamiRegisteredNameText id: textMetricsjamiRegisteredNameText
font: jamiRegisteredNameText.font font: jamiRegisteredNameText.font
text: accountListModel.data( text: UtilsAdapter.getBestId(AccountAdapter.currentAccountId)
accountListModel.index(
currentAccountIndex, 0), 258)
elideWidth: welcomeRectComponentsGroup.width elideWidth: welcomeRectComponentsGroup.width
elide: Qt.ElideMiddle elide: Qt.ElideMiddle
} }
@ -171,8 +165,4 @@ Rectangle {
bBorderwidth: 0 bBorderwidth: 0
borderColor: JamiTheme.tabbarBorderColor borderColor: JamiTheme.tabbarBorderColor
} }
Component.onCompleted: {
updateWelcomePage()
}
} }

View file

@ -25,12 +25,6 @@ import net.jami.Adapters 1.0
Dialog { Dialog {
id: userQrImageDialog 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. // When dialog is opened, trigger mainViewWindow overlay which is defined in overlay.model.
// (model : true is necessary) // (model : true is necessary)
modal: true modal: true
@ -43,14 +37,12 @@ Dialog {
anchors.centerIn: parent anchors.centerIn: parent
width: 250 width: 256
height: 250 height: 256
smooth: false
fillMode: Image.PreserveAspectFit fillMode: Image.PreserveAspectFit
source: "image://qrImage/account_" + accountIdStr source: "image://qrImage/account_" + AccountAdapter.currentAccountId
sourceSize.width: 260
sourceSize.height: 260
mipmap: true
} }
background: Rectangle { background: Rectangle {

View file

@ -27,7 +27,6 @@
#include "avadapter.h" #include "avadapter.h"
#include "bannedlistmodel.h" #include "bannedlistmodel.h"
#include "calladapter.h" #include "calladapter.h"
#include "clientwrapper.h"
#include "contactadapter.h" #include "contactadapter.h"
#include "conversationsadapter.h" #include "conversationsadapter.h"
#include "deviceitemlistmodel.h" #include "deviceitemlistmodel.h"
@ -51,127 +50,109 @@
#include <QMetaType> #include <QMetaType>
#include <QQmlEngine> #include <QQmlEngine>
// clang-format off
#define QML_REGISTERSINGLETONTYPE(N, T, MAJ, MIN) \ #define QML_REGISTERSINGLETONTYPE(N, T, MAJ, MIN) \
qmlRegisterSingletonType<T>(N, MAJ, MIN, #T, \ qmlRegisterSingletonType<T>(N, MAJ, MIN, #T, \
[](QQmlEngine *e, QJSEngine *se) -> QObject * { \ [](QQmlEngine* e, QJSEngine* se) -> QObject* { \
Q_UNUSED(e); \ Q_UNUSED(e); Q_UNUSED(se); \
Q_UNUSED(se); \ T* obj = new T(); return obj; \
T *obj = new T(); \
return obj; \
}); });
#define QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(T, MAJ, MIN) \ #define QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(T, MAJ, MIN) \
qmlRegisterSingletonType<T>("net.jami.Models", \ qmlRegisterSingletonType<T>("net.jami.Models", MAJ, MIN, #T, \
MAJ, \ [](QQmlEngine* e, QJSEngine* se) -> QObject* { \
MIN, \ Q_UNUSED(e); Q_UNUSED(se); \
#T, \
[](QQmlEngine *e, QJSEngine *se) -> QObject * { \
Q_UNUSED(e); \
Q_UNUSED(se); \
return &(T::instance()); \ return &(T::instance()); \
}); });
#define QML_REGISTERSINGLETONTYPE_URL(URL, T, MAJ, MIN) \ #define QML_REGISTERSINGLETONTYPE_CUSTOM(N, T, MAJ, MIN, P) \
qmlRegisterSingletonType(QUrl(URL), "net.jami.Models", MAJ, MIN, #T); 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) \ #define QML_REGISTERNAMESPACE(T, NAME, MAJ, MIN) \
qmlRegisterUncreatableMetaObject(T, "net.jami.Models", MAJ, MIN, NAME, "") qmlRegisterUncreatableMetaObject(T, "net.jami.Models", MAJ, MIN, NAME, "")
#define QML_REGISTERUNCREATABLE(N, T, MAJ, MIN) \ #define QML_REGISTERUNCREATABLE(N, T, MAJ, MIN) \
qmlRegisterUncreatableType<T>(N, \ qmlRegisterUncreatableType<T>(N, MAJ, MIN, #T, "Don't try to add to a qml definition of " #T);
MAJ, \
MIN, \
#T, \
"Don't try to add to a qml definition of " #T);
#define QML_REGISTERUNCREATABLE_IN_NAMESPACE(T, NAMESPACE, MAJ, MIN) \ #define QML_REGISTERUNCREATABLE_IN_NAMESPACE(T, NAMESPACE, MAJ, MIN) \
qmlRegisterUncreatableType<NAMESPACE::T>("net.jami.Models", \ qmlRegisterUncreatableType<NAMESPACE::T>("net.jami.Models", \
MAJ, \ MAJ, MIN, #T, \
MIN, \
#T, \
"Don't try to add to a qml definition of " #T); "Don't try to add to a qml definition of " #T);
/*! /*!
* This function will expose custom types to the QML engine. * 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("net.jami.Models", AccountListModel, 1, 0);
QML_REGISTERTYPE(DeviceItemListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", DeviceItemListModel, 1, 0);
QML_REGISTERTYPE(PluginItemListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", PluginItemListModel, 1, 0);
QML_REGISTERTYPE(MediaHandlerItemListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", MediaHandlerItemListModel, 1, 0);
QML_REGISTERTYPE(PreferenceItemListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", PreferenceItemListModel, 1, 0);
QML_REGISTERTYPE(BannedListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", BannedListModel, 1, 0);
QML_REGISTERTYPE(VideoCodecListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoCodecListModel, 1, 0);
QML_REGISTERTYPE(AudioCodecListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioCodecListModel, 1, 0);
QML_REGISTERTYPE(AccountsToMigrateListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AccountsToMigrateListModel, 1, 0);
QML_REGISTERTYPE(AudioInputDeviceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioInputDeviceModel, 1, 0);
QML_REGISTERTYPE(AudioOutputDeviceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioOutputDeviceModel, 1, 0);
QML_REGISTERTYPE(AudioManagerListModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", AudioManagerListModel, 1, 0);
QML_REGISTERTYPE(VideoInputDeviceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoInputDeviceModel, 1, 0);
QML_REGISTERTYPE(VideoFormatResolutionModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoFormatResolutionModel, 1, 0);
QML_REGISTERTYPE(VideoFormatFpsModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoFormatFpsModel, 1, 0);
QML_REGISTERTYPE(PluginListPreferenceModel, 1, 0); QML_REGISTERTYPE("net.jami.Models", PluginListPreferenceModel, 1, 0);
/* /*
* Register QQuickItem type. * QQuickItems
*/ */
QML_REGISTERTYPE(PreviewRenderer, 1, 0); QML_REGISTERTYPE("net.jami.Models", PreviewRenderer, 1, 0);
QML_REGISTERTYPE(VideoCallPreviewRenderer, 1, 0); QML_REGISTERTYPE("net.jami.Models", VideoCallPreviewRenderer, 1, 0);
QML_REGISTERTYPE(DistantRenderer, 1, 0); QML_REGISTERTYPE("net.jami.Models", DistantRenderer, 1, 0);
QML_REGISTERTYPE(PhotoboothPreviewRender, 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", CallAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Models", MessagesAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Models", MessagesAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Models", ConversationsAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Models", AvAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Models", ContactAdapter, 1, 0); QML_REGISTERSINGLETONTYPE("net.jami.Models", ContactAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Models", PluginAdapter, 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", UtilsAdapter, 1, 0);
QML_REGISTERSINGLETONTYPE("net.jami.Adapters", SettingsAdapter, 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. * Qml singleton components
* This to make lrc models recognizable in qml.
*/ */
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewAccountModel, lrc::api, 1, 0); QML_REGISTERSINGLETONTYPE_URL("qrc:/src/constant/JamiTheme.qml", JamiTheme, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(BehaviorController, lrc::api, 1, 0); QML_REGISTERSINGLETONTYPE_URL("qrc:/src/constant/JamiQmlUtils.qml", JamiQmlUtils, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(DataTransferModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(AVModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(ContactModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(ConversationModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCallModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(PluginModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewDeviceModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(NewCodecModel, lrc::api, 1, 0);
QML_REGISTERUNCREATABLE_IN_NAMESPACE(PeerDiscoveryModel, lrc::api, 1, 0);
/* /*
* qmlRegisterUncreatableType & Q_DECLARE_METATYPE to expose models in qml. * C++ singletons
*/ */
QML_REGISTERUNCREATABLE("net.jami.Models", RenderManager, 1, 0); QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(LRCInstance, 1, 0);
QML_REGISTERUNCREATABLE("net.jami.Models", NameDirectory, 1, 0); QML_REGISTERSINGLETONTYPE_WITH_INSTANCE(NameDirectory, 1, 0);
QML_REGISTERUNCREATABLE("net.jami.Models", LRCInstance, 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::staticMetaObject, "Lrc", 1, 0);
QML_REGISTERNAMESPACE(lrc::api::account::staticMetaObject, "Account", 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::interaction::staticMetaObject, "Interaction", 1, 0);
QML_REGISTERNAMESPACE(lrc::api::video::staticMetaObject, "Video", 1, 0); QML_REGISTERNAMESPACE(lrc::api::video::staticMetaObject, "Video", 1, 0);
QML_REGISTERNAMESPACE(lrc::api::profile::staticMetaObject, "Profile", 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 }; enum class QrType { Account, Contact };
/* /*
* Id should be string like account_0 (account index), * Id should be string like account_0 (account index),
* or contact_xxx (uid). * or contact_xxx (uid).
* Cannot use getCurrentAccId to replace account index, * Cannot use getCurrentAccId to replace account index,
* since we need to keep each image id unique. * since we need to keep each image id unique.
*/ */
QPair<QrType, QString> QPair<QrType, QString> getIndexFromID(const QString& id)
getIndexFromID(const QString &id)
{ {
auto list = id.split('_', QString::SkipEmptyParts); auto list = id.split('_', Qt::SkipEmptyParts);
if (list.size() < 2) if (list.size() < 2)
return QPair(QrType::Account, ""); return QPair(QrType::Account, "");
if (list.contains("account") && list.size() > 1) { if (list.contains("account") && list.size() > 1) {
@ -65,8 +64,7 @@ public:
return QPair(QrType::Account, ""); return QPair(QrType::Account, "");
} }
QImage QImage requestImage(const QString& id, QSize* size, const QSize& requestedSize) override
requestImage(const QString &id, QSize *size, const QSize &requestedSize) override
{ {
Q_UNUSED(size); Q_UNUSED(size);
@ -84,7 +82,7 @@ public:
if (accountList.size() <= accountIndex) if (accountList.size() <= accountIndex)
return QImage(); return QImage();
auto &accountInfo = LRCInstance::accountModel().getAccountInfo( auto& accountInfo = LRCInstance::accountModel().getAccountInfo(
accountList.at(accountIndex)); accountList.at(accountIndex));
uri = accountInfo.profileInfo.uri; uri = accountInfo.profileInfo.uri;
} }

View file

@ -46,7 +46,8 @@ class FrameWrapper final : public QObject
Q_OBJECT; Q_OBJECT;
public: public:
FrameWrapper(AVModel &avModel, const QString &id = video::PREVIEW_RENDERER_ID); FrameWrapper(AVModel &avModel,
const QString &id = video::PREVIEW_RENDERER_ID);
~FrameWrapper(); ~FrameWrapper();
/* /*

View file

@ -30,7 +30,6 @@ import "components"
Rectangle { Rectangle {
id: root id: root
enum SettingsMenu{ enum SettingsMenu{
Account, Account,
General, General,
@ -48,7 +47,7 @@ Rectangle {
profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type() profileType = SettingsAdapter.getCurrentAccount_Profile_Info_Type()
if(selectedMenu === sel && (!recovery)){return} if(selectedMenu === sel && (!recovery)){return}
switch(sel){ switch(sel) {
case SettingsView.Account: case SettingsView.Account:
currentAccountSettingsScrollWidget.connectCurrentAccount() currentAccountSettingsScrollWidget.connectCurrentAccount()
@ -57,7 +56,7 @@ Rectangle {
selectedMenu = sel selectedMenu = sel
if(!settingsViewRect.isSIP){ if(!settingsViewRect.isSIP) {
if(currentAccountSettingsScrollWidget.isPhotoBoothOpened()) if(currentAccountSettingsScrollWidget.isPhotoBoothOpened())
{ {
currentAccountSettingsScrollWidget.setAvatar() currentAccountSettingsScrollWidget.setAvatar()
@ -75,7 +74,7 @@ Rectangle {
try{ try{
avSettings.stopAudioMeter() avSettings.stopAudioMeter()
avSettings.stopPreviewing() avSettings.stopPreviewing()
} catch(erro){} } catch(erro) {}
selectedMenu = sel selectedMenu = sel
generalSettings.populateGeneralSettings() generalSettings.populateGeneralSettings()
@ -91,7 +90,7 @@ Rectangle {
try{ try{
avSettings.stopAudioMeter() avSettings.stopAudioMeter()
avSettings.stopPreviewing() avSettings.stopPreviewing()
} catch(erro){} } catch(erro) {}
selectedMenu = sel selectedMenu = sel
pluginSettings.populatePluginSettings() pluginSettings.populatePluginSettings()
@ -99,9 +98,9 @@ Rectangle {
} }
} }
Connections{ Connections {
id: accountListChangedConnection id: accountListChangedConnection
target: ClientWrapper.lrcInstance target: LRCInstance
function onAccountListChanged(){ function onAccountListChanged(){
slotAccountListChanged() slotAccountListChanged()
@ -124,14 +123,13 @@ Rectangle {
} }
function slotAccountListChanged(){ function slotAccountListChanged(){
var accountList = ClientWrapper.accountModel.getAccountList() var accountList = AccountAdapter.model.getAccountList()
if(accountList.length === 0) if(accountList.length === 0)
return return
currentAccountSettingsScrollWidget.disconnectAccountConnections() currentAccountSettingsScrollWidget.disconnectAccountConnections()
var device = ClientWrapper.avmodel.getDefaultDevice() var device = AVModel.getDefaultDevice()
if(device.length === 0){ if(device.length === 0){
ClientWrapper.avmodel.setCurrentVideoCaptureDevice(device) AVModel.setCurrentVideoCaptureDevice(device)
} }
} }
property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type() property int profileType: SettingsAdapter.getCurrentAccount_Profile_Info_Type()

View file

@ -48,13 +48,13 @@ ColumnLayout {
enableSDESToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() enableSDESToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled()
fallbackRTPToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled() fallbackRTPToggle.enabled = SettingsAdapter.getAccountConfig_SRTP_Enabled()
btnSIPCACert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) btnSIPCACert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile())
btnSIPUserCert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) btnSIPUserCert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile())
btnSIPPrivateKey.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) btnSIPPrivateKey.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile())
lineEditSIPCertPassword.text = SettingsAdapter.getAccountConfig_TLS_Password() lineEditSIPCertPassword.text = SettingsAdapter.getAccountConfig_TLS_Password()
encryptMediaStreamsToggle.checked = SettingsAdapter.getAccountConfig_SRTP_Enabled() 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() fallbackRTPToggle.checked = SettingsAdapter.getAccountConfig_SRTP_RtpFallback()
encryptNegotitationToggle.checked = SettingsAdapter.getAccountConfig_TLS_Enable() encryptNegotitationToggle.checked = SettingsAdapter.getAccountConfig_TLS_Enable()
verifyIncomingCertificatesServerToogle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyServer() verifyIncomingCertificatesServerToogle.checked = SettingsAdapter.getAccountConfig_TLS_VerifyServer()
@ -96,7 +96,7 @@ ColumnLayout {
updateAudioCodecs() updateAudioCodecs()
updateVideoCodecs() updateVideoCodecs()
btnRingtoneSIP.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() 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() lineEditSTUNAddressSIP.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled()
// SDP session negotiation ports // SDP session negotiation ports
@ -161,7 +161,7 @@ ColumnLayout {
// slots // slots
function audioRTPMinPortSpinBoxEditFinished(value){ function audioRTPMinPortSpinBoxEditFinished(value){
if (ClientWrapper.SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) { if (SettingsAdapter.getAccountConfig_Audio_AudioPortMax() < value) {
audioRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMin() audioRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Audio_AudioPortMin()
return return
} }
@ -177,7 +177,7 @@ ColumnLayout {
} }
function videoRTPMinPortSpinBoxEditFinished(value){ function videoRTPMinPortSpinBoxEditFinished(value){
if (ClientWrapper.SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) { if (SettingsAdapter.getAccountConfig_Video_VideoPortMax() < value) {
videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin() videoRTPMinPortSpinBox.value = SettingsAdapter.getAccountConfig_Video_VideoPortMin()
return return
} }
@ -197,7 +197,7 @@ ColumnLayout {
if(url.length !== 0) { if(url.length !== 0) {
SettingsAdapter.set_RingtonePath(url) SettingsAdapter.set_RingtonePath(url)
btnRingtoneSIP.text = UtilsAdapter.toFileInfoName(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") btnRingtoneSIP.text = qsTr("Add a custom ringtone")
} }
} }

View file

@ -52,9 +52,9 @@ ColumnLayout {
lineEditBootstrap.text = SettingsAdapter.getAccountConfig_Hostname() lineEditBootstrap.text = SettingsAdapter.getAccountConfig_Hostname()
// Security // Security
btnCACert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateListFile()) btnCACert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateListFile())
btnUserCert.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_CertificateFile()) btnUserCert.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_CertificateFile())
btnPrivateKey.text = UtilsAdapter.toFileInfoName(ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()) btnPrivateKey.text = UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile())
// Connectivity // Connectivity
checkBoxUPnP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled() checkBoxUPnP.checked = SettingsAdapter.getAccountConfig_UpnpEnabled()
@ -70,7 +70,7 @@ ColumnLayout {
updateAudioCodecs(); updateAudioCodecs();
updateVideoCodecs(); updateVideoCodecs();
btnRingtone.enabled = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() 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() lineEditProxy.enabled = SettingsAdapter.getAccountConfig_ProxyEnabled()
lineEditSTUNAddress.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled() lineEditSTUNAddress.enabled = SettingsAdapter.getAccountConfig_STUN_Enabled()
} }
@ -129,7 +129,7 @@ ColumnLayout {
if(url.length !== 0) { if(url.length !== 0) {
SettingsAdapter.set_RingtonePath(url) SettingsAdapter.set_RingtonePath(url)
btnRingtone.text = UtilsAdapter.toFileInfoName(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") btnRingtone.text = qsTr("Add a custom ringtone")
} }
} }
@ -214,7 +214,7 @@ ColumnLayout {
id: privateKey_Dialog id: privateKey_Dialog
property string oldPath : { property string oldPath : {
return ClientWrapper.SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile() return SettingsAdapter.getAccountConfig_TLS_PrivateKeyFile()
} }
property string openPath : oldPath === "" ? (UtilsAdapter.getCurrentPath() + "/ringtones/") : (UtilsAdapter.toFileAbsolutepath(oldPath)) 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 QtGraphicalEffects 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
Rectangle { Rectangle {
@ -37,7 +39,7 @@ Rectangle {
signal backArrowClicked signal backArrowClicked
Connections{ Connections{
target: ClientWrapper.avmodel target: AVModel
enabled: root.visible enabled: root.visible
function onAudioMeter(id, level){ function onAudioMeter(id, level){
@ -46,7 +48,7 @@ Rectangle {
} }
Connections{ Connections{
target: ClientWrapper.renderManager target: RenderManager
enabled: root.visible enabled: root.visible
function onVideoDeviceListChanged(){ function onVideoDeviceListChanged(){
@ -75,7 +77,7 @@ Rectangle {
} }
populateVideoSettings() populateVideoSettings()
var encodeAccel = ClientWrapper.avmodel.getHardwareAcceleration() var encodeAccel = AVModel.getHardwareAcceleration()
hardwareAccelControl.checked = encodeAccel hardwareAccelControl.checked = encodeAccel
} }
@ -99,8 +101,8 @@ Rectangle {
} }
function setFormatListForCurrentDevice(){ function setFormatListForCurrentDevice(){
var device = ClientWrapper.avmodel.getCurrentVideoCaptureDevice() var device = AVModel.getCurrentVideoCaptureDevice()
if(ClientWrapper.SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0){ if(SettingsAdapter.get_DeviceCapabilitiesSize(device) === 0){
return return
} }
@ -112,22 +114,22 @@ Rectangle {
} }
function startPreviewing(force = false, async = true){ function startPreviewing(force = false, async = true){
ClientWrapper.accountAdaptor.startPreviewing(force, async) AccountAdapter.startPreviewing(force, async)
previewAvailable = true previewAvailable = true
} }
function stopPreviewing(async = true){ function stopPreviewing(async = true){
ClientWrapper.accountAdaptor.stopPreviewing(async) AccountAdapter.stopPreviewing(async)
} }
function startAudioMeter(async = true){ function startAudioMeter(async = true){
audioInputMeter.start() audioInputMeter.start()
ClientWrapper.accountAdaptor.startAudioMeter(async) AccountAdapter.startAudioMeter(async)
} }
function stopAudioMeter(async = true){ function stopAudioMeter(async = true){
audioInputMeter.stop() audioInputMeter.stop()
ClientWrapper.accountAdaptor.stopAudioMeter(async) AccountAdapter.stopAudioMeter(async)
} }
// slots for av page // slots for av page
@ -138,7 +140,7 @@ Rectangle {
} }
function slotSetHardwareAccel(state){ function slotSetHardwareAccel(state){
ClientWrapper.avmodel.setHardwareAcceleration(state) AVModel.setHardwareAcceleration(state)
startPreviewing(true) startPreviewing(true)
} }
@ -146,7 +148,7 @@ Rectangle {
stopAudioMeter(false) stopAudioMeter(false)
var selectedAudioManager = audioManagerComboBox.model.data(audioManagerComboBox.model.index( var selectedAudioManager = audioManagerComboBox.model.data(audioManagerComboBox.model.index(
index, 0), AudioManagerListModel.AudioManagerID) index, 0), AudioManagerListModel.AudioManagerID)
ClientWrapper.avmodel.setAudioManager(selectedAudioManager) AVModel.setAudioManager(selectedAudioManager)
startAudioMeter(false) startAudioMeter(false)
} }
@ -154,7 +156,7 @@ Rectangle {
stopAudioMeter(false) stopAudioMeter(false)
var selectedRingtoneDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index( var selectedRingtoneDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index(
index, 0), AudioOutputDeviceModel.Device_ID) index, 0), AudioOutputDeviceModel.Device_ID)
ClientWrapper.avmodel.setRingtoneDevice(selectedRingtoneDeviceName) AVModel.setRingtoneDevice(selectedRingtoneDeviceName)
startAudioMeter(false) startAudioMeter(false)
} }
@ -162,7 +164,7 @@ Rectangle {
stopAudioMeter(false) stopAudioMeter(false)
var selectedOutputDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index( var selectedOutputDeviceName = audioOutputDeviceModel.data(audioOutputDeviceModel.index(
index, 0), AudioOutputDeviceModel.Device_ID) index, 0), AudioOutputDeviceModel.Device_ID)
ClientWrapper.avmodel.setOutputDevice(selectedOutputDeviceName) AVModel.setOutputDevice(selectedOutputDeviceName)
startAudioMeter(false) startAudioMeter(false)
} }
@ -171,7 +173,7 @@ Rectangle {
var selectedInputDeviceName = audioInputComboBox.model.data(audioInputComboBox.model.index( var selectedInputDeviceName = audioInputComboBox.model.data(audioInputComboBox.model.index(
index, 0), AudioInputDeviceModel.Device_ID) index, 0), AudioInputDeviceModel.Device_ID)
ClientWrapper.avmodel.setInputDevice(selectedInputDeviceName) AVModel.setInputDevice(selectedInputDeviceName)
startAudioMeter(false) startAudioMeter(false)
} }
@ -190,8 +192,8 @@ Rectangle {
return return
} }
ClientWrapper.avmodel.setCurrentVideoCaptureDevice(deviceId) AVModel.setCurrentVideoCaptureDevice(deviceId)
ClientWrapper.avmodel.setDefaultDevice(deviceId) AVModel.setDefaultDevice(deviceId)
setFormatListForCurrentDevice() setFormatListForCurrentDevice()
startPreviewing(true) startPreviewing(true)
} catch(err){console.warn(err.message)} } catch(err){console.warn(err.message)}
@ -216,7 +218,7 @@ Rectangle {
} }
try{ 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) updatePreviewRatio(resolution)
} catch(error){console.warn(error.message)} } catch(error){console.warn(error.message)}
} }

View file

@ -48,12 +48,12 @@ Rectangle {
accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled() accountEnableCheckBox.checked = SettingsAdapter.get_CurrentAccountInfo_Enabled()
displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias() displayNameLineEdit.text = SettingsAdapter.getCurrentAccount_Profile_Info_Alias()
var showLocalAccountConfig = (ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === "") var showLocalAccountConfig = (SettingsAdapter.getAccountConfig_Manageruri() === "")
passwdPushButton.visible = showLocalAccountConfig passwdPushButton.visible = showLocalAccountConfig
btnExportAccount.visible = showLocalAccountConfig btnExportAccount.visible = showLocalAccountConfig
linkDevPushButton.visible = showLocalAccountConfig linkDevPushButton.visible = showLocalAccountConfig
registeredIdNeedsSet = (ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "") registeredIdNeedsSet = (SettingsAdapter.get_CurrentAccountInfo_RegisteredName() === "")
if(!registeredIdNeedsSet){ if(!registeredIdNeedsSet){
currentRegisteredID.text = SettingsAdapter.get_CurrentAccountInfo_RegisteredName() currentRegisteredID.text = SettingsAdapter.get_CurrentAccountInfo_RegisteredName()
@ -111,8 +111,8 @@ Rectangle {
Connections { Connections {
id: accountConnections_ContactModel id: accountConnections_ContactModel
target: ClientWrapper.contactModel target: AccountAdapter.contactModel
enabled: root.visible enabled: accountViewRect.visible
function onModelUpdated(uri, needsSorted) { function onModelUpdated(uri, needsSorted) {
updateAndShowBannedContactsSlot() updateAndShowBannedContactsSlot()
@ -129,8 +129,8 @@ Rectangle {
Connections { Connections {
id: accountConnections_DeviceModel id: accountConnections_DeviceModel
target: ClientWrapper.deviceModel target: AccountAdapter.deviceModel
enabled: root.visible enabled: accountViewRect.visible
function onDeviceAdded(id) { function onDeviceAdded(id) {
updateAndShowDevicesSlot() updateAndShowDevicesSlot()
@ -146,7 +146,7 @@ Rectangle {
} }
function setAccEnableSlot(state) { function setAccEnableSlot(state) {
ClientWrapper.accountModel.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) AccountAdapter.model.setAccountEnabled(UtilsAdapter.getCurrAccId(), state)
} }
// JamiFileDialog for exporting account // JamiFileDialog for exporting account
@ -164,12 +164,12 @@ Rectangle {
onAccepted: { onAccepted: {
// is there password? If so, go to password dialog, else, go to following directly // is there password? If so, go to password dialog, else, go to following directly
var exportPath = UtilsAdapter.getAbsPath(file.toString()) var exportPath = UtilsAdapter.getAbsPath(file.toString())
if (ClientWrapper.accountAdaptor.hasPassword()) { if (AccountAdapter.hasPassword()) {
passwordDialog.openDialog(PasswordDialog.ExportAccount,exportPath) passwordDialog.openDialog(PasswordDialog.ExportAccount,exportPath)
return return
} else { } else {
if (exportPath.length > 0) { 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 title = isSuccessful ? qsTr("Success") : qsTr("Error")
var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical var iconMode = isSuccessful ? StandardIcon.Information : StandardIcon.Critical
var info = isSuccessful ? qsTr("Export Successful") : qsTr("Export Failed") var info = isSuccessful ? qsTr("Export Successful") : qsTr("Export Failed")
@ -212,7 +212,7 @@ Rectangle {
} }
function passwordClicked() { function passwordClicked() {
if (ClientWrapper.accountAdaptor.hasPassword()){ if (AccountAdapter.hasPassword()){
passwordDialog.openDialog(PasswordDialog.ChangePassword) passwordDialog.openDialog(PasswordDialog.ChangePassword)
} else { } else {
passwordDialog.openDialog(PasswordDialog.SetPassword) passwordDialog.openDialog(PasswordDialog.SetPassword)
@ -229,7 +229,7 @@ Rectangle {
anchors.centerIn: parent.Center anchors.centerIn: parent.Center
onAccepted: { onAccepted: {
ClientWrapper.accountAdaptor.setSelectedConvId() AccountAdapter.setSelectedConvId()
if(UtilsAdapter.getAccountListSize() > 0){ if(UtilsAdapter.getAccountListSize() > 0){
navigateToMainView() navigateToMainView()
@ -289,8 +289,8 @@ Rectangle {
} }
function removeDeviceSlot(index){ function removeDeviceSlot(index){
var idOfDevice = settingsListView.model.data(settingsListView.model.index(index,0), DeviceItemListModel.DeviceID) var idOfDevice = deviceItemListModel.data(deviceItemListModel.index(index,0), DeviceItemListModel.DeviceID)
if(ClientWrapper.accountAdaptor.hasPassword()){ if(AccountAdapter.hasPassword()){
revokeDevicePasswordDialog.openRevokeDeviceDialog(idOfDevice) revokeDevicePasswordDialog.openRevokeDeviceDialog(idOfDevice)
} else { } else {
revokeDeviceMessageBox.idOfDev = idOfDevice revokeDeviceMessageBox.idOfDev = idOfDevice
@ -299,7 +299,7 @@ Rectangle {
} }
function revokeDeviceWithIDAndPassword(idDevice, password){ function revokeDeviceWithIDAndPassword(idDevice, password){
ClientWrapper.deviceModel.revokeDevice(idDevice, password) AccountAdapter.deviceModel.revokeDevice(idDevice, password)
updateAndShowDevicesSlot() updateAndShowDevicesSlot()
} }
@ -313,7 +313,7 @@ Rectangle {
} }
function updateAndShowDevicesSlot() { function updateAndShowDevicesSlot() {
if(ClientWrapper.SettingsAdapter.getAccountConfig_Manageruri() === ""){ if(SettingsAdapter.getAccountConfig_Manageruri() === ""){
linkDevPushButton.visible = true linkDevPushButton.visible = true
} }
@ -450,7 +450,7 @@ Rectangle {
padding: 8 padding: 8
onEditingFinished: { onEditingFinished: {
ClientWrapper.accountAdaptor.setCurrAccDisplayName( AccountAdapter.setCurrAccDisplayName(
displayNameLineEdit.text) displayNameLineEdit.text)
} }
} }
@ -525,7 +525,7 @@ Rectangle {
elide: Text.ElideRight elide: Text.ElideRight
elideWidth: root.width - idLabel.width -JamiTheme.preferredMarginSize*4 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") : "" qsTr("Type here to register a username") : ""
text: { text: {
if (!registeredIdNeedsSet) if (!registeredIdNeedsSet)
return ClientWrapper.SettingsAdapter.get_CurrentAccountInfo_RegisteredName() return SettingsAdapter.get_CurrentAccountInfo_RegisteredName()
else else
return "" return ""
} }
@ -615,10 +615,10 @@ Rectangle {
pressedColor: JamiTheme.buttonTintedBlackPressed pressedColor: JamiTheme.buttonTintedBlackPressed
outlined: true outlined: true
toolTipText: ClientWrapper.accountAdaptor.hasPassword() ? toolTipText: AccountAdapter.hasPassword() ?
qsTr("Change the current password") : qsTr("Change the current password") :
qsTr("Currently no password, press this button to set a 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") qsTr("Set Password")
source: "qrc:/images/icons/round-edit-24px.svg" 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 QtQuick.Layouts 1.3
import QtGraphicalEffects 1.14 import QtGraphicalEffects 1.14
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
@ -67,7 +68,7 @@ Rectangle {
// slots // slots
function setAccEnableSlot(state) { function setAccEnableSlot(state) {
ClientWrapper.accountModel.setAccountEnabled(UtilsAdapter.getCurrAccId(), state) AccountAdapter.model.setAccountEnabled(UtilsAdapter.getCurrAccId(), state)
} }
function delAccountSlot() { function delAccountSlot() {
@ -80,7 +81,7 @@ Rectangle {
anchors.centerIn: parent.Center anchors.centerIn: parent.Center
onAccepted: { onAccepted: {
ClientWrapper.accountAdaptor.setSelectedConvId() AccountAdapter.setSelectedConvId()
if(UtilsAdapter.getAccountListSize() > 0){ if(UtilsAdapter.getAccountListSize() > 0){
navigateToMainView() navigateToMainView()
@ -212,7 +213,7 @@ Rectangle {
padding: 8 padding: 8
onEditingFinished: { onEditingFinished: {
ClientWrapper.accountAdaptor.setCurrAccDisplayName( AccountAdapter.setCurrAccDisplayName(
displaySIPNameLineEdit.text) displaySIPNameLineEdit.text)
} }
} }

View file

@ -37,12 +37,12 @@ Rectangle {
applicationOnStartUpCheckBox.checked = UtilsAdapter.checkStartupLink() applicationOnStartUpCheckBox.checked = UtilsAdapter.checkStartupLink()
notificationCheckBox.checked = SettingsAdapter.getAppValue(Settings.EnableNotifications) notificationCheckBox.checked = SettingsAdapter.getAppValue(Settings.EnableNotifications)
alwaysRecordingCheckBox.checked = ClientWrapper.avmodel.getAlwaysRecord() alwaysRecordingCheckBox.checked = AVModel.getAlwaysRecord()
recordPreviewCheckBox.checked = ClientWrapper.avmodel.getRecordPreview() recordPreviewCheckBox.checked = AVModel.getRecordPreview()
recordQualityValueLabel.text = UtilsAdapter.getRecordQualityString(ClientWrapper.avmodel.getRecordQuality() / 100) recordQualityValueLabel.text = UtilsAdapter.getRecordQualityString(AVModel.getRecordQuality() / 100)
recordQualitySlider.value = ClientWrapper.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) autoUpdateCheckBox.checked = SettingsAdapter.getAppValue(Settings.Key.AutoUpdate)
} }
@ -64,11 +64,11 @@ Rectangle {
} }
function slotAlwaysRecordingClicked(state){ function slotAlwaysRecordingClicked(state){
ClientWrapper.avmodel.setAlwaysRecord(state) AVModel.setAlwaysRecord(state)
} }
function slotRecordPreviewClicked(state){ function slotRecordPreviewClicked(state){
ClientWrapper.avmodel.setRecordPreview(state) AVModel.setRecordPreview(state)
} }
function slotRecordQualitySliderValueChanged(value){ function slotRecordQualitySliderValueChanged(value){
@ -88,7 +88,7 @@ Rectangle {
function slotRecordQualitySliderSliderReleased(){ function slotRecordQualitySliderSliderReleased(){
var value = recordQualitySlider.value var value = recordQualitySlider.value
ClientWrapper.avmodel.setRecordQuality(value * 100) AVModel.setRecordQuality(value * 100)
} }
function openDownloadFolderSlot(){ function openDownloadFolderSlot(){
@ -146,8 +146,8 @@ Rectangle {
onRecordPathChanged: { onRecordPathChanged: {
if(recordPath === "") return if(recordPath === "") return
if(ClientWrapper.avmodel){ if(AVModel){
ClientWrapper.avmodel.setRecordPath(recordPath) AVModel.setRecordPath(recordPath)
} }
} }

View file

@ -21,6 +21,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" 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.") infoLabel.text = qsTr("This pin and the account password should be entered in your device within 10 minutes.")
passwordEdit.clear() passwordEdit.clear()
root.open() root.open()
if(ClientWrapper.accountAdaptor.hasPassword()) { if(AccountAdapter.hasPassword()) {
stackedWidget.currentIndex = 0 stackedWidget.currentIndex = 0
} else { } else {
setGeneratingPage() setGeneratingPage()
@ -39,7 +40,7 @@ Dialog {
} }
function setGeneratingPage() { function setGeneratingPage() {
if(passwordEdit.length === 0 && ClientWrapper.accountAdaptor.hasPassword()){ if(passwordEdit.length === 0 && AccountAdapter.hasPassword()){
setExportPage(NameDirectory.ExportOnRingStatus.WRONG_PASSWORD, "") setExportPage(NameDirectory.ExportOnRingStatus.WRONG_PASSWORD, "")
return return
} }
@ -51,7 +52,7 @@ Dialog {
} }
function slotExportOnRing(){ function slotExportOnRing(){
ClientWrapper.accountModel.exportOnRing(UtilsAdapter.getCurrAccId(),passwordEdit.text) AccountAdapter.model.exportOnRing(UtilsAdapter.getCurrAccId(),passwordEdit.text)
} }
Timer{ Timer{
@ -111,8 +112,8 @@ Dialog {
property int exportTimeout : 20000 property int exportTimeout : 20000
Connections{ Connections {
target: ClientWrapper.nameDirectory target: NameDirectory
function onExportOnRingEnded(status, pin) { function onExportOnRingEnded(status, pin) {
setExportPage(status, pin) setExportPage(status, pin)

View file

@ -21,6 +21,7 @@ import QtQuick.Controls 2.14
import QtQuick.Layouts 1.14 import QtQuick.Layouts 1.14
import QtQuick.Controls.Styles 1.4 import QtQuick.Controls.Styles 1.4
import net.jami.Models 1.0 import net.jami.Models 1.0
import net.jami.Adapters 1.0
import "../../commoncomponents" import "../../commoncomponents"
@ -33,7 +34,7 @@ Dialog {
registerdName = registerNameIn registerdName = registerNameIn
lblRegistrationError.text = qsTr("Something went wrong") lblRegistrationError.text = qsTr("Something went wrong")
passwordEdit.clear() passwordEdit.clear()
if(ClientWrapper.accountAdaptor.hasPassword()){ if(AccountAdapter.hasPassword()){
stackedWidget.currentIndex = 0 stackedWidget.currentIndex = 0
} else { } else {
startRegistration() startRegistration()
@ -49,7 +50,7 @@ Dialog {
function slotStartNameRegistration(){ function slotStartNameRegistration(){
var password = passwordEdit.text var password = passwordEdit.text
ClientWrapper.accountModel.registerName(UtilsAdapter.getCurrAccId(), password, registerdName) AccountAdapter.model.registerName(UtilsAdapter.getCurrAccId(), password, registerdName)
} }
function startSpinner(){ function startSpinner(){
@ -70,7 +71,7 @@ Dialog {
} }
Connections{ Connections{
target: ClientWrapper.nameDirectory target: NameDirectory
function onNameRegistrationEnded(status, name){ function onNameRegistrationEnded(status, name){
if(status === NameDirectory.RegisterNameStatus.SUCCESS){ if(status === NameDirectory.RegisterNameStatus.SUCCESS){

View file

@ -49,11 +49,11 @@ Rectangle {
function resetPlugin(){ function resetPlugin(){
if (isLoaded){ if (isLoaded){
ClientWrapper.pluginModel.unloadPlugin(pluginId) PluginModel.unloadPlugin(pluginId)
ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId) PluginModel.resetPluginPreferencesValues(pluginId)
ClientWrapper.pluginModel.loadPlugin(pluginId) PluginModel.loadPlugin(pluginId)
} else { } else {
ClientWrapper.pluginModel.resetPluginPreferencesValues(pluginId) PluginModel.resetPluginPreferencesValues(pluginId)
} }
pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId) pluginPreferenceView.model = PluginAdapter.getPluginPreferencesModel(pluginId)
} }
@ -63,18 +63,18 @@ Rectangle {
} }
function uninstallPlugin(){ function uninstallPlugin(){
ClientWrapper.pluginModel.uninstallPlugin(pluginId) PluginModel.uninstallPlugin(pluginId)
} }
function setPreference(pluginId, preferenceKey, preferenceNewValue) function setPreference(pluginId, preferenceKey, preferenceNewValue)
{ {
if (isLoaded){ if (isLoaded){
ClientWrapper.pluginModel.unloadPlugin(pluginId) PluginModel.unloadPlugin(pluginId)
ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
ClientWrapper.pluginModel.loadPlugin(pluginId) PluginModel.loadPlugin(pluginId)
} }
else { else {
ClientWrapper.pluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue) PluginModel.setPluginPreference(pluginId, preferenceKey, preferenceNewValue)
} }
} }

View file

@ -40,9 +40,9 @@ Rectangle {
function loadPluginSlot(pluginId, isLoaded){ function loadPluginSlot(pluginId, isLoaded){
var loaded = false var loaded = false
if (isLoaded) if (isLoaded)
ClientWrapper.pluginModel.unloadPlugin(pluginId) PluginModel.unloadPlugin(pluginId)
else else
loaded = ClientWrapper.pluginModel.loadPlugin(pluginId) loaded = PluginModel.loadPlugin(pluginId)
if(pluginListPreferencesView.pluginId === pluginId) if(pluginListPreferencesView.pluginId === pluginId)
pluginListPreferencesView.isLoaded = loaded pluginListPreferencesView.isLoaded = loaded
} }
@ -78,7 +78,7 @@ Rectangle {
onAccepted: { onAccepted: {
var url = UtilsAdapter.getAbsPath(file.toString()) var url = UtilsAdapter.getAbsPath(file.toString())
ClientWrapper.pluginModel.installPlugin(url, true) PluginModel.installPlugin(url, true)
} }
} }

View file

@ -31,12 +31,12 @@ Rectangle {
function populatePluginSettings(){ function populatePluginSettings(){
// settings // settings
enabledplugin.checked = ClientWrapper.pluginModel.getPluginsEnabled() enabledplugin.checked = PluginModel.getPluginsEnabled()
pluginListSettingsView.visible = enabledplugin.checked pluginListSettingsView.visible = enabledplugin.checked
} }
function slotSetPluginEnabled(state){ function slotSetPluginEnabled(state){
ClientWrapper.pluginModel.setPluginsEnabled(state) PluginModel.setPluginsEnabled(state)
} }
signal backArrowClicked signal backArrowClicked
@ -110,7 +110,7 @@ Rectangle {
pluginListSettingsView.visible = checked pluginListSettingsView.visible = checked
if (!pluginListSettingsView.visible) { if (!pluginListSettingsView.visible) {
ClientWrapper.pluginModel.toggleCallMediaHandler("", true) PluginModel.toggleCallMediaHandler("", true)
pluginListSettingsView.hidePreferences() pluginListSettingsView.hidePreferences()
} }
} }

View file

@ -60,13 +60,13 @@ UtilsAdapter::setText(QString text)
} }
const QString const QString
UtilsAdapter::qStringFromFile(const QString &filename) UtilsAdapter::qStringFromFile(const QString& filename)
{ {
return Utils::QByteArrayFromFile(filename); return Utils::QByteArrayFromFile(filename);
} }
const QString const QString
UtilsAdapter::getStyleSheet(const QString &name, const QString &source) UtilsAdapter::getStyleSheet(const QString& name, const QString& source)
{ {
auto simplifiedCSS = source.simplified().replace("'", "\""); auto simplifiedCSS = source.simplified().replace("'", "\"");
QString s = QString::fromLatin1("(function() {" QString s = QString::fromLatin1("(function() {"
@ -106,20 +106,29 @@ UtilsAdapter::checkStartupLink()
} }
const QString const QString
UtilsAdapter::getContactImageString(const QString &accountId, const QString &uid) UtilsAdapter::getContactImageString(const QString& accountId, const QString& uid)
{ {
return Utils::getContactImageString(accountId, uid); return Utils::getContactImageString(accountId, uid);
} }
const QString 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(); auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestNameForConversation(convModel->getConversationForUID(uid), *convModel); 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 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(); auto* convModel = LRCInstance::getAccountInfo(accountId).conversationModel.get();
return Utils::bestIdForConversation(convModel->getConversationForUID(uid), *convModel); return Utils::bestIdForConversation(convModel->getConversationForUID(uid), *convModel);
@ -128,13 +137,13 @@ UtilsAdapter::getBestId(const QString &accountId, const QString &uid)
int int
UtilsAdapter::getTotalUnreadMessages() UtilsAdapter::getTotalUnreadMessages()
{ {
int totalUnreadMessages{0}; int totalUnreadMessages {0};
if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) { if (LRCInstance::getCurrentAccountInfo().profileInfo.type != lrc::api::profile::Type::SIP) {
auto* convModel = LRCInstance::getCurrentConversationModel(); auto* convModel = LRCInstance::getCurrentConversationModel();
auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING); auto ringConversations = convModel->getFilteredConversations(lrc::api::profile::Type::RING);
std::for_each(ringConversations.begin(), std::for_each(ringConversations.begin(),
ringConversations.end(), ringConversations.end(),
[&totalUnreadMessages](const auto &conversation) { [&totalUnreadMessages](const auto& conversation) {
totalUnreadMessages += conversation.unreadMessages; totalUnreadMessages += conversation.unreadMessages;
}); });
} }
@ -144,24 +153,24 @@ UtilsAdapter::getTotalUnreadMessages()
int int
UtilsAdapter::getTotalPendingRequest() UtilsAdapter::getTotalPendingRequest()
{ {
auto &accountInfo = LRCInstance::getCurrentAccountInfo(); auto& accountInfo = LRCInstance::getCurrentAccountInfo();
return accountInfo.contactModel->pendingRequestCount(); return accountInfo.contactModel->pendingRequestCount();
} }
void void
UtilsAdapter::setConversationFilter(const QString &filter) UtilsAdapter::setConversationFilter(const QString& filter)
{ {
LRCInstance::getCurrentConversationModel()->setFilter(filter); LRCInstance::getCurrentConversationModel()->setFilter(filter);
} }
void void
UtilsAdapter::clearConversationHistory(const QString &accountId, const QString &uid) UtilsAdapter::clearConversationHistory(const QString& accountId, const QString& uid)
{ {
LRCInstance::getAccountInfo(accountId).conversationModel->clearHistory(uid); LRCInstance::getAccountInfo(accountId).conversationModel->clearHistory(uid);
} }
void 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); LRCInstance::getAccountInfo(accountId).conversationModel->removeConversation(uid, banContact);
} }
@ -197,9 +206,9 @@ UtilsAdapter::getAccountListSize()
} }
void 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); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
accInfo.callModel->setCurrentCall(convInfo.callId); accInfo.callModel->setCurrentCall(convInfo.callId);
} }
@ -225,9 +234,9 @@ UtilsAdapter::hasVideoCall()
} }
const QString 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); const auto convInfo = accInfo.conversationModel->getConversationForUID(convUid);
if (convInfo.uid.isEmpty()) { if (convInfo.uid.isEmpty()) {
@ -249,10 +258,9 @@ UtilsAdapter::getCallStatusStr(int statusInt)
return lrc::api::call::to_string(status); return lrc::api::call::to_string(status);
} }
// returns true if name is valid registered name // returns true if name is valid registered name
bool bool
UtilsAdapter::validateRegNameForm(const QString &regName) UtilsAdapter::validateRegNameForm(const QString& regName)
{ {
QRegularExpression regExp(" "); QRegularExpression regExp(" ");

View file

@ -31,47 +31,43 @@ class UtilsAdapter final : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit UtilsAdapter(QObject *parent = nullptr); explicit UtilsAdapter(QObject* parent = nullptr);
~UtilsAdapter() = default; ~UtilsAdapter() = default;
Q_INVOKABLE const QString getChangeLog(); Q_INVOKABLE const QString getChangeLog();
Q_INVOKABLE const QString getProjectCredits(); Q_INVOKABLE const QString getProjectCredits();
Q_INVOKABLE const QString getVersionStr(); Q_INVOKABLE const QString getVersionStr();
Q_INVOKABLE void setText(QString text); Q_INVOKABLE void setText(QString text);
Q_INVOKABLE const QString qStringFromFile(const QString &filename); Q_INVOKABLE const QString qStringFromFile(const QString& filename);
Q_INVOKABLE const QString getStyleSheet(const QString &name, Q_INVOKABLE const QString getStyleSheet(const QString& name, const QString& source);
const QString &source);
Q_INVOKABLE const QString getCachePath(); Q_INVOKABLE const QString getCachePath();
Q_INVOKABLE bool createStartupLink(); Q_INVOKABLE bool createStartupLink();
Q_INVOKABLE QString GetRingtonePath(); Q_INVOKABLE QString GetRingtonePath();
Q_INVOKABLE bool checkStartupLink(); Q_INVOKABLE bool checkStartupLink();
Q_INVOKABLE const QString getContactImageString(const QString &accountId, Q_INVOKABLE const QString getContactImageString(const QString& accountId, const QString& uid);
const QString &uid); Q_INVOKABLE void removeConversation(const QString& accountId,
Q_INVOKABLE void removeConversation(const QString &accountId, const QString& uid,
const QString &uid,
bool banContact = false); bool banContact = false);
Q_INVOKABLE void clearConversationHistory(const QString &accountId, Q_INVOKABLE void clearConversationHistory(const QString& accountId, const QString& uid);
const QString &uid); Q_INVOKABLE void setConversationFilter(const QString& filter);
Q_INVOKABLE void setConversationFilter(const QString &filter);
Q_INVOKABLE int getTotalUnreadMessages(); Q_INVOKABLE int getTotalUnreadMessages();
Q_INVOKABLE int getTotalPendingRequest(); Q_INVOKABLE int getTotalPendingRequest();
Q_INVOKABLE const QString getBestName(const QString &accountId, Q_INVOKABLE const QString getBestName(const QString& accountId, const QString& uid);
const QString &uid); Q_INVOKABLE QString getBestId(const QString& accountId);
Q_INVOKABLE const QString getBestId(const QString &accountId, Q_INVOKABLE const QString getBestId(const QString& accountId, const QString& uid);
const QString &uid);
Q_INVOKABLE const QString getCurrAccId(); Q_INVOKABLE const QString getCurrAccId();
Q_INVOKABLE const QString getCurrConvId(); Q_INVOKABLE const QString getCurrConvId();
Q_INVOKABLE void makePermanentCurrentConv(); Q_INVOKABLE void makePermanentCurrentConv();
Q_INVOKABLE const QStringList getCurrAccList(); Q_INVOKABLE const QStringList getCurrAccList();
Q_INVOKABLE int getAccountListSize(); 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 startPreviewing(bool force);
Q_INVOKABLE void stopPreviewing(); Q_INVOKABLE void stopPreviewing();
Q_INVOKABLE bool hasVideoCall(); 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 const QString getCallStatusStr(int statusInt);
Q_INVOKABLE QString getStringUTF8(QString string); 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 getRecordQualityString(int value);
Q_INVOKABLE QString getCurrentPath(); Q_INVOKABLE QString getCurrentPath();
Q_INVOKABLE QString stringSimplifier(QString input); Q_INVOKABLE QString stringSimplifier(QString input);
@ -86,6 +82,6 @@ public:
Q_INVOKABLE bool isImage(const QString& fileExt); Q_INVOKABLE bool isImage(const QString& fileExt);
private: private:
QClipboard *clipboard_; QClipboard* clipboard_;
}; };
Q_DECLARE_METATYPE(UtilsAdapter *) Q_DECLARE_METATYPE(UtilsAdapter*)

View file

@ -76,11 +76,11 @@ Rectangle {
} }
Connections{ Connections{
target: ClientWrapper.accountAdaptor target: AccountAdapter
function onAccountAdded(showBackUp, index) { function onAccountAdded(showBackUp, index) {
addedAccountIndex = index addedAccountIndex = index
ClientWrapper.accountAdaptor.accountChanged(index) AccountAdapter.accountChanged(index)
if (showProfile) { if (showProfile) {
changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE) changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE)
profilePage.readyToSaveDetails() profilePage.readyToSaveDetails()
@ -150,7 +150,7 @@ Rectangle {
var info = success ? qsTr("Export Successful") : qsTr( var info = success ? qsTr("Export Successful") : qsTr(
"Export Failed") "Export Failed")
ClientWrapper.accountAdaptor.passwordSetStatusMessageBox(success, AccountAdapter.passwordSetStatusMessageBox(success,
title, info) title, info)
if (success) { if (success) {
console.log("Account Export Succeed") console.log("Account Export Succeed")
@ -190,7 +190,7 @@ Rectangle {
onCreateAccount: { onCreateAccount: {
inputParaObject = {} inputParaObject = {}
inputParaObject["password"] = text_passwordEditAlias inputParaObject["password"] = text_passwordEditAlias
ClientWrapper.accountAdaptor.createJamiAccount( AccountAdapter.createJamiAccount(
createAccountPage.text_usernameEditAlias, createAccountPage.text_usernameEditAlias,
inputParaObject, inputParaObject,
createAccountPage.boothImgBase64, createAccountPage.boothImgBase64,
@ -220,7 +220,7 @@ Rectangle {
inputParaObject["proxy"] = createSIPAccountPage.text_sipProxyEditAlias inputParaObject["proxy"] = createSIPAccountPage.text_sipProxyEditAlias
createSIPAccountPage.clearAllTextFields() createSIPAccountPage.clearAllTextFields()
ClientWrapper.accountAdaptor.createSIPAccount(inputParaObject, "") AccountAdapter.createSIPAccount(inputParaObject, "")
showBackUp = false showBackUp = false
showBottom = false showBottom = false
changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE) changePageQML(WizardView.WizardViewPageIndex.PROFILEPAGE)
@ -242,7 +242,7 @@ Rectangle {
showBackUp = false showBackUp = false
showBottom = false showBottom = false
showProfile = true showProfile = true
ClientWrapper.accountAdaptor.createJamiAccount( AccountAdapter.createJamiAccount(
"", inputParaObject, "", false) "", inputParaObject, "", false)
} }
} }
@ -257,13 +257,13 @@ Rectangle {
onExport_Btn_FileDialogAccepted: { onExport_Btn_FileDialogAccepted: {
if (accepted) { if (accepted) {
// is there password? If so, go to password dialog, else, go to following directly // 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.path = UtilsAdapter.getAbsPath(folderDir)
passwordDialog.open() passwordDialog.open()
return return
} else { } else {
if (folderDir.length > 0) { if (folderDir.length > 0) {
ClientWrapper.accountAdaptor.exportToFile( AccountAdapter.exportToFile(
UtilsAdapter.getCurrAccId(), UtilsAdapter.getCurrAccId(),
UtilsAdapter.getAbsPath(folderDir)) UtilsAdapter.getAbsPath(folderDir))
} }
@ -295,7 +295,7 @@ Rectangle {
showProfile = true showProfile = true
showBackUp = false showBackUp = false
showBottom = false showBottom = false
ClientWrapper.accountAdaptor.createJamiAccount( AccountAdapter.createJamiAccount(
"", inputParaObject, "", false) "", inputParaObject, "", false)
} }
} }
@ -311,7 +311,7 @@ Rectangle {
= connectToAccountManagerPage.text_passwordManagerEditAlias = connectToAccountManagerPage.text_passwordManagerEditAlias
inputParaObject["manager"] inputParaObject["manager"]
= connectToAccountManagerPage.text_accountManagerEditAlias = connectToAccountManagerPage.text_accountManagerEditAlias
ClientWrapper.accountAdaptor.createJAMSAccount(inputParaObject) AccountAdapter.createJAMSAccount(inputParaObject)
} }
onLeavePage: { onLeavePage: {
@ -333,7 +333,7 @@ Rectangle {
onSaveProfile: { onSaveProfile: {
SettingsAdapter.setCurrAccAvatar(profilePage.boothImgBase64) SettingsAdapter.setCurrAccAvatar(profilePage.boothImgBase64)
ClientWrapper.accountAdaptor.setCurrAccDisplayName(profilePage.displayName) AccountAdapter.setCurrAccDisplayName(profilePage.displayName)
leave() leave()
} }

View file

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