lrcinstance: remove custom setter/getter for currentAccountId

Using a custom getter setter cause the setting of the value to
require manual changed signal emission and in addition to being
error prone, this prevents the changed signal from being emitted
upon initial selection. Some excess workaround code may be removed
in following commits.

This patch also refactors the banned contact signaling as part of
an accountadapter connection cleanup.

Change-Id: I73fb751001e53e086adc7a6a8d706671c2878a77
This commit is contained in:
Andreas Traczyk
2021-07-07 13:48:41 -04:00
parent f8d5ab7fe7
commit 285316dd32
25 changed files with 236 additions and 353 deletions

View File

@@ -1,11 +1,8 @@
/*
* Copyright (C) 2020 by Savoir-faire Linux
* Author: Edric Ladent Milaret <edric.ladent-milaret@savoirfairelinux.com>
* Author: Anthony L<>onard <anthony.leonard@savoirfairelinux.com
* Author: Olivier Soldano <olivier.soldano@savoirfairelinux.com>
* Copyright (C) 2020-2021 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
* Author: Yang Wang <yang.yang@savoirfairelinux.com>
* Author: Andreas Traczyk <andreas.traczyk@savoirfairelinux.com>
* Author: Isa Nanic <isa.nanic@savoirfairelinux.com>
* Author: Mingrui Zhang <mingrui.zhang@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
@@ -37,28 +34,31 @@ AccountAdapter::AccountAdapter(AppSettingsManager* settingsManager,
, accSrcModel_(new AccountListModel(instance))
, accModel_(new CurrentAccountFilterModel(instance, accSrcModel_.get()))
{
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, accModel_.get(), "CurrentAccountFilterModel");
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, accSrcModel_.get(), "AccountListModel");
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, accModel_.get(), "CurrentAccountFilterModel");
}
void
AccountAdapter::safeInit()
{
connect(lrcInstance_,
&LRCInstance::currentAccountIdChanged,
connect(&lrcInstance_->accountModel(),
&NewAccountModel::accountStatusChanged,
this,
&AccountAdapter::onCurrentAccountChanged);
&AccountAdapter::accountStatusChanged);
connectAccount(lrcInstance_->getCurrentAccountId());
connect(&lrcInstance_->accountModel(),
&NewAccountModel::profileUpdated,
this,
&AccountAdapter::accountStatusChanged);
}
lrc::api::NewAccountModel*
NewAccountModel*
AccountAdapter::getModel()
{
return &(lrcInstance_->accountModel());
}
lrc::api::NewDeviceModel*
NewDeviceModel*
AccountAdapter::getDeviceModel()
{
return lrcInstance_->getCurrentAccountInfo().deviceModel.get();
@@ -69,7 +69,7 @@ AccountAdapter::changeAccount(int row)
{
auto accountList = lrcInstance_->accountModel().getAccountList();
if (accountList.size() > row) {
lrcInstance_->setCurrentAccountId(accountList.at(row));
lrcInstance_->set_currentAccountId(accountList.at(row));
}
}
@@ -82,6 +82,7 @@ AccountAdapter::connectFailure()
Q_UNUSED(accountId);
Q_EMIT reportFailure();
});
Utils::oneShotConnect(&lrcInstance_->accountModel(),
&lrc::api::NewAccountModel::invalidAccountDetected,
[this](const QString& accountId) {
@@ -226,7 +227,7 @@ AccountAdapter::createJAMSAccount(const QVariantMap& settings)
void
AccountAdapter::deleteCurrentAccount()
{
lrcInstance_->accountModel().removeAccount(lrcInstance_->getCurrentAccountId());
lrcInstance_->accountModel().removeAccount(lrcInstance_->get_currentAccountId());
Q_EMIT lrcInstance_->accountListChanged();
}
@@ -270,12 +271,6 @@ AccountAdapter::setCurrAccDisplayName(const QString& text)
lrcInstance_->setCurrAccDisplayName(text);
}
lrc::api::profile::Type
AccountAdapter::getCurrentAccountType()
{
return lrcInstance_->getCurrentAccountInfo().profileInfo.type;
}
void
AccountAdapter::setCurrAccAvatar(bool fromFile, const QString& source)
{
@@ -292,17 +287,11 @@ AccountAdapter::setCurrAccAvatar(bool fromFile, const QString& source)
});
}
void
AccountAdapter::onCurrentAccountChanged()
{
connectAccount(lrcInstance_->getCurrentAccountId());
}
bool
AccountAdapter::hasPassword()
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
return confProps.archiveHasPassword;
}
@@ -310,9 +299,9 @@ void
AccountAdapter::setArchiveHasPassword(bool isHavePassword)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.archiveHasPassword = isHavePassword;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
bool
AccountAdapter::exportToFile(const QString& accountId,
@@ -341,50 +330,3 @@ AccountAdapter::passwordSetStatusMessageBox(bool success, QString title, QString
QMessageBox::critical(0, title, infoToDisplay);
}
}
void
AccountAdapter::connectAccount(const QString& accountId)
{
try {
auto& accInfo = lrcInstance_->accountModel().getAccountInfo(accountId);
QObject::disconnect(accountStatusChangedConnection_);
QObject::disconnect(accountProfileUpdatedConnection_);
QObject::disconnect(addedToConferenceConnection_);
QObject::disconnect(bannedStatusChangedConnection_);
accountStatusChangedConnection_
= QObject::connect(accInfo.accountModel,
&lrc::api::NewAccountModel::accountStatusChanged,
[this](const QString& accountId) {
Q_EMIT accountStatusChanged(accountId);
});
accountProfileUpdatedConnection_
= QObject::connect(accInfo.accountModel,
&lrc::api::NewAccountModel::profileUpdated,
[this](const QString& accountId) {
Q_EMIT accountStatusChanged(accountId);
});
addedToConferenceConnection_
= QObject::connect(accInfo.callModel.get(),
&NewCallModel::callAddedToConference,
[this](const QString& callId, const QString& confId) {
Q_UNUSED(callId);
lrcInstance_->renderer()->addDistantRenderer(confId);
});
bannedStatusChangedConnection_
= QObject::connect(accInfo.contactModel.get(),
&lrc::api::ContactModel::bannedStatusChanged,
[this](const QString& uri, bool banned) {
if (!banned)
Q_EMIT contactUnbanned();
else
Q_EMIT lrcInstance_->contactBanned(uri);
});
} catch (...) {
qWarning() << "Couldn't get account: " << accountId;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020 by Savoir-faire Linux
* Copyright (C) 2021 by Savoir-faire Linux
* Author: Mingrui Zhang <mingrui.zhang@savoirfairelinux.com>
*
* This program is free software; you can redistribute it and/or modify
@@ -20,14 +20,13 @@
#include "qmladapterbase.h"
#include <QObject>
#include <QSettings>
#include <QString>
#include "accountlistmodel.h"
#include "lrcinstance.h"
#include "utils.h"
#include <QSettings>
#include <QString>
class AppSettingsManager;
class AccountAdapter final : public QmlAdapterBase
@@ -51,10 +50,8 @@ public:
QObject* parent = nullptr);
~AccountAdapter() = default;
protected:
void safeInit() override;
public:
// Change to account corresponding to combox box index.
Q_INVOKABLE void changeAccount(int row);
@@ -89,8 +86,6 @@ public:
Q_INVOKABLE bool hasVideoCall();
Q_INVOKABLE bool isPreviewing();
Q_INVOKABLE void setCurrAccDisplayName(const QString& text);
Q_INVOKABLE lrc::api::profile::Type getCurrentAccountType();
Q_INVOKABLE void setCurrAccAvatar(bool fromFile, const QString& source);
Q_SIGNALS:
@@ -100,22 +95,11 @@ Q_SIGNALS:
// Send report failure to QML to make it show the right UI state .
void reportFailure();
void accountAdded(QString accountId, bool showBackUp, int index);
void contactUnbanned();
private Q_SLOTS:
void onCurrentAccountChanged();
private:
// Make account signal connections.
void connectAccount(const QString& accountId);
// Implement what to do when account creation fails.
void connectFailure();
QMetaObject::Connection accountStatusChangedConnection_;
QMetaObject::Connection accountProfileUpdatedConnection_;
QMetaObject::Connection addedToConferenceConnection_;
QMetaObject::Connection bannedStatusChangedConnection_;
QMetaObject::Connection registeredNameSavedConnection_;
AppSettingsManager* settingsManager_;

View File

@@ -19,8 +19,6 @@
#include "accountlistmodel.h"
#include <QDateTime>
#include "lrcinstance.h"
#include "utils.h"
@@ -28,39 +26,23 @@
#include "api/contact.h"
#include "api/conversation.h"
#include <QDateTime>
AccountListModel::AccountListModel(LRCInstance* instance, QObject* parent)
: AbstractListModelBase(parent)
{
lrcInstance_ = instance;
}
AccountListModel::~AccountListModel() {}
int
AccountListModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid() && lrcInstance_) {
/*
* Count.
*/
return lrcInstance_->accountModel().getAccountList().size();
}
/*
* A valid QModelIndex returns 0 as no entry has sub-elements.
*/
return 0;
}
int
AccountListModel::columnCount(const QModelIndex& parent) const
{
Q_UNUSED(parent);
/*
* Only need one column.
*/
return 1;
}
QVariant
AccountListModel::data(const QModelIndex& index, int role) const
{

View File

@@ -63,32 +63,23 @@ public:
{
// Accept all contacts in conversation list filtered with account type, except those in a call.
auto index = sourceModel()->index(sourceRow, 0, sourceParent);
auto accountID = sourceModel()->data(index, AccountList::ID);
return accountID != lrcInstance_->getCurrentAccountId();
auto accountId = sourceModel()->data(index, AccountList::ID);
return accountId != lrcInstance_->get_currentAccountId();
}
protected:
LRCInstance* lrcInstance_ {nullptr};
};
class AccountListModel : public AbstractListModelBase
class AccountListModel final : public AbstractListModelBase
{
Q_OBJECT
public:
explicit AccountListModel(LRCInstance* instance, QObject* parent = nullptr);
~AccountListModel();
/*
* QAbstractListModel override.
*/
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
int columnCount(const QModelIndex& parent) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
/*
* Override role name as access point in qml.
*/
QHash<int, QByteArray> roleNames() const override;
/*

View File

@@ -39,7 +39,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject*
overlayModel_.reset(new CallOverlayModel(lrcInstance_, this));
QML_REGISTERSINGLETONTYPE_POBJECT(NS_MODELS, overlayModel_.get(), "CallOverlayModel");
accountId_ = lrcInstance_->getCurrentAccountId();
accountId_ = lrcInstance_->get_currentAccountId();
if (!accountId_.isEmpty())
connectCallModel(accountId_);
@@ -90,7 +90,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject*
void
CallAdapter::onAccountChanged()
{
accountId_ = lrcInstance_->getCurrentAccountId();
accountId_ = lrcInstance_->get_currentAccountId();
connectCallModel(accountId_);
}
@@ -284,7 +284,7 @@ void
CallAdapter::onCallAddedToConference(const QString& callId, const QString& confId)
{
Q_UNUSED(callId)
Q_UNUSED(confId)
lrcInstance_->renderer()->addDistantRenderer(confId);
saveConferenceSubcalls();
}
@@ -362,7 +362,7 @@ CallAdapter::onShowIncomingCallView(const QString& accountId, const QString& con
// this will update various UI elements that portray the call state
Q_EMIT callStatusChanged(static_cast<int>(call.status), accountId, convInfo.uid);
auto callBelongsToSelectedAccount = accountId == lrcInstance_->getCurrentAccountId();
auto callBelongsToSelectedAccount = accountId == lrcInstance_->get_currentAccountId();
auto accountProperties = lrcInstance_->accountModel().getAccountConfig(accountId);
// do nothing but update the status UI for incoming calls on RendezVous accounts

View File

@@ -28,6 +28,18 @@ ContactAdapter::ContactAdapter(LRCInstance* instance, QObject* parent)
selectableProxyModel_.reset(new SelectableProxyModel(this));
}
void
ContactAdapter::safeInit()
{
connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this] {
connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&ContactAdapter::bannedStatusChanged,
Qt::UniqueConnection);
});
}
QVariant
ContactAdapter::getContactSelectableModel(int type)
{
@@ -36,7 +48,7 @@ ContactAdapter::getContactSelectableModel(int type)
if (listModeltype_ == SmartListModel::Type::CONVERSATION) {
defaultModerators_ = lrcInstance_->accountModel().getDefaultModerators(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
}
smartListModel_.reset(new SmartListModel(this, listModeltype_, lrcInstance_));
@@ -63,7 +75,7 @@ ContactAdapter::getContactSelectableModel(int type)
lrcInstance_->get_selectedConvUid());
if (!conv.participants.isEmpty()) {
QString calleeDisplayId = lrcInstance_
->getAccountInfo(lrcInstance_->getCurrentAccountId())
->getAccountInfo(lrcInstance_->get_currentAccountId())
.contactModel->bestIdForContact(conv.participants[0]);
QRegExp matchExcept = QRegExp(QString("\\b(?!" + calleeDisplayId + "\\b)\\w+"));
@@ -171,7 +183,7 @@ ContactAdapter::contactSelected(int index)
return;
}
lrcInstance_->accountModel().setDefaultModerator(lrcInstance_->getCurrentAccountId(),
lrcInstance_->accountModel().setDefaultModerator(lrcInstance_->get_currentAccountId(),
contactUri,
true);
Q_EMIT defaultModeratorsUpdated();

View File

@@ -84,15 +84,17 @@ public:
explicit ContactAdapter(LRCInstance* instance, QObject* parent = nullptr);
~ContactAdapter() = default;
protected:
using Role = ConversationList::Role;
void safeInit() override {};
void safeInit() override;
Q_INVOKABLE QVariant getContactSelectableModel(int type);
Q_INVOKABLE void setSearchFilter(const QString& filter);
Q_INVOKABLE void contactSelected(int index);
Q_SIGNALS:
void bannedStatusChanged(const QString& uri, bool banned);
private:
SmartListModel::Type listModeltype_;
QScopedPointer<SmartListModel> smartListModel_;

View File

@@ -35,7 +35,7 @@ public:
explicit ConversationListModel(LRCInstance* instance, QObject* parent = nullptr);
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
virtual QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
};
// The top level filtered and sorted model to be consumed by QML ListViews

View File

@@ -82,16 +82,6 @@ ConversationsAdapter::ConversationsAdapter(SystemTray* systemTray,
Q_EMIT convSrcModel_->dataChanged(index, index);
});
connect(lrcInstance_, &LRCInstance::contactBanned, [this](const QString& uri) {
auto& convInfo = lrcInstance_->getConversationFromPeerUri(uri);
if (convInfo.uid.isEmpty())
return;
auto row = lrcInstance_->indexOf(convInfo.uid);
const auto index = convSrcModel_->index(row, 0);
Q_EMIT convSrcModel_->dataChanged(index, index);
lrcInstance_->set_selectedConvUid();
});
#ifdef Q_OS_LINUX
// notification responses
connect(systemTray_,
@@ -174,7 +164,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId,
const interaction::Info& interaction)
{
if (!interaction.authorUri.isEmpty()
&& (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrentAccountId()
&& (!QApplication::focusWindow() || accountId != lrcInstance_->get_currentAccountId()
|| convUid != lrcInstance_->get_selectedConvUid())) {
auto& accountInfo = lrcInstance_->getAccountInfo(accountId);
auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri);
@@ -224,7 +214,7 @@ void
ConversationsAdapter::onNewTrustRequest(const QString& accountId, const QString& convId, const QString& peerUri)
{
#ifdef Q_OS_LINUX
if (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrentAccountId()) {
if (!QApplication::focusWindow() || accountId != lrcInstance_->get_currentAccountId()) {
auto conv = convId;
if (conv.isEmpty()) {
auto& convInfo = lrcInstance_->getConversationFromPeerUri(peerUri);
@@ -327,6 +317,19 @@ ConversationsAdapter::updateConversation(const QString& convId)
lrcInstance_->selectConversation(convId);
}
void
ConversationsAdapter::onBannedStatusChanged(const QString& uri, bool banned)
{
Q_UNUSED(banned)
auto& convInfo = lrcInstance_->getConversationFromPeerUri(uri);
if (convInfo.uid.isEmpty())
return;
auto row = lrcInstance_->indexOf(convInfo.uid);
const auto index = convSrcModel_->index(row, 0);
Q_EMIT convSrcModel_->dataChanged(index, index);
lrcInstance_->set_selectedConvUid();
}
void
ConversationsAdapter::updateConversationFilterData()
{
@@ -461,6 +464,12 @@ ConversationsAdapter::connectConversationModel()
&ConversationsAdapter::updateConversation,
Qt::UniqueConnection);
QObject::connect(lrcInstance_->getCurrentContactModel(),
&ContactModel::bannedStatusChanged,
this,
&ConversationsAdapter::onBannedStatusChanged,
Qt::UniqueConnection);
convSrcModel_.reset(new ConversationListModel(lrcInstance_));
convModel_->bindSourceModel(convSrcModel_.get());
searchSrcModel_.reset(new SearchResultsListModel(lrcInstance_));

View File

@@ -82,6 +82,7 @@ private Q_SLOTS:
void onSearchStatusChanged(const QString&);
void onSearchResultUpdated();
void updateConversation(const QString&);
void onBannedStatusChanged(const QString&, bool);
void updateConversationFilterData();

View File

@@ -38,6 +38,21 @@ LRCInstance::LRCInstance(migrateCallback willMigrateCb,
, updateManager_(std::make_unique<UpdateManager>(updateUrl, connectivityMonitor, this))
{
lrc_->holdConferences = false;
connect(this, &LRCInstance::currentAccountIdChanged, [this] {
// save to config, editing the accountlistmodel's underlying data
accountModel().setTopAccount(currentAccountId_);
Q_EMIT accountListChanged();
// update type
set_currentAccountType(getCurrentAccountInfo().profileInfo.type);
});
// set the current account if any
auto accountList = accountModel().getAccountList();
if (accountList.size()) {
set_currentAccountId(accountList.at(0));
}
};
VectorString
@@ -109,20 +124,7 @@ LRCInstance::getAccountInfo(const QString& accountId)
const account::Info&
LRCInstance::getCurrentAccountInfo()
{
return getAccountInfo(getCurrentAccountId());
}
profile::Type
LRCInstance::getCurrentAccountType()
{
if (currentAccountType_ == profile::Type::INVALID) {
try {
currentAccountType_ = getCurrentAccountInfo().profileInfo.type;
} catch (...) {
qDebug() << "Cannot find current account info";
}
}
return currentAccountType_;
return getAccountInfo(get_currentAccountId());
}
bool
@@ -194,7 +196,7 @@ const conversation::Info&
LRCInstance::getConversationFromConvUid(const QString& convUid, const QString& accountId)
{
auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId
: getCurrentAccountId());
: get_currentAccountId());
auto& convModel = accInfo.conversationModel;
return convModel->getConversationForUid(convUid).value_or(invalid);
}
@@ -203,7 +205,7 @@ const conversation::Info&
LRCInstance::getConversationFromPeerUri(const QString& peerUri, const QString& accountId)
{
auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId
: getCurrentAccountId());
: get_currentAccountId());
auto& convModel = accInfo.conversationModel;
return convModel->getConversationForPeerUri(peerUri).value_or(invalid);
}
@@ -212,7 +214,7 @@ const conversation::Info&
LRCInstance::getConversationFromCallId(const QString& callId, const QString& accountId)
{
auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId
: getCurrentAccountId());
: get_currentAccountId());
auto& convModel = accInfo.conversationModel;
return convModel->getConversationForCallId(callId).value_or(invalid);
}
@@ -250,43 +252,11 @@ LRCInstance::getCurrentContactModel()
}
}
const QString&
LRCInstance::getCurrentAccountId()
{
if (currentAccountId_.isEmpty()) {
auto accountList = accountModel().getAccountList();
if (accountList.size())
currentAccountId_ = accountList.at(0);
}
return currentAccountId_;
}
void
LRCInstance::setCurrentAccountId(const QString& accountId)
{
if (accountId == currentAccountId_)
return; // No need to select current selected account
auto newAccountType = getAccountInfo(accountId).profileInfo.type;
bool accountTypeChanged = getCurrentAccountType() != newAccountType;
currentAccountId_ = accountId;
// Last selected account should be set as preferred.
accountModel().setTopAccount(accountId);
if (accountTypeChanged) {
currentAccountType_ = newAccountType;
Q_EMIT currentAccountTypeChanged(newAccountType);
}
Q_EMIT currentAccountIdChanged(accountId);
}
int
LRCInstance::getCurrentAccountIndex()
{
for (int i = 0; i < accountModel().getAccountList().size(); i++) {
if (accountModel().getAccountList()[i] == getCurrentAccountId()) {
if (accountModel().getAccountList()[i] == get_currentAccountId()) {
return i;
}
}
@@ -312,19 +282,19 @@ LRCInstance::setCurrAccAvatar(const QPixmap& avatarPixmap)
bu.open(QIODevice::WriteOnly);
avatarPixmap.save(&bu, "PNG");
auto str = QString::fromLocal8Bit(ba.toBase64());
accountModel().setAvatar(getCurrentAccountId(), str);
accountModel().setAvatar(get_currentAccountId(), str);
}
void
LRCInstance::setCurrAccAvatar(const QString& avatar)
{
accountModel().setAvatar(getCurrentAccountId(), avatar);
accountModel().setAvatar(get_currentAccountId(), avatar);
}
void
LRCInstance::setCurrAccDisplayName(const QString& displayName)
{
auto accountId = getCurrentAccountId();
auto accountId = get_currentAccountId();
accountModel().setAlias(accountId, displayName);
/*
* Force save to .yml.
@@ -423,11 +393,11 @@ LRCInstance::selectConversation(const QString& convId, const QString& accountId)
}
// if the account is not currently selected, do that first, then
// proceed to select the conversation
if (!accountId.isEmpty() && accountId != getCurrentAccountId()) {
if (!accountId.isEmpty() && accountId != get_currentAccountId()) {
Utils::oneShotConnect(this, &LRCInstance::currentAccountIdChanged, [this, convId] {
set_selectedConvUid(convId);
});
setCurrentAccountId(accountId);
set_currentAccountId(accountId);
return;
}
set_selectedConvUid(convId);

View File

@@ -55,10 +55,8 @@ class LRCInstance : public QObject
{
Q_OBJECT
QML_PROPERTY(QString, selectedConvUid)
Q_PROPERTY(lrc::api::profile::Type currentAccountType READ getCurrentAccountType NOTIFY
currentAccountTypeChanged)
Q_PROPERTY(QString currentAccountId READ getCurrentAccountId WRITE setCurrentAccountId NOTIFY
currentAccountIdChanged)
QML_PROPERTY(QString, currentAccountId)
QML_RO_PROPERTY(lrc::api::profile::Type, currentAccountType)
public:
explicit LRCInstance(migrateCallback willMigrateCb = {},
@@ -88,7 +86,6 @@ public:
const account::Info& getAccountInfo(const QString& accountId);
const account::Info& getCurrentAccountInfo();
profile::Type getCurrentAccountType();
QString getCallIdForConversationUid(const QString& convUid, const QString& accountId);
const call::Info* getCallInfo(const QString& callId, const QString& accountId);
const call::Info* getCallInfoForConversation(const conversation::Info& convInfo,
@@ -109,8 +106,6 @@ public:
const QString& accountId,
const QString& content);
const QString& getCurrentAccountId();
void setCurrentAccountId(const QString& accountId = {});
int getCurrentAccountIndex();
void setAvatarForAccount(const QPixmap& avatarPixmap, const QString& accountID);
void setCurrAccAvatar(const QPixmap& avatarPixmap);
@@ -134,17 +129,12 @@ Q_SIGNALS:
void quitEngineRequested();
void conversationUpdated(const QString& convId, const QString& accountId);
void draftSaved(const QString& convId);
void contactBanned(const QString& uri);
void currentAccountIdChanged(const QString& accountId);
void currentAccountTypeChanged(profile::Type type);
private:
std::unique_ptr<Lrc> lrc_;
std::unique_ptr<RenderManager> renderer_;
std::unique_ptr<UpdateManager> updateManager_;
QString currentAccountId_ {};
profile::Type currentAccountType_ = profile::Type::INVALID;
MapStringString contentDrafts_;
MapStringString lastConferences_;

View File

@@ -46,7 +46,7 @@ Label {
Connections {
target: LRCInstance
function onCurrentAccountIdChanged() {
function onAccountListChanged() {
root.update()
resetAccountListModel(LRCInstance.currentAccountId)
}

View File

@@ -61,9 +61,7 @@ Popup {
width: root.width
onClicked: {
root.close()
var sourceRow = CurrentAccountFilterModel.mapToSource(
CurrentAccountFilterModel.index(index, 0)).row
AccountAdapter.changeAccount(sourceRow)
LRCInstance.currentAccountId = ID
}
}

View File

@@ -71,7 +71,7 @@ MessagesAdapter::setupChatView(const QString& convUid)
QString contactURI = convInfo.participants.at(0);
auto selectedAccountId = lrcInstance_->getCurrentAccountId();
auto selectedAccountId = lrcInstance_->get_currentAccountId();
auto& accountInfo = lrcInstance_->accountModel().getAccountInfo(selectedAccountId);
QMetaObject::invokeMethod(qmlObj_,
@@ -102,7 +102,7 @@ MessagesAdapter::onNewInteraction(const QString& convUid,
const QString& interactionId,
const lrc::api::interaction::Info& interaction)
{
auto accountId = lrcInstance_->getCurrentAccountId();
auto accountId = lrcInstance_->get_currentAccountId();
newInteraction(accountId, convUid, interactionId, interaction);
}
@@ -270,7 +270,7 @@ MessagesAdapter::copyToDownloads(const QString& interactionId, const QString& di
{
auto downloadDir = lrcInstance_->accountModel().downloadDirectory;
if (auto accInfo = &lrcInstance_->getCurrentAccountInfo())
accInfo->dataTransferModel->copyTo(lrcInstance_->getCurrentAccountId(),
accInfo->dataTransferModel->copyTo(lrcInstance_->get_currentAccountId(),
lrcInstance_->get_selectedConvUid(),
interactionId,
downloadDir,
@@ -627,7 +627,6 @@ MessagesAdapter::blockConversation(const QString& convUid)
const auto currentConvUid = convUid.isEmpty() ? lrcInstance_->get_selectedConvUid() : convUid;
lrcInstance_->getCurrentConversationModel()->removeConversation(currentConvUid, true);
setInvitation(false);
Q_EMIT contactBanned();
}
void

View File

@@ -94,7 +94,6 @@ protected:
void contactIsComposing(const QString& contactUri, bool isComposing);
Q_SIGNALS:
void contactBanned();
void newInteraction(int type);
void newMessageBarPlaceholderText(QString placeholderText);
void newFilePasted(QString filePath);

View File

@@ -52,7 +52,7 @@ ModeratorListModel::data(const QModelIndex& index, int role) const
{
try {
QStringList list = lrcInstance_->accountModel().getDefaultModerators(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
if (!index.isValid() || list.size() <= index.row()) {
return QVariant();
}

View File

@@ -24,9 +24,7 @@
#include <QObject>
#define QML_PROPERTY(type, prop) \
private: \
Q_PROPERTY(type prop MEMBER prop##_ NOTIFY prop##Changed); \
#define PROPERTY_BASE(type, prop) \
type prop##_ {}; \
\
public: \
@@ -43,6 +41,16 @@ public: \
} \
}
#define QML_RO_PROPERTY(type, prop) \
private: \
Q_PROPERTY(type prop READ get_##prop NOTIFY prop##Changed); \
PROPERTY_BASE(type, prop)
#define QML_PROPERTY(type, prop) \
private: \
Q_PROPERTY(type prop MEMBER prop##_ NOTIFY prop##Changed); \
PROPERTY_BASE(type, prop)
namespace Utils {
template<typename Func1, typename Func2>

View File

@@ -256,7 +256,7 @@ SettingsAdapter::getCurrentAccount_Profile_Info_Type()
QString
SettingsAdapter::getAccountBestName()
{
return lrcInstance_->accountModel().bestNameForAccount(lrcInstance_->getCurrentAccountId());
return lrcInstance_->accountModel().bestNameForAccount(lrcInstance_->get_currentAccountId());
}
lrc::api::account::ConfProperties_t
@@ -264,7 +264,7 @@ SettingsAdapter::getAccountConfig()
{
lrc::api::account::ConfProperties_t res;
try {
res = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrentAccountId());
res = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->get_currentAccountId());
} catch (...) {
}
return res;
@@ -563,7 +563,7 @@ SettingsAdapter::setAccountConfig_Username(QString input)
{
auto confProps = getAccountConfig();
confProps.username = input;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
@@ -571,7 +571,7 @@ SettingsAdapter::setAccountConfig_Hostname(QString input)
{
auto confProps = getAccountConfig();
confProps.hostname = input;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
@@ -579,7 +579,7 @@ SettingsAdapter::setAccountConfig_Password(QString input)
{
auto confProps = getAccountConfig();
confProps.password = input;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
@@ -587,366 +587,366 @@ SettingsAdapter::setAccountConfig_RouteSet(QString input)
{
auto confProps = getAccountConfig();
confProps.routeset = input;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setAutoConnectOnLocalNetwork(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.peerDiscovery = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setCallsUntrusted(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.DHT.PublicInCalls = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setIsRendezVous(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.isRendezVous = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setAutoAnswerCalls(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.autoAnswer = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setEnableRingtone(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Ringtone.ringtoneEnabled = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setEnableProxy(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.proxyEnabled = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setKeepAliveEnabled(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.keepAliveEnabled = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseUPnP(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.upnpEnabled = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseTURN(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TURN.enable = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseSTUN(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.STUN.enable = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setVideoState(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Video.videoEnabled = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseSRTP(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.SRTP.enable = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseSDES(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.SRTP.keyExchange = state ? lrc::api::account::KeyExchangeProtocol::SDES
: lrc::api::account::KeyExchangeProtocol::NONE;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseRTPFallback(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.SRTP.rtpFallback = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseTLS(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.enable = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setVerifyCertificatesServer(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.verifyServer = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setVerifyCertificatesClient(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.verifyClient = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setRequireCertificatesIncomingTLS(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.requireClientCertificate = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setUseCustomAddressAndPort(bool state)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.publishedSameAsLocal = state;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setNameServer(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.RingNS.uri = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setProxyAddress(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.proxyServer = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setBootstrapAddress(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.hostname = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setTURNAddress(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TURN.server = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setTURNUsername(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TURN.username = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setTURNPassword(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TURN.password = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setTURNRealm(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TURN.realm = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::setSTUNAddress(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.STUN.server = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::lineEditVoiceMailDialCodeEditFinished(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.mailbox = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::outgoingTLSServerNameLineEditTextChanged(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.serverName = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::lineEditSIPCertPasswordLineEditTextChanged(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.password = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::lineEditSIPCustomAddressLineEditTextChanged(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.publishedAddress = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::customPortSIPSpinBoxValueChanged(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.publishedPort = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::negotiationTimeoutSpinBoxValueChanged(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.negotiationTimeoutSec = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::registrationExpirationTimeSpinBoxValueChanged(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Registration.expire = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.localPort = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::audioRTPMinPortSpinBoxEditFinished(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Audio.audioPortMin = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::audioRTPMaxPortSpinBoxEditFinished(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Audio.audioPortMax = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::videoRTPMinPortSpinBoxEditFinished(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Video.videoPortMin = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::videoRTPMaxPortSpinBoxEditFinished(int value)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Video.videoPortMax = value;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
if (static_cast<int>(confProps.TLS.method) != index) {
if (index == 0) {
@@ -958,7 +958,7 @@ SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index)
} else {
confProps.TLS.method = lrc::api::account::TlsMethod::TLSv1_2;
}
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(),
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(),
confProps);
}
}
@@ -967,9 +967,9 @@ void
SettingsAdapter::setDeviceName(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.deviceName = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
@@ -1030,36 +1030,36 @@ void
SettingsAdapter::set_RingtonePath(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.Ringtone.ringtonePath = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::set_FileCACert(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.certificateListFile = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::set_FileUserCert(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.certificateFile = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void
SettingsAdapter::set_FilePrivateKey(QString text)
{
auto confProps = lrcInstance_->accountModel().getAccountConfig(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
confProps.TLS.privateKeyFile = text;
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps);
lrcInstance_->accountModel().setAccountConfig(lrcInstance_->get_currentAccountId(), confProps);
}
void

View File

@@ -41,21 +41,17 @@ ColumnLayout {
}
Connections {
target: MessagesAdapter
target: ContactAdapter
function onContactBanned() {
bannedListWidget.model.reset()
root.visible = true
bannedContactsBtn.visible = true
bannedListWidget.visible = false
}
}
Connections {
target: AccountAdapter
function onContactUnbanned() {
updateAndShowBannedContactsSlot()
function onBannedStatusChanged(uri, banned) {
if (banned) {
bannedListWidget.model.reset()
root.visible = true
bannedContactsBtn.visible = true
bannedListWidget.visible = false
} else {
updateAndShowBannedContactsSlot()
}
}
}

View File

@@ -47,7 +47,7 @@ SmartListModel::rowCount(const QModelIndex& parent) const
{
if (!parent.isValid() && lrcInstance_) {
auto& accInfo = lrcInstance_->accountModel().getAccountInfo(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
auto& convModel = accInfo.conversationModel;
if (listModelType_ == Type::TRANSFER) {
return convModel->getFilteredConversations(accInfo.profileInfo.type).size();
@@ -77,7 +77,7 @@ SmartListModel::data(const QModelIndex& index, int role) const
case Type::TRANSFER: {
try {
auto& currentAccountInfo = lrcInstance_->accountModel().getAccountInfo(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
auto& convModel = currentAccountInfo.conversationModel;
auto& item = convModel->getFilteredConversations(currentAccountInfo.profileInfo.type)
@@ -144,7 +144,7 @@ SmartListModel::setConferenceableFilter(const QString& filter)
{
beginResetModel();
auto& accountInfo = lrcInstance_->accountModel().getAccountInfo(
lrcInstance_->getCurrentAccountId());
lrcInstance_->get_currentAccountId());
auto& convModel = accountInfo.conversationModel;
conferenceables_ = convModel->getConferenceableConversations(lrcInstance_->get_selectedConvUid(),
filter);

View File

@@ -337,7 +337,7 @@ Utils::contactPhoto(LRCInstance* instance,
* Get first contact photo.
*/
auto& accountInfo = instance->accountModel().getAccountInfo(
accountId.isEmpty() ? instance->getCurrentAccountId() : accountId);
accountId.isEmpty() ? instance->get_currentAccountId() : accountId);
auto contactInfo = accountInfo.contactModel->getContact(contactUri);
auto contactPhoto = contactInfo.profileInfo.avatar;
auto bestName = accountInfo.contactModel->bestNameForContact(contactUri);

View File

@@ -212,7 +212,7 @@ UtilsAdapter::getCallId(const QString& accountId, const QString& convUid)
int
UtilsAdapter::getCallStatus(const QString& callId)
{
const auto callStatus = lrcInstance_->getCallInfo(callId, lrcInstance_->getCurrentAccountId());
const auto callStatus = lrcInstance_->getCallInfo(callId, lrcInstance_->get_currentAccountId());
return static_cast<int>(callStatus->status);
}

View File

@@ -55,7 +55,7 @@ TEST_F(AccountFixture, CreateSIPAccountTest)
{
// AccountAdded signal spy
QSignalSpy accountAddedSpy(&globalEnv.lrcInstance->accountModel(),
&lrc::api::NewAccountModel::accountAdded);
&NewAccountModel::accountAdded);
// Create SIP Acc
globalEnv.accountAdapter->createSIPAccount(QVariantMap());
@@ -67,24 +67,24 @@ TEST_F(AccountFixture, CreateSIPAccountTest)
QVERIFY(accountAddedArguments.at(0).type() == QVariant::String);
// Select the created account
globalEnv.lrcInstance->setCurrentAccountId(accountAddedArguments.at(0).toString());
globalEnv.lrcInstance->set_currentAccountId(accountAddedArguments.at(0).toString());
auto accountListSize = globalEnv.lrcInstance->accountModel().getAccountList().size();
ASSERT_EQ(accountListSize, 1);
// Make sure the account setup is done
QSignalSpy accountStatusChangedSpy(&globalEnv.lrcInstance->accountModel(),
&lrc::api::NewAccountModel::accountStatusChanged);
&NewAccountModel::accountStatusChanged);
QVERIFY(accountStatusChangedSpy.wait());
QCOMPARE(accountStatusChangedSpy.count(), 1);
// Remove the account
globalEnv.lrcInstance->accountModel().removeAccount(
globalEnv.lrcInstance->getCurrentAccountId());
globalEnv.lrcInstance->get_currentAccountId());
QSignalSpy accountRemovedSpy(&globalEnv.lrcInstance->accountModel(),
&lrc::api::NewAccountModel::accountRemoved);
&NewAccountModel::accountRemoved);
QVERIFY(accountRemovedSpy.wait());
QCOMPARE(accountRemovedSpy.count(), 1);

View File

@@ -55,7 +55,7 @@ TEST_F(ContactFixture, AddSIPContactTest)
QVERIFY(accountAddedArguments.at(0).type() == QVariant::String);
// Select the created account
globalEnv.lrcInstance->setCurrentAccountId(accountAddedArguments.at(0).toString());
globalEnv.lrcInstance->set_currentAccountId(accountAddedArguments.at(0).toString());
// Make sure the account setup is done
QSignalSpy accountStatusChangedSpy(&globalEnv.lrcInstance->accountModel(),
@@ -94,7 +94,7 @@ TEST_F(ContactFixture, AddSIPContactTest)
// Remove the account
globalEnv.lrcInstance->accountModel().removeAccount(
globalEnv.lrcInstance->getCurrentAccountId());
globalEnv.lrcInstance->get_currentAccountId());
QSignalSpy accountRemovedSpy(&globalEnv.lrcInstance->accountModel(),
&lrc::api::NewAccountModel::accountRemoved);