diff --git a/src/gui/accountmanager.cpp b/src/gui/accountmanager.cpp index 5d84ebf99..b17de5d61 100644 --- a/src/gui/accountmanager.cpp +++ b/src/gui/accountmanager.cpp @@ -193,7 +193,7 @@ AccountPtr AccountManager::load(QSettings& settings) return acc; } -void AccountManager::addAccount(const AccountPtr& newAccount) +AccountState *AccountManager::addAccount(const AccountPtr& newAccount) { auto id = newAccount->id(); if (id.isEmpty() || !isAccountIdAvailable(id)) { @@ -204,6 +204,7 @@ void AccountManager::addAccount(const AccountPtr& newAccount) AccountStatePtr newAccountState(new AccountState(newAccount)); _accounts << newAccountState; emit accountAdded(newAccountState.data()); + return newAccountState.data(); } void AccountManager::shutdown() diff --git a/src/gui/accountmanager.h b/src/gui/accountmanager.h index 44ef48fab..6cf4434f4 100644 --- a/src/gui/accountmanager.h +++ b/src/gui/accountmanager.h @@ -41,13 +41,16 @@ public: * Add this account in the list of saved account. * Typically called from the wizard */ - void addAccount(const AccountPtr &newAccount); + AccountState *addAccount(const AccountPtr &newAccount); /** * remove all accounts */ void shutdown(); + /** + * Return a list of all accounts. + */ QList accounts() { return _accounts; } private: diff --git a/src/gui/owncloudsetupwizard.cpp b/src/gui/owncloudsetupwizard.cpp index 70ae2a2cc..c62da09a4 100644 --- a/src/gui/owncloudsetupwizard.cpp +++ b/src/gui/owncloudsetupwizard.cpp @@ -461,7 +461,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result ) // This may or may not wipe all folder definitions, depending // on whether a new account is activated or the existing one // is changed. - applyAccountChanges(); + auto account = applyAccountChanges(); // But if the user went through with the folder config wizard, // we assume they always want to have only that folder configured. @@ -480,8 +480,6 @@ void OwncloudSetupWizard::slotAssistantFinished( int result ) folderDefinition.localPath = localFolder; folderDefinition.targetPath = _remoteFolder; folderDefinition.selectiveSyncBlackList = _ocWizard->selectiveSyncBlacklist(); -#warning fixme: which account? save the one from addAccount below? - AccountState* account = AccountManager::instance()->accounts().value(0).data(); folderMan->addFolder(account, folderDefinition); _ocWizard->appendToConfigurationLog(tr("Local sync folder %1 successfully created!").arg(localFolder)); } @@ -501,13 +499,14 @@ void OwncloudSetupWizard::slotSkipFolderConfiguration() emit ownCloudWizardDone( QDialog::Accepted ); } -void OwncloudSetupWizard::applyAccountChanges() +AccountState *OwncloudSetupWizard::applyAccountChanges() { AccountPtr newAccount = _ocWizard->account(); auto manager = AccountManager::instance(); - manager->addAccount(newAccount); + auto newState = manager->addAccount(newAccount); manager->save(); + return newState; } diff --git a/src/gui/owncloudsetupwizard.h b/src/gui/owncloudsetupwizard.h index fc5b85035..6c246b3ae 100644 --- a/src/gui/owncloudsetupwizard.h +++ b/src/gui/owncloudsetupwizard.h @@ -29,6 +29,8 @@ namespace OCC { +class AccountState; + class OwncloudWizard; class DetermineAuthTypeJob : public AbstractNetworkJob { @@ -78,7 +80,7 @@ private: void createRemoteFolder(); void finalizeSetup( bool ); bool ensureStartFromScratch(const QString &localFolder); - void applyAccountChanges(); + AccountState *applyAccountChanges(); bool checkDowngradeAdvised(QNetworkReply* reply); OwncloudWizard* _ocWizard;