mirror of
https://gitlab.linphone.org/BC/public/linphone-desktop.git
synced 2026-01-17 11:28:07 +00:00
Fix removing account
This commit is contained in:
parent
ebba8f342f
commit
d2ddf01144
3 changed files with 27 additions and 18 deletions
|
|
@ -129,15 +129,7 @@ bool AccountManager::login(QString username,
|
|||
if (mAccountModel && account == mAccountModel->getAccount()) {
|
||||
if (state == linphone::RegistrationState::Failed) {
|
||||
connect(
|
||||
mAccountModel.get(), &AccountModel::removedFromCore, this,
|
||||
[this]() {
|
||||
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;
|
||||
},
|
||||
mAccountModel.get(), &AccountModel::removed, this, [this]() { mAccountModel = nullptr; },
|
||||
Qt::SingleShotConnection);
|
||||
mAccountModel->removeAccount();
|
||||
} else if (state == linphone::RegistrationState::Ok) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,18 @@ AccountModel::AccountModel(const std::shared_ptr<linphone::Account> &account, QO
|
|||
});
|
||||
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this,
|
||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
|
||||
if (account == mMonitor) emit removedFromCore();
|
||||
if (account == mMonitor) {
|
||||
if (mToRemove && account->getState() == linphone::RegistrationState::None) {
|
||||
lInfo() << log().arg("Disabled account removed");
|
||||
auto authInfo = mMonitor->findAuthInfo();
|
||||
if (authInfo) {
|
||||
lInfo() << log().arg("Removing authinfo for disabled account");
|
||||
CoreModel::getInstance()->getCore()->removeAuthInfo(authInfo);
|
||||
}
|
||||
removeUserData(mMonitor);
|
||||
emit removed();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -59,10 +70,13 @@ AccountModel::~AccountModel() {
|
|||
void AccountModel::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||
linphone::RegistrationState state,
|
||||
const std::string &message) {
|
||||
if (state == linphone::RegistrationState::Cleared) {
|
||||
qDebug() << log().arg("Account removed");
|
||||
// Cleared and None are the last state on processes after being change. Check for accountRemoved for account that
|
||||
// was not registered.
|
||||
if (mToRemove && (state == linphone::RegistrationState::Cleared || state == linphone::RegistrationState::None)) {
|
||||
lInfo() << log().arg("Account removed on state [%1]").arg((int)state);
|
||||
auto authInfo = mMonitor->findAuthInfo();
|
||||
if (authInfo) {
|
||||
lInfo() << log().arg("Removing authinfo");
|
||||
CoreModel::getInstance()->getCore()->removeAuthInfo(authInfo);
|
||||
}
|
||||
removeUserData(mMonitor);
|
||||
|
|
@ -122,11 +136,13 @@ void AccountModel::setDefault() {
|
|||
void AccountModel::removeAccount() {
|
||||
auto core = CoreModel::getInstance()->getCore();
|
||||
auto params = mMonitor ? mMonitor->getParams() : nullptr;
|
||||
qDebug() << log()
|
||||
.arg("Removing account [%1]")
|
||||
.arg(params && params->getIdentityAddress()
|
||||
? Utils::coreStringToAppString(params->getIdentityAddress()->asString())
|
||||
: "Null");
|
||||
lInfo() << log()
|
||||
.arg("Removing account [%1]")
|
||||
.arg(params && params->getIdentityAddress()
|
||||
? Utils::coreStringToAppString(params->getIdentityAddress()->asString())
|
||||
: "Null");
|
||||
mToRemove = true;
|
||||
if (mMonitor) core->removeAccount(mMonitor);
|
||||
}
|
||||
|
||||
std::shared_ptr<linphone::Account> AccountModel::getAccount() const {
|
||||
|
|
|
|||
|
|
@ -109,7 +109,6 @@ 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);
|
||||
|
|
@ -128,6 +127,8 @@ private:
|
|||
static std::shared_ptr<AccountUserData> getUserData(const std::shared_ptr<linphone::Account> &account);
|
||||
static void removeUserData(const std::shared_ptr<linphone::Account> &account);
|
||||
|
||||
bool mToRemove = false;
|
||||
|
||||
DECLARE_ABSTRACT_OBJECT
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue