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

Rename QtScriptResolver to JSResolver because JS != QtScript.

This commit is contained in:
Teo Mrnjavac
2013-05-23 10:23:23 +02:00
parent 2ec10fc80f
commit 68aa51b6d5
7 changed files with 77 additions and 77 deletions

View File

@@ -66,7 +66,7 @@
#include "utils/TomahawkCache.h" #include "utils/TomahawkCache.h"
#ifndef ENABLE_HEADLESS #ifndef ENABLE_HEADLESS
#include "resolvers/QtScriptResolver.h" #include "resolvers/JSResolver.h"
#include "resolvers/ScriptResolver.h" #include "resolvers/ScriptResolver.h"
#include "utils/SpotifyParser.h" #include "utils/SpotifyParser.h"
#include "AtticaManager.h" #include "AtticaManager.h"
@@ -203,7 +203,7 @@ TomahawkApp::init()
m_scanManager = QPointer<ScanManager>( new ScanManager( this ) ); m_scanManager = QPointer<ScanManager>( new ScanManager( this ) );
#ifndef ENABLE_HEADLESS #ifndef ENABLE_HEADLESS
Pipeline::instance()->addExternalResolverFactory( boost::bind( &QtScriptResolver::factory, _1, _2 ) ); Pipeline::instance()->addExternalResolverFactory( boost::bind( &JSResolver::factory, _1, _2 ) );
Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2 ) ); Pipeline::instance()->addExternalResolverFactory( boost::bind( &ScriptResolver::factory, _1, _2 ) );
new ActionCollection( this ); new ActionCollection( this );

View File

@@ -93,7 +93,7 @@ set( libGuiSources
resolvers/ExternalResolverGui.cpp resolvers/ExternalResolverGui.cpp
resolvers/ScriptResolver.cpp resolvers/ScriptResolver.cpp
resolvers/QtScriptResolver.cpp resolvers/JSResolver.cpp
utils/ImageRegistry.cpp utils/ImageRegistry.cpp
utils/WidgetDragFilter.cpp utils/WidgetDragFilter.cpp

View File

@@ -24,7 +24,7 @@
#include "database/Database.h" #include "database/Database.h"
#include "resolvers/ExternalResolver.h" #include "resolvers/ExternalResolver.h"
#include "resolvers/ScriptResolver.h" #include "resolvers/ScriptResolver.h"
#include "resolvers/QtScriptResolver.h" #include "resolvers/JSResolver.h"
#include "Source.h" #include "Source.h"
#include "SourceList.h" #include "SourceList.h"
#include "utils/ResultUrlChecker.h" #include "utils/ResultUrlChecker.h"

View File

@@ -21,8 +21,8 @@
#include "infosystem/InfoSystem.h" #include "infosystem/InfoSystem.h"
#include "LastFmInfoPlugin.h" #include "LastFmInfoPlugin.h"
#include "resolvers/ExternalResolverGui.h"
#include "utils/TomahawkUtilsGui.h" #include "utils/TomahawkUtilsGui.h"
#include "resolvers/QtScriptResolver.h"
#include "AtticaManager.h" #include "AtticaManager.h"
#include "Pipeline.h" #include "Pipeline.h"
#include "accounts/AccountManager.h" #include "accounts/AccountManager.h"

View File

@@ -1123,7 +1123,7 @@ Servent::getIODeviceForUrl( const Tomahawk::result_ptr& result,
return; return;
} }
//QtScriptResolverHelper::customIODeviceFactory is async! //JSResolverHelper::customIODeviceFactory is async!
m_iofactories.value( proto )( result, callback ); m_iofactories.value( proto )( result, callback );
} }

View File

@@ -18,7 +18,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "QtScriptResolver.h" #include "JSResolver.h"
#include "Artist.h" #include "Artist.h"
#include "Album.h" #include "Album.h"
@@ -63,7 +63,7 @@
#define RESOLVER_LEGACY_CODE2 "var resolver = Tomahawk.resolver.instance ? Tomahawk.resolver.instance : window;" #define RESOLVER_LEGACY_CODE2 "var resolver = Tomahawk.resolver.instance ? Tomahawk.resolver.instance : window;"
QtScriptResolverHelper::QtScriptResolverHelper( const QString& scriptPath, QtScriptResolver* parent ) JSResolverHelper::JSResolverHelper( const QString& scriptPath, JSResolver* parent )
: QObject( parent ) : QObject( parent )
, m_urlCallbackIsAsync( false ) , m_urlCallbackIsAsync( false )
{ {
@@ -73,7 +73,7 @@ QtScriptResolverHelper::QtScriptResolverHelper( const QString& scriptPath, QtScr
QByteArray QByteArray
QtScriptResolverHelper::readRaw( const QString& fileName ) JSResolverHelper::readRaw( const QString& fileName )
{ {
QString path = QFileInfo( m_scriptPath ).absolutePath(); QString path = QFileInfo( m_scriptPath ).absolutePath();
// remove directories // remove directories
@@ -93,7 +93,7 @@ QtScriptResolverHelper::readRaw( const QString& fileName )
QString QString
QtScriptResolverHelper::compress( const QString& data ) JSResolverHelper::compress( const QString& data )
{ {
QByteArray comp = qCompress( data.toLatin1(), 9 ); QByteArray comp = qCompress( data.toLatin1(), 9 );
return comp.toBase64(); return comp.toBase64();
@@ -101,21 +101,21 @@ QtScriptResolverHelper::compress( const QString& data )
QString QString
QtScriptResolverHelper::readCompressed( const QString& fileName ) JSResolverHelper::readCompressed( const QString& fileName )
{ {
return compress( readRaw( fileName ) ); return compress( readRaw( fileName ) );
} }
QString QString
QtScriptResolverHelper::readBase64( const QString& fileName ) JSResolverHelper::readBase64( const QString& fileName )
{ {
return readRaw( fileName ).toBase64(); return readRaw( fileName ).toBase64();
} }
QVariantMap QVariantMap
QtScriptResolverHelper::resolverData() JSResolverHelper::resolverData()
{ {
QVariantMap resolver; QVariantMap resolver;
resolver["config"] = m_resolverConfig; resolver["config"] = m_resolverConfig;
@@ -125,14 +125,14 @@ QtScriptResolverHelper::resolverData()
void void
QtScriptResolverHelper::log( const QString& message ) JSResolverHelper::log( const QString& message )
{ {
tLog() << m_scriptPath << ":" << message; tLog() << m_scriptPath << ":" << message;
} }
void void
QtScriptResolverHelper::addTrackResults( const QVariantMap& results ) JSResolverHelper::addTrackResults( const QVariantMap& results )
{ {
qDebug() << "Resolver reporting results:" << results; qDebug() << "Resolver reporting results:" << results;
QList< Tomahawk::result_ptr > tracks = m_resolver->parseResultVariantList( results.value("results").toList() ); QList< Tomahawk::result_ptr > tracks = m_resolver->parseResultVariantList( results.value("results").toList() );
@@ -144,7 +144,7 @@ QtScriptResolverHelper::addTrackResults( const QVariantMap& results )
void void
QtScriptResolverHelper::addArtistResults( const QVariantMap& results ) JSResolverHelper::addArtistResults( const QVariantMap& results )
{ {
qDebug() << "Resolver reporting artists:" << results; qDebug() << "Resolver reporting artists:" << results;
QList< Tomahawk::artist_ptr > artists = m_resolver->parseArtistVariantList( results.value( "artists" ).toList() ); QList< Tomahawk::artist_ptr > artists = m_resolver->parseArtistVariantList( results.value( "artists" ).toList() );
@@ -171,7 +171,7 @@ QtScriptResolverHelper::addArtistResults( const QVariantMap& results )
void void
QtScriptResolverHelper::addAlbumResults( const QVariantMap& results ) JSResolverHelper::addAlbumResults( const QVariantMap& results )
{ {
qDebug() << "Resolver reporting albums:" << results; qDebug() << "Resolver reporting albums:" << results;
QString artistName = results.value( "artist" ).toString(); QString artistName = results.value( "artist" ).toString();
@@ -202,7 +202,7 @@ QtScriptResolverHelper::addAlbumResults( const QVariantMap& results )
void void
QtScriptResolverHelper::addAlbumTrackResults( const QVariantMap& results ) JSResolverHelper::addAlbumTrackResults( const QVariantMap& results )
{ {
qDebug() << "Resolver reporting album tracks:" << results; qDebug() << "Resolver reporting album tracks:" << results;
QString artistName = results.value( "artist" ).toString(); QString artistName = results.value( "artist" ).toString();
@@ -244,7 +244,7 @@ QtScriptResolverHelper::addAlbumTrackResults( const QVariantMap& results )
void void
QtScriptResolverHelper::reportCapabilities( const QVariant& v ) JSResolverHelper::reportCapabilities( const QVariant& v )
{ {
bool ok = 0; bool ok = 0;
int intCap = v.toInt( &ok ); int intCap = v.toInt( &ok );
@@ -259,14 +259,14 @@ QtScriptResolverHelper::reportCapabilities( const QVariant& v )
void void
QtScriptResolverHelper::setResolverConfig( const QVariantMap& config ) JSResolverHelper::setResolverConfig( const QVariantMap& config )
{ {
m_resolverConfig = config; m_resolverConfig = config;
} }
QString QString
QtScriptResolverHelper::hmac( const QByteArray& key, const QByteArray &input ) JSResolverHelper::hmac( const QByteArray& key, const QByteArray &input )
{ {
#ifdef QCA2_FOUND #ifdef QCA2_FOUND
if ( !QCA::isSupported( "hmac(md5)" ) ) if ( !QCA::isSupported( "hmac(md5)" ) )
@@ -292,7 +292,7 @@ QtScriptResolverHelper::hmac( const QByteArray& key, const QByteArray &input )
QString QString
QtScriptResolverHelper::md5( const QByteArray& input ) JSResolverHelper::md5( const QByteArray& input )
{ {
QByteArray const digest = QCryptographicHash::hash( input, QCryptographicHash::Md5 ); QByteArray const digest = QCryptographicHash::hash( input, QCryptographicHash::Md5 );
return QString::fromLatin1( digest.toHex() ); return QString::fromLatin1( digest.toHex() );
@@ -300,7 +300,7 @@ QtScriptResolverHelper::md5( const QByteArray& input )
void void
QtScriptResolverHelper::addCustomUrlHandler( const QString& protocol, JSResolverHelper::addCustomUrlHandler( const QString& protocol,
const QString& callbackFuncName, const QString& callbackFuncName,
const QString& isAsynchronous ) const QString& isAsynchronous )
{ {
@@ -308,7 +308,7 @@ QtScriptResolverHelper::addCustomUrlHandler( const QString& protocol,
boost::function< void( const Tomahawk::result_ptr&, boost::function< void( const Tomahawk::result_ptr&,
boost::function< void( QSharedPointer< QIODevice >& ) > )> fac = boost::function< void( QSharedPointer< QIODevice >& ) > )> fac =
boost::bind( &QtScriptResolverHelper::customIODeviceFactory, this, _1, _2 ); boost::bind( &JSResolverHelper::customIODeviceFactory, this, _1, _2 );
Servent::instance()->registerIODeviceFactory( protocol, fac ); Servent::instance()->registerIODeviceFactory( protocol, fac );
m_urlCallback = callbackFuncName; m_urlCallback = callbackFuncName;
@@ -316,21 +316,21 @@ QtScriptResolverHelper::addCustomUrlHandler( const QString& protocol,
QByteArray QByteArray
QtScriptResolverHelper::base64Encode( const QByteArray& input ) JSResolverHelper::base64Encode( const QByteArray& input )
{ {
return input.toBase64(); return input.toBase64();
} }
QByteArray QByteArray
QtScriptResolverHelper::base64Decode( const QByteArray& input ) JSResolverHelper::base64Decode( const QByteArray& input )
{ {
return QByteArray::fromBase64( input ); return QByteArray::fromBase64( input );
} }
void void
QtScriptResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr& result, JSResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr& result,
boost::function< void( QSharedPointer< QIODevice >& ) > callback ) boost::function< void( QSharedPointer< QIODevice >& ) > callback )
{ {
//can be sync or async //can be sync or async
@@ -359,7 +359,7 @@ QtScriptResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr& resul
void void
QtScriptResolverHelper::reportStreamUrl( const QString& qid, JSResolverHelper::reportStreamUrl( const QString& qid,
const QString& streamUrl ) const QString& streamUrl )
{ {
if ( !m_streamCallbacks.contains( qid ) ) if ( !m_streamCallbacks.contains( qid ) )
@@ -372,7 +372,7 @@ QtScriptResolverHelper::reportStreamUrl( const QString& qid,
void void
QtScriptResolverHelper::returnStreamUrl( const QString& streamUrl, boost::function< void( QSharedPointer< QIODevice >& ) > callback ) JSResolverHelper::returnStreamUrl( const QString& streamUrl, boost::function< void( QSharedPointer< QIODevice >& ) > callback )
{ {
QSharedPointer< QIODevice > sp; QSharedPointer< QIODevice > sp;
if ( streamUrl.isEmpty() ) if ( streamUrl.isEmpty() )
@@ -392,12 +392,12 @@ QtScriptResolverHelper::returnStreamUrl( const QString& streamUrl, boost::functi
} }
QtScriptResolver::QtScriptResolver( const QString& scriptPath, const QStringList& additionalScriptPaths ) JSResolver::JSResolver( const QString& scriptPath, const QStringList& additionalScriptPaths )
: Tomahawk::ExternalResolverGui( scriptPath ) : Tomahawk::ExternalResolverGui( scriptPath )
, m_ready( false ) , m_ready( false )
, m_stopped( true ) , m_stopped( true )
, m_error( Tomahawk::ExternalResolver::NoError ) , m_error( Tomahawk::ExternalResolver::NoError )
, m_resolverHelper( new QtScriptResolverHelper( scriptPath, this ) ) , m_resolverHelper( new JSResolverHelper( scriptPath, this ) )
, m_requiredScriptPaths( additionalScriptPaths ) , m_requiredScriptPaths( additionalScriptPaths )
{ {
tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath; tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath;
@@ -420,7 +420,7 @@ QtScriptResolver::QtScriptResolver( const QString& scriptPath, const QStringList
} }
QtScriptResolver::~QtScriptResolver() JSResolver::~JSResolver()
{ {
if ( !m_stopped ) if ( !m_stopped )
stop(); stop();
@@ -429,14 +429,14 @@ QtScriptResolver::~QtScriptResolver()
} }
Tomahawk::ExternalResolver* QtScriptResolver::factory( const QString& scriptPath, const QStringList& additionalScriptPaths ) Tomahawk::ExternalResolver* JSResolver::factory( const QString& scriptPath, const QStringList& additionalScriptPaths )
{ {
ExternalResolver* res = 0; ExternalResolver* res = 0;
const QFileInfo fi( scriptPath ); const QFileInfo fi( scriptPath );
if ( fi.suffix() == "js" || fi.suffix() == "script" ) if ( fi.suffix() == "js" || fi.suffix() == "script" )
{ {
res = new QtScriptResolver( scriptPath, additionalScriptPaths ); res = new JSResolver( scriptPath, additionalScriptPaths );
tLog() << Q_FUNC_INFO << scriptPath << "Loaded."; tLog() << Q_FUNC_INFO << scriptPath << "Loaded.";
} }
@@ -445,14 +445,14 @@ Tomahawk::ExternalResolver* QtScriptResolver::factory( const QString& scriptPath
bool bool
QtScriptResolver::running() const JSResolver::running() const
{ {
return m_ready && !m_stopped; return m_ready && !m_stopped;
} }
void void
QtScriptResolver::reload() JSResolver::reload()
{ {
if ( QFile::exists( filePath() ) ) if ( QFile::exists( filePath() ) )
{ {
@@ -466,7 +466,7 @@ QtScriptResolver::reload()
void void
QtScriptResolver::init() JSResolver::init()
{ {
QFile scriptFile( filePath() ); QFile scriptFile( filePath() );
if( !scriptFile.open( QIODevice::ReadOnly ) ) if( !scriptFile.open( QIODevice::ReadOnly ) )
@@ -550,7 +550,7 @@ QtScriptResolver::init()
void void
QtScriptResolver::start() JSResolver::start()
{ {
m_stopped = false; m_stopped = false;
if ( m_ready ) if ( m_ready )
@@ -561,7 +561,7 @@ QtScriptResolver::start()
void void
QtScriptResolver::artists( const Tomahawk::collection_ptr& collection ) JSResolver::artists( const Tomahawk::collection_ptr& collection )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -593,7 +593,7 @@ QtScriptResolver::artists( const Tomahawk::collection_ptr& collection )
void void
QtScriptResolver::albums( const Tomahawk::collection_ptr& collection, const Tomahawk::artist_ptr& artist ) JSResolver::albums( const Tomahawk::collection_ptr& collection, const Tomahawk::artist_ptr& artist )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -628,7 +628,7 @@ QtScriptResolver::albums( const Tomahawk::collection_ptr& collection, const Toma
void void
QtScriptResolver::tracks( const Tomahawk::collection_ptr& collection, const Tomahawk::album_ptr& album ) JSResolver::tracks( const Tomahawk::collection_ptr& collection, const Tomahawk::album_ptr& album )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -664,14 +664,14 @@ QtScriptResolver::tracks( const Tomahawk::collection_ptr& collection, const Toma
Tomahawk::ExternalResolver::ErrorState Tomahawk::ExternalResolver::ErrorState
QtScriptResolver::error() const JSResolver::error() const
{ {
return m_error; return m_error;
} }
void void
QtScriptResolver::resolve( const Tomahawk::query_ptr& query ) JSResolver::resolve( const Tomahawk::query_ptr& query )
{ {
if ( QThread::currentThread() != thread() ) if ( QThread::currentThread() != thread() )
{ {
@@ -719,7 +719,7 @@ QtScriptResolver::resolve( const Tomahawk::query_ptr& query )
QList< Tomahawk::result_ptr > QList< Tomahawk::result_ptr >
QtScriptResolver::parseResultVariantList( const QVariantList& reslist ) JSResolver::parseResultVariantList( const QVariantList& reslist )
{ {
QList< Tomahawk::result_ptr > results; QList< Tomahawk::result_ptr > results;
@@ -785,7 +785,7 @@ QtScriptResolver::parseResultVariantList( const QVariantList& reslist )
QList< Tomahawk::artist_ptr > QList< Tomahawk::artist_ptr >
QtScriptResolver::parseArtistVariantList( const QVariantList& reslist ) JSResolver::parseArtistVariantList( const QVariantList& reslist )
{ {
QList< Tomahawk::artist_ptr > results; QList< Tomahawk::artist_ptr > results;
@@ -804,7 +804,7 @@ QtScriptResolver::parseArtistVariantList( const QVariantList& reslist )
QList< Tomahawk::album_ptr > QList< Tomahawk::album_ptr >
QtScriptResolver::parseAlbumVariantList( const Tomahawk::artist_ptr& artist, const QVariantList& reslist ) JSResolver::parseAlbumVariantList( const Tomahawk::artist_ptr& artist, const QVariantList& reslist )
{ {
QList< Tomahawk::album_ptr > results; QList< Tomahawk::album_ptr > results;
@@ -823,7 +823,7 @@ QtScriptResolver::parseAlbumVariantList( const Tomahawk::artist_ptr& artist, con
void void
QtScriptResolver::stop() JSResolver::stop()
{ {
m_stopped = true; m_stopped = true;
@@ -838,7 +838,7 @@ QtScriptResolver::stop()
void void
QtScriptResolver::loadUi() JSResolver::loadUi()
{ {
QVariantMap m = m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.getConfigUi();" ).toMap(); QVariantMap m = m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.getConfigUi();" ).toMap();
m_dataWidgets = m["fields"].toList(); m_dataWidgets = m["fields"].toList();
@@ -871,7 +871,7 @@ QtScriptResolver::loadUi()
AccountConfigWidget* AccountConfigWidget*
QtScriptResolver::configUI() const JSResolver::configUI() const
{ {
if( m_configWidget.isNull() ) if( m_configWidget.isNull() )
return 0; return 0;
@@ -881,7 +881,7 @@ QtScriptResolver::configUI() const
void void
QtScriptResolver::saveConfig() JSResolver::saveConfig()
{ {
QVariant saveData = loadDataFromWidgets(); QVariant saveData = loadDataFromWidgets();
// qDebug() << Q_FUNC_INFO << saveData; // qDebug() << Q_FUNC_INFO << saveData;
@@ -892,7 +892,7 @@ QtScriptResolver::saveConfig()
QVariant QVariant
QtScriptResolver::widgetData(QWidget* widget, const QString& property) JSResolver::widgetData(QWidget* widget, const QString& property)
{ {
for( int i = 0; i < widget->metaObject()->propertyCount(); i++ ) for( int i = 0; i < widget->metaObject()->propertyCount(); i++ )
{ {
@@ -907,7 +907,7 @@ QtScriptResolver::widgetData(QWidget* widget, const QString& property)
void void
QtScriptResolver::setWidgetData(const QVariant& value, QWidget* widget, const QString& property) JSResolver::setWidgetData(const QVariant& value, QWidget* widget, const QString& property)
{ {
for( int i = 0; i < widget->metaObject()->propertyCount(); i++ ) for( int i = 0; i < widget->metaObject()->propertyCount(); i++ )
{ {
@@ -921,7 +921,7 @@ QtScriptResolver::setWidgetData(const QVariant& value, QWidget* widget, const QS
QVariantMap QVariantMap
QtScriptResolver::loadDataFromWidgets() JSResolver::loadDataFromWidgets()
{ {
QVariantMap saveData; QVariantMap saveData;
foreach( const QVariant& dataWidget, m_dataWidgets ) foreach( const QVariant& dataWidget, m_dataWidgets )
@@ -941,7 +941,7 @@ QtScriptResolver::loadDataFromWidgets()
void void
QtScriptResolver::fillDataInWidgets( const QVariantMap& data ) JSResolver::fillDataInWidgets( const QVariantMap& data )
{ {
foreach(const QVariant& dataWidget, m_dataWidgets) foreach(const QVariant& dataWidget, m_dataWidgets)
{ {
@@ -963,7 +963,7 @@ QtScriptResolver::fillDataInWidgets( const QVariantMap& data )
void void
QtScriptResolver::onCapabilitiesChanged( Tomahawk::ExternalResolver::Capabilities capabilities ) JSResolver::onCapabilitiesChanged( Tomahawk::ExternalResolver::Capabilities capabilities )
{ {
m_capabilities = capabilities; m_capabilities = capabilities;
loadCollections(); loadCollections();
@@ -971,7 +971,7 @@ QtScriptResolver::onCapabilitiesChanged( Tomahawk::ExternalResolver::Capabilitie
void void
QtScriptResolver::loadCollections() JSResolver::loadCollections()
{ {
if ( m_capabilities.testFlag( Browsable ) ) if ( m_capabilities.testFlag( Browsable ) )
{ {
@@ -1045,7 +1045,7 @@ QtScriptResolver::loadCollections()
void void
QtScriptResolver::onCollectionIconFetched() JSResolver::onCollectionIconFetched()
{ {
QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() ); QNetworkReply* reply = qobject_cast< QNetworkReply* >( sender() );
if ( reply != 0 ) if ( reply != 0 )
@@ -1069,28 +1069,28 @@ QtScriptResolver::onCollectionIconFetched()
QVariantMap QVariantMap
QtScriptResolver::resolverSettings() JSResolver::resolverSettings()
{ {
return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "if(resolver.settings) resolver.settings; else getSettings(); " ).toMap(); return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "if(resolver.settings) resolver.settings; else getSettings(); " ).toMap();
} }
QVariantMap QVariantMap
QtScriptResolver::resolverUserConfig() JSResolver::resolverUserConfig()
{ {
return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.getUserConfig();" ).toMap(); return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.getUserConfig();" ).toMap();
} }
QVariantMap QVariantMap
QtScriptResolver::resolverInit() JSResolver::resolverInit()
{ {
return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.init();" ).toMap(); return m_engine->mainFrame()->evaluateJavaScript( RESOLVER_LEGACY_CODE "resolver.init();" ).toMap();
} }
QVariantMap QVariantMap
QtScriptResolver::resolverCollections() JSResolver::resolverCollections()
{ {
return QVariantMap(); //TODO: add a way to distinguish collections return QVariantMap(); //TODO: add a way to distinguish collections
// the resolver should provide a unique ID string for each collection, and then be queriable // the resolver should provide a unique ID string for each collection, and then be queriable
@@ -1100,7 +1100,7 @@ QtScriptResolver::resolverCollections()
} }
ScriptEngine::ScriptEngine( QtScriptResolver* parent ) ScriptEngine::ScriptEngine( JSResolver* parent )
: QWebPage( (QObject*) parent ) : QWebPage( (QObject*) parent )
, m_parent( parent ) , m_parent( parent )
{ {
@@ -1117,7 +1117,7 @@ ScriptEngine::ScriptEngine( QtScriptResolver* parent )
.arg( TOMAHAWK_APPLICATION_NAME ) .arg( TOMAHAWK_APPLICATION_NAME )
.arg( TOMAHAWK_VERSION ) .arg( TOMAHAWK_VERSION )
,""); ,"");
tLog( LOGVERBOSE ) << "QtScriptResolver Using header" << m_header; tLog( LOGVERBOSE ) << "JSResolver Using header" << m_header;
connect( networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, QList<QSslError> ) ), connect( networkAccessManager(), SIGNAL( sslErrors( QNetworkReply*, QList<QSslError> ) ),
SLOT( sslErrorHandler( QNetworkReply*, QList<QSslError> ) ) ); SLOT( sslErrorHandler( QNetworkReply*, QList<QSslError> ) ) );

View File

@@ -18,8 +18,8 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>. * along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef QTSCRIPTRESOLVER_H #ifndef JSRESOLVER_H
#define QTSCRIPTRESOLVER_H #define JSRESOLVER_H
#include "ExternalResolverGui.h" #include "ExternalResolverGui.h"
#include "Query.h" #include "Query.h"
@@ -35,14 +35,14 @@
#include "DllMacro.h" #include "DllMacro.h"
class QtScriptResolver; class JSResolver;
class DLLEXPORT QtScriptResolverHelper : public QObject class DLLEXPORT JSResolverHelper : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
QtScriptResolverHelper( const QString& scriptPath, QtScriptResolver* parent ); JSResolverHelper( const QString& scriptPath, JSResolver* 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
@@ -83,7 +83,7 @@ private:
QHash< QString, boost::function< void( QSharedPointer< QIODevice >& ) > > m_streamCallbacks; QHash< QString, boost::function< void( QSharedPointer< QIODevice >& ) > > m_streamCallbacks;
bool m_urlCallbackIsAsync; bool m_urlCallbackIsAsync;
QVariantMap m_resolverConfig; QVariantMap m_resolverConfig;
QtScriptResolver* m_resolver; JSResolver* m_resolver;
}; };
class DLLEXPORT ScriptEngine : public QWebPage class DLLEXPORT ScriptEngine : public QWebPage
@@ -91,7 +91,7 @@ class DLLEXPORT ScriptEngine : public QWebPage
Q_OBJECT Q_OBJECT
public: public:
explicit ScriptEngine( QtScriptResolver* parent ); explicit ScriptEngine( JSResolver* parent );
QString userAgentForUrl( const QUrl& url ) const; QString userAgentForUrl( const QUrl& url ) const;
void setScriptPath( const QString& scriptPath ); void setScriptPath( const QString& scriptPath );
@@ -106,21 +106,21 @@ private slots:
void sslErrorHandler( QNetworkReply* qnr, const QList<QSslError>& errlist ); void sslErrorHandler( QNetworkReply* qnr, const QList<QSslError>& errlist );
private: private:
QtScriptResolver* m_parent; JSResolver* m_parent;
QString m_scriptPath; QString m_scriptPath;
QString m_header; QString m_header;
}; };
class DLLEXPORT QtScriptResolver : public Tomahawk::ExternalResolverGui class DLLEXPORT JSResolver : public Tomahawk::ExternalResolverGui
{ {
Q_OBJECT Q_OBJECT
friend class ::QtScriptResolverHelper; friend class ::JSResolverHelper;
public: public:
explicit QtScriptResolver( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); explicit JSResolver( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() );
virtual ~QtScriptResolver(); virtual ~JSResolver();
static ExternalResolver* factory( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() ); static ExternalResolver* factory( const QString& scriptPath, const QStringList& additionalScriptPaths = QStringList() );
virtual Capabilities capabilities() const { return m_capabilities; } virtual Capabilities capabilities() const { return m_capabilities; }
@@ -187,10 +187,10 @@ private:
bool m_ready, m_stopped; bool m_ready, m_stopped;
ExternalResolver::ErrorState m_error; ExternalResolver::ErrorState m_error;
QtScriptResolverHelper* m_resolverHelper; JSResolverHelper* m_resolverHelper;
QPointer< AccountConfigWidget > m_configWidget; QPointer< AccountConfigWidget > m_configWidget;
QList< QVariant > m_dataWidgets; QList< QVariant > m_dataWidgets;
QStringList m_requiredScriptPaths; QStringList m_requiredScriptPaths;
}; };
#endif // QTSCRIPTRESOLVER_H #endif // JSRESOLVER_H