Wizard: Setup the folder in the right account

This commit is contained in:
Olivier Goffart 2015-04-27 17:43:07 +02:00
parent 3e4886725a
commit 4006bcdaed
4 changed files with 13 additions and 8 deletions

View file

@ -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()

View file

@ -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<AccountStatePtr> accounts() { return _accounts; }
private:

View file

@ -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("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").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;
}

View file

@ -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;