1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-04-07 01:22:49 +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

@ -138,9 +138,15 @@ SpotifyAccount::delayedInit()
if ( !path.isEmpty() )
{
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() )
{
QVariantHash conf = configuration();
conf.remove( "path" );
setConfiguration( conf );
sync();
return;
}
}
hookupResolver();
}
@ -165,6 +171,17 @@ SpotifyAccount::hookupResolver()
}
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 ) ) );
connect( m_spotifyResolver.data(), SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
@ -228,13 +245,18 @@ SpotifyAccount::authenticate()
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
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 )
{
// 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";
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();
if ( res.isValid() && !res.id().isEmpty() )
@ -318,6 +340,11 @@ SpotifyAccount::setManualResolverPath( const QString &resolverPath )
setConfiguration( conf );
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;
if ( !m_spotifyResolver.isNull() )