Updating bada-wac JS, VERSION to 2.6.0rc1
diff --git a/Res/cordova.js b/Res/cordova.js
index 98c4de4..337fa0c 100644
--- a/Res/cordova.js
+++ b/Res/cordova.js
@@ -1,8 +1,8 @@
// Platform: bada
-// commit 54660e97952c558518cad8c4eecc67cfa42b2993
+// commit bbf1562d4934b1331ffb263424b6ae054cedeb71
-// File generated at :: Tue Feb 26 2013 18:14:09 GMT-0800 (PST)
+// File generated at :: Thu Mar 21 2013 15:25:30 GMT-0700 (PDT)
/*
Licensed to the Apache Software Foundation (ASF) under one
@@ -725,7 +725,6 @@
channel.createSticky('onCordovaConnectionReady');
// Event to indicate that all automatically loaded JS plugins are loaded and ready.
-// This is used in conjunction with the automatic plugin JS loading CLI prototype.
channel.createSticky('onPluginsReady');
// Event to indicate that Cordova is ready
@@ -977,9 +976,10 @@
var correctOrientation = !!options.correctOrientation;
var saveToPhotoAlbum = !!options.saveToPhotoAlbum;
var popoverOptions = getValue(options.popoverOptions, null);
+ var cameraDirection = getValue(options.cameraDirection, Camera.Direction.BACK);
var args = [quality, destinationType, sourceType, targetWidth, targetHeight, encodingType,
- mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions];
+ mediaType, allowEdit, correctOrientation, saveToPhotoAlbum, popoverOptions, cameraDirection];
exec(successCallback, errorCallback, "Camera", "takePicture", args);
return new CameraPopoverHandle();
@@ -1022,6 +1022,10 @@
ARROW_LEFT : 4,
ARROW_RIGHT : 8,
ARROW_ANY : 15
+ },
+ Direction:{
+ BACK: 0,
+ FRONT: 1
}
};
@@ -2213,14 +2217,7 @@
// Default encoding is UTF-8
var enc = encoding ? encoding : "UTF-8";
var me = this;
- var execArgs = [this._fileName, enc];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, enc, file.start, file.end];
// Read file
exec(
@@ -2289,14 +2286,7 @@
}
var me = this;
- var execArgs = [this._fileName];
-
- // Maybe add slice parameters.
- if (file.end < file.size) {
- execArgs.push(file.start, file.end);
- } else if (file.start > 0) {
- execArgs.push(file.start);
- }
+ var execArgs = [this._fileName, file.start, file.end];
// Read file
exec(
@@ -2359,9 +2349,59 @@
if (initRead(this, file)) {
return this._realReader.readAsBinaryString(file);
}
- // TODO - Can't return binary data to browser.
- console.log('method "readAsBinaryString" is not supported at this time.');
- this.abort();
+
+ var me = this;
+ var execArgs = [this._fileName, file.start, file.end];
+
+ // Read file
+ exec(
+ // Success callback
+ function(r) {
+ // If DONE (cancelled), then don't do anything
+ if (me._readyState === FileReader.DONE) {
+ return;
+ }
+
+ // DONE state
+ me._readyState = FileReader.DONE;
+
+ me._result = r;
+
+ // If onload callback
+ if (typeof me.onload === "function") {
+ me.onload(new ProgressEvent("load", {target:me}));
+ }
+
+ // If onloadend callback
+ if (typeof me.onloadend === "function") {
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
+ }
+ },
+ // Error callback
+ function(e) {
+ // If DONE (cancelled), then don't do anything
+ if (me._readyState === FileReader.DONE) {
+ return;
+ }
+
+ // DONE state
+ me._readyState = FileReader.DONE;
+
+ me._result = null;
+
+ // Save error
+ me._error = new FileError(e);
+
+ // If onerror callback
+ if (typeof me.onerror === "function") {
+ me.onerror(new ProgressEvent("error", {target:me}));
+ }
+
+ // If onloadend callback
+ if (typeof me.onloadend === "function") {
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
+ }
+ }, "File", "readAsBinaryString", execArgs);
};
/**
@@ -2373,9 +2413,59 @@
if (initRead(this, file)) {
return this._realReader.readAsArrayBuffer(file);
}
- // TODO - Can't return binary data to browser.
- console.log('This method is not supported at this time.');
- this.abort();
+
+ var me = this;
+ var execArgs = [this._fileName, file.start, file.end];
+
+ // Read file
+ exec(
+ // Success callback
+ function(r) {
+ // If DONE (cancelled), then don't do anything
+ if (me._readyState === FileReader.DONE) {
+ return;
+ }
+
+ // DONE state
+ me._readyState = FileReader.DONE;
+
+ me._result = r;
+
+ // If onload callback
+ if (typeof me.onload === "function") {
+ me.onload(new ProgressEvent("load", {target:me}));
+ }
+
+ // If onloadend callback
+ if (typeof me.onloadend === "function") {
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
+ }
+ },
+ // Error callback
+ function(e) {
+ // If DONE (cancelled), then don't do anything
+ if (me._readyState === FileReader.DONE) {
+ return;
+ }
+
+ // DONE state
+ me._readyState = FileReader.DONE;
+
+ me._result = null;
+
+ // Save error
+ me._error = new FileError(e);
+
+ // If onerror callback
+ if (typeof me.onerror === "function") {
+ me.onerror(new ProgressEvent("error", {target:me}));
+ }
+
+ // If onloadend callback
+ if (typeof me.onloadend === "function") {
+ me.onloadend(new ProgressEvent("loadend", {target:me}));
+ }
+ }, "File", "readAsArrayBuffer", execArgs);
};
module.exports = FileReader;
@@ -2421,6 +2511,38 @@
return pe;
}
+function getBasicAuthHeader(urlString) {
+ var header = null;
+
+ if (window.btoa) {
+ // parse the url using the Location object
+ var url = document.createElement('a');
+ url.href = urlString;
+
+ var credentials = null;
+ var protocol = url.protocol + "//";
+ var origin = protocol + url.host;
+
+ // check whether there are the username:password credentials in the url
+ if (url.href.indexOf(origin) != 0) { // credentials found
+ var atIndex = url.href.indexOf("@");
+ credentials = url.href.substring(protocol.length, atIndex);
+ }
+
+ if (credentials) {
+ var authHeader = "Authorization";
+ var authHeaderValue = "Basic " + window.btoa(credentials);
+
+ header = {
+ name : authHeader,
+ value : authHeaderValue
+ };
+ }
+ }
+
+ return header;
+}
+
var idCounter = 0;
/**
@@ -2451,6 +2573,18 @@
var params = null;
var chunkedMode = true;
var headers = null;
+
+ var basicAuthHeader = getBasicAuthHeader(server);
+ if (basicAuthHeader) {
+ if (!options) {
+ options = new FileUploadOptions();
+ }
+ if (!options.headers) {
+ options.headers = {};
+ }
+ options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+ }
+
if (options) {
fileKey = options.fileKey;
fileName = options.fileName;
@@ -2492,10 +2626,28 @@
* @param successCallback (Function} Callback to be invoked when upload has completed
* @param errorCallback {Function} Callback to be invoked upon error
* @param trustAllHosts {Boolean} Optional trust all hosts (e.g. for self-signed certs), defaults to false
+ * @param options {FileDownloadOptions} Optional parameters such as headers
*/
-FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts) {
+FileTransfer.prototype.download = function(source, target, successCallback, errorCallback, trustAllHosts, options) {
argscheck.checkArgs('ssFF*', 'FileTransfer.download', arguments);
var self = this;
+
+ var basicAuthHeader = getBasicAuthHeader(source);
+ if (basicAuthHeader) {
+ if (!options) {
+ options = {};
+ }
+ if (!options.headers) {
+ options.headers = {};
+ }
+ options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+ }
+
+ var headers = null;
+ if (options) {
+ headers = options.headers || null;
+ }
+
var win = function(result) {
if (typeof result.lengthComputable != "undefined") {
if (self.onprogress) {
@@ -2522,7 +2674,7 @@
errorCallback(error);
};
- exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id]);
+ exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
};
/**
@@ -2920,6 +3072,7 @@
this.channels = {
'loadstart': channel.create('loadstart'),
'loadstop' : channel.create('loadstop'),
+ 'loaderror' : channel.create('loaderror'),
'exit' : channel.create('exit')
};
}
@@ -2950,7 +3103,7 @@
var cb = function(eventname) {
iab._eventHandler(eventname);
};
- exec(cb, null, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
+ exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
return iab;
};
@@ -4110,9 +4263,6 @@
var channel = require('cordova/channel'),
utils = require('cordova/utils');
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
-
function Device() {
this.platform = null;
this.version = null;
@@ -5834,6 +5984,7 @@
define("cordova/plugin/notification", function(require, exports, module) {
var exec = require('cordova/exec');
+var platform = require('cordova/platform');
/**
* Provides access to notifications on the device.
@@ -5862,15 +6013,53 @@
* @param {String} message Message to print in the body of the alert
* @param {Function} resultCallback The callback that is called when user clicks on a button.
* @param {String} title Title of the alert dialog (default: Confirm)
- * @param {String} buttonLabels Comma separated list of the labels of the buttons (default: 'OK,Cancel')
+ * @param {Array} buttonLabels Array of the labels of the buttons (default: ['OK', 'Cancel'])
*/
confirm: function(message, resultCallback, title, buttonLabels) {
var _title = (title || "Confirm");
- var _buttonLabels = (buttonLabels || "OK,Cancel");
+ var _buttonLabels = (buttonLabels || ["OK", "Cancel"]);
+
+ // Strings are deprecated!
+ if (typeof _buttonLabels === 'string') {
+ console.log("Notification.confirm(string, function, string, string) is deprecated. Use Notification.confirm(string, function, string, array).");
+ }
+
+ // Android and iOS take an array of button label names.
+ // Other platforms take a comma separated list.
+ // For compatibility, we convert to the desired type based on the platform.
+ if (platform.id == "android" || platform.id == "ios") {
+ if (typeof _buttonLabels === 'string') {
+ var buttonLabelString = _buttonLabels;
+ _buttonLabels = buttonLabelString.split(",");
+ }
+ } else {
+ if (Array.isArray(_buttonLabels)) {
+ var buttonLabelArray = _buttonLabels;
+ _buttonLabels = buttonLabelArray.toString();
+ }
+ }
exec(resultCallback, null, "Notification", "confirm", [message, _title, _buttonLabels]);
},
/**
+ * Open a native prompt dialog, with a customizable title and button text.
+ * The following results are returned to the result callback:
+ * buttonIndex Index number of the button selected.
+ * input1 The text entered in the prompt dialog box.
+ *
+ * @param {String} message Dialog message to display (default: "Prompt message")
+ * @param {Function} resultCallback The callback that is called when user clicks on a button.
+ * @param {String} title Title of the dialog (default: "Prompt")
+ * @param {Array} buttonLabels Array of strings for the button labels (default: ["OK","Cancel"])
+ */
+ prompt: function(message, resultCallback, title, buttonLabels) {
+ var _message = (message || "Prompt message");
+ var _title = (title || "Prompt");
+ var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
+ exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels]);
+ },
+
+ /**
* Causes the device to vibrate.
*
* @param {Integer} mills The number of milliseconds to vibrate for.
@@ -6323,15 +6512,6 @@
/**
* Create all cordova objects once page has fully loaded and native side is ready.
*/
- var joinEvents = [ channel.onDOMContentLoaded, channel.onNativeReady ];
-
- // If this property is set to something truthy, join on onPluginsReady too.
- // This property is set by the automatic JS installation prototype in cordova-cli,
- // and will be removed when the prototype either becomes mainline or is dropped.
- if (window.__onPluginsLoadedHack) {
- joinEvents.push(channel.onPluginsReady);
- }
-
channel.join(function() {
var builder = require('cordova/builder'),
platform = require('cordova/platform');
@@ -6352,7 +6532,7 @@
require('cordova').fireDocumentEvent('deviceready');
}, channel.deviceReadyChannelsArray);
- }, joinEvents);
+ }, [ channel.onDOMContentLoaded, channel.onNativeReady, channel.onPluginsReady ]);
}(window));
@@ -6360,5 +6540,105 @@
require('cordova/channel').onNativeReady.fire();
+// file: lib/scripts/plugin_loader.js
+
+// Tries to load all plugins' js-modules.
+// This is an async process, but onDeviceReady is blocked on onPluginsReady.
+// onPluginsReady is fired when there are no plugins to load, or they are all done.
+(function (context) {
+ // To be populated with the handler by handlePluginsObject.
+ var onScriptLoadingComplete;
+
+ var scriptCounter = 0;
+ function scriptLoadedCallback() {
+ scriptCounter--;
+ if (scriptCounter === 0) {
+ onScriptLoadingComplete && onScriptLoadingComplete();
+ }
+ }
+
+ // Helper function to inject a <script> tag.
+ function injectScript(path) {
+ scriptCounter++;
+ var script = document.createElement("script");
+ script.onload = scriptLoadedCallback;
+ script.src = path;
+ document.head.appendChild(script);
+ }
+
+ // Called when:
+ // * There are plugins defined and all plugins are finished loading.
+ // * There are no plugins to load.
+ function finishPluginLoading() {
+ context.cordova.require('cordova/channel').onPluginsReady.fire();
+ }
+
+ // Handler for the cordova_plugins.json content.
+ // See plugman's plugin_loader.js for the details of this object.
+ // This function is only called if the really is a plugins array that isn't empty.
+ // Otherwise the XHR response handler will just call finishPluginLoading().
+ function handlePluginsObject(modules) {
+ // First create the callback for when all plugins are loaded.
+ var mapper = context.cordova.require('cordova/modulemapper');
+ onScriptLoadingComplete = function() {
+ // Loop through all the plugins and then through their clobbers and merges.
+ for (var i = 0; i < modules.length; i++) {
+ var module = modules[i];
+ if (!module) continue;
+
+ if (module.clobbers && module.clobbers.length) {
+ for (var j = 0; j < module.clobbers.length; j++) {
+ mapper.clobbers(module.id, module.clobbers[j]);
+ }
+ }
+
+ if (module.merges && module.merges.length) {
+ for (var k = 0; k < module.merges.length; k++) {
+ mapper.merges(module.id, module.merges[k]);
+ }
+ }
+
+ // Finally, if runs is truthy we want to simply require() the module.
+ // This can be skipped if it had any merges or clobbers, though,
+ // since the mapper will already have required the module.
+ if (module.runs && !(module.clobbers && module.clobbers.length) && !(module.merges && module.merges.length)) {
+ context.cordova.require(module.id);
+ }
+ }
+
+ finishPluginLoading();
+ };
+
+ // Now inject the scripts.
+ for (var i = 0; i < modules.length; i++) {
+ injectScript(modules[i].file);
+ }
+ }
+
+ // Try to XHR the cordova_plugins.json file asynchronously.
+ var xhr = new context.XMLHttpRequest();
+ xhr.onreadystatechange = function() {
+ if (this.readyState != 4) { // not DONE
+ return;
+ }
+
+ // If the response is a JSON string which composes an array, call handlePluginsObject.
+ // If the request fails, or the response is not a JSON array, just call finishPluginLoading.
+ if (this.status == 200) {
+ var obj = JSON.parse(this.responseText);
+ if (obj && obj instanceof Array && obj.length > 0) {
+ handlePluginsObject(obj);
+ } else {
+ finishPluginLoading();
+ }
+ } else {
+ finishPluginLoading();
+ }
+ };
+ xhr.open('GET', 'cordova_plugins.json', true); // Async
+ xhr.send();
+}(window));
+
+
})();
\ No newline at end of file
diff --git a/VERSION b/VERSION
index 437459c..f47de85 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-2.5.0
+2.6.0rc1