mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-04-22 17:01:51 +02:00
Load Account credentials from CredentialsManager.
This commit is contained in:
parent
75f99dca4f
commit
29c8e6ed97
src/libtomahawk/accounts
@ -20,6 +20,8 @@
|
||||
#include "Account.h"
|
||||
|
||||
#include "TomahawkSettings.h"
|
||||
#include "AccountManager.h"
|
||||
#include "CredentialsManager.h"
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
@ -134,12 +136,14 @@ Account::syncConfig()
|
||||
s->beginGroup( "accounts/" + m_accountId );
|
||||
s->setValue( "accountfriendlyname", m_accountFriendlyName );
|
||||
s->setValue( "enabled", m_enabled );
|
||||
s->setValue( "credentials", m_credentials );
|
||||
s->setValue( "configuration", m_configuration );
|
||||
s->setValue( "acl", m_acl );
|
||||
s->setValue( "types", m_types );
|
||||
s->endGroup();
|
||||
s->sync();
|
||||
|
||||
CredentialsManager* c = AccountManager::instance()->credentialsManager();
|
||||
c->setCredentials( m_accountId, m_credentials );
|
||||
}
|
||||
|
||||
|
||||
@ -151,11 +155,13 @@ Account::loadFromConfig( const QString& accountId )
|
||||
s->beginGroup( "accounts/" + m_accountId );
|
||||
m_accountFriendlyName = s->value( "accountfriendlyname", QString() ).toString();
|
||||
m_enabled = s->value( "enabled", false ).toBool();
|
||||
m_credentials = s->value( "credentials", QVariantHash() ).toHash();
|
||||
m_configuration = s->value( "configuration", QVariantHash() ).toHash();
|
||||
m_acl = s->value( "acl", QVariantMap() ).toMap();
|
||||
m_types = s->value( "types", QStringList() ).toStringList();
|
||||
s->endGroup();
|
||||
|
||||
CredentialsManager* c = AccountManager::instance()->credentialsManager();
|
||||
m_credentials = c->credentials( m_accountId );
|
||||
}
|
||||
|
||||
|
||||
@ -166,12 +172,14 @@ Account::removeFromConfig()
|
||||
s->beginGroup( "accounts/" + m_accountId );
|
||||
s->remove( "accountfriendlyname" );
|
||||
s->remove( "enabled" );
|
||||
s->remove( "credentials" );
|
||||
s->remove( "configuration" );
|
||||
s->remove( "acl" );
|
||||
s->remove( "types" );
|
||||
s->endGroup();
|
||||
s->remove( "accounts/" + m_accountId );
|
||||
|
||||
CredentialsManager* c = AccountManager::instance()->credentialsManager();
|
||||
c->setCredentials( m_accountId, QVariantHash() );
|
||||
}
|
||||
|
||||
|
||||
|
@ -86,9 +86,10 @@ public:
|
||||
Account* zeroconfAccount() const;
|
||||
|
||||
bool isConnected() const { return m_connected; }
|
||||
|
||||
bool isReadyForSip() const { return m_readyForSip; }
|
||||
|
||||
CredentialsManager* credentialsManager() const { return m_creds; }
|
||||
|
||||
public slots:
|
||||
void connectAll();
|
||||
void disconnectAll();
|
||||
|
@ -66,6 +66,31 @@ CredentialsManager::keys() const
|
||||
}
|
||||
|
||||
|
||||
QVariantHash
|
||||
CredentialsManager::credentials( const QString& key ) const
|
||||
{
|
||||
return m_credentials.value( key );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CredentialsManager::setCredentials( const QString& key, const QVariantHash& value )
|
||||
{
|
||||
if ( value.isEmpty() )
|
||||
{
|
||||
m_credentials.remove( key );
|
||||
|
||||
//TODO: delete job
|
||||
}
|
||||
else
|
||||
{
|
||||
m_credentials.insert( key, value );
|
||||
|
||||
//TODO: write job
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
CredentialsManager::keychainJobFinished( QKeychain::Job* j )
|
||||
{
|
||||
|
@ -57,6 +57,9 @@ public:
|
||||
|
||||
QStringList keys() const;
|
||||
|
||||
QVariantHash credentials( const QString& key ) const;
|
||||
void setCredentials( const QString& key, const QVariantHash& value );
|
||||
|
||||
signals:
|
||||
void ready();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user