mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 03:18:07 +00:00
switch default account if clicking on a notification leading to a chat room from another account
This commit is contained in:
parent
da2ea7d114
commit
e0cb654746
3 changed files with 27 additions and 1 deletions
|
|
@ -108,6 +108,7 @@ ChatCore::ChatCore(const std::shared_ptr<linphone::ChatRoom> &chatRoom) : QObjec
|
|||
mChatRoomState = LinphoneEnums::fromLinphone(chatRoom->getState());
|
||||
mIsEncrypted = chatRoom->hasCapability((int)linphone::ChatRoom::Capabilities::Encrypted);
|
||||
auto localAccount = ToolModel::findAccount(chatRoom->getLocalAddress());
|
||||
if (localAccount) mLocalAccount = AccountCore::create(localAccount);
|
||||
bool associatedAccountHasIMEncryptionMandatory =
|
||||
localAccount && localAccount->getParams() &&
|
||||
localAccount->getParams()->getInstantMessagingEncryptionMandatory();
|
||||
|
|
@ -693,6 +694,10 @@ QList<QSharedPointer<ParticipantCore>> ChatCore::getParticipants() const {
|
|||
return mParticipants;
|
||||
}
|
||||
|
||||
QSharedPointer<AccountCore> ChatCore::getLocalAccount() const {
|
||||
return mLocalAccount;
|
||||
}
|
||||
|
||||
void ChatCore::updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend, bool isRemoval) {
|
||||
mustBeInLinphoneThread(log().arg(Q_FUNC_INFO));
|
||||
auto fAddress = ToolModel::interpretUrl(mPeerAddress);
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@
|
|||
|
||||
class EventLogCore;
|
||||
class FriendModel;
|
||||
class AccountCore;
|
||||
|
||||
class ChatCore : public QObject, public AbstractObject {
|
||||
Q_OBJECT
|
||||
|
|
@ -148,6 +149,8 @@ public:
|
|||
QVariantList getParticipantsGui() const;
|
||||
QStringList getParticipantsAddresses() const;
|
||||
|
||||
QSharedPointer<AccountCore> getLocalAccount() const;
|
||||
|
||||
void updateInfo(const std::shared_ptr<linphone::Friend> &updatedFriend, bool isRemoval = false);
|
||||
|
||||
signals:
|
||||
|
|
@ -222,6 +225,7 @@ private:
|
|||
std::shared_ptr<ChatModel> mChatModel;
|
||||
QSharedPointer<ChatMessageCore> mLastMessage;
|
||||
QList<QSharedPointer<EventLogCore>> mEventLogList;
|
||||
QSharedPointer<AccountCore> mLocalAccount;
|
||||
std::shared_ptr<FriendModel> mFriendModel;
|
||||
QSharedPointer<SafeConnection<ChatCore, ChatModel>> mChatModelConnection;
|
||||
QSharedPointer<SafeConnection<ChatCore, CoreModel>> mCoreModelConnection;
|
||||
|
|
|
|||
|
|
@ -1657,7 +1657,24 @@ void Utils::openChat(ChatGui *chat) {
|
|||
smartShowWindow(mainWindow);
|
||||
if (mainWindow && chat) {
|
||||
emit chat->mCore->messageOpen();
|
||||
QMetaObject::invokeMethod(mainWindow, "openChat", Q_ARG(QVariant, QVariant::fromValue(chat)));
|
||||
auto localChatAccount = chat->mCore->getLocalAccount();
|
||||
auto accountList = App::getInstance()->getAccountList();
|
||||
auto defaultAccount = accountList->getDefaultAccountCore();
|
||||
// If multiple accounts, we must switch to the correct account before opening the chatroom, otherwise,
|
||||
// a chat room corresponding to the wrong account could be added in the chat list
|
||||
if (localChatAccount && localChatAccount->getIdentityAddress() != defaultAccount->getIdentityAddress()) {
|
||||
connect(accountList.get(), &AccountList::defaultAccountChanged, accountList.get(),
|
||||
[localChatAccount, accountList, chat] {
|
||||
auto defaultAccount = accountList->getDefaultAccountCore();
|
||||
if (defaultAccount->getIdentityAddress() == localChatAccount->getIdentityAddress()) {
|
||||
disconnect(accountList.get(), &AccountList::defaultAccountChanged, accountList.get(),
|
||||
nullptr);
|
||||
QMetaObject::invokeMethod(getMainWindow(), "openChat",
|
||||
Q_ARG(QVariant, QVariant::fromValue(chat)));
|
||||
}
|
||||
});
|
||||
localChatAccount->lSetDefaultAccount();
|
||||
} else QMetaObject::invokeMethod(mainWindow, "openChat", Q_ARG(QVariant, QVariant::fromValue(chat)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue