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
[7/12] 2nd try at file refactoring
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/ios/plugin/ios/FileReader.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/FileReader.js b/lib/ios/plugin/ios/FileReader.js
new file mode 100644
index 0000000..5711393
--- /dev/null
+++ b/lib/ios/plugin/ios/FileReader.js
@@ -0,0 +1,87 @@
+var exec = require('cordova/exec'),
+ FileError = require('cordova/plugin/FileError'),
+ FileReader = require('cordova/plugin/FileReader'),
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
+
+module.exports = {
+ 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 = decodeURIComponent(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]);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/ios/plugin/ios/console.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/console.js b/lib/ios/plugin/ios/console.js
new file mode 100644
index 0000000..8651591
--- /dev/null
+++ b/lib/ios/plugin/ios/console.js
@@ -0,0 +1,102 @@
+var exec = require('cordova/exec');
+
+/**
+ * String indentation/formatting
+ */
+function indent(str) {
+ return str.replace(/^/mg, " ");
+}
+/**
+ * Format a string for pretty logging
+ */
+function makeStructured(obj, depth) {
+ var str = "";
+ for (var i in obj) {
+ try {
+ if (typeof(obj[i]) == 'object' && depth < maxDepth) {
+ str += i + ":\n" + indent(makeStructured(obj[i])) + "\n";
+ } else {
+ str += i + " = " + indent(String(obj[i])).replace(/^ {4}/, "") + "\n";
+ }
+ } catch(e) {
+ str += i + " = EXCEPTION: " + e.message + "\n";
+ }
+ }
+ return str;
+}
+
+/**
+ * This class provides access to the debugging console.
+ * @constructor
+ */
+var DebugConsole = function() {
+ this.winConsole = window.console;
+ this.logLevel = DebugConsole.INFO_LEVEL;
+};
+
+// from most verbose, to least verbose
+DebugConsole.ALL_LEVEL = 1; // same as first level
+DebugConsole.INFO_LEVEL = 1;
+DebugConsole.WARN_LEVEL = 2;
+DebugConsole.ERROR_LEVEL = 4;
+DebugConsole.NONE_LEVEL = 8;
+
+DebugConsole.prototype.setLevel = function(level) {
+ this.logLevel = level;
+};
+
+/**
+ * Utility function for rendering and indenting strings, or serializing
+ * objects to a string capable of being printed to the console.
+ * @param {Object|String} message The string or object to convert to an indented string
+ * @private
+ */
+DebugConsole.prototype.processMessage = function(message, maxDepth) {
+ if (maxDepth === undefined) maxDepth = 0;
+ if (typeof(message) != 'object') {
+ return (this.isDeprecated ? "WARNING: debug object is deprecated, please use console object \n" + message : message);
+ } else {
+ return ("Object:\n" + makeStructured(message, maxDepth));
+ }
+};
+
+/**
+ * Print a normal log message to the console
+ * @param {Object|String} message Message or object to print to the console
+ */
+DebugConsole.prototype.log = function(message, maxDepth) {
+ if (this.logLevel <= DebugConsole.INFO_LEVEL)
+ exec(null, null, 'Debug Console', 'log',
+ [ this.processMessage(message, maxDepth), { logLevel: 'INFO' } ]
+ );
+ else
+ this.winConsole.log(message);
+};
+
+/**
+ * Print a warning message to the console
+ * @param {Object|String} message Message or object to print to the console
+ */
+DebugConsole.prototype.warn = function(message, maxDepth) {
+ if (this.logLevel <= DebugConsole.WARN_LEVEL)
+ exec(null, null, 'Debug Console', 'log',
+ [ this.processMessage(message, maxDepth), { logLevel: 'WARN' } ]
+ );
+ else
+ this.winConsole.error(message);
+};
+
+/**
+ * Print an error message to the console
+ * @param {Object|String} message Message or object to print to the console
+ */
+DebugConsole.prototype.error = function(message, maxDepth) {
+ if (this.logLevel <= DebugConsole.ERROR_LEVEL)
+ exec(null, null, 'Debug Console', 'log',
+ [ this.processMessage(message, maxDepth), { logLevel: 'ERROR' } ]
+ );
+ else
+ this.winConsole.error(message);
+};
+
+module.exports = new DebugConsole();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/ios/plugin/ios/device.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/device.js b/lib/ios/plugin/ios/device.js
new file mode 100644
index 0000000..c6d117b
--- /dev/null
+++ b/lib/ios/plugin/ios/device.js
@@ -0,0 +1,30 @@
+/**
+ * this represents the mobile device, and provides properties for inspecting the model, version, UUID of the
+ * phone, etc.
+ * @constructor
+ */
+var exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+
+var Device = function() {
+ this.platform = null;
+ this.version = null;
+ this.name = null;
+ this.cordova = null;
+ this.uuid = null;
+};
+
+Device.prototype.setInfo = function(info) {
+ try {
+ this.platform = info.platform;
+ this.version = info.version;
+ this.name = info.name;
+ this.cordova = info.gap;
+ this.uuid = info.uuid;
+ channel.onCordovaInfoReady.fire();
+ } catch(e) {
+ alert('Error during device info setting in cordova/plugin/ios/device!');
+ }
+};
+
+module.exports = new Device();
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/ios/plugin/ios/nativecomm.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/nativecomm.js b/lib/ios/plugin/ios/nativecomm.js
new file mode 100644
index 0000000..938a68c
--- /dev/null
+++ b/lib/ios/plugin/ios/nativecomm.js
@@ -0,0 +1,10 @@
+var cordova = require('cordova');
+
+/**
+ * Called by native code to retrieve all queued commands and clear the queue.
+ */
+module.exports = function() {
+ var json = JSON.stringify(cordova.commandQueue);
+ cordova.commandQueue = [];
+ return json;
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/ios/plugin/ios/notification.js
----------------------------------------------------------------------
diff --git a/lib/ios/plugin/ios/notification.js b/lib/ios/plugin/ios/notification.js
new file mode 100644
index 0000000..a49567d
--- /dev/null
+++ b/lib/ios/plugin/ios/notification.js
@@ -0,0 +1,7 @@
+var Media = require('cordova/plugin/Media');
+
+module.exports = {
+ beep:function(count) {
+ (new Media('beep.wav')).play();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/android.js
----------------------------------------------------------------------
diff --git a/lib/platform/android.js b/lib/platform/android.js
deleted file mode 100644
index 6c71820..0000000
--- a/lib/platform/android.js
+++ /dev/null
@@ -1,131 +0,0 @@
-module.exports = {
- id: "android",
- initialize:function() {
- var channel = require("cordova/channel"),
- cordova = require('cordova'),
- callback = require('cordova/plugin/android/callback'),
- polling = require('cordova/plugin/android/polling'),
- exec = require('cordova/exec');
-
- channel.onDestroy.subscribe(function() {
- cordova.shuttingDown = true;
- });
-
- // Start listening for XHR callbacks
- // Figure out which bridge approach will work on this Android
- // device: polling or XHR-based callbacks
- setTimeout(function() {
- if (cordova.UsePolling) {
- polling();
- }
- else {
- var isPolling = prompt("usePolling", "gap_callbackServer:");
- cordova.UsePolling = isPolling;
- if (isPolling == "true") {
- cordova.UsePolling = true;
- polling();
- } else {
- cordova.UsePolling = false;
- callback();
- }
- }
- }, 1);
-
- // Inject a listener for the backbutton on the document.
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton', {
- onSubscribe:function() {
- // If we just attached the first handler, let native know we need to override the back button.
- if (this.numHandlers === 1) {
- exec(null, null, "App", "overrideBackbutton", [true]);
- }
- },
- onUnsubscribe:function() {
- // If we just detached the last handler, let native know we no longer override the back button.
- if (this.numHandlers === 0) {
- exec(null, null, "App", "overrideBackbutton", [false]);
- }
- }
- });
-
- // Add hardware MENU and SEARCH button handlers
- cordova.addDocumentEventHandler('menubutton');
- cordova.addDocumentEventHandler('searchbutton');
-
- // Figure out if we need to shim-in localStorage and WebSQL
- // support from the native side.
- var storage = require('cordova/plugin/android/storage');
-
- // First patch WebSQL if necessary
- if (typeof window.openDatabase == 'undefined') {
- // Not defined, create an openDatabase function for all to use!
- window.openDatabase = storage.openDatabase;
- } else {
- // Defined, but some Android devices will throw a SECURITY_ERR -
- // so we wrap the whole thing in a try-catch and shim in our own
- // if the device has Android bug 16175.
- var originalOpenDatabase = window.openDatabase;
- window.openDatabase = function(name, version, desc, size) {
- var db = null;
- try {
- db = originalOpenDatabase(name, version, desc, size);
- }
- catch (ex) {
- db = null;
- }
-
- if (db === null) {
- return storage.openDatabase(name, version, desc, size);
- }
- else {
- return db;
- }
-
- };
- }
-
- // Patch localStorage if necessary
- if (typeof window.localStorage == 'undefined' || window.localStorage === null) {
- window.localStorage = new storage.CupCakeLocalStorage();
- }
-
- // Let native code know we are all done on the JS side.
- // Native code will then un-hide the WebView.
- channel.join(function() {
- prompt("", "gap_init:");
- }, [channel.onCordovaReady]);
- },
- objects: {
- cordova: {
- children: {
- JSCallback:{
- path:"cordova/plugin/android/callback"
- },
- JSCallbackPolling:{
- path:"cordova/plugin/android/polling"
- }
- }
- },
- navigator: {
- children: {
- app:{
- path: "cordova/plugin/android/app"
- }
- }
- },
- device:{
- path: "cordova/plugin/android/device"
- },
- File: { // exists natively on Android WebView, override
- path: "cordova/plugin/File"
- },
- FileReader: { // exists natively on Android WebView, override
- path: "cordova/plugin/FileReader"
- },
- FileError: { //exists natively on Android WebView on Android 4.x
- path: "cordova/plugin/FileError"
- },
- MediaError: { // exists natively on Android WebView on Android 4.x
- path: "cordova/plugin/MediaError"
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/blackberry.js
----------------------------------------------------------------------
diff --git a/lib/platform/blackberry.js b/lib/platform/blackberry.js
deleted file mode 100644
index e7fa2e3..0000000
--- a/lib/platform/blackberry.js
+++ /dev/null
@@ -1,173 +0,0 @@
-module.exports = {
- id: "blackberry",
- initialize:function() {
- var cordova = require('cordova'),
- exec = require('cordova/exec'),
- channel = require('cordova/channel'),
- blackberryManager = require('cordova/plugin/blackberry/manager'),
- app = require('cordova/plugin/blackberry/app');
-
- // BB OS 5 does not define window.console.
- if (typeof window.console === 'undefined') {
- window.console = {};
- }
-
- // Override console.log with native logging ability.
- // BB OS 7 devices define console.log for use with web inspector
- // debugging. If console.log is already defined, invoke it in addition
- // to native logging.
- var origLog = window.console.log;
- window.console.log = function(msg) {
- if (typeof origLog === 'function') {
- origLog.call(window.console, msg);
- }
- org.apache.cordova.Logger.log(''+msg);
- };
-
- // Mapping of button events to BlackBerry key identifier.
- var buttonMapping = {
- 'backbutton' : blackberry.system.event.KEY_BACK,
- 'conveniencebutton1' : blackberry.system.event.KEY_CONVENIENCE_1,
- 'conveniencebutton2' : blackberry.system.event.KEY_CONVENIENCE_2,
- 'endcallbutton' : blackberry.system.event.KEY_ENDCALL,
- 'menubutton' : blackberry.system.event.KEY_MENU,
- 'startcallbutton' : blackberry.system.event.KEY_STARTCALL,
- 'volumedownbutton' : blackberry.system.event.KEY_VOLUMEDOWN,
- 'volumeupbutton' : blackberry.system.event.KEY_VOLUMEUP
- };
-
- // Generates a function which fires the specified event.
- var fireEvent = function(event) {
- return function() {
- cordova.fireDocumentEvent(event, null);
- };
- };
-
- var eventHandler = function(event) {
- return { onSubscribe : function() {
- // If we just attached the first handler, let native know we
- // need to override the back button.
- if (this.numHandlers === 1) {
- blackberry.system.event.onHardwareKey(
- buttonMapping[event], fireEvent(event));
- }
- },
- onUnsubscribe : function() {
- // If we just detached the last handler, let native know we
- // no longer override the back button.
- if (this.numHandlers === 0) {
- blackberry.system.event.onHardwareKey(
- buttonMapping[event], null);
- }
- }};
- };
-
- // Inject listeners for buttons on the document.
- for (var button in buttonMapping) {
- if (buttonMapping.hasOwnProperty(button)) {
- cordova.addDocumentEventHandler(button, eventHandler(button));
- }
- }
-
- // Fires off necessary code to pause/resume app
- var resume = function() {
- cordova.fireDocumentEvent('resume');
- blackberryManager.resume();
- };
- var pause = function() {
- cordova.fireDocumentEvent('pause');
- blackberryManager.pause();
- };
-
- /************************************************
- * Patch up the generic pause/resume listeners. *
- ************************************************/
-
- // Unsubscribe handler - turns off native backlight change
- // listener
- var onUnsubscribe = function() {
- if (channel.onResume.numHandlers === 0 && channel.onPause.numHandlers === 0) {
- exec(null, null, 'App', 'ignoreBacklight', []);
- }
- };
-
- // Native backlight detection win/fail callbacks
- var backlightWin = function(isOn) {
- if (isOn === true) {
- resume();
- } else {
- pause();
- }
- };
- var backlightFail = function(e) {
- console.log("Error detecting backlight on/off.");
- };
-
- // Override stock resume and pause listeners so we can trigger
- // some native methods during attach/remove
- channel.onResume = cordova.addDocumentEventHandler('resume', {
- onSubscribe:function() {
- // If we just attached the first handler and there are
- // no pause handlers, start the backlight system
- // listener on the native side.
- if (channel.onResume.numHandlers === 1 && channel.onPause.numHandlers === 0) {
- exec(backlightWin, backlightFail, "App", "detectBacklight", []);
- }
- },
- onUnsubscribe:onUnsubscribe
- });
- channel.onPause = cordova.addDocumentEventHandler('pause', {
- onSubscribe:function() {
- // If we just attached the first handler and there are
- // no resume handlers, start the backlight system
- // listener on the native side.
- if (channel.onResume.numHandlers === 0 && channel.onPause.numHandlers === 1) {
- exec(backlightWin, backlightFail, "App", "detectBacklight", []);
- }
- },
- onUnsubscribe:onUnsubscribe
- });
-
- // Fire resume event when application brought to foreground.
- blackberry.app.event.onForeground(resume);
-
- // Fire pause event when application sent to background.
- blackberry.app.event.onBackground(pause);
-
- // Trap BlackBerry WebWorks exit. Allow plugins to clean up before exiting.
- blackberry.app.event.onExit(app.exitApp);
- },
- objects: {
- navigator: {
- children: {
- app: {
- path: "cordova/plugin/blackberry/app"
- }
- }
- },
- device: {
- path: "cordova/plugin/blackberry/device"
- },
- File: { // exists natively on BlackBerry OS 7, override
- path: "cordova/plugin/File"
- }
- },
- merges: {
- navigator: {
- children: {
- device: {
- path: 'cordova/plugin/blackberry/device'
- },
- notification: {
- path: 'cordova/plugin/blackberry/notification'
- }
- }
- },
- DirectoryEntry: {
- path: 'cordova/plugin/blackberry/DirectoryEntry'
- },
- Entry: {
- path: 'cordova/plugin/blackberry/Entry'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/common.js
----------------------------------------------------------------------
diff --git a/lib/platform/common.js b/lib/platform/common.js
deleted file mode 100644
index e07bf03..0000000
--- a/lib/platform/common.js
+++ /dev/null
@@ -1,180 +0,0 @@
-module.exports = {
- objects: {
- cordova: {
- path: 'cordova',
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- navigator: {
- children: {
- notification: {
- path: 'cordova/plugin/notification'
- },
- accelerometer: {
- path: 'cordova/plugin/accelerometer'
- },
- battery: {
- path: 'cordova/plugin/battery'
- },
- camera:{
- path: 'cordova/plugin/Camera'
- },
- compass:{
- path: 'cordova/plugin/compass'
- },
- contacts: {
- path: 'cordova/plugin/contacts'
- },
- device:{
- children:{
- capture: {
- path: 'cordova/plugin/capture'
- }
- }
- },
- geolocation: {
- path: 'cordova/plugin/geolocation'
- },
- network: {
- children: {
- connection: {
- path: 'cordova/plugin/network'
- }
- }
- }
- }
- },
- Acceleration: {
- path: 'cordova/plugin/Acceleration'
- },
- Camera:{
- path: 'cordova/plugin/CameraConstants'
- },
- CaptureError: {
- path: 'cordova/plugin/CaptureError'
- },
- CaptureAudioOptions:{
- path: 'cordova/plugin/CaptureAudioOptions'
- },
- CaptureImageOptions: {
- path: 'cordova/plugin/CaptureImageOptions'
- },
- CaptureVideoOptions: {
- path: 'cordova/plugin/CaptureVideoOptions'
- },
- CompassHeading:{
- path: 'cordova/plugin/CompassHeading'
- },
- CompassError:{
- path: 'cordova/plugin/CompassError'
- },
- ConfigurationData: {
- path: 'cordova/plugin/ConfigurationData'
- },
- Connection: {
- path: 'cordova/plugin/Connection'
- },
- Contact: {
- path: 'cordova/plugin/Contact'
- },
- ContactAddress: {
- path: 'cordova/plugin/ContactAddress'
- },
- ContactError: {
- path: 'cordova/plugin/ContactError'
- },
- ContactField: {
- path: 'cordova/plugin/ContactField'
- },
- ContactFindOptions: {
- path: 'cordova/plugin/ContactFindOptions'
- },
- ContactName: {
- path: 'cordova/plugin/ContactName'
- },
- ContactOrganization: {
- path: 'cordova/plugin/ContactOrganization'
- },
- Coordinates: {
- path: 'cordova/plugin/Coordinates'
- },
- DirectoryEntry: {
- path: 'cordova/plugin/DirectoryEntry'
- },
- DirectoryReader: {
- path: 'cordova/plugin/DirectoryReader'
- },
- Entry: {
- path: 'cordova/plugin/Entry'
- },
- File: {
- path: 'cordova/plugin/File'
- },
- FileEntry: {
- path: 'cordova/plugin/FileEntry'
- },
- FileError: {
- path: 'cordova/plugin/FileError'
- },
- FileReader: {
- path: 'cordova/plugin/FileReader'
- },
- FileSystem: {
- path: 'cordova/plugin/FileSystem'
- },
- FileTransfer: {
- path: 'cordova/plugin/FileTransfer'
- },
- FileTransferError: {
- path: 'cordova/plugin/FileTransferError'
- },
- FileUploadOptions: {
- path: 'cordova/plugin/FileUploadOptions'
- },
- FileUploadResult: {
- path: 'cordova/plugin/FileUploadResult'
- },
- FileWriter: {
- path: 'cordova/plugin/FileWriter'
- },
- Flags: {
- path: 'cordova/plugin/Flags'
- },
- LocalFileSystem: {
- path: 'cordova/plugin/LocalFileSystem'
- },
- Media: {
- path: 'cordova/plugin/Media'
- },
- MediaError: {
- path: 'cordova/plugin/MediaError'
- },
- MediaFile: {
- path: 'cordova/plugin/MediaFile'
- },
- MediaFileData:{
- path: 'cordova/plugin/MediaFileData'
- },
- Metadata:{
- path: 'cordova/plugin/Metadata'
- },
- Position: {
- path: 'cordova/plugin/Position'
- },
- PositionError: {
- path: 'cordova/plugin/PositionError'
- },
- ProgressEvent: {
- path: 'cordova/plugin/ProgressEvent'
- },
- requestFileSystem:{
- path: 'cordova/plugin/requestFileSystem'
- },
- resolveLocalFileSystemURI:{
- path: 'cordova/plugin/resolveLocalFileSystemURI'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/errgen.js
----------------------------------------------------------------------
diff --git a/lib/platform/errgen.js b/lib/platform/errgen.js
deleted file mode 100644
index 8677cab..0000000
--- a/lib/platform/errgen.js
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-// required call to kick off the device ready callback
-require('cordova/plugin/errgen/device')
-
-//------------------------------------------------------------------------------
-module.exports = {
- id: "errgen",
- initialize: function() {},
- objects: {}
-}
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/ios.js
----------------------------------------------------------------------
diff --git a/lib/platform/ios.js b/lib/platform/ios.js
deleted file mode 100644
index e68b52e..0000000
--- a/lib/platform/ios.js
+++ /dev/null
@@ -1,41 +0,0 @@
-module.exports = {
- id: "ios",
- initialize:function() {
- // iOS doesn't allow reassigning / overriding navigator.geolocation object.
- // So clobber its methods here instead :)
- var geo = require('cordova/plugin/geolocation');
-
- navigator.geolocation.getCurrentPosition = geo.getCurrentPosition;
- navigator.geolocation.watchPosition = geo.watchPosition;
- navigator.geolocation.clearWatch = geo.clearWatch;
- },
- objects: {
- File: { // exists natively, override
- path: "cordova/plugin/File"
- },
- MediaError: { // exists natively, override
- path: "cordova/plugin/MediaError"
- },
- device: {
- path: 'cordova/plugin/ios/device'
- },
- console: {
- path: 'cordova/plugin/ios/console'
- }
- },
- merges:{
- Entry:{
- path: "cordova/plugin/ios/Entry"
- },
- FileReader:{
- path: "cordova/plugin/ios/FileReader"
- },
- navigator:{
- children:{
- notification:{
- path:"cordova/plugin/ios/notification"
- }
- }
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/playbook.js
----------------------------------------------------------------------
diff --git a/lib/platform/playbook.js b/lib/platform/playbook.js
deleted file mode 100644
index 4854f9b..0000000
--- a/lib/platform/playbook.js
+++ /dev/null
@@ -1,16 +0,0 @@
-module.exports = {
- id: "playbook",
- initialize:function() {},
- objects: {
- navigator: {
- children: {
- device: {
- path: "cordova/plugin/playbook/device"
- }
- }
- },
- device: {
- path: "cordova/plugin/playbook/device"
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/platform/wp7.js
----------------------------------------------------------------------
diff --git a/lib/platform/wp7.js b/lib/platform/wp7.js
deleted file mode 100644
index f2d74b4..0000000
--- a/lib/platform/wp7.js
+++ /dev/null
@@ -1,16 +0,0 @@
-module.exports = {
- id: "wp7",
- initialize:function() {},
- objects: {
- navigator: {
- children: {
- device: {
- path: "cordova/plugin/wp7/device"
- }
- }
- },
- device: {
- path: 'cordova/plugin/wp7/device'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/playbook/exec.js
----------------------------------------------------------------------
diff --git a/lib/playbook/exec.js b/lib/playbook/exec.js
new file mode 100644
index 0000000..ff2cbd9
--- /dev/null
+++ b/lib/playbook/exec.js
@@ -0,0 +1,56 @@
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchrounous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+ */
+
+module.exports = function(success, fail, service, action, args) {
+ try {
+ var playbook = require('cordova/plugin/playbook/manager'),
+ cordova = require('cordova'),
+ v = playbook.exec(success, fail, service, action, args);
+
+ // If status is OK, then return value back to caller
+ if (v.status == cordova.callbackStatus.OK) {
+
+ // If there is a success callback, then call it now with returned value
+ if (success) {
+ try {
+ success(v.message);
+ }
+ catch (e) {
+ console.log("Error in success callback: "+cordova.callbackId+" = "+e);
+ }
+
+ }
+ return v.message;
+ } else if (v.status == cordova.callbackStatus.NO_RESULT) {
+
+ } else {
+ // If error, then display error
+ console.log("Error: Status="+v.status+" Message="+v.message);
+
+ // If there is a fail callback, then call it now with returned value
+ if (fail) {
+ try {
+ fail(v.message);
+ }
+ catch (e) {
+ console.log("Error in error callback: "+cordova.callbackId+" = "+e);
+ }
+ }
+ return null;
+ }
+ } catch (e) {
+ alert("Error: "+e);
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/playbook/platform.js
----------------------------------------------------------------------
diff --git a/lib/playbook/platform.js b/lib/playbook/platform.js
new file mode 100644
index 0000000..4854f9b
--- /dev/null
+++ b/lib/playbook/platform.js
@@ -0,0 +1,16 @@
+module.exports = {
+ id: "playbook",
+ initialize:function() {},
+ objects: {
+ navigator: {
+ children: {
+ device: {
+ path: "cordova/plugin/playbook/device"
+ }
+ }
+ },
+ device: {
+ path: "cordova/plugin/playbook/device"
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/playbook/plugin/playbook/device.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/device.js b/lib/playbook/plugin/playbook/device.js
new file mode 100644
index 0000000..90ec376
--- /dev/null
+++ b/lib/playbook/plugin/playbook/device.js
@@ -0,0 +1,23 @@
+var me = {},
+ exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+
+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/playbook/plugin/playbook/manager.js
----------------------------------------------------------------------
diff --git a/lib/playbook/plugin/playbook/manager.js b/lib/playbook/plugin/playbook/manager.js
new file mode 100644
index 0000000..312a1d2
--- /dev/null
+++ b/lib/playbook/plugin/playbook/manager.js
@@ -0,0 +1,285 @@
+var webworks = require('cordova/plugin/webworks/manager'),
+ cordova = require('cordova'),
+ /**
+ * Private list of HTML 5 audio objects, indexed by the Cordova media object ids
+ */
+ audioObjects = {},
+ retInvalidAction = function () {
+ return { "status" : cordova.callbackStatus.INVALID_ACTION, "message" : "Action not found" };
+ },
+ retAsyncCall = function () {
+ return { "status" : cordova.callbackStatus.NO_RESULT, "message" : "WebWorks Is On It" };
+ },
+ cameraAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ if (action === 'takePicture') {
+ blackberry.media.camera.takePicture(win, fail, fail);
+ return retAsyncCall();
+ }
+ else {
+ return retInvalidAction();
+ }
+ }
+ },
+ deviceAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ if (action === 'getDeviceInfo') {
+ return {"status" : cordova.callbackStatus.OK,
+ "message" : {
+ "version" : blackberry.system.softwareVersion,
+ "name" : blackberry.system.model,
+ "uuid" : blackberry.identity.PIN,
+ "platform" : "PlayBook",
+ "cordova" : "1.4.1"
+ }
+ };
+ }
+ return retInvalidAction();
+ }
+ },
+ loggerAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ if (action === 'log') {
+ console.log(args);
+ return {"status" : cordova.callbackStatus.OK,
+ "message" : 'Message logged to console: ' + args};
+ }
+ else {
+ return retInvalidAction();
+ }
+ }
+ },
+ mediaAPI = {
+ execute: function (webWorksResult, action, 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;
+
+ switch (action) {
+ case 'startPlayingAudio':
+ if (args.length === 1) {
+ result = {"status" : 9, "message" : "Media source argument not found"};
+
+ }
+
+ if (audio) {
+ audio.pause();
+ audioObjects[id] = undefined;
+ }
+
+ audio = audioObjects[id] = new Audio(args[1]);
+ audio.play();
+
+ result = {"status" : 1, "message" : "Audio play started" };
+ break;
+ case 'stopPlayingAudio':
+ if (!audio) {
+ return {"status" : 2, "message" : "Audio Object has not been initialized"};
+ }
+
+ audio.pause();
+ audioObjects[id] = undefined;
+
+ result = {"status" : 1, "message" : "Audio play stopped" };
+ break;
+ case 'seekToAudio':
+ 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" };
+ }
+ break;
+ case 'pausePlayingAudio':
+ if (!audio) {
+ return {"status" : 2, "message" : "Audio Object has not been initialized"};
+ }
+
+ audio.pause();
+
+ result = {"status" : 1, "message" : "Audio paused" };
+ break;
+ case 'getCurrentPositionAudio':
+ if (!audio) {
+ return {"status" : 2, "message" : "Audio Object has not been initialized"};
+ }
+
+ result = {"status" : 1, "message" : audio.currentTime };
+ break;
+ case 'getDuration':
+ if (!audio) {
+ return {"status" : 2, "message" : "Audio Object has not been initialized"};
+ }
+
+ result = {"status" : 1, "message" : audio.duration };
+ break;
+ case 'startRecordingAudio':
+ if (args.length <= 1) {
+ result = {"status" : 9, "message" : "Media start recording, insufficient arguments"};
+ }
+
+ blackberry.media.microphone.record(args[1], win, fail);
+ result = retAsyncCall();
+ break;
+ case 'stopRecordingAudio':
+ break;
+ case 'release':
+ if (audio) {
+ audioObjects[id] = undefined;
+ audio.src = undefined;
+ //delete audio;
+ }
+
+ result = {"status" : 1, "message" : "Media resources released"};
+ break;
+ default:
+ result = retInvalidAction();
+ }
+
+ return result;
+ }
+ },
+ mediaCaptureAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ var limit = args[0],
+ pictureFiles = [],
+ captureMethod;
+
+ function captureCB(filePath) {
+ var mediaFile;
+
+ if (filePath) {
+ mediaFile = new MediaFile();
+ mediaFile.fullPath = filePath;
+ pictureFiles.push(mediaFile);
+ }
+
+ if (limit > 0) {
+ limit--;
+ blackberry.media.camera[captureMethod](win, fail, fail);
+ return;
+ }
+
+ win(pictureFiles);
+
+ return retAsyncCall();
+ }
+
+ switch (action) {
+ case 'getSupportedAudioModes':
+ case 'getSupportedImageModes':
+ case 'getSupportedVideoModes':
+ return {"status": cordova.callbackStatus.OK, "message": []};
+ case 'captureImage':
+ captureMethod = "takePicture";
+ captureCB();
+ break;
+ case 'captureVideo':
+ captureMethod = "takeVideo";
+ captureCB();
+ break;
+ case 'captureAudio':
+ return {"status": cordova.callbackStatus.INVALID_ACTION, "message": "captureAudio is not currently supported"};
+ }
+
+ return retAsyncCall();
+ }
+ },
+ networkAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ if (action !== 'getConnectionInfo') {
+ return retInvalidAction();
+ }
+
+ var connectionType = require("cordova/plugin/Connection").NONE,
+ eventType = "offline",
+ callbackID,
+ request;
+
+ /**
+ * For PlayBooks, we currently only have WiFi connections, so return WiFi if there is
+ * any access at all.
+ * TODO: update if/when PlayBook gets other connection types...
+ */
+ if (blackberry.system.hasDataCoverage()) {
+ connectionType = require("cordova/plugin/Connection").WIFI;
+ eventType = "online";
+ }
+
+ //Register an event handler for the networkChange event
+ callbackID = blackberry.events.registerEventHandler("networkChange", win);
+
+ //pass our callback id down to our network extension
+ request = new blackberry.transport.RemoteFunctionCall("org/apache/cordova/getConnectionInfo");
+ request.addParam("networkStatusChangedID", callbackID);
+ request.makeSyncCall();
+
+ return { "status": cordova.callbackStatus.OK, "message": {"type": connectionType, "event": eventType } };
+ }
+ },
+ notificationAPI = {
+ execute: function (webWorksResult, action, args, win, fail) {
+ if (args.length !== 3) {
+ return {"status" : 9, "message" : "Notification action - " + action + " arguments not found"};
+
+ }
+
+ //Unpack and map the args
+ var msg = args[0],
+ title = args[1],
+ btnLabel = args[2],
+ btnLabels;
+
+ switch (action) {
+ case 'alert':
+ blackberry.ui.dialog.customAskAsync.apply(this, [ msg, [ btnLabel ], win, { "title" : title } ]);
+ return retAsyncCall();
+ case 'confirm':
+ btnLabels = btnLabel.split(",");
+ blackberry.ui.dialog.customAskAsync.apply(this, [msg, btnLabels, win, {"title" : title} ]);
+ return retAsyncCall();
+ }
+ return retInvalidAction();
+
+ }
+ },
+ plugins = {
+ 'Camera' : cameraAPI,
+ 'Device' : deviceAPI,
+ 'Logger' : loggerAPI,
+ 'Media' : mediaAPI,
+ 'MediaCapture' : mediaCaptureAPI,
+ 'Network Status' : networkAPI,
+ 'Notification' : notificationAPI
+ };
+
+module.exports = {
+ exec: function (win, fail, clazz, action, args) {
+ var wwResult = 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 ((wwResult.status === cordova.callbackStatus.OK ||
+ wwResult.status === cordova.callbackStatus.CLASS_NOT_FOUND_EXCEPTION) &&
+ plugins[clazz]) {
+ return plugins[clazz].execute(wwResult.message, action, args, win, fail);
+ }
+
+ return wwResult;
+ },
+ resume: function () {},
+ pause: function () {},
+ destroy: function () {}
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Acceleration.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Acceleration.js b/lib/plugin/Acceleration.js
deleted file mode 100644
index f02d24b..0000000
--- a/lib/plugin/Acceleration.js
+++ /dev/null
@@ -1,8 +0,0 @@
-var Acceleration = function(x, y, z) {
- this.x = x;
- this.y = y;
- this.z = z;
- this.timestamp = new Date().getTime();
-};
-
-module.exports = Acceleration;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Camera.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Camera.js b/lib/plugin/Camera.js
deleted file mode 100644
index 5e58af8..0000000
--- a/lib/plugin/Camera.js
+++ /dev/null
@@ -1,84 +0,0 @@
-var exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants');
-
-var cameraExport = {};
-
-// Tack on the Camera Constants to the base camera plugin.
-for (var key in Camera) {
- cameraExport[key] = Camera[key];
-}
-
-/**
- * Gets a picture from source defined by "options.sourceType", and returns the
- * image as defined by the "options.destinationType" option.
-
- * The defaults are sourceType=CAMERA and destinationType=FILE_URL.
- *
- * @param {Function} successCallback
- * @param {Function} errorCallback
- * @param {Object} options
- */
-cameraExport.getPicture = function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback != "function") {
- console.log("Camera Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback != "function")) {
- console.log("Camera Error: errorCallback is not a function");
- return;
- }
-
- var quality = 50;
- if (options && typeof options.quality == "number") {
- quality = options.quality;
- } else if (options && typeof options.quality == "string") {
- var qlity = parseInt(options.quality, 10);
- if (isNaN(qlity) === false) {
- quality = qlity.valueOf();
- }
- }
-
- var destinationType = Camera.DestinationType.FILE_URI;
- if (typeof options.destinationType == "number") {
- destinationType = options.destinationType;
- }
-
- var sourceType = Camera.PictureSourceType.CAMERA;
- if (typeof options.sourceType == "number") {
- sourceType = options.sourceType;
- }
-
- var targetWidth = -1;
- if (typeof options.targetWidth == "number") {
- targetWidth = options.targetWidth;
- } else if (typeof options.targetWidth == "string") {
- var width = parseInt(options.targetWidth, 10);
- if (isNaN(width) === false) {
- targetWidth = width.valueOf();
- }
- }
-
- var targetHeight = -1;
- if (typeof options.targetHeight == "number") {
- targetHeight = options.targetHeight;
- } else if (typeof options.targetHeight == "string") {
- var height = parseInt(options.targetHeight, 10);
- if (isNaN(height) === false) {
- targetHeight = height.valueOf();
- }
- }
-
- var encodingType = Camera.EncodingType.JPEG;
- if (typeof options.encodingType == "number") {
- encodingType = options.encodingType;
- }
- // TODO: parse MediaType
- // TODO: enable allow edit?
-
- exec(successCallback, errorCallback, "Camera", "takePicture", [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType]);
-}
-
-module.exports = cameraExport;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CameraConstants.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CameraConstants.js b/lib/plugin/CameraConstants.js
deleted file mode 100644
index b379234..0000000
--- a/lib/plugin/CameraConstants.js
+++ /dev/null
@@ -1,20 +0,0 @@
-module.exports = {
- DestinationType:{
- DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
- },
- EncodingType:{
- JPEG: 0, // Return JPEG encoded image
- PNG: 1 // Return PNG encoded image
- },
- MediaType:{
- PICTURE: 0, // allow selection of still pictures only. DEFAULT. Will return format specified via DestinationType
- VIDEO: 1, // allow selection of video only, ONLY RETURNS URL
- ALLMEDIA : 2 // allow selection from all media types
- },
- PictureSourceType:{
- PHOTOLIBRARY : 0, // Choose image from picture library (same as SAVEDPHOTOALBUM for Android)
- CAMERA : 1, // Take picture from camera
- SAVEDPHOTOALBUM : 2 // Choose image from picture library (same as PHOTOLIBRARY for Android)
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CaptureAudioOptions.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CaptureAudioOptions.js b/lib/plugin/CaptureAudioOptions.js
deleted file mode 100644
index ee07932..0000000
--- a/lib/plugin/CaptureAudioOptions.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
- this.mode = null;
-};
-
-module.exports = CaptureAudioOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CaptureError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CaptureError.js b/lib/plugin/CaptureError.js
deleted file mode 100644
index b217ae4..0000000
--- a/lib/plugin/CaptureError.js
+++ /dev/null
@@ -1,19 +0,0 @@
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CaptureImageOptions.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CaptureImageOptions.js b/lib/plugin/CaptureImageOptions.js
deleted file mode 100644
index c90e8d4..0000000
--- a/lib/plugin/CaptureImageOptions.js
+++ /dev/null
@@ -1,11 +0,0 @@
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
- this.mode = null;
-};
-
-module.exports = CaptureImageOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CaptureVideoOptions.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CaptureVideoOptions.js b/lib/plugin/CaptureVideoOptions.js
deleted file mode 100644
index 5583ddb..0000000
--- a/lib/plugin/CaptureVideoOptions.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
- this.mode = null;
-};
-
-module.exports = CaptureVideoOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CompassError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CompassError.js b/lib/plugin/CompassError.js
deleted file mode 100644
index baba76d..0000000
--- a/lib/plugin/CompassError.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * CompassError.
- * An error code assigned by an implementation when an error has occured
- * @constructor
- */
-var CompassError = function(err) {
- this.code = (err !== undefined ? err : null);
-};
-
-CompassError.COMPASS_INTERNAL_ERR = 0;
-CompassError.COMPASS_NOT_SUPPORTED = 20;
-
-module.exports = CompassError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/CompassHeading.js
----------------------------------------------------------------------
diff --git a/lib/plugin/CompassHeading.js b/lib/plugin/CompassHeading.js
deleted file mode 100644
index 2336beb..0000000
--- a/lib/plugin/CompassHeading.js
+++ /dev/null
@@ -1,8 +0,0 @@
-var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
- this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
- this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
- this.timestamp = (timestamp !== undefined ? new Date(timestamp) : new Date());
-};
-
-module.exports = CompassHeading;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ConfigurationData.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ConfigurationData.js b/lib/plugin/ConfigurationData.js
deleted file mode 100644
index 838c87c..0000000
--- a/lib/plugin/ConfigurationData.js
+++ /dev/null
@@ -1,15 +0,0 @@
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Connection.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Connection.js b/lib/plugin/Connection.js
deleted file mode 100644
index 1a7fea8..0000000
--- a/lib/plugin/Connection.js
+++ /dev/null
@@ -1,12 +0,0 @@
-/**
- * Network status
- */
-module.exports = {
- UNKNOWN: "unknown",
- ETHERNET: "ethernet",
- WIFI: "wifi",
- CELL_2G: "2g",
- CELL_3G: "3g",
- CELL_4G: "4g",
- NONE: "none"
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Contact.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Contact.js b/lib/plugin/Contact.js
deleted file mode 100644
index 261bb12..0000000
--- a/lib/plugin/Contact.js
+++ /dev/null
@@ -1,177 +0,0 @@
-var exec = require('cordova/exec'),
- ContactError = require('cordova/plugin/ContactError'),
- utils = require('cordova/utils');
-
-/**
-* Converts primitives into Complex Object
-* Currently only used for Date fields
-*/
-function convertIn(contact) {
- var value = contact.birthday;
- try {
- contact.birthday = new Date(parseFloat(value));
- } catch (exception){
- console.log("Cordova Contact convertIn error: exception creating date.");
- }
- return contact;
-};
-
-/**
-* Converts Complex objects into primitives
-* Only conversion at present is for Dates.
-**/
-
-function convertOut(contact) {
- var value = contact.birthday;
- if (value != null) {
- // try to make it a Date object if it is not already
- if (!value instanceof Date){
- try {
- value = new Date(value);
- } catch(exception){
- value = null;
- }
- }
- if (value instanceof Date){
- value = value.valueOf(); // convert to milliseconds
- }
- contact.birthday = value;
- }
- return contact;
-};
-
-/**
-* Contains information about a single contact.
-* @constructor
-* @param {DOMString} id unique identifier
-* @param {DOMString} displayName
-* @param {ContactName} name
-* @param {DOMString} nickname
-* @param {Array.<ContactField>} phoneNumbers array of phone numbers
-* @param {Array.<ContactField>} emails array of email addresses
-* @param {Array.<ContactAddress>} addresses array of addresses
-* @param {Array.<ContactField>} ims instant messaging user ids
-* @param {Array.<ContactOrganization>} organizations
-* @param {DOMString} birthday contact's birthday
-* @param {DOMString} note user notes about contact
-* @param {Array.<ContactField>} photos
-* @param {Array.<ContactField>} categories
-* @param {Array.<ContactField>} urls contact's web sites
-*/
-var Contact = function (id, displayName, name, nickname, phoneNumbers, emails, addresses,
- ims, organizations, birthday, note, photos, categories, urls) {
- this.id = id || null;
- this.rawId = null;
- this.displayName = displayName || null;
- this.name = name || null; // ContactName
- this.nickname = nickname || null;
- this.phoneNumbers = phoneNumbers || null; // ContactField[]
- this.emails = emails || null; // ContactField[]
- this.addresses = addresses || null; // ContactAddress[]
- this.ims = ims || null; // ContactField[]
- this.organizations = organizations || null; // ContactOrganization[]
- this.birthday = birthday || null;
- this.note = note || null;
- this.photos = photos || null; // ContactField[]
- this.categories = categories || null; // ContactField[]
- this.urls = urls || null; // ContactField[]
-};
-
-/**
-* Removes contact from device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.remove = function(successCB, errorCB) {
- var fail = function(code) {
- errorCB(new ContactError(code));
- };
- if (this.id === null) {
- fail(ContactError.UNKNOWN_ERROR);
- }
- else {
- exec(successCB, fail, "Contacts", "remove", [this.id]);
- }
-};
-
-/**
-* Creates a deep copy of this Contact.
-* With the contact ID set to null.
-* @return copy of this Contact
-*/
-Contact.prototype.clone = function() {
- var clonedContact = utils.clone(this);
- var i;
- clonedContact.id = null;
- clonedContact.rawId = null;
- // Loop through and clear out any id's in phones, emails, etc.
- if (clonedContact.phoneNumbers) {
- for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
- clonedContact.phoneNumbers[i].id = null;
- }
- }
- if (clonedContact.emails) {
- for (i = 0; i < clonedContact.emails.length; i++) {
- clonedContact.emails[i].id = null;
- }
- }
- if (clonedContact.addresses) {
- for (i = 0; i < clonedContact.addresses.length; i++) {
- clonedContact.addresses[i].id = null;
- }
- }
- if (clonedContact.ims) {
- for (i = 0; i < clonedContact.ims.length; i++) {
- clonedContact.ims[i].id = null;
- }
- }
- if (clonedContact.organizations) {
- for (i = 0; i < clonedContact.organizations.length; i++) {
- clonedContact.organizations[i].id = null;
- }
- }
- if (clonedContact.categories) {
- for (i = 0; i < clonedContact.categories.length; i++) {
- clonedContact.categories[i].id = null;
- }
- }
- if (clonedContact.photos) {
- for (i = 0; i < clonedContact.photos.length; i++) {
- clonedContact.photos[i].id = null;
- }
- }
- if (clonedContact.urls) {
- for (i = 0; i < clonedContact.urls.length; i++) {
- clonedContact.urls[i].id = null;
- }
- }
- return clonedContact;
-};
-
-/**
-* Persists contact to device storage.
-* @param successCB success callback
-* @param errorCB error callback
-*/
-Contact.prototype.save = function(successCB, errorCB) {
- var fail = function(code) {
- errorCB(new ContactError(code));
- };
- var success = function(result) {
- if (result) {
- if (typeof successCB === 'function') {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
- var dupContact = convertOut(utils.clone(this));
- exec(success, fail, "Contacts", "save", [dupContact]);
-};
-
-
-module.exports = Contact;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactAddress.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactAddress.js b/lib/plugin/ContactAddress.js
deleted file mode 100644
index 9fa3605..0000000
--- a/lib/plugin/ContactAddress.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
-* Contact address.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code
-* @param formatted // NOTE: not a W3C standard
-* @param streetAddress
-* @param locality
-* @param region
-* @param postalCode
-* @param country
-*/
-
-var ContactAddress = function(pref, type, formatted, streetAddress, locality, region, postalCode, country) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.formatted = formatted || null;
- this.streetAddress = streetAddress || null;
- this.locality = locality || null;
- this.region = region || null;
- this.postalCode = postalCode || null;
- this.country = country || null;
-};
-
-module.exports = ContactAddress;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactError.js b/lib/plugin/ContactError.js
deleted file mode 100644
index 324a0cf..0000000
--- a/lib/plugin/ContactError.js
+++ /dev/null
@@ -1,21 +0,0 @@
-/**
- * ContactError.
- * An error code assigned by an implementation when an error has occured
- * @constructor
- */
-var ContactError = function(err) {
- this.code = (typeof err != 'undefined' ? err : null);
-};
-
-/**
- * Error codes
- */
-ContactError.UNKNOWN_ERROR = 0;
-ContactError.INVALID_ARGUMENT_ERROR = 1;
-ContactError.TIMEOUT_ERROR = 2;
-ContactError.PENDING_OPERATION_ERROR = 3;
-ContactError.IO_ERROR = 4;
-ContactError.NOT_SUPPORTED_ERROR = 5;
-ContactError.PERMISSION_DENIED_ERROR = 20;
-
-module.exports = ContactError;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactField.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactField.js b/lib/plugin/ContactField.js
deleted file mode 100644
index c2a8ac1..0000000
--- a/lib/plugin/ContactField.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/**
-* Generic contact field.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param type
-* @param value
-* @param pref
-*/
-var ContactField = function(type, value, pref) {
- this.id = null;
- this.type = type || null;
- this.value = value || null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
-};
-
-module.exports = ContactField;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactFindOptions.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactFindOptions.js b/lib/plugin/ContactFindOptions.js
deleted file mode 100644
index 036c4c6..0000000
--- a/lib/plugin/ContactFindOptions.js
+++ /dev/null
@@ -1,13 +0,0 @@
-/**
- * ContactFindOptions.
- * @constructor
- * @param filter used to match contacts against
- * @param multiple boolean used to determine if more than one contact should be returned
- */
-
-var ContactFindOptions = function(filter, multiple) {
- this.filter = filter || '';
- this.multiple = (typeof multiple != 'undefined' ? multiple : false);
-};
-
-module.exports = ContactFindOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactName.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactName.js b/lib/plugin/ContactName.js
deleted file mode 100644
index 5434e74..0000000
--- a/lib/plugin/ContactName.js
+++ /dev/null
@@ -1,20 +0,0 @@
-/**
-* Contact name.
-* @constructor
-* @param formatted // NOTE: not part of W3C standard
-* @param familyName
-* @param givenName
-* @param middle
-* @param prefix
-* @param suffix
-*/
-var ContactName = function(formatted, familyName, givenName, middle, prefix, suffix) {
- this.formatted = formatted || null;
- this.familyName = familyName || null;
- this.givenName = givenName || null;
- this.middleName = middle || null;
- this.honorificPrefix = prefix || null;
- this.honorificSuffix = suffix || null;
-};
-
-module.exports = ContactName;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/ContactOrganization.js
----------------------------------------------------------------------
diff --git a/lib/plugin/ContactOrganization.js b/lib/plugin/ContactOrganization.js
deleted file mode 100644
index 32ec462..0000000
--- a/lib/plugin/ContactOrganization.js
+++ /dev/null
@@ -1,23 +0,0 @@
-/**
-* Contact organization.
-* @constructor
-* @param {DOMString} id unique identifier, should only be set by native code // NOTE: not a W3C standard
-* @param name
-* @param dept
-* @param title
-* @param startDate
-* @param endDate
-* @param location
-* @param desc
-*/
-
-var ContactOrganization = function(pref, type, name, dept, title) {
- this.id = null;
- this.pref = (typeof pref != 'undefined' ? pref : false);
- this.type = type || null;
- this.name = name || null;
- this.department = dept || null;
- this.title = title || null;
-};
-
-module.exports = ContactOrganization;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Coordinates.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Coordinates.js b/lib/plugin/Coordinates.js
deleted file mode 100644
index d783e1c..0000000
--- a/lib/plugin/Coordinates.js
+++ /dev/null
@@ -1,43 +0,0 @@
-/**
- * This class contains position information.
- * @param {Object} lat
- * @param {Object} lng
- * @param {Object} alt
- * @param {Object} acc
- * @param {Object} head
- * @param {Object} vel
- * @param {Object} altacc
- * @constructor
- */
-var Coordinates = function(lat, lng, alt, acc, head, vel, altacc) {
- /**
- * The latitude of the position.
- */
- this.latitude = lat;
- /**
- * The longitude of the position,
- */
- this.longitude = lng;
- /**
- * The accuracy of the position.
- */
- this.accuracy = acc;
- /**
- * The altitude of the position.
- */
- this.altitude = alt;
- /**
- * The direction the device is moving at the position.
- */
- this.heading = head;
- /**
- * The velocity with which the device is moving at the position.
- */
- this.speed = vel;
- /**
- * The altitude accuracy of the position.
- */
- this.altitudeAccuracy = (altacc !== undefined) ? altacc : null;
-};
-
-module.exports = Coordinates;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/DirectoryEntry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/DirectoryEntry.js b/lib/plugin/DirectoryEntry.js
deleted file mode 100644
index e9949d0..0000000
--- a/lib/plugin/DirectoryEntry.js
+++ /dev/null
@@ -1,80 +0,0 @@
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- DirectoryReader = require('cordova/plugin/DirectoryReader');
-
-/**
- * An interface representing a directory on the file system.
- *
- * {boolean} isFile always false (readonly)
- * {boolean} isDirectory always true (readonly)
- * {DOMString} name of the directory, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the directory (readonly)
- * {FileSystem} filesystem on which the directory resides (readonly)
- */
-var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
-};
-
-utils.extend(DirectoryEntry, Entry);
-
-/**
- * Creates a new DirectoryReader to read entries from this directory
- */
-DirectoryEntry.prototype.createReader = function() {
- return new DirectoryReader(this.fullPath);
-};
-
-/**
- * Creates or looks up a directory
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or excluively create the directory
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var entry = new DirectoryEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
-};
-
-/**
- * Deletes a directory and all of it's contents
- *
- * @param {Function} successCallback is called with no parameters
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
-};
-
-/**
- * Creates or looks up a file
- *
- * @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or excluively create the file
- * @param {Function} successCallback is called with the new entry
- * @param {Function} errorCallback is called with a FileError
- */
-DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
- var FileEntry = require('cordova/plugin/FileEntry');
- var entry = new FileEntry(result.name, result.fullPath);
- successCallback(entry);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
-};
-
-module.exports = DirectoryEntry;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/DirectoryReader.js
----------------------------------------------------------------------
diff --git a/lib/plugin/DirectoryReader.js b/lib/plugin/DirectoryReader.js
deleted file mode 100644
index 90e67a4..0000000
--- a/lib/plugin/DirectoryReader.js
+++ /dev/null
@@ -1,41 +0,0 @@
-var exec = require('cordova/exec');
-
-/**
- * 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 DirectoryEntry();
- }
- else if (result[i].isFile) {
- entry = new 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));
- };
- exec(win, fail, "File", "readEntries", [this.path]);
-};
-
-module.exports = DirectoryReader;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/Entry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/Entry.js b/lib/plugin/Entry.js
deleted file mode 100644
index f748dcc..0000000
--- a/lib/plugin/Entry.js
+++ /dev/null
@@ -1,198 +0,0 @@
-var exec = require('cordova/exec'),
- FileError = require('cordova/plugin/FileError'),
- Metadata = require('cordova/plugin/Metadata');
-
-/**
- * Represents a file or directory on the local file system.
- *
- * @param isFile
- * {boolean} true if Entry is a file (readonly)
- * @param isDirectory
- * {boolean} true if Entry is a directory (readonly)
- * @param name
- * {DOMString} name of the file or directory, excluding the path
- * leading to it (readonly)
- * @param fullPath
- * {DOMString} the absolute full path to the file or directory
- * (readonly)
- */
-function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = (typeof isFile != 'undefined'?isFile:false);
- this.isDirectory = (typeof isDirectory != 'undefined'?isDirectory:false);
- this.name = name || '';
- this.fullPath = fullPath || '';
- this.filesystem = fileSystem || null;
-}
-
-/**
- * Look up the metadata of the entry.
- *
- * @param successCallback
- * {Function} is called with a Metadata object
- * @param errorCallback
- * {Function} is called with a FileError
- */
-Entry.prototype.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));
- };
-
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
-};
-
-/**
- * Move a file or directory to a new location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to move this entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new DirectoryEntry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.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 (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/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);
- }
- };
-
- // copy
- exec(success, fail, "File", "moveTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Copy a directory to a different location.
- *
- * @param parent
- * {DirectoryEntry} the directory to which to copy the entry
- * @param newName
- * {DOMString} new name of the entry, defaults to the current name
- * @param successCallback
- * {Function} called with the new Entry object
- * @param errorCallback
- * {Function} called with a FileError
- */
-Entry.prototype.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 callback
- success = function(entry) {
- if (entry) {
- if (typeof successCallback === 'function') {
- // create appropriate Entry object
- var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/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);
- }
- };
-
- // copy
- exec(success, fail, "File", "copyTo", [srcPath, parent.fullPath, name]);
-};
-
-/**
- * Return a URL that can be used to identify this entry.
- */
-Entry.prototype.toURL = function() {
- // fullPath attribute contains the full URL
- return this.fullPath;
-};
-
-/**
- * Returns a URI that can be used to identify this entry.
- *
- * @param {DOMString} mimeType for a FileEntry, the mime type to be used to interpret the file, when loaded through this URI.
- * @return uri
- */
-Entry.prototype.toURI = function(mimeType) {
- console.log("DEPRECATED: Update your code to use 'toURL'");
- // fullPath attribute contains the full URI
- return this.fullPath;
-};
-
-/**
- * Remove a file or directory. It is an error to attempt to delete a
- * directory that is not empty. It is an error to attempt to delete a
- * root directory of a file system.
- *
- * @param successCallback {Function} called with no parameters
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.remove = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "remove", [this.fullPath]);
-};
-
-/**
- * Look up the parent DirectoryEntry of this entry.
- *
- * @param successCallback {Function} called with the parent DirectoryEntry object
- * @param errorCallback {Function} called with a FileError
- */
-Entry.prototype.getParent = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
- exec(successCallback, fail, "File", "getParent", [this.fullPath]);
-};
-
-module.exports = Entry;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/File.js
----------------------------------------------------------------------
diff --git a/lib/plugin/File.js b/lib/plugin/File.js
deleted file mode 100644
index 96de0d7..0000000
--- a/lib/plugin/File.js
+++ /dev/null
@@ -1,18 +0,0 @@
-/**
- * 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/76f64673/lib/plugin/FileEntry.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileEntry.js b/lib/plugin/FileEntry.js
deleted file mode 100644
index cbe22c4..0000000
--- a/lib/plugin/FileEntry.js
+++ /dev/null
@@ -1,63 +0,0 @@
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- Entry = require('cordova/plugin/Entry'),
- FileWriter = require('cordova/plugin/FileWriter'),
- File = require('cordova/plugin/File'),
- FileError = require('cordova/plugin/FileError');
-
-/**
- * An interface representing a file on the file system.
- *
- * {boolean} isFile always true (readonly)
- * {boolean} isDirectory always false (readonly)
- * {DOMString} name of the file, excluding the path leading to it (readonly)
- * {DOMString} fullPath the absolute full path to the file (readonly)
- * {FileSystem} filesystem on which the file resides (readonly)
- */
-var FileEntry = function(name, fullPath) {
- FileEntry.__super__.constructor.apply(this, [true, false, name, fullPath]);
-};
-
-utils.extend(FileEntry, Entry);
-
-/**
- * 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
- */
-FileEntry.prototype.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
- */
-FileEntry.prototype.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));
- };
- exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
-};
-
-
-module.exports = FileEntry;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/76f64673/lib/plugin/FileError.js
----------------------------------------------------------------------
diff --git a/lib/plugin/FileError.js b/lib/plugin/FileError.js
deleted file mode 100644
index f61c092..0000000
--- a/lib/plugin/FileError.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/**
- * FileError
- */
-function FileError(error) {
- this.code = error || null;
-}
-
-// File error codes
-// Found in DOMException
-FileError.NOT_FOUND_ERR = 1;
-FileError.SECURITY_ERR = 2;
-FileError.ABORT_ERR = 3;
-
-// Added by File API specification
-FileError.NOT_READABLE_ERR = 4;
-FileError.ENCODING_ERR = 5;
-FileError.NO_MODIFICATION_ALLOWED_ERR = 6;
-FileError.INVALID_STATE_ERR = 7;
-FileError.SYNTAX_ERR = 8;
-FileError.INVALID_MODIFICATION_ERR = 9;
-FileError.QUOTA_EXCEEDED_ERR = 10;
-FileError.TYPE_MISMATCH_ERR = 11;
-FileError.PATH_EXISTS_ERR = 12;
-
-module.exports = FileError;