You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by gt...@apache.org on 2012/11/02 14:31:14 UTC
[3/5] Refactored BlackBerry into one javascript file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/compass.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/compass.js b/lib/blackberry/plugin/qnx/compass.js
new file mode 100644
index 0000000..061ceb5
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/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/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/device.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/device.js b/lib/blackberry/plugin/qnx/device.js
new file mode 100644
index 0000000..ca21d68
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/device.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 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: "BB10",
+ version: blackberry.system.softwareVersion,
+ name: "Dev Alpha",
+ uuid: blackberry.identity.uuid,
+ cordova: "2.2.0"
+ });
+
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "Device info returned" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/fileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/fileTransfer.js b/lib/blackberry/plugin/qnx/fileTransfer.js
new file mode 100644
index 0000000..0433f0c
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/fileTransfer.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 cordova = require('cordova');
+
+module.exports = {
+ download: function (args, win, fail) {
+ var source = args[0],
+ target = args[1];
+
+ blackberry.io.filetransfer.download(source, target, win, fail);
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
+ },
+
+ upload: function (args, win, fail) {
+ var path = args[0],
+ server = args[1],
+ options = {
+ fileKey: args[2],
+ fileName: args[3],
+ mimeType: args[4],
+ params: args[5],
+ chunkedMode: args[6]
+ };
+
+ blackberry.io.filetransfer.upload(path, server, win, fail, options);
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "async"};
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/magnetometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/magnetometer.js b/lib/blackberry/plugin/qnx/magnetometer.js
new file mode 100644
index 0000000..f636ac0
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/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.NO_RESULT, "message" : "WebWorks Is On It" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/manager.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/manager.js b/lib/blackberry/plugin/qnx/manager.js
new file mode 100644
index 0000000..3497da5
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/manager.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 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'),
+ 'FileTransfer': require('cordova/plugin/qnx/fileTransfer')
+ };
+
+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 };
+ }
+ }
+
+ return result;
+ },
+ resume: function () {},
+ pause: function () {},
+ destroy: function () {}
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/network.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/network.js b/lib/blackberry/plugin/qnx/network.js
new file mode 100644
index 0000000..4df3e38
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/network.js
@@ -0,0 +1,29 @@
+/*
+ *
+ * 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'),
+ connection = require('cordova/plugin/Connection');
+
+module.exports = {
+ getConnectionInfo: function (args, win, fail) {
+ return { "status": cordova.callbackStatus.OK, "message": blackberry.connection.type};
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/platform.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/platform.js b/lib/blackberry/plugin/qnx/platform.js
new file mode 100644
index 0000000..21d050f
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/platform.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.
+ *
+*/
+
+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");
+ });
+ });
+ },
+ objects: {
+ requestFileSystem:{
+ path: 'cordova/plugin/qnx/requestFileSystem'
+ },
+ resolveLocalFileSystemURI:{
+ path: 'cordova/plugin/qnx/resolveLocalFileSystemURI'
+ }
+ },
+ merges: {
+ navigator: {
+ children: {
+ compass: {
+ path: 'cordova/plugin/qnx/compass'
+ }
+ }
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/requestFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/requestFileSystem.js b/lib/blackberry/plugin/qnx/requestFileSystem.js
new file mode 100644
index 0000000..36524a0
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/requestFileSystem.js
@@ -0,0 +1,22 @@
+/*
+ *
+ * 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 = window.webkitRequestFileSystem;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/qnx/resolveLocalFileSystemURI.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/qnx/resolveLocalFileSystemURI.js b/lib/blackberry/plugin/qnx/resolveLocalFileSystemURI.js
new file mode 100644
index 0000000..f0b29d2
--- /dev/null
+++ b/lib/blackberry/plugin/qnx/resolveLocalFileSystemURI.js
@@ -0,0 +1,22 @@
+/*
+ *
+ * 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 = window.webkitResolveLocalFileSystemURI;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/webworks/accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/accelerometer.js b/lib/blackberry/plugin/webworks/accelerometer.js
new file mode 100644
index 0000000..90dc0e7
--- /dev/null
+++ b/lib/blackberry/plugin/webworks/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.NO_RESULT, "message" : "WebWorks Is On It" };
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/webworks/logger.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/logger.js b/lib/blackberry/plugin/webworks/logger.js
new file mode 100644
index 0000000..bd47a1e
--- /dev/null
+++ b/lib/blackberry/plugin/webworks/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/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/webworks/media.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/media.js b/lib/blackberry/plugin/webworks/media.js
new file mode 100644
index 0000000..2499aea
--- /dev/null
+++ b/lib/blackberry/plugin/webworks/media.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.
+ *
+*/
+
+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];
+
+ 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) {
+ 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"};
+ }
+
+ var id = args[0],
+ audio = audioObjects[id],
+ result;
+
+ if (args.length <= 1) {
+ result = {"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) {
+ audioObjects[id] = undefined;
+ audio.src = undefined;
+ //delete audio;
+ }
+
+ result = {"status" : 1, "message" : "Media resources released"};
+
+ return result;
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/blackberry/plugin/webworks/notification.js
----------------------------------------------------------------------
diff --git a/lib/blackberry/plugin/webworks/notification.js b/lib/blackberry/plugin/webworks/notification.js
new file mode 100644
index 0000000..9de87b8
--- /dev/null
+++ b/lib/blackberry/plugin/webworks/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/incubator-cordova-js/blob/0919268c/lib/scripts/bootstrap-blackberry.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-blackberry.js b/lib/scripts/bootstrap-blackberry.js
new file mode 100644
index 0000000..58f0f51
--- /dev/null
+++ b/lib/scripts/bootstrap-blackberry.js
@@ -0,0 +1,35 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+switch(require('cordova/platform').runtime()) {
+case 'qnx':
+ console.log('booting!');
+ document.addEventListener("webworksready", function () {
+ require('cordova/channel').onNativeReady.fire();
+ });
+ break;
+case 'air':
+ require('cordova/channel').onNativeReady.fire();
+ break;
+case 'java':
+ //nothing to do for java
+ break;
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/scripts/bootstrap-playbook.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-playbook.js b/lib/scripts/bootstrap-playbook.js
deleted file mode 100644
index 91a6f71..0000000
--- a/lib/scripts/bootstrap-playbook.js
+++ /dev/null
@@ -1,22 +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.
- *
-*/
-
-require('cordova/channel').onNativeReady.fire();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/scripts/bootstrap-qnx.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap-qnx.js b/lib/scripts/bootstrap-qnx.js
deleted file mode 100644
index ace4a6d..0000000
--- a/lib/scripts/bootstrap-qnx.js
+++ /dev/null
@@ -1,24 +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.
- *
-*/
-
-document.addEventListener("webworksready", function () {
- require('cordova/channel').onNativeReady.fire();
-});
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/scripts/bootstrap.js
----------------------------------------------------------------------
diff --git a/lib/scripts/bootstrap.js b/lib/scripts/bootstrap.js
index 7887e7b..02a0319 100644
--- a/lib/scripts/bootstrap.js
+++ b/lib/scripts/bootstrap.js
@@ -48,9 +48,7 @@
// Merge the platform-specific overrides/enhancements into
// the window object.
- if (typeof platform.merges !== 'undefined') {
- builder.build(platform.merges).intoAndMerge(window);
- }
+ builder.build(platform.merges).intoAndMerge(window);
// Call the platform-specific initialization
platform.initialize();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/platform.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/platform.js b/lib/webworks/air/platform.js
deleted file mode 100644
index bfa236d..0000000
--- a/lib/webworks/air/platform.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.
- *
-*/
-
-module.exports = {
- id: "playbook",
- initialize:function() {},
- objects: {
- DirectoryReader:{
- path: 'cordova/plugin/air/DirectoryReader'
- },
- File:{
- path: 'cordova/plugin/air/File'
- },
- FileReader:{
- path: 'cordova/plugin/air/FileReader'
- },
- FileWriter:{
- path: 'cordova/plugin/air/FileWriter'
- },
- requestFileSystem:{
- path: 'cordova/plugin/air/requestFileSystem'
- },
- resolveLocalFileSystemURI:{
- path: 'cordova/plugin/air/resolveLocalFileSystemURI'
- }
- },
- merges: {
- DirectoryEntry: {
- path: 'cordova/plugin/air/DirectoryEntry'
- },
- Entry: {
- path: 'cordova/plugin/air/Entry'
- },
- FileEntry:{
- path: 'cordova/plugin/air/FileEntry'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/DirectoryEntry.js b/lib/webworks/air/plugin/air/DirectoryEntry.js
deleted file mode 100644
index bb74f9f..0000000
--- a/lib/webworks/air/plugin/air/DirectoryEntry.js
+++ /dev/null
@@ -1,278 +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 DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- DirectoryReader = require('cordova/plugin/air/DirectoryReader'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError');
-
-var validFileRe = new RegExp('^[a-zA-Z][0-9a-zA-Z._ ]*$');
-
-module.exports = {
- createReader : function() {
- return new DirectoryReader(this.fullPath);
- },
- /**
- * Creates or looks up a directory; override for BlackBerry.
- *
- * @param path
- * {DOMString} either a relative or absolute path from this
- * directory in which to look up or create a directory
- * @param options
- * {Flags} options to create or exclusively create the directory
- * @param successCallback
- * {Function} called with the new DirectoryEntry
- * @param errorCallback
- * {Function} called with a FileError
- */
- getDirectory : function(path, options, successCallback, errorCallback) {
- // create directory if it doesn't exist
- var create = (options && options.create === true) ? true : false,
- // if true, causes failure if create is true and path already exists
- exclusive = (options && options.exclusive === true) ? true : false,
- // directory exists
- exists,
- // create a new DirectoryEntry object and invoke success callback
- createEntry = function() {
- var path_parts = path.split('/'),
- name = path_parts[path_parts.length - 1],
- dirEntry = new DirectoryEntry(name, path);
-
- // invoke success callback
- if (typeof successCallback === 'function') {
- successCallback(dirEntry);
- }
- };
-
- var fail = function(error) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
- }
- };
-
- // invalid path
- if(!validFileRe.exec(path)){
- fail(FileError.ENCODING_ERR);
- return;
- }
-
- // determine if path is relative or absolute
- if (!path) {
- fail(FileError.ENCODING_ERR);
- return;
- } else if (path.indexOf(this.fullPath) !== 0) {
- // path does not begin with the fullPath of this directory
- // therefore, it is relative
- path = this.fullPath + '/' + path;
- }
-
- // determine if directory exists
- try {
- // will return true if path exists AND is a directory
- exists = blackberry.io.dir.exists(path);
- } catch (e) {
- // invalid path
- // TODO this will not work on playbook - need to think how to find invalid urls
- fail(FileError.ENCODING_ERR);
- return;
- }
-
-
- // path is a directory
- if (exists) {
- if (create && exclusive) {
- // can't guarantee exclusivity
- fail(FileError.PATH_EXISTS_ERR);
- } else {
- // create entry for existing directory
- createEntry();
- }
- }
- // will return true if path exists AND is a file
- else if (blackberry.io.file.exists(path)) {
- // the path is a file
- fail(FileError.TYPE_MISMATCH_ERR);
- }
- // path does not exist, create it
- else if (create) {
- try {
- // directory path must have trailing slash
- var dirPath = path;
- if (dirPath.substr(-1) !== '/') {
- dirPath += '/';
- }
- console.log('creating dir path at: ' + dirPath);
- blackberry.io.dir.createNewDir(dirPath);
- createEntry();
- } catch (eone) {
- // unable to create directory
- fail(FileError.NOT_FOUND_ERR);
- }
- }
- // path does not exist, don't create
- else {
- // directory doesn't exist
- fail(FileError.NOT_FOUND_ERR);
- }
- },
-
- /**
- * Create or look up a file.
- *
- * @param path {DOMString}
- * either a relative or absolute path from this directory in
- * which to look up or create a file
- * @param options {Flags}
- * options to create or exclusively create the file
- * @param successCallback {Function}
- * called with the new FileEntry object
- * @param errorCallback {Function}
- * called with a FileError object if error occurs
- */
- getFile : function(path, options, successCallback, errorCallback) {
- // create file if it doesn't exist
- var create = (options && options.create === true) ? true : false,
- // if true, causes failure if create is true and path already exists
- exclusive = (options && options.exclusive === true) ? true : false,
- // file exists
- exists,
- // create a new FileEntry object and invoke success callback
- createEntry = function() {
- var path_parts = path.split('/'),
- name = path_parts[path_parts.length - 1],
- fileEntry = new FileEntry(name, path);
-
- // invoke success callback
- if (typeof successCallback === 'function') {
- successCallback(fileEntry);
- }
- };
-
- var fail = function(error) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
- }
- };
-
- // invalid path
- if(!validFileRe.exec(path)){
- fail(FileError.ENCODING_ERR);
- return;
- }
- // determine if path is relative or absolute
- if (!path) {
- fail(FileError.ENCODING_ERR);
- return;
- }
- else if (path.indexOf(this.fullPath) !== 0) {
- // path does not begin with the fullPath of this directory
- // therefore, it is relative
- path = this.fullPath + '/' + path;
- }
-
- // determine if file exists
- try {
- // will return true if path exists AND is a file
- exists = blackberry.io.file.exists(path);
- }
- catch (e) {
- // invalid path
- fail(FileError.ENCODING_ERR);
- return;
- }
-
- // path is a file
- if (exists) {
- if (create && exclusive) {
- // can't guarantee exclusivity
- fail(FileError.PATH_EXISTS_ERR);
- }
- else {
- // create entry for existing file
- createEntry();
- }
- }
- // will return true if path exists AND is a directory
- else if (blackberry.io.dir.exists(path)) {
- // the path is a directory
- fail(FileError.TYPE_MISMATCH_ERR);
- }
- // path does not exist, create it
- else if (create) {
- // create empty file
- var emptyBlob = blackberry.utils.stringToBlob('');
- blackberry.io.file.saveFile(path,emptyBlob);
- createEntry();
- }
- // path does not exist, don't create
- else {
- // file doesn't exist
- fail(FileError.NOT_FOUND_ERR);
- }
- },
-
- /**
- * Delete a directory and all of it's contents.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
- removeRecursively : function(successCallback, errorCallback) {
- // we're removing THIS directory
- var path = this.fullPath;
-
- var fail = function(error) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
- }
- };
-
- // attempt to delete directory
- if (blackberry.io.dir.exists(path)) {
- // it is an error to attempt to remove the file system root
- //exec(null, null, "File", "isFileSystemRoot", [ path ]) === true
- if (false) {
- fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
- }
- else {
- try {
- // delete the directory, setting recursive flag to true
- blackberry.io.dir.deleteDirectory(path, true);
- if (typeof successCallback === "function") {
- successCallback();
- }
- } catch (e) {
- // permissions don't allow deletion
- console.log(e);
- fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
- }
- }
- }
- // it's a file, not a directory
- else if (blackberry.io.file.exists(path)) {
- fail(FileError.TYPE_MISMATCH_ERR);
- }
- // not found
- else {
- fail(FileError.NOT_FOUND_ERR);
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/DirectoryReader.js b/lib/webworks/air/plugin/air/DirectoryReader.js
deleted file mode 100644
index fcd701e..0000000
--- a/lib/webworks/air/plugin/air/DirectoryReader.js
+++ /dev/null
@@ -1,90 +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 FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface that lists the files and directories in a directory.
- */
-function DirectoryReader(path) {
- this.path = path || null;
-}
-
-/**
- * Returns a list of entries from a directory.
- *
- * @param {Function} successCallback is called with a list of entries
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var retVal = [];
- for (var i=0; i<result.length; i++) {
- var entry = null;
- if (result[i].isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result[i].isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result[i].isDirectory;
- entry.isFile = result[i].isFile;
- entry.name = result[i].name;
- entry.fullPath = result[i].fullPath;
- retVal.push(entry);
- }
- successCallback(retVal);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
-
- var theEntries = [];
- // Entry object is borked - unable to instantiate a new Entry object so just create one
- var anEntry = function (isDirectory, name, fullPath) {
- this.isDirectory = (isDirectory ? true : false);
- this.isFile = (isDirectory ? false : true);
- this.name = name;
- this.fullPath = fullPath;
- };
-
- if(blackberry.io.dir.exists(this.path)){
- var theDirectories = blackberry.io.dir.listDirectories(this.path);
- var theFiles = blackberry.io.dir.listFiles(this.path);
-
- var theDirectoriesLength = theDirectories.length;
- var theFilesLength = theFiles.length;
- for(var i=0;i<theDirectoriesLength;i++){
- theEntries.push(new anEntry(true, theDirectories[i], this.path+theDirectories[i]));
- }
-
- for(var j=0;j<theFilesLength;j++){
- theEntries.push(new anEntry(false, theFiles[j], this.path+theFiles[j]));
- }
- win(theEntries);
- }else{
- fail(FileError.NOT_FOUND_ERR);
- }
-
-
-};
-
-module.exports = DirectoryReader;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/Entry.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/Entry.js b/lib/webworks/air/plugin/air/Entry.js
deleted file mode 100644
index 1eb7360..0000000
--- a/lib/webworks/air/plugin/air/Entry.js
+++ /dev/null
@@ -1,375 +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 FileError = require('cordova/plugin/FileError'),
- LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
- Metadata = require('cordova/plugin/Metadata'),
- resolveLocalFileSystemURI = require('cordova/plugin/air/resolveLocalFileSystemURI'),
- DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- requestFileSystem = require('cordova/plugin/air/requestFileSystem');
-
-var recursiveCopy = function(srcDirPath, dstDirPath){
- // get all the contents (file+dir) of the dir
- var files = blackberry.io.dir.listFiles(srcDirPath);
- var dirs = blackberry.io.dir.listDirectories(srcDirPath);
-
- for(var i=0;i<files.length;i++){
- blackberry.io.file.copy(srcDirPath + '/' + files[i], dstDirPath + '/' + files[i]);
- }
-
- for(var j=0;j<dirs.length;j++){
- if(!blackberry.io.dir.exists(dstDirPath + '/' + dirs[j])){
- blackberry.io.dir.createNewDir(dstDirPath + '/' + dirs[j]);
- }
- recursiveCopy(srcDirPath + '/' + dirs[j], dstDirPath + '/' + dirs[j]);
- }
-};
-
-var validFileRe = new RegExp('^[a-zA-Z][0-9a-zA-Z._ ]*$');
-
-module.exports = {
- getMetadata : function(successCallback, errorCallback){
- var success = typeof successCallback !== 'function' ? null : function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
-
- if(this.isFile){
- if(blackberry.io.file.exists(this.fullPath)){
- var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
- success(theFileProperties.dateModified);
- }
- }else{
- console.log('Unsupported for directories');
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- },
-
- setMetadata : function(successCallback, errorCallback , metadataObject){
- console.log('setMetadata is unsupported for PlayBook');
- },
-
- moveTo : function(parent, newName, successCallback, errorCallback){
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
- };
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (typeof successCallback === 'function') {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
-
- // Entry object is borked
- var theEntry = {};
- var dstPath = parent.fullPath + '/' + name;
-
- // invalid path
- if(!validFileRe.exec(name)){
- fail(FileError.ENCODING_ERR);
- return;
- }
-
- if(this.isFile){
- if(srcPath != dstPath){
- if(blackberry.io.file.exists(dstPath)){
- blackberry.io.file.deleteFile(dstPath);
- blackberry.io.file.copy(srcPath,dstPath);
- blackberry.io.file.deleteFile(srcPath);
-
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = false;
- theEntry.isFile = true;
- success(theEntry);
- }else if(blackberry.io.dir.exists(dstPath)){
- // destination path is a directory
- fail(FileError.INVALID_MODIFICATION_ERR);
- }else{
- // make sure the directory that we are moving to actually exists
- if(blackberry.io.dir.exists(parent.fullPath)){
- blackberry.io.file.copy(srcPath,dstPath);
- blackberry.io.file.deleteFile(srcPath);
-
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = false;
- theEntry.isFile = true;
- success(theEntry);
- }else{
- fail(FileError.NOT_FOUND_ERR);
- }
- }
- }else{
- // file onto itself
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }else{
- if(srcPath != dstPath){
- if(blackberry.io.file.exists(dstPath) || srcPath == parent.fullPath){
- // destination path is either a file path or moving into parent
- fail(FileError.INVALID_MODIFICATION_ERR);
- }else{
- if(!blackberry.io.dir.exists(dstPath)){
- blackberry.io.dir.createNewDir(dstPath);
- recursiveCopy(srcPath,dstPath);
- blackberry.io.dir.deleteDirectory(srcPath, true);
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = true;
- theEntry.isFile = false;
- success(theEntry);
- }else{
- var numOfEntries = 0;
- numOfEntries += blackberry.io.dir.listDirectories(dstPath).length;
- numOfEntries += blackberry.io.dir.listFiles(dstPath).length;
- if(numOfEntries === 0){
- blackberry.io.dir.createNewDir(dstPath);
- recursiveCopy(srcPath,dstPath);
- blackberry.io.dir.deleteDirectory(srcPath, true);
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = true;
- theEntry.isFile = false;
- success(theEntry);
- }else{
- // destination directory not empty
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }
- }
- }else{
- // directory onto itself
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }
-
- },
-
- copyTo : function(parent, newName, successCallback, errorCallback) {
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
- };
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
- // source path
- var srcPath = this.fullPath,
- // entry name
- name = newName || this.name,
- success = function(entry) {
- if (entry) {
- if (typeof successCallback === 'function') {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
- }
- }
- else {
- // no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
- }
- };
-
- // Entry object is borked
- var theEntry = {};
- var dstPath = parent.fullPath + '/' + name;
-
- // invalid path
- if(!validFileRe.exec(name)){
- fail(FileError.ENCODING_ERR);
- return;
- }
-
- if(this.isFile){
- if(srcPath != dstPath){
- if(blackberry.io.file.exists(dstPath)){
- if(blackberry.io.dir.exists(dstPath)){
- blackberry.io.file.copy(srcPath,dstPath);
-
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = false;
- theEntry.isFile = true;
- success(theEntry);
- }else{
- // destination directory doesn't exist
- fail(FileError.NOT_FOUND_ERR);
- }
-
- }else{
- blackberry.io.file.copy(srcPath,dstPath);
-
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = false;
- theEntry.isFile = true;
- success(theEntry);
- }
- }else{
- // file onto itself
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }else{
- if(srcPath != dstPath){
- // allow back up to the root but not child dirs
- if((parent.name != "root" && dstPath.indexOf(srcPath)>=0) || blackberry.io.file.exists(dstPath)){
- // copying directory into child or is file path
- fail(FileError.INVALID_MODIFICATION_ERR);
- }else{
- recursiveCopy(srcPath, dstPath);
-
- theEntry.fullPath = dstPath;
- theEntry.name = name;
- theEntry.isDirectory = true;
- theEntry.isFile = false;
- success(theEntry);
- }
- }else{
- // directory onto itself
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }
-
- },
-
- remove : function(successCallback, errorCallback) {
- var path = this.fullPath,
- // directory contents
- contents = [];
-
- var fail = function(error) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
- }
- };
-
- // file
- if (blackberry.io.file.exists(path)) {
- try {
- blackberry.io.file.deleteFile(path);
- if (typeof successCallback === "function") {
- successCallback();
- }
- } catch (e) {
- // permissions don't allow
- fail(FileError.INVALID_MODIFICATION_ERR);
- }
- }
- // directory
- else if (blackberry.io.dir.exists(path)) {
- // it is an error to attempt to remove the file system root
- console.log('entry directory');
- // TODO: gotta figure out how to get root dirs on playbook -
- // getRootDirs doesn't work
- if (false) {
- fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
- } else {
- // check to see if directory is empty
- contents = blackberry.io.dir.listFiles(path);
- if (contents.length !== 0) {
- fail(FileError.INVALID_MODIFICATION_ERR);
- } else {
- try {
- // delete
- blackberry.io.dir.deleteDirectory(path, false);
- if (typeof successCallback === "function") {
- successCallback();
- }
- } catch (eone) {
- // permissions don't allow
- fail(FileError.NO_MODIFICATION_ALLOWED_ERR);
- }
- }
- }
- }
- // not found
- else {
- fail(FileError.NOT_FOUND_ERR);
- }
- },
- getParent : function(successCallback, errorCallback) {
- var that = this;
-
- try {
- // On BlackBerry, the TEMPORARY file system is actually a temporary
- // directory that is created on a per-application basis. This is
- // to help ensure that applications do not share the same temporary
- // space. So we check to see if this is the TEMPORARY file system
- // (directory). If it is, we must return this Entry, rather than
- // the Entry for its parent.
- requestFileSystem(LocalFileSystem.TEMPORARY, 0,
- function(fileSystem) {
- if (fileSystem.root.fullPath === that.fullPath) {
- if (typeof successCallback === 'function') {
- successCallback(fileSystem.root);
- }
- } else {
- resolveLocalFileSystemURI(blackberry.io.dir
- .getParentDirectory(that.fullPath),
- successCallback, errorCallback);
- }
- }, errorCallback);
- } catch (e) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(FileError.NOT_FOUND_ERR));
- }
- }
- }
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/File.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/File.js b/lib/webworks/air/plugin/air/File.js
deleted file mode 100644
index 7a3ff3e..0000000
--- a/lib/webworks/air/plugin/air/File.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.
- *
-*/
-
-/**
- * Constructor.
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-
-var File = function(name, fullPath, type, lastModifiedDate, size){
- this.name = name || '';
- this.fullPath = fullPath || null;
- this.type = type || null;
- this.lastModifiedDate = lastModifiedDate || null;
- this.size = size || 0;
-};
-
-module.exports = File;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/FileEntry.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/FileEntry.js b/lib/webworks/air/plugin/air/FileEntry.js
deleted file mode 100644
index 8ac46a3..0000000
--- a/lib/webworks/air/plugin/air/FileEntry.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.
- *
-*/
-
-var FileEntry = require('cordova/plugin/FileEntry'),
- Entry = require('cordova/plugin/air/Entry'),
- FileWriter = require('cordova/plugin/air/FileWriter'),
- File = require('cordova/plugin/air/File'),
- FileError = require('cordova/plugin/FileError');
-
-module.exports = {
- /**
- * Creates a new FileWriter associated with the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new FileWriter
- * @param {Function} errorCallback is called with a FileError
- */
- createWriter : function(successCallback, errorCallback) {
- this.file(function(filePointer) {
- var writer = new FileWriter(filePointer);
-
- if (writer.fileName === null || writer.fileName === "") {
- if (typeof errorCallback === "function") {
- errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- }
- } else {
- if (typeof successCallback === "function") {
- successCallback(writer);
- }
- }
- }, errorCallback);
- },
-
- /**
- * Returns a File that represents the current state of the file that this FileEntry represents.
- *
- * @param {Function} successCallback is called with the new File object
- * @param {Function} errorCallback is called with a FileError
- */
- file : function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(f) {
- var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
- successCallback(file);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
-
- if(blackberry.io.file.exists(this.fullPath)){
- var theFileProperties = blackberry.io.file.getFileProperties(this.fullPath);
- var theFile = {};
-
- theFile.fullPath = this.fullPath;
- theFile.type = theFileProperties.fileExtension;
- theFile.lastModifiedDate = theFileProperties.dateModified;
- theFile.size = theFileProperties.size;
- win(theFile);
- }else{
- fail(FileError.NOT_FOUND_ERR);
- }
- }
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/0919268c/lib/webworks/air/plugin/air/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/webworks/air/plugin/air/FileReader.js b/lib/webworks/air/plugin/air/FileReader.js
deleted file mode 100644
index b6769b0..0000000
--- a/lib/webworks/air/plugin/air/FileReader.js
+++ /dev/null
@@ -1,262 +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 FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class reads the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To read from the SD card, the file name is "sdcard/my_file.txt"
- * @constructor
- */
-var FileReader = function() {
- this.fileName = "";
-
- this.readyState = 0; // FileReader.EMPTY
-
- // File data
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onloadstart = null; // When the read starts.
- this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
- this.onload = null; // When the read has successfully completed.
- this.onerror = null; // When the read has failed (see errors).
- this.onloadend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the read has been aborted. For instance, by invoking the abort() method.
-};
-
-// States
-FileReader.EMPTY = 0;
-FileReader.LOADING = 1;
-FileReader.DONE = 2;
-
-/**
- * Abort reading file.
- */
-FileReader.prototype.abort = function() {
- this.result = null;
-
- if (this.readyState == FileReader.DONE || this.readyState == FileReader.EMPTY) {
- return;
- }
-
- this.readyState = FileReader.DONE;
-
- // If abort callback
- if (typeof this.onabort === 'function') {
- this.onabort(new ProgressEvent('abort', {target:this}));
- }
- // If load end callback
- if (typeof this.onloadend === 'function') {
- this.onloadend(new ProgressEvent('loadend', {target:this}));
- }
-};
-
-/**
- * Read text file.
- *
- * @param file {File} File object containing file properties
- * @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
- */
-FileReader.prototype.readAsText = function(file, encoding) {
- // Figure out pathing
- this.fileName = '';
- if (typeof file.fullPath === 'undefined') {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
- }
-
- // Default encoding is UTF-8
- var enc = encoding ? encoding : "UTF-8";
-
- var me = this;
- // Read file
- if(blackberry.io.file.exists(this.fileName)){
- var theText = '';
- var getFileContents = function(path,blob){
- if(blob){
-
- theText = blackberry.utils.blobToString(blob, enc);
- me.result = theText;
-
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- me.readyState = FileReader.DONE;
-
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }
- };
- // setting asynch to off
- blackberry.io.file.readFile(this.fileName, getFileContents, false);
-
- }else{
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- me.result = null;
-
- // Save error
- me.error = new FileError(FileError.NOT_FOUND_ERR);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }
-};
-
-
-/**
- * Read file and return data as a base64 encoded data url.
- * A data url is of the form:
- * data:[<mediatype>][;base64],<data>
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsDataURL = function(file) {
- this.fileName = "";
- if (typeof file.fullPath === "undefined") {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
- }
-
- var enc = "BASE64";
-
- var me = this;
-
- // Read file
- if(blackberry.io.file.exists(this.fileName)){
- var theText = '';
- var getFileContents = function(path,blob){
- if(blob){
- theText = blackberry.utils.blobToString(blob, enc);
- me.result = "data:text/plain;base64," +theText;
-
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- me.readyState = FileReader.DONE;
-
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }
- };
- // setting asynch to off
- blackberry.io.file.readFile(this.fileName, getFileContents, false);
-
- }else{
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- me.result = null;
-
- // Save error
- me.error = new FileError(FileError.NOT_FOUND_ERR);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- }
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsBinaryString = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('method "readAsBinaryString" is not supported at this time.');
-};
-
-/**
- * Read file and return data as a binary data.
- *
- * @param file {File} File object containing file properties
- */
-FileReader.prototype.readAsArrayBuffer = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('This method is not supported at this time.');
-};
-
-module.exports = FileReader;