From 9d0f84d8be650d6f3fa4f1442214675640fa26fb Mon Sep 17 00:00:00 2001 From: Ming Rui Zhang <mingrui.zhang@savoirfairelinux.com> Date: Thu, 13 May 2021 17:47:23 -0400 Subject: [PATCH] accountadapter: move current account id and type properties to lrcinstance Change-Id: I609452e83edd55a909d0f30aa6cb0daa3687ff3c --- src/accountadapter.cpp | 31 +-- src/accountadapter.h | 14 -- src/accountlistmodel.h | 2 +- src/calladapter.cpp | 11 +- src/commoncomponents/PasswordDialog.qml | 4 +- src/commoncomponents/PhotoboothView.qml | 2 +- src/contactadapter.cpp | 7 +- src/conversationsadapter.cpp | 6 +- src/lrcinstance.cpp | 61 +++-- src/lrcinstance.h | 16 +- src/mainview/MainView.qml | 10 +- src/mainview/components/AccountComboBox.qml | 20 +- .../components/ConversationListView.qml | 6 +- .../components/ParticipantOverlay.qml | 2 +- .../components/PluginHandlerPicker.qml | 6 +- src/mainview/components/SidePanel.qml | 10 +- src/mainview/components/SidePanelTabBar.qml | 2 +- .../components/SmartListItemDelegate.qml | 2 +- src/mainview/components/VideoCallPage.qml | 2 +- src/mainview/components/WelcomePage.qml | 6 +- .../components/WelcomePageQrDialog.qml | 6 +- src/messagesadapter.cpp | 12 +- src/moderatorlistmodel.cpp | 2 +- src/settingsadapter.cpp | 238 +++++++++++------- .../components/AdvancedCallSettings.qml | 10 +- .../components/CurrentAccountSettings.qml | 4 +- .../components/LinkDeviceDialog.qml | 2 +- .../components/NameRegistrationDialog.qml | 2 +- src/smartlistmodel.cpp | 8 +- src/utils.cpp | 2 +- src/utilsadapter.cpp | 2 +- src/wizardview/WizardView.qml | 2 +- 32 files changed, 288 insertions(+), 222 deletions(-) diff --git a/src/accountadapter.cpp b/src/accountadapter.cpp index 8be5d784f..1e2fce8eb 100644 --- a/src/accountadapter.cpp +++ b/src/accountadapter.cpp @@ -45,13 +45,11 @@ void AccountAdapter::safeInit() { connect(lrcInstance_, - &LRCInstance::currentAccountChanged, + &LRCInstance::currentAccountIdChanged, this, &AccountAdapter::onCurrentAccountChanged); - auto accountId = lrcInstance_->getCurrAccId(); - setProperties(accountId); - connectAccount(accountId); + connectAccount(lrcInstance_->getCurrentAccountId()); } lrc::api::NewAccountModel* @@ -71,7 +69,7 @@ AccountAdapter::changeAccount(int row) { auto accountList = lrcInstance_->accountModel().getAccountList(); if (accountList.size() > row) { - lrcInstance_->setSelectedAccountId(accountList.at(row)); + lrcInstance_->setCurrentAccountId(accountList.at(row)); } } @@ -228,7 +226,7 @@ AccountAdapter::createJAMSAccount(const QVariantMap& settings) void AccountAdapter::deleteCurrentAccount() { - lrcInstance_->accountModel().removeAccount(lrcInstance_->getCurrAccId()); + lrcInstance_->accountModel().removeAccount(lrcInstance_->getCurrentAccountId()); Q_EMIT lrcInstance_->accountListChanged(); } @@ -297,24 +295,24 @@ AccountAdapter::setCurrAccAvatar(bool fromFile, const QString& source) void AccountAdapter::onCurrentAccountChanged() { - auto accountId = lrcInstance_->getCurrAccId(); - setProperties(accountId); - connectAccount(accountId); + connectAccount(lrcInstance_->getCurrentAccountId()); } bool AccountAdapter::hasPassword() { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); return confProps.archiveHasPassword; } void AccountAdapter::setArchiveHasPassword(bool isHavePassword) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.archiveHasPassword = isHavePassword; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } bool AccountAdapter::exportToFile(const QString& accountId, @@ -408,12 +406,3 @@ AccountAdapter::connectAccount(const QString& accountId) qWarning() << "Couldn't get account: " << accountId; } } - -void -AccountAdapter::setProperties(const QString& accountId) -{ - setProperty("currentAccountId", accountId); - auto accountType = lrcInstance_->getAccountInfo(accountId).profileInfo.type; - setProperty("currentAccountType", lrc::api::profile::to_string(accountType)); - Q_EMIT deviceModelChanged(); -} diff --git a/src/accountadapter.h b/src/accountadapter.h index d749133b2..1ea64d5fa 100644 --- a/src/accountadapter.h +++ b/src/accountadapter.h @@ -36,10 +36,6 @@ class AccountAdapter final : public QmlAdapterBase Q_PROPERTY(lrc::api::NewAccountModel* model READ getModel NOTIFY modelChanged) Q_PROPERTY(lrc::api::NewDeviceModel* deviceModel READ getDeviceModel NOTIFY deviceModelChanged) - Q_PROPERTY(QString currentAccountId MEMBER currentAccountId_ NOTIFY currentAccountIdChanged) - Q_PROPERTY(lrc::api::profile::Type currentAccountType MEMBER currentAccountType_ NOTIFY - currentAccountTypeChanged) - Q_PROPERTY(int accountListSize MEMBER accountListSize_ NOTIFY accountListSizeChanged) public: lrc::api::NewAccountModel* getModel(); @@ -48,9 +44,6 @@ public: Q_SIGNALS: void modelChanged(); void deviceModelChanged(); - void currentAccountIdChanged(); - void currentAccountTypeChanged(); - void accountListSizeChanged(); public: explicit AccountAdapter(AppSettingsManager* settingsManager, @@ -114,16 +107,9 @@ private Q_SLOTS: void onCurrentAccountChanged(); private: - QString currentAccountId_ {}; - lrc::api::profile::Type currentAccountType_ {}; - int accountListSize_ {}; - // Make account signal connections. void connectAccount(const QString& accountId); - // Make account signal connections. - void setProperties(const QString& accountId); - // Implement what to do when account creation fails. void connectFailure(); diff --git a/src/accountlistmodel.h b/src/accountlistmodel.h index eadd135e4..a7733ab2c 100644 --- a/src/accountlistmodel.h +++ b/src/accountlistmodel.h @@ -64,7 +64,7 @@ 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_->getCurrAccId(); + return accountID != lrcInstance_->getCurrentAccountId(); } protected: diff --git a/src/calladapter.cpp b/src/calladapter.cpp index 1be1bec54..b07246f6d 100644 --- a/src/calladapter.cpp +++ b/src/calladapter.cpp @@ -36,7 +36,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* , oneSecondTimer_(new QTimer(this)) , systemTray_(systemTray) { - accountId_ = lrcInstance_->getCurrAccId(); + accountId_ = lrcInstance_->getCurrentAccountId(); if (!accountId_.isEmpty()) connectCallModel(accountId_); @@ -50,7 +50,10 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* this, &CallAdapter::onShowCallView); - connect(lrcInstance_, &LRCInstance::currentAccountChanged, this, &CallAdapter::onAccountChanged); + connect(lrcInstance_, + &LRCInstance::currentAccountIdChanged, + this, + &CallAdapter::onAccountChanged); #ifdef Q_OS_LINUX // notification responses (gnu/linux currently) @@ -79,7 +82,7 @@ CallAdapter::CallAdapter(SystemTray* systemTray, LRCInstance* instance, QObject* void CallAdapter::onAccountChanged() { - accountId_ = lrcInstance_->getCurrAccId(); + accountId_ = lrcInstance_->getCurrentAccountId(); connectCallModel(accountId_); } @@ -197,7 +200,7 @@ CallAdapter::onShowIncomingCallView(const QString& accountId, const QString& con if (convInfo.uid.isEmpty()) { return; } - auto selectedAccountId = lrcInstance_->getCurrAccId(); + auto selectedAccountId = lrcInstance_->getCurrentAccountId(); auto* callModel = lrcInstance_->getCurrentCallModel(); // new call diff --git a/src/commoncomponents/PasswordDialog.qml b/src/commoncomponents/PasswordDialog.qml index 30bfffb41..3d0baa8d3 100644 --- a/src/commoncomponents/PasswordDialog.qml +++ b/src/commoncomponents/PasswordDialog.qml @@ -69,7 +69,7 @@ BaseDialog { var success = false if (path.length > 0) { success = AccountAdapter.exportToFile( - AccountAdapter.currentAccountId, + LRCInstance.currentAccountId, path, currentPasswordEdit.text) } @@ -80,7 +80,7 @@ BaseDialog { function savePasswordQML() { var success = false success = AccountAdapter.savePassword( - AccountAdapter.currentAccountId, + LRCInstance.currentAccountId, currentPasswordEdit.text, passwordEdit.text) if (success) { diff --git a/src/commoncomponents/PhotoboothView.qml b/src/commoncomponents/PhotoboothView.qml index 69b0b504a..5f0e35c59 100644 --- a/src/commoncomponents/PhotoboothView.qml +++ b/src/commoncomponents/PhotoboothView.qml @@ -66,7 +66,7 @@ ColumnLayout { } function setAvatarImage(mode = AvatarImage.Mode.FromAccount, - imageId = AccountAdapter.currentAccountId){ + imageId = LRCInstance.currentAccountId){ if (mode !== AvatarImage.Mode.FromBase64) avatarImg.enableAnimation = true else diff --git a/src/contactadapter.cpp b/src/contactadapter.cpp index b4b8a4392..fd8f6c4da 100644 --- a/src/contactadapter.cpp +++ b/src/contactadapter.cpp @@ -36,7 +36,7 @@ ContactAdapter::getContactSelectableModel(int type) if (listModeltype_ == SmartListModel::Type::CONVERSATION) { defaultModerators_ = lrcInstance_->accountModel().getDefaultModerators( - lrcInstance_->getCurrAccId()); + lrcInstance_->getCurrentAccountId()); smartListModel_.reset(new SmartListModel(this, listModeltype_, lrcInstance_)); smartListModel_->fillConversationsList(); } else { @@ -64,7 +64,8 @@ ContactAdapter::getContactSelectableModel(int type) const auto& conv = lrcInstance_->getConversationFromConvUid( lrcInstance_->get_selectedConvUid()); if (!conv.participants.isEmpty()) { - QString calleeDisplayId = lrcInstance_->getAccountInfo(lrcInstance_->getCurrAccId()) + QString calleeDisplayId = lrcInstance_ + ->getAccountInfo(lrcInstance_->getCurrentAccountId()) .contactModel->bestIdForContact(conv.participants[0]); QRegExp matchExcept = QRegExp(QString("\\b(?!" + calleeDisplayId + "\\b)\\w+")); @@ -172,7 +173,7 @@ ContactAdapter::contactSelected(int index) return; } - lrcInstance_->accountModel().setDefaultModerator(lrcInstance_->getCurrAccId(), + lrcInstance_->accountModel().setDefaultModerator(lrcInstance_->getCurrentAccountId(), contactUri, true); Q_EMIT defaultModeratorsUpdated(); diff --git a/src/conversationsadapter.cpp b/src/conversationsadapter.cpp index 1d1c7ed4f..ff20c2c2e 100644 --- a/src/conversationsadapter.cpp +++ b/src/conversationsadapter.cpp @@ -164,7 +164,7 @@ ConversationsAdapter::safeInit() Qt::UniqueConnection); connect(lrcInstance_, - &LRCInstance::currentAccountChanged, + &LRCInstance::currentAccountIdChanged, this, &ConversationsAdapter::onCurrentAccountIdChanged, Qt::UniqueConnection); @@ -198,7 +198,7 @@ ConversationsAdapter::onNewUnreadInteraction(const QString& accountId, const interaction::Info& interaction) { if (!interaction.authorUri.isEmpty() - && (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrAccId() + && (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrentAccountId() || convUid != lrcInstance_->get_selectedConvUid())) { auto& accountInfo = lrcInstance_->getAccountInfo(accountId); auto from = accountInfo.contactModel->bestNameForContact(interaction.authorUri); @@ -248,7 +248,7 @@ void ConversationsAdapter::onNewTrustRequest(const QString& accountId, const QString& peerUri) { #ifdef Q_OS_LINUX - if (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrAccId()) { + if (!QApplication::focusWindow() || accountId != lrcInstance_->getCurrentAccountId()) { auto& accInfo = lrcInstance_->getAccountInfo(accountId); auto from = accInfo.contactModel->bestNameForContact(peerUri); auto contactPhoto = Utils::contactPhoto(lrcInstance_, peerUri, QSize(50, 50), accountId); diff --git a/src/lrcinstance.cpp b/src/lrcinstance.cpp index d6c6fd5bf..582a0b32d 100644 --- a/src/lrcinstance.cpp +++ b/src/lrcinstance.cpp @@ -115,7 +115,20 @@ LRCInstance::getAccountInfo(const QString& accountId) const account::Info& LRCInstance::getCurrentAccountInfo() { - return getAccountInfo(getCurrAccId()); + 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_; } bool @@ -186,7 +199,8 @@ LRCInstance::getCallInfoForConversation(const conversation::Info& convInfo, bool const conversation::Info& LRCInstance::getConversationFromConvUid(const QString& convUid, const QString& accountId) { - auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId : getCurrAccId()); + auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId + : getCurrentAccountId()); auto& convModel = accInfo.conversationModel; return convModel->getConversationForUid(convUid).value_or(invalid); } @@ -194,7 +208,8 @@ LRCInstance::getConversationFromConvUid(const QString& convUid, const QString& a const conversation::Info& LRCInstance::getConversationFromPeerUri(const QString& peerUri, const QString& accountId) { - auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId : getCurrAccId()); + auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId + : getCurrentAccountId()); auto& convModel = accInfo.conversationModel; return convModel->getConversationForPeerUri(peerUri).value_or(invalid); } @@ -202,7 +217,8 @@ LRCInstance::getConversationFromPeerUri(const QString& peerUri, const QString& a const conversation::Info& LRCInstance::getConversationFromCallId(const QString& callId, const QString& accountId) { - auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId : getCurrAccId()); + auto& accInfo = accountModel().getAccountInfo(!accountId.isEmpty() ? accountId + : getCurrentAccountId()); auto& convModel = accInfo.conversationModel; return convModel->getConversationForCallId(callId).value_or(invalid); } @@ -241,35 +257,42 @@ LRCInstance::getCurrentContactModel() } const QString& -LRCInstance::getCurrAccId() +LRCInstance::getCurrentAccountId() { - if (selectedAccountId_.isEmpty()) { + if (currentAccountId_.isEmpty()) { auto accountList = accountModel().getAccountList(); if (accountList.size()) - selectedAccountId_ = accountList.at(0); + currentAccountId_ = accountList.at(0); } - return selectedAccountId_; + return currentAccountId_; } void -LRCInstance::setSelectedAccountId(const QString& accountId) +LRCInstance::setCurrentAccountId(const QString& accountId) { - if (accountId == selectedAccountId_) + if (accountId == currentAccountId_) return; // No need to select current selected account - selectedAccountId_ = accountId; + auto newAccountType = getAccountInfo(accountId).profileInfo.type; + bool accountTypeChanged = getCurrentAccountType() != newAccountType; + + currentAccountId_ = accountId; // Last selected account should be set as preferred. accountModel().setTopAccount(accountId); - Q_EMIT currentAccountChanged(); + 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] == getCurrAccId()) { + if (accountModel().getAccountList()[i] == getCurrentAccountId()) { return i; } } @@ -295,19 +318,19 @@ LRCInstance::setCurrAccAvatar(const QPixmap& avatarPixmap) bu.open(QIODevice::WriteOnly); avatarPixmap.save(&bu, "PNG"); auto str = QString::fromLocal8Bit(ba.toBase64()); - accountModel().setAvatar(getCurrAccId(), str); + accountModel().setAvatar(getCurrentAccountId(), str); } void LRCInstance::setCurrAccAvatar(const QString& avatar) { - accountModel().setAvatar(getCurrAccId(), avatar); + accountModel().setAvatar(getCurrentAccountId(), avatar); } void LRCInstance::setCurrAccDisplayName(const QString& displayName) { - auto accountId = getCurrAccId(); + auto accountId = getCurrentAccountId(); accountModel().setAlias(accountId, displayName); /* * Force save to .yml. @@ -413,11 +436,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 != getCurrAccId()) { - Utils::oneShotConnect(this, &LRCInstance::currentAccountChanged, [this, convId] { + if (!accountId.isEmpty() && accountId != getCurrentAccountId()) { + Utils::oneShotConnect(this, &LRCInstance::currentAccountIdChanged, [this, convId] { set_selectedConvUid(convId); }); - setSelectedAccountId(accountId); + setCurrentAccountId(accountId); return; } set_selectedConvUid(convId); diff --git a/src/lrcinstance.h b/src/lrcinstance.h index e4cbe6e77..9bb668e1b 100644 --- a/src/lrcinstance.h +++ b/src/lrcinstance.h @@ -55,6 +55,10 @@ 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) public: explicit LRCInstance(migrateCallback willMigrateCb = {}, @@ -85,6 +89,7 @@ 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, @@ -99,8 +104,8 @@ public: Q_INVOKABLE void selectConversation(const QString& convId, const QString& accountId = {}); Q_INVOKABLE void deselectConversation(); - const QString& getCurrAccId(); - void setSelectedAccountId(const QString& accountId = {}); + const QString& getCurrentAccountId(); + void setCurrentAccountId(const QString& accountId = {}); int getCurrentAccountIndex(); void setAvatarForAccount(const QPixmap& avatarPixmap, const QString& accountID); void setCurrAccAvatar(const QPixmap& avatarPixmap); @@ -122,19 +127,22 @@ public: Q_SIGNALS: void accountListChanged(); - void currentAccountChanged(); void restoreAppRequested(); void notificationClicked(); 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 selectedAccountId_ {}; + + QString currentAccountId_ {}; + profile::Type currentAccountType_ = profile::Type::INVALID; MapStringString contentDrafts_; MapStringString lastConferences_; diff --git a/src/mainview/MainView.qml b/src/mainview/MainView.qml index d4280cce3..3cae75648 100644 --- a/src/mainview/MainView.qml +++ b/src/mainview/MainView.qml @@ -57,7 +57,7 @@ Rectangle { signal loaderSourceChangeRequested(int sourceToLoad) - property string currentAccountId: AccountAdapter.currentAccountId + property string currentAccountId: LRCInstance.currentAccountId onCurrentAccountIdChanged: { if (inSettingsView) { settingsView.accountListChanged() @@ -115,7 +115,7 @@ Rectangle { } function currentAccountIsCalling() { - return UtilsAdapter.hasCall(AccountAdapter.currentAccountId) + return UtilsAdapter.hasCall(LRCInstance.currentAccountId) } // Only called onWidthChanged @@ -137,7 +137,7 @@ Rectangle { return if (checkCurrentCall && currentAccountIsCalling()) { var callConv = UtilsAdapter.getCallConvForAccount( - AccountAdapter.currentAccountId) + LRCInstance.currentAccountId) LRCInstance.selectConversation(callConv) CallAdapter.updateCall(callConv, currentAccountId) } else { @@ -187,13 +187,13 @@ Rectangle { } MessagesAdapter.setupChatView(convId) callStackView.setLinkedWebview(communicationPageMessageWebView) - callStackView.responsibleAccountId = AccountAdapter.currentAccountId + callStackView.responsibleAccountId = LRCInstance.currentAccountId callStackView.responsibleConvUid = convId currentConvUID = convId if (item.callState === Call.Status.IN_PROGRESS || item.callState === Call.Status.PAUSED) { - CallAdapter.updateCall(convId, AccountAdapter.currentAccountId) + CallAdapter.updateCall(convId, LRCInstance.currentAccountId) if (item.isAudioOnly) callStackView.showAudioCallPage() else diff --git a/src/mainview/components/AccountComboBox.qml b/src/mainview/components/AccountComboBox.qml index 7d5873820..28152bb7a 100644 --- a/src/mainview/components/AccountComboBox.qml +++ b/src/mainview/components/AccountComboBox.qml @@ -38,16 +38,20 @@ Label { Connections { target: AccountAdapter - function onCurrentAccountIdChanged() { - root.update() - resetAccountListModel(AccountAdapter.currentAccountId) - } - function onAccountStatusChanged(accountId) { resetAccountListModel(accountId) } } + Connections { + target: LRCInstance + + function onCurrentAccountIdChanged() { + root.update() + resetAccountListModel(LRCInstance.currentAccountId) + } + } + function resetAccountListModel(accountId) { AccountListModel.updateAvatarUid(accountId) AccountListModel.reset() @@ -108,7 +112,7 @@ Label { target: AccountListModel function onModelReset() { - avatar.updateImage(AccountAdapter.currentAccountId, + avatar.updateImage(LRCInstance.currentAccountId, AccountListModel.data(AccountListModel.index(0, 0), AccountList.PictureUid)) avatar.presenceStatus = AccountListModel.data(AccountListModel.index(0, 0), @@ -133,7 +137,7 @@ Label { Layout.preferredHeight: JamiTheme.accountListAvatarSize Layout.alignment: Qt.AlignVCenter - imageId: AccountAdapter.currentAccountId + imageId: LRCInstance.currentAccountId presenceStatus: AccountListModel.data(AccountListModel.index(0, 0), AccountList.Status) @@ -208,7 +212,7 @@ Label { height: visible ? preferredSize : 0 anchors.verticalCenter: parent.verticalCenter - visible: AccountAdapter.currentAccountType === Profile.Type.RING + visible: LRCInstance.currentAccountType === Profile.Type.RING toolTipText: JamiStrings.displayQRCode source: "qrc:/images/icons/share-24px.svg" diff --git a/src/mainview/components/ConversationListView.qml b/src/mainview/components/ConversationListView.qml index 48981cd50..19c8bb8c7 100644 --- a/src/mainview/components/ConversationListView.qml +++ b/src/mainview/components/ConversationListView.qml @@ -136,7 +136,7 @@ ListView { "contactType": model.dataForRow(row, ConversationList.ContactType), } - responsibleAccountId = AccountAdapter.currentAccountId + responsibleAccountId = LRCInstance.currentAccountId responsibleConvUid = item.convId contactType = item.contactType @@ -175,7 +175,7 @@ ListView { context: Qt.ApplicationShortcut enabled: root.visible onActivated: MessagesAdapter.clearConversationHistory( - AccountAdapter.currentAccountId, + LRCInstance.currentAccountId, UtilsAdapter.getCurrConvId()) } @@ -193,7 +193,7 @@ ListView { context: Qt.ApplicationShortcut enabled: root.visible onActivated: MessagesAdapter.removeConversation( - AccountAdapter.currentAccountId, + LRCInstance.currentAccountId, UtilsAdapter.getCurrConvId(), false) } diff --git a/src/mainview/components/ParticipantOverlay.qml b/src/mainview/components/ParticipantOverlay.qml index f800ba07a..cee174d77 100644 --- a/src/mainview/components/ParticipantOverlay.qml +++ b/src/mainview/components/ParticipantOverlay.qml @@ -58,7 +58,7 @@ Rectangle { contactImage.updateImage(avatar) } else if (local) { contactImage.mode = AvatarImage.Mode.FromAccount - contactImage.updateImage(AccountAdapter.currentAccountId) + contactImage.updateImage(LRCInstance.currentAccountId) } else if (isContact) { contactImage.mode = AvatarImage.Mode.FromContactUri contactImage.updateImage(uri) diff --git a/src/mainview/components/PluginHandlerPicker.qml b/src/mainview/components/PluginHandlerPicker.qml index 42234f3e0..84dc51643 100644 --- a/src/mainview/components/PluginHandlerPicker.qml +++ b/src/mainview/components/PluginHandlerPicker.qml @@ -65,7 +65,7 @@ Popup { pluginhandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId) } else { // Reset the model on each show. - var accountId = AccountAdapter.currentAccountId + var accountId = LRCInstance.currentAccountId var peerId = UtilsAdapter.getPeerUri(accountId, UtilsAdapter.getCurrConvId()) pluginhandlerPickerListView.model = PluginAdapter.getChatHandlerSelectableModel(accountId, peerId) } @@ -79,7 +79,7 @@ Popup { PluginModel.toggleCallMediaHandler(handlerId, callId, !isLoaded) pluginhandlerPickerListView.model = PluginAdapter.getMediaHandlerSelectableModel(callId) } else { - var accountId = AccountAdapter.currentAccountId + var accountId = LRCInstance.currentAccountId var peerId = UtilsAdapter.getPeerUri(accountId, UtilsAdapter.getCurrConvId()) PluginModel.toggleChatHandler(handlerId, accountId, peerId, !isLoaded) pluginhandlerPickerListView.model = PluginAdapter.getChatHandlerSelectableModel(accountId, peerId) @@ -138,7 +138,7 @@ Popup { callStackViewWindow.responsibleConvUid) return PluginAdapter.getMediaHandlerSelectableModel(callId) } else { - var accountId = AccountAdapter.currentAccountId + var accountId = LRCInstance.currentAccountId var peerId = UtilsAdapter.getPeerUri(accountId, UtilsAdapter.getCurrConvId()) return PluginAdapter.getChatHandlerSelectableModel(accountId, peerId) } diff --git a/src/mainview/components/SidePanel.qml b/src/mainview/components/SidePanel.qml index d86ba5cb3..6e7bdf1e2 100644 --- a/src/mainview/components/SidePanel.qml +++ b/src/mainview/components/SidePanel.qml @@ -38,13 +38,17 @@ Rectangle { Connections { target: AccountAdapter - function onCurrentAccountIdChanged() { + function onSelectedContactAdded(convId) { clearContactSearchBar() + LRCInstance.selectConversation(convId) } + } - function onSelectedContactAdded(convId) { + Connections { + target: LRCInstance + + function onCurrentAccountIdChanged() { clearContactSearchBar() - LRCInstance.selectConversation(convId) } } diff --git a/src/mainview/components/SidePanelTabBar.qml b/src/mainview/components/SidePanelTabBar.qml index 04cd82dde..a7f9abd5b 100644 --- a/src/mainview/components/SidePanelTabBar.qml +++ b/src/mainview/components/SidePanelTabBar.qml @@ -43,7 +43,7 @@ TabBar { function selectTab(tabIndex) { ConversationsAdapter.currentTypeFilter = (tabIndex === SidePanelTabBar.Conversations) ? - AccountAdapter.currentAccountType : + LRCInstance.currentAccountType : Profile.Type.PENDING } diff --git a/src/mainview/components/SmartListItemDelegate.qml b/src/mainview/components/SmartListItemDelegate.qml index fcabcf499..02f449d29 100644 --- a/src/mainview/components/SmartListItemDelegate.qml +++ b/src/mainview/components/SmartListItemDelegate.qml @@ -166,7 +166,7 @@ ItemDelegate { onClicked: ListView.view.model.select(index) onDoubleClicked: { ListView.view.model.select(index) - if (AccountAdapter.currentAccountType === Profile.Type.SIP) + if (LRCInstance.currentAccountType === Profile.Type.SIP) CallAdapter.placeAudioOnlyCall() else CallAdapter.placeCall() diff --git a/src/mainview/components/VideoCallPage.qml b/src/mainview/components/VideoCallPage.qml index ccd88266a..3221cb9a9 100644 --- a/src/mainview/components/VideoCallPage.qml +++ b/src/mainview/components/VideoCallPage.qml @@ -79,7 +79,7 @@ Rectangle { function handleParticipantsInfo(infos) { if (infos.length === 0) { - bestName = UtilsAdapter.getBestName(AccountAdapter.currentAccountId, + bestName = UtilsAdapter.getBestName(LRCInstance.currentAccountId, UtilsAdapter.getCurrConvId()) } else { bestName = "" diff --git a/src/mainview/components/WelcomePage.qml b/src/mainview/components/WelcomePage.qml index 6fd63d404..279b9dbc8 100644 --- a/src/mainview/components/WelcomePage.qml +++ b/src/mainview/components/WelcomePage.qml @@ -91,7 +91,7 @@ Rectangle { horizontalAlignment: Text.AlignHCenter verticalAlignment: Text.AlignVCenter - visible: AccountAdapter.currentAccountType === Profile.Type.RING + visible: LRCInstance.currentAccountType === Profile.Type.RING text: JamiStrings.shareInvite color: JamiTheme.faddedFontColor @@ -106,7 +106,7 @@ Rectangle { color: JamiTheme.secondaryBackgroundColor - visible: AccountAdapter.currentAccountType === Profile.Type.RING + visible: LRCInstance.currentAccountType === Profile.Type.RING ColumnLayout { id: jamiRegisteredNameRectColumnLayout @@ -128,7 +128,7 @@ Rectangle { TextMetrics { id: textMetricsjamiRegisteredNameText font: jamiRegisteredNameText.font - text: UtilsAdapter.getBestId(AccountAdapter.currentAccountId) + text: UtilsAdapter.getBestId(LRCInstance.currentAccountId) elideWidth: welcomePageColumnLayout.width elide: Qt.ElideMiddle } diff --git a/src/mainview/components/WelcomePageQrDialog.qml b/src/mainview/components/WelcomePageQrDialog.qml index 00be782d4..d21fb7282 100644 --- a/src/mainview/components/WelcomePageQrDialog.qml +++ b/src/mainview/components/WelcomePageQrDialog.qml @@ -49,9 +49,9 @@ ModalPopup { fillMode: Image.PreserveAspectFit source: { - if (AccountAdapter.currentAccountId && - AccountAdapter.currentAccountType === Profile.Type.RING) - return "image://qrImage/account_" + AccountAdapter.currentAccountId + if (LRCInstance.currentAccountId && + LRCInstance.currentAccountType === Profile.Type.RING) + return "image://qrImage/account_" + LRCInstance.currentAccountId return "" } } diff --git a/src/messagesadapter.cpp b/src/messagesadapter.cpp index ecc4a90b2..aac5089ed 100644 --- a/src/messagesadapter.cpp +++ b/src/messagesadapter.cpp @@ -48,7 +48,7 @@ MessagesAdapter::MessagesAdapter(AppSettingsManager* settingsManager, void MessagesAdapter::safeInit() { - connect(lrcInstance_, &LRCInstance::currentAccountChanged, [this]() { + connect(lrcInstance_, &LRCInstance::currentAccountIdChanged, [this]() { currentConvUid_.clear(); connectConversationModel(); }); @@ -73,7 +73,7 @@ MessagesAdapter::setupChatView(const QString& convUid) QString contactURI = convInfo.participants.at(0); - auto selectedAccountId = lrcInstance_->getCurrAccId(); + auto selectedAccountId = lrcInstance_->getCurrentAccountId(); auto& accountInfo = lrcInstance_->accountModel().getAccountInfo(selectedAccountId); lrc::api::contact::Info contactInfo; @@ -131,7 +131,7 @@ MessagesAdapter::connectConversationModel() [this](const QString& convUid, uint64_t interactionId, const lrc::api::interaction::Info& interaction) { - auto accountId = lrcInstance_->getCurrAccId(); + auto accountId = lrcInstance_->getCurrentAccountId(); newInteraction(accountId, convUid, interactionId, interaction); }); @@ -180,7 +180,7 @@ void MessagesAdapter::slotSendMessageContentSaved(const QString& content) { if (!LastConvUid_.isEmpty()) { - lrcInstance_->setContentDraft(LastConvUid_, lrcInstance_->getCurrAccId(), content); + lrcInstance_->setContentDraft(LastConvUid_, lrcInstance_->getCurrentAccountId(), content); } LastConvUid_ = lrcInstance_->get_selectedConvUid(); @@ -189,7 +189,7 @@ MessagesAdapter::slotSendMessageContentSaved(const QString& content) setInvitation(false); clear(); auto restoredContent = lrcInstance_->getContentDraft(lrcInstance_->get_selectedConvUid(), - lrcInstance_->getCurrAccId()); + lrcInstance_->getCurrentAccountId()); setSendMessageContent(restoredContent); } @@ -197,7 +197,7 @@ void MessagesAdapter::slotUpdateDraft(const QString& content) { if (!LastConvUid_.isEmpty()) { - lrcInstance_->setContentDraft(LastConvUid_, lrcInstance_->getCurrAccId(), content); + lrcInstance_->setContentDraft(LastConvUid_, lrcInstance_->getCurrentAccountId(), content); } } diff --git a/src/moderatorlistmodel.cpp b/src/moderatorlistmodel.cpp index f64ecf927..182b2f3d3 100644 --- a/src/moderatorlistmodel.cpp +++ b/src/moderatorlistmodel.cpp @@ -52,7 +52,7 @@ ModeratorListModel::data(const QModelIndex& index, int role) const { try { QStringList list = lrcInstance_->accountModel().getDefaultModerators( - lrcInstance_->getCurrAccId()); + lrcInstance_->getCurrentAccountId()); if (!index.isValid() || list.size() <= index.row()) { return QVariant(); } diff --git a/src/settingsadapter.cpp b/src/settingsadapter.cpp index 8f770c31d..5e514bc9b 100644 --- a/src/settingsadapter.cpp +++ b/src/settingsadapter.cpp @@ -257,7 +257,7 @@ SettingsAdapter::getCurrentAccount_Profile_Info_Type() QString SettingsAdapter::getAccountBestName() { - return lrcInstance_->accountModel().bestNameForAccount(lrcInstance_->getCurrAccId()); + return lrcInstance_->accountModel().bestNameForAccount(lrcInstance_->getCurrentAccountId()); } lrc::api::account::ConfProperties_t @@ -265,7 +265,7 @@ SettingsAdapter::getAccountConfig() { lrc::api::account::ConfProperties_t res; try { - res = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + res = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrentAccountId()); } catch (...) { } return res; @@ -564,7 +564,7 @@ SettingsAdapter::setAccountConfig_Username(QString input) { auto confProps = getAccountConfig(); confProps.username = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void @@ -572,7 +572,7 @@ SettingsAdapter::setAccountConfig_Hostname(QString input) { auto confProps = getAccountConfig(); confProps.hostname = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void @@ -580,7 +580,7 @@ SettingsAdapter::setAccountConfig_Password(QString input) { auto confProps = getAccountConfig(); confProps.password = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void @@ -588,326 +588,366 @@ SettingsAdapter::setAccountConfig_RouteSet(QString input) { auto confProps = getAccountConfig(); confProps.routeset = input; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setAutoConnectOnLocalNetwork(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.peerDiscovery = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setCallsUntrusted(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.DHT.PublicInCalls = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setIsRendezVous(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.isRendezVous = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setAutoAnswerCalls(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.autoAnswer = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setEnableRingtone(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Ringtone.ringtoneEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setEnableProxy(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.proxyEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setKeepAliveEnabled(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.keepAliveEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseUPnP(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.upnpEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseTURN(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TURN.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseSTUN(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.STUN.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setVideoState(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Video.videoEnabled = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseSRTP(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.SRTP.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseSDES(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.SRTP.keyExchange = state ? lrc::api::account::KeyExchangeProtocol::SDES : lrc::api::account::KeyExchangeProtocol::NONE; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseRTPFallback(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.SRTP.rtpFallback = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseTLS(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.enable = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setVerifyCertificatesServer(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.verifyServer = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setVerifyCertificatesClient(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.verifyClient = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setRequireCertificatesIncomingTLS(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.requireClientCertificate = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setUseCustomAddressAndPort(bool state) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.publishedSameAsLocal = state; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setNameServer(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.RingNS.uri = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setProxyAddress(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.proxyServer = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setBootstrapAddress(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.hostname = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setTURNAddress(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TURN.server = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setTURNUsername(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TURN.username = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setTURNPassword(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TURN.password = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setTURNRealm(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TURN.realm = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::setSTUNAddress(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.STUN.server = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::lineEditVoiceMailDialCodeEditFinished(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.mailbox = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::outgoingTLSServerNameLineEditTextChanged(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.serverName = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::lineEditSIPCertPasswordLineEditTextChanged(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.password = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::lineEditSIPCustomAddressLineEditTextChanged(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.publishedAddress = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::customPortSIPSpinBoxValueChanged(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.publishedPort = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::negotiationTimeoutSpinBoxValueChanged(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.negotiationTimeoutSec = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::registrationTimeoutSpinBoxValueChanged(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Registration.expire = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::networkInterfaceSpinBoxValueChanged(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.localPort = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::audioRTPMinPortSpinBoxEditFinished(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Audio.audioPortMin = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::audioRTPMaxPortSpinBoxEditFinished(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Audio.audioPortMax = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::videoRTPMinPortSpinBoxEditFinished(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Video.videoPortMin = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::videoRTPMaxPortSpinBoxEditFinished(int value) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Video.videoPortMax = value; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); if (static_cast<int>(confProps.TLS.method) != index) { if (index == 0) { @@ -919,16 +959,18 @@ SettingsAdapter::tlsProtocolComboBoxIndexChanged(const int& index) } else { confProps.TLS.method = lrc::api::account::TlsMethod::TLSv1_2; } - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), + confProps); } } void SettingsAdapter::setDeviceName(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.deviceName = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void @@ -988,33 +1030,37 @@ SettingsAdapter::increaseVideoCodecPriority(unsigned int id) void SettingsAdapter::set_RingtonePath(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.Ringtone.ringtonePath = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::set_FileCACert(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.certificateListFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::set_FileUserCert(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.certificateFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void SettingsAdapter::set_FilePrivateKey(QString text) { - auto confProps = lrcInstance_->accountModel().getAccountConfig(lrcInstance_->getCurrAccId()); + auto confProps = lrcInstance_->accountModel().getAccountConfig( + lrcInstance_->getCurrentAccountId()); confProps.TLS.privateKeyFile = text; - lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrAccId(), confProps); + lrcInstance_->accountModel().setAccountConfig(lrcInstance_->getCurrentAccountId(), confProps); } void diff --git a/src/settingsview/components/AdvancedCallSettings.qml b/src/settingsview/components/AdvancedCallSettings.qml index 239421ff7..8ed53453f 100644 --- a/src/settingsview/components/AdvancedCallSettings.qml +++ b/src/settingsview/components/AdvancedCallSettings.qml @@ -43,7 +43,7 @@ ColumnLayout { checkBoxRdv.checked = SettingsAdapter.getAccountConfig_RendezVous() checkBoxAutoAnswer.checked = SettingsAdapter.getAccountConfig_AutoAnswer() checkBoxCustomRingtone.checked = SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled() - checkboxAllModerators.checked = SettingsAdapter.isAllModeratorsEnabled(AccountAdapter.currentAccountId) + checkboxAllModerators.checked = SettingsAdapter.isAllModeratorsEnabled(LRCInstance.currentAccountId) btnRingtone.setEnabled(SettingsAdapter.getAccountConfig_Ringtone_RingtoneEnabled()) btnRingtone.setText(UtilsAdapter.toFileInfoName(SettingsAdapter.getAccountConfig_Ringtone_RingtonePath())) @@ -61,7 +61,7 @@ ColumnLayout { function updateAndShowModeratorsSlot() { toggleLocalModerators.checked = SettingsAdapter.isLocalModeratorsEnabled( - AccountAdapter.currentAccountId) + LRCInstance.currentAccountId) moderatorListWidget.model.reset() moderatorListWidget.visible = (moderatorListWidget.model.rowCount() > 0) } @@ -170,7 +170,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: SettingsAdapter.enableLocalModerators( - AccountAdapter.currentAccountId, checked) + LRCInstance.currentAccountId, checked) } ElidedTextLabel { @@ -207,7 +207,7 @@ ColumnLayout { onClicked: moderatorListWidget.currentIndex = index onBtnContactClicked: { SettingsAdapter.setDefaultModerator( - AccountAdapter.currentAccountId, contactID, false) + LRCInstance.currentAccountId, contactID, false) updateAndShowModeratorsSlot() } } @@ -245,7 +245,7 @@ ColumnLayout { fontPointSize: JamiTheme.settingsFontSize onSwitchToggled: SettingsAdapter.setAllModeratorsEnabled( - AccountAdapter.currentAccountId, checked) + LRCInstance.currentAccountId, checked) } } } diff --git a/src/settingsview/components/CurrentAccountSettings.qml b/src/settingsview/components/CurrentAccountSettings.qml index 144efab6f..5e138e3b4 100644 --- a/src/settingsview/components/CurrentAccountSettings.qml +++ b/src/settingsview/components/CurrentAccountSettings.qml @@ -166,7 +166,7 @@ Rectangle { return } else { if (exportPath.length > 0) { - var isSuccessful = AccountAdapter.model.exportToFile(AccountAdapter.currentAccountId, + var isSuccessful = AccountAdapter.model.exportToFile(LRCInstance.currentAccountId, exportPath, "") var title = isSuccessful ? qsTr("Success") : qsTr("Error") var info = isSuccessful ? JamiStrings.backupSuccessful : JamiStrings.backupFailed @@ -195,7 +195,7 @@ Rectangle { fontPointSize: JamiTheme.headerFontSize onSwitchToggled: AccountAdapter.model.setAccountEnabled( - AccountAdapter.currentAccountId, checked) + LRCInstance.currentAccountId, checked) } AccountProfile { diff --git a/src/settingsview/components/LinkDeviceDialog.qml b/src/settingsview/components/LinkDeviceDialog.qml index 5cc354cf7..288d50aac 100644 --- a/src/settingsview/components/LinkDeviceDialog.qml +++ b/src/settingsview/components/LinkDeviceDialog.qml @@ -60,7 +60,7 @@ BaseDialog { interval: 200 onTriggered: { - AccountAdapter.model.exportOnRing(AccountAdapter.currentAccountId, + AccountAdapter.model.exportOnRing(LRCInstance.currentAccountId, passwordEdit.text) } } diff --git a/src/settingsview/components/NameRegistrationDialog.qml b/src/settingsview/components/NameRegistrationDialog.qml index 83768c58a..4f7a6b5e0 100644 --- a/src/settingsview/components/NameRegistrationDialog.qml +++ b/src/settingsview/components/NameRegistrationDialog.qml @@ -53,7 +53,7 @@ BaseDialog { function slotStartNameRegistration() { var password = passwordEdit.text - AccountAdapter.model.registerName(AccountAdapter.currentAccountId, + AccountAdapter.model.registerName(LRCInstance.currentAccountId, password, registerdName) } diff --git a/src/smartlistmodel.cpp b/src/smartlistmodel.cpp index 805218ff5..49d9a83bf 100644 --- a/src/smartlistmodel.cpp +++ b/src/smartlistmodel.cpp @@ -46,7 +46,8 @@ int SmartListModel::rowCount(const QModelIndex& parent) const { if (!parent.isValid() && lrcInstance_) { - auto& accInfo = lrcInstance_->accountModel().getAccountInfo(lrcInstance_->getCurrAccId()); + auto& accInfo = lrcInstance_->accountModel().getAccountInfo( + lrcInstance_->getCurrentAccountId()); auto& convModel = accInfo.conversationModel; if (listModelType_ == Type::TRANSFER) { auto filterType = accInfo.profileInfo.type; @@ -77,7 +78,7 @@ SmartListModel::data(const QModelIndex& index, int role) const case Type::TRANSFER: { try { auto& currentAccountInfo = lrcInstance_->accountModel().getAccountInfo( - lrcInstance_->getCurrAccId()); + lrcInstance_->getCurrentAccountId()); auto& convModel = currentAccountInfo.conversationModel; auto filterType = currentAccountInfo.profileInfo.type; auto& item = convModel->getFilteredConversations(filterType).at(index.row()); @@ -142,7 +143,8 @@ void SmartListModel::setConferenceableFilter(const QString& filter) { beginResetModel(); - auto& accountInfo = lrcInstance_->accountModel().getAccountInfo(lrcInstance_->getCurrAccId()); + auto& accountInfo = lrcInstance_->accountModel().getAccountInfo( + lrcInstance_->getCurrentAccountId()); auto& convModel = accountInfo.conversationModel; conferenceables_ = convModel->getConferenceableConversations(lrcInstance_->get_selectedConvUid(), filter); diff --git a/src/utils.cpp b/src/utils.cpp index 8252dbe63..1184ffa75 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -337,7 +337,7 @@ Utils::contactPhoto(LRCInstance* instance, * Get first contact photo. */ auto& accountInfo = instance->accountModel().getAccountInfo( - accountId.isEmpty() ? instance->getCurrAccId() : accountId); + accountId.isEmpty() ? instance->getCurrentAccountId() : accountId); auto contactInfo = accountInfo.contactModel->getContact(contactUri); auto contactPhoto = contactInfo.profileInfo.avatar; auto bestName = accountInfo.contactModel->bestNameForContact(contactUri); diff --git a/src/utilsadapter.cpp b/src/utilsadapter.cpp index 75b78cc7c..fc21d1429 100644 --- a/src/utilsadapter.cpp +++ b/src/utilsadapter.cpp @@ -218,7 +218,7 @@ UtilsAdapter::getCallId(const QString& accountId, const QString& convUid) int UtilsAdapter::getCallStatus(const QString& callId) { - const auto callStatus = lrcInstance_->getCallInfo(callId, lrcInstance_->getCurrAccId()); + const auto callStatus = lrcInstance_->getCallInfo(callId, lrcInstance_->getCurrentAccountId()); return static_cast<int>(callStatus->status); } diff --git a/src/wizardview/WizardView.qml b/src/wizardview/WizardView.qml index d30b1c22f..83da3b243 100644 --- a/src/wizardview/WizardView.qml +++ b/src/wizardview/WizardView.qml @@ -316,7 +316,7 @@ Rectangle { } else { if (folderDir.length > 0) { AccountAdapter.exportToFile( - AccountAdapter.currentAccountId, + LRCInstance.currentAccountId, UtilsAdapter.getAbsPath(folderDir)) } } -- GitLab