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; return acc;
} }
void AccountManager::addAccount(const AccountPtr& newAccount) AccountState *AccountManager::addAccount(const AccountPtr& newAccount)
{ {
auto id = newAccount->id(); auto id = newAccount->id();
if (id.isEmpty() || !isAccountIdAvailable(id)) { if (id.isEmpty() || !isAccountIdAvailable(id)) {
@ -204,6 +204,7 @@ void AccountManager::addAccount(const AccountPtr& newAccount)
AccountStatePtr newAccountState(new AccountState(newAccount)); AccountStatePtr newAccountState(new AccountState(newAccount));
_accounts << newAccountState; _accounts << newAccountState;
emit accountAdded(newAccountState.data()); emit accountAdded(newAccountState.data());
return newAccountState.data();
} }
void AccountManager::shutdown() void AccountManager::shutdown()

View file

@ -41,13 +41,16 @@ public:
* Add this account in the list of saved account. * Add this account in the list of saved account.
* Typically called from the wizard * Typically called from the wizard
*/ */
void addAccount(const AccountPtr &newAccount); AccountState *addAccount(const AccountPtr &newAccount);
/** /**
* remove all accounts * remove all accounts
*/ */
void shutdown(); void shutdown();
/**
* Return a list of all accounts.
*/
QList<AccountStatePtr> accounts() { return _accounts; } QList<AccountStatePtr> accounts() { return _accounts; }
private: private:

View file

@ -461,7 +461,7 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
// This may or may not wipe all folder definitions, depending // This may or may not wipe all folder definitions, depending
// on whether a new account is activated or the existing one // on whether a new account is activated or the existing one
// is changed. // is changed.
applyAccountChanges(); auto account = applyAccountChanges();
// But if the user went through with the folder config wizard, // But if the user went through with the folder config wizard,
// we assume they always want to have only that folder configured. // we assume they always want to have only that folder configured.
@ -480,8 +480,6 @@ void OwncloudSetupWizard::slotAssistantFinished( int result )
folderDefinition.localPath = localFolder; folderDefinition.localPath = localFolder;
folderDefinition.targetPath = _remoteFolder; folderDefinition.targetPath = _remoteFolder;
folderDefinition.selectiveSyncBlackList = _ocWizard->selectiveSyncBlacklist(); 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); folderMan->addFolder(account, folderDefinition);
_ocWizard->appendToConfigurationLog(tr("<font color=\"green\"><b>Local sync folder %1 successfully created!</b></font>").arg(localFolder)); _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 ); emit ownCloudWizardDone( QDialog::Accepted );
} }
void OwncloudSetupWizard::applyAccountChanges() AccountState *OwncloudSetupWizard::applyAccountChanges()
{ {
AccountPtr newAccount = _ocWizard->account(); AccountPtr newAccount = _ocWizard->account();
auto manager = AccountManager::instance(); auto manager = AccountManager::instance();
manager->addAccount(newAccount); auto newState = manager->addAccount(newAccount);
manager->save(); manager->save();
return newState;
} }

View file

@ -29,6 +29,8 @@
namespace OCC { namespace OCC {
class AccountState;
class OwncloudWizard; class OwncloudWizard;
class DetermineAuthTypeJob : public AbstractNetworkJob { class DetermineAuthTypeJob : public AbstractNetworkJob {
@ -78,7 +80,7 @@ private:
void createRemoteFolder(); void createRemoteFolder();
void finalizeSetup( bool ); void finalizeSetup( bool );
bool ensureStartFromScratch(const QString &localFolder); bool ensureStartFromScratch(const QString &localFolder);
void applyAccountChanges(); AccountState *applyAccountChanges();
bool checkDowngradeAdvised(QNetworkReply* reply); bool checkDowngradeAdvised(QNetworkReply* reply);
OwncloudWizard* _ocWizard; OwncloudWizard* _ocWizard;