mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-05 05:37:29 +02:00
Ensure we have lastfm and spotify accounts
This commit is contained in:
@@ -90,6 +90,9 @@ SpotifyAccount::~SpotifyAccount()
|
|||||||
void
|
void
|
||||||
SpotifyAccount::init()
|
SpotifyAccount::init()
|
||||||
{
|
{
|
||||||
|
setAccountFriendlyName( "Spotify" );
|
||||||
|
setAccountServiceName( "spotify" );
|
||||||
|
|
||||||
if ( !AtticaManager::instance()->resolversLoaded() )
|
if ( !AtticaManager::instance()->resolversLoaded() )
|
||||||
{
|
{
|
||||||
// If we're still waiting to load, wait for the attica resolvers to come down the pipe
|
// If we're still waiting to load, wait for the attica resolvers to come down the pipe
|
||||||
@@ -99,9 +102,6 @@ SpotifyAccount::init()
|
|||||||
|
|
||||||
qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" );
|
qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" );
|
||||||
|
|
||||||
setAccountFriendlyName( "Spotify" );
|
|
||||||
setAccountServiceName( "spotify" );
|
|
||||||
|
|
||||||
AtticaManager::instance()->registerCustomAccount( s_resolverId, this );
|
AtticaManager::instance()->registerCustomAccount( s_resolverId, this );
|
||||||
|
|
||||||
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( resolverInstalled( QString ) ) );
|
connect( AtticaManager::instance(), SIGNAL( resolverInstalled( QString ) ), this, SLOT( resolverInstalled( QString ) ) );
|
||||||
|
@@ -127,6 +127,21 @@ TomahawkSettings::TomahawkSettings( QObject* parent )
|
|||||||
// insert upgrade code here as required
|
// insert upgrade code here as required
|
||||||
setValue( "configversion", TOMAHAWK_SETTINGS_VERSION );
|
setValue( "configversion", TOMAHAWK_SETTINGS_VERSION );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure last.fm and spotify accounts always exist
|
||||||
|
QString spotifyAcct, lastfmAcct;
|
||||||
|
foreach ( const QString& acct, value( "accounts/allaccounts" ).toStringList() )
|
||||||
|
{
|
||||||
|
if ( acct.startsWith( "lastfmaccount_" ) )
|
||||||
|
lastfmAcct = acct;
|
||||||
|
else if ( acct.startsWith( "spotifyaccount_" ) )
|
||||||
|
spotifyAcct = acct;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( spotifyAcct.isEmpty() )
|
||||||
|
createSpotifyAccount();
|
||||||
|
if ( lastfmAcct.isEmpty() )
|
||||||
|
createLastFmAccount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -142,6 +157,15 @@ TomahawkSettings::doInitialSetup()
|
|||||||
// by default we add a local network resolver
|
// by default we add a local network resolver
|
||||||
addAccount( "sipzeroconf_autocreated" );
|
addAccount( "sipzeroconf_autocreated" );
|
||||||
|
|
||||||
|
|
||||||
|
createLastFmAccount();
|
||||||
|
createSpotifyAccount();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::createLastFmAccount()
|
||||||
|
{
|
||||||
// Add a last.fm account for scrobbling and infosystem
|
// Add a last.fm account for scrobbling and infosystem
|
||||||
const QString accountKey = QString( "lastfmaccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) );
|
const QString accountKey = QString( "lastfmaccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) );
|
||||||
addAccount( accountKey );
|
addAccount( accountKey );
|
||||||
@@ -151,6 +175,27 @@ TomahawkSettings::doInitialSetup()
|
|||||||
setValue( "autoconnect", true );
|
setValue( "autoconnect", true );
|
||||||
setValue( "types", QStringList() << "ResolverType" << "StatusPushType" );
|
setValue( "types", QStringList() << "ResolverType" << "StatusPushType" );
|
||||||
endGroup();
|
endGroup();
|
||||||
|
|
||||||
|
QStringList allAccounts = value( "accounts/allaccounts" ).toStringList();
|
||||||
|
allAccounts << accountKey;
|
||||||
|
setValue( "accounts/allaccounts", allAccounts );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
TomahawkSettings::createSpotifyAccount()
|
||||||
|
{
|
||||||
|
const QString accountKey = QString( "spotifyaccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) );
|
||||||
|
beginGroup( "accounts/" + accountKey );
|
||||||
|
setValue( "enabled", false );
|
||||||
|
setValue( "types", QStringList() << "ResolverType" );
|
||||||
|
setValue( "credentials", QVariantHash() );
|
||||||
|
setValue( "configuration", QVariantHash() );
|
||||||
|
endGroup();
|
||||||
|
|
||||||
|
QStringList allAccounts = value( "accounts/allaccounts" ).toStringList();
|
||||||
|
allAccounts << accountKey;
|
||||||
|
setValue( "accounts/allaccounts", allAccounts );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -541,16 +586,7 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const QString accountKey = QString( "spotifyaccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) );
|
createSpotifyAccount();
|
||||||
beginGroup( "accounts/" + accountKey );
|
|
||||||
setValue( "enabled", false );
|
|
||||||
setValue( "types", QStringList() << "ResolverType" );
|
|
||||||
setValue( "credentials", QVariantHash() );
|
|
||||||
setValue( "configuration", QVariantHash() );
|
|
||||||
endGroup();
|
|
||||||
|
|
||||||
allAccounts << accountKey;
|
|
||||||
setValue( "accounts/allaccounts", allAccounts );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -214,6 +214,8 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void doInitialSetup();
|
void doInitialSetup();
|
||||||
|
void createLastFmAccount();
|
||||||
|
void createSpotifyAccount();
|
||||||
void doUpgrade( int oldVersion, int newVersion );
|
void doUpgrade( int oldVersion, int newVersion );
|
||||||
|
|
||||||
static TomahawkSettings* s_instance;
|
static TomahawkSettings* s_instance;
|
||||||
|
@@ -505,7 +505,7 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role
|
|||||||
box.setWindowTitle( tr( "Manual Install Required" ) );
|
box.setWindowTitle( tr( "Manual Install Required" ) );
|
||||||
box.setTextFormat( Qt::RichText );
|
box.setTextFormat( Qt::RichText );
|
||||||
box.setIcon( QMessageBox::Information );
|
box.setIcon( QMessageBox::Information );
|
||||||
box.setText( tr( "Unfortunately, automatic installation of the this resolver is not yet available on Linux.<br /><br />"
|
box.setText( tr( "Unfortunately, automatic installation of this resolver is not yet available on Linux.<br /><br />"
|
||||||
"Please use \"Install from file\" above, by fetching it from your distribution or compiling it yourself. Further instructions can be found here:<br /><br />http://www.tomahawk-player.org/resolvers/%1" ).arg( acct->accountServiceName() ) );
|
"Please use \"Install from file\" above, by fetching it from your distribution or compiling it yourself. Further instructions can be found here:<br /><br />http://www.tomahawk-player.org/resolvers/%1" ).arg( acct->accountServiceName() ) );
|
||||||
box.setStandardButtons( QMessageBox::Ok );
|
box.setStandardButtons( QMessageBox::Ok );
|
||||||
box.exec();
|
box.exec();
|
||||||
|
Reference in New Issue
Block a user