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