Added BB10 camera and capture support - added support for camera (will not work with external app content due to a webworks bug) - added support for capture - cleaned whitespace - added license headers to some files that were missing
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/c7edd610 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/c7edd610 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/c7edd610 Branch: refs/heads/master Commit: c7edd61023c23ec14b36056106e72e669c972e49 Parents: 5f046e1 Author: Gord Tanner <gtan...@gmail.com> Authored: Tue Oct 2 16:40:43 2012 -0400 Committer: Gord Tanner <gtan...@gmail.com> Committed: Tue Oct 2 16:40:43 2012 -0400 ---------------------------------------------------------------------- lib/common/plugin/Media.js | 4 +- lib/common/plugin/MediaError.js | 2 +- lib/common/plugin/battery.js | 1 - lib/cordova.js | 2 +- lib/ios/exec.js | 2 +- lib/ios/plugin/ios/console.js | 6 +- lib/webworks/qnx/plugin/compass.js | 21 ++++++ lib/webworks/qnx/plugin/manager.js | 2 + lib/webworks/qnx/plugin/qnx/battery.js | 22 ++++++- lib/webworks/qnx/plugin/qnx/camera.js | 32 +++++++++ lib/webworks/qnx/plugin/qnx/capture.js | 76 +++++++++++++++++++++ lib/webworks/qnx/plugin/qnx/compass.js | 23 ++++++- lib/webworks/qnx/plugin/qnx/fileTransfer.js | 21 ++++++ lib/windows8/plugin/windows8/CameraProxy.js | 2 +- lib/windows8/plugin/windows8/CaptureProxy.js | 2 +- 15 files changed, 205 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/common/plugin/Media.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/Media.js b/lib/common/plugin/Media.js index 70072c8..d126ace 100644 --- a/lib/common/plugin/Media.js +++ b/lib/common/plugin/Media.js @@ -193,13 +193,13 @@ Media.onStatus = function(id, msgType, value) { media._duration = value; break; case Media.MEDIA_ERROR : - media.errorCallback && media.errorCallback(value); + media.errorCallback && media.errorCallback(value); break; case Media.MEDIA_POSITION : media._position = Number(value); break; default : - console && console.error && console.error("Unhandled Media.onStatus :: " + msgType); + console && console.error && console.error("Unhandled Media.onStatus :: " + msgType); break; } } http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/common/plugin/MediaError.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/MediaError.js b/lib/common/plugin/MediaError.js index e636f3d..53f40dd 100644 --- a/lib/common/plugin/MediaError.js +++ b/lib/common/plugin/MediaError.js @@ -45,7 +45,7 @@ MediaError.MEDIA_ERR_ABORTED = MediaError.MEDIA_ERR_ABORTED || 1; MediaError.MEDIA_ERR_NETWORK = MediaError.MEDIA_ERR_NETWORK || 2; MediaError.MEDIA_ERR_DECODE = MediaError.MEDIA_ERR_DECODE || 3; MediaError.MEDIA_ERR_NONE_SUPPORTED = MediaError.MEDIA_ERR_NONE_SUPPORTED || 4; -// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below. +// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below. // as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/common/plugin/battery.js ---------------------------------------------------------------------- diff --git a/lib/common/plugin/battery.js b/lib/common/plugin/battery.js index 7dddd4b..1b012ab 100644 --- a/lib/common/plugin/battery.js +++ b/lib/common/plugin/battery.js @@ -44,7 +44,6 @@ var Battery = function() { for (var key in this.channels) { this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange; } - }; /** * Event handlers for when callbacks get registered for the battery. http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/cordova.js ---------------------------------------------------------------------- diff --git a/lib/cordova.js b/lib/cordova.js index 3abcbc6..36b305d 100644 --- a/lib/cordova.js +++ b/lib/cordova.js @@ -136,7 +136,7 @@ var cordova = { }, /** * Method to fire event from native code - * bNoDetach is required for events which cause an exception which needs to be caught in native code + * bNoDetach is required for events which cause an exception which needs to be caught in native code */ fireDocumentEvent: function(type, data, bNoDetach) { var evt = createEvent(type, data); http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/ios/exec.js ---------------------------------------------------------------------- diff --git a/lib/ios/exec.js b/lib/ios/exec.js index acd5873..546fb2c 100644 --- a/lib/ios/exec.js +++ b/lib/ios/exec.js @@ -36,7 +36,7 @@ var cordova = require('cordova'), XHR_OPTIONAL_PAYLOAD: 3 }, // XHR mode does not work on iOS 4.2, so default to IFRAME_NAV for such devices. - // XHR mode's main advantage is working around a bug in -webkit-scroll, which + // XHR mode's main advantage is working around a bug in -webkit-scroll, which // doesn't exist in 4.X devices anyways. bridgeMode = navigator.userAgent.indexOf(' 4_') == -1 ? jsToNativeModes.XHR_OPTIONAL_PAYLOAD : jsToNativeModes.IFRAME_NAV, execIframe, http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/ios/plugin/ios/console.js ---------------------------------------------------------------------- diff --git a/lib/ios/plugin/ios/console.js b/lib/ios/plugin/ios/console.js index 5073f31..6ff5b99 100644 --- a/lib/ios/plugin/ios/console.js +++ b/lib/ios/plugin/ios/console.js @@ -76,7 +76,7 @@ var origConsole_error = origConsole.error || function(){} */ DebugConsole.prototype.log = function(message) { origConsole_log.apply(origConsole, arguments) - + if (this.logLevel <= DebugConsole.INFO_LEVEL) { exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'INFO' } ]); } @@ -88,7 +88,7 @@ DebugConsole.prototype.log = function(message) { */ DebugConsole.prototype.warn = function(message) { origConsole_warn.apply(origConsole, arguments) - + if (this.logLevel <= DebugConsole.WARN_LEVEL) { exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'WARN' } ]); } @@ -100,7 +100,7 @@ DebugConsole.prototype.warn = function(message) { */ DebugConsole.prototype.error = function(message) { origConsole_error.apply(origConsole, arguments) - + if (this.logLevel <= DebugConsole.ERROR_LEVEL) { exec(null, null, 'Debug Console', 'log', [ stringify(message), { logLevel: 'ERROR' } ]); } http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/compass.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/compass.js b/lib/webworks/qnx/plugin/compass.js index 7e07ff3..061ceb5 100644 --- a/lib/webworks/qnx/plugin/compass.js +++ b/lib/webworks/qnx/plugin/compass.js @@ -1,3 +1,24 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + var exec = require('cordova/exec'), utils = require('cordova/utils'), CompassHeading = require('cordova/plugin/CompassHeading'), http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/manager.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/manager.js b/lib/webworks/qnx/plugin/manager.js index c08fb17..acdc4d3 100644 --- a/lib/webworks/qnx/plugin/manager.js +++ b/lib/webworks/qnx/plugin/manager.js @@ -26,6 +26,8 @@ var cordova = require('cordova'), 'Device' : require('cordova/plugin/qnx/device'), 'Battery' : require('cordova/plugin/qnx/battery'), 'Compass' : require('cordova/plugin/qnx/compass'), + 'Camera' : require('cordova/plugin/qnx/camera'), + 'Capture' : require('cordova/plugin/qnx/capture'), 'Logger' : require('cordova/plugin/webworks/logger'), 'Notification' : require('cordova/plugin/webworks/notification'), 'Media': require('cordova/plugin/webworks/media') http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/qnx/battery.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/qnx/battery.js b/lib/webworks/qnx/plugin/qnx/battery.js index f1ae695..1971a49 100644 --- a/lib/webworks/qnx/plugin/qnx/battery.js +++ b/lib/webworks/qnx/plugin/qnx/battery.js @@ -1,7 +1,27 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + var cordova = require('cordova'), handler; - module.exports = { start: function (args, win, fail) { handler = win; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/qnx/camera.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/qnx/camera.js b/lib/webworks/qnx/plugin/qnx/camera.js new file mode 100644 index 0000000..c357437 --- /dev/null +++ b/lib/webworks/qnx/plugin/qnx/camera.js @@ -0,0 +1,32 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var cordova = require('cordova'); + +module.exports = { + takePicture: function (args, win, fail) { + var noop = function () {}; + blackberry.invoke.card.invokeCamera("photo", function (path) { + win("file://" + path); + }, noop, noop); + return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; + } +}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/qnx/capture.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/qnx/capture.js b/lib/webworks/qnx/plugin/qnx/capture.js new file mode 100644 index 0000000..41c5de0 --- /dev/null +++ b/lib/webworks/qnx/plugin/qnx/capture.js @@ -0,0 +1,76 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + +var cordova = require('cordova'); + +function capture(action, win, fail) { + var noop = function () {}; + + blackberry.invoke.card.invokeCamera(action, function (path) { + var sb = blackberry.io.sandbox; + blackberry.io.sandbox = false; + webkitRequestFileSystem(PERSISTENT, 1024, function (fs) { + fs.root.getFile(path, {}, function (fe) { + fe.file(function (file) { + file.fullPath = fe.fullPath; + win([file]); + blackberry.io.sandbox = sb; + }, fail); + }, fail); + }, fail); + }, noop, noop); +} + +module.exports = { + getSupportedAudioModes: function (args, win, fail) { + return {"status": cordova.callbackStatus.OK, "message": []}; + }, + getSupportedImageModes: function (args, win, fail) { + return {"status": cordova.callbackStatus.OK, "message": []}; + }, + getSupportedVideoModes: function (args, win, fail) { + return {"status": cordova.callbackStatus.OK, "message": []}; + }, + captureImage: function (args, win, fail) { + if (args[0].limit > 0) { + capture("photo", win, fail); + } + else { + win([]); + } + + return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; + }, + captureVideo: function (args, win, fail) { + if (args[0].limit > 0) { + capture("video", win, fail); + } + else { + win([]); + } + + return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; + }, + captureAudio: function (args, win, fail) { + fail("Capturing Audio not supported"); + return {"status": cordova.callbackStatus.NO_RESULT, "message": "WebWorks Is On It"}; + } +}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/qnx/compass.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/qnx/compass.js b/lib/webworks/qnx/plugin/qnx/compass.js index 6800d69..f636ac0 100644 --- a/lib/webworks/qnx/plugin/qnx/compass.js +++ b/lib/webworks/qnx/plugin/qnx/compass.js @@ -1,3 +1,24 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + var cordova = require('cordova'), callback; @@ -21,4 +42,4 @@ module.exports = { window.removeEventListener("deviceorientation", callback); return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" }; } -} +}; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/webworks/qnx/plugin/qnx/fileTransfer.js ---------------------------------------------------------------------- diff --git a/lib/webworks/qnx/plugin/qnx/fileTransfer.js b/lib/webworks/qnx/plugin/qnx/fileTransfer.js index 6010da0..0433f0c 100644 --- a/lib/webworks/qnx/plugin/qnx/fileTransfer.js +++ b/lib/webworks/qnx/plugin/qnx/fileTransfer.js @@ -1,3 +1,24 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * +*/ + var cordova = require('cordova'); module.exports = { http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/windows8/plugin/windows8/CameraProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/CameraProxy.js b/lib/windows8/plugin/windows8/CameraProxy.js index 96cbefe..28694d6 100644 --- a/lib/windows8/plugin/windows8/CameraProxy.js +++ b/lib/windows8/plugin/windows8/CameraProxy.js @@ -55,7 +55,7 @@ module.exports = { var pkg = Windows.ApplicationModel.Package.current; var packageId = pkg.installedLocation; - + var fail = function (fileError) { errorCallback("FileError, code:" + fileError.code); }; http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/c7edd610/lib/windows8/plugin/windows8/CaptureProxy.js ---------------------------------------------------------------------- diff --git a/lib/windows8/plugin/windows8/CaptureProxy.js b/lib/windows8/plugin/windows8/CaptureProxy.js index dddae68..a1dd4b0 100644 --- a/lib/windows8/plugin/windows8/CaptureProxy.js +++ b/lib/windows8/plugin/windows8/CaptureProxy.js @@ -33,7 +33,7 @@ module.exports = { // No UI support. The duration of the audio recording. captureAudio:function(successCallback, errorCallback, options) { - + var cameraCaptureAudioDuration = 1024; options = options[0]; var audioOptions = new CaptureAudioOptions();