mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-06 22:26:32 +02:00
ifdefs--: make pipeline ready for tomahawk-core
This commit is contained in:
@@ -114,22 +114,29 @@ Pipeline::addResolver( Resolver* r )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Pipeline::addExternalResolverFactory(boost::function< ExternalResolver*(QString) > resolverFactory)
|
||||||
|
{
|
||||||
|
m_resolverFactories << resolverFactory;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Tomahawk::ExternalResolver*
|
Tomahawk::ExternalResolver*
|
||||||
Pipeline::addScriptResolver( const QString& path, bool start )
|
Pipeline::addScriptResolver( const QString& path, bool start )
|
||||||
{
|
{
|
||||||
ExternalResolver* res = 0;
|
ExternalResolver* res = 0;
|
||||||
#ifndef ENABLE_HEADLESS
|
|
||||||
const QFileInfo fi( path );
|
|
||||||
|
|
||||||
if ( fi.suffix() == "js" || fi.suffix() == "script" )
|
Q_FOREACH(boost::function<Tomahawk::ExternalResolver*(QString)> factory, m_resolverFactories)
|
||||||
res = new QtScriptResolver( path );
|
{
|
||||||
else
|
res = factory( path );
|
||||||
res = new ScriptResolver( path );
|
|
||||||
|
if( !res )
|
||||||
|
continue;
|
||||||
|
|
||||||
m_scriptResolvers << res;
|
m_scriptResolvers << res;
|
||||||
if ( start )
|
if ( start )
|
||||||
res->start();
|
res->start();
|
||||||
#endif
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@@ -19,14 +19,16 @@
|
|||||||
#ifndef PIPELINE_H
|
#ifndef PIPELINE_H
|
||||||
#define PIPELINE_H
|
#define PIPELINE_H
|
||||||
|
|
||||||
|
#include "typedefs.h"
|
||||||
|
#include "query.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
#include "typedefs.h"
|
#include <boost/function.hpp>
|
||||||
#include "query.h"
|
|
||||||
|
|
||||||
#include "dllmacro.h"
|
#include "dllmacro.h"
|
||||||
|
|
||||||
@@ -50,6 +52,7 @@ public:
|
|||||||
|
|
||||||
void reportResults( QID qid, const QList< result_ptr >& results );
|
void reportResults( QID qid, const QList< result_ptr >& results );
|
||||||
|
|
||||||
|
void addExternalResolverFactory( boost::function<Tomahawk::ExternalResolver*(QString)> resolverFactory );
|
||||||
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
|
Tomahawk::ExternalResolver* addScriptResolver( const QString& scriptPath, bool start = true );
|
||||||
void stopScriptResolver( const QString& scriptPath );
|
void stopScriptResolver( const QString& scriptPath );
|
||||||
void removeScriptResolver( const QString& scriptPath );
|
void removeScriptResolver( const QString& scriptPath );
|
||||||
@@ -101,7 +104,7 @@ private:
|
|||||||
|
|
||||||
QList< Resolver* > m_resolvers;
|
QList< Resolver* > m_resolvers;
|
||||||
QList< Tomahawk::ExternalResolver* > m_scriptResolvers;
|
QList< Tomahawk::ExternalResolver* > m_scriptResolvers;
|
||||||
|
QList< boost::function<Tomahawk::ExternalResolver*(QString)> > m_resolverFactories;
|
||||||
QMap< QID, bool > m_qidsTimeout;
|
QMap< QID, bool > m_qidsTimeout;
|
||||||
QMap< QID, unsigned int > m_qidsState;
|
QMap< QID, unsigned int > m_qidsState;
|
||||||
QMap< QID, query_ptr > m_qids;
|
QMap< QID, query_ptr > m_qids;
|
||||||
|
@@ -194,11 +194,9 @@ void
|
|||||||
ScriptEngine::javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID )
|
ScriptEngine::javaScriptConsoleMessage( const QString& message, int lineNumber, const QString& sourceID )
|
||||||
{
|
{
|
||||||
tLog() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID;
|
tLog() << "JAVASCRIPT:" << m_scriptPath << message << lineNumber << sourceID;
|
||||||
#ifndef ENABLE_HEADLESS
|
|
||||||
#ifdef DEBUG_BUILD
|
#ifdef DEBUG_BUILD
|
||||||
QMessageBox::critical( 0, "Script Resolver Error", QString( "%1 %2 %3 %4" ).arg( m_scriptPath ).arg( message ).arg( lineNumber ).arg( sourceID ) );
|
QMessageBox::critical( 0, "Script Resolver Error", QString( "%1 %2 %3 %4" ).arg( m_scriptPath ).arg( message ).arg( lineNumber ).arg( sourceID ) );
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -232,6 +230,22 @@ QtScriptResolver::~QtScriptResolver()
|
|||||||
delete m_engine;
|
delete m_engine;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Tomahawk::ExternalResolver* QtScriptResolver::factory( const QString& scriptPath )
|
||||||
|
{
|
||||||
|
ExternalResolver* res = 0;
|
||||||
|
|
||||||
|
const QFileInfo fi( scriptPath );
|
||||||
|
if ( fi.suffix() == "js" || fi.suffix() == "script" )
|
||||||
|
{
|
||||||
|
res = new QtScriptResolver( scriptPath );
|
||||||
|
tLog() << Q_FUNC_INFO << scriptPath << "Loaded.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool
|
bool
|
||||||
QtScriptResolver::running() const
|
QtScriptResolver::running() const
|
||||||
{
|
{
|
||||||
|
@@ -123,6 +123,7 @@ friend class ::QtScriptResolverHelper;
|
|||||||
public:
|
public:
|
||||||
explicit QtScriptResolver( const QString& scriptPath );
|
explicit QtScriptResolver( const QString& scriptPath );
|
||||||
virtual ~QtScriptResolver();
|
virtual ~QtScriptResolver();
|
||||||
|
static ExternalResolver* factory( const QString& scriptPath );
|
||||||
|
|
||||||
virtual QString name() const { return m_name; }
|
virtual QString name() const { return m_name; }
|
||||||
virtual unsigned int weight() const { return m_weight; }
|
virtual unsigned int weight() const { return m_weight; }
|
||||||
|
@@ -79,6 +79,22 @@ ScriptResolver::~ScriptResolver()
|
|||||||
delete m_configWidget.data();
|
delete m_configWidget.data();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tomahawk::ExternalResolver*
|
||||||
|
ScriptResolver::factory(const QString& exe)
|
||||||
|
{
|
||||||
|
ExternalResolver* res = 0;
|
||||||
|
|
||||||
|
const QFileInfo fi( exe );
|
||||||
|
if ( fi.suffix() != "js" && fi.suffix() != "script" )
|
||||||
|
{
|
||||||
|
res = new ScriptResolver( exe );
|
||||||
|
tLog() << Q_FUNC_INFO << exe << "Loaded.";
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ScriptResolver::start()
|
ScriptResolver::start()
|
||||||
{
|
{
|
||||||
|
@@ -39,6 +39,7 @@ Q_OBJECT
|
|||||||
public:
|
public:
|
||||||
explicit ScriptResolver( const QString& exe );
|
explicit ScriptResolver( const QString& exe );
|
||||||
virtual ~ScriptResolver();
|
virtual ~ScriptResolver();
|
||||||
|
static ExternalResolver* factory( const QString& exe );
|
||||||
|
|
||||||
virtual QString name() const { return m_name; }
|
virtual QString name() const { return m_name; }
|
||||||
virtual unsigned int weight() const { return m_weight; }
|
virtual unsigned int weight() const { return m_weight; }
|
||||||
|
@@ -65,6 +65,8 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
|
#include "resolvers/qtscriptresolver.h"
|
||||||
|
#include "resolvers/scriptresolver.h"
|
||||||
#include "utils/spotifyparser.h"
|
#include "utils/spotifyparser.h"
|
||||||
#include "AtticaManager.h"
|
#include "AtticaManager.h"
|
||||||
#include "tomahawkwindow.h"
|
#include "tomahawkwindow.h"
|
||||||
@@ -164,9 +166,15 @@ TomahawkApp::init()
|
|||||||
|
|
||||||
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
|
m_audioEngine = QWeakPointer<AudioEngine>( new AudioEngine );
|
||||||
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
m_scanManager = QWeakPointer<ScanManager>( new ScanManager( this ) );
|
||||||
|
|
||||||
|
// init pipeline and resolver factories
|
||||||
new Pipeline( this );
|
new Pipeline( this );
|
||||||
|
|
||||||
#ifndef ENABLE_HEADLESS
|
#ifndef ENABLE_HEADLESS
|
||||||
|
Pipeline::instance()->addExternalResolverFactory( boost::bind( &QtScriptResolver::factory, _1 ) );
|
||||||
|
Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1 ) );
|
||||||
|
|
||||||
|
|
||||||
new ActionCollection( this );
|
new ActionCollection( this );
|
||||||
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
connect( ActionCollection::instance()->getAction( "quit" ), SIGNAL( triggered() ), SLOT( quit() ), Qt::UniqueConnection );
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user