1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-21 16:29:43 +01: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";
#elif defined(Q_OS_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
static QString s_resolverId = "spotify-linux";
static QString s_resolverId = "spotify-unknown";
#endif
Account*
@ -171,7 +175,7 @@ SpotifyAccount::checkForResolver()
const QDir path = QCoreApplication::applicationDirPath();
QFile file( path.absoluteFilePath( "spotify_tomahawkresolver" ) );
return file.exists();
#else if defined(Q_OS_WIN)
#elif defined(Q_OS_WIN)
QDir appDataDir = TomahawkUtils::appDataDir();
return appDataDir.exists( QString( "atticaresolvers/%1/spotify_tomahawkresolver.exe" ).arg( s_resolverId ) );
#endif

View File

@ -345,7 +345,11 @@ AtticaManager::binaryResolversList( BaseJob* j )
platform = "osx";
#elif defined(Q_OS_WIN)
platform = "win";
#endif
#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
foreach ( const Content& c, binaryResolvers )
{
@ -533,7 +537,7 @@ AtticaManager::payloadFetched()
else
{
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;
}
}

View File

@ -39,6 +39,7 @@
#include <QDir>
#include <QMutex>
#include <QCryptographicHash>
#include <QProcess>
#include <quazip.h>
#include <quazipfile.h>
@ -848,17 +849,6 @@ unzipFileInFolder( const QString &zipFileName, const QDir &folder )
void
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
// Platform-specific handling of resolver payload now. We know it's good
// Unzip the file.
@ -884,7 +874,9 @@ extractBinaryResolver( const QString& zipFilename, QObject* receiver )
qDebug() << "OS X: Copying binary resolver from to:" << src << dest;
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
Q_ASSERT( receiver );
if ( !receiver )
@ -897,19 +889,28 @@ extractBinaryResolver( const QString& zipFilename, QObject* receiver )
return;
const QDir resolverPath( extractScriptPayload( zipFilename, resolverId ) );
#endif
#ifdef Q_OS_WIN
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;
Q_ASSERT( files.size() == 1 );
if ( files.size() < 1 )
return;
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
// No support for binary resolvers on linux! Shouldn't even have been allowed to see/install..
Q_ASSERT( false );
QMetaObject::invokeMethod(receiver, "installSucceeded", Qt::DirectConnection, Q_ARG( QString, resolverToUse ) );
}