1
0
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:
Dominik Schmidt
2014-12-05 03:22:59 +01:00
parent 8ecb67178b
commit 3d4cfa0161
8 changed files with 20 additions and 21 deletions

View File

@@ -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});
});
}

View File

@@ -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 );
}

View File

@@ -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;"

View File

@@ -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

View File

@@ -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

View File

@@ -26,7 +26,6 @@ namespace Tomahawk
class ScriptLinkGeneratorPluginPrivate
{
friend class ScriptLinkGeneratorPlugin;
public:
ScriptLinkGeneratorPluginPrivate( ScriptLinkGeneratorPlugin* q, ScriptObject* scriptObject )
: q_ptr ( q )

View File

@@ -31,7 +31,9 @@ using namespace Tomahawk;
static QString
requestIdGenerator()
{
return uuid();
static int requestCounter = 0;
return QString::number( ++requestCounter );
}