1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-11 00:24:12 +02:00

* Moved AtticaManager and all its deps into libtomahawk.

This commit is contained in:
Christian Muehlhaeuser
2011-09-12 02:52:52 +02:00
parent 2b947254d5
commit e7d78ea52e
43 changed files with 195 additions and 136 deletions

View File

@@ -112,14 +112,14 @@ macro_optional_find_package(QuaZip)
macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers autmatically. Will build internal copy instead." "http://quazip.sourceforge.net/" FALSE "" "") macro_log_feature(QuaZip_FOUND "QuaZip" "Provides support for extracting downloaded resolvers autmatically. Will build internal copy instead." "http://quazip.sourceforge.net/" FALSE "" "")
IF( NOT QuaZip_FOUND ) IF( NOT QuaZip_FOUND )
add_subdirectory( ${THIRDPARTY_DIR}/quazip ) add_subdirectory( ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip )
SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR} ) SET( QuaZip_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/libtomahawk/thirdparty )
SET( QuaZip_LIBRARY quazip ) SET( QuaZip_LIBRARY quazip )
SET( QuaZip_LIBRARIES ${QuaZip_LIBRARY} ) SET( QuaZip_LIBRARIES ${QuaZip_LIBRARY} )
SET( QuaZip_FOUND true ) SET( QuaZip_FOUND true )
# copy headers to build/quazip so we can use proper includes inside the code # copy headers to build/quazip so we can use proper includes inside the code
FILE( COPY ${CMAKE_SOURCE_DIR}/thirdparty/quazip/quazip/ DESTINATION ${CMAKE_BINARY_DIR}/quazip ) FILE( COPY ${CMAKE_SOURCE_DIR}/src/libtomahawk/thirdparty/quazip/quazip/ DESTINATION ${CMAKE_BINARY_DIR}/libtomahawk/thirdparty/quazip )
ENDIF() ENDIF()
# required # required

View File

@@ -1,6 +1,7 @@
SET( OS_SPECIFIC_LINK_LIBRARIES SET( OS_SPECIFIC_LINK_LIBRARIES
${OS_SPECIFIC_LINK_LIBRARIES} ${OS_SPECIFIC_LINK_LIBRARIES}
tomahawklib tomahawklib
breakpad_client
) )
FILE( GLOB _icons "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" ) FILE( GLOB _icons "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )

View File

@@ -37,9 +37,6 @@ ENDIF()
SET( tomahawkSources ${tomahawkSources} SET( tomahawkSources ${tomahawkSources}
web/api_v1.cpp web/api_v1.cpp
resolvers/scriptresolver.cpp
resolvers/qtscriptresolver.cpp
musicscanner.cpp musicscanner.cpp
shortcuthandler.cpp shortcuthandler.cpp
scanmanager.cpp scanmanager.cpp
@@ -85,9 +82,6 @@ SET( tomahawkHeaders ${tomahawkHeaders}
web/api_v1.h web/api_v1.h
resolvers/scriptresolver.h
resolvers/qtscriptresolver.h
musicscanner.h musicscanner.h
scanmanager.h scanmanager.h
shortcuthandler.h shortcuthandler.h
@@ -99,6 +93,12 @@ IF(LIBLASTFM_FOUND)
) )
ENDIF(LIBLASTFM_FOUND) ENDIF(LIBLASTFM_FOUND)
IF(LIBATTICA_FOUND)
SET( tomahawkSources ${tomahawkSources} GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
SET( tomahawkHeaders ${tomahawkHeaders} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
SET( tomahawkHeadersGui ${tomahawkHeadersGui} SET( tomahawkHeadersGui ${tomahawkHeadersGui}
sourcetree/sourcesmodel.h sourcetree/sourcesmodel.h
@@ -126,8 +126,6 @@ SET( tomahawkHeadersGui ${tomahawkHeadersGui}
resolversmodel.h resolversmodel.h
delegateconfigwrapper.h delegateconfigwrapper.h
tomahawkwindow.h tomahawkwindow.h
AtticaManager.h
) )
SET( tomahawkUI ${tomahawkUI} SET( tomahawkUI ${tomahawkUI}
@@ -159,13 +157,13 @@ INCLUDE_DIRECTORIES(
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${THIRDPARTY_DIR}/qtweetlib/qtweetlib/src ${THIRDPARTY_DIR}/qtweetlib/qtweetlib/src
${THIRDPARTY_DIR}/qtweetlib/tomahawk-custom ${THIRDPARTY_DIR}/qtweetlib/tomahawk-custom
${THIRDPARTY_DIR}/breakpad
${TAGLIB_INCLUDES} ${TAGLIB_INCLUDES}
${PHONON_INCLUDES} ${PHONON_INCLUDES}
${QJSON_INCLUDE_DIR} ${QJSON_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR} ${LIBECHONEST_INCLUDE_DIR}
${LIBECHONEST_INCLUDE_DIR}/.. ${LIBECHONEST_INCLUDE_DIR}/..
${QuaZip_INCLUDE_DIR}
) )
SET( OS_SPECIFIC_LINK_LIBRARIES "" ) SET( OS_SPECIFIC_LINK_LIBRARIES "" )
@@ -199,12 +197,6 @@ IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} ) INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
ENDIF(QCA2_FOUND) ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( tomahawkSources ${tomahawkSources} AtticaManager.cpp GetNewStuffDialog.cpp GetNewStuffDelegate.cpp GetNewStuffModel.cpp )
SET( tomahawkHeaders ${tomahawkHeaders} GetNewStuffDialog.h GetNewStuffDelegate.h GetNewStuffModel.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" ) kde4_add_app_icon( tomahawkSources "${CMAKE_SOURCE_DIR}/data/icons/tomahawk-icon-*.png" )
qt4_add_resources( RC_SRCS "../resources.qrc" ) qt4_add_resources( RC_SRCS "../resources.qrc" )
qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} ) qt4_wrap_cpp( tomahawkMoc ${tomahawkHeaders} )
@@ -244,16 +236,10 @@ ENDIF(LIBLASTFM_FOUND)
IF(GLOOX_FOUND) IF(GLOOX_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${GLOOX_LIBRARIES} ) SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${GLOOX_LIBRARIES} )
ENDIF(GLOOX_FOUND) ENDIF(GLOOX_FOUND)
IF(QCA2_FOUND) IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} ) SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND) ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
TARGET_LINK_LIBRARIES( tomahawk TARGET_LINK_LIBRARIES( tomahawk
${LINK_LIBRARIES} ${LINK_LIBRARIES}
${TOMAHAWK_LIBRARIES} ${TOMAHAWK_LIBRARIES}
@@ -265,7 +251,6 @@ TARGET_LINK_LIBRARIES( tomahawk
${QXTWEB_LIBRARIES} ${QXTWEB_LIBRARIES}
${QJSON_LIBRARIES} ${QJSON_LIBRARIES}
${TAGLIB_LIBRARIES} ${TAGLIB_LIBRARIES}
${QuaZip_LIBRARIES}
) )
IF( APPLE ) IF( APPLE )

View File

@@ -18,23 +18,26 @@
#include "AtticaManager.h" #include "AtticaManager.h"
#include "utils/logger.h"
#include "tomahawksettings.h"
#include "utils/tomahawkutils.h" #include "utils/tomahawkutils.h"
#include "tomahawksettings.h"
#include "pipeline.h"
#include <attica/downloaditem.h> #include <attica/downloaditem.h>
#include <quazip/quazip.h> #include <quazip/quazip.h>
#include <quazip/quazipfile.h> #include <quazip/quazipfile.h>
#include <QNetworkReply> #include <QNetworkReply>
#include <QtCore/qtemporaryfile.h> #include <QTemporaryFile>
#include <QDir> #include <QDir>
#include "tomahawkapp.h" #include <QTimer>
#include "utils/logger.h"
using namespace Attica; using namespace Attica;
AtticaManager* AtticaManager::s_instance = 0; AtticaManager* AtticaManager::s_instance = 0;
AtticaManager::AtticaManager( QObject* parent ) AtticaManager::AtticaManager( QObject* parent )
{ {
connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) ); connect( &m_manager, SIGNAL( providerAdded( Attica::Provider ) ), this, SLOT( providerAdded( Attica::Provider ) ) );
@@ -44,11 +47,13 @@ AtticaManager::AtticaManager( QObject* parent )
QTimer::singleShot( 0, this, SLOT( loadPixmapsFromCache() ) ); QTimer::singleShot( 0, this, SLOT( loadPixmapsFromCache() ) );
} }
AtticaManager::~AtticaManager() AtticaManager::~AtticaManager()
{ {
savePixmapsToCache(); savePixmapsToCache();
} }
void void
AtticaManager::loadPixmapsFromCache() AtticaManager::loadPixmapsFromCache()
{ {
@@ -65,6 +70,7 @@ AtticaManager::loadPixmapsFromCache()
} }
} }
void void
AtticaManager::savePixmapsToCache() AtticaManager::savePixmapsToCache()
{ {
@@ -86,6 +92,7 @@ AtticaManager::savePixmapsToCache()
} }
} }
QPixmap QPixmap
AtticaManager::iconForResolver( const Content& resolver ) AtticaManager::iconForResolver( const Content& resolver )
{ {
@@ -99,6 +106,7 @@ AtticaManager::resolvers() const
return m_resolvers; return m_resolvers;
} }
AtticaManager::ResolverState AtticaManager::ResolverState
AtticaManager::resolverState ( const Content& resolver ) const AtticaManager::resolverState ( const Content& resolver ) const
{ {
@@ -110,12 +118,14 @@ AtticaManager::resolverState ( const Content& resolver ) const
return m_resolverStates[ resolver.id() ]; return m_resolverStates[ resolver.id() ];
} }
bool bool
AtticaManager::resolversLoaded() const AtticaManager::resolversLoaded() const
{ {
return !m_resolvers.isEmpty(); return !m_resolvers.isEmpty();
} }
QString QString
AtticaManager::pathFromId( const QString& resolverId ) const AtticaManager::pathFromId( const QString& resolverId ) const
{ {
@@ -142,6 +152,7 @@ AtticaManager::providerAdded( const Provider& provider )
} }
} }
void void
AtticaManager::resolversList( BaseJob* j ) AtticaManager::resolversList( BaseJob* j )
{ {
@@ -163,6 +174,7 @@ AtticaManager::resolversList( BaseJob* j )
} }
} }
void void
AtticaManager::resolverIconFetched() AtticaManager::resolverIconFetched()
{ {
@@ -199,6 +211,7 @@ AtticaManager::installResolver( const Content& resolver )
job->start(); job->start();
} }
void void
AtticaManager::resolverDownloadFinished ( BaseJob* j ) AtticaManager::resolverDownloadFinished ( BaseJob* j )
{ {
@@ -217,10 +230,9 @@ AtticaManager::resolverDownloadFinished ( BaseJob* j )
{ {
tLog() << "Failed to do resolver download job!" << job->metadata().error(); tLog() << "Failed to do resolver download job!" << job->metadata().error();
} }
} }
void void
AtticaManager::payloadFetched() AtticaManager::payloadFetched()
{ {
@@ -245,7 +257,7 @@ AtticaManager::payloadFetched()
if ( !resolverPath.isEmpty() ) if ( !resolverPath.isEmpty() )
{ {
// Do the install / add to tomahawk // Do the install / add to tomahawk
TomahawkApp::instance()->addScriptResolver( resolverPath, true ); Tomahawk::Pipeline::instance()->addScriptResolver( resolverPath, true );
m_resolverStates[ resolverId ] = Installed; m_resolverStates[ resolverId ] = Installed;
TomahawkSettings::instance()->setAtticaResolverState( resolverId, Installed ); TomahawkSettings::instance()->setAtticaResolverState( resolverId, Installed );
emit resolverInstalled( resolverId ); emit resolverInstalled( resolverId );
@@ -258,6 +270,7 @@ AtticaManager::payloadFetched()
} }
} }
QString QString
AtticaManager::extractPayload( const QString& filename, const QString& resolverId ) const AtticaManager::extractPayload( const QString& filename, const QString& resolverId ) const
{ {
@@ -327,6 +340,7 @@ AtticaManager::extractPayload( const QString& filename, const QString& resolverI
return QString( QFile( resolverDir.absolutePath() + "/contents/code/main.js" ).fileName() ); return QString( QFile( resolverDir.absolutePath() + "/contents/code/main.js" ).fileName() );
} }
void void
AtticaManager::uninstallResolver( const QString& pathToResolver ) AtticaManager::uninstallResolver( const QString& pathToResolver )
{ {
@@ -357,13 +371,14 @@ AtticaManager::uninstallResolver( const Content& resolver )
emit resolverUninstalled( resolver.id() ); emit resolverUninstalled( resolver.id() );
emit resolverStateChanged( resolver.id() ); emit resolverStateChanged( resolver.id() );
TomahawkApp::instance()->removeScriptResolver( pathFromId( resolver.id() ) ); Tomahawk::Pipeline::instance()->removeScriptResolver( pathFromId( resolver.id() ) );
m_resolverStates[ resolver.id() ] = Uninstalled; m_resolverStates[ resolver.id() ] = Uninstalled;
TomahawkSettings::instance()->setAtticaResolverState( resolver.id(), Uninstalled ); TomahawkSettings::instance()->setAtticaResolverState( resolver.id(), Uninstalled );
doResolverRemove( resolver.id() ); doResolverRemove( resolver.id() );
} }
void void
AtticaManager::doResolverRemove( const QString& id ) const AtticaManager::doResolverRemove( const QString& id ) const
{ {

View File

@@ -24,6 +24,8 @@
#include <QObject> #include <QObject>
#include <QHash> #include <QHash>
#include "dllmacro.h"
#ifdef LIBATTICA_FOUND #ifdef LIBATTICA_FOUND
#include <attica/provider.h> #include <attica/provider.h>
#include <attica/providermanager.h> #include <attica/providermanager.h>
@@ -31,7 +33,7 @@
#include <QPixmap> #include <QPixmap>
#endif #endif
class AtticaManager : public QObject class DLLEXPORT AtticaManager : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
@@ -46,7 +48,8 @@ public:
typedef QHash< QString, AtticaManager::ResolverState > StateHash; typedef QHash< QString, AtticaManager::ResolverState > StateHash;
static AtticaManager* instance() { static AtticaManager* instance()
{
if ( !s_instance ) if ( !s_instance )
s_instance = new AtticaManager(); s_instance = new AtticaManager();

View File

@@ -159,6 +159,9 @@ set( libSources
playlist/dynamic/database/DatabaseControl.cpp playlist/dynamic/database/DatabaseControl.cpp
playlist/dynamic/database/DatabaseGenerator.cpp playlist/dynamic/database/DatabaseGenerator.cpp
resolvers/scriptresolver.cpp
resolvers/qtscriptresolver.cpp
network/bufferiodevice.cpp network/bufferiodevice.cpp
network/msgprocessor.cpp network/msgprocessor.cpp
network/streamconnection.cpp network/streamconnection.cpp
@@ -232,6 +235,7 @@ set( libHeaders
globalactionmanager.h globalactionmanager.h
contextmenu.h contextmenu.h
dropjob.h dropjob.h
AtticaManager.h
artist.h artist.h
album.h album.h
@@ -372,6 +376,9 @@ set( libHeaders
playlist/dynamic/database/DatabaseControl.h playlist/dynamic/database/DatabaseControl.h
playlist/dynamic/database/DatabaseGenerator.h playlist/dynamic/database/DatabaseGenerator.h
resolvers/scriptresolver.h
resolvers/qtscriptresolver.h
utils/widgetdragfilter.h utils/widgetdragfilter.h
utils/xspfloader.h utils/xspfloader.h
utils/xspfgenerator.h utils/xspfgenerator.h
@@ -456,9 +463,19 @@ include_directories( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR}/.
${LIBPORTFWD_INCLUDE_DIR} ${LIBPORTFWD_INCLUDE_DIR}
${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb ${THIRDPARTY_DIR}/qxt/qxtweb-standalone/qxtweb
${QuaZip_INCLUDE_DIR}
) )
IF(QCA2_FOUND)
INCLUDE_DIRECTORIES( ${QCA2_INCLUDE_DIR} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( libSources ${libSources} AtticaManager.cpp )
SET( libHeaders ${libHeaders} AtticaManager.h )
INCLUDE_DIRECTORIES( ${LIBATTICA_INCLUDE_DIR} )
ENDIF(LIBATTICA_FOUND)
IF( UNIX AND NOT APPLE ) IF( UNIX AND NOT APPLE )
SET( libSources ${libSources} SET( libSources ${libSources}
infosystem/infoplugins/unix/mprispluginrootadaptor.cpp infosystem/infoplugins/unix/mprispluginrootadaptor.cpp
@@ -533,9 +550,17 @@ qt4_wrap_cpp( libMoc ${libHeaders} )
SET( libSources ${libSources} ${libUI_H} ${libHeaders_NoMOC} ) SET( libSources ${libSources} ${libUI_H} ${libHeaders_NoMOC} )
add_library( tomahawklib SHARED ${libSources} ${libMoc} ) ADD_LIBRARY( tomahawklib SHARED ${libSources} ${libMoc} )
target_link_libraries( tomahawklib IF(QCA2_FOUND)
SET(LINK_LIBRARIES ${LINK_LIBRARIES} ${QCA2_LIBRARIES} )
ENDIF(QCA2_FOUND)
IF(LIBATTICA_FOUND)
SET( LINK_LIBRARIES ${LINK_LIBRARIES} ${LIBATTICA_LIBRARIES} ${QuaZip_LIBRARIES} )
ENDIF(LIBATTICA_FOUND)
TARGET_LINK_LIBRARIES( tomahawklib
# Thirdparty shipped with tomahawk # Thirdparty shipped with tomahawk
${LIBPORTFWD_LIBRARIES} ${LIBPORTFWD_LIBRARIES}

View File

@@ -22,6 +22,8 @@
#include "functimeout.h" #include "functimeout.h"
#include "database/database.h" #include "database/database.h"
#include "resolvers/scriptresolver.h"
#include "resolvers/qtscriptresolver.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -59,6 +61,10 @@ Pipeline::Pipeline( QObject* parent )
Pipeline::~Pipeline() Pipeline::~Pipeline()
{ {
m_running = false; m_running = false;
// stop script resolvers
qDeleteAll( m_scriptResolvers );
m_scriptResolvers.clear();
} }
@@ -108,6 +114,67 @@ Pipeline::addResolver( Resolver* r )
} }
Tomahawk::ExternalResolver*
Pipeline::addScriptResolver( const QString& path, bool start )
{
ExternalResolver* res = 0;
const QFileInfo fi( path );
if ( fi.suffix() == "js" || fi.suffix() == "script" )
res = new QtScriptResolver( path );
else
res = new ScriptResolver( path );
m_scriptResolvers << res;
if ( start )
res->start();
return res;
}
void
Pipeline::stopScriptResolver( const QString& path )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == path )
res->stop();
}
}
void
Pipeline::removeScriptResolver( const QString& scriptPath )
{
ExternalResolver* r = 0;
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
r = res;
}
m_scriptResolvers.removeAll( r );
if ( r )
{
r->stop();
connect( r, SIGNAL( stopped() ), r, SLOT( deleteLater() ) );
}
}
ExternalResolver*
Pipeline::resolverForPath( const QString& scriptPath )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
return res;
}
return 0;
}
void void
Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized, bool temporaryQuery ) Pipeline::resolve( const QList<query_ptr>& qlist, bool prioritized, bool temporaryQuery )
{ {

View File

@@ -52,6 +52,12 @@ public:
void reportResults( QID qid, const QList< result_ptr >& results ); void reportResults( QID qid, const QList< result_ptr >& results );
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
void stopScriptResolver( const QString& scriptPath );
void removeScriptResolver( const QString& scriptPath );
QList< Tomahawk::ExternalResolver* > scriptResolvers() const { return m_scriptResolvers; }
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
void addResolver( Resolver* r ); void addResolver( Resolver* r );
void removeResolver( Resolver* r ); void removeResolver( Resolver* r );
@@ -96,6 +102,7 @@ private:
int decQIDState( const Tomahawk::query_ptr& query ); int decQIDState( const Tomahawk::query_ptr& query );
QList< Resolver* > m_resolvers; QList< Resolver* > m_resolvers;
QList< Tomahawk::ExternalResolver* > m_scriptResolvers;
QMap< QID, bool > m_qidsTimeout; QMap< QID, bool > m_qidsTimeout;
QMap< QID, unsigned int > m_qidsState; QMap< QID, unsigned int > m_qidsState;

View File

@@ -36,9 +36,11 @@
#include <QtCrypto> #include <QtCrypto>
#endif #endif
#include "dllmacro.h"
class QtScriptResolver; class QtScriptResolver;
class QtScriptResolverHelper : public QObject class DLLEXPORT QtScriptResolverHelper : public QObject
{ {
Q_OBJECT Q_OBJECT
@@ -46,10 +48,10 @@ public:
QtScriptResolverHelper( const QString& scriptPath, QtScriptResolver* parent ); QtScriptResolverHelper( const QString& scriptPath, QtScriptResolver* parent );
void setResolverConfig( const QVariantMap& config ); void setResolverConfig( const QVariantMap& config );
// Return a HMAC (md5) signature of the input text with the desired key // Return a HMAC (md5) signature of the input text with the desired key
Q_INVOKABLE QString hmac( const QByteArray& key, const QByteArray& input ); Q_INVOKABLE QString hmac( const QByteArray& key, const QByteArray& input );
Q_INVOKABLE QString md5( const QByteArray& input ); Q_INVOKABLE QString md5( const QByteArray& input );
public slots: public slots:
QByteArray readRaw( const QString& fileName ); QByteArray readRaw( const QString& fileName );
QString readBase64( const QString& fileName ); QString readBase64( const QString& fileName );
@@ -72,7 +74,7 @@ private:
#endif #endif
}; };
class ScriptEngine : public QWebPage class DLLEXPORT ScriptEngine : public QWebPage
{ {
Q_OBJECT Q_OBJECT
@@ -110,7 +112,7 @@ private:
}; };
class QtScriptResolver : public Tomahawk::ExternalResolver class DLLEXPORT QtScriptResolver : public Tomahawk::ExternalResolver
{ {
Q_OBJECT Q_OBJECT

View File

@@ -30,8 +30,11 @@
#include "result.h" #include "result.h"
#include "source.h" #include "source.h"
#include "dllmacro.h"
class QWidget; class QWidget;
class ScriptResolver : public Tomahawk::ExternalResolver
class DLLEXPORT ScriptResolver : public Tomahawk::ExternalResolver
{ {
Q_OBJECT Q_OBJECT

View File

@@ -6,6 +6,8 @@ find_package(Qt4 REQUIRED)
set(QT_USE_QTGUI false) set(QT_USE_QTGUI false)
include(${QT_USE_FILE}) include(${QT_USE_FILE})
ADD_DEFINITIONS(-fPIC)
set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)") set(LIB_SUFFIX "" CACHE STRING "Define suffix of directory name (32/64)")
set(LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name" FORCE) set(LIB_DESTINATION "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}" CACHE STRING "Library directory name" FORCE)

View File

@@ -24,7 +24,6 @@
CheckDirModel::CheckDirModel( QWidget* parent ) CheckDirModel::CheckDirModel( QWidget* parent )
: QDirModel( parent ) : QDirModel( parent )
{ {
setLazyChildCount( false );
} }

View File

@@ -28,10 +28,32 @@
static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long ); static pascal OSErr appleEventHandler( const AppleEvent*, AppleEvent*, long );
#endif #endif
#ifdef Q_OS_LINUX
#include "client/linux/handler/exception_handler.h"
static bool
dumpCallback( const char* dump_path, const char* minidump_id, void* /* context */, bool succeeded )
{
printf( "Tomahawk crashed - Dump path: %s/%s.dmp\n", dump_path, minidump_id );
return succeeded;
}
void
crash()
{
volatile int* a = (int*)(NULL);
*a = 1;
}
#endif
int int
main( int argc, char *argv[] ) main( int argc, char *argv[] )
{ {
#ifdef Q_OS_LINUX
google_breakpad::ExceptionHandler eh( "/tmp", NULL, dumpCallback, NULL, true );
#endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// Do Mac specific startup to get media keys working. // Do Mac specific startup to get media keys working.
// This must go before QApplication initialisation. // This must go before QApplication initialisation.

View File

@@ -23,6 +23,7 @@
#include "tomahawksettings.h" #include "tomahawksettings.h"
#include "tomahawkapp.h" #include "tomahawkapp.h"
#include "resolver.h" #include "resolver.h"
#include "pipeline.h"
#include "config.h" #include "config.h"
#include "utils/logger.h" #include "utils/logger.h"
@@ -46,7 +47,7 @@ ResolversModel::data( const QModelIndex& index, int role ) const
if( !index.isValid() || !hasIndex( index.row(), index.column(), QModelIndex() ) ) if( !index.isValid() || !hasIndex( index.row(), index.column(), QModelIndex() ) )
return QVariant(); return QVariant();
Tomahawk::ExternalResolver* res = TomahawkApp::instance()->scriptResolvers().at( index.row() ); Tomahawk::ExternalResolver* res = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() );
switch( role ) switch( role )
{ {
case Qt::DisplayRole: case Qt::DisplayRole:
@@ -73,7 +74,7 @@ ResolversModel::setData( const QModelIndex& index, const QVariant& value, int ro
if ( !hasIndex( index.row(), index.column(), QModelIndex() ) ) if ( !hasIndex( index.row(), index.column(), QModelIndex() ) )
return false; return false;
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->scriptResolvers().at( index.row() ); Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->scriptResolvers().at( index.row() );
if ( r && r->error() == Tomahawk::ExternalResolver::FileNotFound ) // give it a shot to see if the user manually fixed paths if ( r && r->error() == Tomahawk::ExternalResolver::FileNotFound ) // give it a shot to see if the user manually fixed paths
{ {
r->reload(); r->reload();
@@ -109,7 +110,7 @@ int
ResolversModel::rowCount( const QModelIndex& parent ) const ResolversModel::rowCount( const QModelIndex& parent ) const
{ {
Q_UNUSED( parent ); Q_UNUSED( parent );
return APP->scriptResolvers().count(); return Tomahawk::Pipeline::instance()->scriptResolvers().count();
} }
int int
@@ -131,7 +132,7 @@ ResolversModel::addResolver( const QString& resolver, bool enable )
{ {
const int count = rowCount( QModelIndex() ); const int count = rowCount( QModelIndex() );
beginInsertRows( QModelIndex(), count, count ); beginInsertRows( QModelIndex(), count, count );
Tomahawk::ExternalResolver* res = APP->addScriptResolver( resolver, enable ); Tomahawk::ExternalResolver* res = Tomahawk::Pipeline::instance()->addScriptResolver( resolver, enable );
connect( res, SIGNAL( changed() ), this, SLOT( resolverChanged() ) ); connect( res, SIGNAL( changed() ), this, SLOT( resolverChanged() ) );
endInsertRows(); endInsertRows();
} }
@@ -140,10 +141,10 @@ void
ResolversModel::atticaResolverInstalled( const QString& resolverId ) ResolversModel::atticaResolverInstalled( const QString& resolverId )
{ {
#ifdef LIBATTICA_FOUND #ifdef LIBATTICA_FOUND
Tomahawk::ExternalResolver* r = APP->resolverForPath( AtticaManager::instance()->pathFromId( resolverId ) ); Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( AtticaManager::instance()->pathFromId( resolverId ) );
if ( !r ) if ( !r )
return; return;
const int idx = APP->scriptResolvers().indexOf( r ); const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( r );
if ( idx >= 0 ) if ( idx >= 0 )
{ {
beginInsertRows( QModelIndex(), idx, idx ); beginInsertRows( QModelIndex(), idx, idx );
@@ -156,12 +157,12 @@ ResolversModel::atticaResolverInstalled( const QString& resolverId )
void void
ResolversModel::removeResolver( const QString& resolver ) ResolversModel::removeResolver( const QString& resolver )
{ {
const int idx = APP->scriptResolvers().indexOf( APP->resolverForPath( resolver ) ); const int idx = Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( Tomahawk::Pipeline::instance()->resolverForPath( resolver ) );
if ( idx < 0 ) if ( idx < 0 )
return; return;
beginRemoveRows( QModelIndex(), idx, idx ); beginRemoveRows( QModelIndex(), idx, idx );
APP->removeScriptResolver( resolver ); Tomahawk::Pipeline::instance()->removeScriptResolver( resolver );
endRemoveRows(); endRemoveRows();
} }
@@ -171,10 +172,10 @@ ResolversModel::resolverChanged()
Tomahawk::ExternalResolver* res = qobject_cast< Tomahawk::ExternalResolver* >( sender() ); Tomahawk::ExternalResolver* res = qobject_cast< Tomahawk::ExternalResolver* >( sender() );
Q_ASSERT( res ); Q_ASSERT( res );
if ( APP->scriptResolvers().contains( res ) ) if ( Tomahawk::Pipeline::instance()->scriptResolvers().contains( res ) )
{ {
qDebug() << "Got resolverChanged signal, does it have a config UI yet?" << res->configUI(); qDebug() << "Got resolverChanged signal, does it have a config UI yet?" << res->configUI();
const QModelIndex idx = index( APP->scriptResolvers().indexOf( res ), 0, QModelIndex() ); const QModelIndex idx = index( Tomahawk::Pipeline::instance()->scriptResolvers().indexOf( res ), 0, QModelIndex() );
emit dataChanged( idx, idx ); emit dataChanged( idx, idx );
} }
} }
@@ -199,13 +200,13 @@ ResolversModel::addInstalledResolvers()
if ( fileName.contains( "_tomahawkresolver" ) ) { if ( fileName.contains( "_tomahawkresolver" ) ) {
const QString path = pluginDir.absoluteFilePath( fileName ); const QString path = pluginDir.absoluteFilePath( fileName );
bool found = false; bool found = false;
foreach ( Tomahawk::ExternalResolver* res, APP->scriptResolvers() ) foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() )
{ {
if ( res->filePath() == path ) if ( res->filePath() == path )
found = true; found = true;
} }
if ( !found ) { if ( !found ) {
APP->addScriptResolver( path, false ); Tomahawk::Pipeline::instance()->addScriptResolver( path, false );
} }
} }
} }
@@ -216,7 +217,7 @@ void
ResolversModel::saveScriptResolvers() ResolversModel::saveScriptResolvers()
{ {
QStringList enabled, all; QStringList enabled, all;
foreach ( Tomahawk::ExternalResolver* res, APP->scriptResolvers() ) foreach ( Tomahawk::ExternalResolver* res, Tomahawk::Pipeline::instance()->scriptResolvers() )
{ {
all << res->filePath(); all << res->filePath();
if ( res->running() ) if ( res->running() )

View File

@@ -41,6 +41,7 @@
#include "sip/SipHandler.h" #include "sip/SipHandler.h"
#include "database/database.h" #include "database/database.h"
#include "scanmanager.h" #include "scanmanager.h"
#include "pipeline.h"
#include "resolverconfigdelegate.h" #include "resolverconfigdelegate.h"
#include "resolversmodel.h" #include "resolversmodel.h"
#include "delegateconfigwrapper.h" #include "delegateconfigwrapper.h"
@@ -319,7 +320,7 @@ SettingsDialog::createIcons()
ui->listWidget->setMaximumWidth( maxlen + 8 ); ui->listWidget->setMaximumWidth( maxlen + 8 );
#endif #endif
connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem* ,QListWidgetItem* ) ), this, SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) ); connect( ui->listWidget, SIGNAL( currentItemChanged( QListWidgetItem*, QListWidgetItem* ) ), SLOT( changePage( QListWidgetItem*, QListWidgetItem* ) ) );
} }
@@ -588,7 +589,7 @@ SettingsDialog::getMoreResolversFinished( int ret )
void void
SettingsDialog::openResolverConfig( const QString& resolver ) SettingsDialog::openResolverConfig( const QString& resolver )
{ {
Tomahawk::ExternalResolver* r = TomahawkApp::instance()->resolverForPath( resolver ); Tomahawk::ExternalResolver* r = Tomahawk::Pipeline::instance()->resolverForPath( resolver );
if( r && r->configUI() ) if( r && r->configUI() )
{ {
#ifndef Q_WS_MAC #ifndef Q_WS_MAC

View File

@@ -44,8 +44,6 @@
#include "playlist/dynamic/echonest/EchonestGenerator.h" #include "playlist/dynamic/echonest/EchonestGenerator.h"
#include "playlist/dynamic/database/DatabaseGenerator.h" #include "playlist/dynamic/database/DatabaseGenerator.h"
#include "web/api_v1.h" #include "web/api_v1.h"
#include "resolvers/scriptresolver.h"
#include "resolvers/qtscriptresolver.h"
#include "sourcelist.h" #include "sourcelist.h"
#include "shortcuthandler.h" #include "shortcuthandler.h"
#include "scanmanager.h" #include "scanmanager.h"
@@ -268,10 +266,6 @@ TomahawkApp::~TomahawkApp()
{ {
tLog() << "Shutting down Tomahawk..."; tLog() << "Shutting down Tomahawk...";
// stop script resolvers
qDeleteAll( m_scriptResolvers );
m_scriptResolvers.clear();
if ( !m_servent.isNull() ) if ( !m_servent.isNull() )
delete m_servent.data(); delete m_servent.data();
if ( !m_scanManager.isNull() ) if ( !m_scanManager.isNull() )
@@ -447,76 +441,16 @@ TomahawkApp::initPipeline()
{ {
// setup resolvers for local content, and (cached) remote collection content // setup resolvers for local content, and (cached) remote collection content
Pipeline::instance()->addResolver( new DatabaseResolver( 100 ) ); Pipeline::instance()->addResolver( new DatabaseResolver( 100 ) );
// load script resolvers // load script resolvers
QStringList enabled = TomahawkSettings::instance()->enabledScriptResolvers(); QStringList enabled = TomahawkSettings::instance()->enabledScriptResolvers();
foreach ( QString resolver, TomahawkSettings::instance()->allScriptResolvers() ) foreach ( QString resolver, TomahawkSettings::instance()->allScriptResolvers() )
{ {
const bool enable = enabled.contains( resolver ); const bool enable = enabled.contains( resolver );
addScriptResolver( resolver, enable ); Pipeline::instance()->addScriptResolver( resolver, enable );
} }
} }
Tomahawk::ExternalResolver*
TomahawkApp::addScriptResolver( const QString& path, bool start )
{
const QFileInfo fi( path );
ExternalResolver* res = 0;
if ( fi.suffix() == "js" || fi.suffix() == "script" )
res = new QtScriptResolver( path );
else
res = new ScriptResolver( path );
m_scriptResolvers << res;
if ( start )
res->start();
return res;
}
void
TomahawkApp::stopScriptResolver( const QString& path )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == path )
res->stop();
}
}
void
TomahawkApp::removeScriptResolver( const QString& scriptPath )
{
ExternalResolver* r = 0;
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
r = res;
}
m_scriptResolvers.removeAll( r );
if ( r )
{
r->stop();
connect( r, SIGNAL( stopped() ), r, SLOT( deleteLater() ) );
}
}
Tomahawk::ExternalResolver*
TomahawkApp::resolverForPath( const QString& scriptPath )
{
foreach ( ExternalResolver* res, m_scriptResolvers )
{
if ( res->filePath() == scriptPath )
return res;
}
return 0;
}
void void
TomahawkApp::initLocalCollection() TomahawkApp::initLocalCollection()
{ {

View File

@@ -90,13 +90,6 @@ public:
TomahawkWindow* mainWindow() const { return m_mainwindow; } TomahawkWindow* mainWindow() const { return m_mainwindow; }
#endif #endif
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
void stopScriptResolver( const QString& scriptPath );
void removeScriptResolver( const QString& scriptPath );
QList< Tomahawk::ExternalResolver* > scriptResolvers() const { return m_scriptResolvers; }
Tomahawk::ExternalResolver* resolverForPath( const QString& scriptPath );
// PlatformInterface // PlatformInterface
virtual bool loadUrl( const QString& url ); virtual bool loadUrl( const QString& url );
@@ -123,7 +116,6 @@ private:
void loadPlugins(); void loadPlugins();
QList<Tomahawk::collection_ptr> m_collections; QList<Tomahawk::collection_ptr> m_collections;
QList<Tomahawk::ExternalResolver*> m_scriptResolvers;
QWeakPointer<Database> m_database; QWeakPointer<Database> m_database;
QWeakPointer<ScanManager> m_scanManager; QWeakPointer<ScanManager> m_scanManager;