fixed camera and capture API's for playbook due to webworks bug and also fixed capture API for playbook (returning a path instead of an array of file objects)
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/e8f1cefb Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/e8f1cefb Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/e8f1cefb Branch: refs/heads/master Commit: e8f1cefbd4283934968f6497d1116fbef3445bf2 Parents: 20b7e60 Author: Gord Tanner <[email protected]> Authored: Wed May 30 14:43:14 2012 -0400 Committer: Tim Kim <[email protected]> Committed: Thu Jun 7 13:50:55 2012 -0700 ---------------------------------------------------------------------- lib/playbook/plugin/playbook/camera.js | 13 ++++++++- lib/playbook/plugin/playbook/capture.js | 38 ++++++++++++++++++++----- 2 files changed, 42 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e8f1cefb/lib/playbook/plugin/playbook/camera.js ---------------------------------------------------------------------- diff --git a/lib/playbook/plugin/playbook/camera.js b/lib/playbook/plugin/playbook/camera.js index e8e6af2..e4366aa 100644 --- a/lib/playbook/plugin/playbook/camera.js +++ b/lib/playbook/plugin/playbook/camera.js @@ -2,7 +2,18 @@ var cordova = require('cordova'); module.exports = { takePicture: function (args, win, fail) { - blackberry.media.camera.takePicture(win, fail, fail); + var onCaptured = blackberry.events.registerEventHandler("onCaptured", win), + onCameraClosed = blackberry.events.registerEventHandler("onCameraClosed", function () {}), + onError = blackberry.events.registerEventHandler("onError", fail), + request = new blackberry.transport.RemoteFunctionCall('blackberry/media/camera/takePicture'); + + request.addParam("onCaptured", onCaptured); + request.addParam("onCameraClosed", onCameraClosed); + request.addParam("onError", onError); + + //HACK: this is a sync call due to: + //https://github.com/blackberry/WebWorks-TabletOS/issues/51 + request.makeSyncCall(); return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; } }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/e8f1cefb/lib/playbook/plugin/playbook/capture.js ---------------------------------------------------------------------- diff --git a/lib/playbook/plugin/playbook/capture.js b/lib/playbook/plugin/playbook/capture.js index b6bc0d2..6126799 100644 --- a/lib/playbook/plugin/playbook/capture.js +++ b/lib/playbook/plugin/playbook/capture.js @@ -1,6 +1,32 @@ var cordova = require('cordova'); +function capture(action, win, fail) { + var onCaptured = blackberry.events.registerEventHandler("onCaptured", function (path) { + var file = blackberry.io.file.getFileProperties(path); + win([{ + fullPath: path, + lastModifiedDate: file.dateModified, + name: path.replace(file.directory + "/", ""), + size: file.size, + type: file.fileExtension + }]); + }), + onCameraClosed = blackberry.events.registerEventHandler("onCameraClosed", function () {}), + onError = blackberry.events.registerEventHandler("onError", fail), + request = new blackberry.transport.RemoteFunctionCall('blackberry/media/camera/' + action); + + + request.addParam("onCaptured", onCaptured); + request.addParam("onCameraClosed", onCameraClosed); + request.addParam("onError", onError); + + //HACK: this is a sync call due to: + //https://github.com/blackberry/WebWorks-TabletOS/issues/51 + request.makeSyncCall(); +} + module.exports = { + foo: capture, getSupportedAudioModes: function (args, win, fail) { return {"status": cordova.callbackStatus.OK, "message": []}; }, @@ -11,10 +37,8 @@ module.exports = { return {"status": cordova.callbackStatus.OK, "message": []}; }, captureImage: function (args, win, fail) { - var limit = args[0].limit; - - if (limit > 0) { - blackberry.media.camera.takePicture(win, fail, fail); + if (args[0].limit > 0) { + capture("takePicture", win, fail); } else { win([]); @@ -23,10 +47,8 @@ module.exports = { return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; }, captureVideo: function (args, win, fail) { - var limit = args[0]; - - if (limit > 0) { - blackberry.media.camera.takeVideo(win, fail, fail); + if (args[0].limit > 0) { + capture("takeVideo", win, fail); } else { win([]);
