mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-01 03:40:16 +02:00
More work on handling binary resolver install
This commit is contained in:
@@ -738,6 +738,7 @@ void
|
|||||||
AccountDelegate::errorInstalling( const QPersistentModelIndex& idx )
|
AccountDelegate::errorInstalling( const QPersistentModelIndex& idx )
|
||||||
{
|
{
|
||||||
// Just hide the loading spinner as we do after a successful install
|
// Just hide the loading spinner as we do after a successful install
|
||||||
|
qDebug() << "ERROR INSTALLING index:" << idx;
|
||||||
doneInstalling( idx );
|
doneInstalling( idx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -45,6 +45,14 @@ using namespace Accounts;
|
|||||||
|
|
||||||
static QPixmap* s_icon = 0;
|
static QPixmap* s_icon = 0;
|
||||||
|
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
static QString s_resolverId = "spotify-osx";
|
||||||
|
#elif defined(Q_OS_WIN)
|
||||||
|
static QString s_resolverId = "spotify-win";
|
||||||
|
#else
|
||||||
|
static QString s_resolverId = "spotify-linux"
|
||||||
|
#endif
|
||||||
|
|
||||||
Account*
|
Account*
|
||||||
SpotifyAccountFactory::createAccount( const QString& accountId )
|
SpotifyAccountFactory::createAccount( const QString& accountId )
|
||||||
{
|
{
|
||||||
@@ -80,14 +88,21 @@ SpotifyAccount::init()
|
|||||||
{
|
{
|
||||||
qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" );
|
qRegisterMetaType< Tomahawk::Accounts::SpotifyPlaylistInfo* >( "Tomahawk::Accounts::SpotifyPlaylist*" );
|
||||||
|
|
||||||
AtticaManager::instance()->registerCustomAccount( "spotify", this );
|
setAccountFriendlyName( "Spotify" );
|
||||||
|
|
||||||
|
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 ) ) );
|
||||||
|
|
||||||
const Attica::Content res = AtticaManager::instance()->resolverForId( "spotify" );
|
const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId );
|
||||||
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
||||||
|
|
||||||
if ( state == AtticaManager::Installed )
|
if ( !checkForResolver() && state != AtticaManager::Uninstalled )
|
||||||
|
{
|
||||||
|
// If the user manually deleted the resolver, mark it as uninstalled, so we re-fetch for the user
|
||||||
|
AtticaManager::instance()->uninstallResolver( res );
|
||||||
|
}
|
||||||
|
else if ( state == AtticaManager::Installed )
|
||||||
{
|
{
|
||||||
hookupResolver();
|
hookupResolver();
|
||||||
}
|
}
|
||||||
@@ -100,7 +115,7 @@ SpotifyAccount::hookupResolver()
|
|||||||
// initialize the resolver itself. this is called if the account actually has an installed spotify resolver,
|
// initialize the resolver itself. this is called if the account actually has an installed spotify resolver,
|
||||||
// as it might not.
|
// as it might not.
|
||||||
// If there is a last.fm resolver from attica installed, create the corresponding ExternalResolver* and hook up to it
|
// If there is a last.fm resolver from attica installed, create the corresponding ExternalResolver* and hook up to it
|
||||||
const Attica::Content res = AtticaManager::instance()->resolverForId( "spotify" );
|
const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId );
|
||||||
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
||||||
Q_ASSERT( state == AtticaManager::Installed );
|
Q_ASSERT( state == AtticaManager::Installed );
|
||||||
Q_UNUSED( state );
|
Q_UNUSED( state );
|
||||||
@@ -124,6 +139,17 @@ SpotifyAccount::hookupResolver()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool SpotifyAccount::checkForResolver()
|
||||||
|
{
|
||||||
|
#ifdef Q_OS_MAC
|
||||||
|
const QDir path = QCoreApplication::applicationDirPath();
|
||||||
|
QFile file( path.absoluteFilePath( "spotify_tomahawkresolver" ) );
|
||||||
|
return file.exists();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
SpotifyAccount::resolverChanged()
|
SpotifyAccount::resolverChanged()
|
||||||
{
|
{
|
||||||
@@ -135,7 +161,7 @@ SpotifyAccount::resolverChanged()
|
|||||||
Attica::Content
|
Attica::Content
|
||||||
SpotifyAccount::atticaContent() const
|
SpotifyAccount::atticaContent() const
|
||||||
{
|
{
|
||||||
return AtticaManager::instance()->resolverForId( "spotify" );
|
return AtticaManager::instance()->resolverForId( s_resolverId );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +175,7 @@ SpotifyAccount::authenticate()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Attica::Content res = AtticaManager::instance()->resolverForId( "spotify" );
|
const Attica::Content res = AtticaManager::instance()->resolverForId( s_resolverId );
|
||||||
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
const AtticaManager::ResolverState state = AtticaManager::instance()->resolverState( res );
|
||||||
|
|
||||||
qDebug() << "Spotify account authenticating...";
|
qDebug() << "Spotify account authenticating...";
|
||||||
|
@@ -118,6 +118,8 @@ private slots:
|
|||||||
private:
|
private:
|
||||||
void init();
|
void init();
|
||||||
void hookupResolver();
|
void hookupResolver();
|
||||||
|
bool checkForResolver();
|
||||||
|
|
||||||
void loadPlaylists();
|
void loadPlaylists();
|
||||||
void clearUser( bool permanentlyDelete = false );
|
void clearUser( bool permanentlyDelete = false );
|
||||||
|
|
||||||
|
@@ -43,10 +43,11 @@ class BinaryInstallerHelper : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit BinaryInstallerHelper( const QString& resolverId, AtticaManager* manager)
|
explicit BinaryInstallerHelper( const QString& resolverId, bool createAccount, AtticaManager* manager)
|
||||||
: QObject( manager )
|
: QObject( manager )
|
||||||
, m_manager( QWeakPointer< AtticaManager >( manager ) )
|
, m_manager( QWeakPointer< AtticaManager >( manager ) )
|
||||||
, m_resolverId( resolverId )
|
, m_resolverId( resolverId )
|
||||||
|
, m_createAccount( createAccount )
|
||||||
{
|
{
|
||||||
Q_ASSERT( !m_resolverId.isEmpty() );
|
Q_ASSERT( !m_resolverId.isEmpty() );
|
||||||
Q_ASSERT( !m_manager.isNull() );
|
Q_ASSERT( !m_manager.isNull() );
|
||||||
@@ -55,17 +56,21 @@ public:
|
|||||||
virtual ~BinaryInstallerHelper() {}
|
virtual ~BinaryInstallerHelper() {}
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void extractSucceeded( const QString& path )
|
void installSucceeded( const QString& path )
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "install of binary resolver succeeded, enabling";
|
||||||
|
|
||||||
if ( m_manager.isNull() )
|
if ( m_manager.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if ( m_createAccount )
|
||||||
|
{
|
||||||
Tomahawk::Accounts::Account* acct = Tomahawk::Accounts::AccountManager::instance()->accountFromPath( path );
|
Tomahawk::Accounts::Account* acct = Tomahawk::Accounts::AccountManager::instance()->accountFromPath( path );
|
||||||
|
|
||||||
Tomahawk::Accounts::AccountManager::instance()->addAccount( acct );
|
Tomahawk::Accounts::AccountManager::instance()->addAccount( acct );
|
||||||
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
TomahawkSettings::instance()->addAccount( acct->accountId() );
|
||||||
Tomahawk::Accounts::AccountManager::instance()->enableAccount( acct );
|
Tomahawk::Accounts::AccountManager::instance()->enableAccount( acct );
|
||||||
|
}
|
||||||
|
|
||||||
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
|
m_manager.data()->m_resolverStates[ m_resolverId ].state = AtticaManager::Installed;
|
||||||
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
TomahawkSettingsGui::instanceGui()->setAtticaResolverStates( m_manager.data()->m_resolverStates );
|
||||||
@@ -74,8 +79,10 @@ public slots:
|
|||||||
|
|
||||||
deleteLater();
|
deleteLater();
|
||||||
}
|
}
|
||||||
void extractFailed()
|
void installFailed()
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "install failed";
|
||||||
|
|
||||||
if ( m_manager.isNull() )
|
if ( m_manager.isNull() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -86,6 +93,7 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QString m_resolverId;
|
QString m_resolverId;
|
||||||
|
bool m_createAccount;
|
||||||
QWeakPointer<AtticaManager> m_manager;
|
QWeakPointer<AtticaManager> m_manager;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -267,11 +275,8 @@ AtticaManager::userHasRated( const Content& c ) const
|
|||||||
bool
|
bool
|
||||||
AtticaManager::hasCustomAccountForAttica( const QString &id ) const
|
AtticaManager::hasCustomAccountForAttica( const QString &id ) const
|
||||||
{
|
{
|
||||||
// Only last.fm at the moment contains a custom account
|
qDebug() << "Got custom account for?" << id << m_customAccounts.keys();
|
||||||
if ( id == "lastfm" )
|
return m_customAccounts.keys().contains( id );
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -417,6 +422,10 @@ AtticaManager::binaryResolversList( BaseJob* j )
|
|||||||
r.binary = true;
|
r.binary = true;
|
||||||
m_resolverStates.insert( c.id(), r );
|
m_resolverStates.insert( c.id(), r );
|
||||||
}
|
}
|
||||||
|
else if ( m_resolverStates[ c.id() ].binary != true )
|
||||||
|
{ // HACK workaround... why is this not set in the first place sometimes? Migration issue?
|
||||||
|
m_resolverStates[ c.id() ].binary = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -580,10 +589,13 @@ AtticaManager::payloadFetched()
|
|||||||
if ( !TomahawkUtils::verifyFile( f.fileName(), signature ) )
|
if ( !TomahawkUtils::verifyFile( f.fileName(), signature ) )
|
||||||
{
|
{
|
||||||
qWarning() << "FILE SIGNATURE FAILED FOR BINARY RESOLVER! WARNING! :" << f.fileName() << signature;
|
qWarning() << "FILE SIGNATURE FAILED FOR BINARY RESOLVER! WARNING! :" << f.fileName() << signature;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
TomahawkUtils::extractBinaryResolver( f.fileName(), new BinaryInstallerHelper( resolverId, this ) );
|
{
|
||||||
|
TomahawkUtils::extractBinaryResolver( f.fileName(), new BinaryInstallerHelper( resolverId, reply->property( "createAccount" ).toBool(), this ) );
|
||||||
|
// Don't emit failed yet
|
||||||
|
installedSuccessfully = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -516,6 +516,35 @@ TomahawkSettings::doUpgrade( int oldVersion, int newVersion )
|
|||||||
|
|
||||||
remove( "playlistupdaters" );
|
remove( "playlistupdaters" );
|
||||||
}
|
}
|
||||||
|
else if ( oldVersion == 11 )
|
||||||
|
{
|
||||||
|
// 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;
|
||||||
|
foreach ( const QString& account, allAccounts )
|
||||||
|
{
|
||||||
|
if ( account.startsWith( "spotifyaccount_" ) )
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !found )
|
||||||
|
{
|
||||||
|
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();
|
||||||
|
|
||||||
|
allAccounts << accountKey;
|
||||||
|
setValue( "accounts/allaccounts", allAccounts );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "DllMacro.h"
|
#include "DllMacro.h"
|
||||||
|
|
||||||
#define TOMAHAWK_SETTINGS_VERSION 11
|
#define TOMAHAWK_SETTINGS_VERSION 12
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience wrapper around QSettings for tomahawk-specific config
|
* Convenience wrapper around QSettings for tomahawk-specific config
|
||||||
|
@@ -38,7 +38,7 @@ AccountModelFilterProxy::setSourceModel( QAbstractItemModel* sourceModel )
|
|||||||
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
|
connect( sourceModel, SIGNAL( scrollTo( QModelIndex ) ), this, SLOT( onScrollTo( QModelIndex ) ) );
|
||||||
connect( sourceModel, SIGNAL( startInstalling( QPersistentModelIndex ) ), this, SLOT( onStartInstalling( QPersistentModelIndex ) ) );
|
connect( sourceModel, SIGNAL( startInstalling( QPersistentModelIndex ) ), this, SLOT( onStartInstalling( QPersistentModelIndex ) ) );
|
||||||
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( onDoneInstalling( QPersistentModelIndex ) ) );
|
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( onDoneInstalling( QPersistentModelIndex ) ) );
|
||||||
connect( sourceModel, SIGNAL( doneInstalling( QPersistentModelIndex ) ), this, SLOT( errorInstalling( QPersistentModelIndex ) ) );
|
connect( sourceModel, SIGNAL( errorInstalling( QPersistentModelIndex ) ), this, SLOT( onErrorInstalling( QPersistentModelIndex ) ) );
|
||||||
QSortFilterProxyModel::setSourceModel( sourceModel );
|
QSortFilterProxyModel::setSourceModel( sourceModel );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -845,7 +845,7 @@ unzipFileInFolder( const QString &zipFileName, const QDir &folder )
|
|||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
extractBinaryResolver( const QString& zipFilename, QObject* )
|
extractBinaryResolver( const QString& zipFilename, QObject* receiver )
|
||||||
{
|
{
|
||||||
#if !defined(Q_OS_MAC) && !defined (Q_OS_WIN)
|
#if !defined(Q_OS_MAC) && !defined (Q_OS_WIN)
|
||||||
Q_ASSERT( false );
|
Q_ASSERT( false );
|
||||||
@@ -877,7 +877,7 @@ extractBinaryResolver( const QString& zipFilename, QObject* )
|
|||||||
const QString src = toList.absoluteFilePath( files.first() );
|
const QString src = toList.absoluteFilePath( files.first() );
|
||||||
qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
|
qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
|
||||||
|
|
||||||
copyWithAuthentication( src, dest, 0 );
|
copyWithAuthentication( src, dest, receiver );
|
||||||
#elif defined(Q_OS_WIN)
|
#elif defined(Q_OS_WIN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@@ -42,12 +42,11 @@
|
|||||||
|
|
||||||
- (void)moveFinished
|
- (void)moveFinished
|
||||||
{
|
{
|
||||||
if ( receiver )
|
|
||||||
QMetaObject::invokeMethod(receiver, "installSucceeded", Qt::DirectConnection, Q_ARG(QString, path));
|
|
||||||
|
|
||||||
// HACK since I can't figure out how to get QuaZip to maintain executable permissions after unzip (nor find the info)
|
// HACK since I can't figure out how to get QuaZip to maintain executable permissions after unzip (nor find the info)
|
||||||
// we set the binary to executable here
|
// we set the binary to executable here
|
||||||
|
|
||||||
|
NSLog(@"Move succeeded!, handling result");
|
||||||
|
|
||||||
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
NSFileManager *manager = [[[NSFileManager alloc] init] autorelease];
|
||||||
NSError* error;
|
NSError* error;
|
||||||
NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0755], NSFilePosixPermissions, nil];
|
NSDictionary* attrs = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithInt:0755], NSFilePosixPermissions, nil];
|
||||||
@@ -58,10 +57,15 @@
|
|||||||
if (!success) {
|
if (!success) {
|
||||||
NSLog( @"Failed to do chmod +x of moved resolver! %@", [[error userInfo] objectForKey: NSLocalizedDescriptionKey] );
|
NSLog( @"Failed to do chmod +x of moved resolver! %@", [[error userInfo] objectForKey: NSLocalizedDescriptionKey] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( receiver )
|
||||||
|
QMetaObject::invokeMethod(receiver, "installSucceeded", Qt::DirectConnection, Q_ARG(QString, path));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)moveFailedWithError:(NSError *)error
|
- (void)moveFailedWithError:(NSError *)error
|
||||||
{
|
{
|
||||||
|
NSLog(@"Move failed, handling result");
|
||||||
if ( receiver )
|
if ( receiver )
|
||||||
QMetaObject::invokeMethod(receiver, "installFailed", Qt::DirectConnection);
|
QMetaObject::invokeMethod(receiver, "installFailed", Qt::DirectConnection);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user