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 (mAccountModel && account == mAccountModel->getAccount()) {
|
||||||
if (state == linphone::RegistrationState::Failed) {
|
if (state == linphone::RegistrationState::Failed) {
|
||||||
connect(
|
connect(
|
||||||
mAccountModel.get(), &AccountModel::removedFromCore, this,
|
mAccountModel.get(), &AccountModel::removed, this, [this]() { mAccountModel = nullptr; },
|
||||||
[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;
|
|
||||||
},
|
|
||||||
Qt::SingleShotConnection);
|
Qt::SingleShotConnection);
|
||||||
mAccountModel->removeAccount();
|
mAccountModel->removeAccount();
|
||||||
} else if (state == linphone::RegistrationState::Ok) {
|
} 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,
|
connect(CoreModel::getInstance().get(), &CoreModel::accountRemoved, this,
|
||||||
[this](const std::shared_ptr<linphone::Core> &core, const std::shared_ptr<linphone::Account> &account) {
|
[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,
|
void AccountModel::onRegistrationStateChanged(const std::shared_ptr<linphone::Account> &account,
|
||||||
linphone::RegistrationState state,
|
linphone::RegistrationState state,
|
||||||
const std::string &message) {
|
const std::string &message) {
|
||||||
if (state == linphone::RegistrationState::Cleared) {
|
// Cleared and None are the last state on processes after being change. Check for accountRemoved for account that
|
||||||
qDebug() << log().arg("Account removed");
|
// 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();
|
auto authInfo = mMonitor->findAuthInfo();
|
||||||
if (authInfo) {
|
if (authInfo) {
|
||||||
|
lInfo() << log().arg("Removing authinfo");
|
||||||
CoreModel::getInstance()->getCore()->removeAuthInfo(authInfo);
|
CoreModel::getInstance()->getCore()->removeAuthInfo(authInfo);
|
||||||
}
|
}
|
||||||
removeUserData(mMonitor);
|
removeUserData(mMonitor);
|
||||||
|
|
@ -122,11 +136,13 @@ void AccountModel::setDefault() {
|
||||||
void AccountModel::removeAccount() {
|
void AccountModel::removeAccount() {
|
||||||
auto core = CoreModel::getInstance()->getCore();
|
auto core = CoreModel::getInstance()->getCore();
|
||||||
auto params = mMonitor ? mMonitor->getParams() : nullptr;
|
auto params = mMonitor ? mMonitor->getParams() : nullptr;
|
||||||
qDebug() << log()
|
lInfo() << log()
|
||||||
.arg("Removing account [%1]")
|
.arg("Removing account [%1]")
|
||||||
.arg(params && params->getIdentityAddress()
|
.arg(params && params->getIdentityAddress()
|
||||||
? Utils::coreStringToAppString(params->getIdentityAddress()->asString())
|
? Utils::coreStringToAppString(params->getIdentityAddress()->asString())
|
||||||
: "Null");
|
: "Null");
|
||||||
|
mToRemove = true;
|
||||||
|
if (mMonitor) core->removeAccount(mMonitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<linphone::Account> AccountModel::getAccount() const {
|
std::shared_ptr<linphone::Account> AccountModel::getAccount() const {
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,6 @@ signals:
|
||||||
void audioVideoConferenceFactoryAddressChanged(QString value);
|
void audioVideoConferenceFactoryAddressChanged(QString value);
|
||||||
void limeServerUrlChanged(QString value);
|
void limeServerUrlChanged(QString value);
|
||||||
void removed();
|
void removed();
|
||||||
void removedFromCore();
|
|
||||||
void voicemailCountChanged(int count);
|
void voicemailCountChanged(int count);
|
||||||
void showMwiChanged(bool show);
|
void showMwiChanged(bool show);
|
||||||
void voicemailAddressChanged(QString value);
|
void voicemailAddressChanged(QString value);
|
||||||
|
|
@ -128,6 +127,8 @@ private:
|
||||||
static std::shared_ptr<AccountUserData> getUserData(const std::shared_ptr<linphone::Account> &account);
|
static std::shared_ptr<AccountUserData> getUserData(const std::shared_ptr<linphone::Account> &account);
|
||||||
static void removeUserData(const std::shared_ptr<linphone::Account> &account);
|
static void removeUserData(const std::shared_ptr<linphone::Account> &account);
|
||||||
|
|
||||||
|
bool mToRemove = false;
|
||||||
|
|
||||||
DECLARE_ABSTRACT_OBJECT
|
DECLARE_ABSTRACT_OBJECT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue