1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-07-31 11:20:22 +02:00

Upgrade config.

This commit is contained in:
Teo Mrnjavac
2013-05-21 19:08:40 +02:00
parent a28ffdaa8f
commit 7e947cc135

View File

@@ -20,8 +20,6 @@
#include "TomahawkSettings.h"
#include <QDir>
#include "Source.h"
#include "PlaylistInterface.h"
@@ -33,6 +31,9 @@
#include "playlist/PlaylistUpdaterInterface.h"
#include "infosystem/InfoSystemCache.h"
#include <qtkeychain/keychain.h>
#include <QDir>
using namespace Tomahawk;
TomahawkSettings* TomahawkSettings::s_instance = 0;
@@ -612,6 +613,39 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
const bool removed = dataFile.remove();
tDebug() << "Tried to remove echonest_stylesandmoods.dat, succeeded?" << removed;
}
else if ( oldVersion == 14 )
{
const QStringList accounts = value( "accounts/allaccounts" ).toStringList();
tDebug() << "About to move these accounts to QtKeychain:" << accounts;
//Move storage of Credentials from QSettings to QtKeychain
foreach ( const QString& account, accounts )
{
tDebug() << "beginGroup" << QString( "accounts/%1" ).arg( account );
beginGroup( QString( "accounts/%1" ).arg( account ) );
const QVariantHash creds = value( "credentials" ).toHash();
tDebug() << "creds:" << creds;
if ( !creds.isEmpty() )
{
QKeychain::WritePasswordJob* j = new QKeychain::WritePasswordJob( QLatin1String( "tomahawkaccounts" ), this );
j->setKey( account );
j->setAutoDelete( false );
QByteArray data;
QDataStream ds( &data, QIODevice::WriteOnly );
ds << creds;
j->setBinaryData( data );
j->start();
qDebug() << "Migrating account credentials for account:" << account;
}
remove( "credentials" );
endGroup();
}
}
}