1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-10 16:14:40 +02:00

Port ScriptInfoPlugin to new generic script plugin infrastructure

This commit is contained in:
Dominik Schmidt
2015-01-05 00:57:13 +01:00
parent 5e5ff7938a
commit 07838afaa6
20 changed files with 167 additions and 404 deletions

View File

@@ -615,8 +615,8 @@ Tomahawk.PluginManager = {
Tomahawk.registerScriptPlugin(type, object.id);
},
invoke: function (requestId, objectId, methodName, params ) {
Tomahawk.log("requestId: " + requestId + " objectId: " + objectId + " methodName: " + methodName + " params: " + params);
invokeSync: function (objectId, methodName, params) {
if (!this.objects[objectId]) {
Tomahawk.log("Object not found!");
} else {
@@ -625,7 +625,15 @@ Tomahawk.PluginManager = {
}
}
Promise.resolve(this.objects[objectId][methodName](params)).then(function (result) {
if (typeof this.objects[objectId][methodName] === 'function') {
return this.objects[objectId][methodName](params);
}
return this.objects[objectId][methodName];
},
invoke: function (requestId, objectId, methodName, params ) {
Promise.resolve(this.invokeSync(objectId, methodName, params)).then(function (result) {
if (typeof result === 'object') {
Tomahawk.reportScriptJobResults({
requestId: requestId,
@@ -634,7 +642,7 @@ Tomahawk.PluginManager = {
} else {
Tomahawk.reportScriptJobResults({
requestId: requestId,
error: "Scripts need to return objects for requests"
error: "Scripts need to return objects for requests: methodName: " + methodName + " params: " + JSON.encode(params)
});
}
}, function (error) {