mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-08 07:07:05 +02:00
Address simple issues raised in PR
This commit is contained in:
@@ -594,7 +594,7 @@ Tomahawk.base64Encode = function(b) { return window.btoa(b); };
|
||||
Tomahawk.PluginManager = {
|
||||
objects: {},
|
||||
identifyObject: function (object) {
|
||||
if( object.id === undefined ) {
|
||||
if( !object.hasOwnProperty('id') ) {
|
||||
object.id = Tomahawk.uuid();
|
||||
}
|
||||
|
||||
@@ -612,7 +612,7 @@ Tomahawk.PluginManager = {
|
||||
requestId: requestId,
|
||||
data: result
|
||||
});
|
||||
},function (error) {
|
||||
}, function (error) {
|
||||
Tomahawk.reportScriptJobResults({error: error});
|
||||
});
|
||||
}
|
||||
|
@@ -120,7 +120,8 @@ JSPlugin::startJob( ScriptJob* scriptJob )
|
||||
.arg( scriptJob->methodName() )
|
||||
.arg( serializeQVariantMap( scriptJob->arguments() ) );
|
||||
|
||||
tLog() << Q_FUNC_INFO << eval;
|
||||
// Remove when new scripting api turned out to work reliably
|
||||
tDebug( LOGVERBOSE ) << Q_FUNC_INFO << eval;
|
||||
|
||||
evaluateJavaScript( eval );
|
||||
}
|
||||
|
@@ -48,18 +48,18 @@ public:
|
||||
const QString name() const;
|
||||
|
||||
/**
|
||||
* Evaluate JavaScript on the WebKit thread
|
||||
*/
|
||||
* Evaluate JavaScript on the WebKit thread
|
||||
*/
|
||||
Q_INVOKABLE void evaluateJavaScript( const QString& scriptSource );
|
||||
|
||||
/**
|
||||
* This method must be called from the WebKit thread
|
||||
*/
|
||||
* This method must be called from the WebKit thread
|
||||
*/
|
||||
QVariant evaluateJavaScriptWithResult( const QString& scriptSource );
|
||||
|
||||
/**
|
||||
* Escape \ and ' in strings so they are safe to use in JavaScript
|
||||
*/
|
||||
* Escape \ and ' in strings so they are safe to use in JavaScript
|
||||
*/
|
||||
static QString escape( const QString& source );
|
||||
|
||||
|
||||
|
@@ -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 = new JSPlugin( d->name );
|
||||
d->scriptPlugin.reset( new JSPlugin( 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 ) );
|
||||
@@ -87,8 +87,6 @@ JSResolver::~JSResolver()
|
||||
Q_D( JSResolver );
|
||||
if ( !d->stopped )
|
||||
stop();
|
||||
|
||||
delete d->scriptPlugin;
|
||||
}
|
||||
|
||||
|
||||
@@ -233,8 +231,10 @@ JSResolver::init()
|
||||
|
||||
// tomahawk-infosystem.js
|
||||
{
|
||||
// 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 );
|
||||
d->infoSystemHelper = new JSInfoSystemHelper( d->scriptPlugin.get() );
|
||||
d->scriptPlugin->addToJavaScriptWindowObject( "_TomahawkInfoSystem", d->infoSystemHelper );
|
||||
d->scriptPlugin->evaluateJavaScript( "Tomahawk.InfoSystem = _TomahawkInfoSystem;" );
|
||||
|
||||
@@ -967,8 +967,6 @@ JSResolver::callOnResolver( const QString& scriptSource )
|
||||
|
||||
QString propertyName = scriptSource.split('(').first();
|
||||
|
||||
tLog() << "JAVASCRIPT: run: " << scriptSource;
|
||||
|
||||
return d->scriptPlugin->evaluateJavaScriptWithResult( QString(
|
||||
"if(Tomahawk.resolver.instance['_adapter_%1']) {"
|
||||
" Tomahawk.resolver.instance._adapter_%2;"
|
||||
|
@@ -27,8 +27,6 @@
|
||||
#include "ExternalResolverGui.h"
|
||||
#include "Typedefs.h"
|
||||
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
#include "ScriptEngine.h" // hack, also should be renamed to JSEngine
|
||||
|
||||
namespace Tomahawk
|
||||
|
@@ -28,6 +28,8 @@
|
||||
#include "JSInfoSystemHelper.h"
|
||||
#include "database/fuzzyindex/FuzzyIndex.h"
|
||||
|
||||
#include <memory> // unique_ptr
|
||||
|
||||
namespace Tomahawk
|
||||
{
|
||||
|
||||
@@ -42,7 +44,6 @@ public:
|
||||
, stopped( true )
|
||||
, error( Tomahawk::ExternalResolver::NoError )
|
||||
, resolverHelper( new JSResolverHelper( scriptPath, q ) )
|
||||
// TODO: be smarter about this, only instantiate this if the resolver supports infoplugins
|
||||
, infoSystemHelper( nullptr )
|
||||
, requiredScriptPaths( additionalScriptPaths )
|
||||
{
|
||||
@@ -68,7 +69,7 @@ private:
|
||||
QList< QVariant > dataWidgets;
|
||||
QStringList requiredScriptPaths;
|
||||
|
||||
JSPlugin* scriptPlugin;
|
||||
std::unique_ptr<JSPlugin> scriptPlugin;
|
||||
};
|
||||
|
||||
} // ns: Tomahawk
|
||||
|
@@ -26,7 +26,6 @@ namespace Tomahawk
|
||||
|
||||
class ScriptLinkGeneratorPluginPrivate
|
||||
{
|
||||
friend class ScriptLinkGeneratorPlugin;
|
||||
public:
|
||||
ScriptLinkGeneratorPluginPrivate( ScriptLinkGeneratorPlugin* q, ScriptObject* scriptObject )
|
||||
: q_ptr ( q )
|
||||
|
@@ -31,7 +31,9 @@ using namespace Tomahawk;
|
||||
static QString
|
||||
requestIdGenerator()
|
||||
{
|
||||
return uuid();
|
||||
static int requestCounter = 0;
|
||||
return QString::number( ++requestCounter );
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user