You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2012/11/07 01:15:20 UTC
[2/8] js commit: mass rename
mass rename
Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/commit/8789b412
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/tree/8789b412
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/diff/8789b412
Branch: refs/heads/master
Commit: 8789b41207436cc0470eba842dfe7b3cce741cc7
Parents: f7a572d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Nov 6 16:07:23 2012 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Nov 6 16:07:23 2012 -0800
----------------------------------------------------------------------
build/packager.js | 3 +-
lib/windowsphone/exec.js | 68 +++++
lib/windowsphone/platform.js | 77 +++++
.../plugin/windowsphone/CordovaCommandResult.js | 74 +++++
.../plugin/windowsphone/CordovaMediaonStatus.js | 38 +++
lib/windowsphone/plugin/windowsphone/DOMStorage.js | 200 +++++++++++++
.../plugin/windowsphone/FileTransfer.js | 123 ++++++++
.../plugin/windowsphone/FileUploadOptions.js | 47 +++
lib/windowsphone/plugin/windowsphone/XHRPatch.js | 230 +++++++++++++++
lib/windowsphone/plugin/windowsphone/console.js | 45 +++
lib/wp/exec.js | 68 -----
lib/wp/platform.js | 77 -----
lib/wp/plugin/wp/CordovaCommandResult.js | 74 -----
lib/wp/plugin/wp/CordovaMediaonStatus.js | 38 ---
lib/wp/plugin/wp/DOMStorage.js | 200 -------------
lib/wp/plugin/wp/FileTransfer.js | 123 --------
lib/wp/plugin/wp/FileUploadOptions.js | 47 ---
lib/wp/plugin/wp/XHRPatch.js | 230 ---------------
lib/wp/plugin/wp/console.js | 45 ---
lib/wp7/exec.js | 68 -----
lib/wp7/platform.js | 74 -----
lib/wp7/plugin/wp7/CordovaCommandResult.js | 74 -----
lib/wp7/plugin/wp7/CordovaMediaonStatus.js | 38 ---
lib/wp7/plugin/wp7/DOMStorage.js | 195 ------------
lib/wp7/plugin/wp7/FileTransfer.js | 123 --------
lib/wp7/plugin/wp7/FileUploadOptions.js | 47 ---
lib/wp7/plugin/wp7/XHRPatch.js | 230 ---------------
lib/wp7/plugin/wp7/console.js | 45 ---
28 files changed, 903 insertions(+), 1798 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/build/packager.js
----------------------------------------------------------------------
diff --git a/build/packager.js b/build/packager.js
index 20d7ed6..633ba2c 100644
--- a/build/packager.js
+++ b/build/packager.js
@@ -56,8 +56,7 @@ packager.bundle = function(platform, debug, commitId ) {
//Test platform needs to bring in platform specific plugin's for testing
copyProps(modules, collectFiles(path.join('lib', 'blackberry', 'plugin'), 'plugin'));
copyProps(modules, collectFiles(path.join('lib', 'tizen', 'plugin', 'tizen'), 'plubin/tizen'));
- copyProps(modules, collectFiles(path.join('lib', 'wp7', 'plugin', 'wp7'), 'plugin/wp7'));
- copyProps(modules, collectFiles(path.join('lib', 'wp', 'plugin', 'wp'), 'plugin/wp'));
+ copyProps(modules, collectFiles(path.join('lib', 'windowsphone', 'plugin', 'windowsphone'), 'plugin/windowsphone'));
copyProps(modules, collectFiles(path.join('lib', 'windows8', 'plugin', 'windows8'), 'plugin/windows8'));
copyProps(modules, collectFiles(path.join('lib', 'ios', 'plugin', 'ios'), 'plugin/ios/'));
copyProps(modules, collectFiles(path.join('lib', 'bada', 'plugin', 'bada'), 'plugin/bada/'));
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/exec.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/exec.js b/lib/windowsphone/exec.js
new file mode 100644
index 0000000..96eb306
--- /dev/null
+++ b/lib/windowsphone/exec.js
@@ -0,0 +1,68 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova');
+
+/**
+ * Execute a cordova command. It is up to the native side whether this action
+ * is synchronous or asynchronous. The native side can return:
+ * Synchronous: PluginResult object as a JSON string
+ * Asynchronous: Empty string ""
+ * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
+ * depending upon the result of the action.
+ *
+ * @param {Function} success The success callback
+ * @param {Function} fail The fail callback
+ * @param {String} service The name of the service to use
+ * @param {String} action Action to be run in cordova
+ * @param {String[]} [args] Zero or more arguments to pass to the method
+
+ */
+
+module.exports = function(success, fail, service, action, args) {
+
+ var callbackId = service + cordova.callbackId++;
+ if (typeof success == "function" || typeof fail == "function") {
+ cordova.callbacks[callbackId] = {success:success, fail:fail};
+ }
+ // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"]
+ for(var n = 0; n < args.length; n++)
+ {
+ if(typeof args[n] !== "string")
+ {
+ args[n] = JSON.stringify(args[n]);
+ }
+ }
+ var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
+ // pass it on to Notify
+ try {
+ if(window.external) {
+ window.external.Notify(command);
+ }
+ else {
+ console.log("window.external not available :: command=" + command);
+ }
+ }
+ catch(e) {
+ console.log("Exception calling native with command :: " + command + " :: exception=" + e);
+ }
+};
+
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/platform.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/platform.js b/lib/windowsphone/platform.js
new file mode 100644
index 0000000..b387104
--- /dev/null
+++ b/lib/windowsphone/platform.js
@@ -0,0 +1,77 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var cordova = require('cordova'),
+ exec = require('cordova/exec');
+
+// specifically require the following patches :
+
+// localStorage+SessionStorage APIs
+require("cordova/plugin/windowsphone/DOMStorage");
+
+// Fix XHR calls to local file-system
+require("cordova/plugin/windowsphone/XHRPatch");
+
+
+module.exports = {
+ id: "windowsphone",
+ initialize:function() {
+ window.alert = require("cordova/plugin/notification").alert;
+ window.FileReader = require("cordova/plugin/FileReader");
+ window.File = require("cordova/plugin/File");
+
+
+ // Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
+ var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
+ backButtonChannel.onHasSubscribersChange = function() {
+ exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]);
+ };
+ },
+ objects: {
+ CordovaCommandResult: {
+ path:"cordova/plugin/windowsphone/CordovaCommandResult"
+ },
+ CordovaMediaonStatus: {
+ path:"cordova/plugin/windowsphone/CordovaMediaonStatus"
+ },
+ navigator: {
+ children: {
+ device: {
+ children:{
+ capture:{
+ path:"cordova/plugin/capture"
+ }
+ }
+ },
+ console: {
+ path: "cordova/plugin/windowsphone/console"
+
+ }
+ }
+ },
+ console:{
+ path: "cordova/plugin/windowsphone/console"
+ },
+ FileTransfer: {
+ path: 'cordova/plugin/windowsphone/FileTransfer'
+ }
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/CordovaCommandResult.js b/lib/windowsphone/plugin/windowsphone/CordovaCommandResult.js
new file mode 100644
index 0000000..dae5279
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/CordovaCommandResult.js
@@ -0,0 +1,74 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+var cordova = require('cordova');
+var channel = require('cordova/channel');
+
+// singular WP callback function attached to window, status is used to determine if it is a success or error
+module.exports = function(status,callbackId,args,cast) {
+
+ if(status === "backbutton") {
+ // do not detach backbutton event, as we need to be able to catch exceptions
+ cordova.fireDocumentEvent("backbutton", undefined, true);
+ return "true";
+ }
+ else if(status === "resume") {
+ cordova.fireDocumentEvent('resume');
+ return "true";
+ }
+ else if(status === "pause") {
+ cordova.fireDocumentEvent('pause');
+ return "true";
+ }
+
+ var parsedArgs;
+ try
+ {
+ parsedArgs = JSON.parse(args);
+
+ }
+ catch(ex)
+ {
+ console.log("Parse error in CordovaCommandResult :: " + ex);
+ return;
+ }
+
+ try
+ {
+ // For some commands, the message is a JSON encoded string
+ // and other times, it is just a string, the try/catch handles the
+ // case where message was indeed, just a string.
+ parsedArgs.message = JSON.parse(parsedArgs.message);
+ }
+ catch(ex)
+ {
+
+ }
+ var safeStatus = parseInt(status, 10);
+ if(safeStatus === cordova.callbackStatus.NO_RESULT ||
+ safeStatus === cordova.callbackStatus.OK) {
+ cordova.callbackSuccess(callbackId,parsedArgs,cast);
+ }
+ else {
+ cordova.callbackError(callbackId,parsedArgs,cast);
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/CordovaMediaonStatus.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/CordovaMediaonStatus.js b/lib/windowsphone/plugin/windowsphone/CordovaMediaonStatus.js
new file mode 100644
index 0000000..8cd0879
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/CordovaMediaonStatus.js
@@ -0,0 +1,38 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+var cordova = require('cordova');
+var Media = require('cordova/plugin/Media');
+
+module.exports = function(args) {
+ try {
+
+ var res = JSON.parse(args);
+ if(res.msg == Media.MEDIA_ERROR) {
+ res.value = {'code':res.value};
+ }
+ Media.onStatus(res.id, res.msg, res.value);
+ }
+ catch(e) {
+ console.log("Error calling Media.onStatus :: " + e);
+ }
+};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/DOMStorage.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/DOMStorage.js b/lib/windowsphone/plugin/windowsphone/DOMStorage.js
new file mode 100644
index 0000000..67205b8
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/DOMStorage.js
@@ -0,0 +1,200 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+(function(win,doc) {
+
+var docDomain = null;
+try {
+ docDomain = doc.domain;
+} catch (err) {
+ //console.log("caught exception trying to access document.domain");
+}
+
+// conditionally patch the window.localStorage and window.sessionStorage objects
+if (!docDomain || docDomain.length === 0) {
+
+ var DOMStorage = function(type) {
+ // default type is local
+ if(type == "sessionStorage") {
+ this._type = type;
+ }
+ Object.defineProperty( this, "length", {
+ configurable: true,
+ get: function(){ return this.getLength(); }
+ });
+ };
+
+ DOMStorage.prototype = {
+ _type:"localStorage",
+ _result:null,
+ keys:null,
+
+ onResult:function(key,valueStr) {
+ if(!this.keys) {
+ this.keys = [];
+ }
+ this._result = valueStr;
+ },
+
+ onKeysChanged:function(jsonKeys) {
+ this.keys = JSON.parse(jsonKeys);
+
+ var key;
+ for(var n = 0,len = this.keys.length; n < len; n++) {
+ key = this.keys[n];
+ if(!this.hasOwnProperty(key)) {
+ Object.defineProperty( this, key, {
+ configurable: true,
+ get: function(){ return this.getItem(key); },
+ set: function(val){ return this.setItem(key,val); }
+ });
+ }
+ }
+
+ },
+
+ initialize:function() {
+ window.external.Notify("DOMStorage/" + this._type + "/load/keys");
+ },
+
+ /*
+ The length attribute must return the number of key/value pairs currently present
+ in the list associated with the object.
+ */
+ getLength:function() {
+ if(!this.keys) {
+ this.initialize();
+ }
+ return this.keys.length;
+ },
+
+ /*
+ The key(n) method must return the name of the nth key in the list.
+ The order of keys is user-agent defined, but must be consistent within an object so long as the number of keys doesn't change.
+ (Thus, adding or removing a key may change the order of the keys, but merely changing the value of an existing key must not.)
+ If n is greater than or equal to the number of key/value pairs in the object, then this method must return null.
+ */
+ key:function(n) {
+ if(!this.keys) {
+ this.initialize();
+ }
+
+ if(n >= this.keys.length) {
+ return null;
+ } else {
+ return this.keys[n];
+ }
+ },
+
+ /*
+ The getItem(key) method must return the current value associated with the given key.
+ If the given key does not exist in the list associated with the object then this method must return null.
+ */
+ getItem:function(key) {
+ if(!this.keys) {
+ this.initialize();
+ }
+
+ var retVal = null;
+ if(this.keys.indexOf(key) > -1) {
+ window.external.Notify("DOMStorage/" + this._type + "/get/" + key);
+ retVal = window.unescape(decodeURIComponent(this._result));
+ this._result = null;
+ }
+ return retVal;
+ },
+ /*
+ The setItem(key, value) method must first check if a key/value pair with the given key already exists
+ in the list associated with the object.
+ If it does not, then a new key/value pair must be added to the list, with the given key and with its value set to value.
+ If the given key does exist in the list, then it must have its value updated to value.
+ If it couldn't set the new value, the method must raise an QUOTA_EXCEEDED_ERR exception.
+ (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
+ */
+ setItem:function(key,value) {
+ if(!this.keys) {
+ this.initialize();
+ }
+ window.external.Notify("DOMStorage/" + this._type + "/set/" + key + "/" + encodeURIComponent(window.escape(value)));
+ },
+
+ /*
+ The removeItem(key) method must cause the key/value pair with the given key to be removed from the list
+ associated with the object, if it exists.
+ If no item with that key exists, the method must do nothing.
+ */
+ removeItem:function(key) {
+ if(!this.keys) {
+ this.initialize();
+ }
+ var index = this.keys.indexOf(key);
+ if(index > -1) {
+ this.keys.splice(index,1);
+ // TODO: need sanity check for keys ? like 'clear','setItem', ...
+ window.external.Notify("DOMStorage/" + this._type + "/remove/" + key);
+ delete this[key];
+ }
+ },
+
+ /*
+ The clear() method must atomically cause the list associated with the object to be emptied of all
+ key/value pairs, if there are any.
+ If there are none, then the method must do nothing.
+ */
+ clear:function() {
+ if(!this.keys) {
+ this.initialize();
+ }
+
+ for(var n=0,len=this.keys.length; n < len;n++) {
+ // TODO: do we need a sanity check for keys ? like 'clear','setItem', ...
+ delete this[this.keys[n]];
+ }
+ this.keys = [];
+ window.external.Notify("DOMStorage/" + this._type + "/clear/");
+ }
+ };
+
+ // initialize DOMStorage
+
+ if (typeof window.localStorage === "undefined") {
+
+ Object.defineProperty(window, "localStorage", {
+ writable: false,
+ configurable: false,
+ value: new DOMStorage("localStorage")
+ });
+ window.localStorage.initialize();
+ }
+
+ if (typeof window.sessionStorage === "undefined") {
+ Object.defineProperty(window, "sessionStorage", {
+ writable: false,
+ configurable: false,
+ value: new DOMStorage("sessionStorage")
+ });
+ window.sessionStorage.initialize();
+ }
+}
+
+})(window, document);
+
+module.exports = null;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/FileTransfer.js b/lib/windowsphone/plugin/windowsphone/FileTransfer.js
new file mode 100644
index 0000000..b2f8686
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/FileTransfer.js
@@ -0,0 +1,123 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+var exec = require('cordova/exec'),
+ FileTransferError = require('cordova/plugin/FileTransferError');
+
+// Note that the only difference between this and the default implementation is the
+// object literal passed to exec() in upload - jm
+
+/**
+ * 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
+* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
+*/
+
+FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
+
+ // sanity parameter checking
+ if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum.");
+ // 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 are specified, and NOT a string already, we will stringify it.
+ if(options.params && typeof options.params != typeof "") {
+ var arrParams = [];
+ for(var v in options.params) {
+ arrParams.push(v + "=" + options.params[v]);
+ }
+ params = encodeURI(arrParams.join("&"));
+ }
+ }
+
+ var fail = function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+ errorCallback(error);
+ };
+ exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
+ "server":server,
+ "fileKey":fileKey,
+ "fileName":fileName,
+ "mimeType":mimeType,
+ "params":params,
+ "trustAllHosts":trustAllHosts,
+ "chunkedMode":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) {
+ // sanity parameter checking
+ if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
+ var win = function(result) {
+ var entry = null;
+ if (result.isDirectory) {
+ entry = new (require('cordova/plugin/DirectoryEntry'))();
+ }
+ else if (result.isFile) {
+ entry = new (require('cordova/plugin/FileEntry'))();
+ }
+ entry.isDirectory = result.isDirectory;
+ entry.isFile = result.isFile;
+ entry.name = result.name;
+ entry.fullPath = result.fullPath;
+ successCallback(entry);
+ };
+
+ var fail = function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+ errorCallback(error);
+ };
+
+ exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
+};
+
+
+module.exports = FileTransfer;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/FileUploadOptions.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/FileUploadOptions.js b/lib/windowsphone/plugin/windowsphone/FileUploadOptions.js
new file mode 100644
index 0000000..44b0978
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/FileUploadOptions.js
@@ -0,0 +1,47 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+/**
+ * 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;
+
+ if(params && typeof params != typeof "") {
+ var arrParams = [];
+ for(var v in params) {
+ arrParams.push(v + "=" + params[v]);
+ }
+ this.params = encodeURIComponent(arrParams.join("&"));
+ }
+ else {
+ this.params = params || null;
+ }
+};
+
+module.exports = FileUploadOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/XHRPatch.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/XHRPatch.js b/lib/windowsphone/plugin/windowsphone/XHRPatch.js
new file mode 100644
index 0000000..9c9d62a
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/XHRPatch.js
@@ -0,0 +1,230 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+// TODO: the build process will implicitly wrap this in a define() call
+// with a closure of its own; do you need this extra closure?
+
+var LocalFileSystem = require('cordova/plugin/LocalFileSystem');
+
+(function (win, doc) {
+
+var docDomain = null;
+try {
+ docDomain = doc.domain;
+} catch (err) {
+ //console.log("caught exception trying to access document.domain");
+}
+
+if (!docDomain || docDomain.length === 0) {
+
+ var aliasXHR = win.XMLHttpRequest;
+
+ win.XMLHttpRequest = function () { };
+ win.XMLHttpRequest.noConflict = aliasXHR;
+ win.XMLHttpRequest.UNSENT = 0;
+ win.XMLHttpRequest.OPENED = 1;
+ win.XMLHttpRequest.HEADERS_RECEIVED = 2;
+ win.XMLHttpRequest.LOADING = 3;
+ win.XMLHttpRequest.DONE = 4;
+
+ win.XMLHttpRequest.prototype = {
+ UNSENT: 0,
+ OPENED: 1,
+ HEADERS_RECEIVED: 2,
+ LOADING: 3,
+ DONE: 4,
+
+ isAsync: false,
+ onreadystatechange: null,
+ readyState: 0,
+ _url: "",
+ timeout: 0,
+ withCredentials: false,
+ _requestHeaders: null,
+ open: function (reqType, uri, isAsync, user, password) {
+
+ if (uri && uri.indexOf("http") === 0) {
+ if (!this.wrappedXHR) {
+ this.wrappedXHR = new aliasXHR();
+ var self = this;
+
+ // timeout
+ if (this.timeout > 0) {
+ this.wrappedXHR.timeout = this.timeout;
+ }
+ Object.defineProperty(this, "timeout", {
+ set: function (val) {
+ this.wrappedXHR.timeout = val;
+ },
+ get: function () {
+ return this.wrappedXHR.timeout;
+ }
+ });
+
+
+
+ if (this.withCredentials) {
+ this.wrappedXHR.withCredentials = this.withCredentials;
+ }
+ Object.defineProperty(this, "withCredentials", {
+ set: function (val) {
+ this.wrappedXHR.withCredentials = val;
+ },
+ get: function () {
+ return this.wrappedXHR.withCredentials;
+ }
+ });
+
+
+ Object.defineProperty(this, "status", { get: function () {
+ return this.wrappedXHR.status;
+ }
+ });
+ Object.defineProperty(this, "responseText", { get: function () {
+ return this.wrappedXHR.responseText;
+ }
+ });
+ Object.defineProperty(this, "statusText", { get: function () {
+ return this.wrappedXHR.statusText;
+ }
+ });
+
+ Object.defineProperty(this, "responseXML", { get: function () {
+ return this.wrappedXHR.responseXML;
+ }
+ });
+
+ this.getResponseHeader = function (header) {
+ return this.wrappedXHR.getResponseHeader(header);
+ };
+ this.getAllResponseHeaders = function () {
+ return this.wrappedXHR.getAllResponseHeaders();
+ };
+
+ this.wrappedXHR.onreadystatechange = function () {
+ self.changeReadyState(self.wrappedXHR.readyState);
+ };
+ }
+ return this.wrappedXHR.open(reqType, uri, isAsync, user, password);
+ }
+ else {
+ // x-wmapp1://app/www/page2.html
+ // need to work some magic on the actual url/filepath
+ var newUrl = uri;
+ if (newUrl.indexOf(":/") > -1) {
+ newUrl = newUrl.split(":/")[1];
+ }
+ // prefix relative urls to our physical root
+ if(newUrl.indexOf("app/www/") < 0)
+ {
+ newUrl = "app/www/" + newUrl;
+ }
+
+ if (newUrl.lastIndexOf("/") === newUrl.length - 1) {
+ newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? )
+ }
+ this._url = newUrl;
+ }
+ },
+ statusText: "",
+ changeReadyState: function (newState) {
+ this.readyState = newState;
+ if (this.onreadystatechange) {
+ this.onreadystatechange();
+ }
+ },
+ setRequestHeader: function (header, value) {
+ if (this.wrappedXHR) {
+ this.wrappedXHR.setRequestHeader(header, value);
+ }
+ },
+ getResponseHeader: function (header) {
+ return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : "";
+ },
+ getAllResponseHeaders: function () {
+ return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : "";
+ },
+ responseText: "",
+ responseXML: "",
+ onResult: function (res) {
+ this.status = 200;
+ if(typeof res == "object")
+ { // callback result handler may have already parsed this from a string-> a JSON object,
+ // if so, we need to restore its stringyness, as handlers are expecting string data.
+ // especially if used with jQ -> $.getJSON
+ res = JSON.stringify(res);
+ }
+ this.responseText = res;
+ this.responseXML = res;
+ this.changeReadyState(this.DONE);
+ },
+ onError: function (err) {
+ this.status = 404;
+ this.changeReadyState(this.DONE);
+ },
+
+ abort: function () {
+ if (this.wrappedXHR) {
+ return this.wrappedXHR.abort();
+ }
+ },
+
+ send: function (data) {
+ if (this.wrappedXHR) {
+ return this.wrappedXHR.send(data);
+ }
+ else {
+ this.changeReadyState(this.OPENED);
+
+ var alias = this;
+
+ var fail = function fail(evt) {
+ alias.onError(evt.code);
+ };
+
+ var gotFile = function gotFile(file) {
+ var reader = new FileReader();
+ reader.onloadend = function (evt) {
+ alias.onResult.apply(alias,[evt.target.result]);
+ };
+ reader.readAsText(file);
+ };
+
+ var gotEntry = function gotEntry(entry) {
+ entry.file(gotFile, fail);
+ };
+
+ var gotFS = function gotFS(fs) {
+ fs.root.getFile(alias._url, null, gotEntry, fail);
+ };
+
+ window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
+
+ }
+ },
+ status: 404
+ };
+} // if doc domain
+
+// end closure wrap
+})(window, document);
+
+module.exports = null;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/windowsphone/plugin/windowsphone/console.js
----------------------------------------------------------------------
diff --git a/lib/windowsphone/plugin/windowsphone/console.js b/lib/windowsphone/plugin/windowsphone/console.js
new file mode 100644
index 0000000..20197d5
--- /dev/null
+++ b/lib/windowsphone/plugin/windowsphone/console.js
@@ -0,0 +1,45 @@
+/*
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *
+*/
+
+
+var exec = require('cordova/exec'),
+ channel = require('cordova/channel');
+var cordova = require("cordova");
+
+var debugConsole = {
+ log:function(msg){
+ exec(null,null,"DebugConsole","log",msg);
+ },
+ warn:function(msg){
+ exec(null,null,"DebugConsole","warn",msg);
+ },
+ error:function(msg){
+ exec(null,null,"DebugConsole","error",msg);
+ }
+};
+
+var oldOnError = window.onerror;
+window.onerror = function(msg,fileName,line) {
+ oldOnError && oldOnError(msg,fileName,line);
+ debugConsole.error(msg + " file:" + fileName + " Line:" + line);
+};
+
+module.exports = debugConsole;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/exec.js
----------------------------------------------------------------------
diff --git a/lib/wp/exec.js b/lib/wp/exec.js
deleted file mode 100644
index 96eb306..0000000
--- a/lib/wp/exec.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova');
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
-
- */
-
-module.exports = function(success, fail, service, action, args) {
-
- var callbackId = service + cordova.callbackId++;
- if (typeof success == "function" || typeof fail == "function") {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
- // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"]
- for(var n = 0; n < args.length; n++)
- {
- if(typeof args[n] !== "string")
- {
- args[n] = JSON.stringify(args[n]);
- }
- }
- var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
- // pass it on to Notify
- try {
- if(window.external) {
- window.external.Notify(command);
- }
- else {
- console.log("window.external not available :: command=" + command);
- }
- }
- catch(e) {
- console.log("Exception calling native with command :: " + command + " :: exception=" + e);
- }
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/platform.js
----------------------------------------------------------------------
diff --git a/lib/wp/platform.js b/lib/wp/platform.js
deleted file mode 100644
index 5f46ba6..0000000
--- a/lib/wp/platform.js
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-// specifically require the following patches :
-
-// localStorage+SessionStorage APIs
-require("cordova/plugin/wp/DOMStorage");
-
-// Fix XHR calls to local file-system
-require("cordova/plugin/wp/XHRPatch");
-
-
-module.exports = {
- id: "wp",
- initialize:function() {
- window.alert = require("cordova/plugin/notification").alert;
- window.FileReader = require("cordova/plugin/FileReader");
- window.File = require("cordova/plugin/File");
-
-
- // Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
- backButtonChannel.onHasSubscribersChange = function() {
- exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]);
- };
- },
- objects: {
- CordovaCommandResult: {
- path:"cordova/plugin/wp/CordovaCommandResult"
- },
- CordovaMediaonStatus: {
- path:"cordova/plugin/wp/CordovaMediaonStatus"
- },
- navigator: {
- children: {
- device: {
- children:{
- capture:{
- path:"cordova/plugin/capture"
- }
- }
- },
- console: {
- path: "cordova/plugin/wp/console"
-
- }
- }
- },
- console:{
- path: "cordova/plugin/wp/console"
- },
- FileTransfer: {
- path: 'cordova/plugin/wp/FileTransfer'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/CordovaCommandResult.js b/lib/wp/plugin/wp/CordovaCommandResult.js
deleted file mode 100644
index dae5279..0000000
--- a/lib/wp/plugin/wp/CordovaCommandResult.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var cordova = require('cordova');
-var channel = require('cordova/channel');
-
-// singular WP callback function attached to window, status is used to determine if it is a success or error
-module.exports = function(status,callbackId,args,cast) {
-
- if(status === "backbutton") {
- // do not detach backbutton event, as we need to be able to catch exceptions
- cordova.fireDocumentEvent("backbutton", undefined, true);
- return "true";
- }
- else if(status === "resume") {
- cordova.fireDocumentEvent('resume');
- return "true";
- }
- else if(status === "pause") {
- cordova.fireDocumentEvent('pause');
- return "true";
- }
-
- var parsedArgs;
- try
- {
- parsedArgs = JSON.parse(args);
-
- }
- catch(ex)
- {
- console.log("Parse error in CordovaCommandResult :: " + ex);
- return;
- }
-
- try
- {
- // For some commands, the message is a JSON encoded string
- // and other times, it is just a string, the try/catch handles the
- // case where message was indeed, just a string.
- parsedArgs.message = JSON.parse(parsedArgs.message);
- }
- catch(ex)
- {
-
- }
- var safeStatus = parseInt(status, 10);
- if(safeStatus === cordova.callbackStatus.NO_RESULT ||
- safeStatus === cordova.callbackStatus.OK) {
- cordova.callbackSuccess(callbackId,parsedArgs,cast);
- }
- else {
- cordova.callbackError(callbackId,parsedArgs,cast);
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/CordovaMediaonStatus.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/CordovaMediaonStatus.js b/lib/wp/plugin/wp/CordovaMediaonStatus.js
deleted file mode 100644
index 8cd0879..0000000
--- a/lib/wp/plugin/wp/CordovaMediaonStatus.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var cordova = require('cordova');
-var Media = require('cordova/plugin/Media');
-
-module.exports = function(args) {
- try {
-
- var res = JSON.parse(args);
- if(res.msg == Media.MEDIA_ERROR) {
- res.value = {'code':res.value};
- }
- Media.onStatus(res.id, res.msg, res.value);
- }
- catch(e) {
- console.log("Error calling Media.onStatus :: " + e);
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/DOMStorage.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/DOMStorage.js b/lib/wp/plugin/wp/DOMStorage.js
deleted file mode 100644
index 67205b8..0000000
--- a/lib/wp/plugin/wp/DOMStorage.js
+++ /dev/null
@@ -1,200 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-(function(win,doc) {
-
-var docDomain = null;
-try {
- docDomain = doc.domain;
-} catch (err) {
- //console.log("caught exception trying to access document.domain");
-}
-
-// conditionally patch the window.localStorage and window.sessionStorage objects
-if (!docDomain || docDomain.length === 0) {
-
- var DOMStorage = function(type) {
- // default type is local
- if(type == "sessionStorage") {
- this._type = type;
- }
- Object.defineProperty( this, "length", {
- configurable: true,
- get: function(){ return this.getLength(); }
- });
- };
-
- DOMStorage.prototype = {
- _type:"localStorage",
- _result:null,
- keys:null,
-
- onResult:function(key,valueStr) {
- if(!this.keys) {
- this.keys = [];
- }
- this._result = valueStr;
- },
-
- onKeysChanged:function(jsonKeys) {
- this.keys = JSON.parse(jsonKeys);
-
- var key;
- for(var n = 0,len = this.keys.length; n < len; n++) {
- key = this.keys[n];
- if(!this.hasOwnProperty(key)) {
- Object.defineProperty( this, key, {
- configurable: true,
- get: function(){ return this.getItem(key); },
- set: function(val){ return this.setItem(key,val); }
- });
- }
- }
-
- },
-
- initialize:function() {
- window.external.Notify("DOMStorage/" + this._type + "/load/keys");
- },
-
- /*
- The length attribute must return the number of key/value pairs currently present
- in the list associated with the object.
- */
- getLength:function() {
- if(!this.keys) {
- this.initialize();
- }
- return this.keys.length;
- },
-
- /*
- The key(n) method must return the name of the nth key in the list.
- The order of keys is user-agent defined, but must be consistent within an object so long as the number of keys doesn't change.
- (Thus, adding or removing a key may change the order of the keys, but merely changing the value of an existing key must not.)
- If n is greater than or equal to the number of key/value pairs in the object, then this method must return null.
- */
- key:function(n) {
- if(!this.keys) {
- this.initialize();
- }
-
- if(n >= this.keys.length) {
- return null;
- } else {
- return this.keys[n];
- }
- },
-
- /*
- The getItem(key) method must return the current value associated with the given key.
- If the given key does not exist in the list associated with the object then this method must return null.
- */
- getItem:function(key) {
- if(!this.keys) {
- this.initialize();
- }
-
- var retVal = null;
- if(this.keys.indexOf(key) > -1) {
- window.external.Notify("DOMStorage/" + this._type + "/get/" + key);
- retVal = window.unescape(decodeURIComponent(this._result));
- this._result = null;
- }
- return retVal;
- },
- /*
- The setItem(key, value) method must first check if a key/value pair with the given key already exists
- in the list associated with the object.
- If it does not, then a new key/value pair must be added to the list, with the given key and with its value set to value.
- If the given key does exist in the list, then it must have its value updated to value.
- If it couldn't set the new value, the method must raise an QUOTA_EXCEEDED_ERR exception.
- (Setting could fail if, e.g., the user has disabled storage for the site, or if the quota has been exceeded.)
- */
- setItem:function(key,value) {
- if(!this.keys) {
- this.initialize();
- }
- window.external.Notify("DOMStorage/" + this._type + "/set/" + key + "/" + encodeURIComponent(window.escape(value)));
- },
-
- /*
- The removeItem(key) method must cause the key/value pair with the given key to be removed from the list
- associated with the object, if it exists.
- If no item with that key exists, the method must do nothing.
- */
- removeItem:function(key) {
- if(!this.keys) {
- this.initialize();
- }
- var index = this.keys.indexOf(key);
- if(index > -1) {
- this.keys.splice(index,1);
- // TODO: need sanity check for keys ? like 'clear','setItem', ...
- window.external.Notify("DOMStorage/" + this._type + "/remove/" + key);
- delete this[key];
- }
- },
-
- /*
- The clear() method must atomically cause the list associated with the object to be emptied of all
- key/value pairs, if there are any.
- If there are none, then the method must do nothing.
- */
- clear:function() {
- if(!this.keys) {
- this.initialize();
- }
-
- for(var n=0,len=this.keys.length; n < len;n++) {
- // TODO: do we need a sanity check for keys ? like 'clear','setItem', ...
- delete this[this.keys[n]];
- }
- this.keys = [];
- window.external.Notify("DOMStorage/" + this._type + "/clear/");
- }
- };
-
- // initialize DOMStorage
-
- if (typeof window.localStorage === "undefined") {
-
- Object.defineProperty(window, "localStorage", {
- writable: false,
- configurable: false,
- value: new DOMStorage("localStorage")
- });
- window.localStorage.initialize();
- }
-
- if (typeof window.sessionStorage === "undefined") {
- Object.defineProperty(window, "sessionStorage", {
- writable: false,
- configurable: false,
- value: new DOMStorage("sessionStorage")
- });
- window.sessionStorage.initialize();
- }
-}
-
-})(window, document);
-
-module.exports = null;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/FileTransfer.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/FileTransfer.js b/lib/wp/plugin/wp/FileTransfer.js
deleted file mode 100644
index b2f8686..0000000
--- a/lib/wp/plugin/wp/FileTransfer.js
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError');
-
-// Note that the only difference between this and the default implementation is the
-// object literal passed to exec() in upload - jm
-
-/**
- * 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
-* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
-*/
-
-FileTransfer.prototype.upload = function(filePath, server, successCallback, errorCallback, options, trustAllHosts) {
-
- // sanity parameter checking
- if (!filePath || !server) throw new Error("FileTransfer.upload requires filePath and server URL parameters at the minimum.");
- // 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 are specified, and NOT a string already, we will stringify it.
- if(options.params && typeof options.params != typeof "") {
- var arrParams = [];
- for(var v in options.params) {
- arrParams.push(v + "=" + options.params[v]);
- }
- params = encodeURI(arrParams.join("&"));
- }
- }
-
- var fail = function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
- errorCallback(error);
- };
- exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
- "server":server,
- "fileKey":fileKey,
- "fileName":fileName,
- "mimeType":mimeType,
- "params":params,
- "trustAllHosts":trustAllHosts,
- "chunkedMode":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) {
- // sanity parameter checking
- if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
- var win = function(result) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
- }
- else if (result.isFile) {
- entry = new (require('cordova/plugin/FileEntry'))();
- }
- entry.isDirectory = result.isDirectory;
- entry.isFile = result.isFile;
- entry.name = result.name;
- entry.fullPath = result.fullPath;
- successCallback(entry);
- };
-
- var fail = function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
- errorCallback(error);
- };
-
- exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
-};
-
-
-module.exports = FileTransfer;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/FileUploadOptions.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/FileUploadOptions.js b/lib/wp/plugin/wp/FileUploadOptions.js
deleted file mode 100644
index 44b0978..0000000
--- a/lib/wp/plugin/wp/FileUploadOptions.js
+++ /dev/null
@@ -1,47 +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.
- *
-*/
-
-/**
- * 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;
-
- if(params && typeof params != typeof "") {
- var arrParams = [];
- for(var v in params) {
- arrParams.push(v + "=" + params[v]);
- }
- this.params = encodeURIComponent(arrParams.join("&"));
- }
- else {
- this.params = params || null;
- }
-};
-
-module.exports = FileUploadOptions;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/XHRPatch.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/XHRPatch.js b/lib/wp/plugin/wp/XHRPatch.js
deleted file mode 100644
index 9c9d62a..0000000
--- a/lib/wp/plugin/wp/XHRPatch.js
+++ /dev/null
@@ -1,230 +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.
- *
-*/
-
-// TODO: the build process will implicitly wrap this in a define() call
-// with a closure of its own; do you need this extra closure?
-
-var LocalFileSystem = require('cordova/plugin/LocalFileSystem');
-
-(function (win, doc) {
-
-var docDomain = null;
-try {
- docDomain = doc.domain;
-} catch (err) {
- //console.log("caught exception trying to access document.domain");
-}
-
-if (!docDomain || docDomain.length === 0) {
-
- var aliasXHR = win.XMLHttpRequest;
-
- win.XMLHttpRequest = function () { };
- win.XMLHttpRequest.noConflict = aliasXHR;
- win.XMLHttpRequest.UNSENT = 0;
- win.XMLHttpRequest.OPENED = 1;
- win.XMLHttpRequest.HEADERS_RECEIVED = 2;
- win.XMLHttpRequest.LOADING = 3;
- win.XMLHttpRequest.DONE = 4;
-
- win.XMLHttpRequest.prototype = {
- UNSENT: 0,
- OPENED: 1,
- HEADERS_RECEIVED: 2,
- LOADING: 3,
- DONE: 4,
-
- isAsync: false,
- onreadystatechange: null,
- readyState: 0,
- _url: "",
- timeout: 0,
- withCredentials: false,
- _requestHeaders: null,
- open: function (reqType, uri, isAsync, user, password) {
-
- if (uri && uri.indexOf("http") === 0) {
- if (!this.wrappedXHR) {
- this.wrappedXHR = new aliasXHR();
- var self = this;
-
- // timeout
- if (this.timeout > 0) {
- this.wrappedXHR.timeout = this.timeout;
- }
- Object.defineProperty(this, "timeout", {
- set: function (val) {
- this.wrappedXHR.timeout = val;
- },
- get: function () {
- return this.wrappedXHR.timeout;
- }
- });
-
-
-
- if (this.withCredentials) {
- this.wrappedXHR.withCredentials = this.withCredentials;
- }
- Object.defineProperty(this, "withCredentials", {
- set: function (val) {
- this.wrappedXHR.withCredentials = val;
- },
- get: function () {
- return this.wrappedXHR.withCredentials;
- }
- });
-
-
- Object.defineProperty(this, "status", { get: function () {
- return this.wrappedXHR.status;
- }
- });
- Object.defineProperty(this, "responseText", { get: function () {
- return this.wrappedXHR.responseText;
- }
- });
- Object.defineProperty(this, "statusText", { get: function () {
- return this.wrappedXHR.statusText;
- }
- });
-
- Object.defineProperty(this, "responseXML", { get: function () {
- return this.wrappedXHR.responseXML;
- }
- });
-
- this.getResponseHeader = function (header) {
- return this.wrappedXHR.getResponseHeader(header);
- };
- this.getAllResponseHeaders = function () {
- return this.wrappedXHR.getAllResponseHeaders();
- };
-
- this.wrappedXHR.onreadystatechange = function () {
- self.changeReadyState(self.wrappedXHR.readyState);
- };
- }
- return this.wrappedXHR.open(reqType, uri, isAsync, user, password);
- }
- else {
- // x-wmapp1://app/www/page2.html
- // need to work some magic on the actual url/filepath
- var newUrl = uri;
- if (newUrl.indexOf(":/") > -1) {
- newUrl = newUrl.split(":/")[1];
- }
- // prefix relative urls to our physical root
- if(newUrl.indexOf("app/www/") < 0)
- {
- newUrl = "app/www/" + newUrl;
- }
-
- if (newUrl.lastIndexOf("/") === newUrl.length - 1) {
- newUrl += "index.html"; // default page is index.html, when call is to a dir/ ( why not ...? )
- }
- this._url = newUrl;
- }
- },
- statusText: "",
- changeReadyState: function (newState) {
- this.readyState = newState;
- if (this.onreadystatechange) {
- this.onreadystatechange();
- }
- },
- setRequestHeader: function (header, value) {
- if (this.wrappedXHR) {
- this.wrappedXHR.setRequestHeader(header, value);
- }
- },
- getResponseHeader: function (header) {
- return this.wrappedXHR ? this.wrappedXHR.getResponseHeader(header) : "";
- },
- getAllResponseHeaders: function () {
- return this.wrappedXHR ? this.wrappedXHR.getAllResponseHeaders() : "";
- },
- responseText: "",
- responseXML: "",
- onResult: function (res) {
- this.status = 200;
- if(typeof res == "object")
- { // callback result handler may have already parsed this from a string-> a JSON object,
- // if so, we need to restore its stringyness, as handlers are expecting string data.
- // especially if used with jQ -> $.getJSON
- res = JSON.stringify(res);
- }
- this.responseText = res;
- this.responseXML = res;
- this.changeReadyState(this.DONE);
- },
- onError: function (err) {
- this.status = 404;
- this.changeReadyState(this.DONE);
- },
-
- abort: function () {
- if (this.wrappedXHR) {
- return this.wrappedXHR.abort();
- }
- },
-
- send: function (data) {
- if (this.wrappedXHR) {
- return this.wrappedXHR.send(data);
- }
- else {
- this.changeReadyState(this.OPENED);
-
- var alias = this;
-
- var fail = function fail(evt) {
- alias.onError(evt.code);
- };
-
- var gotFile = function gotFile(file) {
- var reader = new FileReader();
- reader.onloadend = function (evt) {
- alias.onResult.apply(alias,[evt.target.result]);
- };
- reader.readAsText(file);
- };
-
- var gotEntry = function gotEntry(entry) {
- entry.file(gotFile, fail);
- };
-
- var gotFS = function gotFS(fs) {
- fs.root.getFile(alias._url, null, gotEntry, fail);
- };
-
- window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, gotFS, fail);
-
- }
- },
- status: 404
- };
-} // if doc domain
-
-// end closure wrap
-})(window, document);
-
-module.exports = null;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp/plugin/wp/console.js
----------------------------------------------------------------------
diff --git a/lib/wp/plugin/wp/console.js b/lib/wp/plugin/wp/console.js
deleted file mode 100644
index 20197d5..0000000
--- a/lib/wp/plugin/wp/console.js
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var exec = require('cordova/exec'),
- channel = require('cordova/channel');
-var cordova = require("cordova");
-
-var debugConsole = {
- log:function(msg){
- exec(null,null,"DebugConsole","log",msg);
- },
- warn:function(msg){
- exec(null,null,"DebugConsole","warn",msg);
- },
- error:function(msg){
- exec(null,null,"DebugConsole","error",msg);
- }
-};
-
-var oldOnError = window.onerror;
-window.onerror = function(msg,fileName,line) {
- oldOnError && oldOnError(msg,fileName,line);
- debugConsole.error(msg + " file:" + fileName + " Line:" + line);
-};
-
-module.exports = debugConsole;
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp7/exec.js
----------------------------------------------------------------------
diff --git a/lib/wp7/exec.js b/lib/wp7/exec.js
deleted file mode 100644
index 96eb306..0000000
--- a/lib/wp7/exec.js
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova');
-
-/**
- * Execute a cordova command. It is up to the native side whether this action
- * is synchronous or asynchronous. The native side can return:
- * Synchronous: PluginResult object as a JSON string
- * Asynchronous: Empty string ""
- * If async, the native side will cordova.callbackSuccess or cordova.callbackError,
- * depending upon the result of the action.
- *
- * @param {Function} success The success callback
- * @param {Function} fail The fail callback
- * @param {String} service The name of the service to use
- * @param {String} action Action to be run in cordova
- * @param {String[]} [args] Zero or more arguments to pass to the method
-
- */
-
-module.exports = function(success, fail, service, action, args) {
-
- var callbackId = service + cordova.callbackId++;
- if (typeof success == "function" || typeof fail == "function") {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
- }
- // generate a new command string, ex. DebugConsole/log/DebugConsole23/["wtf dude?"]
- for(var n = 0; n < args.length; n++)
- {
- if(typeof args[n] !== "string")
- {
- args[n] = JSON.stringify(args[n]);
- }
- }
- var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
- // pass it on to Notify
- try {
- if(window.external) {
- window.external.Notify(command);
- }
- else {
- console.log("window.external not available :: command=" + command);
- }
- }
- catch(e) {
- console.log("Exception calling native with command :: " + command + " :: exception=" + e);
- }
-};
-
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp7/platform.js
----------------------------------------------------------------------
diff --git a/lib/wp7/platform.js b/lib/wp7/platform.js
deleted file mode 100644
index 281f6fc..0000000
--- a/lib/wp7/platform.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var cordova = require('cordova'),
- exec = require('cordova/exec');
-
-// specifically require the following patches :
-
-// localStorage+SessionStorage APIs
-require("cordova/plugin/wp7/DOMStorage");
-
-// Fix XHR calls to local file-system
-require("cordova/plugin/wp7/XHRPatch");
-
-
-module.exports = {
- id: "wp7",
- initialize:function() {
- window.alert = require("cordova/plugin/notification").alert;
-
- // Inject a listener for the backbutton, and tell native to override the flag (true/false) when we have 1 or more, or 0, listeners
- var backButtonChannel = cordova.addDocumentEventHandler('backbutton');
- backButtonChannel.onHasSubscribersChange = function() {
- exec(null, null, "CoreEvents", "overridebackbutton", [this.numHandlers == 1]);
- };
- },
- objects: {
- CordovaCommandResult: {
- path:"cordova/plugin/wp7/CordovaCommandResult"
- },
- CordovaMediaonStatus: {
- path:"cordova/plugin/wp7/CordovaMediaonStatus"
- },
- navigator: {
- children: {
- device: {
- children:{
- capture:{
- path:"cordova/plugin/capture"
- }
- }
- },
- console: {
- path: "cordova/plugin/wp7/console"
-
- }
- }
- },
- console:{
- path: "cordova/plugin/wp7/console"
- },
- FileTransfer: {
- path: 'cordova/plugin/wp7/FileTransfer'
- }
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp7/plugin/wp7/CordovaCommandResult.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaCommandResult.js b/lib/wp7/plugin/wp7/CordovaCommandResult.js
deleted file mode 100644
index 4f88e5c..0000000
--- a/lib/wp7/plugin/wp7/CordovaCommandResult.js
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var cordova = require('cordova');
-var channel = require('cordova/channel');
-
-// singular WP7 callback function attached to window, status is used to determine if it is a success or error
-module.exports = function(status,callbackId,args,cast) {
-
- if(status === "backbutton") {
- // do not detach backbutton event, as we need to be able to catch exceptions
- cordova.fireDocumentEvent("backbutton", undefined, true);
- return "true";
- }
- else if(status === "resume") {
- cordova.fireDocumentEvent('resume');
- return "true";
- }
- else if(status === "pause") {
- cordova.fireDocumentEvent('pause');
- return "true";
- }
-
- var parsedArgs;
- try
- {
- parsedArgs = JSON.parse(args);
-
- }
- catch(ex)
- {
- console.log("Parse error in CordovaCommandResult :: " + ex);
- return;
- }
-
- try
- {
- // For some commands, the message is a JSON encoded string
- // and other times, it is just a string, the try/catch handles the
- // case where message was indeed, just a string.
- parsedArgs.message = JSON.parse(parsedArgs.message);
- }
- catch(ex)
- {
-
- }
- var safeStatus = parseInt(status, 10);
- if(safeStatus === cordova.callbackStatus.NO_RESULT ||
- safeStatus === cordova.callbackStatus.OK) {
- cordova.callbackSuccess(callbackId,parsedArgs,cast);
- }
- else {
- cordova.callbackError(callbackId,parsedArgs,cast);
- }
-};
http://git-wip-us.apache.org/repos/asf/incubator-cordova-js/blob/8789b412/lib/wp7/plugin/wp7/CordovaMediaonStatus.js
----------------------------------------------------------------------
diff --git a/lib/wp7/plugin/wp7/CordovaMediaonStatus.js b/lib/wp7/plugin/wp7/CordovaMediaonStatus.js
deleted file mode 100644
index 8cd0879..0000000
--- a/lib/wp7/plugin/wp7/CordovaMediaonStatus.js
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-
-var cordova = require('cordova');
-var Media = require('cordova/plugin/Media');
-
-module.exports = function(args) {
- try {
-
- var res = JSON.parse(args);
- if(res.msg == Media.MEDIA_ERROR) {
- res.value = {'code':res.value};
- }
- Media.onStatus(res.id, res.msg, res.value);
- }
- catch(e) {
- console.log("Error calling Media.onStatus :: " + e);
- }
-};