From 2cd17362030cc8044f57532cac1f5bc4ad7642b7 Mon Sep 17 00:00:00 2001 From: Teo Mrnjavac Date: Sat, 29 Jun 2013 15:19:02 +0200 Subject: [PATCH] Store to LocalConfigStorage as fallback when installing a ResolverAccount. --- src/libtomahawk/accounts/Account.cpp | 3 ++- src/libtomahawk/accounts/AccountManager.cpp | 7 +++++++ src/libtomahawk/accounts/AccountManager.h | 1 + src/libtomahawk/accounts/ResolverAccount.cpp | 7 +++++++ 4 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/libtomahawk/accounts/Account.cpp b/src/libtomahawk/accounts/Account.cpp index 0cda69122..4fa57d2c3 100644 --- a/src/libtomahawk/accounts/Account.cpp +++ b/src/libtomahawk/accounts/Account.cpp @@ -143,7 +143,8 @@ Account::loadFromConfig( const QString& accountId ) { m_accountId = accountId; - AccountManager::instance()->configStorageForAccount( m_accountId )->load( m_accountId, m_cfg ); + if ( AccountManager::instance()->configStorageForAccount( m_accountId ) != 0 ) //could be 0 if we are installing the account right now + AccountManager::instance()->configStorageForAccount( m_accountId )->load( m_accountId, m_cfg ); } diff --git a/src/libtomahawk/accounts/AccountManager.cpp b/src/libtomahawk/accounts/AccountManager.cpp index 86a259147..6800be04d 100644 --- a/src/libtomahawk/accounts/AccountManager.cpp +++ b/src/libtomahawk/accounts/AccountManager.cpp @@ -424,6 +424,13 @@ AccountManager::configStorageForAccount( const QString& accountId ) } +ConfigStorage* +AccountManager::localConfigStorage() +{ + return m_configStorageById.value( "localconfigstorage" ); +} + + void AccountManager::hookupAccount( Account* account ) const { diff --git a/src/libtomahawk/accounts/AccountManager.h b/src/libtomahawk/accounts/AccountManager.h index b219d8e81..a30b67d8d 100644 --- a/src/libtomahawk/accounts/AccountManager.h +++ b/src/libtomahawk/accounts/AccountManager.h @@ -96,6 +96,7 @@ public: CredentialsManager* credentialsManager() const { return m_creds; } ConfigStorage* configStorageForAccount( const QString& accountId ); + ConfigStorage* localConfigStorage(); public slots: void connectAll(); diff --git a/src/libtomahawk/accounts/ResolverAccount.cpp b/src/libtomahawk/accounts/ResolverAccount.cpp index 90a93a171..3d884f504 100644 --- a/src/libtomahawk/accounts/ResolverAccount.cpp +++ b/src/libtomahawk/accounts/ResolverAccount.cpp @@ -22,6 +22,9 @@ #include "jobview/JobStatusView.h" #include "jobview/JobStatusModel.h" #include "jobview/ErrorStatusMessage.h" +#include "AccountManager.h" +#include "AtticaManager.h" +#include "ConfigStorage.h" #include "resolvers/ExternalResolver.h" #include "resolvers/ExternalResolverGui.h" #include "utils/Logger.h" @@ -302,6 +305,10 @@ ResolverAccount::ResolverAccount( const QString& accountId, const QString& path, setConfiguration( configuration ); + //just init so this account is tracked by LCS, we'll sync later + if ( !AccountManager::instance()->configStorageForAccount( accountId ) ) + AccountManager::instance()->localConfigStorage()->save( accountId, Account::Configuration() ); + init( path ); sync();