You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pm...@apache.org on 2012/03/22 13:50:23 UTC
[8/12] 2nd try at file refactoring
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileReader.js b/lib/plugin/FileReader.js
deleted file mode 100644
index 8b634d9..0000000
--- a/lib/plugin/FileReader.js
+++ /dev/null
@@ -1,249 +0,0 @@
-var exec = require('cordova/exec'),
- 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 (progess.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
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // Save result
- me.result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // null result
- me.result = null;
-
- // Save error
- me.error = new FileError(e);
-
- // 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}));
- }
- }, "File", "readAsText", [this.fileName, enc]);
-};
-
-
-/**
- * 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 me = this;
-
- // Read file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileReader.DONE;
-
- // Save result
- me.result = r;
-
- // If onload callback
- if (typeof me.onload === "function") {
- me.onload(new ProgressEvent("load", {target:me}));
- }
-
- // If onloadend callback
- if (typeof me.onloadend === "function") {
- me.onloadend(new ProgressEvent("loadend", {target:me}));
- }
- },
- // Error callback
- function(e) {
- // 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(e);
-
- // 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}));
- }
- }, "File", "readAsDataURL", [this.fileName]);
-};
-
-/**
- * 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;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileSystem.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileSystem.js b/lib/plugin/FileSystem.js
deleted file mode 100644
index 53636b5..0000000
--- a/lib/plugin/FileSystem.js
+++ /dev/null
@@ -1,17 +0,0 @@
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
-
-/**
- * An interface representing a file system
- *
- * @constructor
- * {DOMString} name the unique name of the file system (readonly)
- * {DirectoryEntry} root directory of the file system (readonly)
- */
-var FileSystem = function(name, root) {
- this.name = name || null;
- if (root) {
- this.root = new DirectoryEntry(root.name, root.fullPath);
- }
-};
-
-module.exports = FileSystem;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileTransfer.js b/lib/plugin/FileTransfer.js
deleted file mode 100644
index a417f5c..0000000
--- a/lib/plugin/FileTransfer.js
+++ /dev/null
@@ -1,68 +0,0 @@
-var exec = require('cordova/exec');
-
-/**
- * FileTransfer uploads a file to a remote server.
- * @constructor
- */
-var FileTransfer = function() {};
-
-/**
-* Given an absolute file path, uploads a file on the device to a remote server
-* using a multipart HTTP request.
-* @param filePath {String} Full path of the file on the device
-* @param server {String} URL of the server to receive the file
-* @param successCallback (Function} Callback to be invoked when upload has completed
-* @param errorCallback {Function} Callback to be invoked upon error
-* @param options {FileUploadOptions} Optional parameters such as file name and mimetype
-*/
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, debug) {
- // check for options
- var fileKey = null;
- var fileName = null;
- var mimeType = null;
- var params = null;
- var chunkedMode = true;
- if (options) {
- fileKey = options.fileKey;
- fileName = options.fileName;
- mimeType = options.mimeType;
- if (options.chunkedMode !== null || typeof options.chunkedMode !== "undefined") {
- chunkedMode = options.chunkedMode;
- }
- if (options.params) {
- params = options.params;
- }
- else {
- params = {};
- }
- }
-
- exec(successCallback, errorCallback, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]);
-};
-
-/**
- * Downloads a file form a given URL and saves it to the specified directory.
- * @param source {String} URL of the server to receive the file
- * @param target {String} Full path of the file on the device
- * @param successCallback (Function} Callback to be invoked when upload has completed
- * @param errorCallback {Function} Callback to be invoked upon error
- */
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback) {
- var win = function(result) {
- var entry = null;
- if (result.isDirectory) {
- entry = new DirectoryEntry();
- }
- else if (result.isFile) {
- entry = new FileEntry();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- };
- exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
-};
-
-module.exports = FileTransfer;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileTransferError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileTransferError.js b/lib/plugin/FileTransferError.js
deleted file mode 100644
index e3e7093..0000000
--- a/lib/plugin/FileTransferError.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * FileTransferError
- * @constructor
- */
-var FileTransferError = function(code) {
- this.code = code || null;
-};
-
-FileTransferError.FILE_NOT_FOUND_ERR = 1;
-FileTransferError.INVALID_URL_ERR = 2;
-FileTransferError.CONNECTION_ERR = 3;
-
-module.exports = FileTransferError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileUploadOptions.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileUploadOptions.js b/lib/plugin/FileUploadOptions.js
deleted file mode 100644
index ff16661..0000000
--- a/lib/plugin/FileUploadOptions.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * Options to customize the HTTP request used to upload files.
- * @constructor
- * @param fileKey {String} Name of file request parameter.
- * @param fileName {String} Filename to be used by the server. Defaults to image.jpg.
- * @param mimeType {String} Mimetype of the uploaded file. Defaults to image/jpeg.
- * @param params {Object} Object with key: value params to send to the server.
- */
-var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
- this.fileKey = fileKey || null;
- this.fileName = fileName || null;
- this.mimeType = mimeType || null;
- this.params = params || null;
-};
-
-module.exports = FileUploadOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileUploadResult.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileUploadResult.js b/lib/plugin/FileUploadResult.js
deleted file mode 100644
index 740babd..0000000
--- a/lib/plugin/FileUploadResult.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * FileUploadResult
- * @constructor
- */
-var FileUploadResult = function() {
- this.bytesSent = 0;
- this.responseCode = null;
- this.response = null;
-};
-
-module.exports = FileUploadResult;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileWriter.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileWriter.js b/lib/plugin/FileWriter.js
deleted file mode 100644
index e0e5626..0000000
--- a/lib/plugin/FileWriter.js
+++ /dev/null
@@ -1,253 +0,0 @@
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError');
- ProgressEvent = require('cordova/plugin/ProgressEvent');
-
-/**
- * This class writes to the mobile device file system.
- *
- * For Android:
- * The root directory is the root of the file system.
- * To write to the SD card, the file name is "sdcard/my_file.txt"
- *
- * @constructor
- * @param file {File} File object containing file properties
- * @param append if true write to the end of the file, otherwise overwrite the file
- */
-var FileWriter = function(file) {
- this.fileName = "";
- this.length = 0;
- if (file) {
- this.fileName = file.fullPath || file;
- this.length = file.size || 0;
- }
- // default is to write at the beginning of the file
- this.position = 0;
-
- this.readyState = 0; // EMPTY
-
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onwritestart = null; // When writing starts
- this.onprogress = null; // While writing the file, and reporting partial file data
- this.onwrite = null; // When the write has successfully completed.
- this.onwriteend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the write has been aborted. For instance, by invoking the abort() method.
- this.onerror = null; // When the write has failed (see errors).
-};
-
-// States
-FileWriter.INIT = 0;
-FileWriter.WRITING = 1;
-FileWriter.DONE = 2;
-
-/**
- * Abort writing file.
- */
-FileWriter.prototype.abort = function() {
- // check for invalid state
- if (this.readyState === FileWriter.DONE || this.readyState === FileWriter.INIT) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // set error
- this.error = new FileError(FileError.ABORT_ERR);
-
- this.readyState = FileWriter.DONE;
-
- // If abort callback
- if (typeof this.onabort === "function") {
- this.onabort(new ProgressEvent("abort", {"target":this}));
- }
-
- // If write end callback
- if (typeof this.onwriteend === "function") {
- this.onwriteend(new ProgressEvent("writeend", {"target":this}));
- }
-};
-
-/**
- * Writes data to the file
- *
- * @param text to be written
- */
-FileWriter.prototype.write = function(text) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":me}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // position always increases by bytes written because file would be extended
- me.position += r;
- // The length of the file is now where we are done writing.
-
- me.length = me.position;
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "write", [this.fileName, text, this.position]);
-};
-
-/**
- * Moves the file pointer to the location specified.
- *
- * If the offset is a negative number the position of the file
- * pointer is rewound. If the offset is greater than the file
- * size the position is set to the end of the file.
- *
- * @param offset is the location to move the file pointer to.
- */
-FileWriter.prototype.seek = function(offset) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- if (!offset) {
- return;
- }
-
- // See back from end of file.
- if (offset < 0) {
- this.position = Math.max(offset + this.length, 0);
- }
- // Offset is bigger then file size so set position
- // to the end of the file.
- else if (offset > this.length) {
- this.position = this.length;
- }
- // Offset is between 0 and file size so set the position
- // to start writing.
- else {
- this.position = offset;
- }
-};
-
-/**
- * Truncates the file to the size specified.
- *
- * @param size to chop the file at.
- */
-FileWriter.prototype.truncate = function(size) {
- // Throw an exception if we are already writing a file
- if (this.readyState === FileWriter.WRITING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // WRITING state
- this.readyState = FileWriter.WRITING;
-
- var me = this;
-
- // If onwritestart callback
- if (typeof me.onwritestart === "function") {
- me.onwritestart(new ProgressEvent("writestart", {"target":this}));
- }
-
- // Write file
- exec(
- // Success callback
- function(r) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Update the length of the file
- me.length = r;
- me.position = Math.min(me.position, r);
-
- // If onwrite callback
- if (typeof me.onwrite === "function") {
- me.onwrite(new ProgressEvent("write", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- },
- // Error callback
- function(e) {
- // If DONE (cancelled), then don't do anything
- if (me.readyState === FileWriter.DONE) {
- return;
- }
-
- // DONE state
- me.readyState = FileWriter.DONE;
-
- // Save error
- me.error = new FileError(e);
-
- // If onerror callback
- if (typeof me.onerror === "function") {
- me.onerror(new ProgressEvent("error", {"target":me}));
- }
-
- // If onwriteend callback
- if (typeof me.onwriteend === "function") {
- me.onwriteend(new ProgressEvent("writeend", {"target":me}));
- }
- }, "File", "truncate", [this.fileName, size]);
-};
-
-module.exports = FileWriter;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Flags.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Flags.js b/lib/plugin/Flags.js
deleted file mode 100644
index d918c38..0000000
--- a/lib/plugin/Flags.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Supplies arguments to methods that lookup or create files and directories.
- *
- * @param create
- * {boolean} file or directory if it doesn't exist
- * @param exclusive
- * {boolean} used with create; if true the command will fail if
- * target path exists
- */
-function Flags(create, exclusive) {
- this.create = create || false;
- this.exclusive = exclusive || false;
-}
-
-module.exports = Flags;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/LocalFileSystem.js
----------------------------------------------------------------------
diff --git a/lib/plugin/LocalFileSystem.js b/lib/plugin/LocalFileSystem.js
deleted file mode 100644
index f71ae62..0000000
--- a/lib/plugin/LocalFileSystem.js
+++ /dev/null
@@ -1,13 +0,0 @@
-var exec = require('cordova/exec');
-
-/**
- * Represents a local file system.
- */
-var LocalFileSystem = function() {
-
-};
-
-LocalFileSystem.TEMPORARY = 0; //temporary, with no guarantee of persistence
-LocalFileSystem.PERSISTENT = 1; //persistent
-
-module.exports = LocalFileSystem;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Media.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Media.js b/lib/plugin/Media.js
deleted file mode 100644
index 8d56da9..0000000
--- a/lib/plugin/Media.js
+++ /dev/null
@@ -1,186 +0,0 @@
-var utils = require('cordova/utils'),
- exec = require('cordova/exec');
-
-var mediaObjects = {};
-
-/**
- * This class provides access to the device media, interfaces to both sound and video
- *
- * @constructor
- * @param src The file name or url to play
- * @param successCallback The callback to be called when the file is done playing or recording.
- * successCallback()
- * @param errorCallback The callback to be called if there is an error.
- * errorCallback(int errorCode) - OPTIONAL
- * @param statusCallback The callback to be called when media status has changed.
- * statusCallback(int statusCode) - OPTIONAL
- */
-var Media = function(src, successCallback, errorCallback, statusCallback) {
-
- // successCallback optional
- if (successCallback && (typeof successCallback !== "function")) {
- console.log("Media Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Media Error: errorCallback is not a function");
- return;
- }
-
- // statusCallback optional
- if (statusCallback && (typeof statusCallback !== "function")) {
- console.log("Media Error: statusCallback is not a function");
- return;
- }
-
- this.id = utils.createUUID();
- mediaObjects[this.id] = this;
- this.src = src;
- this.successCallback = successCallback;
- this.errorCallback = errorCallback;
- this.statusCallback = statusCallback;
- this._duration = -1;
- this._position = -1;
- exec(null, this.errorCallback, "Media", "create", [this.id, this.src]);
-};
-
-// Media messages
-Media.MEDIA_STATE = 1;
-Media.MEDIA_DURATION = 2;
-Media.MEDIA_POSITION = 3;
-Media.MEDIA_ERROR = 9;
-
-// Media states
-Media.MEDIA_NONE = 0;
-Media.MEDIA_STARTING = 1;
-Media.MEDIA_RUNNING = 2;
-Media.MEDIA_PAUSED = 3;
-Media.MEDIA_STOPPED = 4;
-Media.MEDIA_MSG = ["None", "Starting", "Running", "Paused", "Stopped"];
-
-// "static" function to return existing objs.
-Media.get = function(id) {
- return mediaObjects[id];
-};
-
-/**
- * Start or resume playing audio file.
- */
-Media.prototype.play = function() {
- exec(this.successCallback, this.errorCallback, "Media", "startPlayingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop playing audio file.
- */
-Media.prototype.stop = function() {
- var me = this;
- exec(function() {
- me._position = 0;
- me.successCallback();
- }, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
-};
-
-/**
- * Seek or jump to a new time in the track..
- */
-Media.prototype.seekTo = function(milliseconds) {
- var me = this;
- exec(function(p) {
- me._position = p;
- }, this.errorCallback, "Media", "seekToAudio", [this.id, milliseconds]);
-};
-
-/**
- * Pause playing audio file.
- */
-Media.prototype.pause = function() {
- exec(null, this.errorCallback, "Media", "pausePlayingAudio", [this.id]);
-};
-
-/**
- * Get duration of an audio file.
- * The duration is only set for audio that is playing, paused or stopped.
- *
- * @return duration or -1 if not known.
- */
-Media.prototype.getDuration = function() {
- return this._duration;
-};
-
-/**
- * Get position of audio.
- */
-Media.prototype.getCurrentPosition = function(success, fail) {
- var me = this;
- exec(function(p) {
- me._position = p;
- success(p);
- }, fail, "Media", "getCurrentPositionAudio", [this.id]);
-};
-
-/**
- * Start recording audio file.
- */
-Media.prototype.startRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
-};
-
-/**
- * Stop recording audio file.
- */
-Media.prototype.stopRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
-};
-
-/**
- * Release the resources.
- */
-Media.prototype.release = function() {
- exec(null, this.errorCallback, "Media", "release", [this.id]);
-};
-
-/**
- * Adjust the volume.
- */
-Media.prototype.setVolume = function(volume) {
- exec(null, null, "Media", "setVolume", [this.id, volume]);
-};
-
-/**
- * Audio has status update.
- * PRIVATE
- *
- * @param id The media object id (string)
- * @param status The status code (int)
- * @param msg The status message (string)
- */
-Media.onStatus = function(id, msg, value) {
- var media = mediaObjects[id];
- // If state update
- if (msg === Media.MEDIA_STATE) {
- if (value === Media.MEDIA_STOPPED) {
- if (media.successCallback) {
- media.successCallback();
- }
- }
- if (media.statusCallback) {
- media.statusCallback(value);
- }
- }
- else if (msg === Media.MEDIA_DURATION) {
- media._duration = value;
- }
- else if (msg === Media.MEDIA_ERROR) {
- if (media.errorCallback) {
- media.errorCallback({"code":value});
- }
- }
- else if (msg === Media.MEDIA_POSITION) {
- media._position = value;
- }
-};
-
-module.exports = Media;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/MediaError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/MediaError.js b/lib/plugin/MediaError.js
deleted file mode 100644
index 40ce8f1..0000000
--- a/lib/plugin/MediaError.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
- * This class contains information about any Media errors.
- * @constructor
- */
-var MediaError = function(code, msg) {
- this.code = (code !== undefined ? code : null);
- this.message = msg || "";
-};
-
-MediaError.MEDIA_ERR_NONE_ACTIVE = 0;
-MediaError.MEDIA_ERR_ABORTED = 1;
-MediaError.MEDIA_ERR_NETWORK = 2;
-MediaError.MEDIA_ERR_DECODE = 3;
-MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
-
-module.exports = MediaError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/MediaFile.js
----------------------------------------------------------------------
diff --git a/lib/plugin/MediaFile.js b/lib/plugin/MediaFile.js
deleted file mode 100644
index e73716b..0000000
--- a/lib/plugin/MediaFile.js
+++ /dev/null
@@ -1,56 +0,0 @@
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('cordova/plugin/File'),
- CaptureError = require('cordova/plugin/CaptureError');
-/**
- * Represents a single file.
- *
- * 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 MediaFile = function(name, fullPath, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.fullPath, this.type]);
- }
-};
-
-/**
- * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
- * (used in Objective-C and Android)
- *
- * @param {PluginResult} pluginResult
- */
-MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
-};
-
-module.exports = MediaFile;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/MediaFileData.js
----------------------------------------------------------------------
diff --git a/lib/plugin/MediaFileData.js b/lib/plugin/MediaFileData.js
deleted file mode 100644
index ea5c2a3..0000000
--- a/lib/plugin/MediaFileData.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Metadata.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Metadata.js b/lib/plugin/Metadata.js
deleted file mode 100644
index b29cc7c..0000000
--- a/lib/plugin/Metadata.js
+++ /dev/null
@@ -1,10 +0,0 @@
-/**
- * Information about the state of the file or directory
- *
- * {Date} modificationTime (readonly)
- */
-var Metadata = function(time) {
- this.modificationTime = (typeof time != 'undefined'?new Date(time):null);
-};
-
-module.exports = Metadata;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Position.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Position.js b/lib/plugin/Position.js
deleted file mode 100644
index 25096c4..0000000
--- a/lib/plugin/Position.js
+++ /dev/null
@@ -1,8 +0,0 @@
-var Coordinates = require('cordova/plugin/Coordinates');
-
-var Position = function(coords, timestamp) {
- this.coords = new Coordinates(coords.latitude, coords.longitude, coords.altitude, coords.accuracy, coords.heading, coords.velocity, coords.altitudeAccuracy);
- this.timestamp = (timestamp !== undefined) ? timestamp : new Date().getTime();
-};
-
-module.exports = Position;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/PositionError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/PositionError.js b/lib/plugin/PositionError.js
deleted file mode 100644
index 07012d6..0000000
--- a/lib/plugin/PositionError.js
+++ /dev/null
@@ -1,17 +0,0 @@
-/**
- * Position error object
- *
- * @constructor
- * @param code
- * @param message
- */
-var PositionError = function(code, message) {
- this.code = code || null;
- this.message = message || '';
-};
-
-PositionError.PERMISSION_DENIED = 1;
-PositionError.POSITION_UNAVAILABLE = 2;
-PositionError.TIMEOUT = 3;
-
-module.exports = PositionError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ProgressEvent.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ProgressEvent.js b/lib/plugin/ProgressEvent.js
deleted file mode 100644
index d8e41c1..0000000
--- a/lib/plugin/ProgressEvent.js
+++ /dev/null
@@ -1,46 +0,0 @@
-// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
-// Feature test: See if we can instantiate a native ProgressEvent;
-// if so, use that approach,
-// otherwise fill-in with our own implementation.
-//
-// NOTE: right now we always fill in with our own. Down the road would be nice if we can use whatever is native in the webview.
-var ProgressEvent = (function() {
- /*
- var createEvent = function(data) {
- var event = document.createEvent('Events');
- event.initEvent('ProgressEvent', false, false);
- if (data) {
- for (var i in data) {
- if (data.hasOwnProperty(i)) {
- event[i] = data[i];
- }
- }
- if (data.target) {
- // TODO: cannot call <some_custom_object>.dispatchEvent
- // need to first figure out how to implement EventTarget
- }
- }
- return event;
- };
- try {
- var ev = createEvent({type:"abort",target:document});
- return function ProgressEvent(type, data) {
- data.type = type;
- return createEvent(data);
- };
- } catch(e){
- */
- return function ProgressEvent(type, dict) {
- this.type = type;
- this.bubbles = false;
- this.cancelBubble = false;
- this.cancelable = false;
- this.lengthComputable = false;
- this.loaded = dict && dict.loaded ? dict.loaded : 0;
- this.total = dict && dict.total ? dict.total : 0;
- this.target = dict && dict.target ? dict.target : null;
- };
- //}
-})();
-
-module.exports = ProgressEvent;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/accelerometer.js
----------------------------------------------------------------------
diff --git a/lib/plugin/accelerometer.js b/lib/plugin/accelerometer.js
deleted file mode 100644
index 6f01ab8..0000000
--- a/lib/plugin/accelerometer.js
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * This class provides access to device accelerometer data.
- * @constructor
- */
-var utils = require("cordova/utils"),
- exec = require("cordova/exec");
-
-// Local singleton variables.
-var timers = {};
-
-var accelerometer = {
- /**
- * Asynchronously aquires the current acceleration.
- *
- * @param {Function} successCallback The function to call when the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- */
- getCurrentAcceleration: function(successCallback, errorCallback, options) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
-
- // Get acceleration
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
- },
-
- /**
- * Asynchronously aquires the acceleration repeatedly at a given interval.
- *
- * @param {Function} successCallback The function to call each time the acceleration data is available
- * @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
- * @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
- * @return String The watch id that must be passed to #clearWatch to stop watching.
- */
- watchAcceleration: function(successCallback, errorCallback, options) {
-
- // Default interval (10 sec)
- var frequency = (options !== undefined && options.frequency !== undefined)? options.frequency : 10000;
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Accelerometer Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Accelerometer Error: errorCallback is not a function");
- return;
- }
-
- // Make sure accelerometer timeout > frequency + 10 sec
- exec(
- function(timeout) {
- if (timeout < (frequency + 10000)) {
- exec(null, null, "Accelerometer", "setTimeout", [frequency + 10000]);
- }
- },
- function(e) { }, "Accelerometer", "getTimeout", []);
-
- // Start watch timer
- var id = utils.createUUID();
- timers[id] = window.setInterval(function() {
- exec(successCallback, errorCallback, "Accelerometer", "getAcceleration", []);
- }, (frequency ? frequency : 1));
-
- return id;
- },
-
- /**
- * Clears the specified accelerometer watch.
- *
- * @param {String} id The id of the watch returned from #watchAcceleration.
- */
- clearWatch: function(id) {
-
- // Stop javascript timer & remove from timer list
- if (id && timers[id] !== undefined) {
- window.clearInterval(timers[id]);
- delete timers[id];
- }
- }
-};
-
-module.exports = accelerometer;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/android/app.js
----------------------------------------------------------------------
diff --git a/lib/plugin/android/app.js b/lib/plugin/android/app.js
deleted file mode 100644
index f858829..0000000
--- a/lib/plugin/android/app.js
+++ /dev/null
@@ -1,71 +0,0 @@
-var exec = require('cordova/exec');
-
-module.exports = {
- /**
- * Clear the resource cache.
- */
- clearCache:function() {
- exec(null, null, "App", "clearCache", []);
- },
-
- /**
- * Load the url into the webview or into new browser instance.
- *
- * @param url The URL to load
- * @param props Properties that can be passed in to the activity:
- * wait: int => wait msec before loading URL
- * loadingDialog: "Title,Message" => display a native loading dialog
- * loadUrlTimeoutValue: int => time in msec to wait before triggering a timeout error
- * clearHistory: boolean => clear webview history (default=false)
- * openExternal: boolean => open in a new browser (default=false)
- *
- * Example:
- * navigator.app.loadUrl("http://server/myapp/index.html", {wait:2000, loadingDialog:"Wait,Loading App", loadUrlTimeoutValue: 60000});
- */
- loadUrl:function(url, props) {
- exec(null, null, "App", "loadUrl", [url, props]);
- },
-
- /**
- * Cancel loadUrl that is waiting to be loaded.
- */
- cancelLoadUrl:function() {
- exec(null, null, "App", "cancelLoadUrl", []);
- },
-
- /**
- * Clear web history in this web view.
- * Instead of BACK button loading the previous web page, it will exit the app.
- */
- clearHistory:function() {
- exec(null, null, "App", "clearHistory", []);
- },
-
- /**
- * Go to previous page displayed.
- * This is the same as pressing the backbutton on Android device.
- */
- backHistory:function() {
- exec(null, null, "App", "backHistory", []);
- },
-
- /**
- * Override the default behavior of the Android back button.
- * If overridden, when the back button is pressed, the "backKeyDown" JavaScript event will be fired.
- *
- * Note: The user should not have to call this method. Instead, when the user
- * registers for the "backbutton" event, this is automatically done.
- *
- * @param override T=override, F=cancel override
- */
- overrideBackbutton:function(override) {
- exec(null, null, "App", "overrideBackbutton", [override]);
- },
-
- /**
- * Exit and terminate the application.
- */
- exitApp:function() {
- return exec(null, null, "App", "exitApp", []);
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/android/callback.js
----------------------------------------------------------------------
diff --git a/lib/plugin/android/callback.js b/lib/plugin/android/callback.js
deleted file mode 100644
index d5768a7..0000000
--- a/lib/plugin/android/callback.js
+++ /dev/null
@@ -1,85 +0,0 @@
-var port = null,
- token = null,
- cordova = require('cordova'),
- polling = require('cordova/plugin/android/polling'),
- callback = function() {
- // Exit if shutting down app
- if (cordova.shuttingDown) {
- return;
- }
-
- // If polling flag was changed, start using polling from now on
- if (cordova.UsePolling) {
- polling();
- return;
- }
-
- var xmlhttp = new XMLHttpRequest();
-
- // Callback function when XMLHttpRequest is ready
- xmlhttp.onreadystatechange=function(){
- if(xmlhttp.readyState === 4){
-
- // Exit if shutting down app
- if (cordova.shuttingDown) {
- return;
- }
-
- // If callback has JavaScript statement to execute
- if (xmlhttp.status === 200) {
-
- // Need to url decode the response
- var msg = decodeURIComponent(xmlhttp.responseText);
- setTimeout(function() {
- try {
- var t = eval(msg);
- }
- catch (e) {
- // If we're getting an error here, seeing the message will help in debugging
- console.log("JSCallback: Message from Server: " + msg);
- console.log("JSCallback Error: "+e);
- }
- }, 1);
- setTimeout(callback, 1);
- }
-
- // If callback ping (used to keep XHR request from timing out)
- else if (xmlhttp.status === 404) {
- setTimeout(callback, 10);
- }
-
- // If security error
- else if (xmlhttp.status === 403) {
- console.log("JSCallback Error: Invalid token. Stopping callbacks.");
- }
-
- // If server is stopping
- else if (xmlhttp.status === 503) {
- console.log("JSCallback Server Closed: Stopping callbacks.");
- }
-
- // If request wasn't GET
- else if (xmlhttp.status === 400) {
- console.log("JSCallback Error: Bad request. Stopping callbacks.");
- }
-
- // If error, revert to polling
- else {
- console.log("JSCallback Error: Request failed.");
- cordova.UsePolling = true;
- polling();
- }
- }
- };
-
- if (port === null) {
- port = prompt("getPort", "gap_callbackServer:");
- }
- if (token === null) {
- token = prompt("getToken", "gap_callbackServer:");
- }
- xmlhttp.open("GET", "http://127.0.0.1:"+port+"/"+token , true);
- xmlhttp.send();
-};
-
-module.exports = callback;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/android/device.js
----------------------------------------------------------------------
diff --git a/lib/plugin/android/device.js b/lib/plugin/android/device.js
deleted file mode 100644
index 1defbbe..0000000
--- a/lib/plugin/android/device.js
+++ /dev/null
@@ -1,92 +0,0 @@
-var channel = require('cordova/channel'),
- exec = require('cordova/exec');
-
-/**
- * This represents the mobile device, and provides properties for inspecting the model, version, UUID of the
- * phone, etc.
- * @constructor
- */
-function Device() {
- this.available = false;
- this.platform = null;
- this.version = null;
- this.name = null;
- this.uuid = null;
- this.cordova = null;
-
- var me = this;
- this.getInfo(
- function(info) {
- me.available = true;
- me.platform = info.platform;
- me.version = info.version;
- me.name = info.name;
- me.uuid = info.uuid;
- me.cordova = info.cordova;
- channel.onCordovaInfoReady.fire();
- },
- function(e) {
- me.available = false;
- console.log("Error initializing Cordova: " + e);
- alert("Error initializing Cordova: "+e);
- });
-}
-
-/**
- * Get device info
- *
- * @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. (OPTIONAL)
- */
-Device.prototype.getInfo = function(successCallback, errorCallback) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Device Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Device Error: errorCallback is not a function");
- return;
- }
-
- // Get info
- exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
-};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * You must explicitly override the back button.
- */
-Device.prototype.overrideBackButton = function() {
- console.log("Device.overrideBackButton() is deprecated. Use App.overrideBackbutton(true).");
- navigator.app.overrideBackbutton(true);
-};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * This resets the back button to the default behaviour
- */
-Device.prototype.resetBackButton = function() {
- console.log("Device.resetBackButton() is deprecated. Use App.overrideBackbutton(false).");
- navigator.app.overrideBackbutton(false);
-};
-
-/*
- * DEPRECATED
- * This is only for Android.
- *
- * This terminates the activity!
- */
-Device.prototype.exitApp = function() {
- console.log("Device.exitApp() is deprecated. Use App.exitApp().");
- navigator.app.exitApp();
-};
-
-module.exports = new Device();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/android/polling.js
----------------------------------------------------------------------
diff --git a/lib/plugin/android/polling.js b/lib/plugin/android/polling.js
deleted file mode 100644
index 36b8e86..0000000
--- a/lib/plugin/android/polling.js
+++ /dev/null
@@ -1,33 +0,0 @@
-var cordova = require('cordova'),
- period = 50,
- polling = function() {
- // Exit if shutting down app
- if (cordova.shuttingDown) {
- return;
- }
-
- // If polling flag was changed, stop using polling from now on and switch to XHR server / callback
- if (!cordova.UsePolling) {
- require('cordova/plugin/android/callback')();
- return;
- }
-
- var msg = prompt("", "gap_poll:");
- if (msg) {
- setTimeout(function() {
- try {
- var t = eval(""+msg);
- }
- catch (e) {
- console.log("JSCallbackPolling: Message from Server: " + msg);
- console.log("JSCallbackPolling Error: "+e);
- }
- }, 1);
- setTimeout(polling, 1);
- }
- else {
- setTimeout(polling, period);
- }
-};
-
-module.exports = polling;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/android/storage.js
----------------------------------------------------------------------
diff --git a/lib/plugin/android/storage.js b/lib/plugin/android/storage.js
deleted file mode 100644
index 000612b..0000000
--- a/lib/plugin/android/storage.js
+++ /dev/null
@@ -1,377 +0,0 @@
-var utils = require('cordova/utils'),
- exec = require('cordova/exec');
- channel = require('cordova/channel');
-
-var queryQueue = {};
-
-/**
- * SQL result set object
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Rows = function() {
- this.resultSet = []; // results array
- this.length = 0; // number of rows
-};
-
-/**
- * Get item from SQL result set
- *
- * @param row The row number to return
- * @return The row object
- */
-DroidDB_Rows.prototype.item = function(row) {
- return this.resultSet[row];
-};
-
-/**
- * SQL result set that is returned to user.
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Result = function() {
- this.rows = new DroidDB_Rows();
-};
-
-/**
- * Callback from native code when query is complete.
- * PRIVATE METHOD
- *
- * @param id Query id
- */
-function completeQuery(id, data) {
- var query = queryQueue[id];
- if (query) {
- try {
- delete queryQueue[id];
-
- // Get transaction
- var tx = query.tx;
-
- // If transaction hasn't failed
- // Note: We ignore all query results if previous query
- // in the same transaction failed.
- if (tx && tx.queryList[id]) {
-
- // Save query results
- var r = new DroidDB_Result();
- r.rows.resultSet = data;
- r.rows.length = data.length;
- try {
- if (typeof query.successCallback === 'function') {
- query.successCallback(query.tx, r);
- }
- } catch (ex) {
- console.log("executeSql error calling user success callback: "+ex);
- }
-
- tx.queryComplete(id);
- }
- } catch (e) {
- console.log("executeSql error: "+e);
- }
- }
-}
-
-/**
- * Callback from native code when query fails
- * PRIVATE METHOD
- *
- * @param reason Error message
- * @param id Query id
- */
-function failQuery(reason, id) {
- var query = queryQueue[id];
- if (query) {
- try {
- delete queryQueue[id];
-
- // Get transaction
- var tx = query.tx;
-
- // If transaction hasn't failed
- // Note: We ignore all query results if previous query
- // in the same transaction failed.
- if (tx && tx.queryList[id]) {
- tx.queryList = {};
-
- try {
- if (typeof query.errorCallback === 'function') {
- query.errorCallback(query.tx, reason);
- }
- } catch (ex) {
- console.log("executeSql error calling user error callback: "+ex);
- }
-
- tx.queryFailed(id, reason);
- }
-
- } catch (e) {
- console.log("executeSql error: "+e);
- }
- }
-}
-
-/**
- * SQL query object
- * PRIVATE METHOD
- *
- * @constructor
- * @param tx The transaction object that this query belongs to
- */
-var DroidDB_Query = function(tx) {
-
- // Set the id of the query
- this.id = utils.createUUID();
-
- // Add this query to the queue
- queryQueue[this.id] = this;
-
- // Init result
- this.resultSet = [];
-
- // Set transaction that this query belongs to
- this.tx = tx;
-
- // Add this query to transaction list
- this.tx.queryList[this.id] = this;
-
- // Callbacks
- this.successCallback = null;
- this.errorCallback = null;
-
-};
-
-/**
- * Transaction object
- * PRIVATE METHOD
- * @constructor
- */
-var DroidDB_Tx = function() {
-
- // Set the id of the transaction
- this.id = utils.createUUID();
-
- // Callbacks
- this.successCallback = null;
- this.errorCallback = null;
-
- // Query list
- this.queryList = {};
-};
-
-/**
- * Mark query in transaction as complete.
- * If all queries are complete, call the user's transaction success callback.
- *
- * @param id Query id
- */
-DroidDB_Tx.prototype.queryComplete = function(id) {
- delete this.queryList[id];
-
- // If no more outstanding queries, then fire transaction success
- if (this.successCallback) {
- var count = 0;
- var i;
- for (i in this.queryList) {
- if (this.queryList.hasOwnProperty(i)) {
- count++;
- }
- }
- if (count === 0) {
- try {
- this.successCallback();
- } catch(e) {
- console.log("Transaction error calling user success callback: " + e);
- }
- }
- }
-};
-
-/**
- * Mark query in transaction as failed.
- *
- * @param id Query id
- * @param reason Error message
- */
-DroidDB_Tx.prototype.queryFailed = function(id, reason) {
-
- // The sql queries in this transaction have already been run, since
- // we really don't have a real transaction implemented in native code.
- // However, the user callbacks for the remaining sql queries in transaction
- // will not be called.
- this.queryList = {};
-
- if (this.errorCallback) {
- try {
- this.errorCallback(reason);
- } catch(e) {
- console.log("Transaction error calling user error callback: " + e);
- }
- }
-};
-
-/**
- * Execute SQL statement
- *
- * @param sql SQL statement to execute
- * @param params Statement parameters
- * @param successCallback Success callback
- * @param errorCallback Error callback
- */
-DroidDB_Tx.prototype.executeSql = function(sql, params, successCallback, errorCallback) {
-
- // Init params array
- if (typeof params === 'undefined') {
- params = [];
- }
-
- // Create query and add to queue
- var query = new DroidDB_Query(this);
- queryQueue[query.id] = query;
-
- // Save callbacks
- query.successCallback = successCallback;
- query.errorCallback = errorCallback;
-
- // Call native code
- exec(null, null, "Storage", "executeSql", [sql, params, query.id]);
-};
-
-var DatabaseShell = function() {
-};
-
-/**
- * Start a transaction.
- * Does not support rollback in event of failure.
- *
- * @param process {Function} The transaction function
- * @param successCallback {Function}
- * @param errorCallback {Function}
- */
-DatabaseShell.prototype.transaction = function(process, errorCallback, successCallback) {
- var tx = new DroidDB_Tx();
- tx.successCallback = successCallback;
- tx.errorCallback = errorCallback;
- try {
- process(tx);
- } catch (e) {
- console.log("Transaction error: "+e);
- if (tx.errorCallback) {
- try {
- tx.errorCallback(e);
- } catch (ex) {
- console.log("Transaction error calling user error callback: "+e);
- }
- }
- }
-};
-
-/**
- * Open database
- *
- * @param name Database name
- * @param version Database version
- * @param display_name Database display name
- * @param size Database size in bytes
- * @return Database object
- */
-var DroidDB_openDatabase = function(name, version, display_name, size) {
- exec(null, null, "Storage", "openDatabase", [name, version, display_name, size]);
- var db = new DatabaseShell();
- return db;
-};
-
-/**
- * For browsers with no localStorage we emulate it with SQLite. Follows the w3c api.
- * TODO: Do similar for sessionStorage.
- * @constructor
- */
-var CupcakeLocalStorage = function() {
- channel.waitForInitialization("cupcakeStorage");
-
- try {
-
- this.db = openDatabase('localStorage', '1.0', 'localStorage', 2621440);
- var storage = {};
- this.length = 0;
- function setLength (length) {
- this.length = length;
- localStorage.length = length;
- }
- this.db.transaction(
- function (transaction) {
- var i;
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('SELECT * FROM storage', [], function(tx, result) {
- for(var i = 0; i < result.rows.length; i++) {
- storage[result.rows.item(i)['id']] = result.rows.item(i)['body'];
- }
- setLength(result.rows.length);
- channel.initializationComplete("cupcakeStorage");
- });
-
- },
- function (err) {
- alert(err.message);
- }
- );
- this.setItem = function(key, val) {
- if (typeof(storage[key])=='undefined') {
- this.length++;
- }
- storage[key] = val;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('REPLACE INTO storage (id, body) values(?,?)', [key,val]);
- }
- );
- };
- this.getItem = function(key) {
- return storage[key];
- };
- this.removeItem = function(key) {
- delete storage[key];
- this.length--;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('DELETE FROM storage where id=?', [key]);
- }
- );
- };
- this.clear = function() {
- storage = {};
- this.length = 0;
- this.db.transaction(
- function (transaction) {
- transaction.executeSql('CREATE TABLE IF NOT EXISTS storage (id NVARCHAR(40) PRIMARY KEY, body NVARCHAR(255))');
- transaction.executeSql('DELETE FROM storage', []);
- }
- );
- };
- this.key = function(index) {
- var i = 0;
- for (var j in storage) {
- if (i==index) {
- return j;
- } else {
- i++;
- }
- }
- return null;
- };
-
- } catch(e) {
- alert("Database error "+e+".");
- return;
- }
-};
-
-module.exports = {
- openDatabase:DroidDB_openDatabase,
- CupcakeLocalStorage:CupcakeLocalStorage,
- failQuery:failQuery,
- completeQuery:completeQuery
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/battery.js
----------------------------------------------------------------------
diff --git a/lib/plugin/battery.js b/lib/plugin/battery.js
deleted file mode 100644
index 5649356..0000000
--- a/lib/plugin/battery.js
+++ /dev/null
@@ -1,87 +0,0 @@
-/**
- * This class contains information about the current battery status.
- * @constructor
- */
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-function handlers() {
- return battery.channels.batterystatus.numHandlers +
- battery.channels.batterylow.numHandlers +
- battery.channels.batterycritical.numHandlers;
-}
-
-var Battery = function() {
- this._level = null;
- this._isPlugged = null;
- // Create new event handlers on the window (returns a channel instance)
- var subscriptionEvents = {
- onSubscribe:this.onSubscribe,
- onUnsubscribe:this.onUnsubscribe
- };
- this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
- };
-};
-/**
- * Event handlers for when callbacks get registered for the battery.
- * Keep track of how many handlers we have so we can start and stop the native battery listener
- * appropriately (and hopefully save on battery life!).
- */
-Battery.prototype.onSubscribe = function() {
- var me = battery;
- // If we just registered the first handler, make sure native listener is started.
- if (handlers() === 1) {
- exec(me._status, me._error, "Battery", "start", []);
- }
-};
-
-Battery.prototype.onUnsubscribe = function() {
- var me = battery;
-
- // If we just unregistered the last handler, make sure native listener is stopped.
- if (handlers() === 0) {
- exec(null, null, "Battery", "stop", []);
- }
-};
-
-/**
- * Callback for battery status
- *
- * @param {Object} info keys: level, isPlugged
- */
-Battery.prototype._status = function(info) {
- if (info) {
- var me = battery;
- var level = info.level;
- if (me._level !== level || me._isPlugged !== info.isPlugged) {
- // Fire batterystatus event
- cordova.fireWindowEvent("batterystatus", info);
-
- // Fire low battery event
- if (level === 20 || level === 5) {
- if (level === 20) {
- cordova.fireWindowEvent("batterylow", info);
- }
- else {
- cordova.fireWindowEvent("batterycritical", info);
- }
- }
- }
- me._level = level;
- me._isPlugged = info.isPlugged;
- }
-};
-
-/**
- * Error callback for battery start
- */
-Battery.prototype._error = function(e) {
- console.log("Error initializing Battery: " + e);
-};
-
-var battery = new Battery();
-
-module.exports = battery;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/blackberry/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/DirectoryEntry.js b/lib/plugin/blackberry/DirectoryEntry.js
deleted file mode 100644
index 76acaf7..0000000
--- a/lib/plugin/blackberry/DirectoryEntry.js
+++ /dev/null
@@ -1,239 +0,0 @@
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
- FileEntry = require('cordova/plugin/FileEntry'),
- FileError = require('cordova/plugin/FileError'),
- exec = require('cordova/exec');
-
-module.exports = {
- /**
- * 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));
- }
- };
-
- // 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
- 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 += '/';
- }
- 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));
- }
- };
-
- // 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
- exec(
- function(result) {
- // file created
- createEntry();
- },
- fail, "File", "write", [ path, "", 0 ]);
- }
- // 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
- if (exec(null, null, "File", "isFileSystemRoot", [ path ]) === true) {
- 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/76f64673/lib/plugin/blackberry/Entry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/Entry.js b/lib/plugin/blackberry/Entry.js
deleted file mode 100644
index cc9626d..0000000
--- a/lib/plugin/blackberry/Entry.js
+++ /dev/null
@@ -1,87 +0,0 @@
-var FileError = require('cordova/plugin/FileError'),
- LocalFileSystem = require('cordova/plugin/LocalFileSystem'),
- resolveLocalFileSystemURI = require('cordova/plugin/resolveLocalFileSystemURI'),
- exec = require('cordova/exec');
-
-module.exports = {
- 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
- if (exec(null, null, "File", "isFileSystemRoot", [ path ]) === true) {
- 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/76f64673/lib/plugin/blackberry/app.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/app.js b/lib/plugin/blackberry/app.js
deleted file mode 100644
index 6c58e30..0000000
--- a/lib/plugin/blackberry/app.js
+++ /dev/null
@@ -1,51 +0,0 @@
-var exec = require('cordova/exec');
-var manager = require('cordova/plugin/blackberry/manager');
-
-module.exports = {
- /**
- * Clear the resource cache.
- */
- clearCache:function() {
- if (typeof blackberry.widgetcache === "undefined"
- || blackberry.widgetcache === null) {
- console.log("blackberry.widgetcache permission not found. Cache clear denied.");
- return;
- }
- blackberry.widgetcache.clearAll();
- },
-
- /**
- * Clear web history in this web view.
- * Instead of BACK button loading the previous web page, it will exit the app.
- */
- clearHistory:function() {
- exec(null, null, "App", "clearHistory", []);
- },
-
- /**
- * Go to previous page displayed.
- * This is the same as pressing the backbutton on Android device.
- */
- backHistory:function() {
- // window.history.back() behaves oddly on BlackBerry, so use
- // native implementation.
- exec(null, null, "App", "backHistory", []);
- },
-
- /**
- * Exit and terminate the application.
- */
- exitApp:function() {
- // Call onunload if it is defined since BlackBerry does not invoke
- // on application exit.
- if (typeof window.onunload === "function") {
- window.onunload();
- }
-
- // allow Cordova JavaScript Extension opportunity to cleanup
- manager.destroy();
-
- // exit the app
- blackberry.app.exit();
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/blackberry/device.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/device.js b/lib/plugin/blackberry/device.js
deleted file mode 100644
index 42a0647..0000000
--- a/lib/plugin/blackberry/device.js
+++ /dev/null
@@ -1,23 +0,0 @@
-var me = {},
- channel = require('cordova/channel'),
- exec = require('cordova/exec');
-
-exec(
- function (device) {
- me.platform = device.platform;
- me.version = device.version;
- me.name = device.name;
- me.uuid = device.uuid;
- me.cordova = device.cordova;
-
- channel.onCordovaInfoReady.fire();
- },
- function (e) {
- console.log("error initializing cordova: " + e);
- },
- "Device",
- "getDeviceInfo",
- []
-);
-
-module.exports = me;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/blackberry/manager.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/manager.js b/lib/plugin/blackberry/manager.js
deleted file mode 100644
index ef353bb..0000000
--- a/lib/plugin/blackberry/manager.js
+++ /dev/null
@@ -1,87 +0,0 @@
-var webworks = require('cordova/plugin/webworks/manager'),
- Cordova = require('cordova'),
- plugins = {};
-
-function _exec(win, fail, clazz, action, args) {
- var callbackId = clazz + Cordova.callbackId++,
- origResult,
- evalResult,
- execResult;
-
- try {
-
- if (win || fail) {
- Cordova.callbacks[callbackId] = {success: win, fail: fail};
- }
-
- // Note: Device returns string, but for some reason emulator returns object - so convert to string.
- origResult = "" + org.apache.cordova.JavaPluginManager.exec(clazz, action, callbackId, JSON.stringify(args), true);
-
- // If a result was returned
- if (origResult.length > 0) {
- eval("evalResult = " + origResult + ";");
-
- // If status is OK, then return evalResultalue back to caller
- if (evalResult.status === Cordova.callbackStatus.OK) {
-
- // If there is a success callback, then call it now with returned evalResultalue
- if (win) {
- // Clear callback if not expecting any more results
- if (!evalResult.keepCallback) {
- delete Cordova.callbacks[callbackId];
- }
- }
- } else if (evalResult.status === Cordova.callbackStatus.NO_RESULT) {
-
- // Clear callback if not expecting any more results
- if (!evalResult.keepCallback) {
- delete Cordova.callbacks[callbackId];
- }
- } else {
- // If there is a fail callback, then call it now with returned evalResultalue
- if (fail) {
-
- // Clear callback if not expecting any more results
- if (!evalResult.keepCallback) {
- delete Cordova.callbacks[callbackId];
- }
- }
- }
- execResult = evalResult;
- } else {
- // Asynchronous calls return an empty string. Return a NO_RESULT
- // status for those executions.
- execResult = {"status" : Cordova.callbackStatus.NO_RESULT,
- "message" : ""};
- }
- } catch (e) {
- console.log("BlackBerryPluginManager Error: " + e);
- execResult = {"status" : Cordova.callbackStatus.ERROR,
- "message" : e.message};
- }
-
- return execResult;
-}
-
-module.exports = {
- exec: function (win, fail, clazz, action, args) {
- var result = webworks.exec(win, fail, clazz, action, args);
-
- //We got a sync result or a not found from WW that we can pass on to get a native mixin
- //For async calls there's nothing to do
- if (result.status === Cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION ||
- result.status === Cordova.callbackStatus.INVALID_ACTION ||
- result.status === Cordova.callbackStatus.OK) {
- if (plugins[clazz]) {
- return plugins[clazz].execute(result.message, action, args, win, fail);
- } else {
- result = _exec(win, fail, clazz, action, args);
- }
- }
-
- return result;
- },
- resume: org.apache.cordova.JavaPluginManager.resume,
- pause: org.apache.cordova.JavaPluginManager.pause,
- destroy: org.apache.cordova.JavaPluginManager.destroy
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/blackberry/notification.js
----------------------------------------------------------------------
diff --git a/lib/plugin/blackberry/notification.js b/lib/plugin/blackberry/notification.js
deleted file mode 100644
index 83bc77c..0000000
--- a/lib/plugin/blackberry/notification.js
+++ /dev/null
@@ -1,53 +0,0 @@
-var exec = require('cordova/exec');
-
-/**
- * Provides BlackBerry enhanced notification API.
- */
-module.exports = {
- activityStart : function(title, message) {
- // If title and message not specified then mimic Android behavior of
- // using default strings.
- if (typeof title === "undefined" && typeof message == "undefined") {
- title = "Busy";
- message = 'Please wait...';
- }
-
- exec(null, null, 'Notification', 'activityStart', [ title, message ]);
- },
-
- /**
- * Close an activity dialog
- */
- activityStop : function() {
- exec(null, null, 'Notification', 'activityStop', []);
- },
-
- /**
- * Display a progress dialog with progress bar that goes from 0 to 100.
- *
- * @param {String}
- * title Title of the progress dialog.
- * @param {String}
- * message Message to display in the dialog.
- */
- progressStart : function(title, message) {
- exec(null, null, 'Notification', 'progressStart', [ title, message ]);
- },
-
- /**
- * Close the progress dialog.
- */
- progressStop : function() {
- exec(null, null, 'Notification', 'progressStop', []);
- },
-
- /**
- * Set the progress dialog value.
- *
- * @param {Number}
- * value 0-100
- */
- progressValue : function(value) {
- exec(null, null, 'Notification', 'progressValue', [ value ]);
- },
-};
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/capture.js
----------------------------------------------------------------------
diff --git a/lib/plugin/capture.js b/lib/plugin/capture.js
deleted file mode 100644
index e088ba6..0000000
--- a/lib/plugin/capture.js
+++ /dev/null
@@ -1,72 +0,0 @@
-var exec = require('cordova/exec'),
- MediaFile = require('cordova/plugin/MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-function _capture(type, successCallback, errorCallback, options) {
- var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
- }
- successCallback(mediaFiles);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-module.exports = new Capture();