On login and without xmlrpc: use account creator settings before adding an account from scratch.

On account deletion, check if it is registered to avoid unnecessary wait.
This commit is contained in:
Julien Wadel 2023-07-04 10:52:01 +02:00
parent 04a6c401e6
commit 93d7cf66b1
2 changed files with 20 additions and 3 deletions

View file

@ -256,11 +256,23 @@ void AssistantModel::login () {
return;
}
// No verification if no xmlrpc url. Use addOtherSipAccount directly.
// No verification if no xmlrpc url.
auto account = mAccountCreator->createAccountInCore();
if(account){
AccountSettingsModel *accountSettingsModel = CoreManager::getInstance()->getAccountSettingsModel();
if (accountSettingsModel->addOrUpdateAccount(account, account->getParams()->clone())) {
accountSettingsModel->setDefaultAccount(account);
}
emit loginStatusChanged("");
return;
}
// Cannot create new account from account creator. Use addOtherSipAccount directly.
QVariantMap map;
map["sipDomain"] = Utils::coreStringToAppString(config->getString("assistant", "domain", ""));
map["username"] = getUsername();
map["password"] = getPassword();
map["transport"] = LinphoneEnums::toString(LinphoneEnums::fromLinphone(mAccountCreator->getTransport()));
emit loginStatusChanged(addOtherSipAccount(map) ? QString("") : tr("unableToAddAccount"));
setIsProcessing(false);
}
@ -286,7 +298,11 @@ bool AssistantModel::addOtherSipAccount (const QVariantMap &map) {
std::string accountIdKey = map["accountIdKey"].toString().toStdString();
if( accountIdKey != "")
account = core->getAccountByIdkey(accountIdKey);
shared_ptr<linphone::AccountParams> accountParams = core->createAccountParams();
shared_ptr<linphone::AccountParams> accountParams;
if(account)
accountParams = account->getParams()->clone();
else
accountParams = core->createAccountParams();
const QString domain = map["sipDomain"].toString();

View file

@ -296,10 +296,11 @@ void AccountSettingsModel::removeAccount (const shared_ptr<linphone::Account> &a
}
auto accountParams = account->getParams()->clone();
accountParams->setContactParameters(Utils::appStringToCoreString(parameters.join(";")));
bool isRegistered = account->getState() == linphone::RegistrationState::Ok;
if (account->setParams(accountParams) == -1) {
qWarning() << QStringLiteral("Unable to reset message-expiry property before removing account: `%1`.")
.arg(QString::fromStdString(account->getParams()->getIdentityAddress()->asString()));
}else if(account->getParams()->registerEnabled()) { // Wait for update
}else if(isRegistered && account->getParams()->registerEnabled()) { // Wait for update
mRemovingAccounts.push_back(account);
}else{// Registration is not enabled : Removing without wait.
CoreManager::getInstance()->getCore()->removeAccount(account);