From 4f947b893f54474106c0a67e964fa001f40c2967 Mon Sep 17 00:00:00 2001 From: Leo Franchi Date: Fri, 18 May 2012 12:06:03 -0400 Subject: [PATCH] Fix some linux binary resolver stuff --- src/accounts/spotify/SpotifyAccount.cpp | 21 ++++++--------------- src/libtomahawk/TomahawkSettings.cpp | 14 +++++++++++--- src/libtomahawk/accounts/AccountModel.cpp | 19 +++++++++++++++++++ 3 files changed, 36 insertions(+), 18 deletions(-) diff --git a/src/accounts/spotify/SpotifyAccount.cpp b/src/accounts/spotify/SpotifyAccount.cpp index ba6033081..e2d0a86e0 100644 --- a/src/accounts/spotify/SpotifyAccount.cpp +++ b/src/accounts/spotify/SpotifyAccount.cpp @@ -100,6 +100,7 @@ SpotifyAccount::init() qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" ); setAccountFriendlyName( "Spotify" ); + setAccountServiceName( "spotify" ); AtticaManager::instance()->registerCustomAccount( s_resolverId, this ); @@ -108,7 +109,7 @@ SpotifyAccount::init() const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId ); const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res ); - const QString path = configuration().value( "resolverPath" ).toString(); // Manual path override + const QString path = configuration().value( "path" ).toString(); // Manual path override if ( !checkForResolver() && state != AtticaManager::Uninstalled ) { // If the user manually deleted the resolver, mark it as uninstalled, so we re-fetch for the user @@ -127,7 +128,7 @@ SpotifyAccount::hookupResolver() // initialize the resolver itself. this is called if the account actually has an installed spotify resolver, // as it might not. // If there is a spotify resolver from attica installed, create the corresponding ExternalResolver* and hook up to it - QString path = configuration().value( "resolverPath" ).toString(); + QString path = configuration().value( "path" ).toString(); if ( path.isEmpty() ) { const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId ); @@ -209,18 +210,8 @@ SpotifyAccount::authenticate() else { #ifdef Q_OS_LINUX - // Can't install from attica yet on linux, so show a warning if the user tries to turn it on. - // TODO make a prettier display - QMessageBox box; - box.setWindowTitle( tr( "Manual Install Required" ) ); - box.setTextFormat( Qt::RichText ); - box.setIcon( QMessageBox::Information ); - box.setText( tr( "Unfortunately, automatic installation of the Spotify resolver is not yet available on Linux.

" - "Please use \"Install from file\" above, by fetching it from your distribution or compiling it yourself. Further instructions can be found here:

http://www.tomahawk-player.org/resolvers/spotify" ) ); - box.setStandardButtons( QMessageBox::Ok ); - box.exec(); -#endif m_preventEnabling = true; +#endif } } else if ( !m_spotifyResolver.data()->running() ) @@ -282,7 +273,7 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath ) Q_ASSERT( !resolverPath.isEmpty() ); QVariantHash conf = configuration(); - conf[ "resolverPath" ] = resolverPath; + conf[ "path" ] = resolverPath; setConfiguration( conf ); sync(); @@ -291,7 +282,6 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath ) if ( !m_spotifyResolver.isNull() ) { // replace - //connect( m_spotifyResolver.data(), SIGNAL( destroyed( QObject* ) ), this, SLOT( hookupResolver() ) ); NewClosure( m_spotifyResolver.data(), SIGNAL( destroyed() ), this, SLOT( hookupAfterDeletion( bool ) ), true ); m_spotifyResolver.data()->deleteLater(); } @@ -421,6 +411,7 @@ SpotifyAccount::resolverMessage( const QString &msgType, const QVariantMap &msg if ( msgType == "credentials" ) { QVariantHash creds = credentials(); + creds[ "username" ] = msg.value( "username" ); creds[ "password" ] = msg.value( "password" ); creds[ "highQuality" ] = msg.value( "highQuality" ); diff --git a/src/libtomahawk/TomahawkSettings.cpp b/src/libtomahawk/TomahawkSettings.cpp index 002de3865..bf4619865 100644 --- a/src/libtomahawk/TomahawkSettings.cpp +++ b/src/libtomahawk/TomahawkSettings.cpp @@ -521,17 +521,25 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion ) // If the user doesn't have a spotify account, create one, since now it // is like the last.fm account and always exists QStringList allAccounts = value( "accounts/allaccounts" ).toStringList(); - bool found = false; + QString acct; foreach ( const QString& account, allAccounts ) { if ( account.startsWith( "spotifyaccount_" ) ) { - found = true; + acct = account; break; } } - if ( !found ) + if ( !acct.isEmpty() ) + { + beginGroup( "accounts/" + acct ); + QVariantHash conf = value( "configuration" ).toHash(); + foreach ( const QString& key, conf.keys() ) + qDebug() << key << conf[ key ].toString(); + endGroup(); + } + else { const QString accountKey = QString( "spotifyaccount_%1" ).arg( QUuid::createUuid().toString().mid( 1, 8 ) ); beginGroup( "accounts/" + accountKey ); diff --git a/src/libtomahawk/accounts/AccountModel.cpp b/src/libtomahawk/accounts/AccountModel.cpp index 198340b8a..b462e7673 100644 --- a/src/libtomahawk/accounts/AccountModel.cpp +++ b/src/libtomahawk/accounts/AccountModel.cpp @@ -24,6 +24,10 @@ #include "AtticaManager.h" #include "ResolverAccount.h" +#ifndef ENABLE_HEADLESS +#include +#endif + #include using namespace Tomahawk; @@ -492,6 +496,21 @@ AccountModel::setData( const QModelIndex& index, const QVariant& value, int role else if( state == Qt::Unchecked ) AccountManager::instance()->disableAccount( acct ); +#if defined(Q_OS_LINUX) && !defined(ENABLE_HEADLESS) + if ( acct->preventEnabling() ) + { + // Can't install from attica yet on linux, so show a warning if the user tries to turn it on. + // TODO make a prettier display + QMessageBox box; + box.setWindowTitle( tr( "Manual Install Required" ) ); + box.setTextFormat( Qt::RichText ); + box.setIcon( QMessageBox::Information ); + box.setText( tr( "Unfortunately, automatic installation of the this resolver is not yet available on Linux.

" + "Please use \"Install from file\" above, by fetching it from your distribution or compiling it yourself. Further instructions can be found here:

http://www.tomahawk-player.org/resolvers/%1" ).arg( acct->accountServiceName() ) ); + box.setStandardButtons( QMessageBox::Ok ); + box.exec(); + } +#endif emit dataChanged( index, index ); return true;