From 4defd26bb6c6d76a01bfa410c0a138652811e120 Mon Sep 17 00:00:00 2001 From: Julien Wadel Date: Fri, 31 Jan 2025 15:01:34 +0100 Subject: [PATCH] Fix log in conference. Fix removing auth info on bad login. Fix crash on login. --- Linphone/core/conference/ConferenceCore.cpp | 4 ++-- Linphone/model/account/AccountManager.cpp | 8 ++++++-- Linphone/model/account/AccountModel.cpp | 9 +++++++-- Linphone/model/account/AccountModel.hpp | 1 + 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/Linphone/core/conference/ConferenceCore.cpp b/Linphone/core/conference/ConferenceCore.cpp index a2c1327ce..93aa93cfd 100644 --- a/Linphone/core/conference/ConferenceCore.cpp +++ b/Linphone/core/conference/ConferenceCore.cpp @@ -248,7 +248,7 @@ ParticipantGui *ConferenceCore::getMeGui() const { void ConferenceCore::setActiveSpeakerDevice(const QSharedPointer &device) { if (mActiveSpeakerDevice != device) { mActiveSpeakerDevice = device; - log().arg("Changing active speaker device to ").arg(device ? device->getAddress() : "None"); + qDebug() << log().arg("Changing active speaker device to %1").arg(device ? device->getAddress() : "None"); emit activeSpeakerDeviceChanged(); } } @@ -256,7 +256,7 @@ void ConferenceCore::setActiveSpeakerDevice(const QSharedPointer &participant) { if (mActiveSpeaker != participant) { mActiveSpeaker = participant; - log().arg("Changing active speaker to ").arg(participant ? participant->getSipAddress() : "None"); + qDebug() << log().arg("Changing active speaker to %1").arg(participant ? participant->getSipAddress() : "None"); emit activeSpeakerChanged(); } } diff --git a/Linphone/model/account/AccountManager.cpp b/Linphone/model/account/AccountManager.cpp index 6db687f59..1e29b138b 100644 --- a/Linphone/model/account/AccountManager.cpp +++ b/Linphone/model/account/AccountManager.cpp @@ -129,9 +129,13 @@ bool AccountManager::login(QString username, if (mAccountModel && account == mAccountModel->getAccount()) { if (state == linphone::RegistrationState::Failed) { connect( - mAccountModel.get(), &AccountModel::removed, this, + mAccountModel.get(), &AccountModel::removedFromCore, this, [this]() { - emit mAccountModel->removeListener(); + auto authInfo = mAccountModel->getMonitor()->findAuthInfo(); + if (authInfo) { + qDebug() << log().arg("Removing auth info after failing to connect on login"); + CoreModel::getInstance()->getCore()->removeAuthInfo(authInfo); + } mAccountModel = nullptr; }, Qt::SingleShotConnection); diff --git a/Linphone/model/account/AccountModel.cpp b/Linphone/model/account/AccountModel.cpp index fe952adf6..f92d5655f 100644 --- a/Linphone/model/account/AccountModel.cpp +++ b/Linphone/model/account/AccountModel.cpp @@ -46,6 +46,10 @@ AccountModel::AccountModel(const std::shared_ptr &account, QO emit unreadNotificationsChanged(0 /*mMonitor->getUnreadChatMessageCount()*/, mMonitor->getMissedCallsCount()); // TODO }); + connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this, + [this](const std::shared_ptr &core, const std::shared_ptr &account) { + if (account == mMonitor) emit removedFromCore(); + }); } AccountModel::~AccountModel() { @@ -117,10 +121,11 @@ void AccountModel::setDefault() { void AccountModel::removeAccount() { auto core = CoreModel::getInstance()->getCore(); + auto params = mMonitor ? mMonitor->getParams() : nullptr; qDebug() << log() .arg("Removing account [%1]") - .arg(mMonitor ? Utils::coreStringToAppString(mMonitor->getContactAddress()->asString()) : "Null"); - core->removeAccount(mMonitor); + .arg(params ? Utils::coreStringToAppString(params->getIdentityAddress()->asString()) : "Null"); + if (mMonitor) core->removeAccount(mMonitor); } std::shared_ptr AccountModel::getAccount() const { diff --git a/Linphone/model/account/AccountModel.hpp b/Linphone/model/account/AccountModel.hpp index c31904a64..10315206e 100644 --- a/Linphone/model/account/AccountModel.hpp +++ b/Linphone/model/account/AccountModel.hpp @@ -109,6 +109,7 @@ signals: void audioVideoConferenceFactoryAddressChanged(QString value); void limeServerUrlChanged(QString value); void removed(); + void removedFromCore(); void voicemailCountChanged(int count); void showMwiChanged(bool show); void voicemailAddressChanged(QString value);