diff --git a/src/app/accountadapter.cpp b/src/app/accountadapter.cpp index e7610a922c899b8652301eeb7053658e067e1eb8..59ee75a8af11c561a4b8d1f0c056164671aded3a 100644 --- a/src/app/accountadapter.cpp +++ b/src/app/accountadapter.cpp @@ -97,16 +97,14 @@ AccountAdapter::connectFailure() } void -AccountAdapter::createJamiAccount(QString registeredName, - const QVariantMap& settings, - bool isCreating) +AccountAdapter::createJamiAccount(const QVariantMap& settings) { + auto registeredName = settings["registeredName"].toString(); Utils::oneShotConnect( &lrcInstance_->accountModel(), &lrc::api::AccountModel::accountAdded, - [this, registeredName, settings, isCreating](const QString& accountId) { + [this, registeredName, settings](const QString& accountId) { lrcInstance_->accountModel().setAvatar(accountId, settings["avatar"].toString()); - Utils::oneShotConnect(&lrcInstance_->accountModel(), &lrc::api::AccountModel::accountDetailsChanged, [this](const QString& accountId) { @@ -127,6 +125,7 @@ AccountAdapter::createJamiAccount(QString registeredName, registeredNameSavedConnection_ = connect(&lrcInstance_->accountModel(), &lrc::api::AccountModel::profileUpdated, + this, [this, addedAccountId = accountId](const QString& accountId) { if (addedAccountId == accountId) { Q_EMIT lrcInstance_->accountListChanged(); @@ -361,4 +360,4 @@ AccountAdapter::setArchivePasswordAsync(const QString& accountID, const QString& config.archivePassword = password; lrcInstance_->accountModel().setAccountConfig(accountID, config); }); -} \ No newline at end of file +} diff --git a/src/app/accountadapter.h b/src/app/accountadapter.h index a582a056c8ef75db22fe3be1f8728b0d6ea09d11..f8efa6db05266d8dfbe4e9ac354b914027aad9c9 100644 --- a/src/app/accountadapter.h +++ b/src/app/accountadapter.h @@ -56,9 +56,7 @@ public: Q_INVOKABLE void changeAccount(int row); // Create normal Jami account, SIP account and JAMS accounts. - Q_INVOKABLE void createJamiAccount(QString registeredName, - const QVariantMap& settings, - bool isCreating); + Q_INVOKABLE void createJamiAccount(const QVariantMap& settings); Q_INVOKABLE void createSIPAccount(const QVariantMap& settings); Q_INVOKABLE void createJAMSAccount(const QVariantMap& settings); diff --git a/src/app/wizardviewstepmodel.cpp b/src/app/wizardviewstepmodel.cpp index e92aa9914a99b64d3ce441cbe4928090558f6e56..f5e2cbcfec51047e9fc0591ae641d82c3587e247 100644 --- a/src/app/wizardviewstepmodel.cpp +++ b/src/app/wizardviewstepmodel.cpp @@ -32,21 +32,24 @@ WizardViewStepModel::WizardViewStepModel(LRCInstance* lrcInstance, { reset(); - connect(accountAdapter_, &AccountAdapter::accountAdded, [this](QString accountId, int index) { - accountAdapter_->changeAccount(index); + connect(accountAdapter_, + &AccountAdapter::accountAdded, + this, + [this](QString accountId, int index) { + accountAdapter_->changeAccount(index); - auto accountCreationOption = get_accountCreationOption(); - if (accountCreationOption == AccountCreationOption::ConnectToAccountManager - || accountCreationOption == AccountCreationOption::CreateSipAccount) { - Q_EMIT closeWizardView(); - reset(); - } else if (accountCreationOption != AccountCreationOption::None) { - Q_EMIT closeWizardView(); - reset(); - } + auto accountCreationOption = get_accountCreationOption(); + if (accountCreationOption == AccountCreationOption::ConnectToAccountManager + || accountCreationOption == AccountCreationOption::CreateSipAccount) { + Q_EMIT closeWizardView(); + reset(); + } else if (accountCreationOption != AccountCreationOption::None) { + Q_EMIT closeWizardView(); + reset(); + } - Q_EMIT accountIsReady(accountId); - }); + Q_EMIT accountIsReady(accountId); + }); } void @@ -64,36 +67,30 @@ void WizardViewStepModel::nextStep() { auto accountCreationOption = get_accountCreationOption(); - if (accountCreationOption == AccountCreationOption::None) + if (get_mainStep() == MainSteps::Initial + || accountCreationOption == AccountCreationOption::None) { return; + } - switch (get_mainStep()) { - case MainSteps::NameRegistration: - case MainSteps::AccountCreation: { - switch (get_accountCreationOption()) { - case AccountCreationOption::CreateJamiAccount: - case AccountCreationOption::CreateRendezVous: - case AccountCreationOption::ImportFromBackup: - case AccountCreationOption::ImportFromDevice: { - accountAdapter_->createJamiAccount(get_accountCreationInfo()["registeredName"].toString(), - get_accountCreationInfo(), - false); - break; - } - case AccountCreationOption::ConnectToAccountManager: { - accountAdapter_->createJAMSAccount(get_accountCreationInfo()); - break; - } - case AccountCreationOption::CreateSipAccount: { - accountAdapter_->createSIPAccount(get_accountCreationInfo()); - break; - } - } + switch (accountCreationOption) { + case AccountCreationOption::CreateJamiAccount: + case AccountCreationOption::CreateRendezVous: + case AccountCreationOption::ImportFromBackup: + case AccountCreationOption::ImportFromDevice: { + accountAdapter_->createJamiAccount(get_accountCreationInfo()); break; } - default: + case AccountCreationOption::ConnectToAccountManager: { + accountAdapter_->createJAMSAccount(get_accountCreationInfo()); + break; + } + case AccountCreationOption::CreateSipAccount: { + accountAdapter_->createSIPAccount(get_accountCreationInfo()); break; } + default: + return; + } } void