Skip to content
Browse files

mass rename for 2.1.0rc1

  • Loading branch information...
1 parent d99b563 commit 764f10bf0576cbfd0457114048f4e6303a4f8ff7 @purplecabbage purplecabbage committed Aug 24, 2012
Showing with 468 additions and 6,545 deletions.
  1. +1 −1 VERSION
  2. +0 −18 bin/create.js
  3. +1 −1 example/CordovaExample.csproj
  4. +17 −0 example/CordovaSourceDictionary.xml
  5. +1 −1 example/www/accelerometer.html
  6. +1 −1 example/www/accelerometer2.html
  7. +1 −1 example/www/audio.html
  8. +1 −1 example/www/calculator.html
  9. +1 −1 example/www/camera.html
  10. +1 −1 example/www/capture.html
  11. +1 −1 example/www/compass.html
  12. +1 −1 example/www/contacts.html
  13. +115 −209 example/www/{cordova-2.0.0.js → cordova-2.1.0.js}
  14. +1 −1 example/www/events.html
  15. +1 −1 example/www/file.html
  16. +1 −1 example/www/index.html
  17. +1 −1 example/www/location.html
  18. +1 −1 example/www/network.html
  19. +1 −1 example/www/notification.html
  20. +1 −1 example/www/storage.html
  21. BIN templates/CordovaStarter-2.0.0.zip
  22. +1 −1 templates/custom/CordovaAppProj.csproj
  23. +1 −1 templates/custom/VERSION
  24. +115 −209 tests/MobileSpecUnitTests/www/cordova-2.0.0.js → templates/custom/www/cordova-2.1.0.js
  25. +1 −1 templates/custom/www/index.html
  26. +1 −1 templates/description.txt
  27. +1 −1 templates/full/CordovaAppProj.csproj
  28. +1 −1 templates/full/CordovaSourceDictionary.xml
  29. +1 −1 templates/full/VERSION
  30. +96 −204 templates/{custom/www/cordova-2.0.0.js → full/www/cordova-2.1.0.js}
  31. +1 −1 templates/full/www/index.html
  32. +1 −1 templates/standalone/CordovaAppProj.csproj
  33. +1 −1 templates/standalone/VERSION
  34. +0 −5,672 templates/standalone/www/cordova-2.0.0.js
  35. +96 −204 templates/{full/www/cordova-2.0.0.js → standalone/www/cordova-2.1.0.js}
  36. +1 −1 templates/standalone/www/index.html
  37. +1 −1 tests/MobileSpecUnitTests/www/index.html
View
2 VERSION
@@ -1 +1 @@
-2.0.0
+2.1.0rc1
View
18 bin/create.js
@@ -134,21 +134,3 @@ WScript.Echo("Generated project : " + PROJECT_PATH + ACTIVITY);
// update the solution to include the new project by name
// version BS
// index.html title set to project name ?
-
-
-
-
-
-
-// var ACTIVITY_PATH=PROJECT_PATH+'\\src\\'+PACKAGE_AS_PATH+'\\'+ACTIVITY+'.java';
-// var MANIFEST_PATH=PROJECT_PATH+'\\AndroidManifest.xml';
-// var TARGET=shell.Exec('android.bat list targets').StdOut.ReadAll().match(/id:\s([0-9]).*/)[1];
-// var VERSION=read('VERSION').replace(/\r\n/,'').replace(/\n/,'');
-
-// WScript.Echo("Project path: " + PROJECT_PATH);
-// WScript.Echo("Package: " + PACKAGE);
-// WScript.Echo("Activity: " + ACTIVITY);
-// WScript.Echo("Package as path: " + PACKAGE_AS_PATH);
-// WScript.Echo("Activity path: " + ACTIVITY_PATH);
-// WScript.Echo("Manifest path: " + MANIFEST_PATH);
-// WScript.Echo("Cordova version: " + VERSION);
View
2 example/CordovaExample.csproj
@@ -99,7 +99,7 @@
<Content Include="CordovaSourceDictionary.xml">
<SubType>Designer</SubType>
</Content>
- <Content Include="www\cordova-2.0.0.js" />
+ <Content Include="www\cordova-2.1.0.js" />
<Content Include="www\network.html">
<SubType>Designer</SubType>
</Content>
View
17 example/CordovaSourceDictionary.xml
@@ -1,4 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- This file is auto-generated, do not edit! -jm -->
<CordovaSourceDictionary>
+ <FilePath Value="www\cordova-2.1.0.js"/>
+ <FilePath Value="www\network.html"/>
+ <FilePath Value="www\notification.html"/>
+ <FilePath Value="www\storage.html"/>
+ <FilePath Value="www\accelerometer.html"/>
+ <FilePath Value="www\accelerometer2.html"/>
+ <FilePath Value="www\audio.html"/>
+ <FilePath Value="www\calculator.html"/>
+ <FilePath Value="www\camera.html"/>
+ <FilePath Value="www\capture.html"/>
+ <FilePath Value="www\compass.html"/>
+ <FilePath Value="www\contacts.html"/>
+ <FilePath Value="www\events.html"/>
+ <FilePath Value="www\file.html"/>
+ <FilePath Value="www\index.html"/>
+ <FilePath Value="www\location.html"/>
+ <FilePath Value="www\master.css"/>
</CordovaSourceDictionary>
View
2 example/www/accelerometer.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/accelerometer2.html
@@ -27,7 +27,7 @@
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/audio.html
@@ -25,7 +25,7 @@
<title>Cordova</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/calculator.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/camera.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/capture.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/compass.html
@@ -27,7 +27,7 @@
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/contacts.html
@@ -27,7 +27,7 @@
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
324 example/www/cordova-2.0.0.js → example/www/cordova-2.1.0.js
@@ -1,6 +1,6 @@
-// commit fd00bff18daf29606d88263f7586f20cf9421861
+// commit 69d652e9dcaaaf4bdaa55ec37329636dd5b20fbe
-// File generated at :: Fri Jul 13 2012 16:48:42 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Fri Aug 24 2012 14:00:49 GMT-0700 (Pacific Daylight Time)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -29,6 +29,10 @@ var require,
(function () {
var modules = {};
+ // Stack of moduleIds currently being built.
+ var requireStack = [];
+ // Map of module ID -> index into requireStack of modules currently being built.
+ var inProgressModules = {};
function build(module) {
var factory = module.factory;
@@ -41,8 +45,21 @@ var require,
require = function (id) {
if (!modules[id]) {
throw "module " + id + " not found";
+ } else if (id in inProgressModules) {
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
+ throw "Cycle in require graph: " + cycle;
}
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
+ if (modules[id].factory) {
+ try {
+ inProgressModules[id] = requireStack.length;
+ requireStack.push(id);
+ return build(modules[id]);
+ } finally {
+ delete inProgressModules[id];
+ requireStack.pop();
+ }
+ }
+ return modules[id].exports;
};
define = function (id, factory) {
@@ -67,6 +84,7 @@ if (typeof module === "object" && typeof require === "function") {
module.exports.require = require;
module.exports.define = define;
}
+
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
var channel = require('cordova/channel');
@@ -207,10 +225,6 @@ var cordova = {
window.dispatchEvent(evt);
}
},
- // TODO: this is Android only; think about how to do this better
- shuttingDown:false,
- UsePolling:false,
- // END TODO
// TODO: iOS only
// This queue holds the currently executing command and all pending
@@ -289,17 +303,6 @@ var cordova = {
}
}
},
- // TODO: remove in 2.0.
- addPlugin: function(name, obj) {
- console.log("[DEPRECATION NOTICE] window.addPlugin and window.plugins will be removed in version 2.0.");
- if (!window.plugins[name]) {
- window.plugins[name] = obj;
- }
- else {
- console.log("Error: Plugin "+name+" already exists.");
- }
- },
-
addConstructor: function(func) {
channel.onCordovaReady.subscribeOnce(function() {
try {
@@ -316,51 +319,6 @@ channel.onPause = cordova.addDocumentEventHandler('pause');
channel.onResume = cordova.addDocumentEventHandler('resume');
channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
-// Adds deprecation warnings to functions of an object (but only logs a message once)
-function deprecateFunctions(obj, objLabel) {
- var newObj = {};
- var logHash = {};
- for (var i in obj) {
- if (obj.hasOwnProperty(i)) {
- if (typeof obj[i] == 'function') {
- newObj[i] = (function(prop){
- var oldFunk = obj[prop];
- var funkId = objLabel + '_' + prop;
- return function() {
- if (!logHash[funkId]) {
- console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
- logHash[funkId] = true;
- }
- oldFunk.apply(obj, arguments);
- };
- })(i);
- } else {
- newObj[i] = (function(prop) { return obj[prop]; })(i);
- }
- }
- }
- return newObj;
-}
-
-/**
- * Legacy variable for plugin support
- * TODO: remove in 2.0.
- */
-if (!window.PhoneGap) {
- window.PhoneGap = deprecateFunctions(cordova, 'PhoneGap');
-}
-if (!window.Cordova) {
- window.Cordova = deprecateFunctions(cordova, 'Cordova');
-}
-
-/**
- * Plugins object
- * TODO: remove in 2.0.
- */
-if (!window.plugins) {
- window.plugins = {};
-}
-
module.exports = cordova;
});
@@ -460,7 +418,8 @@ module.exports = {
// file: lib\common\channel.js
define("cordova/channel", function(require, exports, module) {
-var utils = require('cordova/utils');
+var utils = require('cordova/utils'),
+ nextGuid = 1;
/**
* Custom pub-sub "channel" that can have functions subscribed to it
@@ -512,7 +471,6 @@ var Channel = function(type, opts) {
this.type = type;
this.handlers = {};
this.numHandlers = 0;
- this.guid = 1;
this.fired = false;
this.enabled = true;
this.events = {
@@ -605,19 +563,19 @@ Channel.prototype.subscribe = function(f, c, g) {
g = g || func.observer_guid || f.observer_guid;
if (!g) {
- // first time we've seen this subscriber
- g = this.guid++;
- }
- else {
- // subscriber already handled; dont set it twice
- return g;
+ // first time any channel has seen this subscriber
+ g = nextGuid++;
}
func.observer_guid = g;
f.observer_guid = g;
- this.handlers[g] = func;
- this.numHandlers++;
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
- if (this.fired) func.call(this);
+
+ // Don't add the same handler more than once.
+ if (!this.handlers[g]) {
+ this.handlers[g] = func;
+ this.numHandlers++;
+ if (this.events.onSubscribe) this.events.onSubscribe.call(this);
+ if (this.fired) func.apply(this, this.fireArgs);
+ }
return g;
};
@@ -631,15 +589,14 @@ Channel.prototype.subscribeOnce = function(f, c) {
var g = null;
var _this = this;
- var m = function() {
- f.apply(c || null, arguments);
- _this.unsubscribe(g);
- };
if (this.fired) {
- if (typeof c == "object") { f = utils.close(c, f); }
- f.apply(this, this.fireArgs);
+ f.apply(c || null, this.fireArgs);
} else {
- g = this.subscribe(m);
+ g = this.subscribe(function() {
+ _this.unsubscribe(g);
+ f.apply(c || null, arguments);
+ });
+ f.observer_guid = g;
}
return g;
};
@@ -655,7 +612,6 @@ Channel.prototype.unsubscribe = function(g) {
var handler = this.handlers[g];
if (handler) {
if (handler.observer_guid) handler.observer_guid=null;
- this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
@@ -669,14 +625,17 @@ Channel.prototype.fire = function(e) {
if (this.enabled) {
var fail = false;
this.fired = true;
+ this.fireArgs = arguments;
+ // Copy the values first so that it is safe to modify it from within
+ // callbacks.
+ var toCall = [];
for (var item in this.handlers) {
- var handler = this.handlers[item];
- if (typeof handler == 'function') {
- var rv = (handler.apply(this, arguments)===false);
- fail = fail || rv;
- }
+ toCall.push(this.handlers[item]);
+ }
+ for (var i = 0; i < toCall.length; ++i) {
+ var rv = (toCall[i].apply(this, arguments)===false);
+ fail = fail || rv;
}
- this.fireArgs = arguments;
return !fail;
}
return true;
@@ -934,68 +893,11 @@ module.exports = {
define("cordova/exec", function(require, exports, module) {
var cordova = require('cordova');
-
- /* definition of named properties expected by the native side,
- all arrays are stored in order of how they are received from common js code.
- When other platforms evolve to using named args this will be removed.
- */
-
-var NamedArgs = {
- File:{
- getFileMetadata:["fullPath"],
- getMetadata:["fullPath"],
- getParent:["fullPath"],
- readAsText:["fileName","encoding"],
- readAsDataURL:["fileName"],
- getDirectory:["fullPath","path","options"],
- remove:["fullPath"],
- removeRecursively:["fullPath"],
- getFile:["fullPath","path","options"],
- readEntries:["fullPath"],
- write:["fileName","data","position"],
- truncate:["fileName","size"],
- copyTo:["fullPath","parent", "newName"],
- moveTo:["fullPath","parent", "newName"],
- requestFileSystem:["type","size"],
- resolveLocalFileSystemURI:["uri"]
- },
- FileTransfer:{
- upload:["filePath", "server", "fileKey", "fileName", "mimeType", "params", "debug", "chunkedMode"],
- download:["url","filePath"]
- },
- Contacts:{
- search:["fields","options"]
- },
- Media:{
- create:["id","src"],
- startPlayingAudio:["id","src","milliseconds"],
- stopPlayingAudio:["id"],
- seekToAudio:["id","milliseconds"],
- pausePlayingAudio:["id"],
- getCurrentPositionAudio:["id"],
- startRecordingAudio:["id","src"],
- stopRecordingAudio:["id"],
- release:["id"],
- setVolume:["id","volume"]
- },
- Notification: {
- alert:["message","title","buttonLabel"],
- confirm:["message","title","buttonLabel"]
- },
- Camera:{
- takePicture:["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType",
- "mediaType", "allowEdit", "correctOrientation", "saveToPhotoAlbum" ]
- },
- Capture:{
- getFormatData:["fullPath","type"]
- }
-};
-
/**
* 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 ""
+ * Asynchronous: Empty string ""
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
* depending upon the result of the action.
*
@@ -1009,30 +911,18 @@ var NamedArgs = {
module.exports = function(success, fail, service, action, args) {
-
var callbackId = service + cordova.callbackId++;
- if (typeof success == "function" || typeof fail == "function")
- {
+ if (typeof success == "function" || typeof fail == "function") {
cordova.callbacks[callbackId] = {success:success, fail:fail};
}
-
- // generate a new command string, ex. DebugConsole/log/DebugConsole23/{"message":"wtf dude?"}
-
- if(NamedArgs[service] && NamedArgs[service][action]) {
- var argNames = NamedArgs[service][action];
- var newArgs = {};
- var len = Math.min(args.length,argNames.length);
-
- for(var n = 0; n < len; n++) {
- newArgs[argNames[n]] = args[n];
+ // 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]);
}
-
- args = newArgs;
- }
- else if(args && args.length && args.length == 1) {
- args = args[0];
}
-
var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
// pass it on to Notify
try {
@@ -2592,10 +2482,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var mimeType = null;
var params = null;
var chunkedMode = true;
+ var headers = null;
if (options) {
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
+ headers = options.headers;
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
@@ -2612,7 +2504,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
errorCallback(error);
};
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
};
/**
@@ -2682,15 +2574,19 @@ define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
* @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.
+ * @param headers {Object} Keys are header names, values are header values. Multiple
+ * headers of the same name are not supported.
*/
-var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
+var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
this.fileKey = fileKey || null;
this.fileName = fileName || null;
this.mimeType = mimeType || null;
this.params = params || null;
+ this.headers = headers || null;
};
module.exports = FileUploadOptions;
+
});
// file: lib\common\plugin\FileUploadResult.js
@@ -2878,7 +2774,7 @@ FileWriter.prototype.seek = function(offset) {
if (offset < 0) {
this.position = Math.max(offset + this.length, 0);
}
- // Offset is bigger then file size so set position
+ // Offset is bigger than file size so set position
// to the end of the file.
else if (offset > this.length) {
this.position = this.length;
@@ -3085,7 +2981,6 @@ Media.prototype.stop = function() {
var me = this;
exec(function() {
me._position = 0;
- me.successCallback();
}, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
};
@@ -3131,14 +3026,14 @@ Media.prototype.getCurrentPosition = function(success, fail) {
* Start recording audio file.
*/
Media.prototype.startRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
+ exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
};
/**
* Stop recording audio file.
*/
Media.prototype.stopRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
+ exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
};
/**
@@ -3167,14 +3062,14 @@ Media.onStatus = function(id, msg, value) {
var media = mediaObjects[id];
// If state update
if (msg === Media.MEDIA_STATE) {
+ if (media.statusCallback) {
+ media.statusCallback(value);
+ }
if (value === Media.MEDIA_STOPPED) {
if (media.successCallback) {
media.successCallback();
}
}
- if (media.statusCallback) {
- media.statusCallback(value);
- }
}
else if (msg === Media.MEDIA_DURATION) {
media._duration = value;
@@ -3248,28 +3143,6 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
}
};
-// TODO: can we axe this?
-/**
- * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
- * (used in Objective-C and Android)
- *
- * @param {PluginResult} pluginResult
- */
-MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- for (var i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
-};
-
module.exports = MediaFile;
});
@@ -3475,12 +3348,12 @@ var accelerometer = {
var p;
var win = function(a) {
- successCallback(a);
removeListeners(p);
+ successCallback(a);
};
var fail = function(e) {
- errorCallback(e);
removeListeners(p);
+ errorCallback(e);
};
p = createCallbackPair(win, fail);
@@ -3512,8 +3385,8 @@ var accelerometer = {
var id = utils.createUUID();
var p = createCallbackPair(function(){}, function(e) {
- errorCallback(e);
removeListeners(p);
+ errorCallback(e);
});
listeners.push(p);
@@ -3528,7 +3401,10 @@ var accelerometer = {
if (running) {
// If we're already running then immediately invoke the success callback
- successCallback(accel);
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if(accel) {
+ successCallback(accel);
+ }
} else {
start();
}
@@ -4043,7 +3919,7 @@ var contacts = {
* This function creates a new contact, but it does not persist the contact
* to device storage. To persist the contact to device storage, invoke
* contact.save().
- * @param properties an object who's properties will be examined to create a new Contact
+ * @param properties an object whose properties will be examined to create a new Contact
* @returns new Contact object
*/
create:function(properties) {
@@ -4130,6 +4006,25 @@ module.exports = new Device();
});
+// file: lib\common\plugin\echo.js
+define("cordova/plugin/echo", function(require, exports, module) {
+var exec = require('cordova/exec');
+
+/**
+ * Sends the given message through exec() to the Echo plugink, which sends it back to the successCallback.
+ * @param successCallback invoked with a FileSystem object
+ * @param errorCallback invoked if error occurs retrieving file system
+ * @param message The string to be echoed.
+ * @param forceAsync Whether to force an async return value (for testing native->js bridge).
+ */
+module.exports = function(successCallback, errorCallback, message, forceAsync) {
+ var action = forceAsync ? 'echoAsync' : 'echo';
+ exec(successCallback, errorCallback, "Echo", action, [message]);
+};
+
+
+});
+
// file: lib\common\plugin\geolocation.js
define("cordova/plugin/geolocation", function(require, exports, module) {
var utils = require('cordova/utils'),
@@ -4238,7 +4133,7 @@ var geolocation = {
} else if (options.timeout === 0) {
fail({
code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceed's provided PositionOptions' maximumAge parameter."
+ message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
});
// Otherwise we have to call into native to retrieve a position.
} else {
@@ -4402,7 +4297,7 @@ CurrentLevel = LevelsMap.WARN;
*
* The value used determines which messages get printed. The logging
* values above are in order, and only messages logged at the logging
- * level or above will actually be displayed to the user. Eg, the
+ * level or above will actually be displayed to the user. E.g., the
* default level is WARN, so only messages logged with LOG, ERROR, or
* WARN will be displayed; INFO and DEBUG messages will be ignored.
*/
@@ -4798,7 +4693,7 @@ define("cordova/plugin/wp7/CordovaCommandResult", function(require, exports, mod
var cordova = require('cordova');
var channel = require('cordova/channel');
-// singular WP7 callback function attached to window, status is used to determin if it is a success or error
+// 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") {
@@ -5050,6 +4945,9 @@ define("cordova/plugin/wp7/FileTransfer", function(require, exports, module) {
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
@@ -5100,8 +4998,14 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
errorCallback(error);
};
-
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
+ "server":server,
+ "fileKey":fileKey,
+ "fileName":fileName,
+ "mimeType":mimeType,
+ "params":params,
+ "trustAllHosts":trustAllHosts,
+ "chunkedMode":chunkedMode}]);
};
/**
@@ -5111,6 +5015,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
* @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.");
@@ -5137,6 +5042,7 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
};
+
module.exports = FileTransfer;
});
@@ -5173,7 +5079,7 @@ module.exports = FileUploadOptions;
// file: lib\wp7\plugin\wp7\XHRPatch.js
define("cordova/plugin/wp7/XHRPatch", function(require, exports, module) {
-// TODO: the build process implicitly will wrap this in a define() call
+// 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');
@@ -5322,7 +5228,7 @@ if (!docDomain || docDomain.length === 0) {
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 it's stringyness, as handlers are expecting string data.
+ // if so, we need to restore its stringyness, as handlers are expecting string data.
// especially if used with jQ -> $.getJSON
res = JSON.stringify(res);
}
View
2 example/www/events.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/file.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/index.html
@@ -27,7 +27,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript">
View
2 example/www/location.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
View
2 example/www/network.html
@@ -25,7 +25,7 @@
<title>Cordova</title>
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/notification.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen" title="no title" charset="utf-8"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
2 example/www/storage.html
@@ -26,7 +26,7 @@
<link rel="stylesheet" href="master.css" type="text/css" media="screen"/>
- <script type="text/javascript" charset="utf-8" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" charset="utf-8" src="cordova-2.1.0.js"></script>
<script type="text/javascript" charset="utf-8">
View
BIN templates/CordovaStarter-2.0.0.zip
Binary file not shown.
View
2 templates/custom/CordovaAppProj.csproj
@@ -93,7 +93,7 @@
<ItemGroup>
<Content Include="BuildManifestProcessor.js" />
<Content Include="CordovaSourceDictionary.xml" />
- <Content Include="www\cordova-2.0.0.js" />
+ <Content Include="www\cordova-2.1.0.js" />
<Content Include="www\css\index.css" />
<Content Include="www\js\index.js" />
<Content Include="www\img\cordova.png" />
View
2 templates/custom/VERSION
@@ -1 +1 @@
-2.0.0rc1
+2.1.0rc1
View
324 .../MobileSpecUnitTests/www/cordova-2.0.0.js → templates/custom/www/cordova-2.1.0.js
@@ -1,6 +1,6 @@
-// commit fd00bff18daf29606d88263f7586f20cf9421861
+// commit 69d652e9dcaaaf4bdaa55ec37329636dd5b20fbe
-// File generated at :: Fri Jul 13 2012 16:48:42 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Fri Aug 24 2012 14:00:49 GMT-0700 (Pacific Daylight Time)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -29,6 +29,10 @@ var require,
(function () {
var modules = {};
+ // Stack of moduleIds currently being built.
+ var requireStack = [];
+ // Map of module ID -> index into requireStack of modules currently being built.
+ var inProgressModules = {};
function build(module) {
var factory = module.factory;
@@ -41,8 +45,21 @@ var require,
require = function (id) {
if (!modules[id]) {
throw "module " + id + " not found";
+ } else if (id in inProgressModules) {
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
+ throw "Cycle in require graph: " + cycle;
}
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
+ if (modules[id].factory) {
+ try {
+ inProgressModules[id] = requireStack.length;
+ requireStack.push(id);
+ return build(modules[id]);
+ } finally {
+ delete inProgressModules[id];
+ requireStack.pop();
+ }
+ }
+ return modules[id].exports;
};
define = function (id, factory) {
@@ -67,6 +84,7 @@ if (typeof module === "object" && typeof require === "function") {
module.exports.require = require;
module.exports.define = define;
}
+
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
var channel = require('cordova/channel');
@@ -207,10 +225,6 @@ var cordova = {
window.dispatchEvent(evt);
}
},
- // TODO: this is Android only; think about how to do this better
- shuttingDown:false,
- UsePolling:false,
- // END TODO
// TODO: iOS only
// This queue holds the currently executing command and all pending
@@ -289,17 +303,6 @@ var cordova = {
}
}
},
- // TODO: remove in 2.0.
- addPlugin: function(name, obj) {
- console.log("[DEPRECATION NOTICE] window.addPlugin and window.plugins will be removed in version 2.0.");
- if (!window.plugins[name]) {
- window.plugins[name] = obj;
- }
- else {
- console.log("Error: Plugin "+name+" already exists.");
- }
- },
-
addConstructor: function(func) {
channel.onCordovaReady.subscribeOnce(function() {
try {
@@ -316,51 +319,6 @@ channel.onPause = cordova.addDocumentEventHandler('pause');
channel.onResume = cordova.addDocumentEventHandler('resume');
channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
-// Adds deprecation warnings to functions of an object (but only logs a message once)
-function deprecateFunctions(obj, objLabel) {
- var newObj = {};
- var logHash = {};
- for (var i in obj) {
- if (obj.hasOwnProperty(i)) {
- if (typeof obj[i] == 'function') {
- newObj[i] = (function(prop){
- var oldFunk = obj[prop];
- var funkId = objLabel + '_' + prop;
- return function() {
- if (!logHash[funkId]) {
- console.log('[DEPRECATION NOTICE] The "' + objLabel + '" global will be removed in version 2.0, please use lowercase "cordova".');
- logHash[funkId] = true;
- }
- oldFunk.apply(obj, arguments);
- };
- })(i);
- } else {
- newObj[i] = (function(prop) { return obj[prop]; })(i);
- }
- }
- }
- return newObj;
-}
-
-/**
- * Legacy variable for plugin support
- * TODO: remove in 2.0.
- */
-if (!window.PhoneGap) {
- window.PhoneGap = deprecateFunctions(cordova, 'PhoneGap');
-}
-if (!window.Cordova) {
- window.Cordova = deprecateFunctions(cordova, 'Cordova');
-}
-
-/**
- * Plugins object
- * TODO: remove in 2.0.
- */
-if (!window.plugins) {
- window.plugins = {};
-}
-
module.exports = cordova;
});
@@ -460,7 +418,8 @@ module.exports = {
// file: lib\common\channel.js
define("cordova/channel", function(require, exports, module) {
-var utils = require('cordova/utils');
+var utils = require('cordova/utils'),
+ nextGuid = 1;
/**
* Custom pub-sub "channel" that can have functions subscribed to it
@@ -512,7 +471,6 @@ var Channel = function(type, opts) {
this.type = type;
this.handlers = {};
this.numHandlers = 0;
- this.guid = 1;
this.fired = false;
this.enabled = true;
this.events = {
@@ -605,19 +563,19 @@ Channel.prototype.subscribe = function(f, c, g) {
g = g || func.observer_guid || f.observer_guid;
if (!g) {
- // first time we've seen this subscriber
- g = this.guid++;
- }
- else {
- // subscriber already handled; dont set it twice
- return g;
+ // first time any channel has seen this subscriber
+ g = nextGuid++;
}
func.observer_guid = g;
f.observer_guid = g;
- this.handlers[g] = func;
- this.numHandlers++;
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
- if (this.fired) func.call(this);
+
+ // Don't add the same handler more than once.
+ if (!this.handlers[g]) {
+ this.handlers[g] = func;
+ this.numHandlers++;
+ if (this.events.onSubscribe) this.events.onSubscribe.call(this);
+ if (this.fired) func.apply(this, this.fireArgs);
+ }
return g;
};
@@ -631,15 +589,14 @@ Channel.prototype.subscribeOnce = function(f, c) {
var g = null;
var _this = this;
- var m = function() {
- f.apply(c || null, arguments);
- _this.unsubscribe(g);
- };
if (this.fired) {
- if (typeof c == "object") { f = utils.close(c, f); }
- f.apply(this, this.fireArgs);
+ f.apply(c || null, this.fireArgs);
} else {
- g = this.subscribe(m);
+ g = this.subscribe(function() {
+ _this.unsubscribe(g);
+ f.apply(c || null, arguments);
+ });
+ f.observer_guid = g;
}
return g;
};
@@ -655,7 +612,6 @@ Channel.prototype.unsubscribe = function(g) {
var handler = this.handlers[g];
if (handler) {
if (handler.observer_guid) handler.observer_guid=null;
- this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
@@ -669,14 +625,17 @@ Channel.prototype.fire = function(e) {
if (this.enabled) {
var fail = false;
this.fired = true;
+ this.fireArgs = arguments;
+ // Copy the values first so that it is safe to modify it from within
+ // callbacks.
+ var toCall = [];
for (var item in this.handlers) {
- var handler = this.handlers[item];
- if (typeof handler == 'function') {
- var rv = (handler.apply(this, arguments)===false);
- fail = fail || rv;
- }
+ toCall.push(this.handlers[item]);
+ }
+ for (var i = 0; i < toCall.length; ++i) {
+ var rv = (toCall[i].apply(this, arguments)===false);
+ fail = fail || rv;
}
- this.fireArgs = arguments;
return !fail;
}
return true;
@@ -934,68 +893,11 @@ module.exports = {
define("cordova/exec", function(require, exports, module) {
var cordova = require('cordova');
-
- /* definition of named properties expected by the native side,
- all arrays are stored in order of how they are received from common js code.
- When other platforms evolve to using named args this will be removed.
- */
-
-var NamedArgs = {
- File:{
- getFileMetadata:["fullPath"],
- getMetadata:["fullPath"],
- getParent:["fullPath"],
- readAsText:["fileName","encoding"],
- readAsDataURL:["fileName"],
- getDirectory:["fullPath","path","options"],
- remove:["fullPath"],
- removeRecursively:["fullPath"],
- getFile:["fullPath","path","options"],
- readEntries:["fullPath"],
- write:["fileName","data","position"],
- truncate:["fileName","size"],
- copyTo:["fullPath","parent", "newName"],
- moveTo:["fullPath","parent", "newName"],
- requestFileSystem:["type","size"],
- resolveLocalFileSystemURI:["uri"]
- },
- FileTransfer:{
- upload:["filePath", "server", "fileKey", "fileName", "mimeType", "params", "debug", "chunkedMode"],
- download:["url","filePath"]
- },
- Contacts:{
- search:["fields","options"]
- },
- Media:{
- create:["id","src"],
- startPlayingAudio:["id","src","milliseconds"],
- stopPlayingAudio:["id"],
- seekToAudio:["id","milliseconds"],
- pausePlayingAudio:["id"],
- getCurrentPositionAudio:["id"],
- startRecordingAudio:["id","src"],
- stopRecordingAudio:["id"],
- release:["id"],
- setVolume:["id","volume"]
- },
- Notification: {
- alert:["message","title","buttonLabel"],
- confirm:["message","title","buttonLabel"]
- },
- Camera:{
- takePicture:["quality", "destinationType", "sourceType", "targetWidth", "targetHeight", "encodingType",
- "mediaType", "allowEdit", "correctOrientation", "saveToPhotoAlbum" ]
- },
- Capture:{
- getFormatData:["fullPath","type"]
- }
-};
-
/**
* 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 ""
+ * Asynchronous: Empty string ""
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
* depending upon the result of the action.
*
@@ -1009,30 +911,18 @@ var NamedArgs = {
module.exports = function(success, fail, service, action, args) {
-
var callbackId = service + cordova.callbackId++;
- if (typeof success == "function" || typeof fail == "function")
- {
+ if (typeof success == "function" || typeof fail == "function") {
cordova.callbacks[callbackId] = {success:success, fail:fail};
}
-
- // generate a new command string, ex. DebugConsole/log/DebugConsole23/{"message":"wtf dude?"}
-
- if(NamedArgs[service] && NamedArgs[service][action]) {
- var argNames = NamedArgs[service][action];
- var newArgs = {};
- var len = Math.min(args.length,argNames.length);
-
- for(var n = 0; n < len; n++) {
- newArgs[argNames[n]] = args[n];
+ // 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]);
}
-
- args = newArgs;
- }
- else if(args && args.length && args.length == 1) {
- args = args[0];
}
-
var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);
// pass it on to Notify
try {
@@ -2592,10 +2482,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var mimeType = null;
var params = null;
var chunkedMode = true;
+ var headers = null;
if (options) {
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
+ headers = options.headers;
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
@@ -2612,7 +2504,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
errorCallback(error);
};
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
};
/**
@@ -2682,15 +2574,19 @@ define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
* @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.
+ * @param headers {Object} Keys are header names, values are header values. Multiple
+ * headers of the same name are not supported.
*/
-var FileUploadOptions = function(fileKey, fileName, mimeType, params) {
+var FileUploadOptions = function(fileKey, fileName, mimeType, params, headers) {
this.fileKey = fileKey || null;
this.fileName = fileName || null;
this.mimeType = mimeType || null;
this.params = params || null;
+ this.headers = headers || null;
};
module.exports = FileUploadOptions;
+
});
// file: lib\common\plugin\FileUploadResult.js
@@ -2878,7 +2774,7 @@ FileWriter.prototype.seek = function(offset) {
if (offset < 0) {
this.position = Math.max(offset + this.length, 0);
}
- // Offset is bigger then file size so set position
+ // Offset is bigger than file size so set position
// to the end of the file.
else if (offset > this.length) {
this.position = this.length;
@@ -3085,7 +2981,6 @@ Media.prototype.stop = function() {
var me = this;
exec(function() {
me._position = 0;
- me.successCallback();
}, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
};
@@ -3131,14 +3026,14 @@ Media.prototype.getCurrentPosition = function(success, fail) {
* Start recording audio file.
*/
Media.prototype.startRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
+ exec(null, this.errorCallback, "Media", "startRecordingAudio", [this.id, this.src]);
};
/**
* Stop recording audio file.
*/
Media.prototype.stopRecord = function() {
- exec(this.successCallback, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
+ exec(null, this.errorCallback, "Media", "stopRecordingAudio", [this.id]);
};
/**
@@ -3167,14 +3062,14 @@ Media.onStatus = function(id, msg, value) {
var media = mediaObjects[id];
// If state update
if (msg === Media.MEDIA_STATE) {
+ if (media.statusCallback) {
+ media.statusCallback(value);
+ }
if (value === Media.MEDIA_STOPPED) {
if (media.successCallback) {
media.successCallback();
}
}
- if (media.statusCallback) {
- media.statusCallback(value);
- }
}
else if (msg === Media.MEDIA_DURATION) {
media._duration = value;
@@ -3248,28 +3143,6 @@ MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
}
};
-// TODO: can we axe this?
-/**
- * Casts a PluginResult message property (array of objects) to an array of MediaFile objects
- * (used in Objective-C and Android)
- *
- * @param {PluginResult} pluginResult
- */
-MediaFile.cast = function(pluginResult) {
- var mediaFiles = [];
- for (var i=0; i<pluginResult.message.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult.message[i].name;
- mediaFile.fullPath = pluginResult.message[i].fullPath;
- mediaFile.type = pluginResult.message[i].type;
- mediaFile.lastModifiedDate = pluginResult.message[i].lastModifiedDate;
- mediaFile.size = pluginResult.message[i].size;
- mediaFiles.push(mediaFile);
- }
- pluginResult.message = mediaFiles;
- return pluginResult;
-};
-
module.exports = MediaFile;
});
@@ -3475,12 +3348,12 @@ var accelerometer = {
var p;
var win = function(a) {
- successCallback(a);
removeListeners(p);
+ successCallback(a);
};
var fail = function(e) {
- errorCallback(e);
removeListeners(p);
+ errorCallback(e);
};
p = createCallbackPair(win, fail);
@@ -3512,8 +3385,8 @@ var accelerometer = {
var id = utils.createUUID();
var p = createCallbackPair(function(){}, function(e) {
- errorCallback(e);
removeListeners(p);
+ errorCallback(e);
});
listeners.push(p);
@@ -3528,7 +3401,10 @@ var accelerometer = {
if (running) {
// If we're already running then immediately invoke the success callback
- successCallback(accel);
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if(accel) {
+ successCallback(accel);
+ }
} else {
start();
}
@@ -4043,7 +3919,7 @@ var contacts = {
* This function creates a new contact, but it does not persist the contact
* to device storage. To persist the contact to device storage, invoke
* contact.save().
- * @param properties an object who's properties will be examined to create a new Contact
+ * @param properties an object whose properties will be examined to create a new Contact
* @returns new Contact object
*/
create:function(properties) {
@@ -4130,6 +4006,25 @@ module.exports = new Device();
});
+// file: lib\common\plugin\echo.js
+define("cordova/plugin/echo", function(require, exports, module) {
+var exec = require('cordova/exec');
+
+/**
+ * Sends the given message through exec() to the Echo plugink, which sends it back to the successCallback.
+ * @param successCallback invoked with a FileSystem object
+ * @param errorCallback invoked if error occurs retrieving file system
+ * @param message The string to be echoed.
+ * @param forceAsync Whether to force an async return value (for testing native->js bridge).
+ */
+module.exports = function(successCallback, errorCallback, message, forceAsync) {
+ var action = forceAsync ? 'echoAsync' : 'echo';
+ exec(successCallback, errorCallback, "Echo", action, [message]);
+};
+
+
+});
+
// file: lib\common\plugin\geolocation.js
define("cordova/plugin/geolocation", function(require, exports, module) {
var utils = require('cordova/utils'),
@@ -4238,7 +4133,7 @@ var geolocation = {
} else if (options.timeout === 0) {
fail({
code:PositionError.TIMEOUT,
- message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceed's provided PositionOptions' maximumAge parameter."
+ message:"timeout value in PositionOptions set to 0 and no cached Position object available, or cached Position object's age exceeds provided PositionOptions' maximumAge parameter."
});
// Otherwise we have to call into native to retrieve a position.
} else {
@@ -4402,7 +4297,7 @@ CurrentLevel = LevelsMap.WARN;
*
* The value used determines which messages get printed. The logging
* values above are in order, and only messages logged at the logging
- * level or above will actually be displayed to the user. Eg, the
+ * level or above will actually be displayed to the user. E.g., the
* default level is WARN, so only messages logged with LOG, ERROR, or
* WARN will be displayed; INFO and DEBUG messages will be ignored.
*/
@@ -4798,7 +4693,7 @@ define("cordova/plugin/wp7/CordovaCommandResult", function(require, exports, mod
var cordova = require('cordova');
var channel = require('cordova/channel');
-// singular WP7 callback function attached to window, status is used to determin if it is a success or error
+// 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") {
@@ -5050,6 +4945,9 @@ define("cordova/plugin/wp7/FileTransfer", function(require, exports, module) {
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
@@ -5100,8 +4998,14 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
errorCallback(error);
};
-
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [{"filePath":filePath,
+ "server":server,
+ "fileKey":fileKey,
+ "fileName":fileName,
+ "mimeType":mimeType,
+ "params":params,
+ "trustAllHosts":trustAllHosts,
+ "chunkedMode":chunkedMode}]);
};
/**
@@ -5111,6 +5015,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
* @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.");
@@ -5137,6 +5042,7 @@ FileTransfer.prototype.download = function(source, target, successCallback, erro
exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
};
+
module.exports = FileTransfer;
});
@@ -5173,7 +5079,7 @@ module.exports = FileUploadOptions;
// file: lib\wp7\plugin\wp7\XHRPatch.js
define("cordova/plugin/wp7/XHRPatch", function(require, exports, module) {
-// TODO: the build process implicitly will wrap this in a define() call
+// 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');
@@ -5322,7 +5228,7 @@ if (!docDomain || docDomain.length === 0) {
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 it's stringyness, as handlers are expecting string data.
+ // if so, we need to restore its stringyness, as handlers are expecting string data.
// especially if used with jQ -> $.getJSON
res = JSON.stringify(res);
}
View
2 templates/custom/www/index.html
@@ -15,7 +15,7 @@
<p class="status complete blink hide">Device is Ready</p>
</div>
</div>
- <script type="text/javascript" src="cordova-2.0.0.js"></script>
+ <script type="text/javascript" src="cordova-2.1.0.js"></script>
<script type="text/javascript" src="js/index.js"></script>
<script type="text/javascript">
app.initialize();
View
2 templates/description.txt
@@ -1,4 +1,4 @@
CordovaStarter
-Starter project for building a Cordova app for Windows Phone version: 2.0.0 ( formerly PhoneGap )
+Starter project for building a Cordova app for Windows Phone version: 2.1.0rc1 ( formerly PhoneGap )
View
2 templates/full/CordovaAppProj.csproj
@@ -100,7 +100,7 @@
<Content Include="www\js\index.js" />
<None Include="BuildManifestProcessor.js" />
<Content Include="CordovaLib\WP7CordovaClassLib.dll" />
- <Content Include="www\cordova-2.0.0.js" />
+ <Content Include="www\cordova-2.1.0.js" />
<Content Include="www\css\index.css" />
<Content Include="www\img\cordova.png" />
<Content Include="www\index.html">
View
2 templates/full/CordovaSourceDictionary.xml
@@ -2,7 +2,7 @@
<!-- This file is auto-generated, do not edit! -jm -->
<CordovaSourceDictionary>
<FilePath Value="www\js\index.js"/>
- <FilePath Value="www\cordova-2.0.0.js"/>
+ <FilePath Value="www\cordova-2.1.0.js"/>
<FilePath Value="www\css\index.css"/>
<FilePath Value="www\img\cordova.png"/>
<FilePath Value="www\index.html"/>
View
2 templates/full/VERSION
@@ -1 +1 @@
-2.0.0rc1
+2.1.0rc1
View
300 templates/custom/www/cordova-2.0.0.js → templates/full/www/cordova-2.1.0.js
@@ -1,6 +1,6 @@
-// WP7 commit 2e33015f0e73540904abc05c4f726c3c9ce6879f
+// commit 69d652e9dcaaaf4bdaa55ec37329636dd5b20fbe
-// File generated at :: Wed Jul 18 2012 18:23:58 GMT-0700 (Pacific Daylight Time)
+// File generated at :: Fri Aug 24 2012 14:00:49 GMT-0700 (Pacific Daylight Time)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -29,6 +29,10 @@ var require,
(function () {
var modules = {};
+ // Stack of moduleIds currently being built.
+ var requireStack = [];
+ // Map of module ID -> index into requireStack of modules currently being built.
+ var inProgressModules = {};
function build(module) {
var factory = module.factory;
@@ -41,8 +45,21 @@ var require,
require = function (id) {
if (!modules[id]) {
throw "module " + id + " not found";
+ } else if (id in inProgressModules) {
+ var cycle = requireStack.slice(inProgressModules[id]).join('->') + '->' + id;
+ throw "Cycle in require graph: " + cycle;
}
- return modules[id].factory ? build(modules[id]) : modules[id].exports;
+ if (modules[id].factory) {
+ try {
+ inProgressModules[id] = requireStack.length;
+ requireStack.push(id);
+ return build(modules[id]);
+ } finally {
+ delete inProgressModules[id];
+ requireStack.pop();
+ }
+ }
+ return modules[id].exports;
};
define = function (id, factory) {
@@ -67,6 +84,7 @@ if (typeof module === "object" && typeof require === "function") {
module.exports.require = require;
module.exports.define = define;
}
+
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
var channel = require('cordova/channel');
@@ -207,10 +225,6 @@ var cordova = {
window.dispatchEvent(evt);
}
},
- // TODO: this is Android only; think about how to do this better
- shuttingDown:false,
- UsePolling:false,
- // END TODO
// TODO: iOS only
// This queue holds the currently executing command and all pending
@@ -404,7 +418,8 @@ module.exports = {
// file: lib\common\channel.js
define("cordova/channel", function(require, exports, module) {
-var utils = require('cordova/utils');
+var utils = require('cordova/utils'),
+ nextGuid = 1;
/**
* Custom pub-sub "channel" that can have functions subscribed to it
@@ -456,7 +471,6 @@ var Channel = function(type, opts) {
this.type = type;
this.handlers = {};
this.numHandlers = 0;
- this.guid = 1;
this.fired = false;
this.enabled = true;
this.events = {
@@ -549,19 +563,19 @@ Channel.prototype.subscribe = function(f, c, g) {
g = g || func.observer_guid || f.observer_guid;
if (!g) {
- // first time we've seen this subscriber
- g = this.guid++;
- }
- else {
- // subscriber already handled; dont set it twice
- return g;
+ // first time any channel has seen this subscriber
+ g = nextGuid++;
}
func.observer_guid = g;
f.observer_guid = g;
- this.handlers[g] = func;
- this.numHandlers++;
- if (this.events.onSubscribe) this.events.onSubscribe.call(this);
- if (this.fired) func.call(this);
+
+ // Don't add the same handler more than once.
+ if (!this.handlers[g]) {
+ this.handlers[g] = func;
+ this.numHandlers++;
+ if (this.events.onSubscribe) this.events.onSubscribe.call(this);
+ if (this.fired) func.apply(this, this.fireArgs);
+ }
return g;
};
@@ -575,15 +589,14 @@ Channel.prototype.subscribeOnce = function(f, c) {
var g = null;
var _this = this;
- var m = function() {
- f.apply(c || null, arguments);
- _this.unsubscribe(g);
- };
if (this.fired) {
- if (typeof c == "object") { f = utils.close(c, f); }
- f.apply(this, this.fireArgs);
+ f.apply(c || null, this.fireArgs);
} else {
- g = this.subscribe(m);
+ g = this.subscribe(function() {
+ _this.unsubscribe(g);
+ f.apply(c || null, arguments);
+ });
+ f.observer_guid = g;
}
return g;
};
@@ -599,7 +612,6 @@ Channel.prototype.unsubscribe = function(g) {
var handler = this.handlers[g];
if (handler) {
if (handler.observer_guid) handler.observer_guid=null;
- this.handlers[g] = null;
delete this.handlers[g];
this.numHandlers--;
if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
@@ -613,14 +625,17 @@ Channel.prototype.fire = function(e) {
if (this.enabled) {
var fail = false;
this.fired = true;
+ this.fireArgs = arguments;
+ // Copy the values first so that it is safe to modify it from within
+ // callbacks.
+ var toCall = [];
for (var item in this.handlers) {
- var handler = this.handlers[item];
- if (typeof handler == 'function') {
- var rv = (handler.apply(this, arguments)===false);
- fail = fail || rv;
- }
+ toCall.push(this.handlers[item]);
+ }
+ for (var i = 0; i < toCall.length; ++i) {
+ var rv = (toCall[i].apply(this, arguments)===false);
+ fail = fail || rv;
}
- this.fireArgs = arguments;
return !fail;
}
return true;
@@ -882,7 +897,7 @@ 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
- * Asynchrounous: Empty string ""
+ * Asynchronous: Empty string ""
* If async, the native side will cordova.callbackSuccess or cordova.callbackError,
* depending upon the result of the action.
*
@@ -901,6 +916,13 @@ module.exports = function(success, fail, service, action, args) {
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 {
@@ -979,22 +1001,8 @@ module.exports = {
},
FileTransfer: {
path: 'cordova/plugin/wp7/FileTransfer'
- },
- DirectoryEntry: {
- path: 'cordova/plugin/wp7/DirectoryEntry'
- }
-
- },
- merges:{
- navigator: {
- children: {
- contacts:{
- path:"cordova/plugin/wp7/contacts"
- }
- }
}
}
-
};
});
@@ -2474,10 +2482,12 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
var mimeType = null;
var params = null;
var chunkedMode = true;
+ var headers = null;
if (options) {
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
+ headers = options.headers;
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
@@ -2494,7 +2504,7 @@ FileTransfer.prototype.upload = function(filePath, server, successCallback, erro
errorCallback(error);
};
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers]);
};
/**