1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-06 14:16:32 +02:00

Always re-install spotify resolver if path is no longer valid

This commit is contained in:
Leo Franchi
2012-06-26 17:53:27 -04:00
parent a7d90b16e7
commit e1416fce06

View File

@@ -138,10 +138,16 @@ SpotifyAccount::delayedInit()
if ( !path.isEmpty() ) if ( !path.isEmpty() )
{ {
QFileInfo info( path ); QFileInfo info( path );
// Resolver was deleted, so abort. // Resolver was deleted, so abort and remove our manual override, as it's no longer valid
if ( !info.exists() ) if ( !info.exists() )
{
QVariantHash conf = configuration();
conf.remove( "path" );
setConfiguration( conf );
sync();
return; return;
} }
}
hookupResolver(); hookupResolver();
} }
} }
@@ -165,6 +171,17 @@ SpotifyAccount::hookupResolver()
} }
qDebug() << "Starting spotify resolver with path:" << path; qDebug() << "Starting spotify resolver with path:" << path;
if ( !m_spotifyResolver.isNull() )
{
delete m_spotifyResolver.data();
}
if ( !QFile::exists( path ) )
{
qWarning() << "Asked to hook up spotify resolver but it doesn't exist, ignoring";
return;
}
m_spotifyResolver = QWeakPointer< ScriptResolver >( qobject_cast< ScriptResolver* >( Pipeline::instance()->addScriptResolver( path ) ) ); m_spotifyResolver = QWeakPointer< ScriptResolver >( qobject_cast< ScriptResolver* >( Pipeline::instance()->addScriptResolver( path ) ) );
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
@@ -228,13 +245,18 @@ SpotifyAccount::authenticate()
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res ); const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
qDebug() << "Spotify account authenticating..."; qDebug() << "Spotify account authenticating...";
const QString path = configuration().value( "path" ).toString();
const QFileInfo info( path );
const bool manualResolverRemoved = !path.isEmpty() && !info.exists();
if ( m_spotifyResolver.isNull() && state == AtticaManager::Installed ) if ( m_spotifyResolver.isNull() && state == AtticaManager::Installed )
{ {
// We don;t have the resolver but it has been installed via attica already, so lets just turn it on // We don;t have the resolver but it has been installed via attica already, so lets just turn it on
qDebug() << "No valid spotify resolver running, but attica reports it is installed, so start it up"; qDebug() << "No valid spotify resolver running, but attica reports it is installed, so start it up";
hookupResolver(); hookupResolver();
} }
else if ( m_spotifyResolver.isNull() ) else if ( m_spotifyResolver.isNull() || manualResolverRemoved )
{ {
qDebug() << "Got null resolver but asked to authenticate, so installing if we have one from attica:" << res.isValid() << res.id(); qDebug() << "Got null resolver but asked to authenticate, so installing if we have one from attica:" << res.isValid() << res.id();
if ( res.isValid() && !res.id().isEmpty() ) if ( res.isValid() && !res.id().isEmpty() )
@@ -318,6 +340,11 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath )
setConfiguration( conf ); setConfiguration( conf );
sync(); sync();
// uninstall
const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId );
if ( AtticaManager::instance()->resolverState( res ) != AtticaManager::Uninstalled )
AtticaManager::instance()->uninstallResolver( res );
m_preventEnabling = false; m_preventEnabling = false;
if ( !m_spotifyResolver.isNull() ) if ( !m_spotifyResolver.isNull() )