1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-15 18:44:30 +02:00

start migration code, load credentials on show (instead on object creation) in XmppConfigWidget

This commit is contained in:
Stefan Derkits
2012-05-14 19:55:58 +02:00
parent e5933b775d
commit 8febff6030
5 changed files with 48 additions and 11 deletions

View File

@@ -38,14 +38,9 @@ XmppConfigWidget::XmppConfigWidget( XmppAccount* account, QWidget *parent ) :
m_account( account )
{
m_ui->setupUi( this );
m_ui->xmppUsername->setText( account->credentials().contains( "username" ) ? account->credentials()[ "username" ].toString() : QString() );
m_ui->xmppPassword->setText( account->credentials().contains( "password" ) ? account->credentials()[ "password" ].toString() : QString() );
m_ui->xmppServer->setText( account->configuration().contains( "server" ) ? account->configuration()[ "server" ].toString() : QString() );
m_ui->xmppPort->setValue( account->configuration().contains( "port" ) ? account->configuration()[ "port" ].toInt() : 5222 );
m_ui->xmppPublishTracksCheckbox->setChecked( account->configuration().contains( "publishtracks" ) ? account->configuration()[ "publishtracks" ].toBool() : true);
m_ui->xmppEnforceSecureCheckbox->setChecked( account->configuration().contains( "enforcesecure" ) ? account->configuration()[ "enforcesecure" ].toBool() : false);
m_ui->jidExistsLabel->hide();
loadFromConfig();
connect( m_ui->xmppUsername, SIGNAL( textChanged( QString ) ), SLOT( onCheckJidExists( QString ) ) );
}
@@ -78,6 +73,26 @@ XmppConfigWidget::saveConfig()
}
void
XmppConfigWidget::showEvent(QShowEvent* event)
{
loadFromConfig();
}
void
XmppConfigWidget::loadFromConfig()
{
m_ui->xmppUsername->setText( m_account->credentials().contains( "username" ) ? m_account->credentials()[ "username" ].toString() : QString() );
m_ui->xmppPassword->setText( m_account->credentials().contains( "password" ) ? m_account->credentials()[ "password" ].toString() : QString() );
m_ui->xmppServer->setText( m_account->configuration().contains( "server" ) ? m_account->configuration()[ "server" ].toString() : QString() );
m_ui->xmppPort->setValue( m_account->configuration().contains( "port" ) ? m_account->configuration()[ "port" ].toInt() : 5222 );
m_ui->xmppPublishTracksCheckbox->setChecked( m_account->configuration().contains( "publishtracks" ) ? m_account->configuration()[ "publishtracks" ].toBool() : true);
m_ui->xmppEnforceSecureCheckbox->setChecked( m_account->configuration().contains( "enforcesecure" ) ? m_account->configuration()[ "enforcesecure" ].toBool() : false);
}
void
XmppConfigWidget::onCheckJidExists( QString jid )
{

View File

@@ -48,10 +48,15 @@ public:
virtual ~XmppConfigWidget();
void saveConfig();
void loadFromConfig();
signals:
void dataError( bool exists );
protected:
void showEvent( QShowEvent* event );
private slots:
void onCheckJidExists( QString jid );

View File

@@ -22,6 +22,8 @@
#include <QDir>
#include <qtkeychain/keychain.h>
#include "sip/SipHandler.h"
#include "PlaylistInterface.h"
@@ -516,6 +518,16 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
remove( "playlistupdaters" );
}
else if ( oldVersion == 10 )
{
const QStringList accounts = childGroups();
//Move storage of Credentials from QSettings to QtKeychain
foreach ( const QString& account, accounts )
{
//TODO: migration code to be written
}
}
}

View File

@@ -19,6 +19,8 @@
#include "Account.h"
#include <qtkeychain/keychain.h>
namespace Tomahawk
{
@@ -216,7 +218,7 @@ Account::loadFromConfig( const QString& accountId )
m_acl = s->value( "acl", QVariantMap() ).toMap();
m_types = s->value( "types", QStringList() ).toStringList();
s->endGroup();
QKeychain::ReadPasswordJob* j = new QKeychain::ReadPasswordJob( QLatin1String( "tomahawkaccounts" ), this );
QKeychain::ReadPasswordJob* j = new QKeychain::ReadPasswordJob( QLatin1String( "tomahawk" ), this );
j->setKey( m_accountId );
j->setAutoDelete( false );
connect( j, SIGNAL( finished( QKeychain::Job* ) ), this, SLOT( keychainJobFinished( QKeychain::Job* ) ) );
@@ -237,7 +239,7 @@ Account::removeFromConfig()
s->remove( "types" );
s->endGroup();
s->remove( "accounts/" + m_accountId );
QKeychain::DeletePasswordJob* j = new QKeychain::DeletePasswordJob( QLatin1String( "tomahawkaccounts" ), this );
QKeychain::DeletePasswordJob* j = new QKeychain::DeletePasswordJob( QLatin1String( "tomahawk" ), this );
j->setKey( m_accountId );
j->setAutoDelete( false );
connect( j, SIGNAL( finished( QKeychain::Job* ) ), this, SLOT( keychainJobFinished( QKeychain::Job* ) ) );

View File

@@ -27,8 +27,6 @@
#include <QtCore/QString>
#include <QtCore/QUuid>
#include <qtkeychain/keychain.h>
#include "Typedefs.h"
#include "DllMacro.h"
#include "TomahawkSettings.h"
@@ -37,6 +35,11 @@
class SipPlugin;
namespace QKeychain
{
class Job;
}
namespace Tomahawk
{