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

Properly download+install binary payload on linux

This commit is contained in:
Leo Franchi
2012-05-22 08:34:51 -04:00
parent 5766ea382b
commit b308212214
3 changed files with 28 additions and 19 deletions

View File

@@ -52,8 +52,12 @@ static QPixmap* s_icon = 0;
static QString s_resolverId = "spotify-osx"; static QString s_resolverId = "spotify-osx";
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
static QString s_resolverId = "spotify-win"; static QString s_resolverId = "spotify-win";
#elif defined(Q_OS_LINUX) && defined(__GNUC__) && defined(__x86_64__)
static QString s_resolverId = "spotify-linux-x64";
#elif defined(Q_OS_LINUX)
static QString s_resolverId = "spotify-linux-x86";
#else #else
static QString s_resolverId = "spotify-linux"; static QString s_resolverId = "spotify-unknown";
#endif #endif
Account* Account*
@@ -171,7 +175,7 @@ SpotifyAccount::checkForResolver()
const QDir path = QCoreApplication::applicationDirPath(); const QDir path = QCoreApplication::applicationDirPath();
QFile file( path.absoluteFilePath( "spotify_tomahawkresolver" ) ); QFile file( path.absoluteFilePath( "spotify_tomahawkresolver" ) );
return file.exists(); return file.exists();
#else if defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
QDir appDataDir = TomahawkUtils::appDataDir(); QDir appDataDir = TomahawkUtils::appDataDir();
return appDataDir.exists( QString( "atticaresolvers/%1/spotify_tomahawkresolver.exe" ).arg( s_resolverId ) ); return appDataDir.exists( QString( "atticaresolvers/%1/spotify_tomahawkresolver.exe" ).arg( s_resolverId ) );
#endif #endif

View File

@@ -345,6 +345,10 @@ AtticaManager::binaryResolversList( BaseJob* j )
platform = "osx"; platform = "osx";
#elif defined(Q_OS_WIN) #elif defined(Q_OS_WIN)
platform = "win"; platform = "win";
#elif defined(Q_OS_LINUX) && defined(__GNUC__) && defined(__x86_64__)
platform = "linux-x64";
#elif defined(Q_OS_LINUX) // Horrible assumption here...
platform = "linux-x86";
#endif #endif
foreach ( const Content& c, binaryResolvers ) foreach ( const Content& c, binaryResolvers )
@@ -533,7 +537,7 @@ AtticaManager::payloadFetched()
else else
{ {
TomahawkUtils::extractBinaryResolver( f.fileName(), new BinaryInstallerHelper( resolverId, reply->property( "createAccount" ).toBool(), this ) ); TomahawkUtils::extractBinaryResolver( f.fileName(), new BinaryInstallerHelper( resolverId, reply->property( "createAccount" ).toBool(), this ) );
// Don't emit success or failed yet, helpre will do that. // Don't emit success or failed yet, helper will do that.
return; return;
} }
} }

View File

@@ -39,6 +39,7 @@
#include <QDir> #include <QDir>
#include <QMutex> #include <QMutex>
#include <QCryptographicHash> #include <QCryptographicHash>
#include <QProcess>
#include <quazip.h> #include <quazip.h>
#include <quazipfile.h> #include <quazipfile.h>
@@ -848,17 +849,6 @@ unzipFileInFolder( const QString &zipFileName, const QDir &folder )
void void
extractBinaryResolver( const QString& zipFilename, QObject* receiver ) extractBinaryResolver( const QString& zipFilename, QObject* receiver )
{ {
#ifndef Q_OS_MAC
Q_UNUSED( zipFilename );
Q_UNUSED( receiver );
#endif
#if !defined(Q_OS_MAC) && !defined (Q_OS_WIN)
Q_ASSERT( false );
qWarning() << "NO SUPPORT YET FOR LINUX BINARY RESOLVERS!";
return;
#endif
#ifdef Q_OS_MAC #ifdef Q_OS_MAC
// Platform-specific handling of resolver payload now. We know it's good // Platform-specific handling of resolver payload now. We know it's good
// Unzip the file. // Unzip the file.
@@ -884,7 +874,9 @@ extractBinaryResolver( const QString& zipFilename, QObject* receiver )
qDebug() << "OS X: Copying binary resolver from to:" << src << dest; qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
copyWithAuthentication( src, dest, receiver ); copyWithAuthentication( src, dest, receiver );
#elif defined(Q_OS_WIN)
return;
#elif defined(Q_OS_WIN) || defined(Q_OS_LINUX)
// We unzip directly to the target location, just like normal attica resolvers // We unzip directly to the target location, just like normal attica resolvers
Q_ASSERT( receiver ); Q_ASSERT( receiver );
if ( !receiver ) if ( !receiver )
@@ -897,19 +889,28 @@ extractBinaryResolver( const QString& zipFilename, QObject* receiver )
return; return;
const QDir resolverPath( extractScriptPayload( zipFilename, resolverId ) ); const QDir resolverPath( extractScriptPayload( zipFilename, resolverId ) );
#endif
#ifdef Q_OS_WIN
const QStringList files = resolverPath.entryList( QStringList() << "*.exe", QDir::Files ); const QStringList files = resolverPath.entryList( QStringList() << "*.exe", QDir::Files );
#elif defined(Q_OS_LINUX)
const QStringList files = resolverPath.entryList( QStringList() << "*_tomahawkresolver", QDir::Files );
#endif
qDebug() << "Found executables in unzipped binary resolver dir:" << files; qDebug() << "Found executables in unzipped binary resolver dir:" << files;
Q_ASSERT( files.size() == 1 ); Q_ASSERT( files.size() == 1 );
if ( files.size() < 1 ) if ( files.size() < 1 )
return; return;
const QString resolverToUse = resolverPath.absoluteFilePath( files.first() ); const QString resolverToUse = resolverPath.absoluteFilePath( files.first() );
QMetaObject::invokeMethod(receiver, "installSucceeded", Qt::DirectConnection, Q_ARG( QString, resolverToUse ) );
#ifdef Q_OS_LINUX
QProcess p;
p.start( "chmod", QStringList() << "744" << resolverToUse, QIODevice::ReadOnly );
p.waitForFinished( 6000 );
#endif #endif
// No support for binary resolvers on linux! Shouldn't even have been allowed to see/install.. QMetaObject::invokeMethod(receiver, "installSucceeded", Qt::DirectConnection, Q_ARG( QString, resolverToUse ) );
Q_ASSERT( false );
} }