You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by lo...@apache.org on 2013/05/07 17:16:17 UTC

[01/32] [BlackBerry10] Split out to new top-level platform

Updated Branches:
  refs/heads/future [created] a2e3993d8


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.camera.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.camera.js b/test/blackberry10/test.camera.js
new file mode 100644
index 0000000..e08809f
--- /dev/null
+++ b/test/blackberry10/test.camera.js
@@ -0,0 +1,59 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 camera", function () {
+    var camera = require('cordova/plugin/blackberry10/camera'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+        global.blackberry = {
+            invoke: {
+                card: {
+                    invokeCamera: jasmine.createSpy("invokeCamera")
+                }
+            }
+        };
+    });
+
+    afterEach(function () {
+        delete global.blackberry;
+    });
+    
+    it("returns no_result when calling takePicture", function () {
+        expect(camera.takePicture()).toEqual({
+            status: cordova.callbackStatus.NO_RESULT,
+            message: "WebWorks Is On It"
+        });
+    });
+
+    it("calls blackberry.invoke.card.invokeCamera", function () {
+        camera.takePicture();
+        expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith("photo", jasmine.any(Function), jasmine.any(Function), jasmine.any(Function));
+    });
+
+    it("adds file:// to the path provided to the callback and calls success", function () {
+        var win = jasmine.createSpy("win");
+        camera.takePicture({}, win);
+
+        blackberry.invoke.card.invokeCamera.mostRecentCall.args[1]("pics/ponies.jpg");
+        expect(win).toHaveBeenCalledWith("file://pics/ponies.jpg");
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.capture.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.capture.js b/test/blackberry10/test.capture.js
new file mode 100644
index 0000000..95b48d4
--- /dev/null
+++ b/test/blackberry10/test.capture.js
@@ -0,0 +1,222 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 capture", function () {
+    var capture = require('cordova/plugin/blackberry10/capture'),
+        cordova = require('cordova');
+
+    describe("getSupportedAudioModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedAudioModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    describe("getSupportedImageModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedImageModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    describe("getSupportedVideoModes", function(){
+        it('should return Ok', function(){
+            expect(capture.getSupportedVideoModes()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: []
+            });
+        });
+    });
+
+    function testCapture(method, action) {
+        describe(method, function(){
+            beforeEach(function () {
+                global.blackberry = {
+                    invoke: {
+                        card: {
+                            invokeCamera: jasmine.createSpy('blackberry.invoke.card.invokeCamera')
+                        }
+                    }
+                };
+            });
+
+            afterEach(function () {
+                delete global.blackberry;
+            });
+
+            it('should return No Result', function(){
+                var args = [{limit: 0}],
+                    win = jasmine.createSpy('win'),
+                    fail = jasmine.createSpy('fail');
+
+                expect(capture[method](args, win, fail)).toEqual({
+                    status: cordova.callbackStatus.NO_RESULT,
+                    message: "WebWorks Is On It"
+                });
+            });
+
+            describe("when the limit is 0 or less", function () {
+                it('calls the win callback with an empty array', function(){
+                    var args = [{ limit: -9 }],
+                        win = jasmine.createSpy('win'),
+                        fail = jasmine.createSpy('fail');
+
+                    capture[method](args, win, fail);
+                    expect(win).toHaveBeenCalled();
+                });
+            });
+
+            describe("when the limit is greater than 0", function () {
+                var win, fail;
+
+                beforeEach(function () {
+                    win = jasmine.createSpy("win");
+                    fail = jasmine.createSpy("fail");
+                });
+
+                it("calls the invokeCamera method", function () {
+                    capture[method]([{limit: 1}], win, fail);
+                    expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith(action, 
+                                                                                     jasmine.any(Function),
+                                                                                     jasmine.any(Function),
+                                                                                     jasmine.any(Function));
+                });
+
+                describe("inside the invokeCamera callback", function () {
+                    var onsave;
+
+                    beforeEach(function () {
+                        window.webkitRequestFileSystem = jasmine.createSpy("window.webkitRequestFileSystem");
+                        global.blackberry.io = { sandbox: true };
+
+                        capture[method]([{limit: 1}], win, fail);
+                        onsave = blackberry.invoke.card.invokeCamera.mostRecentCall.args[1];
+                    });
+
+                    afterEach(function () {
+                        delete window.webkitRequestFileSystem;
+                    });
+
+                    it("sets the sandbox to false", function () {
+                        onsave();
+                        expect(blackberry.io.sandbox).toBe(false);
+                    });
+
+                    it("calls webkitRequestFileSystem", function () {
+                        onsave();
+                        expect(window.webkitRequestFileSystem).toHaveBeenCalledWith(
+                            window.PERSISTENT, 
+                            1024, 
+                            jasmine.any(Function), 
+                            fail);
+                    });
+
+                    describe("in the webkitRequestFileSystem callback", function () {
+                        var callback,
+                            fs = { root: { getFile: jasmine.createSpy("getFile") } };
+
+                        beforeEach(function () {
+                            onsave('/foo/bar/baz.gif');
+                            callback = window.webkitRequestFileSystem.mostRecentCall.args[2];
+                        });
+
+                        it("calls getfile on the provided filesystem", function () {
+                            callback(fs);
+                            expect(fs.root.getFile).toHaveBeenCalledWith('/foo/bar/baz.gif', 
+                                                                         {},
+                                                                         jasmine.any(Function), 
+                                                                         fail);
+                        });
+
+                        it("calls the file method of the fileEntity", function () {
+                            var fe = { file: jasmine.createSpy('file') };
+                            callback(fs);
+                            fs.root.getFile.mostRecentCall.args[2](fe);
+                            expect(fe.file).toHaveBeenCalledWith(jasmine.any(Function), fail);
+                        });
+
+                        describe("in the file callback", function () {
+                            var fe = { 
+                                    file: jasmine.createSpy('file'),
+                                    fullPath: 'file://this/is/the/full/path/eh.png'
+                                },
+                                fileCB;
+
+                            beforeEach(function () {
+                                callback(fs);
+                                fs.root.getFile.mostRecentCall.args[2](fe);
+                                fileCB = fe.file.mostRecentCall.args[0];
+                            });
+
+                            it("sets the fullPath of the file object", function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(file.fullPath).toBe(fe.fullPath);
+                            });
+
+                            it("calls the win callback with an array containing the file", function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(win).toHaveBeenCalledWith([file]);
+                            });
+
+                            it("resets the value of blackberry.io.sandbox", function () {
+                                var file = {};
+                                fileCB(file);
+                                expect(blackberry.io.sandbox).toBe(true);
+                            });
+                        });
+                    });
+                });
+            });
+        });
+    }
+
+    testCapture('captureImage', 'photo');
+    testCapture('captureVideo', 'video');
+
+    describe("captureAudio", function(){
+        it('should call the fail callback', function(){
+            var args = {},
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            capture.captureAudio(args, win, fail);
+            expect(fail).toHaveBeenCalled();
+            expect(win).not.toHaveBeenCalled();
+        });
+
+        it('should return no result', function(){
+            var args = "arguments",
+                win = jasmine.createSpy('win'),
+                fail = jasmine.createSpy('fail');
+
+            expect(capture.captureAudio(args, win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.compass.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.compass.js b/test/blackberry10/test.compass.js
new file mode 100644
index 0000000..19b231b
--- /dev/null
+++ b/test/blackberry10/test.compass.js
@@ -0,0 +1,61 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+xdescribe("blackberry10 compass", function () {
+    var compass = require('cordova/plugin/blackberry10/compass'),
+        cordova = require('cordova'),
+        exec = require('cordova/exec'),
+        utils = require('cordova/utils'),
+        CompassHeading = require('cordova/plugin/CompassHeading'),
+        CompassError = require('cordova/plugin/CompassError'),
+        win = jasmine.createSpy('win'),
+        fail = jasmine.createSpy('fail');
+
+    beforeEach(function () {
+        window.start = jasmine.createSpy('start');
+        window.stop = jasmine.createSpy('stop');
+        window.removeListeners = jasmine.createSpy('removeListeners');
+        global.listeners = [];
+
+    });
+
+    afterEach(function () {
+
+    });
+
+
+    describe("watchHeading", function(){
+        it('should return that successCallback is not a function', function(){
+            expect(compass.getCurrentHeading).toThrow("getCurrentHeading must be called with at least a success callback function as first parameter.");
+        });
+
+        it('should see that start() was called', function(){
+            compass.getCurrentHeading(win, fail);
+            expect(listeners).toHaveBeenCalled();
+        });
+
+    });
+
+    describe("clearWatch", function(){
+
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.device.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.device.js b/test/blackberry10/test.device.js
new file mode 100644
index 0000000..66f3813
--- /dev/null
+++ b/test/blackberry10/test.device.js
@@ -0,0 +1,48 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 device", function () {
+    var device = require('cordova/plugin/blackberry10/device');
+    
+    it("calls the win callback with the device info", function () {
+        global.blackberry = {
+            system: {
+                softwareVersion: "NaN"
+            },
+            identity: {
+                uuid: 1
+            }
+        };
+
+        var info;
+
+        //HACK: I know this is a sync call ;)
+        device.getDeviceInfo({}, function (i) { info = i; });
+
+        expect(info.platform).toBe("BlackBerry");
+        expect(info.version).toBe("NaN");
+        expect(info.name).toBe("Dev Alpha");
+        expect(info.uuid).toBe(1);
+        expect(info.cordova).toBeDefined();
+        
+        delete global.blackberry;
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.fileTransfer.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.fileTransfer.js b/test/blackberry10/test.fileTransfer.js
new file mode 100644
index 0000000..1d7ed57
--- /dev/null
+++ b/test/blackberry10/test.fileTransfer.js
@@ -0,0 +1,85 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 fileTransfer", function () {
+    var fileTransfer = require('cordova/plugin/blackberry10/fileTransfer'),
+        cordova = require('cordova'),
+        win = jasmine.createSpy('win'),
+        fail = jasmine.createSpy('fail')
+        xhrSend = jasmine.createSpy('xhr send');
+        xhrOpen = jasmine.createSpy('xhr open');
+
+    beforeEach(function () {
+        global.blackberry = {
+            io:{
+                filetransfer: {
+                    download: jasmine.createSpy('download'),
+                    upload: jasmine.createSpy('upload')
+                }
+            }
+        };
+        XMLHttpRequest = function () {
+            var xhr = {
+                send: xhrSend,
+                open: xhrOpen
+            };
+            return xhr;
+        };
+        window.webkitResolveLocalFileSystemURL = jasmine.createSpy("resolveFS")
+    });
+
+    afterEach(function () {
+        delete global.blackberry;
+        delete XMLHttpRequest;
+        delete webkitResolveLocalFileSystemURL;
+        delete window.webkitResolveLocalFileSystemURL;
+    });
+
+    describe("download", function(){
+        it('should call the blackberry download', function () {
+            fileTransfer.download(["source/file", "target/file"], win, fail);
+            expect(xhrOpen).toHaveBeenCalled();
+            expect(xhrSend).toHaveBeenCalled();
+        });
+
+        it('should return No Result', function(){
+            expect(fileTransfer.download(["location/source", "location/place/here"], win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "async"
+            });
+        });
+    });
+
+    describe('upload', function(){
+        it('should call the blackberry upload', function(){
+            fileTransfer.upload(["source", "target", "fileKey", "fileName", "mimeType", "params", "chunkedMode"], win, fail);
+            expect(xhrOpen).toHaveBeenCalled();
+            expect(xhrSend).toHaveBeenCalled();
+        });
+
+        it('should return No Result', function(){
+            expect(fileTransfer.upload(["location/source", "location/place/here"], win, fail)).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "async"
+            });
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.magnetometer.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.magnetometer.js b/test/blackberry10/test.magnetometer.js
new file mode 100644
index 0000000..f9ad9b3
--- /dev/null
+++ b/test/blackberry10/test.magnetometer.js
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 magnetometer", function () {
+    var magnetometer = require('cordova/plugin/blackberry10/magnetometer'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+        spyOn(window, "removeEventListener");
+        spyOn(window, "addEventListener");
+    });
+
+    describe("start", function(){
+        it('should return no result', function(){
+            expect(magnetometer.start()).toEqual({
+                status: cordova.callbackStatus.NO_RESULT,
+                message: "WebWorks Is On It"
+            });
+        });
+
+        it('should remove the event listener', function(){
+            magnetometer.start();
+            expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
+        });
+
+        it('should add an event listener', function(){
+            magnetometer.start();
+            expect(window.addEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
+        });
+
+        it('call the win callback with the data from the event', function(){
+            var win = jasmine.createSpy('win');
+            magnetometer.start({}, win);
+
+            window.addEventListener.mostRecentCall.args[1]({
+                alpha: 60,
+                timeStamp: "bout that time, eh chap?"
+            });
+
+            expect(win).toHaveBeenCalledWith({
+                magneticHeading: 300,
+                trueHeading: 300,
+                headingAccuracy: 0,
+                timestamp: "bout that time, eh chap?"
+            });
+        });
+    });
+
+    describe('stop', function(){
+        it('should return OK', function(){
+            expect(magnetometer.stop()).toEqual({
+                status: cordova.callbackStatus.OK,
+                message: "removed"
+            });
+        });
+
+        it('should remove the event listener', function(){
+            magnetometer.stop();
+            expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.manager.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.manager.js b/test/blackberry10/test.manager.js
new file mode 100644
index 0000000..5899fd3
--- /dev/null
+++ b/test/blackberry10/test.manager.js
@@ -0,0 +1,56 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 manager", function () {
+    var manager = require('cordova/plugin/blackberry10/manager');
+
+    it("calls the plugin", function () {
+        var device = require('cordova/plugin/blackberry10/device'),
+            win = jasmine.createSpy('win'),
+            fail = jasmine.createSpy('fail'),
+            args = {};
+
+        spyOn(device, "getDeviceInfo");
+
+        manager.exec(win, fail, "Device", "getDeviceInfo", args);
+        expect(device.getDeviceInfo).toHaveBeenCalledWith(args, win, fail);
+    });
+
+    it("returns the result of the plugin", function () {
+        var camera = require('cordova/plugin/blackberry10/camera');
+        spyOn(camera, "takePicture").andReturn("duckface");
+        expect(manager.exec(null, null, "Camera", "takePicture")).toBe("duckface");
+    });
+
+    it("returns class not found when no plugin", function () {
+        expect(manager.exec(null, null, "Ruby", "method_missing")).toEqual({
+           status: cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION,
+           message: "Class Ruby cannot be found"
+        });
+    });
+
+    it("returns invalid action when no action", function () {
+        expect(manager.exec(null, null, "Camera", "makePonies")).toEqual({
+            status: cordova.callbackStatus.INVALID_ACTION,
+            message: "Action not found: makePonies"
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.network.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.network.js b/test/blackberry10/test.network.js
new file mode 100644
index 0000000..5917269
--- /dev/null
+++ b/test/blackberry10/test.network.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.
+ *
+*/
+
+describe("blackberry10 network", function () {
+    var cordova = require('cordova'),
+        network = require('cordova/plugin/blackberry10/network');
+
+    it("returns the connection info", function () {
+        global.blackberry = {
+            connection: {
+                type: "pigeon"
+            }
+        };
+        expect(network.getConnectionInfo()).toEqual({
+            status: cordova.callbackStatus.OK,
+            message: "pigeon"
+        });
+
+        delete global.blackberry;
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.platform.js b/test/blackberry10/test.platform.js
new file mode 100644
index 0000000..98789a1
--- /dev/null
+++ b/test/blackberry10/test.platform.js
@@ -0,0 +1,117 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 platform", function () {
+    var platform = require('cordova/plugin/blackberry10/platform'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+
+        global.blackberry = {
+            event:{
+                addEventListener: jasmine.createSpy('addEventListener')
+            }
+        }
+
+        spyOn(cordova, "fireDocumentEvent");
+
+        spyOn(document, "addEventListener").andCallFake(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");
+            });
+        });
+        
+        spyOn(window, "addEventListener").andCallFake(function(){
+            cordova.fireDocumentEvent("online");
+            cordova.fireDocumentEvent("offline");
+        });
+    });
+
+    afterEach(function(){
+        delete global.blackberry;
+    });
+
+    describe("initialize", function(){
+        it('should add an event listener to document', function(){
+            platform.initialize();
+            expect(document.addEventListener).toHaveBeenCalledWith("deviceready", jasmine.any(Function));
+        });
+        it('should check if blackberry event addEventListener was called for pause', function(){
+            platform.initialize();
+            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("pause", jasmine.any(Function));
+        });
+        it('should check if blackberry event addEventListener was called for resume', function(){
+            platform.initialize();     
+            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("resume", jasmine.any(Function));
+        });
+        it('should check if window.addEventListener was called for online', function(){
+            platform.initialize();
+            expect(window.addEventListener).toHaveBeenCalledWith("online", jasmine.any(Function));
+            
+        });
+        it('should check if window.addEventListener was called for offline', function(){
+            platform.initialize();
+            expect(window.addEventListener).toHaveBeenCalledWith("offline", jasmine.any(Function));
+        });
+
+        it('should call cordova.fireDocumentEvent online', function(){
+            platform.initialize();
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("online");
+        });
+        it('should call cordova.fireDocumentEvent offline', function(){
+            platform.initialize();
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("offline");
+        });
+        it('should call cordova.fireDocumentEvent pause', function(){
+            delete global.blackberry;
+            global.blackberry = { event: { addEventListener: function(){ } } };
+            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
+                cordova.fireDocumentEvent("pause");
+            });
+
+            platform.initialize();
+            
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("pause");
+        });
+        it('should call cordova.fireDocumentEvent resume', function(){
+            delete global.blackberry;
+            global.blackberry = { event: { addEventListener: function(){ } } };
+            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
+                cordova.fireDocumentEvent("resume");
+            });
+
+            platform.initialize();
+            
+            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("resume");
+        });
+
+    });
+});


[26/32] js commit: [BlackBerry10] Removed builder from platform.js

Posted by lo...@apache.org.
[BlackBerry10] Removed builder from platform.js

- builder is deprecated, switching to moduleMapper
- removed dependency on blackberry10/plugin/blackberry10/platform.js

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/acaf8370
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/acaf8370
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/acaf8370

Branch: refs/heads/future
Commit: acaf837055c235085888683bbac6f85d12d4fc42
Parents: 188c17d
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Wed Apr 24 14:25:53 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:05 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js                     |   16 +--
 lib/blackberry10/plugin/blackberry10/platform.js |   71 ----------
 test/blackberry10/test.platform.js               |  117 -----------------
 3 files changed, 7 insertions(+), 197 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/acaf8370/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 7b6bb2a..5f11f7c 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -22,18 +22,16 @@
 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);
+        var modulemapper = require('cordova/modulemapper'),
+            cordova = require('cordova');
 
         modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
         modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
-        modulemapper.mapModules(window);
 
-        platform.initialize();
+        modulemapper.clobbers('cordova/plugin/blackberry10/vibrate', 'navigator.notification.vibrate');
+        modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
+        modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
+
+        modulemapper.mapModules(window);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/acaf8370/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
deleted file mode 100644
index 231d890..0000000
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ /dev/null
@@ -1,71 +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: "blackberry10",
-    initialize: function () {
-        document.addEventListener("deviceready", function () {
-            /*
-             TODO
-            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");
-            });
-        });
-    },
-    clobbers: {
-        navigator: {
-            children: {
-                notification: {
-                    children: {
-                        vibrate: {
-                            path: 'cordova/plugin/blackberry10/vibrate'
-                        }
-                    }
-                }
-            }
-        },
-        File: {
-            path: 'cordova/plugin/File'
-        }
-    },
-    merges: {
-        navigator: {
-            children: {
-                compass: {
-                    path: 'cordova/plugin/blackberry10/compass'
-                }
-            }
-        }
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/acaf8370/test/blackberry10/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.platform.js b/test/blackberry10/test.platform.js
deleted file mode 100644
index 98789a1..0000000
--- a/test/blackberry10/test.platform.js
+++ /dev/null
@@ -1,117 +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.
- *
-*/
-
-describe("blackberry10 platform", function () {
-    var platform = require('cordova/plugin/blackberry10/platform'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-
-        global.blackberry = {
-            event:{
-                addEventListener: jasmine.createSpy('addEventListener')
-            }
-        }
-
-        spyOn(cordova, "fireDocumentEvent");
-
-        spyOn(document, "addEventListener").andCallFake(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");
-            });
-        });
-        
-        spyOn(window, "addEventListener").andCallFake(function(){
-            cordova.fireDocumentEvent("online");
-            cordova.fireDocumentEvent("offline");
-        });
-    });
-
-    afterEach(function(){
-        delete global.blackberry;
-    });
-
-    describe("initialize", function(){
-        it('should add an event listener to document', function(){
-            platform.initialize();
-            expect(document.addEventListener).toHaveBeenCalledWith("deviceready", jasmine.any(Function));
-        });
-        it('should check if blackberry event addEventListener was called for pause', function(){
-            platform.initialize();
-            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("pause", jasmine.any(Function));
-        });
-        it('should check if blackberry event addEventListener was called for resume', function(){
-            platform.initialize();     
-            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("resume", jasmine.any(Function));
-        });
-        it('should check if window.addEventListener was called for online', function(){
-            platform.initialize();
-            expect(window.addEventListener).toHaveBeenCalledWith("online", jasmine.any(Function));
-            
-        });
-        it('should check if window.addEventListener was called for offline', function(){
-            platform.initialize();
-            expect(window.addEventListener).toHaveBeenCalledWith("offline", jasmine.any(Function));
-        });
-
-        it('should call cordova.fireDocumentEvent online', function(){
-            platform.initialize();
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("online");
-        });
-        it('should call cordova.fireDocumentEvent offline', function(){
-            platform.initialize();
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("offline");
-        });
-        it('should call cordova.fireDocumentEvent pause', function(){
-            delete global.blackberry;
-            global.blackberry = { event: { addEventListener: function(){ } } };
-            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
-                cordova.fireDocumentEvent("pause");
-            });
-
-            platform.initialize();
-            
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("pause");
-        });
-        it('should call cordova.fireDocumentEvent resume', function(){
-            delete global.blackberry;
-            global.blackberry = { event: { addEventListener: function(){ } } };
-            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
-                cordova.fireDocumentEvent("resume");
-            });
-
-            platform.initialize();
-            
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("resume");
-        });
-
-    });
-});


[06/32] js commit: [BlackBerry10] Process plugin clobbers and merges

Posted by lo...@apache.org.
[BlackBerry10] Process plugin clobbers and merges

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d4fa7d39
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d4fa7d39
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d4fa7d39

Branch: refs/heads/future
Commit: d4fa7d3921ee1d11d450c9d38531c4ba01bab3bc
Parents: d2f5266
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Mar 18 14:16:22 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:31 2013 -0400

----------------------------------------------------------------------
 .../plugin/blackberry10/pluginUtils.js             |   16 +++++++++
 test/blackberry10/test.pluginUtils.js              |   27 ++++++++++++--
 2 files changed, 39 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d4fa7d39/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
index 9a52a25..88f03c5 100644
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -19,6 +19,21 @@
  *
  */
 
+function build(plugins) {
+    var builder = require('cordova/builder'),
+        plugin;
+    for (plugin in plugins) {
+        if (plugins.hasOwnProperty(plugin)) {
+            if (plugins[plugin].clobbers) {
+                builder.buildIntoAndClobber(plugins[plugin].clobbers, window);
+            }
+            if (plugins[plugin].merges) {
+                builder.buildIntoAndMerge(plugins[plugin].merges, window);
+            }
+        }
+    }
+}
+
 module.exports = {
 
     loadClientJs: function (plugins, callback) {
@@ -33,6 +48,7 @@ module.exports = {
                     script.src = 'plugins/' + plugin + '/' + plugins[plugin].modules[i];
                     script.onload = function () {
                         if (--count === 0 && typeof callback === 'function') {
+                            build(plugins);
                             callback();
                         }
                     };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d4fa7d39/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
index 37f0e9c..6b5a24a 100644
--- a/test/blackberry10/test.pluginUtils.js
+++ b/test/blackberry10/test.pluginUtils.js
@@ -21,7 +21,8 @@
 
 describe('blackberry10 pluginUtils', function () {
 
-    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils');
+    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils'),
+        builder = require('cordova/builder');
 
     describe('loadClientJs', function () {
 
@@ -35,6 +36,8 @@ describe('blackberry10 pluginUtils', function () {
             });
             spyOn(document.head, "appendChild");
             callback = jasmine.createSpy();
+            spyOn(builder, "buildIntoAndClobber");
+            spyOn(builder, "buildIntoAndMerge");
         });
 
         it('does nothing for 0 plugins', function () {
@@ -46,7 +49,7 @@ describe('blackberry10 pluginUtils', function () {
         });
 
         it('adds a script tag for 1 plugin', function () {
-            var plugins = { foo : { client: ['bar.js'] } };
+            var plugins = { foo : { modules: ['bar.js'] } };
             pluginUtils.loadClientJs(plugins, callback);
             expect(document.createElement).toHaveBeenCalled();
             expect(script.src).toEqual('plugins/foo/bar.js');
@@ -56,7 +59,7 @@ describe('blackberry10 pluginUtils', function () {
         });
 
         it('adds multiple script tags for 1 plugin', function () {
-            var plugins = { foo: { client: ['bar.js', '2.js'] } };
+            var plugins = { foo: { modules: ['bar.js', '2.js'] } };
             pluginUtils.loadClientJs(plugins, callback);
             expect(document.createElement.callCount).toBe(2);
             expect(document.head.appendChild.callCount).toBe(2);
@@ -66,7 +69,7 @@ describe('blackberry10 pluginUtils', function () {
         });
 
         it('adds script tags for multiple plugins', function () {
-            var plugins = { foo: { client: ['1.js'] }, bar: { client: ['1.js', '2.js' ] } };
+            var plugins = { foo: { modules: ['1.js'] }, bar: { modules: ['1.js', '2.js' ] } };
             pluginUtils.loadClientJs(plugins, callback);
             expect(document.createElement.callCount).toBe(3);
             expect(document.head.appendChild.callCount).toBe(3);
@@ -76,6 +79,22 @@ describe('blackberry10 pluginUtils', function () {
             expect(callback.callCount).toBe(1);
         });
 
+        it('calls clobber', function () {
+            var plugins = { foo: { modules : ['bar.js'], clobbers: { bar: { path: 'foo.bar' } } } };
+            pluginUtils.loadClientJs(plugins, callback);
+            script.onload();
+            expect(callback.callCount).toBe(1);
+            expect(builder.buildIntoAndClobber).toHaveBeenCalledWith(plugins.foo.clobbers, window);
+        });
+
+        it('calls merge', function () {
+            var plugins = { foo: { modules : ['bar.js'], merges: { bar: { path: 'foo.bar' } } } };
+            pluginUtils.loadClientJs(plugins, callback);
+            script.onload();
+            expect(callback.callCount).toBe(1);
+            expect(builder.buildIntoAndMerge).toHaveBeenCalledWith(plugins.foo.merges, window);
+        });
+
     });
 
     describe('getPlugins', function () {


[11/32] js commit: [Blackberry10] Clobber window.requestFileSystem to use WebKit version

Posted by lo...@apache.org.
[Blackberry10] Clobber window.requestFileSystem to use WebKit version


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/dbb478cc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/dbb478cc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/dbb478cc

Branch: refs/heads/future
Commit: dbb478cc1b16051dfe7ab465f1ac82801c1c9b47
Parents: d21fed2
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Apr 1 11:18:36 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/blackberry10/platform.js   |   21 ++++++++-
 .../plugin/blackberry10/requestFileSystem.js       |   39 +++++++++++++++
 2 files changed, 59 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/dbb478cc/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
index 871f2d1..d43cdd5 100644
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -25,13 +25,15 @@ module.exports = {
     id: "blackberry10",
     initialize: function () {
         document.addEventListener("deviceready", function () {
+            /*
+             TODO
             blackberry.event.addEventListener("pause", function () {
                 cordova.fireDocumentEvent("pause");
             });
             blackberry.event.addEventListener("resume", function () {
                 cordova.fireDocumentEvent("resume");
             });
-
+            */
             window.addEventListener("online", function () {
                 cordova.fireDocumentEvent("online");
             });
@@ -40,5 +42,22 @@ module.exports = {
                 cordova.fireDocumentEvent("offline");
             });
         });
+    },
+    clobbers: {
+        open: {
+            path: "cordova/plugin/InAppBrowser"
+        },
+        requestFileSystem: {
+            path: "cordova/plugin/blackberry10/requestFileSystem"
+        }
+    },
+    merges: {
+        navigator: {
+            children: {
+                compass: {
+                    path: 'cordova/plugin/blackberry10/compass'
+                }
+            }
+        }
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/dbb478cc/lib/blackberry10/plugin/blackberry10/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/requestFileSystem.js b/lib/blackberry10/plugin/blackberry10/requestFileSystem.js
new file mode 100644
index 0000000..18c64e5
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/requestFileSystem.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.
+ *
+*/
+
+function getFileSystemName(fs) {
+    return (fs.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 = function (type, size, success, fail) {
+    window.webkitRequestFileSystem(type, size, function (fs) {
+        success((new FileSystem(getFileSystemName(fs), makeEntry(fs.root))));
+    }, fail);
+};


[20/32] js commit: [BlackBerry10] Remove accelerometer plugin

Posted by lo...@apache.org.
[BlackBerry10] Remove accelerometer plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/df382c01
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/df382c01
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/df382c01

Branch: refs/heads/future
Commit: df382c01e8ba23383ccdb304b169a220a1adb8dc
Parents: 8b06f29
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Apr 11 16:14:14 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 .../plugin/blackberry10/accelerometer.js           |   43 ---------------
 1 files changed, 0 insertions(+), 43 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/df382c01/lib/blackberry10/plugin/blackberry10/accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/accelerometer.js b/lib/blackberry10/plugin/blackberry10/accelerometer.js
deleted file mode 100644
index 70142fa..0000000
--- a/lib/blackberry10/plugin/blackberry10/accelerometer.js
+++ /dev/null
@@ -1,43 +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("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" };
-    }
-};


[30/32] js commit: [BlackBerry10] Switch module loading to cordova_plugins.json

Posted by lo...@apache.org.
[BlackBerry10] Switch module loading to cordova_plugins.json

Note: this includes a change to plugin_loader.js that should be applied to all platforms

Revewied by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/ea8515b6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/ea8515b6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/ea8515b6

Branch: refs/heads/future
Commit: ea8515b666a8710863af14a6d4abeba1f2491bfd
Parents: 6d6478e
Author: Hasan Ahmad <ha...@blackberry.com>
Authored: Thu Apr 25 15:56:36 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:05 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js                       |    1 -
 .../plugin/blackberry10/pluginUtils.js             |   88 --------
 lib/scripts/bootstrap-blackberry10.js              |   22 +--
 test/blackberry10/test.pluginUtils.js              |  156 ---------------
 4 files changed, 6 insertions(+), 261 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ea8515b6/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 5f11f7c..3d68cd8 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -32,6 +32,5 @@ module.exports = {
         modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
         modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
 
-        modulemapper.mapModules(window);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ea8515b6/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
deleted file mode 100644
index ed41518..0000000
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ /dev/null
@@ -1,88 +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.
- *
- */
-
-function build(plugins) {
-    var builder = require('cordova/builder'),
-        plugin;
-    for (plugin in plugins) {
-        if (plugins.hasOwnProperty(plugin)) {
-            if (plugins[plugin].clobbers) {
-                builder.buildIntoAndClobber(plugins[plugin].clobbers, window);
-            }
-            if (plugins[plugin].merges) {
-                builder.buildIntoAndMerge(plugins[plugin].merges, window);
-            }
-        }
-    }
-}
-
-module.exports = {
-
-    loadClientJs: function (plugins, callback) {
-        var plugin,
-            script,
-            i,
-            count = 0;
-        for (plugin in plugins) {
-            if (plugins.hasOwnProperty(plugin) && plugins[plugin].modules) {
-                for (i = 0; i < plugins[plugin].modules.length; i++) {
-                    script = document.createElement('script');
-                    script.src = 'local:///plugins/' + plugin + '/' + plugins[plugin].modules[i];
-                    script.onload = function () {
-                        if (--count === 0 && typeof callback === 'function') {
-                            build(plugins);
-                            callback();
-                        }
-                    };
-                    count++;
-                    document.head.appendChild(script);
-                }
-            }
-        }
-        if (count === 0) {
-            callback();
-        }
-    },
-
-    getPlugins: function (success, error) {
-        var request,
-            response;
-        request = new XMLHttpRequest();
-        request.open('GET', 'local:///plugins/plugins.json', true);
-        request.onreadystatechange = function () {
-            if (request.readyState === 4) {
-                if (request.status === 200) {
-                    try {
-                        response = JSON.parse(decodeURIComponent(request.responseText));
-                        success(response);
-                    }
-                    catch (e) {
-                        error(e);
-                    }
-                }
-                else {
-                    error(request.status);
-                }
-            }
-        };
-        request.send(null);
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ea8515b6/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 836880f..351411c 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -20,8 +20,7 @@
 */
 
 (function () {
-    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils'),
-        docAddEventListener = document.addEventListener,
+    var docAddEventListener = document.addEventListener,
         webworksReady = false,
         alreadyFired = false,
         listenerRegistered = false;
@@ -124,20 +123,11 @@
         event: require("cordova/plugin/blackberry10/event")
     };
 
-    //Fire webworks ready once plugin javascript has been loaded
-    pluginUtils.getPlugins(
-        function (plugins) {
-            pluginUtils.loadClientJs(plugins, function () {
-                webworksReady = true;
-                fireWebworksReadyEvent();
-            });
-        },
-        function () {
-            console.log('Unable to load plugins.json');
-            webworksReady = true;
-            fireWebworksReadyEvent();
-        }
-    );
+    require("cordova/channel").onPluginsReady.subscribe(function () {
+        require("cordova/modulemapper").mapModules(window);
+        webworksReady = true;
+        fireWebworksReadyEvent();
+    });
 }());
 
 document.addEventListener("DOMContentLoaded", function () {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ea8515b6/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
deleted file mode 100644
index 3fe83bb..0000000
--- a/test/blackberry10/test.pluginUtils.js
+++ /dev/null
@@ -1,156 +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.
- *
-*/
-
-describe('blackberry10 pluginUtils', function () {
-
-    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils'),
-        builder = require('cordova/builder');
-
-    describe('loadClientJs', function () {
-
-        var callback,
-            script;
-
-        beforeEach(function () {
-            script = {};
-            spyOn(document, "createElement").andCallFake(function () {
-                return script;
-            });
-            spyOn(document.head, "appendChild");
-            callback = jasmine.createSpy();
-            spyOn(builder, "buildIntoAndClobber");
-            spyOn(builder, "buildIntoAndMerge");
-        });
-
-        it('does nothing for 0 plugins', function () {
-            var plugins = {};
-            pluginUtils.loadClientJs(plugins, callback);
-            expect(document.createElement).not.toHaveBeenCalled();
-            expect(document.head.appendChild).not.toHaveBeenCalled();
-            expect(callback).toHaveBeenCalled();
-        });
-
-        it('adds a script tag for 1 plugin', function () {
-            var plugins = { foo : { modules: ['bar.js'] } };
-            pluginUtils.loadClientJs(plugins, callback);
-            expect(document.createElement).toHaveBeenCalled();
-            expect(script.src).toEqual('local:///plugins/foo/bar.js');
-            expect(document.head.appendChild).toHaveBeenCalled();
-            script.onload();
-            expect(callback).toHaveBeenCalled();
-        });
-
-        it('adds multiple script tags for 1 plugin', function () {
-            var plugins = { foo: { modules: ['bar.js', '2.js'] } };
-            pluginUtils.loadClientJs(plugins, callback);
-            expect(document.createElement.callCount).toBe(2);
-            expect(document.head.appendChild.callCount).toBe(2);
-            script.onload();
-            script.onload();
-            expect(callback.callCount).toBe(1);
-        });
-
-        it('adds script tags for multiple plugins', function () {
-            var plugins = { foo: { modules: ['1.js'] }, bar: { modules: ['1.js', '2.js' ] } };
-            pluginUtils.loadClientJs(plugins, callback);
-            expect(document.createElement.callCount).toBe(3);
-            expect(document.head.appendChild.callCount).toBe(3);
-            script.onload();
-            script.onload();
-            script.onload();
-            expect(callback.callCount).toBe(1);
-        });
-
-        it('calls clobber', function () {
-            var plugins = { foo: { modules : ['bar.js'], clobbers: { bar: { path: 'foo.bar' } } } };
-            pluginUtils.loadClientJs(plugins, callback);
-            script.onload();
-            expect(callback.callCount).toBe(1);
-            expect(builder.buildIntoAndClobber).toHaveBeenCalledWith(plugins.foo.clobbers, window);
-        });
-
-        it('calls merge', function () {
-            var plugins = { foo: { modules : ['bar.js'], merges: { bar: { path: 'foo.bar' } } } };
-            pluginUtils.loadClientJs(plugins, callback);
-            script.onload();
-            expect(callback.callCount).toBe(1);
-            expect(builder.buildIntoAndMerge).toHaveBeenCalledWith(plugins.foo.merges, window);
-        });
-
-    });
-
-    describe('getPlugins', function () {
-
-        var success,
-            error,
-            xhr;
-
-        beforeEach(function () {
-            GLOBAL.XMLHttpRequest = function () {
-                this.open = jasmine.createSpy();
-                this.send = jasmine.createSpy();
-                xhr = this;
-            };
-            success = jasmine.createSpy();
-            error = jasmine.createSpy();
-        });
-
-        afterEach(function () {
-            delete GLOBAL.XMLHttpRequest;
-        });
-
-        it('sends XHR for plugins.json', function () {
-            pluginUtils.getPlugins(success, error);
-            expect(xhr.open).toHaveBeenCalledWith('GET', 'local:///plugins/plugins.json', true);
-            expect(xhr.send).toHaveBeenCalled();
-        });
-
-        it('calls success with JSON response', function () {
-            pluginUtils.getPlugins(success, error);
-            xhr.readyState = 4;
-            xhr.status = 200;
-            xhr.responseText = '{ "hello" : "World" }';
-            xhr.onreadystatechange();
-            expect(success).toHaveBeenCalledWith({ hello: "World"});
-            expect(error).not.toHaveBeenCalled();
-        });
-
-        it('calls error with status', function () {
-            pluginUtils.getPlugins(success, error);
-            xhr.readyState = 4;
-            xhr.status = 500;
-            xhr.onreadystatechange();
-            expect(error).toHaveBeenCalledWith(500);
-            expect(success).not.toHaveBeenCalled();
-        });
-
-        it('calls error with parse exception', function () {
-            pluginUtils.getPlugins(success, error);
-            xhr.readyState = 4;
-            xhr.status = 200;
-            xhr.responseText = 'INVALID';
-            xhr.onreadystatechange();
-            expect(error).toHaveBeenCalled();
-            expect(success).not.toHaveBeenCalled();
-        });
-
-    });
-});


[04/32] js commit: [BlackBerry10] Incorporate webworks.js logic into cordova.blackberry10.js

Posted by lo...@apache.org.
[BlackBerry10] Incorporate webworks.js logic into cordova.blackberry10.js


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/28084c53
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/28084c53
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/28084c53

Branch: refs/heads/future
Commit: 28084c5348374f3c94787fae4807b69672758bd6
Parents: 615aea4
Author: Rosa Tse <rt...@rim.com>
Authored: Wed Feb 20 09:21:18 2013 -0500
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:10 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js                      |    2 +-
 lib/blackberry10/plugin/blackberry10/builder.js   |   74 ++
 lib/blackberry10/plugin/blackberry10/event.js     |  102 +++
 lib/blackberry10/plugin/blackberry10/exception.js |   74 ++
 lib/blackberry10/plugin/blackberry10/utils.js     |  556 ++++++++++++++++
 lib/scripts/bootstrap-blackberry10.js             |  199 ++++++-
 lib/scripts/require.js                            |  289 +++++++--
 test/blackberry10/test.builder.js                 |  121 ++++
 test/blackberry10/test.event.js                   |  188 ++++++
 9 files changed, 1533 insertions(+), 72 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index af6d65e..7b6bb2a 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -31,7 +31,7 @@ module.exports = {
         builder.buildIntoAndMerge(platform.merges, window);
 
         modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
-        modulemapper.loadMatchingModules(new RegExp('cordova/.*' + this.runtime() + '/.*bbsymbols$'));
+        modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
         modulemapper.mapModules(window);
 
         platform.initialize();

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/blackberry10/plugin/blackberry10/builder.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/builder.js b/lib/blackberry10/plugin/blackberry10/builder.js
new file mode 100644
index 0000000..9271c58
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/builder.js
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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 utils = require("cordova/plugin/blackberry10/utils");
+
+function buildNamespace(currentNamespace, namespaceParts, featureProperties) {
+    var featureId,
+        nextPart;
+
+    if (namespaceParts.length === 1) {
+        //base case, feature properties go here
+        featureId = namespaceParts[0];
+        if (currentNamespace[featureId] === undefined) {
+            currentNamespace[featureId] = {};
+        }
+
+        currentNamespace = utils.mixin(featureProperties, currentNamespace[featureId]);
+        return currentNamespace;
+    }
+    else {
+        nextPart = namespaceParts.shift();
+        if (currentNamespace[nextPart] === undefined) {
+            currentNamespace[nextPart] = {};
+        }
+
+        return buildNamespace(currentNamespace[nextPart], namespaceParts, featureProperties);
+    }
+}
+
+function include(parent, featureIdList) {
+    var featureId,
+        featureProperties,
+        localUrl,
+        i;
+
+    for (i = 0; i < featureIdList.length; i++) {
+        featureId = featureIdList[i];
+
+        localUrl = "local://ext/" + featureId + "/client.js";
+        featureProperties = utils.loadModule(localUrl);
+
+        buildNamespace(parent, featureId.split("."), featureProperties);
+    }
+}
+
+var _self = {
+    build: function (featureIdList) {
+        return {
+            into: function (target) {
+                include(target, featureIdList);
+            }
+        };
+    }
+};
+
+module.exports = _self;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/blackberry10/plugin/blackberry10/event.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/event.js b/lib/blackberry10/plugin/blackberry10/event.js
new file mode 100644
index 0000000..9e91fe4
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/event.js
@@ -0,0 +1,102 @@
+/*
+ *
+ * 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 _handlers = {};
+
+function _add(featureId, name, cb, success, fail, once) {
+    var handler;
+    if (featureId && name && typeof cb === "function") {
+        handler = {
+            func: cb,
+            once: !!once
+        };
+        //If this is the first time we are adding a cb
+        if (!_handlers.hasOwnProperty(name)) {
+            _handlers[name] = [handler];
+            //Once listeners should not be registered with the context because there is no underlying event to call them
+            //HOWEVER the webview needs to register itself with lib/event.
+            if (once) {
+                window.webworks.exec(success, fail, "event", "once", {"eventName": name});
+            } else {
+                window.webworks.exec(success, fail, featureId, "add", {"eventName": name});
+            }
+        } else if (!_handlers[name].some(function (element, index, array) {
+            return element.func === cb;
+        })) {
+            //Only add unique callbacks
+            _handlers[name].push(handler);
+        }
+    }
+}
+
+module.exports = {
+    add: function (featureId, name, cb, success, fail) {
+        _add(featureId, name, cb, success, fail, false);
+    },
+
+    once: function (featureId, name, cb, success, fail) {
+        _add(featureId, name, cb, success, fail, true);
+    },
+
+    isOn: function (name) {
+        return !!_handlers[name];
+    },
+
+    remove: function (featureId, name, cb, success, fail) {
+        if (featureId && name && typeof cb === "function") {
+            if (_handlers.hasOwnProperty(name)) {
+                _handlers[name] = _handlers[name].filter(function (element, index, array) {
+                    return element.func !== cb || element.once;
+                });
+
+                if (_handlers[name].length === 0) {
+                    delete _handlers[name];
+                    window.webworks.exec(success, fail, featureId, "remove", {"eventName": name});
+                }
+            }
+        }
+    },
+
+    trigger: function (name, args) {
+        var parsedArgs;
+        if (_handlers.hasOwnProperty(name)) {
+            if (args && args !== "undefined") {
+                parsedArgs = JSON.parse(decodeURIComponent(unescape(args)));
+            }
+            //Call the handlers
+            _handlers[name].forEach(function (handler) {
+                if (handler) {
+                    //args should be an array of arguments
+                    handler.func.apply(undefined, parsedArgs);
+                }
+            });
+            //Remove the once listeners
+            _handlers[name] = _handlers[name].filter(function (handler) {
+                return !handler.once;
+            });
+            //Clean up the array if it is empty
+            if (_handlers[name].length === 0) {
+                delete _handlers[name];
+                //No need to call remove since this would only be for callbacks
+            }
+        }
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/blackberry10/plugin/blackberry10/exception.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/exception.js b/lib/blackberry10/plugin/blackberry10/exception.js
new file mode 100644
index 0000000..515d46d
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/exception.js
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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 = {
+
+    types: {
+        Application: "Application",
+        ArgumentLength: "ArgumentLength",
+        ArgumentType: "ArgumentType",
+        Argument: "Argument",
+        NotificationType: "NotificationType",
+        NotificationStateType: "NotificationStateType",
+        DomObjectNotFound: "DomObjectNotFound",
+        MethodNotImplemented: "MethodNotImplemented",
+        InvalidState: "InvalidState",
+        ApplicationState: "ApplicationState"
+    },
+
+    handle: function handle(exception, reThrow) {
+        reThrow = reThrow || false;
+
+        var eMsg = exception.message || "exception caught!",
+        msg = eMsg + "\n\n" + (exception.stack || "*no stack provided*") + "\n\n";
+
+        console.error(msg);
+
+        if (reThrow) {
+            throw exception;
+        }
+    },
+
+    raise: function raise(exceptionType, message, customExceptionObject) {
+        var obj = customExceptionObject || {
+                type: "",
+                message: "",
+
+                toString: function () {
+                    var result = this.name + ': "' + this.message + '"';
+
+                    if (this.stack) {
+                        result += "\n" + this.stack;
+                    }
+                    return result;
+                }
+            };
+
+        message = message || "";
+
+        obj.name = exceptionType;
+        obj.type = exceptionType;
+        // TODO: include the exception objects original message if exists
+        obj.message = message;
+
+        throw obj;
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/blackberry10/plugin/blackberry10/utils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/utils.js b/lib/blackberry10/plugin/blackberry10/utils.js
new file mode 100644
index 0000000..3a630da
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/utils.js
@@ -0,0 +1,556 @@
+/*
+ *
+ * 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 self,
+    exception = require('cordova/plugin/blackberry10/exception');
+
+function S4() {
+    return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
+}
+
+self = module.exports = {
+    validateNumberOfArguments: function (lowerBound, upperBound, numberOfArguments, customExceptionType, customExceptionMessage, customExceptionObject) {
+
+        customExceptionMessage = customExceptionMessage || "";
+
+        if (arguments.length < 3 || arguments.length > 6) {
+            exception.raise(exception.types.Argument, "Wrong number of arguments when calling: validateNumberOfArguments()");
+        }
+
+        if (isNaN(lowerBound) && isNaN(upperBound) && isNaN(numberOfArguments)) {
+            exception.raise(exception.types.ArgumentType, "(validateNumberOfArguments) Arguments are not numbers");
+        }
+
+        lowerBound = parseInt(lowerBound, 10);
+        upperBound = parseInt(upperBound, 10);
+        numberOfArguments = parseInt(numberOfArguments, 10);
+
+        if (numberOfArguments < lowerBound || numberOfArguments > upperBound) {
+            exception.raise((customExceptionType || exception.types.ArgumentLength), (customExceptionMessage + "\n\nWrong number of arguments"), customExceptionObject);
+        }
+
+    },
+
+    validateArgumentType: function (arg, argType, customExceptionType, customExceptionMessage, customExceptionObject) {
+        var invalidArg = false,
+            msg;
+
+        switch (argType) {
+        case "array":
+            if (!arg instanceof Array) {
+                invalidArg = true;
+            }
+            break;
+        case "date":
+            if (!arg instanceof Date) {
+                invalidArg = true;
+            }
+            break;
+        case "integer":
+            if (typeof arg === "number") {
+                if (arg !== Math.floor(arg)) {
+                    invalidArg = true;
+                }
+            }
+            else {
+                invalidArg = true;
+            }
+            break;
+        default:
+            if (typeof arg !== argType) {
+                invalidArg = true;
+            }
+            break;
+        }
+
+        if (invalidArg) {
+            msg = customExceptionMessage +  ("\n\nInvalid Argument type. argument: " + arg + " ==> was expected to be of type: " + argType);
+            exception.raise((customExceptionType || exception.types.ArgumentType), msg, customExceptionObject);
+        }
+    },
+
+    validateMultipleArgumentTypes: function (argArray, argTypeArray, customExceptionType, customExceptionMessage, customExceptionObject) {
+        for (var i = 0; i < argArray.length; i++) {
+            this.validateArgumentType(argArray[i], argTypeArray[i], customExceptionType, customExceptionMessage, customExceptionObject);
+        }
+    },
+
+    arrayContains: function (array, obj) {
+        var i = array.length;
+        while (i--) {
+            if (array[i] === obj) {
+                return true;
+            }
+        }
+        return false;
+    },
+
+    some: function (obj, predicate, scope) {
+        if (obj instanceof Array) {
+            return obj.some(predicate, scope);
+        }
+        else {
+            var values = self.map(obj, predicate, scope);
+
+            return self.reduce(values, function (some, value) {
+                return value ? value : some;
+            }, false);
+        }
+    },
+
+    count: function (obj) {
+        return self.sum(obj, function (total) {
+            return 1;
+        });
+    },
+
+    sum: function (obj, selector, scope) {
+        var values = self.map(obj, selector, scope);
+        return self.reduce(values, function (total, value) {
+            return total + value;
+        });
+    },
+
+    max: function (obj, selector, scope) {
+        var values = self.map(obj, selector, scope);
+        return self.reduce(values, function (max, value) {
+            return max < value ? value : max;
+        }, Number.MIN_VALUE);
+    },
+
+    min: function (obj, selector, scope) {
+        var values = self.map(obj, selector, scope);
+        return self.reduce(values, function (min, value) {
+            return min > value ? value : min;
+        }, Number.MAX_VALUE);
+    },
+
+    forEach: function (obj, action, scope) {
+        if (obj instanceof Array) {
+            return obj.forEach(action, scope);
+        }
+        else {
+            self.map(obj, action, scope);
+        }
+    },
+
+    filter: function (obj, predicate, scope) {
+        if (obj instanceof Array) {
+            return obj.filter(predicate, scope);
+        }
+        else {
+            var result = [];
+            self.forEach(obj, function (value, index) {
+                if (predicate.apply(scope, [value, index])) {
+                    result.push(value);
+                }
+
+            }, scope);
+
+            return result;
+        }
+    },
+
+    reduce: function (obj, func, init, scope) {
+        var i,
+            initial = init === undefined ? 0 : init,
+            result = initial;
+
+
+        if (obj instanceof Array) {
+            return obj.reduce(func, initial);
+        }
+        else if (obj instanceof NamedNodeMap) {
+            for (i = 0; i < obj.length; i++) {
+                result = func.apply(scope, [result, obj[i], i]);
+            }
+        }
+        else {
+            for (i in obj) {
+                if (obj.hasOwnProperty(i)) {
+                    result = func.apply(scope, [result, obj[i], i]);
+                }
+            }
+        }
+
+        return result;
+
+    },
+
+    map: function (obj, func, scope) {
+        var i,
+            returnVal = null,
+            result = [];
+
+        if (obj instanceof Array) {
+            return obj.map(func, scope);
+        }
+        else if (obj instanceof NamedNodeMap) {
+            for (i = 0; i < obj.length; i++) {
+                returnVal = func.apply(scope, [obj[i], i]);
+                result.push(returnVal);
+            }
+        }
+        else {
+            for (i in obj) {
+                if (obj.hasOwnProperty(i)) {
+                    returnVal = func.apply(scope, [obj[i], i]);
+                    result.push(returnVal);
+                }
+            }
+        }
+
+        return result;
+    },
+
+    series: function (tasks, callback) {
+
+        var execute = function () {
+            var args = [],
+                task;
+
+            if (tasks.length) {
+                task = tasks.shift();
+                args = args.concat(task.args).concat(execute);
+                task.func.apply(this, args);
+            }
+            else {
+                callback.func.apply(this, callback.args);
+            }
+        };
+
+        execute();
+    },
+
+    regexSanitize: function (regexString) {
+        return regexString.replace("^", "\\^")
+                    .replace("$", "\\$")
+                    .replace("(", "\\(")
+                    .replace(")", "\\)")
+                    .replace("<", "\\<")
+                    .replace("[", "\\[")
+                    .replace("{", "\\{")
+                    .replace(/\\/, "\\\\")
+                    .replace("|", "\\|")
+                    .replace(">", "\\>")
+                    .replace(".", "\\.")
+                    .replace("*", "\\*")
+                    .replace("+", "\\+")
+                    .replace("?", "\\?");
+    },
+
+    find: function (comparison, collection, startInx, endInx, callback) {
+        var results = [],
+            compare = function (s, pattern) {
+
+                if (typeof(s) !== "string" || pattern === null) {
+                    return s === pattern;
+                }
+
+                var regex = pattern.replace(/\./g, "\\.")
+                                   .replace(/\^/g, "\\^")
+                                   .replace(/\*/g, ".*")
+                                   .replace(/\\\.\*/g, "\\*");
+
+                regex = "^".concat(regex, "$");
+
+                return !!s.match(new RegExp(regex, "i"));
+            };
+
+        self.forEach(collection, function (c) {
+            var match,
+                fail = false;
+
+            self.forEach(comparison, function (value, key) {
+                if (!fail && value !== undefined) {
+
+                    if (compare(c[key], value)) {
+                        match = c;
+                    }
+                    else {
+                        fail = true;
+                        match = null;
+                    }
+                }
+            });
+
+            if (match) {
+                results.push(match);
+            }
+        });
+
+        if (callback) {
+            if (startInx === undefined) {
+                startInx = 0;
+            }
+            if (endInx === undefined) {
+                endInx = results.length;
+            }
+            if (startInx === endInx) {
+                endInx = startInx + 1;
+            }
+
+            callback.apply(null, [results.slice(startInx, endInx)]);
+        }
+    },
+
+    mixin: function (mixin, to) {
+        Object.getOwnPropertyNames(mixin).forEach(function (prop) {
+            if (Object.hasOwnProperty.call(mixin, prop)) {
+                Object.defineProperty(to, prop, Object.getOwnPropertyDescriptor(mixin, prop));
+            }
+        });
+        return to;
+    },
+
+    copy: function (obj) {
+        var i,
+            newObj = (obj === null ? false : global.toString.call(obj) === "[object Array]") ? [] : {};
+
+        if (typeof obj === 'number' ||
+            typeof obj === 'string' ||
+            typeof obj === 'boolean' ||
+            obj === null ||
+            obj === undefined) {
+            return obj;
+        }
+
+        if (obj instanceof Date) {
+            return new Date(obj);
+        }
+
+        if (obj instanceof RegExp) {
+            return new RegExp(obj);
+        }
+
+        for (i in obj) {
+            if (obj.hasOwnProperty(i)) {
+                if (obj[i] && typeof obj[i] === "object") {
+                    if (obj[i] instanceof Date) {
+                        newObj[i] = obj[i];
+                    }
+                    else {
+                        newObj[i] = self.copy(obj[i]);
+                    }
+                }
+                else {
+                    newObj[i] = obj[i];
+                }
+            }
+        }
+
+        return newObj;
+    },
+
+    startsWith : function (str, substr) {
+        return str.indexOf(substr) === 0;
+    },
+
+    endsWith : function (str, substr) {
+        return str.indexOf(substr, str.length - substr.length) !== -1;
+    },
+
+    parseUri : function (str) {
+        var i, uri = {},
+            key = [ "source", "scheme", "authority", "userInfo", "user", "password", "host", "port", "relative", "path", "directory", "file", "query", "anchor" ],
+            matcher = /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/.exec(str);
+
+        for (i = key.length - 1; i >= 0; i--) {
+            uri[key[i]] = matcher[i] || "";
+        }
+
+        return uri;
+    },
+
+    // uri - output from parseUri
+    isAbsoluteURI : function (uri) {
+        if (uri && uri.source) {
+            return uri.relative !== uri.source;
+        }
+
+        return false;
+    },
+
+    fileNameToImageMIME : function (fileName) {
+
+        var extensionsToMIME = {},
+            ext;
+
+        extensionsToMIME.png = 'image/png';
+        extensionsToMIME.jpg = 'image/jpeg';
+        extensionsToMIME.jpe = 'image/jpeg';
+        extensionsToMIME.jpeg = 'image/jpeg';
+        extensionsToMIME.gif = 'image/gif';
+        extensionsToMIME.bmp = 'image/bmp';
+        extensionsToMIME.bm = 'image/bmp';
+        extensionsToMIME.svg = 'image/svg+xml';
+        extensionsToMIME.tif = 'image/tiff';
+        extensionsToMIME.tiff = 'image/tiff';
+
+        ext = fileName.split('.').pop();
+        return extensionsToMIME[ext];
+    },
+
+    isLocalURI : function (uri) {
+        return uri && uri.scheme && "local:///".indexOf(uri.scheme.toLowerCase()) !== -1;
+    },
+
+    isFileURI : function (uri) {
+        return uri && uri.scheme && "file://".indexOf(uri.scheme.toLowerCase()) !== -1;
+    },
+
+    isHttpURI : function (uri) {
+        return uri && uri.scheme && "http://".indexOf(uri.scheme.toLowerCase()) !== -1;
+    },
+
+    isHttpsURI : function (uri) {
+        return uri && uri.scheme && "https://".indexOf(uri.scheme.toLowerCase()) !== -1;
+    },
+
+    // Checks if the specified uri starts with 'data:'
+    isDataURI : function (uri) {
+        return uri && uri.scheme && "data:".indexOf(uri.scheme.toLowerCase()) !== -1;
+    },
+
+    performExec : function (featureId, property, args) {
+        var result;
+
+        window.webworks.exec(function (data, response) {
+            result = data;
+        }, function (data, response) {
+            throw data;
+        }, featureId, property, args, true);
+
+        return result;
+    },
+
+    inNode : function () {
+        return !!require.resolve;
+    },
+
+    requireWebview : function () {
+        return require("./webview");
+    },
+    convertDataToBinary : function (data, dataEncoding) {
+        var rawData,
+            uint8Array,
+            i;
+
+        if (data) {
+            if (dataEncoding.toLowerCase() === "base64") {
+                rawData = window.atob(data);
+            }
+            else {
+                rawData = data;
+            }
+
+            uint8Array = new Uint8Array(new ArrayBuffer(rawData.length));
+
+            for (i = 0; i < uint8Array.length; i++) {
+                uint8Array[i] = rawData.charCodeAt(i);
+            }
+
+            return uint8Array.buffer;
+        }
+    },
+    getBlobWithArrayBufferAsData : function (data, dataEncoding) {
+        var rawData,
+            blobBuilderObj = new window.WebKitBlobBuilder();
+        rawData = this.convertDataToBinary(data, dataEncoding);
+        blobBuilderObj.append(rawData);
+
+        return blobBuilderObj.getBlob("arraybuffer");
+    },
+    loadModule: function (module) {
+        return require(module);
+    },
+    loadExtensionModule: function (extBasename, path) {
+        var ext = require("./manifest")[extBasename];
+
+        if (ext) {
+            return require("../ext/" + ext.namespace + "/" + path);
+        } else {
+            return null;
+        }
+    },
+    hasPermission: function (config, permission) {
+        if (config && config.permissions && config.permissions.length) {
+            return config.permissions.indexOf(permission) >= 0;
+        }
+
+        return false;
+    },
+    guid: function () {
+        return (S4() + S4() + "-" + S4() + "-" + S4() + "-" + S4() + "-" + S4() + S4() + S4());
+    },
+    getURIPrefix: function () {
+        return "http://localhost:8472/";
+    },
+    translatePath: function (path) {
+        if (path.indexOf("local:///") === 0) {
+            var sourceDir = window.qnx.webplatform.getApplication().getEnv("HOME"); //leading slashes need to be removed
+            path = "file:///" + sourceDir.replace(/^\/*/, '') + "/../app/native/" + path.replace(/local:\/\/\//, '');
+        }
+        return path;
+    },
+    invokeInBrowser: function (url) {
+        var request = {
+            uri: url,
+            target: "sys.browser"
+        };
+        window.qnx.webplatform.getApplication().invocation.invoke(request);
+    },
+    isPersonal: function () {
+        return window.qnx.webplatform.getApplication().getEnv("PERIMETER") === "personal";
+    },
+    deepclone: function (obj) {
+        var newObj = obj instanceof Array ? [] : {},
+            key;
+
+        if (typeof obj === 'number' ||
+                typeof obj === 'string' ||
+                typeof obj === 'boolean' ||
+                obj === null ||
+                obj === undefined) {
+            return obj;
+        }
+
+        if (obj instanceof Date) {
+            return new Date(obj);
+        }
+
+        if (obj instanceof RegExp) {
+            return new RegExp(obj);
+        }
+
+        for (key in obj) {
+            if (obj.hasOwnProperty(key)) {
+                if (obj[key] && typeof obj[key] === "object") {
+                    newObj[key] = self.deepclone(obj[key]);
+                } else {
+                    newObj[key] = obj[key];
+                }
+            }
+        }
+
+        return newObj;
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 65115fd..1a33845 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -19,16 +19,193 @@
  *
 */
 
-document.addEventListener("DOMContentLoaded", function () {
-    var wwjs = document.createElement("script");
-    wwjs.src = "local:///chrome/webworks.js";
-    wwjs.onload = function () {
-        document.addEventListener("webworksready", function () {
-            require('cordova/channel').onNativeReady.fire();
-        });
-    };
-    wwjs.onerror = function () {
-        alert('there was a problem loading webworks.js');
+(function () {
+    var _d = document.addEventListener,
+        _webworksReady = false,
+        _alreadyFired = false,
+        _listenerRegistered = false;
+
+    //Only fire the webworks event when both webworks is ready and a listener is registered
+    function fireWebworksReadyEvent() {
+        if (_listenerRegistered && _webworksReady && !_alreadyFired) {
+            _alreadyFired = true;
+            var evt = document.createEvent("Events");
+            evt.initEvent("webworksready", true, true);
+            document.dispatchEvent(evt);
+        }
+    }
+
+    //Trapping when users add listeners to the webworks ready event
+    //This way we can make sure not to fire the event before there is a listener
+    document.addEventListener = function (event, callback, capture) {
+        _d.call(document, event, callback, capture);
+        if (event.toLowerCase() === "webworksready") {
+            _listenerRegistered = true;
+            fireWebworksReadyEvent();
+        }
     };
-    document.head.appendChild(wwjs);
+
+    function createWebworksReady() {
+        function RemoteFunctionCall(functionUri) {
+            var params = {};
+
+            function composeUri() {
+                return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
+            }
+
+            function createXhrRequest(uri, isAsync) {
+                var request = new XMLHttpRequest();
+
+                request.open("POST", uri, isAsync);
+                request.setRequestHeader("Content-Type", "application/json");
+
+                return request;
+            }
+
+            this.addParam = function (name, value) {
+                params[name] = encodeURIComponent(JSON.stringify(value));
+            };
+
+            this.makeSyncCall = function (success, error) {
+                var requestUri = composeUri(),
+                    request = createXhrRequest(requestUri, false),
+                    response,
+                    errored,
+                    cb,
+                    data;
+
+                request.send(JSON.stringify(params));
+
+                response = JSON.parse(decodeURIComponent(request.responseText) || "null");
+                errored = response.code < 0;
+                cb = errored ? error : success;
+                data = errored ? response.msg : response.data;
+
+                if (cb) {
+                    cb(data, response);
+                }
+                else if (errored) {
+                    throw data;
+                }
+
+                return data;
+            };
+
+            this.makeAsyncCall = function (success, error) {
+                var requestUri = composeUri(),
+                    request = createXhrRequest(requestUri, true);
+
+                request.onreadystatechange = function () {
+                    if (request.readyState === 4 && request.status === 200) {
+                        var response = JSON.parse(decodeURIComponent(request.responseText) || "null"),
+                        cb = response.code < 0 ? error : success,
+                        data = response.code < 0 ? response.msg : response.data;
+
+                        return cb && cb(data, response);
+                    }
+                };
+
+                request.send(JSON.stringify(params));
+            };
+        }
+
+        var builder,
+            request,
+            resp,
+            execFunc;
+
+        //For users who wish to have a single source project across BB7 -> PB -> BB10 they will need to use webworks.js
+        //To aid in this, we will fire the webworksready event on these platforms as well
+        //If blackberry object already exists then we are in an older version of webworks
+        if (window.blackberry) {
+            _webworksReady = true;
+            fireWebworksReadyEvent();
+            return;
+        }
+
+        // Build out the blackberry namespace based on the APIs desired in the config.xml
+        builder = require('cordova/plugin/blackberry10/builder');
+
+        request = new XMLHttpRequest();
+        request.open("GET", "http://localhost:8472/extensions/get", true);
+
+        request.onreadystatechange = function () {
+            if (request.readyState === 4) {
+                resp = JSON.parse(decodeURIComponent(request.responseText));
+
+                if (request.status === 200) {
+                    builder.build(resp.data).into(window);
+                    //At this point all of the APIs should be built into the window object
+                    //Fire the webworks ready event
+                    _webworksReady = true;
+                    fireWebworksReadyEvent();
+                }
+            }
+        };
+        request.send(null);
+
+        execFunc = function (success, fail, service, action, args, sync) {
+            var uri = service + "/" + action,
+                request = new RemoteFunctionCall(uri),
+                name;
+
+            for (name in args) {
+                if (Object.hasOwnProperty.call(args, name)) {
+                    request.addParam(name, args[name]);
+                }
+            }
+
+            request[sync ? "makeSyncCall" : "makeAsyncCall"](success, fail);
+        };
+
+        window.webworks = {
+            exec: execFunc,
+            execSync: function (service, action, args) {
+                var result;
+
+                execFunc(function (data, response) {
+                    result = data;
+                }, function (data, response) {
+                    throw data;
+                }, service, action, args, true);
+
+                return result;
+            },
+            execAsync: function (service, action, args) {
+                var result;
+
+                execFunc(function (data, response) {
+                    result = data;
+                }, function (data, response) {
+                    throw data;
+                }, service, action, args, false);
+
+                return result;
+            },
+            successCallback: function (id, args) {
+                //HACK: this will live later
+                throw "not implemented";
+            },
+            errorCallback: function (id, args) {
+                //HACK: this will live later
+                throw "not implemented";
+            },
+            defineReadOnlyField: function (obj, field, value) {
+                Object.defineProperty(obj, field, {
+                    "value": value,
+                    "writable": false
+                });
+            },
+            event: require("cordova/plugin/blackberry10/event")
+        };
+    }
+
+    // Let's create the webworks namespace
+    createWebworksReady();
+}());
+
+document.addEventListener("DOMContentLoaded", function () {
+    document.addEventListener("webworksready", function () {
+        require('cordova/channel').onNativeReady.fire();
+    });
 });

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/lib/scripts/require.js
----------------------------------------------------------------------
diff --git a/lib/scripts/require.js b/lib/scripts/require.js
index 5dbc905..35f160e 100644
--- a/lib/scripts/require.js
+++ b/lib/scripts/require.js
@@ -1,82 +1,251 @@
 /*
+ *  Copyright 2012 Research In Motion Limited.
  *
- * 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
+ * Licensed 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
+ * 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.
- *
-*/
+ * 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 require,
-    define;
+var define,
+    require;
 
 (function () {
-    var modules = {};
-    // Stack of moduleIds currently being built.
-    var requireStack = [];
-    // Map of module ID -> index into requireStack of modules currently being built.
-    var inProgressModules = {};
-
-    function build(module) {
-        var factory = module.factory;
-        module.exports = {};
-        delete module.factory;
-        factory(require, module.exports, module);
+    var unpreparedModules = {},
+        readyModules = {},
+        ACCEPTABLE_EXTENSIONS = [".js", ".json"],
+        DEFAULT_EXTENSION = ".js";
+
+    function hasValidExtension(moduleName) {
+        return ACCEPTABLE_EXTENSIONS.some(function (element, index, array) {
+            return moduleName.match("\\" + element + "$");
+        });
+    }
+
+
+    function normalizeName(originalName, baseName) {
+        var nameParts,
+            name = originalName.slice(0);
+        //remove ^local:// (if it exists) and .js$
+        //This will not work for local:// without a trailing js
+        name = name.replace(/(?:^local:\/\/)/, "");
+        if (name.charAt(0) === '.' && baseName) {
+            //Split the baseName and remove the final part (the module name)
+            nameParts = baseName.split('/');
+            nameParts.pop();
+            nameParts = nameParts.concat(name.split('/'));
+            
+            name = nameParts.reduce(function (previous, current,  index, array) {
+                var returnValue,
+                    slashIndex;
+
+                //If previous is a dot, ignore it
+                //If previous is ever just .. we're screwed anyway
+                if (previous !== '.') {
+                    returnValue = previous;
+                }
+                
+                //If we have a .. then remove a chunk of previous
+                if (current === "..") {
+                    slashIndex = previous.lastIndexOf('/');
+                    //If there's no slash we're either screwed or we remove the final token
+                    if (slashIndex !== -1) {
+                        returnValue = previous.slice(0, previous.lastIndexOf('/'));
+                    } else {
+                        returnValue = "";
+                    }
+                } else if (current !== '.') {
+                    //Otherwise simply append anything not a .
+                    //Only append a slash if we're not empty
+                    if (returnValue.length) {
+                        returnValue += "/";
+                    }
+                    returnValue += current;
+                }
+
+                return returnValue;
+            });
+
+        }
+        
+        //If there is no acceptable extension tack on a .js
+        if (!hasValidExtension(name)) {
+            name = name + DEFAULT_EXTENSION;
+        }
+
+        return name;
+    }
+
+    function buildModule(name, dependencies, factory) {
+        var module = {exports: {}},
+            localRequire = function (moduleName) {
+                return require(moduleName, name);
+            },
+            args = [];
+        localRequire.toUrl = function (moduleName, baseName) {
+            return require.toUrl(moduleName, baseName || name);
+        };
+        dependencies.forEach(function (dependency) {
+            if (dependency === 'require') {
+                args.push(localRequire);
+            } else if (dependency === 'exports') {
+                args.push(module.exports);
+            } else if (dependency === 'module') {
+                args.push(module);
+            } else {
+                //This is because jshint cannot handle out of order functions
+                /*global loadModule:false */
+                args.push(loadModule(dependency));
+                /*global loadModule:true */
+            }
+        });
+
+        //No need to process dependencies, webworks only has require, exports, module
+        factory.apply(this, args);
+
+        //For full AMD we would need logic to also check the return value
         return module.exports;
+
     }
 
-    require = function (id) {
-        if (!modules[id]) {
-            throw "module " + id + " not found";
-        } else if (id in inProgressModules) {
-            var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
-            throw "Cycle in require graph: " + cycle;
+    function getDefineString(moduleName, body) {
+        var evalString = 'define("' + moduleName + '", function (require, exports, module) {',
+            isJson = /\.json$/.test(moduleName);
+
+        evalString += isJson ? ' module.exports = ' : '';
+        evalString += body.replace(/^\s+|\s+$/g, '');
+        evalString += isJson ? ' ;' : '';
+        evalString += '});';
+
+        return evalString;
+    }
+
+    function loadModule(name, baseName) {
+        var normalizedName = normalizeName(name, baseName),
+            url,
+            xhr,
+            loadResult;
+        //Always check undefined first, this allows the user to redefine modules
+        //(Not used in WebWorks, although it is used in our unit tests)
+        if (unpreparedModules[normalizedName]) {
+            readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
+            delete unpreparedModules[normalizedName];
         }
-        if (modules[id].factory) {
-            try {
-                inProgressModules[id] = requireStack.length;
-                requireStack.push(id);
-                return build(modules[id]);
-            } finally {
-                delete inProgressModules[id];
-                requireStack.pop();
+
+        //If the module does not exist, load the module from external source
+        //Webworks currently only loads APIs from across bridge
+        if (!readyModules[normalizedName]) {
+            //If the module to be loaded ends in .js then we will define it
+            //Also if baseName exists than we have a local require situation
+            if (hasValidExtension(name) || baseName) {
+                xhr = new XMLHttpRequest();
+                url = name;
+                //If the module to be loaded starts with local:// go over the bridge
+                //Else If the module to be loaded is a relative load it may not have .js extension which is needed
+                if (/^local:\/\//.test(name)) {
+                    url = "http://localhost:8472/extensions/load/" + normalizedName.replace(/(?:^ext\/)(.+)(?:\/client.js$)/, "$1");
+
+                    xhr.open("GET", url, false);
+                    xhr.send(null);
+                    try {
+                        loadResult = JSON.parse(xhr.responseText);
+
+                        loadResult.dependencies.forEach(function (dep) {
+                            /*jshint evil:true */
+                            eval(getDefineString(dep.moduleName, dep.body));
+                            /*jshint evil:false */
+                        });
+
+                        //Trimming responseText to remove EOF chars
+                        /*jshint evil:true */
+                        eval(getDefineString(normalizedName, loadResult.client));
+                        /*jshint evil:false */
+                    } catch (err1) {
+                        err1.message += ' in ' + url;
+                        throw err1;
+                    }
+                } else {
+                    if (baseName) {
+                        url = normalizedName;
+                    }
+
+                    xhr.open("GET", url, false);
+                    xhr.send(null);
+                    try {
+                        //Trimming responseText to remove EOF chars
+                        /*jshint evil:true */
+                        eval(getDefineString(normalizedName, xhr.responseText));
+                        /*jshint evil:false */
+                    } catch (err) {
+                        err.message += ' in ' + url;
+                        throw err;
+                    }
+                }
+
+                if (unpreparedModules[normalizedName]) {
+                    readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
+                    delete unpreparedModules[normalizedName];
+                }
+            } else {
+                throw "module " + name + " cannot be found";
             }
+
         }
-        return modules[id].exports;
-    };
 
-    define = function (id, factory) {
-        if (modules[id]) {
-            throw "module " + id + " already defined";
+        return readyModules[normalizedName];
+
+    }
+
+    //Use the AMD signature incase we ever want to change.
+    //For now we will only be using (name, baseName)
+    require = function (dependencies, callback) {
+        if (typeof dependencies === "string") {
+            //dependencies is the module name and callback is the relName
+            //relName is not part of the AMDJS spec, but we use it from localRequire
+            return loadModule(dependencies, callback);
+        } else if (Array.isArray(dependencies) && typeof callback === 'function') {
+            //Call it Asynchronously
+            setTimeout(function () {
+                buildModule(undefined, dependencies, callback);
+            }, 0);
         }
+    }; 
 
-        modules[id] = {
-            id: id,
-            factory: factory
-        };
+    require.toUrl = function (originalName, baseName) {
+        return normalizeName(originalName, baseName);
     };
 
-    define.remove = function (id) {
-        delete modules[id];
-    };
+    //Use the AMD signature incase we ever want to change.
+    //For now webworks will only be using (name, factory) signature.
+    define = function (name, dependencies, factory) {
+        if (typeof name === "string" && typeof dependencies === 'function') {
+            factory = dependencies;
+            dependencies = ['require', 'exports', 'module'];
+        }
 
-    define.moduleMap = modules;
-})();
+        //According to the AMDJS spec we should parse out the require statments 
+        //from factory.toString and add those to the list of dependencies
 
-//Export for use in node
+        //Normalize the name. Remove local:// and .js
+        name = normalizeName(name);
+        unpreparedModules[name] = {
+            dependencies: dependencies,
+            factory: factory
+        }; 
+    };
+}());
+
+//Export for use in node for unit tests
 if (typeof module === "object" && typeof require === "function") {
-    module.exports.require = require;
-    module.exports.define = define;
+    module.exports = {
+        require: require,
+        define: define
+    };
 }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/test/blackberry10/test.builder.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.builder.js b/test/blackberry10/test.builder.js
new file mode 100644
index 0000000..86e5487
--- /dev/null
+++ b/test/blackberry10/test.builder.js
@@ -0,0 +1,121 @@
+/*
+ *
+ * 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 app,
+    io,
+    filetransfer,
+    system,
+    builder,
+    utils;
+
+describe("blackberry10 builder", function () {
+
+    beforeEach(function () {
+        //Set up mocking, no need to "spyOn" since spies are included in mock
+        window.webworks = {
+            webworks: {
+                execSync: jasmine.createSpy(),
+                defineReadOnlyField: jasmine.createSpy()
+            }
+        };
+
+        app = {
+            "name": "abc",
+            "version": "1.2.3"
+        };
+        io = {
+            "sandbox": false
+        };
+        filetransfer = {
+            "upload": function () {},
+            "download": function () {}
+        };
+        system =  {
+            "getCurrentTimezone": function () {}
+        };
+
+        utils = require("cordova/plugin/blackberry10/utils");
+        spyOn(utils, "loadModule").andCallFake(function (module) {
+            if (module.indexOf("app") !== -1) {
+                return app;
+            } else if (module.indexOf("filetransfer") !== -1) {
+                return filetransfer;
+            } else if (module.indexOf("io") !== -1) {
+                return io;
+            } else if (module.indexOf("system") !== -1) {
+                return system;
+            }
+        });
+
+        builder = require("cordova/plugin/blackberry10/builder");
+    });
+
+    afterEach(function () {
+        delete window.webworks;
+        builder = null;
+    });
+
+    it("can build an object with a single member", function () {
+        var featureIds = ['blackberry.app'],
+            target = {};
+
+        builder.build(featureIds).into(target);
+
+        expect(target.blackberry.app).toEqual(app);
+        expect(Object.hasOwnProperty.call(target.blackberry.app, "name")).toBeTruthy();
+        expect(Object.hasOwnProperty.call(target.blackberry.app, "version")).toBeTruthy();
+    });
+
+    it("can build an object with a nested member", function () {
+        var featureIds = ['blackberry.io', 'blackberry.io.filetransfer'],
+            target = {};
+
+        builder.build(featureIds).into(target);
+        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
+        expect(target.blackberry.io.sandbox).toEqual(io.sandbox);
+    });
+
+    it("can build with feature IDs provided in any order", function () {
+        var featureIds = ['blackberry.io.filetransfer', 'blackberry.io'],
+            target = {};
+
+        builder.build(featureIds).into(target);
+        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
+        expect(target.blackberry.io.sandbox).toEqual(io.sandbox);
+    });
+
+    it("can build an object with only the nested member", function () {
+        var featureIds = ['blackberry.io.filetransfer'],
+            target = {};
+
+        builder.build(featureIds).into(target);
+        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
+    });
+
+    it("can build an object with multiple members", function () {
+        var featureIds = ['blackberry.app', 'blackberry.system'],
+            target = {};
+
+        builder.build(featureIds).into(target);
+        expect(target.blackberry.app).toEqual(app);
+        expect(target.blackberry.system).toEqual(system);
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/28084c53/test/blackberry10/test.event.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.event.js b/test/blackberry10/test.event.js
new file mode 100644
index 0000000..7d293b8
--- /dev/null
+++ b/test/blackberry10/test.event.js
@@ -0,0 +1,188 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+describe("blackberry10 event", function () {
+    var event = require("cordova/plugin/blackberry10/event"),
+        _window;
+
+    beforeEach(function () {
+        _window = {
+            webworks: {
+                exec: jasmine.createSpy("window.webworks.exec")
+            }
+        };
+        window.webworks = _window.webworks;
+    });
+
+    afterEach(function () {
+        delete window.webworks;
+    });
+
+    describe("add", function () {
+
+        it("it can call webworks.exec action 'add' given valid featureId, eventName and callback", function () {
+            var callback = function () {};
+            event.add("blackberry.system.event", "foo", callback);
+            expect(_window.webworks.exec).toHaveBeenCalledWith(undefined, undefined, "blackberry.system.event", "add", {"eventName": "foo"});
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("it will not call webworks.exec for multiple callbacks", function () {
+            var callback = jasmine.createSpy(),
+                callback2 = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.add("blackberry.system.event", "foo", callback2);
+            expect(_window.webworks.exec).toHaveBeenCalledWith(undefined, undefined, "blackberry.system.event", "add", {"eventName": "foo"});
+            expect(_window.webworks.exec.callCount).toEqual(1);
+            event.remove("blackberry.system.event", "foo", callback);
+            event.remove("blackberry.system.event", "foo", callback2);
+        });
+
+        it("will not register duplicate callbacks if it is the only registered callback for the event", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.add("blackberry.system.event", "foo", callback);
+            event.trigger("foo", '[{"id": 1}]');
+            expect(callback).toHaveBeenCalledWith({"id": 1});
+            expect(callback.callCount).toEqual(1);
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("will not register duplicate callbacks if it is not the only registered callback for the event", function () {
+            var firstCallback = jasmine.createSpy(),
+                secondCallback = jasmine.createSpy(),
+                thirdCallback = jasmine.createSpy();
+
+            event.add("blackberry.system.event", "foo", firstCallback);
+            event.add("blackberry.system.event", "foo", secondCallback);
+            event.add("blackberry.system.event", "foo", thirdCallback);
+            event.add("blackberry.system.event", "foo", firstCallback);
+            event.trigger("foo", null);
+            expect(firstCallback.callCount).toEqual(1);
+            event.remove("blackberry.system.event", "foo", firstCallback);
+            event.remove("blackberry.system.event", "foo", secondCallback);
+            event.remove("blackberry.system.event", "foo", thirdCallback);
+        });
+
+        it("will register two distinct callbacks", function () {
+            var callback = jasmine.createSpy(),
+                callback2 = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.add("blackberry.system.event", "foo", callback2);
+            event.trigger("foo", '[{"id": 1}]');
+            expect(callback).toHaveBeenCalledWith({"id": 1});
+            expect(callback2).toHaveBeenCalledWith({"id": 1});
+            event.remove("blackberry.system.event", "foo", callback);
+            event.remove("blackberry.system.event", "foo", callback2);
+        });
+    });
+
+    describe("once", function () {
+        it("will call webworks.exec action 'once' given valid featureId, eventName and callback", function () {
+            var callback = function () {};
+            event.once("blackberry.system.event", "foo", callback);
+            expect(_window.webworks.exec).toHaveBeenCalledWith(undefined, undefined, "event", "once", {"eventName": "foo"});
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+    });
+
+    describe("remove", function () {
+        it("can call webworks.exec action 'remove' given valid featureId, eventName and callback", function () {
+            var cb = jasmine.createSpy();
+            event.add("blackberry.system.event", "a", cb);
+            event.remove("blackberry.system.event", "a", cb);
+            expect(_window.webworks.exec).toHaveBeenCalledWith(undefined, undefined, "blackberry.system.event", "remove", {"eventName": "a"});
+        });
+    });
+
+    describe("trigger", function () {
+        it("will invoke callback if event has been added", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.trigger("foo", '[{"id": 1}]');
+            expect(callback).toHaveBeenCalledWith({"id": 1});
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("will invoke callback if no args are provided", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.event", "pause", callback);
+            event.trigger("pause");
+            expect(callback).toHaveBeenCalled();
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("will invoke callback with multiple args", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.event", "pause", callback);
+            event.trigger("pause", "[1,2,3,4,5]");
+            expect(callback).toHaveBeenCalledWith(1, 2, 3, 4, 5);
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("will not invoke callback if event has been removed", function () {
+            var cb = jasmine.createSpy();
+            event.add("blackberry.system.event", "c", cb);
+            event.remove("blackberry.system.event", "c", cb);
+            event.trigger("c", {"id": 1});
+            expect(cb).not.toHaveBeenCalled();
+        });
+
+        it("will remove once listeners after they are triggered", function () {
+            var callback = jasmine.createSpy();
+            event.once("blackberry.system.event", "foo", callback);
+            event.trigger("foo", '[{"id": 1}]');
+            event.trigger("foo", '[{"id": 1}]');
+            expect(callback).toHaveBeenCalledWith({"id": 1});
+            expect(callback.callCount).toEqual(1);
+        });
+
+        it("will not remove on listeners after they are triggered", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.trigger("foo", '[{"id": 1}]');
+            event.trigger("foo", '[{"id": 1}]');
+            expect(callback).toHaveBeenCalledWith({"id": 1});
+            expect(callback.callCount).toEqual(2);
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+    });
+
+    describe("isOn", function () {
+        it("returns false with no listeners", function () {
+            expect(event.isOn("foo")).toEqual(false);
+        });
+
+        it("returns true with listeners", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            expect(event.isOn("foo")).toEqual(true);
+            event.remove("blackberry.system.event", "foo", callback);
+        });
+
+        it("Updates properly once listeners are removed", function () {
+            var callback = jasmine.createSpy();
+            event.add("blackberry.system.event", "foo", callback);
+            event.remove("blackberry.system.event", "foo", callback);
+            expect(event.isOn("foo")).toEqual(false);
+        });
+    });
+});


[03/32] js commit: [BlackBerry10] Split out to new top-level platform

Posted by lo...@apache.org.
[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/future
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" };
+    }
+};


[02/32] [BlackBerry10] Split out to new top-level platform

Posted by lo...@apache.org.
http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/file.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/file.js b/lib/blackberry10/plugin/blackberry10/file.js
new file mode 100644
index 0000000..d611daf
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/file.js
@@ -0,0 +1,424 @@
+/*
+ *
+ * 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/blackberry10/plugin/blackberry10/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/fileTransfer.js b/lib/blackberry10/plugin/blackberry10/fileTransfer.js
new file mode 100644
index 0000000..6848516
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/fileTransfer.js
@@ -0,0 +1,205 @@
+/*
+ *
+ * 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/blackberry10/plugin/blackberry10/logger.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/logger.js b/lib/blackberry10/plugin/blackberry10/logger.js
new file mode 100644
index 0000000..bd47a1e
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/logger.js
@@ -0,0 +1,30 @@
+/*
+ *
+ * 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 = {
+    log: function (args, win, fail) {
+        console.log(args);
+        return {"status" : cordova.callbackStatus.OK,
+                "message" : 'Message logged to console: ' + args};
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/magnetometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/magnetometer.js b/lib/blackberry10/plugin/blackberry10/magnetometer.js
new file mode 100644
index 0000000..72aa90e
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/magnetometer.js
@@ -0,0 +1,45 @@
+/*
+ *
+ * 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/blackberry10/plugin/blackberry10/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/manager.js b/lib/blackberry10/plugin/blackberry10/manager.js
new file mode 100644
index 0000000..8307c74
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/manager.js
@@ -0,0 +1,60 @@
+/*
+ *
+ * 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/blackberry10/network'),
+        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
+        'Device' : require('cordova/plugin/blackberry10/device'),
+        'Battery' : require('cordova/plugin/blackberry10/battery'),
+        'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
+        'Camera' : require('cordova/plugin/blackberry10/camera'),
+        'Capture' : require('cordova/plugin/blackberry10/capture'),
+        'Logger' : require('cordova/plugin/blackberry10/logger'),
+        'Notification' : require('cordova/plugin/blackberry10/notification'),
+        'Media': require('cordova/plugin/blackberry10/media'),
+        'File' : require('cordova/plugin/blackberry10/file'),
+        'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
+        'FileTransfer': require('cordova/plugin/blackberry10/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/blackberry10/plugin/blackberry10/media.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/media.js b/lib/blackberry10/plugin/blackberry10/media.js
new file mode 100644
index 0000000..a141a99
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/media.js
@@ -0,0 +1,189 @@
+/*
+ *
+ * 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'),
+    audioObjects = {};
+
+module.exports = {
+    create: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            src = args[1];
+
+        if (typeof src == "undefined"){
+            audioObjects[id] = new Audio();
+        } else {
+            audioObjects[id] = new Audio(src);
+        }
+
+        return {"status" : 1, "message" : "Audio object created" };
+    },
+    startPlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (args.length === 1 || typeof args[1] == "undefined" ) {
+            return {"status" : 9, "message" : "Media source argument not found"};
+        }
+
+        if (audio) {
+            audio.pause();
+            audioObjects[id] = undefined;
+        }
+
+        audio = audioObjects[id] = new Audio(args[1]);
+        audio.play();
+        return {"status" : 1, "message" : "Audio play started" };
+    },
+    stopPlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        audio.pause();
+        audioObjects[id] = undefined;
+
+        return {"status" : 1, "message" : "Audio play stopped" };
+    },
+    seekToAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            result = {"status" : 2, "message" : "Audio Object has not been initialized"};
+        } else if (args.length === 1) {
+            result = {"status" : 9, "message" : "Media seek time argument not found"};
+        } else {
+            try {
+                audio.currentTime = args[1];
+            } catch (e) {
+                console.log('Error seeking audio: ' + e);
+                return {"status" : 3, "message" : "Error seeking audio: " + e};
+            }
+
+            result = {"status" : 1, "message" : "Seek to audio succeeded" };
+        }
+        return result;
+    },
+    pausePlayingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        audio.pause();
+
+        return {"status" : 1, "message" : "Audio paused" };
+    },
+    getCurrentPositionAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        return {"status" : 1, "message" : audio.currentTime };
+    },
+    getDuration: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (!audio) {
+            return {"status" : 2, "message" : "Audio Object has not been initialized"};
+        }
+
+        return {"status" : 1, "message" : audio.duration };
+    },
+    startRecordingAudio: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        if (args.length <= 1) {
+            return {"status" : 9, "message" : "Media start recording, insufficient arguments"};
+        }
+
+        blackberry.media.microphone.record(args[1], win, fail);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+    },
+    stopRecordingAudio: function (args, win, fail) {
+    },
+    release: function (args, win, fail) {
+        if (!args.length) {
+            return {"status" : 9, "message" : "Media Object id was not sent in arguments"};
+        }
+
+        var id = args[0],
+            audio = audioObjects[id],
+            result;
+
+        if (audio) {
+            if(audio.src !== ""){
+                audio.src = undefined;
+            }
+            audioObjects[id] = undefined;
+            //delete audio;
+        }
+
+        result = {"status" : 1, "message" : "Media resources released"};
+
+        return result;
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/blackberry10/plugin/blackberry10/network.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/network.js b/lib/blackberry10/plugin/blackberry10/network.js
new file mode 100644
index 0000000..b640f75
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/network.js
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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/blackberry10/plugin/blackberry10/notification.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/notification.js b/lib/blackberry10/plugin/blackberry10/notification.js
new file mode 100644
index 0000000..9de87b8
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/notification.js
@@ -0,0 +1,52 @@
+/*
+ *
+ * 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 = {
+    alert: function (args, win, fail) {
+        if (args.length !== 3) {
+            return {"status" : 9, "message" : "Notification action - alert arguments not found"};
+        }
+
+        //Unpack and map the args
+        var msg = args[0],
+            title = args[1],
+            btnLabel = args[2];
+
+        blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title" : title } ]);
+        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+    },
+    confirm: function (args, win, fail) {
+        if (args.length !== 3) {
+            return {"status" : 9, "message" : "Notification action - confirm arguments not found"};
+        }
+
+        //Unpack and map the args
+        var msg = args[0],
+            title = args[1],
+            btnLabel = args[2],
+            btnLabels = btnLabel.split(",");
+
+        blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title" : title} ]);
+        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/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
new file mode 100644
index 0000000..871f2d1
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -0,0 +1,44 @@
+/*
+ *
+ * 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: "blackberry10",
+    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/scripts/bootstrap-blackberry.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry.js b/lib/scripts/bootstrap-blackberry.js
index 8dbf65e..8f3c0bc 100644
--- a/lib/scripts/bootstrap-blackberry.js
+++ b/lib/scripts/bootstrap-blackberry.js
@@ -20,25 +20,7 @@
 */
 
 document.addEventListener("DOMContentLoaded", function () {
-    switch(require('cordova/platform').runtime()) {
-    case 'qnx':
-        var wwjs = document.createElement("script");
-        wwjs.src = "local:///chrome/webworks.js";
-        wwjs.onload = function () {
-            document.addEventListener("webworksready", function () {
-                require('cordova/channel').onNativeReady.fire();
-            });
-        };
-        wwjs.onerror = function () {
-            console.error('there was a problem loading webworks.js');
-        };
-        document.head.appendChild(wwjs);
-        break;
-    case 'air':
+    if (require('cordova/platform').runtime() === 'air') {
         require('cordova/channel').onNativeReady.fire();
-        break;
-    case 'java':
-        //nothing to do for java
-        break;
     }
 });

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
new file mode 100644
index 0000000..65115fd
--- /dev/null
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -0,0 +1,34 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+document.addEventListener("DOMContentLoaded", function () {
+    var wwjs = document.createElement("script");
+    wwjs.src = "local:///chrome/webworks.js";
+    wwjs.onload = function () {
+        document.addEventListener("webworksready", function () {
+            require('cordova/channel').onNativeReady.fire();
+        });
+    };
+    wwjs.onerror = function () {
+        alert('there was a problem loading webworks.js');
+    };
+    document.head.appendChild(wwjs);
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.battery.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.battery.js b/test/blackberry/qnx/test.battery.js
deleted file mode 100644
index c66c0ef..0000000
--- a/test/blackberry/qnx/test.battery.js
+++ /dev/null
@@ -1,72 +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.
- *
-*/
-
-describe("blackberry qnx battery", function () {
-    var battery = require('cordova/plugin/qnx/battery'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-        spyOn(window, "setInterval").andReturn(1);
-        spyOn(window, "clearInterval");
-    });
-
-    it("returns no_result when calling start", function () {
-        expect(battery.start()).toEqual({
-            status: cordova.callbackStatus.NO_RESULT,
-            message: "WebWorks Is On It"
-        });
-    });
-
-    it("sets an interval for 500 ms when calling start", function () {
-        battery.start();
-        expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 500);
-    });
-
-    it("calls the win callback with values from navigator.webkitBattery", function () {
-        global.navigator = window.navigator;
-        window.navigator.webkitBattery = { level: 0.12, charging: true };
-
-        var win = jasmine.createSpy("win");
-        battery.start({}, win);
-
-        window.setInterval.mostRecentCall.args[0]();
-
-        expect(win).toHaveBeenCalledWith({
-            level: 12,
-            isPlugged: true
-        });
-
-        delete window.navigator.webkitBattery;
-    });
-
-    it("returns ok when calling stop", function () {
-        expect(battery.stop()).toEqual({
-            status: cordova.callbackStatus.OK,
-            message: "stopped"
-        });
-    });
-
-    it("calls clearInterval when stopping", function () {
-        battery.start();
-        battery.stop();
-        expect(window.clearInterval).toHaveBeenCalledWith(1);
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.camera.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.camera.js b/test/blackberry/qnx/test.camera.js
deleted file mode 100644
index 1cedd6c..0000000
--- a/test/blackberry/qnx/test.camera.js
+++ /dev/null
@@ -1,59 +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.
- *
-*/
-
-describe("blackberry qnx camera", function () {
-    var camera = require('cordova/plugin/qnx/camera'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-        global.blackberry = {
-            invoke: {
-                card: {
-                    invokeCamera: jasmine.createSpy("invokeCamera")
-                }
-            }
-        };
-    });
-
-    afterEach(function () {
-        delete global.blackberry;
-    });
-    
-    it("returns no_result when calling takePicture", function () {
-        expect(camera.takePicture()).toEqual({
-            status: cordova.callbackStatus.NO_RESULT,
-            message: "WebWorks Is On It"
-        });
-    });
-
-    it("calls blackberry.invoke.card.invokeCamera", function () {
-        camera.takePicture();
-        expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith("photo", jasmine.any(Function), jasmine.any(Function), jasmine.any(Function));
-    });
-
-    it("adds file:// to the path provided to the callback and calls success", function () {
-        var win = jasmine.createSpy("win");
-        camera.takePicture({}, win);
-
-        blackberry.invoke.card.invokeCamera.mostRecentCall.args[1]("pics/ponies.jpg");
-        expect(win).toHaveBeenCalledWith("file://pics/ponies.jpg");
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.capture.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.capture.js b/test/blackberry/qnx/test.capture.js
deleted file mode 100644
index 2c73f91..0000000
--- a/test/blackberry/qnx/test.capture.js
+++ /dev/null
@@ -1,222 +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.
- *
-*/
-
-describe("blackberry qnx capture", function () {
-    var capture = require('cordova/plugin/qnx/capture'),
-        cordova = require('cordova');
-
-    describe("getSupportedAudioModes", function(){
-        it('should return Ok', function(){
-            expect(capture.getSupportedAudioModes()).toEqual({
-                status: cordova.callbackStatus.OK,
-                message: []
-            });
-        });
-    });
-
-    describe("getSupportedImageModes", function(){
-        it('should return Ok', function(){
-            expect(capture.getSupportedImageModes()).toEqual({
-                status: cordova.callbackStatus.OK,
-                message: []
-            });
-        });
-    });
-
-    describe("getSupportedVideoModes", function(){
-        it('should return Ok', function(){
-            expect(capture.getSupportedVideoModes()).toEqual({
-                status: cordova.callbackStatus.OK,
-                message: []
-            });
-        });
-    });
-
-    function testCapture(method, action) {
-        describe(method, function(){
-            beforeEach(function () {
-                global.blackberry = {
-                    invoke: {
-                        card: {
-                            invokeCamera: jasmine.createSpy('blackberry.invoke.card.invokeCamera')
-                        }
-                    }
-                };
-            });
-
-            afterEach(function () {
-                delete global.blackberry;
-            });
-
-            it('should return No Result', function(){
-                var args = [{limit: 0}],
-                    win = jasmine.createSpy('win'),
-                    fail = jasmine.createSpy('fail');
-
-                expect(capture[method](args, win, fail)).toEqual({
-                    status: cordova.callbackStatus.NO_RESULT,
-                    message: "WebWorks Is On It"
-                });
-            });
-
-            describe("when the limit is 0 or less", function () {
-                it('calls the win callback with an empty array', function(){
-                    var args = [{ limit: -9 }],
-                        win = jasmine.createSpy('win'),
-                        fail = jasmine.createSpy('fail');
-
-                    capture[method](args, win, fail);
-                    expect(win).toHaveBeenCalled();
-                });
-            });
-
-            describe("when the limit is greater than 0", function () {
-                var win, fail;
-
-                beforeEach(function () {
-                    win = jasmine.createSpy("win");
-                    fail = jasmine.createSpy("fail");
-                });
-
-                it("calls the invokeCamera method", function () {
-                    capture[method]([{limit: 1}], win, fail);
-                    expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith(action, 
-                                                                                     jasmine.any(Function),
-                                                                                     jasmine.any(Function),
-                                                                                     jasmine.any(Function));
-                });
-
-                describe("inside the invokeCamera callback", function () {
-                    var onsave;
-
-                    beforeEach(function () {
-                        window.webkitRequestFileSystem = jasmine.createSpy("window.webkitRequestFileSystem");
-                        global.blackberry.io = { sandbox: true };
-
-                        capture[method]([{limit: 1}], win, fail);
-                        onsave = blackberry.invoke.card.invokeCamera.mostRecentCall.args[1];
-                    });
-
-                    afterEach(function () {
-                        delete window.webkitRequestFileSystem;
-                    });
-
-                    it("sets the sandbox to false", function () {
-                        onsave();
-                        expect(blackberry.io.sandbox).toBe(false);
-                    });
-
-                    it("calls webkitRequestFileSystem", function () {
-                        onsave();
-                        expect(window.webkitRequestFileSystem).toHaveBeenCalledWith(
-                            window.PERSISTENT, 
-                            1024, 
-                            jasmine.any(Function), 
-                            fail);
-                    });
-
-                    describe("in the webkitRequestFileSystem callback", function () {
-                        var callback,
-                            fs = { root: { getFile: jasmine.createSpy("getFile") } };
-
-                        beforeEach(function () {
-                            onsave('/foo/bar/baz.gif');
-                            callback = window.webkitRequestFileSystem.mostRecentCall.args[2];
-                        });
-
-                        it("calls getfile on the provided filesystem", function () {
-                            callback(fs);
-                            expect(fs.root.getFile).toHaveBeenCalledWith('/foo/bar/baz.gif', 
-                                                                         {},
-                                                                         jasmine.any(Function), 
-                                                                         fail);
-                        });
-
-                        it("calls the file method of the fileEntity", function () {
-                            var fe = { file: jasmine.createSpy('file') };
-                            callback(fs);
-                            fs.root.getFile.mostRecentCall.args[2](fe);
-                            expect(fe.file).toHaveBeenCalledWith(jasmine.any(Function), fail);
-                        });
-
-                        describe("in the file callback", function () {
-                            var fe = { 
-                                    file: jasmine.createSpy('file'),
-                                    fullPath: 'file://this/is/the/full/path/eh.png'
-                                },
-                                fileCB;
-
-                            beforeEach(function () {
-                                callback(fs);
-                                fs.root.getFile.mostRecentCall.args[2](fe);
-                                fileCB = fe.file.mostRecentCall.args[0];
-                            });
-
-                            it("sets the fullPath of the file object", function () {
-                                var file = {};
-                                fileCB(file);
-                                expect(file.fullPath).toBe(fe.fullPath);
-                            });
-
-                            it("calls the win callback with an array containing the file", function () {
-                                var file = {};
-                                fileCB(file);
-                                expect(win).toHaveBeenCalledWith([file]);
-                            });
-
-                            it("resets the value of blackberry.io.sandbox", function () {
-                                var file = {};
-                                fileCB(file);
-                                expect(blackberry.io.sandbox).toBe(true);
-                            });
-                        });
-                    });
-                });
-            });
-        });
-    }
-
-    testCapture('captureImage', 'photo');
-    testCapture('captureVideo', 'video');
-
-    describe("captureAudio", function(){
-        it('should call the fail callback', function(){
-            var args = {},
-                win = jasmine.createSpy('win'),
-                fail = jasmine.createSpy('fail');
-
-            capture.captureAudio(args, win, fail);
-            expect(fail).toHaveBeenCalled();
-            expect(win).not.toHaveBeenCalled();
-        });
-
-        it('should return no result', function(){
-            var args = "arguments",
-                win = jasmine.createSpy('win'),
-                fail = jasmine.createSpy('fail');
-
-            expect(capture.captureAudio(args, win, fail)).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "WebWorks Is On It"
-            });
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.compass.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.compass.js b/test/blackberry/qnx/test.compass.js
deleted file mode 100644
index 870a0a4..0000000
--- a/test/blackberry/qnx/test.compass.js
+++ /dev/null
@@ -1,61 +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.
- *
-*/
-
-xdescribe("blackberry qnx compass", function () {
-    var compass = require('cordova/plugin/qnx/compass'),
-        cordova = require('cordova'),
-        exec = require('cordova/exec'),
-        utils = require('cordova/utils'),
-        CompassHeading = require('cordova/plugin/CompassHeading'),
-        CompassError = require('cordova/plugin/CompassError'),
-        win = jasmine.createSpy('win'),
-        fail = jasmine.createSpy('fail');
-
-    beforeEach(function () {
-        window.start = jasmine.createSpy('start');
-        window.stop = jasmine.createSpy('stop');
-        window.removeListeners = jasmine.createSpy('removeListeners');
-        global.listeners = [];
-
-    });
-
-    afterEach(function () {
-
-    });
-
-
-    describe("watchHeading", function(){
-        it('should return that successCallback is not a function', function(){
-            expect(compass.getCurrentHeading).toThrow("getCurrentHeading must be called with at least a success callback function as first parameter.");
-        });
-
-        it('should see that start() was called', function(){
-            compass.getCurrentHeading(win, fail);
-            expect(listeners).toHaveBeenCalled();
-        });
-
-    });
-
-    describe("clearWatch", function(){
-
-
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.device.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.device.js b/test/blackberry/qnx/test.device.js
deleted file mode 100644
index 58c1c8d..0000000
--- a/test/blackberry/qnx/test.device.js
+++ /dev/null
@@ -1,48 +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.
- *
-*/
-
-describe("blackberry qnx device", function () {
-    var device = require('cordova/plugin/qnx/device');
-    
-    it("calls the win callback with the device info", function () {
-        global.blackberry = {
-            system: {
-                softwareVersion: "NaN"
-            },
-            identity: {
-                uuid: 1
-            }
-        };
-
-        var info;
-
-        //HACK: I know this is a sync call ;)
-        device.getDeviceInfo({}, function (i) { info = i; });
-
-        expect(info.platform).toBe("BlackBerry");
-        expect(info.version).toBe("NaN");
-        expect(info.name).toBe("Dev Alpha");
-        expect(info.uuid).toBe(1);
-        expect(info.cordova).toBeDefined();
-        
-        delete global.blackberry;
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.fileTransfer.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.fileTransfer.js b/test/blackberry/qnx/test.fileTransfer.js
deleted file mode 100644
index 43baedc..0000000
--- a/test/blackberry/qnx/test.fileTransfer.js
+++ /dev/null
@@ -1,85 +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.
- *
-*/
-
-describe("blackberry qnx fileTransfer", function () {
-    var fileTransfer = require('cordova/plugin/qnx/fileTransfer');
-    var cordova = require('cordova'),
-        win = jasmine.createSpy('win'),
-        fail = jasmine.createSpy('fail')
-        xhrSend = jasmine.createSpy('xhr send');
-        xhrOpen = jasmine.createSpy('xhr open');
-
-    beforeEach(function () {
-        global.blackberry = {
-            io:{
-                filetransfer: {
-                    download: jasmine.createSpy('download'),
-                    upload: jasmine.createSpy('upload')
-                }
-            }
-        };
-        XMLHttpRequest = function () {
-            var xhr = {
-                send: xhrSend,
-                open: xhrOpen
-            };
-            return xhr;
-        };
-        window.webkitResolveLocalFileSystemURL = jasmine.createSpy("resolveFS")
-    });
-
-    afterEach(function () {
-        delete global.blackberry;
-        delete XMLHttpRequest;
-        delete webkitResolveLocalFileSystemURL;
-        delete window.webkitResolveLocalFileSystemURL;
-    });
-
-    describe("download", function(){
-        it('should call the blackberry download', function () {
-            fileTransfer.download(["source/file", "target/file"], win, fail);
-            expect(xhrOpen).toHaveBeenCalled();
-            expect(xhrSend).toHaveBeenCalled();
-        });
-
-        it('should return No Result', function(){
-            expect(fileTransfer.download(["location/source", "location/place/here"], win, fail)).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "async"
-            });
-        });
-    });
-
-    describe('upload', function(){
-        it('should call the blackberry upload', function(){
-            fileTransfer.upload(["source", "target", "fileKey", "fileName", "mimeType", "params", "chunkedMode"], win, fail);
-            expect(xhrOpen).toHaveBeenCalled();
-            expect(xhrSend).toHaveBeenCalled();
-        });
-
-        it('should return No Result', function(){
-            expect(fileTransfer.upload(["location/source", "location/place/here"], win, fail)).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "async"
-            });
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.magnetometer.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.magnetometer.js b/test/blackberry/qnx/test.magnetometer.js
deleted file mode 100644
index 2f8e583..0000000
--- a/test/blackberry/qnx/test.magnetometer.js
+++ /dev/null
@@ -1,80 +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.
- *
-*/
-
-describe("blackberry qnx magnetometer", function () {
-    var magnetometer = require('cordova/plugin/qnx/magnetometer'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-        spyOn(window, "removeEventListener");
-        spyOn(window, "addEventListener");
-    });
-
-    describe("start", function(){
-        it('should return no result', function(){
-            expect(magnetometer.start()).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "WebWorks Is On It"
-            });
-        });
-
-        it('should remove the event listener', function(){
-            magnetometer.start();
-            expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
-        });
-
-        it('should add an event listener', function(){
-            magnetometer.start();
-            expect(window.addEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
-        });
-
-        it('call the win callback with the data from the event', function(){
-            var win = jasmine.createSpy('win');
-            magnetometer.start({}, win);
-
-            window.addEventListener.mostRecentCall.args[1]({
-                alpha: 60,
-                timeStamp: "bout that time, eh chap?"
-            });
-
-            expect(win).toHaveBeenCalledWith({
-                magneticHeading: 300,
-                trueHeading: 300,
-                headingAccuracy: 0,
-                timestamp: "bout that time, eh chap?"
-            });
-        });
-    });
-
-    describe('stop', function(){
-        it('should return OK', function(){
-            expect(magnetometer.stop()).toEqual({
-                status: cordova.callbackStatus.OK,
-                message: "removed"
-            });
-        });
-
-        it('should remove the event listener', function(){
-            magnetometer.stop();
-            expect(window.removeEventListener).toHaveBeenCalledWith("deviceorientation", jasmine.any(Function));
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.manager.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.manager.js b/test/blackberry/qnx/test.manager.js
deleted file mode 100644
index 5e5571a..0000000
--- a/test/blackberry/qnx/test.manager.js
+++ /dev/null
@@ -1,56 +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.
- *
-*/
-
-describe("blackberry qnx manager", function () {
-    var manager = require('cordova/plugin/qnx/manager');
-
-    it("calls the plugin", function () {
-        var device = require('cordova/plugin/qnx/device'),
-            win = jasmine.createSpy('win'),
-            fail = jasmine.createSpy('fail'),
-            args = {};
-
-        spyOn(device, "getDeviceInfo");
-
-        manager.exec(win, fail, "Device", "getDeviceInfo", args);
-        expect(device.getDeviceInfo).toHaveBeenCalledWith(args, win, fail);
-    });
-
-    it("returns the result of the plugin", function () {
-        var camera = require('cordova/plugin/qnx/camera');
-        spyOn(camera, "takePicture").andReturn("duckface");
-        expect(manager.exec(null, null, "Camera", "takePicture")).toBe("duckface");
-    });
-
-    it("returns class not found when no plugin", function () {
-        expect(manager.exec(null, null, "Ruby", "method_missing")).toEqual({
-           status: cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION,
-           message: "Class Ruby cannot be found"
-        });
-    });
-
-    it("returns invalid action when no action", function () {
-        expect(manager.exec(null, null, "Camera", "makePonies")).toEqual({
-            status: cordova.callbackStatus.INVALID_ACTION,
-            message: "Action not found: makePonies"
-        });
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.network.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.network.js b/test/blackberry/qnx/test.network.js
deleted file mode 100644
index 63a224b..0000000
--- a/test/blackberry/qnx/test.network.js
+++ /dev/null
@@ -1,39 +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.
- *
-*/
-
-describe("blackberry qnx network", function () {
-    var cordova = require('cordova'),
-        network = require('cordova/plugin/qnx/network');
-
-    it("returns the connection info", function () {
-        global.blackberry = {
-            connection: {
-                type: "pigeon"
-            }
-        };
-        expect(network.getConnectionInfo()).toEqual({
-            status: cordova.callbackStatus.OK,
-            message: "pigeon"
-        });
-
-        delete global.blackberry;
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/qnx/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/qnx/test.platform.js b/test/blackberry/qnx/test.platform.js
deleted file mode 100644
index 231c5ca..0000000
--- a/test/blackberry/qnx/test.platform.js
+++ /dev/null
@@ -1,123 +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.
- *
-*/
-
-describe("blackberry qnx platform", function () {
-    var platform = require('cordova/plugin/qnx/platform'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-
-        global.blackberry = {
-            event:{
-                addEventListener: jasmine.createSpy('addEventListener')
-            }
-        }
-
-        spyOn(cordova, "fireDocumentEvent");
-
-        spyOn(document, "addEventListener").andCallFake(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");
-            });
-        });
-        
-        spyOn(window, "addEventListener").andCallFake(function(){
-            cordova.fireDocumentEvent("online");
-            cordova.fireDocumentEvent("offline");
-        });
-    });
-
-    afterEach(function(){
-        delete global.blackberry;
-    });
-
-    describe("exports", function(){
-        it('should have the qnx id', function(){
-            expect(platform.id).toBe("qnx");
-        });
-    });
-
-    describe("initialize", function(){
-        it('should add an event listener to document', function(){
-            platform.initialize();
-            expect(document.addEventListener).toHaveBeenCalledWith("deviceready", jasmine.any(Function));
-        });
-        it('should check if blackberry event addEventListener was called for pause', function(){
-            platform.initialize();
-            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("pause", jasmine.any(Function));
-        });
-        it('should check if blackberry event addEventListener was called for resume', function(){
-            platform.initialize();     
-            expect(blackberry.event.addEventListener).toHaveBeenCalledWith("resume", jasmine.any(Function));
-        });
-        it('should check if window.addEventListener was called for online', function(){
-            platform.initialize();
-            expect(window.addEventListener).toHaveBeenCalledWith("online", jasmine.any(Function));
-            
-        });
-        it('should check if window.addEventListener was called for offline', function(){
-            platform.initialize();
-            expect(window.addEventListener).toHaveBeenCalledWith("offline", jasmine.any(Function));
-        });
-
-        it('should call cordova.fireDocumentEvent online', function(){
-            platform.initialize();
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("online");
-        });
-        it('should call cordova.fireDocumentEvent offline', function(){
-            platform.initialize();
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("offline");
-        });
-        it('should call cordova.fireDocumentEvent pause', function(){
-            delete global.blackberry;
-            global.blackberry = { event: { addEventListener: function(){ } } };
-            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
-                cordova.fireDocumentEvent("pause");
-            });
-
-            platform.initialize();
-            
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("pause");
-        });
-        it('should call cordova.fireDocumentEvent resume', function(){
-            delete global.blackberry;
-            global.blackberry = { event: { addEventListener: function(){ } } };
-            spyOn(blackberry.event, "addEventListener").andCallFake(function(){
-                cordova.fireDocumentEvent("resume");
-            });
-
-            platform.initialize();
-            
-            expect(cordova.fireDocumentEvent).toHaveBeenCalledWith("resume");
-        });
-
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/test.exec.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.exec.js b/test/blackberry/test.exec.js
index 755b067..1becbe0 100644
--- a/test/blackberry/test.exec.js
+++ b/test/blackberry/test.exec.js
@@ -25,12 +25,12 @@ describe("blackberry exec", function () {
 
     it("calls the managers exec for the given runtime", function () {
         var platform = require('cordova/platform'),
-            manager = require('cordova/plugin/qnx/manager'),
+            manager = require('cordova/plugin/air/manager'),
             win = jasmine.createSpy("win"),
             fail = jasmine.createSpy("fail"),
             args = {};
 
-        spyOn(platform, "runtime").andReturn("qnx");
+        spyOn(platform, "runtime").andReturn("air");
         spyOn(manager, "exec");
 
         exec(win, fail, "foo", "bar", args);
@@ -40,10 +40,10 @@ describe("blackberry exec", function () {
 
     describe("when the callback status is ok", function () {
         var platform = require('cordova/platform'),
-            manager = require('cordova/plugin/qnx/manager');
+            manager = require('cordova/plugin/air/manager');
 
         beforeEach(function () {
-            spyOn(platform, "runtime").andReturn("qnx");
+            spyOn(platform, "runtime").andReturn("air");
             spyOn(manager, "exec").andReturn({
                 status: cordova.callbackStatus.OK,
                 message: "sometimes I drink from the milk carton"
@@ -85,10 +85,10 @@ describe("blackberry exec", function () {
 
     describe("when the callback status is no_result", function () {
         var platform = require('cordova/platform'),
-            manager = require('cordova/plugin/qnx/manager');
+            manager = require('cordova/plugin/air/manager');
 
         beforeEach(function () {
-            spyOn(platform, "runtime").andReturn("qnx");
+            spyOn(platform, "runtime").andReturn("air");
             spyOn(manager, "exec").andReturn({
                 status: cordova.callbackStatus.NO_RESULT,
                 message: "I know what you did last summer"
@@ -114,11 +114,11 @@ describe("blackberry exec", function () {
 
     describe("when the callback status is anything else", function () {
         var platform = require('cordova/platform'),
-            manager = require('cordova/plugin/qnx/manager');
+            manager = require('cordova/plugin/air/manager');
 
         beforeEach(function () {
             spyOn(console, "log");
-            spyOn(platform, "runtime").andReturn("qnx");
+            spyOn(platform, "runtime").andReturn("air");
             spyOn(manager, "exec").andReturn({
                 status: "poop",
                 message: "the bed"

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry/test.platform.js
----------------------------------------------------------------------
diff --git a/test/blackberry/test.platform.js b/test/blackberry/test.platform.js
index 8e2a9d0..067d436 100644
--- a/test/blackberry/test.platform.js
+++ b/test/blackberry/test.platform.js
@@ -33,14 +33,15 @@ describe("blackberry platform", function () {
         modulereplacer.replace('cordova/platform', platform);
     });
 
-    describe("when getting the runtime", function () {
-        it("returns qnx for the bb10 user agent", function () {
-            navigator.__defineGetter__("userAgent", function () {
-               return "Mozilla/5.0 (BB10; Touch) AppleWebKit/537.1+ (KHTML, like Gecko) Version/10.0.0.1337 Mobile Safari/537.1+";
-            });
-            expect(platform.runtime()).toBe("qnx");
-        });
+    beforeEach(function () {
+        GLOBAL.navigator = {};
+    });
 
+    afterEach(function () {
+        delete GLOBAL.navigator;
+    });
+
+    describe("when getting the runtime", function () {
         it("returns air for the playbook user agent", function () {
             navigator.__defineGetter__("userAgent", function () {
                return "Mozilla/5.0 (PlayBook; U; RIM Tablet OS 2.1.0; en-US) AppleWebKit/536.2+ (KHTML, like Gecko) Version/7.2.1.0 Safari/536.2+";
@@ -90,15 +91,5 @@ describe("blackberry platform", function () {
             expect(platform.contextObj.navigator.app).not.toBeUndefined();
         });
 
-        it("builds qnx objects into window", function () {
-            var qnx = require('cordova/plugin/qnx/platform');
-
-            spyOn(qnx, "initialize");
-            spyOn(platform, "runtime").andReturn("qnx");
-            platform.initialize();
-
-            expect(platform.contextObj.open).not.toBeUndefined();
-            expect(platform.contextObj.navigator.compass).not.toBeUndefined();
-        });
     });
 });

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/615aea47/test/blackberry10/test.battery.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.battery.js b/test/blackberry10/test.battery.js
new file mode 100644
index 0000000..4e8b0b0
--- /dev/null
+++ b/test/blackberry10/test.battery.js
@@ -0,0 +1,72 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe("blackberry10 battery", function () {
+    var battery = require('cordova/plugin/blackberry10/battery'),
+        cordova = require('cordova');
+
+    beforeEach(function () {
+        spyOn(window, "setInterval").andReturn(1);
+        spyOn(window, "clearInterval");
+    });
+
+    it("returns no_result when calling start", function () {
+        expect(battery.start()).toEqual({
+            status: cordova.callbackStatus.NO_RESULT,
+            message: "WebWorks Is On It"
+        });
+    });
+
+    it("sets an interval for 500 ms when calling start", function () {
+        battery.start();
+        expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 500);
+    });
+
+    it("calls the win callback with values from navigator.webkitBattery", function () {
+        global.navigator = window.navigator;
+        window.navigator.webkitBattery = { level: 0.12, charging: true };
+
+        var win = jasmine.createSpy("win");
+        battery.start({}, win);
+
+        window.setInterval.mostRecentCall.args[0]();
+
+        expect(win).toHaveBeenCalledWith({
+            level: 12,
+            isPlugged: true
+        });
+
+        delete window.navigator.webkitBattery;
+    });
+
+    it("returns ok when calling stop", function () {
+        expect(battery.stop()).toEqual({
+            status: cordova.callbackStatus.OK,
+            message: "stopped"
+        });
+    });
+
+    it("calls clearInterval when stopping", function () {
+        battery.start();
+        battery.stop();
+        expect(window.clearInterval).toHaveBeenCalledWith(1);
+    });
+});


[16/32] js commit: [BlackBerry10] Remove Camera plugin

Posted by lo...@apache.org.
[BlackBerry10] Remove Camera plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d21fed20
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d21fed20
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d21fed20

Branch: refs/heads/future
Commit: d21fed2047a49b9f39852bacfd60fabbca6c35fd
Parents: 8b8e7bb
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Apr 1 09:50:44 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                       |    3 -
 lib/blackberry10/plugin/blackberry10/camera.js |   32 ----------
 test/blackberry10/test.camera.js               |   59 -------------------
 3 files changed, 0 insertions(+), 94 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d21fed20/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index 5aa81c3..61f6c9b 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -23,13 +23,10 @@ var cordova = require('cordova'),
     plugins = {
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
-        'Camera' : require('cordova/plugin/blackberry10/camera'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
         'Logger' : require('cordova/plugin/blackberry10/logger'),
         'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
-        'File' : require('cordova/plugin/blackberry10/file'),
-        'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
     };
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d21fed20/lib/blackberry10/plugin/blackberry10/camera.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/camera.js b/lib/blackberry10/plugin/blackberry10/camera.js
deleted file mode 100644
index c357437..0000000
--- a/lib/blackberry10/plugin/blackberry10/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/d21fed20/test/blackberry10/test.camera.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.camera.js b/test/blackberry10/test.camera.js
deleted file mode 100644
index e08809f..0000000
--- a/test/blackberry10/test.camera.js
+++ /dev/null
@@ -1,59 +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.
- *
-*/
-
-describe("blackberry10 camera", function () {
-    var camera = require('cordova/plugin/blackberry10/camera'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-        global.blackberry = {
-            invoke: {
-                card: {
-                    invokeCamera: jasmine.createSpy("invokeCamera")
-                }
-            }
-        };
-    });
-
-    afterEach(function () {
-        delete global.blackberry;
-    });
-    
-    it("returns no_result when calling takePicture", function () {
-        expect(camera.takePicture()).toEqual({
-            status: cordova.callbackStatus.NO_RESULT,
-            message: "WebWorks Is On It"
-        });
-    });
-
-    it("calls blackberry.invoke.card.invokeCamera", function () {
-        camera.takePicture();
-        expect(blackberry.invoke.card.invokeCamera).toHaveBeenCalledWith("photo", jasmine.any(Function), jasmine.any(Function), jasmine.any(Function));
-    });
-
-    it("adds file:// to the path provided to the callback and calls success", function () {
-        var win = jasmine.createSpy("win");
-        camera.takePicture({}, win);
-
-        blackberry.invoke.card.invokeCamera.mostRecentCall.args[1]("pics/ponies.jpg");
-        expect(win).toHaveBeenCalledWith("file://pics/ponies.jpg");
-    });
-});


[08/32] js commit: [BlackBerry10] Use full path to plugins.json

Posted by lo...@apache.org.
[BlackBerry10] Use full path to plugins.json

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/2e12eda5
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/2e12eda5
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/2e12eda5

Branch: refs/heads/future
Commit: 2e12eda546031cbca35832b496086f5d71caf43a
Parents: 86c137f
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Mar 22 11:36:42 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 .../plugin/blackberry10/pluginUtils.js             |    2 +-
 test/blackberry10/test.pluginUtils.js              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2e12eda5/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
index 88f03c5..a07a665 100644
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -63,7 +63,7 @@ module.exports = {
         var request,
             response;
         request = new XMLHttpRequest();
-        request.open('GET', 'plugins/plugins.json', true);
+        request.open('GET', 'local:///plugins/plugins.json', true);
         request.onreadystatechange = function () {
             if (request.readyState === 4) {
                 if (request.status === 200) {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/2e12eda5/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
index 6b5a24a..441ebcc 100644
--- a/test/blackberry10/test.pluginUtils.js
+++ b/test/blackberry10/test.pluginUtils.js
@@ -119,7 +119,7 @@ describe('blackberry10 pluginUtils', function () {
 
         it('sends XHR for plugins.json', function () {
             pluginUtils.getPlugins(success, error);
-            expect(xhr.open).toHaveBeenCalledWith('GET', 'plugins/plugins.json', true);
+            expect(xhr.open).toHaveBeenCalledWith('GET', 'local:///plugins/plugins.json', true);
             expect(xhr.send).toHaveBeenCalled();
         });
 


[12/32] js commit: [BlackBerry10] Move all exec logic (along with window.webworks) into exec.js

Posted by lo...@apache.org.
[BlackBerry10] Move all exec logic (along with window.webworks) into exec.js

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/56c53149
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/56c53149
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/56c53149

Branch: refs/heads/future
Commit: 56c5314989ffcf8a0be058714e9a7af7e622d5f3
Parents: b5dc123
Author: Bryan Higgins <br...@bryanhiggins.net>
Authored: Wed Mar 27 14:28:17 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                        |   99 ++++++++++++++++--
 lib/blackberry10/plugin/blackberry10/manager.js |   54 ----------
 lib/scripts/bootstrap-blackberry10.js           |   83 ---------------
 3 files changed, 91 insertions(+), 145 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/56c53149/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index e84cd69..25ec0ae 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -20,8 +20,17 @@
 */
 
 var cordova = require('cordova'),
-    platform = require('cordova/platform'),
-    utils = require('cordova/utils');
+    plugins = {
+        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
+        'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
+        'Camera' : require('cordova/plugin/blackberry10/camera'),
+        'Capture' : require('cordova/plugin/blackberry10/capture'),
+        'Logger' : require('cordova/plugin/blackberry10/logger'),
+        'Notification' : require('cordova/plugin/blackberry10/notification'),
+        'Media': require('cordova/plugin/blackberry10/media'),
+        'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
+        'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
+    };
 
 /**
  * Execute a cordova command.  It is up to the native side whether this action
@@ -37,12 +46,86 @@ var cordova = require('cordova'),
  * @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) {
+    if (plugins[service] && plugins[service][action]) {
+        return plugins[service][action](args, success, fail);
+    }
+    return webworks.exec(success, fail, service, action, args);
+};
 
-module.exports = function(success, fail, service, action, args) {
-    try {
-        require('cordova/plugin/blackberry10/manager').exec(success, fail, service, action, args);
-        return null;
-    } catch (e) {
-        utils.alert("Error: "+e);
+function RemoteFunctionCall(functionUri) {
+     var params = {};
+
+    function composeUri() {
+        return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
     }
+
+    function createXhrRequest(uri, isAsync) {
+        var request = new XMLHttpRequest();
+        request.open("POST", uri, isAsync);
+        request.setRequestHeader("Content-Type", "application/json");
+        return request;
+    }
+
+    this.addParam = function (name, value) {
+        params[name] = encodeURIComponent(JSON.stringify(value));
+    };
+
+    this.makeSyncCall = function (success, error) {
+        var requestUri = composeUri(),
+            request = createXhrRequest(requestUri, false),
+            response,
+            errored,
+            cb,
+            data;
+
+        request.send(JSON.stringify(params));
+        response = JSON.parse(decodeURIComponent(request.responseText) || "null");
+        return response;
+    };
+}
+
+window.webworks = {
+    exec: function (success, fail, service, action, args) {
+        var uri = service + "/" + action,
+            request = new RemoteFunctionCall(uri),
+            callbackId = service + cordova.callbackId++,
+            response,
+            name,
+            didSucceed;
+
+        for (name in args) {
+            if (Object.hasOwnProperty.call(args, name)) {
+                request.addParam(name, args[name]);
+            }
+        }
+
+        cordova.callbacks[callbackId] = {success:success, fail:fail};
+        request.addParam("callbackId", callbackId);
+
+        response = request.makeSyncCall();
+
+        //Old WebWorks Extension success
+        if (response.code === 42) {
+            if (success) {
+                success(response.data, response);
+            }
+            delete cordova.callbacks[callbackId];
+        } else if (response.code < 0) {
+            if (fail) {
+                fail(response.msg, response);
+            }
+            delete cordova.callbacks[callbackId];
+        } else {
+            didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
+            cordova.callbackFromNative(callbackId, didSucceed, response.code, didSucceed ? response.data : response.msg, !!response.keepCallback);
+        }
+    },
+    defineReadOnlyField: function (obj, field, value) {
+        Object.defineProperty(obj, field, {
+            "value": value,
+            "writable": false
+        });
+    },
+    event: require("cordova/plugin/blackberry10/event")
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/56c53149/lib/blackberry10/plugin/blackberry10/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/manager.js b/lib/blackberry10/plugin/blackberry10/manager.js
deleted file mode 100644
index 6fc0dda..0000000
--- a/lib/blackberry10/plugin/blackberry10/manager.js
+++ /dev/null
@@ -1,54 +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 = {
-        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
-        'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
-        'Camera' : require('cordova/plugin/blackberry10/camera'),
-        'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Logger' : require('cordova/plugin/blackberry10/logger'),
-        'Notification' : require('cordova/plugin/blackberry10/notification'),
-        'Media': require('cordova/plugin/blackberry10/media'),
-        'File' : require('cordova/plugin/blackberry10/file'),
-        'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
-        'FileTransfer': require('cordova/plugin/blackberry10/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] && plugins[clazz][action]) {
-            result = plugins[clazz][action](args, win, fail);
-        }
-        else {
-            result = webworks.exec(win, fail, clazz, action, args);
-        }
-        return result;
-    },
-    resume: function () {},
-    pause: function () {},
-    destroy: function () {}
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/56c53149/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index ac32edd..e1c2b83 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -61,89 +61,6 @@
             fireWebworksReadyEvent();
         }
     );
-
-    /**
-     * webworks.exec
-     *
-     * This will all be moved into lib/blackberry10/exec once cordova.exec can be replaced
-     */
-
-    function RemoteFunctionCall(functionUri) {
-         var params = {};
-
-        function composeUri() {
-            return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
-        }
-
-        function createXhrRequest(uri, isAsync) {
-            var request = new XMLHttpRequest();
-            request.open("POST", uri, isAsync);
-            request.setRequestHeader("Content-Type", "application/json");
-            return request;
-        }
-
-        this.addParam = function (name, value) {
-            params[name] = encodeURIComponent(JSON.stringify(value));
-        };
-
-        this.makeSyncCall = function (success, error) {
-            var requestUri = composeUri(),
-                request = createXhrRequest(requestUri, false),
-                response,
-                errored,
-                cb,
-                data;
-
-            request.send(JSON.stringify(params));
-            response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-            return response;
-        };
-    }
-
-    window.webworks = {
-        exec: function (success, fail, service, action, args) {
-            var uri = service + "/" + action,
-                request = new RemoteFunctionCall(uri),
-                callbackId = service + cordova.callbackId++,
-                response,
-                name,
-                didSucceed;
-
-            for (name in args) {
-                if (Object.hasOwnProperty.call(args, name)) {
-                    request.addParam(name, args[name]);
-                }
-            }
-
-            cordova.callbacks[callbackId] = {success:success, fail:fail};
-            request.addParam("callbackId", callbackId);
-
-            response = request.makeSyncCall();
-
-            //Old WebWorks Extension success
-            if (response.code === 42) {
-                if (success) {
-                    success(response.data, response);
-                }
-                delete cordova.callbacks[callbackId];
-            } else if (response.code < 0) {
-                if (fail) {
-                    fail(response.msg, response);
-                }
-                delete cordova.callbacks[callbackId];
-            } else {
-                didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-                cordova.callbackFromNative(callbackId, didSucceed, response.code, [didSucceed ? response.data : response.msg], !!response.keepCallback);
-            }
-        },
-        defineReadOnlyField: function (obj, field, value) {
-            Object.defineProperty(obj, field, {
-                "value": value,
-                "writable": false
-            });
-        },
-        event: require("cordova/plugin/blackberry10/event")
-    };
 }());
 
 document.addEventListener("DOMContentLoaded", function () {


[25/32] js commit: [BlackBerry10] Update bootstrap to fix exec error caused by rebasing

Posted by lo...@apache.org.
[BlackBerry10] Update bootstrap to fix exec error caused by rebasing


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/5be2dabc
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/5be2dabc
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/5be2dabc

Branch: refs/heads/future
Commit: 5be2dabc4bde38b59fa29d6dc656e0ef7a865dfd
Parents: f0fb6ec
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed Apr 17 14:55:43 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 lib/scripts/bootstrap-blackberry10.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/5be2dabc/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index e359a15..836880f 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -112,7 +112,7 @@
                 delete cordova.callbacks[callbackId];
             } else {
                 didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-                cordova.callbackFromNative(callbackId, didSucceed, response.code, didSucceed ? response.data : response.msg, !!response.keepCallback);
+                cordova.callbackFromNative(callbackId, didSucceed, response.code, [ didSucceed ? response.data : response.msg ], !!response.keepCallback);
             }
         },
         defineReadOnlyField: function (obj, field, value) {


[09/32] js commit: [BlackBerry10] Remove NetworkStatus plugin

Posted by lo...@apache.org.
[BlackBerry10] Remove NetworkStatus plugin

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/86c137f1
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/86c137f1
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/86c137f1

Branch: refs/heads/future
Commit: 86c137f1c77154ed9d565c73c9aef8a1ff452309
Parents: d5ec1d2
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Mar 19 13:41:05 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/blackberry10/manager.js |    1 -
 lib/blackberry10/plugin/blackberry10/network.js |   28 -------------
 test/blackberry10/test.network.js               |   39 ------------------
 3 files changed, 0 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/86c137f1/lib/blackberry10/plugin/blackberry10/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/manager.js b/lib/blackberry10/plugin/blackberry10/manager.js
index 76476be..b0855b7 100644
--- a/lib/blackberry10/plugin/blackberry10/manager.js
+++ b/lib/blackberry10/plugin/blackberry10/manager.js
@@ -21,7 +21,6 @@
 
 var cordova = require('cordova'),
     plugins = {
-        'NetworkStatus' : require('cordova/plugin/blackberry10/network'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/86c137f1/lib/blackberry10/plugin/blackberry10/network.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/network.js b/lib/blackberry10/plugin/blackberry10/network.js
deleted file mode 100644
index b640f75..0000000
--- a/lib/blackberry10/plugin/blackberry10/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/86c137f1/test/blackberry10/test.network.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.network.js b/test/blackberry10/test.network.js
deleted file mode 100644
index 5917269..0000000
--- a/test/blackberry10/test.network.js
+++ /dev/null
@@ -1,39 +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.
- *
-*/
-
-describe("blackberry10 network", function () {
-    var cordova = require('cordova'),
-        network = require('cordova/plugin/blackberry10/network');
-
-    it("returns the connection info", function () {
-        global.blackberry = {
-            connection: {
-                type: "pigeon"
-            }
-        };
-        expect(network.getConnectionInfo()).toEqual({
-            status: cordova.callbackStatus.OK,
-            message: "pigeon"
-        });
-
-        delete global.blackberry;
-    });
-});


[13/32] js commit: [BlackBerry10] Update plugin path to support HTML pages outside of project root

Posted by lo...@apache.org.
[BlackBerry10] Update plugin path to support HTML pages outside of project root

Reviewed by: Danyi Lin <da...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/ad806405
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/ad806405
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/ad806405

Branch: refs/heads/future
Commit: ad80640505f3749e9738e0d2c41accabf4faf1ed
Parents: e8f1e59
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Mar 22 16:31:52 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 .../plugin/blackberry10/pluginUtils.js             |    2 +-
 test/blackberry10/test.pluginUtils.js              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ad806405/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
index a07a665..8545c71 100644
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -45,7 +45,7 @@ module.exports = {
             if (plugins.hasOwnProperty(plugin) && plugins[plugin].modules) {
                 for (i = 0; i < plugins[plugin].modules.length; i++) {
                     script = document.createElement('script');
-                    script.src = 'plugins/' + plugin + '/' + plugins[plugin].modules[i];
+                    script.src = 'local:///plugins/' + plugin + '/' + plugins[plugin].modules[i];
                     script.onload = function () {
                         if (--count === 0 && typeof callback === 'function') {
                             build(plugins);

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/ad806405/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
index 441ebcc..d298c43 100644
--- a/test/blackberry10/test.pluginUtils.js
+++ b/test/blackberry10/test.pluginUtils.js
@@ -52,7 +52,7 @@ describe('blackberry10 pluginUtils', function () {
             var plugins = { foo : { modules: ['bar.js'] } };
             pluginUtils.loadClientJs(plugins, callback);
             expect(document.createElement).toHaveBeenCalled();
-            expect(script.src).toEqual('plugins/foo/bar.js');
+            expect(script.src).toEqual('local:///plugins/foo/bar.js');
             expect(document.head.appendChild).toHaveBeenCalled();
             script.onload();
             expect(callback).toHaveBeenCalled();


[18/32] js commit: [BlackBerry10] Remove logger plugin

Posted by lo...@apache.org.
[BlackBerry10] Remove logger plugin


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/64b5b08a
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/64b5b08a
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/64b5b08a

Branch: refs/heads/future
Commit: 64b5b08a501d2937c4c082d643aebd53e2d5e7d2
Parents: 92cb895
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 2 11:36:13 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:39 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                       |    1 -
 lib/blackberry10/plugin/blackberry10/logger.js |   30 -------------------
 2 files changed, 0 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/64b5b08a/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index 61f6c9b..80fa69e 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -24,7 +24,6 @@ var cordova = require('cordova'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Logger' : require('cordova/plugin/blackberry10/logger'),
         'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/64b5b08a/lib/blackberry10/plugin/blackberry10/logger.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/logger.js b/lib/blackberry10/plugin/blackberry10/logger.js
deleted file mode 100644
index bd47a1e..0000000
--- a/lib/blackberry10/plugin/blackberry10/logger.js
+++ /dev/null
@@ -1,30 +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 = {
-    log: function (args, win, fail) {
-        console.log(args);
-        return {"status" : cordova.callbackStatus.OK,
-                "message" : 'Message logged to console: ' + args};
-    }
-};


[15/32] js commit: [BlackBerry10] Fixed to fire deviceready event if there is no client script to load for any plugin

Posted by lo...@apache.org.
[BlackBerry10] Fixed to fire deviceready event if there is no client script to load for any plugin

Reviewed by: Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/b5dc1237
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/b5dc1237
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/b5dc1237

Branch: refs/heads/future
Commit: b5dc12373a75cad961cfe7b6a516fb1988c32906
Parents: ad80640
Author: Rosa Tse <rt...@blackberry.com>
Authored: Tue Mar 26 13:59:23 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 .../plugin/blackberry10/pluginUtils.js             |    3 +++
 test/blackberry10/test.pluginUtils.js              |    2 +-
 2 files changed, 4 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b5dc1237/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
index 8545c71..aa49077 100644
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -57,6 +57,9 @@ module.exports = {
                 }
             }
         }
+        if (count === 0) {
+           callback();
+        }
     },
 
     getPlugins: function (success, error) {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b5dc1237/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
index d298c43..3fe83bb 100644
--- a/test/blackberry10/test.pluginUtils.js
+++ b/test/blackberry10/test.pluginUtils.js
@@ -45,7 +45,7 @@ describe('blackberry10 pluginUtils', function () {
             pluginUtils.loadClientJs(plugins, callback);
             expect(document.createElement).not.toHaveBeenCalled();
             expect(document.head.appendChild).not.toHaveBeenCalled();
-            expect(callback).not.toHaveBeenCalled();
+            expect(callback).toHaveBeenCalled();
         });
 
         it('adds a script tag for 1 plugin', function () {


[32/32] js commit: [BlackBerry10] Move File clobber to window from navigator

Posted by lo...@apache.org.
[BlackBerry10] Move File clobber to window from navigator

Fixes File API tests


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/a2e3993d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/a2e3993d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/a2e3993d

Branch: refs/heads/future
Commit: a2e3993d81de451942adadb0f313d67fa6a97058
Parents: 8d59461
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Wed May 1 14:44:25 2013 -0400
Committer: Bryan Higgins <br...@bryanhiggins.net>
Committed: Mon May 6 18:46:57 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/a2e3993d/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 5f11f7c..3b29584 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -29,7 +29,7 @@ module.exports = {
         modulemapper.loadMatchingModules(new RegExp('cordova/blackberry10/.*bbsymbols$'));
 
         modulemapper.clobbers('cordova/plugin/blackberry10/vibrate', 'navigator.notification.vibrate');
-        modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
+        modulemapper.clobbers('cordova/plugin/File', 'File');
         modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
 
         modulemapper.mapModules(window);


[05/32] js commit: [BlackBerry10] Implement plugin client script loading via script tag appended to document head.

Posted by lo...@apache.org.
[BlackBerry10] Implement plugin client script loading via script tag appended to document head.

Reviewed by Rose Tse <rt...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d2f52662
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d2f52662
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d2f52662

Branch: refs/heads/future
Commit: d2f526623bdab447af897b9bc7fc3776d1245a53
Parents: 28084c5
Author: Bryan Higgins <bh...@rim.com>
Authored: Tue Mar 5 11:46:53 2013 -0500
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:22 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/blackberry10/builder.js    |   74 ----
 .../plugin/blackberry10/pluginUtils.js             |   69 ++++
 lib/scripts/bootstrap-blackberry10.js              |  220 ++++--------
 lib/scripts/require.js                             |  289 +++------------
 test/blackberry10/test.builder.js                  |  121 ------
 test/blackberry10/test.pluginUtils.js              |  137 +++++++
 test/runner.js                                     |    2 +-
 7 files changed, 342 insertions(+), 570 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/lib/blackberry10/plugin/blackberry10/builder.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/builder.js b/lib/blackberry10/plugin/blackberry10/builder.js
deleted file mode 100644
index 9271c58..0000000
--- a/lib/blackberry10/plugin/blackberry10/builder.js
+++ /dev/null
@@ -1,74 +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 utils = require("cordova/plugin/blackberry10/utils");
-
-function buildNamespace(currentNamespace, namespaceParts, featureProperties) {
-    var featureId,
-        nextPart;
-
-    if (namespaceParts.length === 1) {
-        //base case, feature properties go here
-        featureId = namespaceParts[0];
-        if (currentNamespace[featureId] === undefined) {
-            currentNamespace[featureId] = {};
-        }
-
-        currentNamespace = utils.mixin(featureProperties, currentNamespace[featureId]);
-        return currentNamespace;
-    }
-    else {
-        nextPart = namespaceParts.shift();
-        if (currentNamespace[nextPart] === undefined) {
-            currentNamespace[nextPart] = {};
-        }
-
-        return buildNamespace(currentNamespace[nextPart], namespaceParts, featureProperties);
-    }
-}
-
-function include(parent, featureIdList) {
-    var featureId,
-        featureProperties,
-        localUrl,
-        i;
-
-    for (i = 0; i < featureIdList.length; i++) {
-        featureId = featureIdList[i];
-
-        localUrl = "local://ext/" + featureId + "/client.js";
-        featureProperties = utils.loadModule(localUrl);
-
-        buildNamespace(parent, featureId.split("."), featureProperties);
-    }
-}
-
-var _self = {
-    build: function (featureIdList) {
-        return {
-            into: function (target) {
-                include(target, featureIdList);
-            }
-        };
-    }
-};
-
-module.exports = _self;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
new file mode 100644
index 0000000..9a52a25
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -0,0 +1,69 @@
+/*
+ *
+ * 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 = {
+
+    loadClientJs: function (plugins, callback) {
+        var plugin,
+            script,
+            i,
+            count = 0;
+        for (plugin in plugins) {
+            if (plugins.hasOwnProperty(plugin) && plugins[plugin].modules) {
+                for (i = 0; i < plugins[plugin].modules.length; i++) {
+                    script = document.createElement('script');
+                    script.src = 'plugins/' + plugin + '/' + plugins[plugin].modules[i];
+                    script.onload = function () {
+                        if (--count === 0 && typeof callback === 'function') {
+                            callback();
+                        }
+                    };
+                    count++;
+                    document.head.appendChild(script);
+                }
+            }
+        }
+    },
+
+    getPlugins: function (success, error) {
+        var request,
+            response;
+        request = new XMLHttpRequest();
+        request.open('GET', 'plugins/plugins.json', true);
+        request.onreadystatechange = function () {
+            if (request.readyState === 4) {
+                if (request.status === 200) {
+                    try {
+                        response = JSON.parse(decodeURIComponent(request.responseText));
+                        success(response);
+                    }
+                    catch (e) {
+                        error(e);
+                    }
+                }
+                else {
+                    error(request.status);
+                }
+            }
+        };
+        request.send(null);
+    }
+}

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 1a33845..8c97e46 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -20,17 +20,19 @@
 */
 
 (function () {
-    var _d = document.addEventListener,
-        _webworksReady = false,
-        _alreadyFired = false,
-        _listenerRegistered = false;
+    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils'),
+        docAddEventListener = document.addEventListener,
+        webworksReady = false,
+        alreadyFired = false,
+        listenerRegistered = false;
 
     //Only fire the webworks event when both webworks is ready and a listener is registered
     function fireWebworksReadyEvent() {
-        if (_listenerRegistered && _webworksReady && !_alreadyFired) {
-            _alreadyFired = true;
-            var evt = document.createEvent("Events");
-            evt.initEvent("webworksready", true, true);
+        var evt;
+        if (listenerRegistered && webworksReady && !alreadyFired) {
+            alreadyFired = true;
+            evt = document.createEvent('Events');
+            evt.initEvent('webworksready', true, true);
             document.dispatchEvent(evt);
         }
     }
@@ -38,113 +40,78 @@
     //Trapping when users add listeners to the webworks ready event
     //This way we can make sure not to fire the event before there is a listener
     document.addEventListener = function (event, callback, capture) {
-        _d.call(document, event, callback, capture);
-        if (event.toLowerCase() === "webworksready") {
-            _listenerRegistered = true;
+        docAddEventListener.call(document, event, callback, capture);
+        if (event.toLowerCase() === 'webworksready') {
+            listenerRegistered = true;
             fireWebworksReadyEvent();
         }
     };
 
-    function createWebworksReady() {
-        function RemoteFunctionCall(functionUri) {
-            var params = {};
-
-            function composeUri() {
-                return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
-            }
-
-            function createXhrRequest(uri, isAsync) {
-                var request = new XMLHttpRequest();
-
-                request.open("POST", uri, isAsync);
-                request.setRequestHeader("Content-Type", "application/json");
-
-                return request;
-            }
-
-            this.addParam = function (name, value) {
-                params[name] = encodeURIComponent(JSON.stringify(value));
-            };
-
-            this.makeSyncCall = function (success, error) {
-                var requestUri = composeUri(),
-                    request = createXhrRequest(requestUri, false),
-                    response,
-                    errored,
-                    cb,
-                    data;
-
-                request.send(JSON.stringify(params));
-
-                response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-                errored = response.code < 0;
-                cb = errored ? error : success;
-                data = errored ? response.msg : response.data;
-
-                if (cb) {
-                    cb(data, response);
-                }
-                else if (errored) {
-                    throw data;
-                }
-
-                return data;
-            };
-
-            this.makeAsyncCall = function (success, error) {
-                var requestUri = composeUri(),
-                    request = createXhrRequest(requestUri, true);
+    //Fire webworks ready once plugin javascript has been loaded
+    pluginUtils.getPlugins(
+        function (plugins) {
+            pluginUtils.loadClientJs(plugins, function () {
+                webworksReady = true;
+                fireWebworksReadyEvent();
+            });
+        },
+        function (e) {
+            console.log(e);
+        }
+    );
 
-                request.onreadystatechange = function () {
-                    if (request.readyState === 4 && request.status === 200) {
-                        var response = JSON.parse(decodeURIComponent(request.responseText) || "null"),
-                        cb = response.code < 0 ? error : success,
-                        data = response.code < 0 ? response.msg : response.data;
+    /**
+     * webworks.exec
+     *
+     * This will all be moved into lib/blackberry10/exec once cordova.exec can be replaced
+     */
 
-                        return cb && cb(data, response);
-                    }
-                };
+    function RemoteFunctionCall(functionUri) {
+         var params = {};
 
-                request.send(JSON.stringify(params));
-            };
+        function composeUri() {
+            return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
         }
 
-        var builder,
-            request,
-            resp,
-            execFunc;
-
-        //For users who wish to have a single source project across BB7 -> PB -> BB10 they will need to use webworks.js
-        //To aid in this, we will fire the webworksready event on these platforms as well
-        //If blackberry object already exists then we are in an older version of webworks
-        if (window.blackberry) {
-            _webworksReady = true;
-            fireWebworksReadyEvent();
-            return;
+        function createXhrRequest(uri, isAsync) {
+            var request = new XMLHttpRequest();
+            request.open("POST", uri, isAsync);
+            request.setRequestHeader("Content-Type", "application/json");
+            return request;
         }
 
-        // Build out the blackberry namespace based on the APIs desired in the config.xml
-        builder = require('cordova/plugin/blackberry10/builder');
+        this.addParam = function (name, value) {
+            params[name] = encodeURIComponent(JSON.stringify(value));
+        };
+
+        this.makeSyncCall = function (success, error) {
+            var requestUri = composeUri(),
+                request = createXhrRequest(requestUri, false),
+                response,
+                errored,
+                cb,
+                data;
 
-        request = new XMLHttpRequest();
-        request.open("GET", "http://localhost:8472/extensions/get", true);
+            request.send(JSON.stringify(params));
 
-        request.onreadystatechange = function () {
-            if (request.readyState === 4) {
-                resp = JSON.parse(decodeURIComponent(request.responseText));
+            response = JSON.parse(decodeURIComponent(request.responseText) || "null");
+            errored = response.code < 0;
+            cb = errored ? error : success;
+            data = errored ? response.msg : response.data;
 
-                if (request.status === 200) {
-                    builder.build(resp.data).into(window);
-                    //At this point all of the APIs should be built into the window object
-                    //Fire the webworks ready event
-                    _webworksReady = true;
-                    fireWebworksReadyEvent();
-                }
+            if (cb) {
+                cb(data, response);
             }
+            else if (errored) {
+                throw data;
+            }
+
+            return data;
         };
-        request.send(null);
+    }
 
-        execFunc = function (success, fail, service, action, args, sync) {
+    window.webworks = {
+        exec: function (success, fail, service, action, args) {
             var uri = service + "/" + action,
                 request = new RemoteFunctionCall(uri),
                 name;
@@ -155,53 +122,16 @@
                 }
             }
 
-            request[sync ? "makeSyncCall" : "makeAsyncCall"](success, fail);
-        };
-
-        window.webworks = {
-            exec: execFunc,
-            execSync: function (service, action, args) {
-                var result;
-
-                execFunc(function (data, response) {
-                    result = data;
-                }, function (data, response) {
-                    throw data;
-                }, service, action, args, true);
-
-                return result;
-            },
-            execAsync: function (service, action, args) {
-                var result;
-
-                execFunc(function (data, response) {
-                    result = data;
-                }, function (data, response) {
-                    throw data;
-                }, service, action, args, false);
-
-                return result;
-            },
-            successCallback: function (id, args) {
-                //HACK: this will live later
-                throw "not implemented";
-            },
-            errorCallback: function (id, args) {
-                //HACK: this will live later
-                throw "not implemented";
-            },
-            defineReadOnlyField: function (obj, field, value) {
-                Object.defineProperty(obj, field, {
-                    "value": value,
-                    "writable": false
-                });
-            },
-            event: require("cordova/plugin/blackberry10/event")
-        };
-    }
-
-    // Let's create the webworks namespace
-    createWebworksReady();
+            return request.makeSyncCall(success, fail);
+        },
+        defineReadOnlyField: function (obj, field, value) {
+            Object.defineProperty(obj, field, {
+                "value": value,
+                "writable": false
+            });
+        },
+        event: require("cordova/plugin/blackberry10/event")
+    };
 }());
 
 document.addEventListener("DOMContentLoaded", function () {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/lib/scripts/require.js
----------------------------------------------------------------------
diff --git a/lib/scripts/require.js b/lib/scripts/require.js
index 35f160e..5dbc905 100644
--- a/lib/scripts/require.js
+++ b/lib/scripts/require.js
@@ -1,251 +1,82 @@
 /*
- *  Copyright 2012 Research In Motion Limited.
  *
- * Licensed 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
+ * 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
+ *   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.
- */
+ * 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 define,
-    require;
+var require,
+    define;
 
 (function () {
-    var unpreparedModules = {},
-        readyModules = {},
-        ACCEPTABLE_EXTENSIONS = [".js", ".json"],
-        DEFAULT_EXTENSION = ".js";
-
-    function hasValidExtension(moduleName) {
-        return ACCEPTABLE_EXTENSIONS.some(function (element, index, array) {
-            return moduleName.match("\\" + element + "$");
-        });
-    }
-
-
-    function normalizeName(originalName, baseName) {
-        var nameParts,
-            name = originalName.slice(0);
-        //remove ^local:// (if it exists) and .js$
-        //This will not work for local:// without a trailing js
-        name = name.replace(/(?:^local:\/\/)/, "");
-        if (name.charAt(0) === '.' && baseName) {
-            //Split the baseName and remove the final part (the module name)
-            nameParts = baseName.split('/');
-            nameParts.pop();
-            nameParts = nameParts.concat(name.split('/'));
-            
-            name = nameParts.reduce(function (previous, current,  index, array) {
-                var returnValue,
-                    slashIndex;
-
-                //If previous is a dot, ignore it
-                //If previous is ever just .. we're screwed anyway
-                if (previous !== '.') {
-                    returnValue = previous;
-                }
-                
-                //If we have a .. then remove a chunk of previous
-                if (current === "..") {
-                    slashIndex = previous.lastIndexOf('/');
-                    //If there's no slash we're either screwed or we remove the final token
-                    if (slashIndex !== -1) {
-                        returnValue = previous.slice(0, previous.lastIndexOf('/'));
-                    } else {
-                        returnValue = "";
-                    }
-                } else if (current !== '.') {
-                    //Otherwise simply append anything not a .
-                    //Only append a slash if we're not empty
-                    if (returnValue.length) {
-                        returnValue += "/";
-                    }
-                    returnValue += current;
-                }
-
-                return returnValue;
-            });
-
-        }
-        
-        //If there is no acceptable extension tack on a .js
-        if (!hasValidExtension(name)) {
-            name = name + DEFAULT_EXTENSION;
-        }
-
-        return name;
-    }
-
-    function buildModule(name, dependencies, factory) {
-        var module = {exports: {}},
-            localRequire = function (moduleName) {
-                return require(moduleName, name);
-            },
-            args = [];
-        localRequire.toUrl = function (moduleName, baseName) {
-            return require.toUrl(moduleName, baseName || name);
-        };
-        dependencies.forEach(function (dependency) {
-            if (dependency === 'require') {
-                args.push(localRequire);
-            } else if (dependency === 'exports') {
-                args.push(module.exports);
-            } else if (dependency === 'module') {
-                args.push(module);
-            } else {
-                //This is because jshint cannot handle out of order functions
-                /*global loadModule:false */
-                args.push(loadModule(dependency));
-                /*global loadModule:true */
-            }
-        });
-
-        //No need to process dependencies, webworks only has require, exports, module
-        factory.apply(this, args);
-
-        //For full AMD we would need logic to also check the return value
+    var modules = {};
+    // Stack of moduleIds currently being built.
+    var requireStack = [];
+    // Map of module ID -> index into requireStack of modules currently being built.
+    var inProgressModules = {};
+
+    function build(module) {
+        var factory = module.factory;
+        module.exports = {};
+        delete module.factory;
+        factory(require, module.exports, module);
         return module.exports;
-
     }
 
-    function getDefineString(moduleName, body) {
-        var evalString = 'define("' + moduleName + '", function (require, exports, module) {',
-            isJson = /\.json$/.test(moduleName);
-
-        evalString += isJson ? ' module.exports = ' : '';
-        evalString += body.replace(/^\s+|\s+$/g, '');
-        evalString += isJson ? ' ;' : '';
-        evalString += '});';
-
-        return evalString;
-    }
-
-    function loadModule(name, baseName) {
-        var normalizedName = normalizeName(name, baseName),
-            url,
-            xhr,
-            loadResult;
-        //Always check undefined first, this allows the user to redefine modules
-        //(Not used in WebWorks, although it is used in our unit tests)
-        if (unpreparedModules[normalizedName]) {
-            readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
-            delete unpreparedModules[normalizedName];
+    require = function (id) {
+        if (!modules[id]) {
+            throw "module " + id + " not found";
+        } else if (id in inProgressModules) {
+            var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
+            throw "Cycle in require graph: " + cycle;
         }
-
-        //If the module does not exist, load the module from external source
-        //Webworks currently only loads APIs from across bridge
-        if (!readyModules[normalizedName]) {
-            //If the module to be loaded ends in .js then we will define it
-            //Also if baseName exists than we have a local require situation
-            if (hasValidExtension(name) || baseName) {
-                xhr = new XMLHttpRequest();
-                url = name;
-                //If the module to be loaded starts with local:// go over the bridge
-                //Else If the module to be loaded is a relative load it may not have .js extension which is needed
-                if (/^local:\/\//.test(name)) {
-                    url = "http://localhost:8472/extensions/load/" + normalizedName.replace(/(?:^ext\/)(.+)(?:\/client.js$)/, "$1");
-
-                    xhr.open("GET", url, false);
-                    xhr.send(null);
-                    try {
-                        loadResult = JSON.parse(xhr.responseText);
-
-                        loadResult.dependencies.forEach(function (dep) {
-                            /*jshint evil:true */
-                            eval(getDefineString(dep.moduleName, dep.body));
-                            /*jshint evil:false */
-                        });
-
-                        //Trimming responseText to remove EOF chars
-                        /*jshint evil:true */
-                        eval(getDefineString(normalizedName, loadResult.client));
-                        /*jshint evil:false */
-                    } catch (err1) {
-                        err1.message += ' in ' + url;
-                        throw err1;
-                    }
-                } else {
-                    if (baseName) {
-                        url = normalizedName;
-                    }
-
-                    xhr.open("GET", url, false);
-                    xhr.send(null);
-                    try {
-                        //Trimming responseText to remove EOF chars
-                        /*jshint evil:true */
-                        eval(getDefineString(normalizedName, xhr.responseText));
-                        /*jshint evil:false */
-                    } catch (err) {
-                        err.message += ' in ' + url;
-                        throw err;
-                    }
-                }
-
-                if (unpreparedModules[normalizedName]) {
-                    readyModules[normalizedName] = buildModule(normalizedName, unpreparedModules[normalizedName].dependencies, unpreparedModules[normalizedName].factory);
-                    delete unpreparedModules[normalizedName];
-                }
-            } else {
-                throw "module " + name + " cannot be found";
+        if (modules[id].factory) {
+            try {
+                inProgressModules[id] = requireStack.length;
+                requireStack.push(id);
+                return build(modules[id]);
+            } finally {
+                delete inProgressModules[id];
+                requireStack.pop();
             }
-
-        }
-
-        return readyModules[normalizedName];
-
-    }
-
-    //Use the AMD signature incase we ever want to change.
-    //For now we will only be using (name, baseName)
-    require = function (dependencies, callback) {
-        if (typeof dependencies === "string") {
-            //dependencies is the module name and callback is the relName
-            //relName is not part of the AMDJS spec, but we use it from localRequire
-            return loadModule(dependencies, callback);
-        } else if (Array.isArray(dependencies) && typeof callback === 'function') {
-            //Call it Asynchronously
-            setTimeout(function () {
-                buildModule(undefined, dependencies, callback);
-            }, 0);
         }
-    }; 
-
-    require.toUrl = function (originalName, baseName) {
-        return normalizeName(originalName, baseName);
+        return modules[id].exports;
     };
 
-    //Use the AMD signature incase we ever want to change.
-    //For now webworks will only be using (name, factory) signature.
-    define = function (name, dependencies, factory) {
-        if (typeof name === "string" && typeof dependencies === 'function') {
-            factory = dependencies;
-            dependencies = ['require', 'exports', 'module'];
+    define = function (id, factory) {
+        if (modules[id]) {
+            throw "module " + id + " already defined";
         }
 
-        //According to the AMDJS spec we should parse out the require statments 
-        //from factory.toString and add those to the list of dependencies
-
-        //Normalize the name. Remove local:// and .js
-        name = normalizeName(name);
-        unpreparedModules[name] = {
-            dependencies: dependencies,
+        modules[id] = {
+            id: id,
             factory: factory
-        }; 
+        };
     };
-}());
 
-//Export for use in node for unit tests
-if (typeof module === "object" && typeof require === "function") {
-    module.exports = {
-        require: require,
-        define: define
+    define.remove = function (id) {
+        delete modules[id];
     };
+
+    define.moduleMap = modules;
+})();
+
+//Export for use in node
+if (typeof module === "object" && typeof require === "function") {
+    module.exports.require = require;
+    module.exports.define = define;
 }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/test/blackberry10/test.builder.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.builder.js b/test/blackberry10/test.builder.js
deleted file mode 100644
index 86e5487..0000000
--- a/test/blackberry10/test.builder.js
+++ /dev/null
@@ -1,121 +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 app,
-    io,
-    filetransfer,
-    system,
-    builder,
-    utils;
-
-describe("blackberry10 builder", function () {
-
-    beforeEach(function () {
-        //Set up mocking, no need to "spyOn" since spies are included in mock
-        window.webworks = {
-            webworks: {
-                execSync: jasmine.createSpy(),
-                defineReadOnlyField: jasmine.createSpy()
-            }
-        };
-
-        app = {
-            "name": "abc",
-            "version": "1.2.3"
-        };
-        io = {
-            "sandbox": false
-        };
-        filetransfer = {
-            "upload": function () {},
-            "download": function () {}
-        };
-        system =  {
-            "getCurrentTimezone": function () {}
-        };
-
-        utils = require("cordova/plugin/blackberry10/utils");
-        spyOn(utils, "loadModule").andCallFake(function (module) {
-            if (module.indexOf("app") !== -1) {
-                return app;
-            } else if (module.indexOf("filetransfer") !== -1) {
-                return filetransfer;
-            } else if (module.indexOf("io") !== -1) {
-                return io;
-            } else if (module.indexOf("system") !== -1) {
-                return system;
-            }
-        });
-
-        builder = require("cordova/plugin/blackberry10/builder");
-    });
-
-    afterEach(function () {
-        delete window.webworks;
-        builder = null;
-    });
-
-    it("can build an object with a single member", function () {
-        var featureIds = ['blackberry.app'],
-            target = {};
-
-        builder.build(featureIds).into(target);
-
-        expect(target.blackberry.app).toEqual(app);
-        expect(Object.hasOwnProperty.call(target.blackberry.app, "name")).toBeTruthy();
-        expect(Object.hasOwnProperty.call(target.blackberry.app, "version")).toBeTruthy();
-    });
-
-    it("can build an object with a nested member", function () {
-        var featureIds = ['blackberry.io', 'blackberry.io.filetransfer'],
-            target = {};
-
-        builder.build(featureIds).into(target);
-        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
-        expect(target.blackberry.io.sandbox).toEqual(io.sandbox);
-    });
-
-    it("can build with feature IDs provided in any order", function () {
-        var featureIds = ['blackberry.io.filetransfer', 'blackberry.io'],
-            target = {};
-
-        builder.build(featureIds).into(target);
-        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
-        expect(target.blackberry.io.sandbox).toEqual(io.sandbox);
-    });
-
-    it("can build an object with only the nested member", function () {
-        var featureIds = ['blackberry.io.filetransfer'],
-            target = {};
-
-        builder.build(featureIds).into(target);
-        expect(target.blackberry.io.filetransfer).toEqual(filetransfer);
-    });
-
-    it("can build an object with multiple members", function () {
-        var featureIds = ['blackberry.app', 'blackberry.system'],
-            target = {};
-
-        builder.build(featureIds).into(target);
-        expect(target.blackberry.app).toEqual(app);
-        expect(target.blackberry.system).toEqual(system);
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/test/blackberry10/test.pluginUtils.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.pluginUtils.js b/test/blackberry10/test.pluginUtils.js
new file mode 100644
index 0000000..37f0e9c
--- /dev/null
+++ b/test/blackberry10/test.pluginUtils.js
@@ -0,0 +1,137 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+describe('blackberry10 pluginUtils', function () {
+
+    var pluginUtils = require('cordova/plugin/blackberry10/pluginUtils');
+
+    describe('loadClientJs', function () {
+
+        var callback,
+            script;
+
+        beforeEach(function () {
+            script = {};
+            spyOn(document, "createElement").andCallFake(function () {
+                return script;
+            });
+            spyOn(document.head, "appendChild");
+            callback = jasmine.createSpy();
+        });
+
+        it('does nothing for 0 plugins', function () {
+            var plugins = {};
+            pluginUtils.loadClientJs(plugins, callback);
+            expect(document.createElement).not.toHaveBeenCalled();
+            expect(document.head.appendChild).not.toHaveBeenCalled();
+            expect(callback).not.toHaveBeenCalled();
+        });
+
+        it('adds a script tag for 1 plugin', function () {
+            var plugins = { foo : { client: ['bar.js'] } };
+            pluginUtils.loadClientJs(plugins, callback);
+            expect(document.createElement).toHaveBeenCalled();
+            expect(script.src).toEqual('plugins/foo/bar.js');
+            expect(document.head.appendChild).toHaveBeenCalled();
+            script.onload();
+            expect(callback).toHaveBeenCalled();
+        });
+
+        it('adds multiple script tags for 1 plugin', function () {
+            var plugins = { foo: { client: ['bar.js', '2.js'] } };
+            pluginUtils.loadClientJs(plugins, callback);
+            expect(document.createElement.callCount).toBe(2);
+            expect(document.head.appendChild.callCount).toBe(2);
+            script.onload();
+            script.onload();
+            expect(callback.callCount).toBe(1);
+        });
+
+        it('adds script tags for multiple plugins', function () {
+            var plugins = { foo: { client: ['1.js'] }, bar: { client: ['1.js', '2.js' ] } };
+            pluginUtils.loadClientJs(plugins, callback);
+            expect(document.createElement.callCount).toBe(3);
+            expect(document.head.appendChild.callCount).toBe(3);
+            script.onload();
+            script.onload();
+            script.onload();
+            expect(callback.callCount).toBe(1);
+        });
+
+    });
+
+    describe('getPlugins', function () {
+
+        var success,
+            error,
+            xhr;
+
+        beforeEach(function () {
+            GLOBAL.XMLHttpRequest = function () {
+                this.open = jasmine.createSpy();
+                this.send = jasmine.createSpy();
+                xhr = this;
+            };
+            success = jasmine.createSpy();
+            error = jasmine.createSpy();
+        });
+
+        afterEach(function () {
+            delete GLOBAL.XMLHttpRequest;
+        });
+
+        it('sends XHR for plugins.json', function () {
+            pluginUtils.getPlugins(success, error);
+            expect(xhr.open).toHaveBeenCalledWith('GET', 'plugins/plugins.json', true);
+            expect(xhr.send).toHaveBeenCalled();
+        });
+
+        it('calls success with JSON response', function () {
+            pluginUtils.getPlugins(success, error);
+            xhr.readyState = 4;
+            xhr.status = 200;
+            xhr.responseText = '{ "hello" : "World" }';
+            xhr.onreadystatechange();
+            expect(success).toHaveBeenCalledWith({ hello: "World"});
+            expect(error).not.toHaveBeenCalled();
+        });
+
+        it('calls error with status', function () {
+            pluginUtils.getPlugins(success, error);
+            xhr.readyState = 4;
+            xhr.status = 500;
+            xhr.onreadystatechange();
+            expect(error).toHaveBeenCalledWith(500);
+            expect(success).not.toHaveBeenCalled();
+        });
+
+        it('calls error with parse exception', function () {
+            pluginUtils.getPlugins(success, error);
+            xhr.readyState = 4;
+            xhr.status = 200;
+            xhr.responseText = 'INVALID';
+            xhr.onreadystatechange();
+            expect(error).toHaveBeenCalled();
+            expect(success).not.toHaveBeenCalled();
+        });
+
+    });
+});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d2f52662/test/runner.js
----------------------------------------------------------------------
diff --git a/test/runner.js b/test/runner.js
index e25afbb..c908cf3 100644
--- a/test/runner.js
+++ b/test/runner.js
@@ -49,7 +49,7 @@ module.exports = {
 
         try {
             jsdom = require("jsdom").jsdom;
-            document = jsdom("<html>");
+            document = jsdom("<html><head></head></html>");
             window = document.createWindow();
         } catch (e) {
             //no jsDom (some people don't have compilers)


[19/32] js commit: [BlackBerry10] Removed Notication API implementation

Posted by lo...@apache.org.
[BlackBerry10] Removed Notication API implementation

- now exists as core plugin in template
- clobbered navigation.notification.vibrate()

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/b205fd1d
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/b205fd1d
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/b205fd1d

Branch: refs/heads/future
Commit: b205fd1da28aa4619731c6fcd5a85be05c9ab120
Parents: 64b5b08
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Mon Apr 8 15:22:44 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:39 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                           |    1 -
 .../plugin/blackberry10/notification.js            |   52 ---------------
 lib/blackberry10/plugin/blackberry10/platform.js   |   11 +++
 lib/blackberry10/plugin/blackberry10/vibrate.js    |   31 +++++++++
 4 files changed, 42 insertions(+), 53 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b205fd1d/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index 80fa69e..ad9c673 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -24,7 +24,6 @@ var cordova = require('cordova'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
-        'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
     };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b205fd1d/lib/blackberry10/plugin/blackberry10/notification.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/notification.js b/lib/blackberry10/plugin/blackberry10/notification.js
deleted file mode 100644
index 9de87b8..0000000
--- a/lib/blackberry10/plugin/blackberry10/notification.js
+++ /dev/null
@@ -1,52 +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 = {
-    alert: function (args, win, fail) {
-        if (args.length !== 3) {
-            return {"status" : 9, "message" : "Notification action - alert arguments not found"};
-        }
-
-        //Unpack and map the args
-        var msg = args[0],
-            title = args[1],
-            btnLabel = args[2];
-
-        blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title" : title } ]);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    },
-    confirm: function (args, win, fail) {
-        if (args.length !== 3) {
-            return {"status" : 9, "message" : "Notification action - confirm arguments not found"};
-        }
-
-        //Unpack and map the args
-        var msg = args[0],
-            title = args[1],
-            btnLabel = args[2],
-            btnLabels = btnLabel.split(",");
-
-        blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title" : title} ]);
-        return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
-    }
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b205fd1d/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
index 9678434..b283554 100644
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -46,6 +46,17 @@ module.exports = {
     clobbers: {
         requestFileSystem: {
             path: "cordova/plugin/blackberry10/requestFileSystem"
+        },
+        navigator: {
+            children: {
+                notification: {
+                    children: {
+                        vibrate: {
+                            path: 'cordova/plugin/blackberry10/vibrate'
+                        }
+                    }
+                }
+            }
         }
     },
     merges: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/b205fd1d/lib/blackberry10/plugin/blackberry10/vibrate.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/vibrate.js b/lib/blackberry10/plugin/blackberry10/vibrate.js
new file mode 100644
index 0000000..ba05294
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/vibrate.js
@@ -0,0 +1,31 @@
+/*
+ *
+ * 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 = function (time) {
+    var proto = Object.getPrototypeOf(navigator);
+
+    if (proto && proto.vibrate) {
+        proto.vibrate(time);
+    } else if (proto && proto.webkitVibrate) {
+        //Older OS contain webkit prefix
+        proto.webkitVibrate(time);
+    }
+};


[31/32] js commit: Add leading slash to cordova_plugins.json in plugin loader

Posted by lo...@apache.org.
Add leading slash to cordova_plugins.json in plugin loader

This fixes script injection on pages which are not at the application root.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/8d59461c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/8d59461c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/8d59461c

Branch: refs/heads/future
Commit: 8d59461c6f796f2c88a0eae2467cc663897ccce9
Parents: 93152a0
Author: Bryan Higgins <br...@bryanhiggins.net>
Authored: Mon May 6 18:44:00 2013 -0400
Committer: Bryan Higgins <br...@bryanhiggins.net>
Committed: Mon May 6 18:44:00 2013 -0400

----------------------------------------------------------------------
 lib/scripts/plugin_loader.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8d59461c/lib/scripts/plugin_loader.js
----------------------------------------------------------------------
diff --git a/lib/scripts/plugin_loader.js b/lib/scripts/plugin_loader.js
index 00f889c..1100245 100644
--- a/lib/scripts/plugin_loader.js
+++ b/lib/scripts/plugin_loader.js
@@ -114,7 +114,7 @@
         finishPluginLoading();
     };
     try { // we commented we were going to try, so let us actually try and catch
-        xhr.open('GET', 'cordova_plugins.json', true); // Async
+        xhr.open('GET', '/cordova_plugins.json', true); // Async
         xhr.send();
     } catch(err){
         finishPluginLoading();


[22/32] js commit: Rewriting require to allow for relative paths within a module

Posted by lo...@apache.org.
Rewriting require to allow for relative paths within a module

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/8b06f297
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/8b06f297
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/8b06f297

Branch: refs/heads/future
Commit: 8b06f297fd415835dc0dfa729e96e7ce4fc074ad
Parents: b205fd1
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Mon Apr 8 15:58:13 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 lib/scripts/require.js |   21 ++++++++++++++++-----
 test/test.require.js   |    2 +-
 2 files changed, 17 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8b06f297/lib/scripts/require.js
----------------------------------------------------------------------
diff --git a/lib/scripts/require.js b/lib/scripts/require.js
index 5dbc905..93f8d16 100644
--- a/lib/scripts/require.js
+++ b/lib/scripts/require.js
@@ -23,17 +23,28 @@ var require,
     define;
 
 (function () {
-    var modules = {};
+    var modules = {},
     // Stack of moduleIds currently being built.
-    var requireStack = [];
+        requireStack = [],
     // Map of module ID -> index into requireStack of modules currently being built.
-    var inProgressModules = {};
+        inProgressModules = {},
+        SEPERATOR = ".";
+
+
 
     function build(module) {
-        var factory = module.factory;
+        var factory = module.factory,
+            localRequire = function (id) {
+                var resultantId = id;
+                //Its a relative path, so lop off the last portion and add the id (minus "./")
+                if (id.charAt(0) === ".") {
+                    resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
+                }
+                return require(resultantId);
+            };
         module.exports = {};
         delete module.factory;
-        factory(require, module.exports, module);
+        factory(localRequire, module.exports, module);
         return module.exports;
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8b06f297/test/test.require.js
----------------------------------------------------------------------
diff --git a/test/test.require.js b/test/test.require.js
index 7734e41..19d179d 100644
--- a/test/test.require.js
+++ b/test/test.require.js
@@ -93,7 +93,7 @@ describe("require + define", function () {
             define("dino", factory);
             require("dino");
 
-            expect(factory).toHaveBeenCalledWith(require,
+            expect(factory).toHaveBeenCalledWith(jasmine.any(Function),
                 {}, {
                     id: "dino",
                     exports: {}


[28/32] js commit: [BlackBerry10] Fix Entry.moveTo check for valid success function

Posted by lo...@apache.org.
[BlackBerry10] Fix Entry.moveTo check for valid success function

Reviewed by Hasan Ahmad <ha...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/188c17d6
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/188c17d6
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/188c17d6

Branch: refs/heads/future
Commit: 188c17d64400770a1dcba7294aed38244aa1d811
Parents: 369e1af
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Apr 22 10:42:57 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:05 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/Entry.js |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/188c17d6/lib/blackberry10/plugin/Entry.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/Entry.js b/lib/blackberry10/plugin/Entry.js
index f80e879..cf971fe 100644
--- a/lib/blackberry10/plugin/Entry.js
+++ b/lib/blackberry10/plugin/Entry.js
@@ -50,20 +50,17 @@ Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataO
 
 Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
-    var fail = errorCallback && function(code) {
-            errorCallback(new FileError(code));
-        },
-        srcPath = this.fullPath,
+    var srcPath = this.fullPath,
         name = newName || this.name,
         success = function(entry) {
             if (entry) {
-                if (successCallback === 'function') {
+                if (typeof successCallback === 'function') {
                     successCallback(fileUtils.createEntry(entry));
                 }
             }
             else {
-                if (typeof fail === 'function') {
-                    fail(FileError.NOT_FOUND_ERR);
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
                 }
             }
         };
@@ -73,10 +70,7 @@ Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallbac
 
 Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
     argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
-    var fail = errorCallback && function(code) {
-            errorCallback(new FileError(code));
-        },
-        srcPath = this.fullPath,
+    var srcPath = this.fullPath,
         name = newName || this.name,
         success = function(entry) {
             if (entry) {
@@ -85,8 +79,8 @@ Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallbac
                 }
             }
             else {
-                if (typeof fail === 'function') {
-                    fail(FileError.NOT_FOUND_ERR);
+                if (typeof errorCallback === 'function') {
+                    errorCallback(new FileError(FileError.NOT_FOUND_ERR));
                 }
             }
         };


[27/32] js commit: [BlackBerry10] Moving moduleMapping back into platform initialize

Posted by lo...@apache.org.
[BlackBerry10] Moving moduleMapping back into platform initialize

Reviewed By: Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/93152a0e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/93152a0e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/93152a0e

Branch: refs/heads/future
Commit: 93152a0e3fb9b5b86f8cf1e53f01104047cca34c
Parents: ea8515b
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Fri Apr 26 11:35:06 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:05 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/platform.js          |    1 +
 lib/scripts/bootstrap-blackberry10.js |    1 -
 2 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/93152a0e/lib/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/platform.js b/lib/blackberry10/platform.js
index 3d68cd8..5f11f7c 100644
--- a/lib/blackberry10/platform.js
+++ b/lib/blackberry10/platform.js
@@ -32,5 +32,6 @@ module.exports = {
         modulemapper.clobbers('cordova/plugin/File', 'navigator.File');
         modulemapper.merges('cordova/plugin/blackberry10/compass', 'navigator.compass');
 
+        modulemapper.mapModules(window);
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/93152a0e/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 351411c..1e40bae 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -124,7 +124,6 @@
     };
 
     require("cordova/channel").onPluginsReady.subscribe(function () {
-        require("cordova/modulemapper").mapModules(window);
         webworksReady = true;
         fireWebworksReadyEvent();
     });


[14/32] js commit: [BlackBerry10] Initial work on cleaning up the exec chain. Includes the removal of the battery extension to test its working correctly.

Posted by lo...@apache.org.
[BlackBerry10] Initial work on cleaning up the exec chain. Includes the removal of the
battery extension to test its working correctly.

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/e8f1e595
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/e8f1e595
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/e8f1e595

Branch: refs/heads/future
Commit: e8f1e595c7c6056dcb3d131b930e3f1cf1efe2f1
Parents: 2e12eda
Author: Jeffrey Heifetz <jh...@rim.com>
Authored: Thu Mar 21 14:31:20 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                        |   35 +--------
 lib/blackberry10/plugin/blackberry10/battery.js |   40 ----------
 lib/blackberry10/plugin/blackberry10/manager.js |    1 -
 lib/scripts/bootstrap-blackberry10.js           |   40 ++++++----
 test/blackberry10/test.battery.js               |   72 ------------------
 5 files changed, 27 insertions(+), 161 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/e8f1e595/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index 5880fbc..e84cd69 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -40,39 +40,8 @@ var cordova = require('cordova'),
 
 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;
-        }
+        require('cordova/plugin/blackberry10/manager').exec(success, fail, service, action, args);
+        return null;
     } catch (e) {
         utils.alert("Error: "+e);
     }

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/e8f1e595/lib/blackberry10/plugin/blackberry10/battery.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/battery.js b/lib/blackberry10/plugin/blackberry10/battery.js
deleted file mode 100644
index 8bd9f44..0000000
--- a/lib/blackberry10/plugin/blackberry10/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/e8f1e595/lib/blackberry10/plugin/blackberry10/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/manager.js b/lib/blackberry10/plugin/blackberry10/manager.js
index b0855b7..6fc0dda 100644
--- a/lib/blackberry10/plugin/blackberry10/manager.js
+++ b/lib/blackberry10/plugin/blackberry10/manager.js
@@ -22,7 +22,6 @@
 var cordova = require('cordova'),
     plugins = {
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
-        'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Camera' : require('cordova/plugin/blackberry10/camera'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/e8f1e595/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 153d2c9..ac32edd 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -95,20 +95,8 @@
                 data;
 
             request.send(JSON.stringify(params));
-
             response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-            errored = response.code < 0;
-            cb = errored ? error : success;
-            data = errored ? response.msg : response.data;
-
-            if (cb) {
-                cb(data, response);
-            }
-            else if (errored) {
-                throw data;
-            }
-
-            return { status: 0 };
+            return response;
         };
     }
 
@@ -116,7 +104,10 @@
         exec: function (success, fail, service, action, args) {
             var uri = service + "/" + action,
                 request = new RemoteFunctionCall(uri),
-                name;
+                callbackId = service + cordova.callbackId++,
+                response,
+                name,
+                didSucceed;
 
             for (name in args) {
                 if (Object.hasOwnProperty.call(args, name)) {
@@ -124,7 +115,26 @@
                 }
             }
 
-            return request.makeSyncCall(success, fail);
+            cordova.callbacks[callbackId] = {success:success, fail:fail};
+            request.addParam("callbackId", callbackId);
+
+            response = request.makeSyncCall();
+
+            //Old WebWorks Extension success
+            if (response.code === 42) {
+                if (success) {
+                    success(response.data, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else if (response.code < 0) {
+                if (fail) {
+                    fail(response.msg, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else {
+                didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
+                cordova.callbackFromNative(callbackId, didSucceed, response.code, [didSucceed ? response.data : response.msg], !!response.keepCallback);
+            }
         },
         defineReadOnlyField: function (obj, field, value) {
             Object.defineProperty(obj, field, {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/e8f1e595/test/blackberry10/test.battery.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.battery.js b/test/blackberry10/test.battery.js
deleted file mode 100644
index 4e8b0b0..0000000
--- a/test/blackberry10/test.battery.js
+++ /dev/null
@@ -1,72 +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.
- *
-*/
-
-describe("blackberry10 battery", function () {
-    var battery = require('cordova/plugin/blackberry10/battery'),
-        cordova = require('cordova');
-
-    beforeEach(function () {
-        spyOn(window, "setInterval").andReturn(1);
-        spyOn(window, "clearInterval");
-    });
-
-    it("returns no_result when calling start", function () {
-        expect(battery.start()).toEqual({
-            status: cordova.callbackStatus.NO_RESULT,
-            message: "WebWorks Is On It"
-        });
-    });
-
-    it("sets an interval for 500 ms when calling start", function () {
-        battery.start();
-        expect(window.setInterval).toHaveBeenCalledWith(jasmine.any(Function), 500);
-    });
-
-    it("calls the win callback with values from navigator.webkitBattery", function () {
-        global.navigator = window.navigator;
-        window.navigator.webkitBattery = { level: 0.12, charging: true };
-
-        var win = jasmine.createSpy("win");
-        battery.start({}, win);
-
-        window.setInterval.mostRecentCall.args[0]();
-
-        expect(win).toHaveBeenCalledWith({
-            level: 12,
-            isPlugged: true
-        });
-
-        delete window.navigator.webkitBattery;
-    });
-
-    it("returns ok when calling stop", function () {
-        expect(battery.stop()).toEqual({
-            status: cordova.callbackStatus.OK,
-            message: "stopped"
-        });
-    });
-
-    it("calls clearInterval when stopping", function () {
-        battery.start();
-        battery.stop();
-        expect(window.clearInterval).toHaveBeenCalledWith(1);
-    });
-});


[29/32] js commit: [BlackBerry10] Fix notification handling of commas in button labels

Posted by lo...@apache.org.
[BlackBerry10] Fix notification handling of commas in button labels

Reviewed by Bryan Higgins <bh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/6d6478ee
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/6d6478ee
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/6d6478ee

Branch: refs/heads/future
Commit: 6d6478ee42a46bca394cde7f028face62f9e1903
Parents: acaf837
Author: jkeshavarzi <jk...@blackberry.com>
Authored: Wed Apr 24 14:26:18 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:05 2013 -0400

----------------------------------------------------------------------
 lib/common/plugin/notification.js |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/6d6478ee/lib/common/plugin/notification.js
----------------------------------------------------------------------
diff --git a/lib/common/plugin/notification.js b/lib/common/plugin/notification.js
index 47a1c52..919e050 100644
--- a/lib/common/plugin/notification.js
+++ b/lib/common/plugin/notification.js
@@ -63,7 +63,7 @@ module.exports = {
         // Some platforms take an array of button label names.
         // Other platforms take a comma separated list.
         // For compatibility, we convert to the desired type based on the platform.
-        if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone") {
+        if (platform.id == "android" || platform.id == "ios" || platform.id == "windowsphone" || platform.id == "blackberry10") {
             if (typeof _buttonLabels === 'string') {
                 var buttonLabelString = _buttonLabels;
                 _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here


[07/32] js commit: [BlackBerry10] Remove window.open clobber so child window functions correctly

Posted by lo...@apache.org.
[BlackBerry10] Remove window.open clobber so child window functions correctly

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/92cb8952
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/92cb8952
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/92cb8952

Branch: refs/heads/future
Commit: 92cb8952f86c556d55f7b82624def8d49ae4f6dc
Parents: dbb478c
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 2 16:08:25 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/blackberry10/platform.js |    3 ---
 1 files changed, 0 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/92cb8952/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
index d43cdd5..9678434 100644
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -44,9 +44,6 @@ module.exports = {
         });
     },
     clobbers: {
-        open: {
-            path: "cordova/plugin/InAppBrowser"
-        },
         requestFileSystem: {
             path: "cordova/plugin/blackberry10/requestFileSystem"
         }


[10/32] js commit: [BlackBerry10] Start the process of moving out the core plugins, beginning with Device.

Posted by lo...@apache.org.
[BlackBerry10] Start the process of moving out the core plugins, beginning with Device.

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/d5ec1d29
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/d5ec1d29
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/d5ec1d29

Branch: refs/heads/future
Commit: d5ec1d2974444fbddd3aff5b0f44ad558d06ecdc
Parents: d4fa7d3
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Mon Mar 18 20:52:55 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/blackberry10/device.js  |   41 -------------
 lib/blackberry10/plugin/blackberry10/manager.js |   14 ++---
 lib/scripts/bootstrap-blackberry10.js           |    8 ++-
 test/blackberry10/test.device.js                |   48 ---------------
 test/blackberry10/test.manager.js               |   56 ------------------
 5 files changed, 10 insertions(+), 157 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d5ec1d29/lib/blackberry10/plugin/blackberry10/device.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/device.js b/lib/blackberry10/plugin/blackberry10/device.js
deleted file mode 100644
index 8898e09..0000000
--- a/lib/blackberry10/plugin/blackberry10/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/d5ec1d29/lib/blackberry10/plugin/blackberry10/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/manager.js b/lib/blackberry10/plugin/blackberry10/manager.js
index 8307c74..76476be 100644
--- a/lib/blackberry10/plugin/blackberry10/manager.js
+++ b/lib/blackberry10/plugin/blackberry10/manager.js
@@ -23,7 +23,6 @@ var cordova = require('cordova'),
     plugins = {
         'NetworkStatus' : require('cordova/plugin/blackberry10/network'),
         'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
-        'Device' : require('cordova/plugin/blackberry10/device'),
         'Battery' : require('cordova/plugin/blackberry10/battery'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Camera' : require('cordova/plugin/blackberry10/camera'),
@@ -43,15 +42,12 @@ module.exports = {
     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 };
-            }
+        if (plugins[clazz] && plugins[clazz][action]) {
+            result = plugins[clazz][action](args, win, fail);
+        }
+        else {
+            result = webworks.exec(win, fail, clazz, action, args);
         }
-
         return result;
     },
     resume: function () {},

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d5ec1d29/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index 8c97e46..153d2c9 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -55,8 +55,10 @@
                 fireWebworksReadyEvent();
             });
         },
-        function (e) {
-            console.log(e);
+        function () {
+            console.log('Unable to load plugins.json');
+            webworksReady = true;
+            fireWebworksReadyEvent();
         }
     );
 
@@ -106,7 +108,7 @@
                 throw data;
             }
 
-            return data;
+            return { status: 0 };
         };
     }
 

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d5ec1d29/test/blackberry10/test.device.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.device.js b/test/blackberry10/test.device.js
deleted file mode 100644
index 66f3813..0000000
--- a/test/blackberry10/test.device.js
+++ /dev/null
@@ -1,48 +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.
- *
-*/
-
-describe("blackberry10 device", function () {
-    var device = require('cordova/plugin/blackberry10/device');
-    
-    it("calls the win callback with the device info", function () {
-        global.blackberry = {
-            system: {
-                softwareVersion: "NaN"
-            },
-            identity: {
-                uuid: 1
-            }
-        };
-
-        var info;
-
-        //HACK: I know this is a sync call ;)
-        device.getDeviceInfo({}, function (i) { info = i; });
-
-        expect(info.platform).toBe("BlackBerry");
-        expect(info.version).toBe("NaN");
-        expect(info.name).toBe("Dev Alpha");
-        expect(info.uuid).toBe(1);
-        expect(info.cordova).toBeDefined();
-        
-        delete global.blackberry;
-    });
-});

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/d5ec1d29/test/blackberry10/test.manager.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.manager.js b/test/blackberry10/test.manager.js
deleted file mode 100644
index 5899fd3..0000000
--- a/test/blackberry10/test.manager.js
+++ /dev/null
@@ -1,56 +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.
- *
-*/
-
-describe("blackberry10 manager", function () {
-    var manager = require('cordova/plugin/blackberry10/manager');
-
-    it("calls the plugin", function () {
-        var device = require('cordova/plugin/blackberry10/device'),
-            win = jasmine.createSpy('win'),
-            fail = jasmine.createSpy('fail'),
-            args = {};
-
-        spyOn(device, "getDeviceInfo");
-
-        manager.exec(win, fail, "Device", "getDeviceInfo", args);
-        expect(device.getDeviceInfo).toHaveBeenCalledWith(args, win, fail);
-    });
-
-    it("returns the result of the plugin", function () {
-        var camera = require('cordova/plugin/blackberry10/camera');
-        spyOn(camera, "takePicture").andReturn("duckface");
-        expect(manager.exec(null, null, "Camera", "takePicture")).toBe("duckface");
-    });
-
-    it("returns class not found when no plugin", function () {
-        expect(manager.exec(null, null, "Ruby", "method_missing")).toEqual({
-           status: cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION,
-           message: "Class Ruby cannot be found"
-        });
-    });
-
-    it("returns invalid action when no action", function () {
-        expect(manager.exec(null, null, "Camera", "makePonies")).toEqual({
-            status: cordova.callbackStatus.INVALID_ACTION,
-            message: "Action not found: makePonies"
-        });
-    });
-});


[24/32] js commit: [BlackBerry10] Implement File API as client side wrapper

Posted by lo...@apache.org.
[BlackBerry10] Implement File API as client side wrapper

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f0fb6ec0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f0fb6ec0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f0fb6ec0

Branch: refs/heads/future
Commit: f0fb6ec02c3c216c04591441b2359c4100cea66e
Parents: f4f3f4b
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Tue Apr 9 17:09:07 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/DirectoryEntry.js          |   57 ++
 lib/blackberry10/plugin/DirectoryReader.js         |   47 ++
 lib/blackberry10/plugin/Entry.js                   |  118 ++++
 lib/blackberry10/plugin/FileEntry.js               |   47 ++
 lib/blackberry10/plugin/FileReader.js              |   98 ++++
 lib/blackberry10/plugin/FileSystem.js              |   27 +
 lib/blackberry10/plugin/FileWriter.js              |  120 ++++
 lib/blackberry10/plugin/blackberry10/file.js       |  424 ---------------
 .../plugin/blackberry10/fileTransfer.js            |   33 +-
 lib/blackberry10/plugin/blackberry10/fileUtils.js  |   47 ++
 lib/blackberry10/plugin/blackberry10/platform.js   |    3 +
 .../plugin/blackberry10/pluginUtils.js             |    4 +-
 .../plugin/blackberry10/requestFileSystem.js       |   39 --
 lib/blackberry10/plugin/requestFileSystem.js       |   38 ++
 .../plugin/resolveLocalFileSystemURI.js            |   55 ++
 test/blackberry10/test.fileTransfer.js             |   85 ---
 16 files changed, 674 insertions(+), 568 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/DirectoryEntry.js b/lib/blackberry10/plugin/DirectoryEntry.js
new file mode 100644
index 0000000..259a79e
--- /dev/null
+++ b/lib/blackberry10/plugin/DirectoryEntry.js
@@ -0,0 +1,57 @@
+/*
+ *
+ * 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 argscheck = require('cordova/argscheck'),
+    utils = require('cordova/utils'),
+    Entry = require('cordova/plugin/Entry'),
+    FileError = require('cordova/plugin/FileError'),
+    DirectoryReader = require('cordova/plugin/DirectoryReader'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    DirectoryEntry = function (name, fullPath) {
+        DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
+    };
+
+utils.extend(DirectoryEntry, Entry);
+
+DirectoryEntry.prototype.createReader = function () {
+    return new DirectoryReader(this.fullPath);
+};
+
+DirectoryEntry.prototype.getDirectory = function (path, options, successCallback, errorCallback) {
+    argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
+    this.nativeEntry.getDirectory(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
+};
+
+DirectoryEntry.prototype.removeRecursively = function (successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
+    this.nativeEntry.removeRecursively(successCallback, errorCallback);
+};
+
+DirectoryEntry.prototype.getFile = function (path, options, successCallback, errorCallback) {
+    argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
+    this.nativeEntry.getFile(path, options, function (entry) {
+        successCallback(fileUtils.createEntry(entry));
+    }, errorCallback);
+};
+
+module.exports = DirectoryEntry;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/DirectoryReader.js b/lib/blackberry10/plugin/DirectoryReader.js
new file mode 100644
index 0000000..8bb9968
--- /dev/null
+++ b/lib/blackberry10/plugin/DirectoryReader.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 FileError = require('cordova/plugin/FileError'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils');
+
+function DirectoryReader(path) {
+    this.path = path;
+}
+
+DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
+    var win = typeof successCallback !== 'function' ? null : function(result) {
+            var retVal = [];
+            for (var i=0; i<result.length; i++) {
+                retVal.push(fileUtils.createEntry(result[i]));
+            }
+            successCallback(retVal);
+        },
+        fail = typeof errorCallback !== 'function' ? null : function(code) {
+            errorCallback(new FileError(code));
+        };
+    fileUtils.getEntryForURI(this.path, function (entry) {
+        entry.nativeEntry.createReader().readEntries(win, fail);
+    }, function () {
+        fail(FileError.NOT_FOUND_ERR);
+    });
+};
+
+module.exports = DirectoryReader;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/Entry.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/Entry.js b/lib/blackberry10/plugin/Entry.js
new file mode 100644
index 0000000..f80e879
--- /dev/null
+++ b/lib/blackberry10/plugin/Entry.js
@@ -0,0 +1,118 @@
+/*
+ *
+ * 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 argscheck = require('cordova/argscheck'),
+    FileError = require('cordova/plugin/FileError'),
+    Metadata = require('cordova/plugin/Metadata'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils');
+
+function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
+    this.isFile = !!isFile;
+    this.isDirectory = !!isDirectory;
+    this.name = name || '';
+    this.fullPath = fullPath || '';
+    this.filesystem = fileSystem || null;
+}
+
+Entry.prototype.getMetadata = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
+    var success = function(lastModified) {
+        var metadata = new Metadata(lastModified);
+        if (typeof successCallback === 'function') {
+            successCallback(metadata);
+        }
+    };
+    this.nativeEntry.getMetadata(success, errorCallback);
+};
+
+Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
+    argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
+    errorCallback("Not supported by platform");
+};
+
+Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
+    argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
+    var fail = errorCallback && function(code) {
+            errorCallback(new FileError(code));
+        },
+        srcPath = this.fullPath,
+        name = newName || this.name,
+        success = function(entry) {
+            if (entry) {
+                if (successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
+                }
+            }
+            else {
+                if (typeof fail === 'function') {
+                    fail(FileError.NOT_FOUND_ERR);
+                }
+            }
+        };
+    this.nativeEntry.moveTo(parent.nativeEntry, newName, success, errorCallback);
+};
+
+
+Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
+    argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
+    var fail = errorCallback && function(code) {
+            errorCallback(new FileError(code));
+        },
+        srcPath = this.fullPath,
+        name = newName || this.name,
+        success = function(entry) {
+            if (entry) {
+                if (typeof successCallback === 'function') {
+                    successCallback(fileUtils.createEntry(entry));
+                }
+            }
+            else {
+                if (typeof fail === 'function') {
+                    fail(FileError.NOT_FOUND_ERR);
+                }
+            }
+        };
+    this.nativeEntry.copyTo(parent.nativeEntry, newName, success, errorCallback);
+};
+
+Entry.prototype.toURL = function() {
+    return this.fullPath;
+};
+
+Entry.prototype.toURI = function(mimeType) {
+    console.log("DEPRECATED: Update your code to use 'toURL'");
+    return this.toURL();
+};
+
+Entry.prototype.remove = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.remove', arguments);
+    this.nativeEntry.remove(successCallback, errorCallback);
+};
+
+Entry.prototype.getParent = function(successCallback, errorCallback) {
+    argscheck.checkArgs('FF', 'Entry.getParent', arguments);
+    var win = successCallback && function(result) {
+        successCallback(fileUtils.createEntry(result));
+    };
+    this.nativeEntry.getParent(win, errorCallback);
+};
+
+module.exports = Entry;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/FileEntry.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/FileEntry.js b/lib/blackberry10/plugin/FileEntry.js
new file mode 100644
index 0000000..17f9393
--- /dev/null
+++ b/lib/blackberry10/plugin/FileEntry.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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 utils = require('cordova/utils'),
+    Entry = require('cordova/plugin/Entry'),
+    FileWriter = require('cordova/plugin/FileWriter'),
+    File = require('cordova/plugin/File'),
+    FileError = require('cordova/plugin/FileError'),
+    FileEntry = function (name, fullPath) {
+        FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
+    };
+
+utils.extend(FileEntry, Entry);
+
+FileEntry.prototype.createWriter = function(successCallback, errorCallback) {
+    this.file(function (file) {
+        successCallback(new FileWriter(file));
+    }, errorCallback);
+};
+
+FileEntry.prototype.file = function(successCallback, errorCallback) {
+    var fullPath = this.fullPath,
+        success = function (file) {
+            successCallback(new File(file.name, fullPath, file.type, file.lastModifiedDate, file.size));
+        };
+    this.nativeEntry.file(success, errorCallback);
+};
+
+module.exports = FileEntry;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/FileReader.js b/lib/blackberry10/plugin/FileReader.js
new file mode 100644
index 0000000..c806b3f
--- /dev/null
+++ b/lib/blackberry10/plugin/FileReader.js
@@ -0,0 +1,98 @@
+/*
+ *
+ * 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 origFileReader = window.FileReader,
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    utils = require('cordova/utils');
+
+var FileReader = function() {
+    this.nativeReader = new origFileReader();
+};
+
+utils.defineGetter(FileReader.prototype, 'readyState', function() {
+    return this.nativeReader.readyState;
+});
+
+utils.defineGetter(FileReader.prototype, 'error', function() {
+    return this.nativeReader.error;
+});
+
+utils.defineGetter(FileReader.prototype, 'result', function() {
+    return this.nativeReader.result;
+});
+
+function defineEvent(eventName) {
+    utils.defineGetterSetter(FileReader.prototype, eventName, function() {
+        return this.nativeReader[eventName] || null;
+    }, function(value) {
+        this.nativeReader[eventName] = value;
+    });
+}
+
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onload');
+defineEvent('onloadend');
+defineEvent('onloadstart');
+defineEvent('onprogress');
+
+FileReader.prototype.abort = function() {
+    return this.nativeReader.abort();
+};
+
+FileReader.prototype.readAsText = function(file, encoding) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsText(nativeFile, encoding);
+        }, that.onerror);
+    }, that.onerror);
+};
+
+FileReader.prototype.readAsDataURL = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsDataURL(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
+
+FileReader.prototype.readAsBinaryString = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsBinaryString(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
+
+FileReader.prototype.readAsArrayBuffer = function(file) {
+    var that = this;
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.file(function (nativeFile) {
+            that.nativeReader.readAsArrayBuffer(nativeFile);
+        }, that.onerror);
+    }, that.onerror);
+};
+
+window.FileReader = FileReader;
+module.exports = FileReader;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/FileSystem.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/FileSystem.js b/lib/blackberry10/plugin/FileSystem.js
new file mode 100644
index 0000000..d1432d6
--- /dev/null
+++ b/lib/blackberry10/plugin/FileSystem.js
@@ -0,0 +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.
+ *
+*/
+
+module.exports = function(name, root) {
+    this.name = name || null;
+    if (root) {
+        this.root = root;
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/FileWriter.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/FileWriter.js b/lib/blackberry10/plugin/FileWriter.js
new file mode 100644
index 0000000..0f71d6a
--- /dev/null
+++ b/lib/blackberry10/plugin/FileWriter.js
@@ -0,0 +1,120 @@
+/*
+ *
+ * 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 FileError = require('cordova/plugin/FileError'),
+    ProgressEvent = require('cordova/plugin/ProgressEvent'),
+    fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    utils = require('cordova/utils');
+
+function FileWriter (file) {
+    var that = this;
+    this.file = file;
+    this.events = {};
+    this.pending = [];
+    fileUtils.getEntryForURI(file.fullPath, function (entry) {
+        entry.nativeEntry.createWriter(function (writer) {
+            var i,
+                event;
+            that.nativeWriter = writer;
+            for (event in that.events) {
+                if (that.events.hasOwnProperty(event)) {
+                    that.nativeWriter[event] = that.events[event];
+                }
+            }
+            for (i = 0; i < that.pending.length; i++) {
+                that.pending[i]();
+            }
+        });
+    });
+    this.events = {};
+    this.pending = [];
+}
+
+utils.defineGetter(FileWriter.prototype, 'error', function() {
+    return this.nativeWriter ? this.nativeWriter.error : null;
+});
+
+utils.defineGetter(FileWriter.prototype, 'fileName', function() {
+    return this.nativeWriter ? this.nativeWriter.fileName : this.file.name;
+});
+
+utils.defineGetter(FileWriter.prototype, 'length', function() {
+    return this.nativeWriter ? this.nativeWriter.length : this.file.size;
+});
+
+utils.defineGetter(FileWriter.prototype, 'position', function() {
+    return this.nativeWriter ? this.nativeWriter.position : 0;
+});
+
+utils.defineGetter(FileWriter.prototype, 'readyState', function() {
+    return this.nativeWriter ? this.nativeWriter.readyState : 0;
+});
+
+function defineEvent(eventName) {
+    utils.defineGetterSetter(FileWriter.prototype, eventName, function() {
+        return this.nativeWriter ? this.nativeWriter[eventName] || null : this.events[eventName] || null;
+    }, function(value) {
+        if (this.nativeWriter) {
+            this.nativeWriter[eventName] = value;
+        }
+        else {
+            this.events[eventName] = value;
+        }
+    });
+}
+
+defineEvent('onabort');
+defineEvent('onerror');
+defineEvent('onprogress');
+defineEvent('onwrite');
+defineEvent('onwriteend');
+defineEvent('onwritestart');
+
+FileWriter.prototype.abort = function() {
+    this.nativeWriter.abort();
+};
+
+FileWriter.prototype.write = function(text) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.write(new Blob([text]));
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+
+};
+
+FileWriter.prototype.seek = function(offset) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.seek(offset);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+};
+
+FileWriter.prototype.truncate = function(size) {
+    var that = this,
+        op = function () {
+            that.nativeWriter.truncate(size);
+        };
+    this.nativeWriter ? op() : this.pending.push(op);
+};
+
+module.exports = FileWriter;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/blackberry10/file.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/file.js b/lib/blackberry10/plugin/blackberry10/file.js
deleted file mode 100644
index d611daf..0000000
--- a/lib/blackberry10/plugin/blackberry10/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/f0fb6ec0/lib/blackberry10/plugin/blackberry10/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/fileTransfer.js b/lib/blackberry10/plugin/blackberry10/fileTransfer.js
index 6848516..c225433 100644
--- a/lib/blackberry10/plugin/blackberry10/fileTransfer.js
+++ b/lib/blackberry10/plugin/blackberry10/fileTransfer.js
@@ -21,9 +21,6 @@
 
 /*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:") {
@@ -69,7 +66,7 @@ module.exports = {
             headers = args[8];
 
         if (!checkURL(server)) {
-            fail(new FileTransferError(FileTransferError.INVALID_URL_ERR));
+            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR));
         }
 
         nativeResolveLocalFileSystemURI(filePath, function(entry) {
@@ -88,22 +85,22 @@ module.exports = {
                     xhr.open("POST", server);
                     xhr.onload = function(evt) {
                         if (xhr.status == 200) {
-                            var result = new FileUploadResult();
+                            var result = new window.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));
+                            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR, server, filePath, xhr.status));
                         } else {
-                            fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
+                            fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
                         }
                     };
                     xhr.ontimeout = function(evt) {
-                        fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
+                        fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, xhr.status));
                     };
                     xhr.onerror = function () {
-                        fail(new FileTransferError(FileTransferError.CONNECTION_ERR, server, filePath, this.status));
+                        fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, server, filePath, this.status));
                     };
                     xhr.onprogress = function (evt) {
                         win(evt);
@@ -133,10 +130,10 @@ module.exports = {
                     end = start + bytesPerChunk;
                 }
             }, function(error) {
-                fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
+                fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
             });
         }, function(error) {
-            fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
+            fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
         });
 
         return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
@@ -148,7 +145,7 @@ module.exports = {
             fileWriter;
 
         if (!checkURL(source)) {
-            fail(new FileTransferError(FileTransferError.INVALID_URL_ERR));
+            fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR));
         }
 
         xhr = new XMLHttpRequest();
@@ -158,7 +155,7 @@ module.exports = {
                 fileWriter = writer;
                 fileWriter.onwriteend = function (evt) {
                     if (!evt.target.error) {
-                        win(new FileEntry(entry.name, entry.toURL()));
+                        win(new window.FileEntry(entry.name, entry.toURL()));
                     } else {
                         fail(evt.target.error);
                     }
@@ -173,7 +170,7 @@ module.exports = {
         }
 
         xhr.onerror = function (e) {
-            fail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr.status));
+            fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, source, target, xhr.status));
         };
 
         xhr.onload = function () {
@@ -181,15 +178,15 @@ module.exports = {
                 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));
+                            fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
                         });
                     }, function (error) {
-                        fail(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
+                        fail(new window.FileTransferError(window.FileTransferError.FILE_NOT_FOUND_ERR));
                     });
                 } else if (xhr.status === 404) {
-                    fail(new FileTransferError(FileTransferError.INVALID_URL_ERR, source, target, xhr.status));
+                    fail(new window.FileTransferError(window.FileTransferError.INVALID_URL_ERR, source, target, xhr.status));
                 } else {
-                    fail(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target, xhr.status));
+                    fail(new window.FileTransferError(window.FileTransferError.CONNECTION_ERR, source, target, xhr.status));
                 }
             }
         };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/blackberry10/fileUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/fileUtils.js b/lib/blackberry10/plugin/blackberry10/fileUtils.js
new file mode 100644
index 0000000..e26e4e9
--- /dev/null
+++ b/lib/blackberry10/plugin/blackberry10/fileUtils.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * 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.
+ *
+ */
+
+function convertPath(url) {
+    return decodeURI(url).substring(11).replace(/\/$/, '');
+}
+
+module.exports = {
+
+    createEntry: function (entry) {
+        var cordovaEntry;
+        if (entry.isFile) {
+            cordovaEntry = new window.FileEntry(entry.name, convertPath(entry.toURL()));
+        } else {
+            cordovaEntry = new window.DirectoryEntry(entry.name, convertPath(entry.toURL()));
+        }
+        cordovaEntry.nativeEntry = entry;
+        return cordovaEntry;
+    },
+
+    getEntryForURI: function (uri, success, fail) {
+        //TODO: account for local vs file system
+        window.resolveLocalFileSystemURI(uri, success, fail);
+    },
+
+    getFileSystemName: function (fs) {
+        return (fs.name.indexOf('Persistent') != -1) ? 'persistent' : 'temporary';
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
index b1ab163..231d890 100644
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -54,6 +54,9 @@ module.exports = {
                     }
                 }
             }
+        },
+        File: {
+            path: 'cordova/plugin/File'
         }
     },
     merges: {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/blackberry10/pluginUtils.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/pluginUtils.js b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
index aa49077..ed41518 100644
--- a/lib/blackberry10/plugin/blackberry10/pluginUtils.js
+++ b/lib/blackberry10/plugin/blackberry10/pluginUtils.js
@@ -58,7 +58,7 @@ module.exports = {
             }
         }
         if (count === 0) {
-           callback();
+            callback();
         }
     },
 
@@ -85,4 +85,4 @@ module.exports = {
         };
         request.send(null);
     }
-}
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/blackberry10/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/requestFileSystem.js b/lib/blackberry10/plugin/blackberry10/requestFileSystem.js
deleted file mode 100644
index 18c64e5..0000000
--- a/lib/blackberry10/plugin/blackberry10/requestFileSystem.js
+++ /dev/null
@@ -1,39 +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.
- *
-*/
-
-function getFileSystemName(fs) {
-    return (fs.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 = function (type, size, success, fail) {
-    window.webkitRequestFileSystem(type, size, function (fs) {
-        success((new FileSystem(getFileSystemName(fs), makeEntry(fs.root))));
-    }, fail);
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/requestFileSystem.js b/lib/blackberry10/plugin/requestFileSystem.js
new file mode 100644
index 0000000..62e1753
--- /dev/null
+++ b/lib/blackberry10/plugin/requestFileSystem.js
@@ -0,0 +1,38 @@
+/*
+ *
+ * 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 fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    FileError = require('cordova/plugin/FileError'),
+    FileSystem = require('cordova/plugin/FileSystem');
+
+module.exports = function (type, size, success, fail) {
+    if (size >= 1000000000000000) {
+        fail(new FileError(FileError.QUOTA_EXCEEDED_ERR));
+    } else if (type !== 1 && type !== 0) {
+        fail(new FileError(FileError.SYNTAX_ERR));
+    } else {
+        window.webkitRequestFileSystem(type, size, function (fs) {
+            success((new FileSystem(fileUtils.getFileSystemName(fs), fileUtils.createEntry(fs.root))));
+        }, function (error) {
+            fail(new FileError(error));
+        });
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/lib/blackberry10/plugin/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/resolveLocalFileSystemURI.js b/lib/blackberry10/plugin/resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..d11b0ca
--- /dev/null
+++ b/lib/blackberry10/plugin/resolveLocalFileSystemURI.js
@@ -0,0 +1,55 @@
+/*
+ *
+ * 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 fileUtils = require('cordova/plugin/blackberry10/fileUtils'),
+    FileError = require('cordova/plugin/FileError');
+
+module.exports = function (uri, success, fail) {
+    var type,
+        path,
+        paramPath;
+    if (!uri || uri.indexOf("/") === 0) {
+        fail(new FileError(FileError.ENCODING_ERR));
+    } else {
+        type = uri.indexOf("persistent") === -1 ? 0 : 1;
+        path = uri.substring(type === 1 ? uri.indexOf("persistent") + 11 : uri.indexOf("temporary") + 10);
+        if (path.substring(0,1) == "/") {
+            path = path.substring(1);
+        }
+        paramPath = path.indexOf("?");
+        if (paramPath > -1) {
+            path = path.substring(0, paramPath);
+        }
+        window.webkitRequestFileSystem(type, 25*1024*1024, function (fs) {
+            if (path === "") {
+                success(fileUtils.createEntry(fs.root));
+            } else {
+                fs.root.getDirectory(path, {}, function (entry) {
+                    success(fileUtils.createEntry(entry));
+                }, function () {
+                    fs.root.getFile(path, {}, function (entry) {
+                        success(fileUtils.createEntry(entry));
+                    }, fail);
+                });
+            }
+        }, fail);
+    }
+};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f0fb6ec0/test/blackberry10/test.fileTransfer.js
----------------------------------------------------------------------
diff --git a/test/blackberry10/test.fileTransfer.js b/test/blackberry10/test.fileTransfer.js
deleted file mode 100644
index 1d7ed57..0000000
--- a/test/blackberry10/test.fileTransfer.js
+++ /dev/null
@@ -1,85 +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.
- *
-*/
-
-describe("blackberry10 fileTransfer", function () {
-    var fileTransfer = require('cordova/plugin/blackberry10/fileTransfer'),
-        cordova = require('cordova'),
-        win = jasmine.createSpy('win'),
-        fail = jasmine.createSpy('fail')
-        xhrSend = jasmine.createSpy('xhr send');
-        xhrOpen = jasmine.createSpy('xhr open');
-
-    beforeEach(function () {
-        global.blackberry = {
-            io:{
-                filetransfer: {
-                    download: jasmine.createSpy('download'),
-                    upload: jasmine.createSpy('upload')
-                }
-            }
-        };
-        XMLHttpRequest = function () {
-            var xhr = {
-                send: xhrSend,
-                open: xhrOpen
-            };
-            return xhr;
-        };
-        window.webkitResolveLocalFileSystemURL = jasmine.createSpy("resolveFS")
-    });
-
-    afterEach(function () {
-        delete global.blackberry;
-        delete XMLHttpRequest;
-        delete webkitResolveLocalFileSystemURL;
-        delete window.webkitResolveLocalFileSystemURL;
-    });
-
-    describe("download", function(){
-        it('should call the blackberry download', function () {
-            fileTransfer.download(["source/file", "target/file"], win, fail);
-            expect(xhrOpen).toHaveBeenCalled();
-            expect(xhrSend).toHaveBeenCalled();
-        });
-
-        it('should return No Result', function(){
-            expect(fileTransfer.download(["location/source", "location/place/here"], win, fail)).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "async"
-            });
-        });
-    });
-
-    describe('upload', function(){
-        it('should call the blackberry upload', function(){
-            fileTransfer.upload(["source", "target", "fileKey", "fileName", "mimeType", "params", "chunkedMode"], win, fail);
-            expect(xhrOpen).toHaveBeenCalled();
-            expect(xhrSend).toHaveBeenCalled();
-        });
-
-        it('should return No Result', function(){
-            expect(fileTransfer.upload(["location/source", "location/place/here"], win, fail)).toEqual({
-                status: cordova.callbackStatus.NO_RESULT,
-                message: "async"
-            });
-        });
-    });
-});


[17/32] js commit: [BlackBerry10] Revert the move of webworks.exec so that plugins that rely on it can be built properly.

Posted by lo...@apache.org.
[BlackBerry10] Revert the move of webworks.exec so that plugins that rely on it can be
built properly.

Reviewed by Bryan Higgins <bh...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/8b8e7bb0
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/8b8e7bb0
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/8b8e7bb0

Branch: refs/heads/future
Commit: 8b8e7bb07ef91e2d22202f8109a2f88b4cc6ec6b
Parents: 56c5314
Author: Jeffrey Heifetz <jh...@blackberry.com>
Authored: Thu Mar 28 22:38:53 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:49:38 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js              |   78 +---------------------------
 lib/scripts/bootstrap-blackberry10.js |   77 +++++++++++++++++++++++++++
 2 files changed, 78 insertions(+), 77 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8b8e7bb0/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index 25ec0ae..5aa81c3 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -28,6 +28,7 @@ var cordova = require('cordova'),
         'Logger' : require('cordova/plugin/blackberry10/logger'),
         'Notification' : require('cordova/plugin/blackberry10/notification'),
         'Media': require('cordova/plugin/blackberry10/media'),
+        'File' : require('cordova/plugin/blackberry10/file'),
         'InAppBrowser' : require('cordova/plugin/blackberry10/InAppBrowser'),
         'FileTransfer': require('cordova/plugin/blackberry10/fileTransfer')
     };
@@ -52,80 +53,3 @@ module.exports = function (success, fail, service, action, args) {
     }
     return webworks.exec(success, fail, service, action, args);
 };
-
-function RemoteFunctionCall(functionUri) {
-     var params = {};
-
-    function composeUri() {
-        return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
-    }
-
-    function createXhrRequest(uri, isAsync) {
-        var request = new XMLHttpRequest();
-        request.open("POST", uri, isAsync);
-        request.setRequestHeader("Content-Type", "application/json");
-        return request;
-    }
-
-    this.addParam = function (name, value) {
-        params[name] = encodeURIComponent(JSON.stringify(value));
-    };
-
-    this.makeSyncCall = function (success, error) {
-        var requestUri = composeUri(),
-            request = createXhrRequest(requestUri, false),
-            response,
-            errored,
-            cb,
-            data;
-
-        request.send(JSON.stringify(params));
-        response = JSON.parse(decodeURIComponent(request.responseText) || "null");
-        return response;
-    };
-}
-
-window.webworks = {
-    exec: function (success, fail, service, action, args) {
-        var uri = service + "/" + action,
-            request = new RemoteFunctionCall(uri),
-            callbackId = service + cordova.callbackId++,
-            response,
-            name,
-            didSucceed;
-
-        for (name in args) {
-            if (Object.hasOwnProperty.call(args, name)) {
-                request.addParam(name, args[name]);
-            }
-        }
-
-        cordova.callbacks[callbackId] = {success:success, fail:fail};
-        request.addParam("callbackId", callbackId);
-
-        response = request.makeSyncCall();
-
-        //Old WebWorks Extension success
-        if (response.code === 42) {
-            if (success) {
-                success(response.data, response);
-            }
-            delete cordova.callbacks[callbackId];
-        } else if (response.code < 0) {
-            if (fail) {
-                fail(response.msg, response);
-            }
-            delete cordova.callbacks[callbackId];
-        } else {
-            didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-            cordova.callbackFromNative(callbackId, didSucceed, response.code, didSucceed ? response.data : response.msg, !!response.keepCallback);
-        }
-    },
-    defineReadOnlyField: function (obj, field, value) {
-        Object.defineProperty(obj, field, {
-            "value": value,
-            "writable": false
-        });
-    },
-    event: require("cordova/plugin/blackberry10/event")
-};

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/8b8e7bb0/lib/scripts/bootstrap-blackberry10.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry10.js b/lib/scripts/bootstrap-blackberry10.js
index e1c2b83..e359a15 100644
--- a/lib/scripts/bootstrap-blackberry10.js
+++ b/lib/scripts/bootstrap-blackberry10.js
@@ -47,6 +47,83 @@
         }
     };
 
+    function RemoteFunctionCall(functionUri) {
+        var params = {};
+
+        function composeUri() {
+            return require("cordova/plugin/blackberry10/utils").getURIPrefix() + functionUri;
+        }
+
+        function createXhrRequest(uri, isAsync) {
+            var request = new XMLHttpRequest();
+            request.open("POST", uri, isAsync);
+            request.setRequestHeader("Content-Type", "application/json");
+            return request;
+        }
+
+        this.addParam = function (name, value) {
+            params[name] = encodeURIComponent(JSON.stringify(value));
+        };
+
+        this.makeSyncCall = function (success, error) {
+            var requestUri = composeUri(),
+            request = createXhrRequest(requestUri, false),
+            response,
+            errored,
+            cb,
+            data;
+
+            request.send(JSON.stringify(params));
+            response = JSON.parse(decodeURIComponent(request.responseText) || "null");
+            return response;
+        };
+    }
+
+    window.webworks = {
+        exec: function (success, fail, service, action, args) {
+            var uri = service + "/" + action,
+            request = new RemoteFunctionCall(uri),
+            callbackId = service + cordova.callbackId++,
+            response,
+            name,
+            didSucceed;
+
+            for (name in args) {
+                if (Object.hasOwnProperty.call(args, name)) {
+                    request.addParam(name, args[name]);
+                }
+            }
+
+            cordova.callbacks[callbackId] = {success:success, fail:fail};
+            request.addParam("callbackId", callbackId);
+
+            response = request.makeSyncCall();
+
+            //Old WebWorks Extension success
+            if (response.code === 42) {
+                if (success) {
+                    success(response.data, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else if (response.code < 0) {
+                if (fail) {
+                    fail(response.msg, response);
+                }
+                delete cordova.callbacks[callbackId];
+            } else {
+                didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
+                cordova.callbackFromNative(callbackId, didSucceed, response.code, didSucceed ? response.data : response.msg, !!response.keepCallback);
+            }
+        },
+        defineReadOnlyField: function (obj, field, value) {
+            Object.defineProperty(obj, field, {
+                "value": value,
+                "writable": false
+            });
+        },
+        event: require("cordova/plugin/blackberry10/event")
+    };
+
     //Fire webworks ready once plugin javascript has been loaded
     pluginUtils.getPlugins(
         function (plugins) {


[23/32] js commit: [BlackBerry10] Remove accelerometer from exec

Posted by lo...@apache.org.
[BlackBerry10] Remove accelerometer from exec


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/f4f3f4be
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/f4f3f4be
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/f4f3f4be

Branch: refs/heads/future
Commit: f4f3f4be47e09db6096193d945d9326f484ed2de
Parents: df382c0
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Fri Apr 12 11:33:44 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/exec.js                         |    1 -
 lib/blackberry10/plugin/blackberry10/platform.js |    3 ---
 2 files changed, 0 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f4f3f4be/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index ad9c673..efa3729 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -21,7 +21,6 @@
 
 var cordova = require('cordova'),
     plugins = {
-        'Accelerometer' : require('cordova/plugin/blackberry10/accelerometer'),
         'Compass' : require('cordova/plugin/blackberry10/magnetometer'),
         'Capture' : require('cordova/plugin/blackberry10/capture'),
         'Media': require('cordova/plugin/blackberry10/media'),

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/f4f3f4be/lib/blackberry10/plugin/blackberry10/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/blackberry10/platform.js b/lib/blackberry10/plugin/blackberry10/platform.js
index b283554..b1ab163 100644
--- a/lib/blackberry10/plugin/blackberry10/platform.js
+++ b/lib/blackberry10/plugin/blackberry10/platform.js
@@ -44,9 +44,6 @@ module.exports = {
         });
     },
     clobbers: {
-        requestFileSystem: {
-            path: "cordova/plugin/blackberry10/requestFileSystem"
-        },
         navigator: {
             children: {
                 notification: {


[21/32] js commit: [BlackBerry10] FileReader - handle case where native file object is passed in

Posted by lo...@apache.org.
[BlackBerry10] FileReader - handle case where native file object is passed in

Reviewed by Jeffrey Heifetz <jh...@blackberry.com>
Tested by Tracy Li <tl...@blackberry.com>


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/369e1aff
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/369e1aff
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/369e1aff

Branch: refs/heads/future
Commit: 369e1aff171ee589366cc79d0736991dc5e23536
Parents: 5be2dab
Author: Bryan Higgins <bh...@blackberry.com>
Authored: Thu Apr 18 13:49:57 2013 -0400
Committer: Bryan Higgins <bh...@blackberry.com>
Committed: Fri May 3 09:50:04 2013 -0400

----------------------------------------------------------------------
 lib/blackberry10/plugin/FileReader.js |   40 +++++++++++----------------
 1 files changed, 16 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/369e1aff/lib/blackberry10/plugin/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/plugin/FileReader.js b/lib/blackberry10/plugin/FileReader.js
index c806b3f..17214ef 100644
--- a/lib/blackberry10/plugin/FileReader.js
+++ b/lib/blackberry10/plugin/FileReader.js
@@ -58,40 +58,32 @@ FileReader.prototype.abort = function() {
     return this.nativeReader.abort();
 };
 
+function read(method, context, file, encoding) {
+    if (file.fullPath) {
+         fileUtils.getEntryForURI(file.fullPath, function (entry) {
+            entry.nativeEntry.file(function (nativeFile) {
+                context.nativeReader[method].call(context.nativeReader, nativeFile, encoding);
+            }, context.onerror);
+        }, context.onerror);
+    } else {
+        context.nativeReader[method](file, encoding);
+    }
+}
+
 FileReader.prototype.readAsText = function(file, encoding) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsText(nativeFile, encoding);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsText", this, file, encoding);
 };
 
 FileReader.prototype.readAsDataURL = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsDataURL(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsDataURL", this, file);
 };
 
 FileReader.prototype.readAsBinaryString = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsBinaryString(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsBinaryString", this, file);
 };
 
 FileReader.prototype.readAsArrayBuffer = function(file) {
-    var that = this;
-    fileUtils.getEntryForURI(file.fullPath, function (entry) {
-        entry.nativeEntry.file(function (nativeFile) {
-            that.nativeReader.readAsArrayBuffer(nativeFile);
-        }, that.onerror);
-    }, that.onerror);
+    read("readAsArrayBuffer", this, file);
 };
 
 window.FileReader = FileReader;