mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 14:16:32 +02:00
Load Account credentials from CredentialsManager.
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
#include "Account.h"
|
#include "Account.h"
|
||||||
|
|
||||||
#include "TomahawkSettings.h"
|
#include "TomahawkSettings.h"
|
||||||
|
#include "AccountManager.h"
|
||||||
|
#include "CredentialsManager.h"
|
||||||
|
|
||||||
namespace Tomahawk
|
namespace Tomahawk
|
||||||
{
|
{
|
||||||
@@ -134,12 +136,14 @@ Account::syncConfig()
|
|||||||
s->beginGroup( "accounts/" + m_accountId );
|
s->beginGroup( "accounts/" + m_accountId );
|
||||||
s->setValue( "accountfriendlyname", m_accountFriendlyName );
|
s->setValue( "accountfriendlyname", m_accountFriendlyName );
|
||||||
s->setValue( "enabled", m_enabled );
|
s->setValue( "enabled", m_enabled );
|
||||||
s->setValue( "credentials", m_credentials );
|
|
||||||
s->setValue( "configuration", m_configuration );
|
s->setValue( "configuration", m_configuration );
|
||||||
s->setValue( "acl", m_acl );
|
s->setValue( "acl", m_acl );
|
||||||
s->setValue( "types", m_types );
|
s->setValue( "types", m_types );
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
s->sync();
|
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 );
|
s->beginGroup( "accounts/" + m_accountId );
|
||||||
m_accountFriendlyName = s->value( "accountfriendlyname", QString() ).toString();
|
m_accountFriendlyName = s->value( "accountfriendlyname", QString() ).toString();
|
||||||
m_enabled = s->value( "enabled", false ).toBool();
|
m_enabled = s->value( "enabled", false ).toBool();
|
||||||
m_credentials = s->value( "credentials", QVariantHash() ).toHash();
|
|
||||||
m_configuration = s->value( "configuration", QVariantHash() ).toHash();
|
m_configuration = s->value( "configuration", QVariantHash() ).toHash();
|
||||||
m_acl = s->value( "acl", QVariantMap() ).toMap();
|
m_acl = s->value( "acl", QVariantMap() ).toMap();
|
||||||
m_types = s->value( "types", QStringList() ).toStringList();
|
m_types = s->value( "types", QStringList() ).toStringList();
|
||||||
s->endGroup();
|
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->beginGroup( "accounts/" + m_accountId );
|
||||||
s->remove( "accountfriendlyname" );
|
s->remove( "accountfriendlyname" );
|
||||||
s->remove( "enabled" );
|
s->remove( "enabled" );
|
||||||
s->remove( "credentials" );
|
|
||||||
s->remove( "configuration" );
|
s->remove( "configuration" );
|
||||||
s->remove( "acl" );
|
s->remove( "acl" );
|
||||||
s->remove( "types" );
|
s->remove( "types" );
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
s->remove( "accounts/" + m_accountId );
|
s->remove( "accounts/" + m_accountId );
|
||||||
|
|
||||||
|
CredentialsManager* c = AccountManager::instance()->credentialsManager();
|
||||||
|
c->setCredentials( m_accountId, QVariantHash() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -86,9 +86,10 @@ public:
|
|||||||
Account* zeroconfAccount() const;
|
Account* zeroconfAccount() const;
|
||||||
|
|
||||||
bool isConnected() const { return m_connected; }
|
bool isConnected() const { return m_connected; }
|
||||||
|
|
||||||
bool isReadyForSip() const { return m_readyForSip; }
|
bool isReadyForSip() const { return m_readyForSip; }
|
||||||
|
|
||||||
|
CredentialsManager* credentialsManager() const { return m_creds; }
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void connectAll();
|
void connectAll();
|
||||||
void disconnectAll();
|
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
|
void
|
||||||
CredentialsManager::keychainJobFinished( QKeychain::Job* j )
|
CredentialsManager::keychainJobFinished( QKeychain::Job* j )
|
||||||
{
|
{
|
||||||
|
@@ -57,6 +57,9 @@ public:
|
|||||||
|
|
||||||
QStringList keys() const;
|
QStringList keys() const;
|
||||||
|
|
||||||
|
QVariantHash credentials( const QString& key ) const;
|
||||||
|
void setCredentials( const QString& key, const QVariantHash& value );
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void ready();
|
void ready();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user