mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-17 19:37:09 +02:00
Added ConfigStorage priority and account deduplication.
This commit is contained in:
@@ -311,7 +311,25 @@ AccountManager::loadPlugin( const QString& accountId )
|
|||||||
void
|
void
|
||||||
AccountManager::addAccount( Account* account )
|
AccountManager::addAccount( Account* account )
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO << "adding account plugin";
|
tDebug() << Q_FUNC_INFO << "adding account plugin" << account->accountId();
|
||||||
|
foreach ( Account* a, m_accounts )
|
||||||
|
{
|
||||||
|
if ( a->credentials()["username"] == account->credentials()["username"] )
|
||||||
|
{
|
||||||
|
ConfigStorage* configStorageForA = configStorageForAccount( a->accountId() );
|
||||||
|
ConfigStorage* configStorageForNewAccount = configStorageForAccount( account->accountId() );
|
||||||
|
|
||||||
|
if ( !configStorageForA || !configStorageForNewAccount || configStorageForA->priority() > configStorageForNewAccount->priority() )
|
||||||
|
{
|
||||||
|
removeAccount( a );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
m_accounts.append( account );
|
m_accounts.append( account );
|
||||||
|
|
||||||
if ( account->types() & Accounts::SipType )
|
if ( account->types() & Accounts::SipType )
|
||||||
|
@@ -151,8 +151,8 @@ private:
|
|||||||
static AccountManager* s_instance;
|
static AccountManager* s_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -49,6 +49,8 @@ public:
|
|||||||
|
|
||||||
virtual QStringList accountIds() const = 0;
|
virtual QStringList accountIds() const = 0;
|
||||||
|
|
||||||
|
virtual unsigned int priority() const = 0; //LocalConfigStorage has 0, everything else comes later
|
||||||
|
|
||||||
virtual void save( const QString& accountId, const Account::Configuration& cfg ) = 0;
|
virtual void save( const QString& accountId, const Account::Configuration& cfg ) = 0;
|
||||||
virtual void load( const QString& accountId, Account::Configuration& cfg ) = 0;
|
virtual void load( const QString& accountId, Account::Configuration& cfg ) = 0;
|
||||||
virtual void remove( const QString& accountId ) = 0;
|
virtual void remove( const QString& accountId ) = 0;
|
||||||
|
@@ -80,6 +80,13 @@ LocalConfigStorage::accountIds() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
LocalConfigStorage::priority() const
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
LocalConfigStorage::save( const QString& accountId, const Account::Configuration& cfg )
|
LocalConfigStorage::save( const QString& accountId, const Account::Configuration& cfg )
|
||||||
{
|
{
|
||||||
|
@@ -39,6 +39,8 @@ public:
|
|||||||
|
|
||||||
QStringList accountIds() const;
|
QStringList accountIds() const;
|
||||||
|
|
||||||
|
unsigned int priority() const;
|
||||||
|
|
||||||
virtual void save( const QString& accountId, const Account::Configuration& cfg );
|
virtual void save( const QString& accountId, const Account::Configuration& cfg );
|
||||||
virtual void load( const QString& accountId, Account::Configuration& cfg );
|
virtual void load( const QString& accountId, Account::Configuration& cfg );
|
||||||
virtual void remove( const QString& accountId );
|
virtual void remove( const QString& accountId );
|
||||||
|
@@ -201,6 +201,13 @@ Tomahawk::Accounts::TelepathyConfigStorage::accountIds() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
unsigned int
|
||||||
|
Tomahawk::Accounts::TelepathyConfigStorage::priority() const
|
||||||
|
{
|
||||||
|
return 30;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
Tomahawk::Accounts::TelepathyConfigStorage::save( const QString& accountId, const Account::Configuration& cfg )
|
Tomahawk::Accounts::TelepathyConfigStorage::save( const QString& accountId, const Account::Configuration& cfg )
|
||||||
{
|
{
|
||||||
|
@@ -55,6 +55,8 @@ public:
|
|||||||
|
|
||||||
QStringList accountIds() const;
|
QStringList accountIds() const;
|
||||||
|
|
||||||
|
unsigned int priority() const;
|
||||||
|
|
||||||
virtual void save( const QString& accountId, const Account::Configuration& cfg );
|
virtual void save( const QString& accountId, const Account::Configuration& cfg );
|
||||||
virtual void load( const QString& accountId, Account::Configuration& cfg );
|
virtual void load( const QString& accountId, Account::Configuration& cfg );
|
||||||
virtual void remove( const QString& accountId );
|
virtual void remove( const QString& accountId );
|
||||||
|
Reference in New Issue
Block a user