You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/05/14 23:12:42 UTC
[03/38] js commit: [BlackBerry10] Split out to new top-level platform
[BlackBerry10] Split out to new top-level platform
Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/615aea47
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/615aea47
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/615aea47
Branch: refs/heads/3.0.0
Commit: 615aea47a568bd11aa86b8813fef9a3aacaec8ba
Parents: 26796d7
Author: Bryan Higgins <bh...@rim.com>
Authored: Thu Feb 7 10:02:28 2013 -0500
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:48:50 2013 -0400
----------------------------------------------------------------------
Jakefile | 1 +
build/packager.js | 1 +
lib/blackberry/platform.js | 5 +-
lib/blackberry/plugin/qnx/InAppBrowser.js | 86 ---
lib/blackberry/plugin/qnx/battery.js | 40 --
lib/blackberry/plugin/qnx/camera.js | 32 --
lib/blackberry/plugin/qnx/capture.js | 76 ---
lib/blackberry/plugin/qnx/compass.js | 162 ------
lib/blackberry/plugin/qnx/device.js | 41 --
lib/blackberry/plugin/qnx/file.js | 424 ---------------
lib/blackberry/plugin/qnx/fileTransfer.js | 205 -------
lib/blackberry/plugin/qnx/magnetometer.js | 45 --
lib/blackberry/plugin/qnx/manager.js | 60 --
lib/blackberry/plugin/qnx/network.js | 28 -
lib/blackberry/plugin/qnx/platform.js | 44 --
lib/blackberry10/exec.js | 79 +++
lib/blackberry10/platform.js | 39 ++
.../plugin/blackberry10/InAppBrowser.js | 86 +++
.../plugin/blackberry10/accelerometer.js | 43 ++
lib/blackberry10/plugin/blackberry10/battery.js | 40 ++
lib/blackberry10/plugin/blackberry10/camera.js | 32 ++
lib/blackberry10/plugin/blackberry10/capture.js | 76 +++
lib/blackberry10/plugin/blackberry10/compass.js | 162 ++++++
lib/blackberry10/plugin/blackberry10/device.js | 41 ++
lib/blackberry10/plugin/blackberry10/file.js | 424 +++++++++++++++
.../plugin/blackberry10/fileTransfer.js | 205 +++++++
lib/blackberry10/plugin/blackberry10/logger.js | 30 +
.../plugin/blackberry10/magnetometer.js | 45 ++
lib/blackberry10/plugin/blackberry10/manager.js | 60 ++
lib/blackberry10/plugin/blackberry10/media.js | 189 +++++++
lib/blackberry10/plugin/blackberry10/network.js | 28 +
.../plugin/blackberry10/notification.js | 52 ++
lib/blackberry10/plugin/blackberry10/platform.js | 44 ++
lib/scripts/bootstrap-blackberry.js | 20 +-
lib/scripts/bootstrap-blackberry10.js | 34 ++
test/blackberry/qnx/test.battery.js | 72 ---
test/blackberry/qnx/test.camera.js | 59 --
test/blackberry/qnx/test.capture.js | 222 --------
test/blackberry/qnx/test.compass.js | 61 --
test/blackberry/qnx/test.device.js | 48 --
test/blackberry/qnx/test.fileTransfer.js | 85 ---
test/blackberry/qnx/test.magnetometer.js | 80 ---
test/blackberry/qnx/test.manager.js | 56 --
test/blackberry/qnx/test.network.js | 39 --
test/blackberry/qnx/test.platform.js | 123 -----
test/blackberry/test.exec.js | 16 +-
test/blackberry/test.platform.js | 25 +-
test/blackberry10/test.battery.js | 72 +++
test/blackberry10/test.camera.js | 59 ++
test/blackberry10/test.capture.js | 222 ++++++++
test/blackberry10/test.compass.js | 61 ++
test/blackberry10/test.device.js | 48 ++
test/blackberry10/test.fileTransfer.js | 85 +++
test/blackberry10/test.magnetometer.js | 80 +++
test/blackberry10/test.manager.js | 56 ++
test/blackberry10/test.network.js | 39 ++
test/blackberry10/test.platform.js | 117 ++++
57 files changed, 2568 insertions(+), 2136 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/Jakefile
----------------------------------------------------------------------
diff --git a/Jakefile b/Jakefile
index bd1639e..55af2d8 100644
--- a/Jakefile
+++ b/Jakefile
@@ -89,6 +89,7 @@ task('build', ['clean', 'hint'], function () {
packager.generate("windows8", version,true);
packager.generate("blackberry", version);
+ packager.generate("blackberry10", version);
packager.generate("firefoxos", version);
packager.generate("ios", version);
packager.generate("windowsphone", version,true);
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 0801451..8cb6e0f 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -57,6 +57,7 @@ packager.bundle = function(platform, debug, commitId ) {
//Test platform needs to bring in platform specific plugin's for testing
copyProps(modules, collectFiles(path.join('lib', 'blackberry', 'plugin'), 'plugin'));
+ copyProps(modules, collectFiles(path.join('lib', 'blackberry10', 'plugin'), 'plugin'));
copyProps(modules, collectFiles(path.join('lib', 'firefoxos', 'plugin', 'firefoxos'), 'plugin/firefoxos'));
copyProps(modules, collectFiles(path.join('lib', 'tizen', 'plugin', 'tizen'), 'plugin/tizen'));
copyProps(modules, collectFiles(path.join('lib', 'windowsphone', 'plugin', 'windowsphone'), 'plugin/windowsphone'));
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/platform.js b/lib/blackberry/platform.js
index 0e9dd79..c6bdddd 100644
--- a/lib/blackberry/platform.js
+++ b/lib/blackberry/platform.js
@@ -22,10 +22,7 @@
module.exports = {
id: "blackberry",
runtime: function () {
- if (navigator.userAgent.indexOf("BB10") > -1) {
- return 'qnx';
- }
- else if (navigator.userAgent.indexOf("PlayBook") > -1) {
+ if (navigator.userAgent.indexOf("PlayBook") > -1) {
return 'air';
}
else if (navigator.userAgent.indexOf("BlackBerry") > -1) {
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/InAppBrowser.js b/lib/blackberry/plugin/qnx/InAppBrowser.js
deleted file mode 100644
index e42a293..0000000
--- a/lib/blackberry/plugin/qnx/InAppBrowser.js
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- *
- * 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'),
- modulemapper = require('cordova/modulemapper'),
- origOpen = modulemapper.getOriginalSymbol(window, 'open'),
- browser = {
- close: function () { } //dummy so we don't have to check for undefined
- };
-
-var navigate = {
- "_blank": function (url, whitelisted) {
- return origOpen(url, "_blank");
- },
-
- "_self": function (url, whitelisted) {
- if (whitelisted) {
- window.location.href = url;
- return window;
- }
- else {
- return origOpen(url, "_blank");
- }
- },
-
- "_system": function (url, whitelisted) {
- blackberry.invoke.invoke({
- target: "sys.browser",
- uri: url
- }, function () {}, function () {});
-
- return {
- close: function () { }
- };
- }
-};
-
-module.exports = {
- open: function (args, win, fail) {
- var url = args[0],
- target = args[1] || '_self',
- a = document.createElement('a');
-
- //Make all URLs absolute
- a.href = url;
- url = a.href;
-
- switch (target) {
- case '_self':
- case '_system':
- case '_blank':
- break;
- default:
- target = '_blank';
- break;
- }
-
- webworks.exec(function (whitelisted) {
- browser = navigate[target](url, whitelisted);
- }, fail, "org.apache.cordova", "isWhitelisted", [url], true);
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "" };
- },
- close: function (args, win, fail) {
- browser.close();
- return { "status" : cordova.callbackStatus.OK, "message" : "" };
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/battery.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/battery.js b/lib/blackberry/plugin/qnx/battery.js
deleted file mode 100644
index 8bd9f44..0000000
--- a/lib/blackberry/plugin/qnx/battery.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * 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'),
- interval;
-
-module.exports = {
- start: function (args, win, fail) {
- interval = window.setInterval(function () {
- win({
- level: navigator.webkitBattery.level * 100,
- isPlugged: navigator.webkitBattery.charging
- });
- }, 500);
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
-
- stop: function (args, win, fail) {
- window.clearInterval(interval);
- return { "status" : cordova.callbackStatus.OK, "message" : "stopped" };
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/camera.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/camera.js b/lib/blackberry/plugin/qnx/camera.js
deleted file mode 100644
index c357437..0000000
--- a/lib/blackberry/plugin/qnx/camera.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * 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/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/capture.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/capture.js b/lib/blackberry/plugin/qnx/capture.js
deleted file mode 100644
index 3c8f1cb..0000000
--- a/lib/blackberry/plugin/qnx/capture.js
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- *
- * 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;
- window.webkitRequestFileSystem(window.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/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/compass.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/compass.js b/lib/blackberry/plugin/qnx/compass.js
deleted file mode 100644
index 061ceb5..0000000
--- a/lib/blackberry/plugin/qnx/compass.js
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- *
- * 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'),
- CompassError = require('cordova/plugin/CompassError'),
- timers = {},
- listeners = [],
- heading = null,
- running = false,
- start = function () {
- exec(function (result) {
- heading = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
- listeners.forEach(function (l) {
- l.win(heading);
- });
- }, function (e) {
- listeners.forEach(function (l) {
- l.fail(e);
- });
- },
- "Compass", "start", []);
- running = true;
- },
- stop = function () {
- exec(null, null, "Compass", "stop", []);
- running = false;
- },
- createCallbackPair = function (win, fail) {
- return {win:win, fail:fail};
- },
- removeListeners = function (l) {
- var idx = listeners.indexOf(l);
- if (idx > -1) {
- listeners.splice(idx, 1);
- if (listeners.length === 0) {
- stop();
- }
- }
- },
- compass = {
- /**
- * Asynchronously acquires the current heading.
- * @param {Function} successCallback The function to call when the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {CompassOptions} options The options for getting the heading data (not used).
- */
- getCurrentHeading:function(successCallback, errorCallback, options) {
- if (typeof successCallback !== "function") {
- throw "getCurrentHeading must be called with at least a success callback function as first parameter.";
- }
-
- var p;
- var win = function(a) {
- removeListeners(p);
- successCallback(a);
- };
- var fail = function(e) {
- removeListeners(p);
- errorCallback(e);
- };
-
- p = createCallbackPair(win, fail);
- listeners.push(p);
-
- if (!running) {
- start();
- }
- },
-
- /**
- * Asynchronously acquires the heading repeatedly at a given interval.
- * @param {Function} successCallback The function to call each time the heading
- * data is available
- * @param {Function} errorCallback The function to call when there is an error
- * getting the heading data.
- * @param {HeadingOptions} options The options for getting the heading data
- * such as timeout and the frequency of the watch. For iOS, filter parameter
- * specifies to watch via a distance filter rather than time.
- */
- watchHeading:function(successCallback, errorCallback, options) {
- var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
- var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return;
- }
- // Keep reference to watch id, and report heading readings as often as defined in frequency
- var id = utils.createUUID();
-
- var p = createCallbackPair(function(){}, function(e) {
- removeListeners(p);
- errorCallback(e);
- });
- listeners.push(p);
-
- timers[id] = {
- timer:window.setInterval(function() {
- if (heading) {
- successCallback(heading);
- }
- }, frequency),
- listeners:p
- };
-
- if (running) {
- // If we're already running then immediately invoke the success callback
- // but only if we have retrieved a value, sample code does not check for null ...
- if(heading) {
- successCallback(heading);
- }
- } else {
- start();
- }
-
- return id;
- },
-
- /**
- * Clears the specified heading watch.
- * @param {String} watchId The ID of the watch returned from #watchHeading.
- */
- clearWatch:function(id) {
- // Stop javascript timer & remove from timer list
- if (id && timers[id]) {
- window.clearInterval(timers[id].timer);
- removeListeners(timers[id].listeners);
- delete timers[id];
- }
- }
- };
-
-module.exports = compass;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/device.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/device.js b/lib/blackberry/plugin/qnx/device.js
deleted file mode 100644
index 8898e09..0000000
--- a/lib/blackberry/plugin/qnx/device.js
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * 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 channel = require('cordova/channel'),
- cordova = require('cordova');
-
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
-module.exports = {
- getDeviceInfo : function(args, win, fail){
- win({
- platform: "BlackBerry",
- version: blackberry.system.softwareVersion,
- model: "Dev Alpha",
- name: "Dev Alpha", // deprecated: please use device.model
- uuid: blackberry.identity.uuid,
- cordova: CORDOVA_JS_BUILD_LABEL
- });
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "Device info returned" };
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/file.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/file.js b/lib/blackberry/plugin/qnx/file.js
deleted file mode 100644
index d611daf..0000000
--- a/lib/blackberry/plugin/qnx/file.js
+++ /dev/null
@@ -1,424 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-/*global WebKitBlobBuilder:false */
-/*global Blob:false */
-var cordova = require('cordova'),
- FileError = require('cordova/plugin/FileError'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- File = require('cordova/plugin/File'),
- FileSystem = require('cordova/plugin/FileSystem'),
- FileReader = require('cordova/plugin/FileReader'),
- nativeRequestFileSystem = window.webkitRequestFileSystem,
- nativeResolveLocalFileSystemURI = function(uri, success, fail) {
- if (uri.substring(0,11) !== "filesystem:") {
- uri = "filesystem:" + uri;
- }
- window.webkitResolveLocalFileSystemURL(uri, success, fail);
- },
- NativeFileReader = window.FileReader;
-
-window.FileReader = FileReader;
-window.File = File;
-
-function getFileSystemName(nativeFs) {
- return (nativeFs.name.indexOf("Persistent") != -1) ? "persistent" : "temporary";
-}
-
-function makeEntry(entry) {
- if (entry.isDirectory) {
- return new DirectoryEntry(entry.name, decodeURI(entry.toURL()).substring(11));
- }
- else {
- return new FileEntry(entry.name, decodeURI(entry.toURL()).substring(11));
- }
-}
-
-module.exports = {
- /* requestFileSystem */
- requestFileSystem: function(args, successCallback, errorCallback) {
- var type = args[0],
- size = args[1];
-
- nativeRequestFileSystem(type, size, function(nativeFs) {
- successCallback(new FileSystem(getFileSystemName(nativeFs), makeEntry(nativeFs.root)));
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* resolveLocalFileSystemURI */
- resolveLocalFileSystemURI: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- var code = error.code;
- switch (code) {
- case 5:
- code = FileError.NOT_FOUND_ERR;
- break;
-
- case 2:
- code = FileError.ENCODING_ERR;
- break;
- }
- errorCallback(code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* DirectoryReader */
- readEntries: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(dirEntry) {
- var reader = dirEntry.createReader();
- reader.readEntries(function(entries) {
- var retVal = [];
- for (var i = 0; i < entries.length; i++) {
- retVal.push(makeEntry(entries[i]));
- }
- successCallback(retVal);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* Entry */
- getMetadata: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getMetadata(function(metaData) {
- successCallback(metaData.modificationTime);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- moveTo: function(args, successCallback, errorCallback) {
- var srcUri = args[0],
- parentUri = args[1],
- name = args[2];
-
- nativeResolveLocalFileSystemURI(srcUri, function(source) {
- nativeResolveLocalFileSystemURI(parentUri, function(parent) {
- source.moveTo(parent, name, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- copyTo: function(args, successCallback, errorCallback) {
- var srcUri = args[0],
- parentUri = args[1],
- name = args[2];
-
- nativeResolveLocalFileSystemURI(srcUri, function(source) {
- nativeResolveLocalFileSystemURI(parentUri, function(parent) {
- source.copyTo(parent, name, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- remove: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- if (entry.fullPath === "/") {
- errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
- } else {
- entry.remove(
- function (success) {
- if (successCallback) {
- successCallback(success);
- }
- },
- function(error) {
- if (errorCallback) {
- errorCallback(error.code);
- }
- }
- );
- }
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- getParent: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getParent(function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* FileEntry */
- getFileMetadata: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.file(function(file) {
- var retVal = new File(file.name, decodeURI(entry.toURL()), file.type, file.lastModifiedDate, file.size);
- successCallback(retVal);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* DirectoryEntry */
- getDirectory: function(args, successCallback, errorCallback) {
- var uri = args[0],
- path = args[1],
- options = args[2];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getDirectory(path, options, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- if (error.code === FileError.INVALID_MODIFICATION_ERR) {
- if (options.create) {
- errorCallback(FileError.PATH_EXISTS_ERR);
- } else {
- errorCallback(FileError.ENCODING_ERR);
- }
- } else {
- errorCallback(error.code);
- }
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- removeRecursively: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- if (entry.fullPath === "/") {
- errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
- } else {
- entry.removeRecursively(
- function (success) {
- if (successCallback) {
- successCallback(success);
- }
- },
- function(error) {
- errorCallback(error.code);
- }
- );
- }
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- getFile: function(args, successCallback, errorCallback) {
- var uri = args[0],
- path = args[1],
- options = args[2];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getFile(path, options, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- if (error.code === FileError.INVALID_MODIFICATION_ERR) {
- if (options.create) {
- errorCallback(FileError.PATH_EXISTS_ERR);
- } else {
- errorCallback(FileError.NOT_FOUND_ERR);
- }
- } else {
- errorCallback(error.code);
- }
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* FileReader */
- readAsText: function(args, successCallback, errorCallback) {
- var uri = args[0],
- encoding = args[1];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onLoadEnd = function(evt) {
- if (!evt.target.error) {
- successCallback(evt.target.result);
- }
- },
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- var reader = new NativeFileReader();
-
- reader.onloadend = onLoadEnd;
- reader.onerror = onError;
- entry.file(function(file) {
- reader.readAsText(file, encoding);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- readAsDataURL: function(args, successCallback, errorCallback) {
- var uri = args[0];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onLoadEnd = function(evt) {
- if (!evt.target.error) {
- successCallback(evt.target.result);
- }
- },
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- var reader = new NativeFileReader();
-
- reader.onloadend = onLoadEnd;
- reader.onerror = onError;
- entry.file(function(file) {
- reader.readAsDataURL(file);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- /* FileWriter */
- write: function(args, successCallback, errorCallback) {
- var uri = args[0],
- text = args[1],
- position = args[2];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onWriteEnd = function(evt) {
- if(!evt.target.error) {
- successCallback(evt.target.position - position);
- } else {
- errorCallback(evt.target.error.code);
- }
- },
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- entry.createWriter(function(writer) {
- writer.onwriteend = onWriteEnd;
- writer.onerror = onError;
-
- writer.seek(position);
- writer.write(new Blob([text], {type: "text/plain"}));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- truncate: function(args, successCallback, errorCallback) {
- var uri = args[0],
- size = args[1];
-
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onWriteEnd = function(evt) {
- if(!evt.target.error) {
- successCallback(evt.target.length);
- } else {
- errorCallback(evt.target.error.code);
- }
- },
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- entry.createWriter(function(writer) {
- writer.onwriteend = onWriteEnd;
- writer.onerror = onError;
-
- writer.truncate(size);
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/fileTransfer.js b/lib/blackberry/plugin/qnx/fileTransfer.js
deleted file mode 100644
index 6848516..0000000
--- a/lib/blackberry/plugin/qnx/fileTransfer.js
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- *
- * 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.
- *
-*/
-
-/*global Blob:false */
-var cordova = require('cordova'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileTransferError = require('cordova/plugin/FileTransferError'),
- FileUploadResult = require('cordova/plugin/FileUploadResult'),
- ProgressEvent = require('cordova/plugin/ProgressEvent'),
- nativeResolveLocalFileSystemURI = function(uri, success, fail) {
- if (uri.substring(0,11) !== "filesystem:") {
- uri = "filesystem:" + uri;
- }
- window.webkitResolveLocalFileSystemURL(uri, success, fail);
- },
- xhr;
-
-function getParentPath(filePath) {
- var pos = filePath.lastIndexOf('/');
- return filePath.substring(0, pos + 1);
-}
-
-function getFileName(filePath) {
- var pos = filePath.lastIndexOf('/');
- return filePath.substring(pos + 1);
-}
-
-function cleanUpPath(filePath) {
- var pos = filePath.lastIndexOf('/');
- return filePath.substring(0, pos) + filePath.substring(pos + 1, filePath.length);
-}
-
-function checkURL(url) {
- return url.indexOf(' ') === -1 ? true : false;
-}
-
-module.exports = {
- abort: function () {
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- upload: function(args, win, fail) {
- var filePath = args[0],
- server = args[1],
- fileKey = args[2],
- fileName = args[3],
- mimeType = args[4],
- params = args[5],
- /*trustAllHosts = args[6],*/
- chunkedMode = args[7],
- headers = args[8];
-
- if (!checkURL(server)) {
- fail(new FileTransferError(FileTransferError.INVALID_URL_ERR));
- }
-
- nativeResolveLocalFileSystemURI(filePath, function(entry) {
- entry.file(function(file) {
- function uploadFile(blobFile) {
- var fd = new FormData();
-
- fd.append(fileKey, blobFile, fileName);
- for (var prop in params) {
- if(params.hasOwnProperty(prop)) {
- fd.append(prop, params[prop]);
- }
- }
-
- xhr = new XMLHttpRequest();
- xhr.open("POST", server);
- xhr.onload = function(evt) {
- if (xhr.status == 200) {
- var result = new FileUploadResult();
- result.bytesSent = file.size;
- result.responseCode = xhr.status;
- result.response = xhr.response;
- win(result);
- } else if (xhr.status == 404) {
- fail(new FileTransferError(FileTransferError.INVALID_URL_ERR, server, filePath, xhr.status));
- } else {
- fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
- }
- };
- xhr.ontimeout = function(evt) {
- fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
- };
- xhr.onerror = function () {
- fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, this.status));
- };
- xhr.onprogress = function (evt) {
- win(evt);
- };
-
- for (var header in headers) {
- if (headers.hasOwnProperty(header)) {
- xhr.setRequestHeader(header, headers[header]);
- }
- }
-
- xhr.send(fd);
- }
-
- var bytesPerChunk;
- if (chunkedMode === true) {
- bytesPerChunk = 1024 * 1024; // 1MB chunk sizes.
- } else {
- bytesPerChunk = file.size;
- }
- var start = 0;
- var end = bytesPerChunk;
- while (start < file.size) {
- var chunk = file.slice(start, end, mimeType);
- uploadFile(chunk);
- start = end;
- end = start + bytesPerChunk;
- }
- }, function(error) {
- fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
- }, function(error) {
- fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
-
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- },
-
- download: function (args, win, fail) {
- var source = args[0],
- target = cleanUpPath(args[1]),
- fileWriter;
-
- if (!checkURL(source)) {
- fail(new FileTransferError(FileTransferError.INVALID_URL_ERR));
- }
-
- xhr = new XMLHttpRequest();
-
- function writeFile(entry) {
- entry.createWriter(function (writer) {
- fileWriter = writer;
- fileWriter.onwriteend = function (evt) {
- if (!evt.target.error) {
- win(new FileEntry(entry.name, entry.toURL()));
- } else {
- fail(evt.target.error);
- }
- };
- fileWriter.onerror = function (evt) {
- fail(evt.target.error);
- };
- fileWriter.write(new Blob([xhr.response]));
- }, function (error) {
- fail(error);
- });
- }
-
- xhr.onerror = function (e) {
- fail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr.status));
- };
-
- xhr.onload = function () {
- if (xhr.readyState === xhr.DONE) {
- if (xhr.status === 200 && xhr.response) {
- nativeResolveLocalFileSystemURI(getParentPath(target), function (dir) {
- dir.getFile(getFileName(target), {create: true}, writeFile, function (error) {
- fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
- }, function (error) {
- fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
- } else if (xhr.status === 404) {
- fail(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target, xhr.status));
- } else {
- fail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr.status));
- }
- }
- };
- xhr.onprogress = function (evt) {
- win(evt);
- };
-
- xhr.responseType = "blob";
- xhr.open("GET", source, true);
- xhr.send();
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/magnetometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/magnetometer.js b/lib/blackberry/plugin/qnx/magnetometer.js
deleted file mode 100644
index 72aa90e..0000000
--- a/lib/blackberry/plugin/qnx/magnetometer.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * 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;
-
-module.exports = {
- start: function (args, win, fail) {
- window.removeEventListener("deviceorientation", callback);
- callback = function (orientation) {
- var heading = 360 - orientation.alpha;
- win({
- magneticHeading: heading,
- trueHeading: heading,
- headingAccuracy: 0,
- timestamp: orientation.timeStamp
- });
- };
-
- window.addEventListener("deviceorientation", callback);
- return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
- },
- stop: function (args, win, fail) {
- window.removeEventListener("deviceorientation", callback);
- return { "status" : cordova.callbackStatus.OK, "message" : "removed" };
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/manager.js b/lib/blackberry/plugin/qnx/manager.js
deleted file mode 100644
index 36244f9..0000000
--- a/lib/blackberry/plugin/qnx/manager.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- *
- * 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'),
- plugins = {
- 'NetworkStatus' : require('cordova/plugin/qnx/network'),
- 'Accelerometer' : require('cordova/plugin/webworks/accelerometer'),
- 'Device' : require('cordova/plugin/qnx/device'),
- 'Battery' : require('cordova/plugin/qnx/battery'),
- 'Compass' : require('cordova/plugin/qnx/magnetometer'),
- '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'),
- 'File' : require('cordova/plugin/qnx/file'),
- 'InAppBrowser' : require('cordova/plugin/qnx/InAppBrowser'),
- 'FileTransfer': require('cordova/plugin/qnx/fileTransfer')
- };
-
-module.exports = {
- addPlugin: function (key, module) {
- plugins[key] = require(module);
- },
- exec: function (win, fail, clazz, action, args) {
- var result = {"status" : cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION, "message" : "Class " + clazz + " cannot be found"};
-
- if (plugins[clazz]) {
- if (plugins[clazz][action]) {
- result = plugins[clazz][action](args, win, fail);
- }
- else {
- result = { "status" : cordova.callbackStatus.INVALID_ACTION, "message" : "Action not found: " + action };
- }
- }
-
- return result;
- },
- resume: function () {},
- pause: function () {},
- destroy: function () {}
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/network.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/network.js b/lib/blackberry/plugin/qnx/network.js
deleted file mode 100644
index b640f75..0000000
--- a/lib/blackberry/plugin/qnx/network.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * 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 = {
- getConnectionInfo: function (args, win, fail) {
- return { "status": cordova.callbackStatus.OK, "message": blackberry.connection.type};
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry/plugin/qnx/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/platform.js b/lib/blackberry/plugin/qnx/platform.js
deleted file mode 100644
index a6daa03..0000000
--- a/lib/blackberry/plugin/qnx/platform.js
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- *
- * 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 = {
- id: "qnx",
- initialize: function () {
- document.addEventListener("deviceready", function () {
- blackberry.event.addEventListener("pause", function () {
- cordova.fireDocumentEvent("pause");
- });
- blackberry.event.addEventListener("resume", function () {
- cordova.fireDocumentEvent("resume");
- });
-
- window.addEventListener("online", function () {
- cordova.fireDocumentEvent("online");
- });
-
- window.addEventListener("offline", function () {
- cordova.fireDocumentEvent("offline");
- });
- });
- }
-};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
new file mode 100644
index 0000000..5880fbc
--- /dev/null
+++ b/lib/blackberry10/exec.js
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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'),
+ platform = require('cordova/platform'),
+ utils = require('cordova/utils');
+
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchronous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+ */
+
+module.exports = function(success, fail, service, action, args) {
+ try {
+ var manager = require('cordova/plugin/blackberry10/manager'),
+ v = manager.exec(success, fail, service, action, args);
+
+ // If status is OK, then return value back to caller
+ if (v.status == cordova.callbackStatus.OK) {
+
+ // If there is a success callback, then call it now with returned value
+ if (success) {
+ try {
+ success(v.message);
+ }
+ catch (e) {
+ console.log("Error in success callback: "+cordova.callbackId+" = "+e);
+ }
+ }
+ return v.message;
+ } else if (v.status == cordova.callbackStatus.NO_RESULT) {
+
+ } else {
+ // If error, then display error
+ console.log("Error: Status="+v.status+" Message="+v.message);
+
+ // If there is a fail callback, then call it now with returned value
+ if (fail) {
+ try {
+ fail(v.message);
+ }
+ catch (e) {
+ console.log("Error in error callback: "+cordova.callbackId+" = "+e);
+ }
+ }
+ return null;
+ }
+ } catch (e) {
+ utils.alert("Error: "+e);
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
new file mode 100644
index 0000000..af6d65e
--- /dev/null
+++ b/lib/blackberry10/platform.js
@@ -0,0 +1,39 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+module.exports = {
+ id: "blackberry10",
+ initialize: function() {
+ var builder = require('cordova/builder'),
+ modulemapper = require('cordova/modulemapper'),
+ platform = require('cordova/plugin/blackberry10/platform');
+
+ builder.buildIntoButDoNotClobber(platform.defaults, window);
+ builder.buildIntoAndClobber(platform.clobbers, window);
+ builder.buildIntoAndMerge(platform.merges, window);
+
+ modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
+ modulemapper.loadMatchingModules(new RegExp('cordova/.*' + this.runtime() + '/.*bbsymbols$'));
+ modulemapper.mapModules(window);
+
+ platform.initialize();
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/InAppBrowser.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/InAppBrowser.js b/lib/blackberry10/plugin/blackberry10/InAppBrowser.js
new file mode 100644
index 0000000..e42a293
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/InAppBrowser.js
@@ -0,0 +1,86 @@
+/*
+ *
+ * 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'),
+ modulemapper = require('cordova/modulemapper'),
+ origOpen = modulemapper.getOriginalSymbol(window, 'open'),
+ browser = {
+ close: function () { } //dummy so we don't have to check for undefined
+ };
+
+var navigate = {
+ "_blank": function (url, whitelisted) {
+ return origOpen(url, "_blank");
+ },
+
+ "_self": function (url, whitelisted) {
+ if (whitelisted) {
+ window.location.href = url;
+ return window;
+ }
+ else {
+ return origOpen(url, "_blank");
+ }
+ },
+
+ "_system": function (url, whitelisted) {
+ blackberry.invoke.invoke({
+ target: "sys.browser",
+ uri: url
+ }, function () {}, function () {});
+
+ return {
+ close: function () { }
+ };
+ }
+};
+
+module.exports = {
+ open: function (args, win, fail) {
+ var url = args[0],
+ target = args[1] || '_self',
+ a = document.createElement('a');
+
+ //Make all URLs absolute
+ a.href = url;
+ url = a.href;
+
+ switch (target) {
+ case '_self':
+ case '_system':
+ case '_blank':
+ break;
+ default:
+ target = '_blank';
+ break;
+ }
+
+ webworks.exec(function (whitelisted) {
+ browser = navigate[target](url, whitelisted);
+ }, fail, "org.apache.cordova", "isWhitelisted", [url], true);
+
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "" };
+ },
+ close: function (args, win, fail) {
+ browser.close();
+ return { "status" : cordova.callbackStatus.OK, "message" : "" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/accelerometer.js b/lib/blackberry10/plugin/blackberry10/accelerometer.js
new file mode 100644
index 0000000..70142fa
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/accelerometer.js
@@ -0,0 +1,43 @@
+/*
+ *
+ * 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;
+
+module.exports = {
+ start: function (args, win, fail) {
+ window.removeEventListener("devicemotion", callback);
+ callback = function (motion) {
+ win({
+ x: motion.accelerationIncludingGravity.x,
+ y: motion.accelerationIncludingGravity.y,
+ z: motion.accelerationIncludingGravity.z,
+ timestamp: motion.timestamp
+ });
+ };
+ window.addEventListener("devicemotion", callback);
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+ },
+ stop: function (args, win, fail) {
+ window.removeEventListener("devicemotion", callback);
+ return { "status" : cordova.callbackStatus.OK, "message" : "removed" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/battery.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/battery.js b/lib/blackberry10/plugin/blackberry10/battery.js
new file mode 100644
index 0000000..8bd9f44
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/battery.js
@@ -0,0 +1,40 @@
+/*
+ *
+ * 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'),
+ interval;
+
+module.exports = {
+ start: function (args, win, fail) {
+ interval = window.setInterval(function () {
+ win({
+ level: navigator.webkitBattery.level * 100,
+ isPlugged: navigator.webkitBattery.charging
+ });
+ }, 500);
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+ },
+
+ stop: function (args, win, fail) {
+ window.clearInterval(interval);
+ return { "status" : cordova.callbackStatus.OK, "message" : "stopped" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/camera.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/camera.js b/lib/blackberry10/plugin/blackberry10/camera.js
new file mode 100644
index 0000000..c357437
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/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/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/capture.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/capture.js b/lib/blackberry10/plugin/blackberry10/capture.js
new file mode 100644
index 0000000..3c8f1cb
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/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;
+ window.webkitRequestFileSystem(window.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/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/compass.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/compass.js b/lib/blackberry10/plugin/blackberry10/compass.js
new file mode 100644
index 0000000..061ceb5
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/compass.js
@@ -0,0 +1,162 @@
+/*
+ *
+ * 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'),
+ CompassError = require('cordova/plugin/CompassError'),
+ timers = {},
+ listeners = [],
+ heading = null,
+ running = false,
+ start = function () {
+ exec(function (result) {
+ heading = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
+ listeners.forEach(function (l) {
+ l.win(heading);
+ });
+ }, function (e) {
+ listeners.forEach(function (l) {
+ l.fail(e);
+ });
+ },
+ "Compass", "start", []);
+ running = true;
+ },
+ stop = function () {
+ exec(null, null, "Compass", "stop", []);
+ running = false;
+ },
+ createCallbackPair = function (win, fail) {
+ return {win:win, fail:fail};
+ },
+ removeListeners = function (l) {
+ var idx = listeners.indexOf(l);
+ if (idx > -1) {
+ listeners.splice(idx, 1);
+ if (listeners.length === 0) {
+ stop();
+ }
+ }
+ },
+ compass = {
+ /**
+ * Asynchronously acquires the current heading.
+ * @param {Function} successCallback The function to call when the heading
+ * data is available
+ * @param {Function} errorCallback The function to call when there is an error
+ * getting the heading data.
+ * @param {CompassOptions} options The options for getting the heading data (not used).
+ */
+ getCurrentHeading:function(successCallback, errorCallback, options) {
+ if (typeof successCallback !== "function") {
+ throw "getCurrentHeading must be called with at least a success callback function as first parameter.";
+ }
+
+ var p;
+ var win = function(a) {
+ removeListeners(p);
+ successCallback(a);
+ };
+ var fail = function(e) {
+ removeListeners(p);
+ errorCallback(e);
+ };
+
+ p = createCallbackPair(win, fail);
+ listeners.push(p);
+
+ if (!running) {
+ start();
+ }
+ },
+
+ /**
+ * Asynchronously acquires the heading repeatedly at a given interval.
+ * @param {Function} successCallback The function to call each time the heading
+ * data is available
+ * @param {Function} errorCallback The function to call when there is an error
+ * getting the heading data.
+ * @param {HeadingOptions} options The options for getting the heading data
+ * such as timeout and the frequency of the watch. For iOS, filter parameter
+ * specifies to watch via a distance filter rather than time.
+ */
+ watchHeading:function(successCallback, errorCallback, options) {
+ var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
+ var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
+
+ // successCallback required
+ if (typeof successCallback !== "function") {
+ console.log("Compass Error: successCallback is not a function");
+ return;
+ }
+
+ // errorCallback optional
+ if (errorCallback && (typeof errorCallback !== "function")) {
+ console.log("Compass Error: errorCallback is not a function");
+ return;
+ }
+ // Keep reference to watch id, and report heading readings as often as defined in frequency
+ var id = utils.createUUID();
+
+ var p = createCallbackPair(function(){}, function(e) {
+ removeListeners(p);
+ errorCallback(e);
+ });
+ listeners.push(p);
+
+ timers[id] = {
+ timer:window.setInterval(function() {
+ if (heading) {
+ successCallback(heading);
+ }
+ }, frequency),
+ listeners:p
+ };
+
+ if (running) {
+ // If we're already running then immediately invoke the success callback
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if(heading) {
+ successCallback(heading);
+ }
+ } else {
+ start();
+ }
+
+ return id;
+ },
+
+ /**
+ * Clears the specified heading watch.
+ * @param {String} watchId The ID of the watch returned from #watchHeading.
+ */
+ clearWatch:function(id) {
+ // Stop javascript timer & remove from timer list
+ if (id && timers[id]) {
+ window.clearInterval(timers[id].timer);
+ removeListeners(timers[id].listeners);
+ delete timers[id];
+ }
+ }
+ };
+
+module.exports = compass;
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/device.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/device.js b/lib/blackberry10/plugin/blackberry10/device.js
new file mode 100644
index 0000000..8898e09
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/device.js
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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 channel = require('cordova/channel'),
+ cordova = require('cordova');
+
+// Tell cordova channel to wait on the CordovaInfoReady event
+channel.waitForInitialization('onCordovaInfoReady');
+
+module.exports = {
+ getDeviceInfo : function(args, win, fail){
+ win({
+ platform: "BlackBerry",
+ version: blackberry.system.softwareVersion,
+ model: "Dev Alpha",
+ name: "Dev Alpha", // deprecated: please use device.model
+ uuid: blackberry.identity.uuid,
+ cordova: CORDOVA_JS_BUILD_LABEL
+ });
+
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "Device info returned" };
+ }
+};