1
0
mirror of https://github.com/tomahawk-player/tomahawk.git synced 2025-08-04 21:27:58 +02:00

Allow registering C++-plugins from JS, make them usable and use the new api in ScriptLinkGeneratorPlugin

This commit is contained in:
Dominik Schmidt
2014-12-01 19:18:10 +01:00
parent 166be08da3
commit ec3f40718e
17 changed files with 613 additions and 10 deletions

View File

@@ -590,3 +590,31 @@ Tomahawk.setTimeout = Tomahawk.setTimeout || window.setTimeout;
Tomahawk.setInterval = Tomahawk.setInterval || window.setInterval;
Tomahawk.base64Decode = function(a) { return window.atob(a); };
Tomahawk.base64Encode = function(b) { return window.btoa(b); };
Tomahawk.PluginManager = {
objects: {},
identifyObject: function (object) {
if( object.id === undefined ) {
// FIXME: get a proper unique id
object.id = "foobar";
}
return object.id;
},
registerPlugin: function (type, object) {
this.objects[this.identifyObject(object)] = object;
Tomahawk.registerScriptPlugin(type, object.id);
},
invoke: function (requestId, objectId, methodName, params ) {
this.objects[objectId][methodName](params).then(function (result) {
Tomahawk.reportScriptJobResults({
requestId: requestId,
data: result
});
},function (error) {
Tomahawk.reportScriptJobResults({error: error});
});
}
};