1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-03-19 15:29:42 +01:00

Rename ScriptPlugin to ScriptAccount and JSPlugin to JSAccount

This commit is contained in:
Dominik Schmidt 2014-12-08 23:46:10 +01:00
parent b59c272819
commit 7adac470da
20 changed files with 107 additions and 104 deletions

View File

@ -89,12 +89,12 @@ set( libGuiSources
resolvers/JSResolver.cpp
resolvers/JSResolverHelper.cpp
resolvers/ScriptEngine.cpp
resolvers/JSPlugin.cpp
resolvers/JSAccount.cpp
resolvers/ScriptJob.cpp
resolvers/SyncScriptJob.cpp
resolvers/ScriptObject.cpp
resolvers/ScriptLinkGeneratorPlugin.cpp
resolvers/ScriptPlugin.cpp
resolvers/ScriptAccount.cpp
utils/DpiScaler.cpp
utils/ImageRegistry.cpp

View File

@ -16,7 +16,7 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "JSPlugin.h"
#include "JSAccount.h"
#include "../utils/Json.h"
#include "../utils/Logger.h"
@ -30,7 +30,7 @@
using namespace Tomahawk;
JSPlugin::JSPlugin( const QString& name )
JSAccount::JSAccount( const QString& name )
: m_engine( new ScriptEngine( this ) )
, m_name( name )
{
@ -38,14 +38,14 @@ JSPlugin::JSPlugin( const QString& name )
void
JSPlugin::addToJavaScriptWindowObject( const QString& name, QObject* object )
JSAccount::addToJavaScriptWindowObject( const QString& name, QObject* object )
{
m_engine->mainFrame()->addToJavaScriptWindowObject( name, object );
}
QString
JSPlugin::serializeQVariantMap( const QVariantMap& map )
JSAccount::serializeQVariantMap( const QVariantMap& map )
{
QVariantMap localMap = map;
@ -62,12 +62,12 @@ JSPlugin::serializeQVariantMap( const QVariantMap& map )
QByteArray serialized = TomahawkUtils::toJson( localMap );
return QString( "JSON.parse('%1')" ).arg( JSPlugin::escape( QString::fromUtf8( serialized ) ) );
return QString( "JSON.parse('%1')" ).arg( JSAccount::escape( QString::fromUtf8( serialized ) ) );
}
QString
JSPlugin::JSPlugin::escape( const QString& source )
JSAccount::JSAccount::escape( const QString& source )
{
QString copy = source;
return copy.replace( "\\", "\\\\" ).replace( "'", "\\'" );
@ -75,7 +75,7 @@ JSPlugin::JSPlugin::escape( const QString& source )
void
JSPlugin::loadScript( const QString& path )
JSAccount::loadScript( const QString& path )
{
QFile file( path );
@ -96,7 +96,7 @@ JSPlugin::loadScript( const QString& path )
void
JSPlugin::loadScripts( const QStringList& paths )
JSAccount::loadScripts( const QStringList& paths )
{
foreach ( const QString& path, paths )
{
@ -106,7 +106,7 @@ JSPlugin::loadScripts( const QStringList& paths )
void
JSPlugin::startJob( ScriptJob* scriptJob )
JSAccount::startJob( ScriptJob* scriptJob )
{
QString eval = QString(
"Tomahawk.PluginManager.invoke("
@ -128,21 +128,21 @@ JSPlugin::startJob( ScriptJob* scriptJob )
const QString
JSPlugin::name() const
JSAccount::name() const
{
return m_name;
}
QVariant
JSPlugin::evaluateJavaScriptInternal( const QString& scriptSource )
JSAccount::evaluateJavaScriptInternal( const QString& scriptSource )
{
return m_engine->mainFrame()->evaluateJavaScript( scriptSource );
}
void
JSPlugin::evaluateJavaScript( const QString& scriptSource )
JSAccount::evaluateJavaScript( const QString& scriptSource )
{
if ( QThread::currentThread() != thread() )
{
@ -155,7 +155,7 @@ JSPlugin::evaluateJavaScript( const QString& scriptSource )
QVariant
JSPlugin::evaluateJavaScriptWithResult( const QString& scriptSource )
JSAccount::evaluateJavaScriptWithResult( const QString& scriptSource )
{
Q_ASSERT( QThread::currentThread() == thread() );

View File

@ -16,11 +16,11 @@
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TOMAHAWK_JSPLUGIN_H
#define TOMAHAWK_JSPLUGIN_H
#ifndef TOMAHAWK_JSACCOUNT_H
#define TOMAHAWK_JSACCOUNT_H
#include "ScriptPlugin.h"
#include "ScriptAccount.h"
#include <QVariantMap>
#include <QObject>
@ -35,13 +35,13 @@ namespace Tomahawk
//TODO: pimple
class ScriptEngine;
class DLLEXPORT JSPlugin : public ScriptPlugin
class DLLEXPORT JSAccount : public ScriptAccount
{
Q_OBJECT
public:
// HACK: needs refactoring
JSPlugin( const QString& name );
JSAccount( const QString& name );
void startJob( ScriptJob* scriptJob ) override;
@ -82,5 +82,5 @@ private:
}
#endif // TOMAHAWK_SCRIPTJOB_H
#endif // TOMAHAWK_JSACCOUNT_H

View File

@ -18,7 +18,7 @@
#include "JSInfoPlugin_p.h"
#include "JSPlugin.h"
#include "JSAccount.h"
#include "Typedefs.h"
#include "../utils/Logger.h"
@ -26,7 +26,7 @@
using namespace Tomahawk;
JSInfoPlugin::JSInfoPlugin( int id, JSPlugin *resolver )
JSInfoPlugin::JSInfoPlugin( int id, JSAccount *resolver )
: d_ptr( new JSInfoPluginPrivate( this, id, resolver ) )
{
Q_ASSERT( resolver );
@ -229,7 +229,7 @@ JSInfoPlugin::serializeQVariantMap( const QVariantMap& map )
}
}
return JSPlugin::serializeQVariantMap( localMap );
return JSAccount::serializeQVariantMap( localMap );
}

View File

@ -27,7 +27,7 @@
namespace Tomahawk
{
class JSPlugin;
class JSAccount;
class JSInfoPluginPrivate;
@ -39,7 +39,7 @@ public:
/**
* @param id unique identifier to identify an infoplugin in its scope
*/
JSInfoPlugin( int id, JSPlugin* resolver );
JSInfoPlugin( int id, JSAccount* resolver );
virtual ~JSInfoPlugin();
@ -55,7 +55,7 @@ protected slots:
void notInCacheSlot( Tomahawk::InfoSystem::InfoStringHash criteria, Tomahawk::InfoSystem::InfoRequestData requestData ) override;
protected:
// TODO: create JSPlugin base class and move these methods there
// TODO: create JSAccount base class and move these methods there
QString serviceGetter() const; // = 0
void callMethodOnInfoPlugin( const QString& scriptSource );
QVariant callMethodOnInfoPluginWithResult( const QString& scriptSource );

View File

@ -28,7 +28,7 @@ class JSInfoPluginPrivate
{
friend class JSInfoPlugin;
public:
JSInfoPluginPrivate( JSInfoPlugin* q, int id, JSPlugin* resolver )
JSInfoPluginPrivate( JSInfoPlugin* q, int id, JSAccount* resolver )
: q_ptr ( q )
, id( id )
, resolver( resolver )
@ -40,7 +40,7 @@ public:
private:
int id;
// HACK: JSInfoPlugin needs to be refactored to track a ScriptObject
JSPlugin* resolver;
JSAccount* resolver;
QMap< int, Tomahawk::InfoSystem::InfoRequestData > requestDataCache;
QMap< int, Tomahawk::InfoSystem::InfoStringHash > criteriaCache;

View File

@ -19,12 +19,12 @@
#include "JSInfoSystemHelper_p.h"
#include "JSInfoPlugin.h"
#include "JSPlugin.h"
#include "JSAccount.h"
#include "../utils/Logger.h"
using namespace Tomahawk;
JSInfoSystemHelper::JSInfoSystemHelper( JSPlugin* parent )
JSInfoSystemHelper::JSInfoSystemHelper( JSAccount* parent )
: QObject( parent )
, d_ptr( new JSInfoSystemHelperPrivate( this, parent ) )
{
@ -49,7 +49,7 @@ JSInfoSystemHelper::nativeAddInfoPlugin( int id )
Q_D( JSInfoSystemHelper );
// create infoplugin instance
JSInfoPlugin* jsInfoPlugin = new JSInfoPlugin( id, d->scriptPlugin );
JSInfoPlugin* jsInfoPlugin = new JSInfoPlugin( id, d->scriptAccount );
Tomahawk::InfoSystem::InfoPluginPtr infoPlugin( jsInfoPlugin );
// move it to infosystem thread

View File

@ -24,7 +24,7 @@
namespace Tomahawk
{
class JSPlugin;
class JSAccount;
class JSInfoSystemHelperPrivate;
class JSInfoSystemHelper : public QObject
@ -32,7 +32,7 @@ class JSInfoSystemHelper : public QObject
Q_OBJECT
public:
JSInfoSystemHelper( JSPlugin* parent );
JSInfoSystemHelper( JSAccount* parent );
~JSInfoSystemHelper();
QStringList requiredScriptPaths() const;

View File

@ -29,9 +29,9 @@ class JSInfoSystemHelperPrivate
{
friend class JSInfoSystemHelper;
public:
JSInfoSystemHelperPrivate( JSInfoSystemHelper* q, JSPlugin* scriptPlugin )
JSInfoSystemHelperPrivate( JSInfoSystemHelper* q, JSAccount* scriptAccount )
: q_ptr ( q )
, scriptPlugin ( scriptPlugin )
, scriptAccount ( scriptAccount )
{
}
@ -39,7 +39,7 @@ public:
Q_DECLARE_PUBLIC ( JSInfoSystemHelper )
private:
JSPlugin* scriptPlugin;
JSAccount* scriptAccount;
QMap<int,JSInfoPlugin*> infoPlugins;
};

View File

@ -43,7 +43,7 @@
#include "TomahawkVersion.h"
#include "Track.h"
#include "JSInfoPlugin.h"
#include "JSPlugin.h"
#include "JSAccount.h"
#include <QDir>
#include <QFile>
@ -65,7 +65,7 @@ JSResolver::JSResolver( const QString& accountId, const QString& scriptPath, con
tLog() << Q_FUNC_INFO << "Loading JS resolver:" << scriptPath;
d->name = QFileInfo( filePath() ).baseName();
d->scriptPlugin.reset( new JSPlugin( d->name ) );
d->scriptAccount.reset( new JSAccount( d->name ) );
// set the icon, if we launch properly we'll get the icon the resolver reports
d->icon = TomahawkUtils::defaultPixmap( TomahawkUtils::DefaultResolver, TomahawkUtils::Original, QSize( 128, 128 ) );
@ -207,14 +207,14 @@ JSResolver::init()
// tomahawk.js
{
// add c++ part of tomahawk javascript library
d->scriptPlugin->addToJavaScriptWindowObject( "Tomahawk", d->resolverHelper );
d->scriptAccount->addToJavaScriptWindowObject( "Tomahawk", d->resolverHelper );
// load es6-promises shim
d->scriptPlugin->loadScript( RESPATH "js/es6-promise-2.0.0.min.js" );
d->scriptAccount->loadScript( RESPATH "js/es6-promise-2.0.0.min.js" );
// Load CrytoJS core
d->scriptPlugin->loadScript( RESPATH "js/cryptojs-core.js" );
d->scriptAccount->loadScript( RESPATH "js/cryptojs-core.js" );
// Load CryptoJS modules
QStringList jsfiles;
@ -222,11 +222,11 @@ JSResolver::init()
QDir cryptojs( RESPATH "js/cryptojs" );
foreach ( QString jsfile, cryptojs.entryList( jsfiles ) )
{
d->scriptPlugin->loadScript( RESPATH "js/cryptojs/" + jsfile );
d->scriptAccount->loadScript( RESPATH "js/cryptojs/" + jsfile );
}
// Load tomahawk.js
d->scriptPlugin->loadScript( RESPATH "js/tomahawk.js" );
d->scriptAccount->loadScript( RESPATH "js/tomahawk.js" );
}
// tomahawk-infosystem.js
@ -234,21 +234,24 @@ JSResolver::init()
// TODO: be smarter about this, only instantiate this if the resolver supports infoplugins
// add c++ part of tomahawk infosystem bindings as Tomahawk.InfoSystem
d->infoSystemHelper = new JSInfoSystemHelper( d->scriptPlugin.get() );
d->scriptPlugin->addToJavaScriptWindowObject( "_TomahawkInfoSystem", d->infoSystemHelper );
d->scriptPlugin->evaluateJavaScript( "Tomahawk.InfoSystem = _TomahawkInfoSystem;" );
d->infoSystemHelper = new JSInfoSystemHelper( d->scriptAccount.get() );
d->scriptAccount->addToJavaScriptWindowObject( "_TomahawkInfoSystem", d->infoSystemHelper );
d->scriptAccount->evaluateJavaScript( "Tomahawk.InfoSystem = _TomahawkInfoSystem;" );
// add deps
d->scriptPlugin->loadScripts( d->infoSystemHelper->requiredScriptPaths() );
d->scriptAccount->loadScripts( d->infoSystemHelper->requiredScriptPaths() );
}
// add resolver dependencies, if any
d->scriptPlugin->loadScripts( d->requiredScriptPaths );
d->scriptAccount->loadScripts( d->requiredScriptPaths );
// add resolver
d->scriptPlugin->loadScript( filePath() );
d->scriptAccount->loadScript( filePath() );
// HACK: register resolver object
d->scriptAccount->evaluateJavaScript( "Tomahawk.PluginManager.registerPlugin('resolver', Tomahawk.resolver.instance);" )
;
// init resolver
resolverInit();
@ -326,7 +329,7 @@ JSResolver::artists( const Tomahawk::collection_ptr& collection )
}
QString eval = QString( "artists( '%1' )" )
.arg( JSPlugin::escape( collection->name() ) );
.arg( JSAccount::escape( collection->name() ) );
QVariantMap m = callOnResolver( eval ).toMap();
if ( m.isEmpty() )
@ -362,8 +365,8 @@ JSResolver::albums( const Tomahawk::collection_ptr& collection, const Tomahawk::
}
QString eval = QString( "albums( '%1', '%2' )" )
.arg( JSPlugin::escape( collection->name() ) )
.arg( JSPlugin::escape( artist->name() ) );
.arg( JSAccount::escape( collection->name() ) )
.arg( JSAccount::escape( artist->name() ) );
QVariantMap m = callOnResolver( eval ).toMap();
if ( m.isEmpty() )
@ -399,9 +402,9 @@ JSResolver::tracks( const Tomahawk::collection_ptr& collection, const Tomahawk::
}
QString eval = QString( "tracks( '%1', '%2', '%3' )" )
.arg( JSPlugin::escape( collection->name() ) )
.arg( JSPlugin::escape( album->artist()->name() ) )
.arg( JSPlugin::escape( album->name() ) );
.arg( JSAccount::escape( collection->name() ) )
.arg( JSAccount::escape( album->artist()->name() ) )
.arg( JSAccount::escape( album->name() ) );
QVariantMap m = callOnResolver( eval ).toMap();
if ( m.isEmpty() )
@ -432,7 +435,7 @@ JSResolver::canParseUrl( const QString& url, UrlType type )
if ( d->capabilities.testFlag( UrlLookup ) )
{
QString eval = QString( "canParseUrl( '%1', %2 )" )
.arg( JSPlugin::escape( QString( url ) ) )
.arg( JSAccount::escape( QString( url ) ) )
.arg( (int) type );
return callOnResolver( eval ).toBool();
}
@ -463,7 +466,7 @@ JSResolver::lookupUrl( const QString& url )
}
QString eval = QString( "lookupUrl( '%1' )" )
.arg( JSPlugin::escape( QString( url ) ) );
.arg( JSAccount::escape( QString( url ) ) );
QVariantMap m = callOnResolver( eval ).toMap();
if ( m.isEmpty() )
@ -500,16 +503,16 @@ JSResolver::resolve( const Tomahawk::query_ptr& query )
if ( !query->isFullTextQuery() )
{
eval = QString( "resolve( '%1', '%2', '%3', '%4' )" )
.arg( JSPlugin::escape( query->id() ) )
.arg( JSPlugin::escape( query->queryTrack()->artist() ) )
.arg( JSPlugin::escape( query->queryTrack()->album() ) )
.arg( JSPlugin::escape( query->queryTrack()->track() ) );
.arg( JSAccount::escape( query->id() ) )
.arg( JSAccount::escape( query->queryTrack()->artist() ) )
.arg( JSAccount::escape( query->queryTrack()->album() ) )
.arg( JSAccount::escape( query->queryTrack()->track() ) );
}
else
{
eval = QString( "search( '%1', '%2' )" )
.arg( JSPlugin::escape( query->id() ) )
.arg( JSPlugin::escape( query->fullTextQuery() ) );
.arg( JSAccount::escape( query->id() ) )
.arg( JSAccount::escape( query->fullTextQuery() ) );
}
QVariantMap m = callOnResolver( eval ).toMap();
@ -960,7 +963,7 @@ JSResolver::callOnResolver( const QString& scriptSource )
QString propertyName = scriptSource.split('(').first();
return d->scriptPlugin->evaluateJavaScriptWithResult( QString(
return d->scriptAccount->evaluateJavaScriptWithResult( QString(
"if(Tomahawk.resolver.instance['_adapter_%1']) {"
" Tomahawk.resolver.instance._adapter_%2;"
"} else {"

View File

@ -38,7 +38,7 @@ class JSResolverPrivate;
class ScriptEngine;
class ScriptJob;
class ScriptObject;
class ScriptPlugin;
class ScriptAccount;
class DLLEXPORT JSResolver : public Tomahawk::ExternalResolverGui
{

View File

@ -40,7 +40,7 @@
#include "Result.h"
#include "SourceList.h"
#include "UrlHandler.h"
#include "JSPlugin.h"
#include "JSAccount.h"
#include <QFile>
#include <QFileInfo>
@ -412,14 +412,14 @@ JSResolverHelper::reportCapabilities( const QVariant& v )
void
JSResolverHelper::reportScriptJobResults( const QVariantMap& result )
{
m_resolver->d_func()->scriptPlugin->reportScriptJobResult( result );
m_resolver->d_func()->scriptAccount->reportScriptJobResult( result );
}
void
JSResolverHelper::registerScriptPlugin(const QString& type, const QString& objectId)
{
m_resolver->d_func()->scriptPlugin->registerScriptPlugin( type, objectId );
m_resolver->d_func()->scriptAccount->registerScriptPlugin( type, objectId );
}
@ -507,14 +507,14 @@ JSResolverHelper::customIODeviceFactory( const Tomahawk::result_ptr&, const QStr
.arg( url );
m_streamCallbacks.insert( qid, callback );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( getUrl );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( getUrl );
}
else
{
QString getUrl = QString( "Tomahawk.resolver.instance.%1( '%2' );" ).arg( m_urlCallback )
.arg( url );
QString urlStr = m_resolver->d_func()->scriptPlugin->evaluateJavaScriptWithResult( getUrl ).toString();
QString urlStr = m_resolver->d_func()->scriptAccount->evaluateJavaScriptWithResult( getUrl ).toString();
returnStreamUrl( urlStr, QMap<QString, QString>(), callback );
}
@ -551,7 +551,7 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Supplied size is not (yet) supported');" )
.arg( metadataId );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
return;
}
@ -618,7 +618,7 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Unknown mime type for tagging: %2');" )
.arg( metadataId ).arg( mime_type );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
return;
}
@ -633,7 +633,7 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Could not read tag information.');" )
.arg( metadataId );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
return;
}
@ -647,7 +647,7 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Empty track returnd');" )
.arg( metadataId );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
return;
}
@ -655,7 +655,7 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Empty artist returnd');" )
.arg( metadataId );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
return;
}
@ -670,13 +670,13 @@ JSResolverHelper::nativeRetrieveMetadata( int metadataId, const QString& url,
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, %2 );" )
.arg( metadataId )
.arg( QString::fromLatin1( TomahawkUtils::toJson( m ) ) );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
}
else
{
QString javascript = QString( "Tomahawk.retrievedMetadata( %1, null, 'Protocol not supported');" )
.arg( metadataId );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
}
}
@ -740,7 +740,7 @@ JSResolverHelper::nativeAsyncRequestDone( int requestId, NetworkReply* reply )
QString javascript = QString( "Tomahawk.nativeAsyncRequestDone( %1, %2 );" )
.arg( QString::number( requestId ) )
.arg( json );
m_resolver->d_func()->scriptPlugin->evaluateJavaScript( javascript );
m_resolver->d_func()->scriptAccount->evaluateJavaScript( javascript );
}

View File

@ -69,7 +69,7 @@ private:
QList< QVariant > dataWidgets;
QStringList requiredScriptPaths;
std::unique_ptr<JSPlugin> scriptPlugin;
std::unique_ptr<JSAccount> scriptAccount;
};
} // ns: Tomahawk

View File

@ -16,7 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with Tomahawk. If not, see <http://www.gnu.org/licenses/>.
*/
#include "ScriptPlugin.h"
#include "ScriptAccount.h"
#include "ScriptObject.h"
#include "../utils/Logger.h"
@ -38,7 +38,7 @@ requestIdGenerator()
ScriptJob*
ScriptPlugin::invoke( ScriptObject* scriptObject, const QString& methodName, const QVariantMap& arguments )
ScriptAccount::invoke( ScriptObject* scriptObject, const QString& methodName, const QVariantMap& arguments )
{
QString requestId = requestIdGenerator();
@ -51,7 +51,7 @@ ScriptPlugin::invoke( ScriptObject* scriptObject, const QString& methodName, con
void
ScriptPlugin::reportScriptJobResult( const QVariantMap& result )
ScriptAccount::reportScriptJobResult( const QVariantMap& result )
{
tLog() << Q_FUNC_INFO << result;
const QString requestId = result[ "requestId" ].toString();
@ -75,7 +75,7 @@ ScriptPlugin::reportScriptJobResult( const QVariantMap& result )
void
ScriptPlugin::registerScriptPlugin( const QString& type, const QString& objectId )
ScriptAccount::registerScriptPlugin( const QString& type, const QString& objectId )
{
ScriptObject* object = m_objects.value( objectId );
if( !object )
@ -99,7 +99,7 @@ ScriptPlugin::registerScriptPlugin( const QString& type, const QString& objectId
void
ScriptPlugin::onJobDeleted( const QString& jobId )
ScriptAccount::onJobDeleted( const QString& jobId )
{
m_jobs.remove( jobId );
}

View File

@ -18,8 +18,8 @@
*/
#pragma once
#ifndef TOMAHAWK_SCRIPTPLUGIN_H
#define TOMAHAWK_SCRIPTPLUGIN_H
#ifndef TOMAHAWK_SCRIPTACCOUNT_H
#define TOMAHAWK_SCRIPTACCOUNT_H
#include <QObject>
#include <QVariantMap>
@ -34,12 +34,12 @@ namespace Tomahawk {
class ScriptObject;
class ScriptJob;
class DLLEXPORT ScriptPlugin : public QObject
class DLLEXPORT ScriptAccount : public QObject
{
Q_OBJECT
public:
virtual ~ScriptPlugin() {}
virtual ~ScriptAccount() {}
ScriptJob* invoke( ScriptObject* scriptObject, const QString& methodName, const QVariantMap& arguments );
virtual void startJob( ScriptJob* scriptJob ) = 0;
@ -57,4 +57,4 @@ private: // TODO: pimple, might be renamed before tho
} // ns: Tomahawk
#endif // TOMAHAWK_SCRIPTPLUGIN_H
#endif // TOMAHAWK_SCRIPTACCOUNT_H

View File

@ -36,7 +36,7 @@
using namespace Tomahawk;
ScriptEngine::ScriptEngine( JSPlugin* parent )
ScriptEngine::ScriptEngine( JSAccount* parent )
: QWebPage( (QObject*) parent )
, m_parent( parent )
{

View File

@ -32,14 +32,14 @@ class QNetworkReply;
namespace Tomahawk
{
class JSPlugin;
class JSAccount;
class DLLEXPORT ScriptEngine : public QWebPage
{
Q_OBJECT
public:
explicit ScriptEngine( JSPlugin* parent );
explicit ScriptEngine( JSAccount* parent );
QString userAgentForUrl( const QUrl& url ) const;
void setScriptPath( const QString& scriptPath );
@ -54,7 +54,7 @@ private slots:
void sslErrorHandler( QNetworkReply* qnr, const QList<QSslError>& errlist );
private:
JSPlugin* m_parent;
JSAccount* m_parent;
QString m_scriptPath;
QString m_header;
};

View File

@ -17,12 +17,12 @@
*/
#include "ScriptObject_p.h"
#include "ScriptPlugin.h"
#include "ScriptAccount.h"
using namespace Tomahawk;
ScriptObject::ScriptObject( const QString& id, ScriptPlugin* parent )
ScriptObject::ScriptObject( const QString& id, ScriptAccount* parent )
: QObject( parent )
, d_ptr( new ScriptObjectPrivate( this, id, parent ))
{
@ -39,7 +39,7 @@ ScriptObject::invoke( const QString& methodName, const QVariantMap& arguments )
{
Q_D( ScriptObject );
return d->scriptPlugin->invoke( this, methodName, arguments );
return d->scriptAccount->invoke( this, methodName, arguments );
}
@ -57,5 +57,5 @@ ScriptObject::startJob( ScriptJob* scriptJob )
{
Q_D( const ScriptObject );
d->scriptPlugin->startJob( scriptJob );
d->scriptAccount->startJob( scriptJob );
}

View File

@ -27,17 +27,17 @@
namespace Tomahawk
{
class ScriptPlugin;
class ScriptAccount;
class ScriptObjectPrivate;
class ScriptJob;
class DLLEXPORT ScriptObject : public QObject
{
friend class JSPlugin;
friend class JSAccount;
friend class ScriptJob;
public:
ScriptObject( const QString& id, ScriptPlugin* parent );
ScriptObject( const QString& id, ScriptAccount* parent );
virtual ~ScriptObject();
ScriptJob* invoke( const QString& methodName, const QVariantMap& arguments );

View File

@ -28,10 +28,10 @@ class ScriptObjectPrivate
{
friend class ScriptObject;
public:
ScriptObjectPrivate( ScriptObject* q, const QString& id, ScriptPlugin* scriptPlugin )
ScriptObjectPrivate( ScriptObject* q, const QString& id, ScriptAccount* scriptAccount )
: q_ptr ( q )
, id( id )
, scriptPlugin( scriptPlugin )
, scriptAccount( scriptAccount )
{
}
ScriptObject* q_ptr;
@ -39,7 +39,7 @@ public:
private:
QString id;
ScriptPlugin* scriptPlugin;
ScriptAccount* scriptAccount;
};
} // ns: Tomahawk