[cordova-tizen] tizen SDK 22 update
update lib/cordova.js file with a 2.9.0 cordova build
diff --git a/lib/cordova.js b/lib/cordova.js
index 04a0a99..0124b12 100644
--- a/lib/cordova.js
+++ b/lib/cordova.js
@@ -1,4 +1,25 @@
/*
+ *
+ * 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.
+ *
+*/
+
+/*
* No real native code
*/
@@ -7,10 +28,8 @@
window._nativeReady = true;
-// commit 7dd17b00544742d14ecdeff2148a66480680f12b
-
-// File generated at :: Thu Jul 26 2012 17:32:56 GMT+0200 (CEST)
-
+// Platform: tizen
+// 2.9.0-28-gc01c173
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -29,29 +48,57 @@
specific language governing permissions and limitations
under the License.
*/
-
;(function() {
-
+var CORDOVA_JS_BUILD_LABEL = '2.9.0-28-gc01c173';
// file: lib/scripts/require.js
+
var require,
define;
(function () {
- var modules = {};
+ var modules = {},
+ // Stack of moduleIds currently being built.
+ requireStack = [],
+ // Map of module ID -> index into requireStack of modules currently being built.
+ inProgressModules = {},
+ SEPERATOR = ".";
+
+
function build(module) {
- var factory = module.factory;
+ var factory = module.factory,
+ localRequire = function (id) {
+ var resultantId = id;
+ //Its a relative path, so lop off the last portion and add the id (minus "./")
+ if (id.charAt(0) === ".") {
+ resultantId = module.id.slice(0, module.id.lastIndexOf(SEPERATOR)) + SEPERATOR + id.slice(2);
+ }
+ return require(resultantId);
+ };
module.exports = {};
delete module.factory;
- factory(require, module.exports, module);
+ factory(localRequire, module.exports, module);
return module.exports;
}
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) {
@@ -69,6 +116,7 @@
delete modules[id];
};
+ define.moduleMap = modules;
})();
//Export for use in node
@@ -76,8 +124,11 @@
module.exports.require = require;
module.exports.define = define;
}
+
// file: lib/cordova.js
define("cordova", function(require, exports, module) {
+
+
var channel = require('cordova/channel');
/**
@@ -108,11 +159,7 @@
document.addEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
if (typeof documentEventHandlers[e] != 'undefined') {
- if (evt === 'deviceready') {
- documentEventHandlers[e].subscribeOnce(handler);
- } else {
- documentEventHandlers[e].subscribe(handler);
- }
+ documentEventHandlers[e].subscribe(handler);
} else {
m_document_addEventListener.call(document, evt, handler, capture);
}
@@ -129,7 +176,7 @@
document.removeEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
+ // If unsubscribing from an event that is handled by a plugin
if (typeof documentEventHandlers[e] != "undefined") {
documentEventHandlers[e].unsubscribe(handler);
} else {
@@ -139,7 +186,7 @@
window.removeEventListener = function(evt, handler, capture) {
var e = evt.toLowerCase();
- // If unsubcribing from an event that is handled by a plugin
+ // If unsubscribing from an event that is handled by a plugin
if (typeof windowEventHandlers[e] != "undefined") {
windowEventHandlers[e].unsubscribe(handler);
} else {
@@ -172,11 +219,14 @@
/**
* Methods to add/remove your own addEventListener hijacking on document + window.
*/
- addWindowEventHandler:function(event, opts) {
- return (windowEventHandlers[event] = channel.create(event, opts));
+ addWindowEventHandler:function(event) {
+ return (windowEventHandlers[event] = channel.create(event));
},
- addDocumentEventHandler:function(event, opts) {
- return (documentEventHandlers[event] = channel.create(event, opts));
+ addStickyDocumentEventHandler:function(event) {
+ return (documentEventHandlers[event] = channel.createSticky(event));
+ },
+ addDocumentEventHandler:function(event) {
+ return (documentEventHandlers[event] = channel.create(event));
},
removeWindowEventHandler:function(event) {
delete windowEventHandlers[event];
@@ -185,7 +235,7 @@
delete documentEventHandlers[event];
},
/**
- * Retreive original event handlers that were replaced by Cordova
+ * Retrieve original event handlers that were replaced by Cordova
*
* @return object
*/
@@ -195,13 +245,23 @@
},
/**
* Method to fire event from native code
+ * bNoDetach is required for events which cause an exception which needs to be caught in native code
*/
- fireDocumentEvent: function(type, data) {
+ fireDocumentEvent: function(type, data, bNoDetach) {
var evt = createEvent(type, data);
if (typeof documentEventHandlers[type] != 'undefined') {
- setTimeout(function() {
- documentEventHandlers[type].fire(evt);
- }, 0);
+ if( bNoDetach ) {
+ documentEventHandlers[type].fire(evt);
+ }
+ else {
+ setTimeout(function() {
+ // Fire deviceready on listeners that were registered before cordova.js was loaded.
+ if (type == 'deviceready') {
+ document.dispatchEvent(evt);
+ }
+ documentEventHandlers[type].fire(evt);
+ }, 0);
+ }
} else {
document.dispatchEvent(evt);
}
@@ -216,23 +276,13 @@
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
- // commands executed with cordova.exec().
- commandQueue:[],
- // Indicates if we're currently in the middle of flushing the command
- // queue on the native side.
- commandQueueFlushing:false,
- // END TODO
/**
* Plugin callback mechanism.
*/
- callbackId: 0,
+ // Randomize the starting callbackId to avoid collisions after refreshing or navigating.
+ // This way, it's very unlikely that any new callback would get the same callbackId as an old callback.
+ callbackId: Math.floor(Math.random() * 2000000000),
callbacks: {},
callbackStatus: {
NO_RESULT: 0,
@@ -249,57 +299,48 @@
/**
* Called by native code when returning successful result from an action.
- *
- * @param callbackId
- * @param args
*/
callbackSuccess: function(callbackId, args) {
- if (cordova.callbacks[callbackId]) {
-
- // If result is to be sent to callback
- if (args.status == cordova.callbackStatus.OK) {
- try {
- if (cordova.callbacks[callbackId].success) {
- cordova.callbacks[callbackId].success(args.message);
- }
- }
- catch (e) {
- console.log("Error in success callback: "+callbackId+" = "+e);
- }
- }
-
- // Clear callback if not expecting any more results
- if (!args.keepCallback) {
- delete cordova.callbacks[callbackId];
- }
+ try {
+ cordova.callbackFromNative(callbackId, true, args.status, [args.message], args.keepCallback);
+ } catch (e) {
+ console.log("Error in error callback: " + callbackId + " = "+e);
}
},
/**
* Called by native code when returning error result from an action.
- *
- * @param callbackId
- * @param args
*/
callbackError: function(callbackId, args) {
- if (cordova.callbacks[callbackId]) {
- try {
- if (cordova.callbacks[callbackId].fail) {
- cordova.callbacks[callbackId].fail(args.message);
- }
- }
- catch (e) {
- console.log("Error in error callback: "+callbackId+" = "+e);
+ // TODO: Deprecate callbackSuccess and callbackError in favour of callbackFromNative.
+ // Derive success from status.
+ try {
+ cordova.callbackFromNative(callbackId, false, args.status, [args.message], args.keepCallback);
+ } catch (e) {
+ console.log("Error in error callback: " + callbackId + " = "+e);
+ }
+ },
+
+ /**
+ * Called by native code when returning the result from an action.
+ */
+ callbackFromNative: function(callbackId, success, status, args, keepCallback) {
+ var callback = cordova.callbacks[callbackId];
+ if (callback) {
+ if (success && status == cordova.callbackStatus.OK) {
+ callback.success && callback.success.apply(null, args);
+ } else if (!success) {
+ callback.fail && callback.fail.apply(null, args);
}
// Clear callback if not expecting any more results
- if (!args.keepCallback) {
+ if (!keepCallback) {
delete cordova.callbacks[callbackId];
}
}
},
addConstructor: function(func) {
- channel.onCordovaReady.subscribeOnce(function() {
+ channel.onCordovaReady.subscribe(function() {
try {
func();
} catch(e) {
@@ -312,14 +353,81 @@
// Register pause, resume and deviceready channels as events on document.
channel.onPause = cordova.addDocumentEventHandler('pause');
channel.onResume = cordova.addDocumentEventHandler('resume');
-channel.onDeviceReady = cordova.addDocumentEventHandler('deviceready');
+channel.onDeviceReady = cordova.addStickyDocumentEventHandler('deviceready');
module.exports = cordova;
});
+// file: lib/common/argscheck.js
+define("cordova/argscheck", function(require, exports, module) {
+
+var exec = require('cordova/exec');
+var utils = require('cordova/utils');
+
+var moduleExports = module.exports;
+
+var typeMap = {
+ 'A': 'Array',
+ 'D': 'Date',
+ 'N': 'Number',
+ 'S': 'String',
+ 'F': 'Function',
+ 'O': 'Object'
+};
+
+function extractParamName(callee, argIndex) {
+ return (/.*?\((.*?)\)/).exec(callee)[1].split(', ')[argIndex];
+}
+
+function checkArgs(spec, functionName, args, opt_callee) {
+ if (!moduleExports.enableChecks) {
+ return;
+ }
+ var errMsg = null;
+ var typeName;
+ for (var i = 0; i < spec.length; ++i) {
+ var c = spec.charAt(i),
+ cUpper = c.toUpperCase(),
+ arg = args[i];
+ // Asterix means allow anything.
+ if (c == '*') {
+ continue;
+ }
+ typeName = utils.typeName(arg);
+ if ((arg === null || arg === undefined) && c == cUpper) {
+ continue;
+ }
+ if (typeName != typeMap[cUpper]) {
+ errMsg = 'Expected ' + typeMap[cUpper];
+ break;
+ }
+ }
+ if (errMsg) {
+ errMsg += ', but got ' + typeName + '.';
+ errMsg = 'Wrong type for parameter "' + extractParamName(opt_callee || args.callee, i) + '" of ' + functionName + ': ' + errMsg;
+ // Don't log when running unit tests.
+ if (typeof jasmine == 'undefined') {
+ console.error(errMsg);
+ }
+ throw TypeError(errMsg);
+ }
+}
+
+function getValue(value, defaultValue) {
+ return value === undefined ? defaultValue : value;
+}
+
+moduleExports.checkArgs = checkArgs;
+moduleExports.getValue = getValue;
+moduleExports.enableChecks = true;
+
+
+});
+
// file: lib/common/builder.js
define("cordova/builder", function(require, exports, module) {
+
var utils = require('cordova/utils');
function each(objects, func, context) {
@@ -330,6 +438,30 @@
}
}
+function clobber(obj, key, value) {
+ exports.replaceHookForTesting(obj, key);
+ obj[key] = value;
+ // Getters can only be overridden by getters.
+ if (obj[key] !== value) {
+ utils.defineGetter(obj, key, function() {
+ return value;
+ });
+ }
+}
+
+function assignOrWrapInDeprecateGetter(obj, key, value, message) {
+ if (message) {
+ utils.defineGetter(obj, key, function() {
+ console.log(message);
+ delete obj[key];
+ clobber(obj, key, value);
+ return value;
+ });
+ } else {
+ clobber(obj, key, value);
+ }
+}
+
function include(parent, objects, clobber, merge) {
each(objects, function (obj, key) {
try {
@@ -338,24 +470,20 @@
if (clobber) {
// Clobber if it doesn't exist.
if (typeof parent[key] === 'undefined') {
- parent[key] = result;
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else if (typeof obj.path !== 'undefined') {
// If merging, merge properties onto parent, otherwise, clobber.
if (merge) {
recursiveMerge(parent[key], result);
} else {
- parent[key] = result;
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
}
}
result = parent[key];
} else {
// Overwrite if not currently defined.
if (typeof parent[key] == 'undefined') {
- parent[key] = result;
- } else if (merge && typeof obj.path !== 'undefined') {
- // If merging, merge parent onto result
- recursiveMerge(result, parent[key]);
- parent[key] = result;
+ assignOrWrapInDeprecateGetter(parent, key, result, obj.deprecated);
} else {
// Set result to what already exists, so we can build children into it if they exist.
result = parent[key];
@@ -381,56 +509,60 @@
function recursiveMerge(target, src) {
for (var prop in src) {
if (src.hasOwnProperty(prop)) {
- if (typeof target.prototype !== 'undefined' && target.prototype.constructor === target) {
+ if (target.prototype && target.prototype.constructor === target) {
// If the target object is a constructor override off prototype.
- target.prototype[prop] = src[prop];
+ clobber(target.prototype, prop, src[prop]);
} else {
- target[prop] = typeof src[prop] === 'object' ? recursiveMerge(
- target[prop], src[prop]) : src[prop];
+ if (typeof src[prop] === 'object' && typeof target[prop] === 'object') {
+ recursiveMerge(target[prop], src[prop]);
+ } else {
+ clobber(target, prop, src[prop]);
+ }
}
}
}
- return target;
}
-module.exports = {
- build: function (objects) {
- return {
- intoButDontClobber: function (target) {
- include(target, objects, false, false);
- },
- intoAndClobber: function(target) {
- include(target, objects, true, false);
- },
- intoAndMerge: function(target) {
- include(target, objects, true, true);
- }
- };
- }
+exports.buildIntoButDoNotClobber = function(objects, target) {
+ include(target, objects, false, false);
};
+exports.buildIntoAndClobber = function(objects, target) {
+ include(target, objects, true, false);
+};
+exports.buildIntoAndMerge = function(objects, target) {
+ include(target, objects, true, true);
+};
+exports.recursiveMerge = recursiveMerge;
+exports.assignOrWrapInDeprecateGetter = assignOrWrapInDeprecateGetter;
+exports.replaceHookForTesting = function() {};
});
// 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
* This object is used to define and control firing of events for
- * cordova initialization.
+ * cordova initialization, as well as for custom events thereafter.
*
* The order of events during page load and Cordova startup is as follows:
*
- * onDOMContentLoaded Internal event that is received when the web page is loaded and parsed.
- * onNativeReady Internal event that indicates the Cordova native side is ready.
- * onCordovaReady Internal event fired when all Cordova JavaScript objects have been created.
- * onCordovaInfoReady Internal event fired when device properties are available.
- * onCordovaConnectionReady Internal event fired when the connection property has been set.
- * onDeviceReady User event fired to indicate that Cordova is ready
- * onResume User event fired to indicate a start/resume lifecycle event
- * onPause User event fired to indicate a pause lifecycle event
- * onDestroy Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
+ * onDOMContentLoaded* Internal event that is received when the web page is loaded and parsed.
+ * onNativeReady* Internal event that indicates the Cordova native side is ready.
+ * onCordovaReady* Internal event fired when all Cordova JavaScript objects have been created.
+ * onCordovaInfoReady* Internal event fired when device properties are available.
+ * onCordovaConnectionReady* Internal event fired when the connection property has been set.
+ * onDeviceReady* User event fired to indicate that Cordova is ready
+ * onResume User event fired to indicate a start/resume lifecycle event
+ * onPause User event fired to indicate a pause lifecycle event
+ * onDestroy* Internal event fired when app is being destroyed (User should use window.onunload event, not this one).
+ *
+ * The events marked with an * are sticky. Once they have fired, they will stay in the fired state.
+ * All listeners that subscribe after the event is fired will be executed right away.
*
* The only Cordova events that user code should register for are:
* deviceready Cordova native code is initialized and Cordova APIs can be called from JavaScript
@@ -452,50 +584,45 @@
* Channel
* @constructor
* @param type String the channel name
- * @param opts Object options to pass into the channel, currently
- * supports:
- * onSubscribe: callback that fires when
- * something subscribes to the Channel. Sets
- * context to the Channel.
- * onUnsubscribe: callback that fires when
- * something unsubscribes to the Channel. Sets
- * context to the Channel.
*/
-var Channel = function(type, opts) {
+var Channel = function(type, sticky) {
this.type = type;
+ // Map of guid -> function.
this.handlers = {};
+ // 0 = Non-sticky, 1 = Sticky non-fired, 2 = Sticky fired.
+ this.state = sticky ? 1 : 0;
+ // Used in sticky mode to remember args passed to fire().
+ this.fireArgs = null;
+ // Used by onHasSubscribersChange to know if there are any listeners.
this.numHandlers = 0;
- this.guid = 1;
- this.fired = false;
- this.enabled = true;
- this.events = {
- onSubscribe:null,
- onUnsubscribe:null
- };
- if (opts) {
- if (opts.onSubscribe) this.events.onSubscribe = opts.onSubscribe;
- if (opts.onUnsubscribe) this.events.onUnsubscribe = opts.onUnsubscribe;
- }
+ // Function that is called when the first listener is subscribed, or when
+ // the last listener is unsubscribed.
+ this.onHasSubscribersChange = null;
},
channel = {
/**
* Calls the provided function only after all of the channels specified
- * have been fired.
+ * have been fired. All channels must be sticky channels.
*/
- join: function (h, c) {
- var i = c.length;
- var len = i;
- var f = function() {
- if (!(--i)) h();
- };
+ join: function(h, c) {
+ var len = c.length,
+ i = len,
+ f = function() {
+ if (!(--i)) h();
+ };
for (var j=0; j<len; j++) {
- !c[j].fired?c[j].subscribeOnce(f):i--;
+ if (c[j].state === 0) {
+ throw Error('Can only use join with sticky channels.');
+ }
+ c[j].subscribe(f);
}
- if (!i) h();
+ if (!len) h();
},
- create: function (type, opts) {
- channel[type] = new Channel(type, opts);
- return channel[type];
+ create: function(type) {
+ return channel[type] = new Channel(type, false);
+ },
+ createSticky: function(type) {
+ return channel[type] = new Channel(type, true);
},
/**
@@ -513,13 +640,7 @@
*/
waitForInitialization: function(feature) {
if (feature) {
- var c = null;
- if (this[feature]) {
- c = this[feature];
- }
- else {
- c = this.create(feature);
- }
+ var c = channel[feature] || this.createSticky(feature);
this.deviceReadyChannelsMap[feature] = c;
this.deviceReadyChannelsArray.push(c);
}
@@ -539,7 +660,7 @@
};
function forceFunction(f) {
- if (f === null || f === undefined || typeof f != 'function') throw "Function required as first argument!";
+ if (typeof f != 'function') throw "Function required as first argument!";
}
/**
@@ -549,69 +670,50 @@
* and a guid that can be used to stop subscribing to the channel.
* Returns the guid.
*/
-Channel.prototype.subscribe = function(f, c, g) {
+Channel.prototype.subscribe = function(f, c) {
// need a function to call
forceFunction(f);
+ if (this.state == 2) {
+ f.apply(c || this, this.fireArgs);
+ return;
+ }
- var func = f;
+ var func = f,
+ guid = f.observer_guid;
if (typeof c == "object") { func = utils.close(c, f); }
- g = g || func.observer_guid || f.observer_guid;
- if (!g) {
- // first time we've seen this subscriber
- g = this.guid++;
+ if (!guid) {
+ // first time any channel has seen this subscriber
+ guid = '' + nextGuid++;
}
- else {
- // subscriber already handled; dont set it twice
- return g;
- }
- 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);
- return g;
-};
+ func.observer_guid = guid;
+ f.observer_guid = guid;
-/**
- * Like subscribe but the function is only called once and then it
- * auto-unsubscribes itself.
- */
-Channel.prototype.subscribeOnce = function(f, c) {
- // need a function to call
- forceFunction(f);
-
- 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);
- } else {
- g = this.subscribe(m);
+ // Don't add the same handler more than once.
+ if (!this.handlers[guid]) {
+ this.handlers[guid] = func;
+ this.numHandlers++;
+ if (this.numHandlers == 1) {
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
+ }
}
- return g;
};
/**
* Unsubscribes the function with the given guid from the channel.
*/
-Channel.prototype.unsubscribe = function(g) {
+Channel.prototype.unsubscribe = function(f) {
// need a function to unsubscribe
- if (g === null || g === undefined) { throw "You must pass _something_ into Channel.unsubscribe"; }
+ forceFunction(f);
- if (typeof g == 'function') { g = g.observer_guid; }
- var handler = this.handlers[g];
+ var guid = f.observer_guid,
+ handler = this.handlers[guid];
if (handler) {
- if (handler.observer_guid) handler.observer_guid=null;
- this.handlers[g] = null;
- delete this.handlers[g];
+ delete this.handlers[guid];
this.numHandlers--;
- if (this.events.onUnsubscribe) this.events.onUnsubscribe.call(this);
+ if (this.numHandlers === 0) {
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
+ }
}
};
@@ -619,41 +721,54 @@
* Calls all functions subscribed to this channel.
*/
Channel.prototype.fire = function(e) {
- if (this.enabled) {
- var fail = false;
- this.fired = true;
- 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;
- }
- }
- this.fireArgs = arguments;
- return !fail;
+ var fail = false,
+ fireArgs = Array.prototype.slice.call(arguments);
+ // Apply stickiness.
+ if (this.state == 1) {
+ this.state = 2;
+ this.fireArgs = fireArgs;
}
- return true;
+ if (this.numHandlers) {
+ // Copy the values first so that it is safe to modify it from within
+ // callbacks.
+ var toCall = [];
+ for (var item in this.handlers) {
+ toCall.push(this.handlers[item]);
+ }
+ for (var i = 0; i < toCall.length; ++i) {
+ toCall[i].apply(this, fireArgs);
+ }
+ if (this.state == 2 && this.numHandlers) {
+ this.numHandlers = 0;
+ this.handlers = {};
+ this.onHasSubscribersChange && this.onHasSubscribersChange();
+ }
+ }
};
+
// defining them here so they are ready super fast!
// DOM event that is received when the web page is loaded and parsed.
-channel.create('onDOMContentLoaded');
+channel.createSticky('onDOMContentLoaded');
// Event to indicate the Cordova native side is ready.
-channel.create('onNativeReady');
+channel.createSticky('onNativeReady');
// Event to indicate that all Cordova JavaScript objects have been created
// and it's time to run plugin constructors.
-channel.create('onCordovaReady');
+channel.createSticky('onCordovaReady');
// Event to indicate that device properties are available
-channel.create('onCordovaInfoReady');
+channel.createSticky('onCordovaInfoReady');
// Event to indicate that the connection property has been set.
-channel.create('onCordovaConnectionReady');
+channel.createSticky('onCordovaConnectionReady');
+
+// Event to indicate that all automatically loaded JS plugins are loaded and ready.
+channel.createSticky('onPluginsReady');
// Event to indicate that Cordova is ready
-channel.create('onDeviceReady');
+channel.createSticky('onDeviceReady');
// Event to indicate a resume lifecycle event
channel.create('onResume');
@@ -662,234 +777,69 @@
channel.create('onPause');
// Event to indicate a destroy lifecycle event
-channel.create('onDestroy');
+channel.createSticky('onDestroy');
// Channels that must fire before "deviceready" is fired.
channel.waitForInitialization('onCordovaReady');
channel.waitForInitialization('onCordovaConnectionReady');
+channel.waitForInitialization('onDOMContentLoaded');
module.exports = channel;
});
-// file: lib/common/common.js
-define("cordova/common", function(require, exports, module) {
+// file: lib/common/commandProxy.js
+define("cordova/commandProxy", function(require, exports, module) {
+
+
+// internal map of proxy function
+var CommandProxyMap = {};
+
module.exports = {
- objects: {
- cordova: {
- path: 'cordova',
- children: {
- exec: {
- path: 'cordova/exec'
- },
- logger: {
- path: 'cordova/plugin/logger'
- }
- }
- },
- Cordova: {
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- PhoneGap:{
- children: {
- exec: {
- path: 'cordova/exec'
- }
- }
- },
- navigator: {
- children: {
- notification: {
- path: 'cordova/plugin/notification'
- },
- accelerometer: {
- path: 'cordova/plugin/accelerometer'
- },
- battery: {
- path: 'cordova/plugin/battery'
- },
- camera:{
- path: 'cordova/plugin/Camera'
- },
- compass:{
- path: 'cordova/plugin/compass'
- },
- contacts: {
- path: 'cordova/plugin/contacts'
- },
- device:{
- children:{
- capture: {
- path: 'cordova/plugin/capture'
- }
- }
- },
- geolocation: {
- path: 'cordova/plugin/geolocation'
- },
- network: {
- children: {
- connection: {
- path: 'cordova/plugin/network'
- }
- }
- },
- splashscreen: {
- path: 'cordova/plugin/splashscreen'
- }
- }
- },
- Acceleration: {
- path: 'cordova/plugin/Acceleration'
- },
- Camera:{
- path: 'cordova/plugin/CameraConstants'
- },
- CameraPopoverOptions: {
- path: 'cordova/plugin/CameraPopoverOptions'
- },
- CaptureError: {
- path: 'cordova/plugin/CaptureError'
- },
- CaptureAudioOptions:{
- path: 'cordova/plugin/CaptureAudioOptions'
- },
- CaptureImageOptions: {
- path: 'cordova/plugin/CaptureImageOptions'
- },
- CaptureVideoOptions: {
- path: 'cordova/plugin/CaptureVideoOptions'
- },
- CompassHeading:{
- path: 'cordova/plugin/CompassHeading'
- },
- CompassError:{
- path: 'cordova/plugin/CompassError'
- },
- ConfigurationData: {
- path: 'cordova/plugin/ConfigurationData'
- },
- Connection: {
- path: 'cordova/plugin/Connection'
- },
- Contact: {
- path: 'cordova/plugin/Contact'
- },
- ContactAddress: {
- path: 'cordova/plugin/ContactAddress'
- },
- ContactError: {
- path: 'cordova/plugin/ContactError'
- },
- ContactField: {
- path: 'cordova/plugin/ContactField'
- },
- ContactFindOptions: {
- path: 'cordova/plugin/ContactFindOptions'
- },
- ContactName: {
- path: 'cordova/plugin/ContactName'
- },
- ContactOrganization: {
- path: 'cordova/plugin/ContactOrganization'
- },
- Coordinates: {
- path: 'cordova/plugin/Coordinates'
- },
- device: {
- path: 'cordova/plugin/device'
- },
- DirectoryEntry: {
- path: 'cordova/plugin/DirectoryEntry'
- },
- DirectoryReader: {
- path: 'cordova/plugin/DirectoryReader'
- },
- Entry: {
- path: 'cordova/plugin/Entry'
- },
- File: {
- path: 'cordova/plugin/File'
- },
- FileEntry: {
- path: 'cordova/plugin/FileEntry'
- },
- FileError: {
- path: 'cordova/plugin/FileError'
- },
- FileReader: {
- path: 'cordova/plugin/FileReader'
- },
- FileSystem: {
- path: 'cordova/plugin/FileSystem'
- },
- FileTransfer: {
- path: 'cordova/plugin/FileTransfer'
- },
- FileTransferError: {
- path: 'cordova/plugin/FileTransferError'
- },
- FileUploadOptions: {
- path: 'cordova/plugin/FileUploadOptions'
- },
- FileUploadResult: {
- path: 'cordova/plugin/FileUploadResult'
- },
- FileWriter: {
- path: 'cordova/plugin/FileWriter'
- },
- Flags: {
- path: 'cordova/plugin/Flags'
- },
- LocalFileSystem: {
- path: 'cordova/plugin/LocalFileSystem'
- },
- Media: {
- path: 'cordova/plugin/Media'
- },
- MediaError: {
- path: 'cordova/plugin/MediaError'
- },
- MediaFile: {
- path: 'cordova/plugin/MediaFile'
- },
- MediaFileData:{
- path: 'cordova/plugin/MediaFileData'
- },
- Metadata:{
- path: 'cordova/plugin/Metadata'
- },
- Position: {
- path: 'cordova/plugin/Position'
- },
- PositionError: {
- path: 'cordova/plugin/PositionError'
- },
- ProgressEvent: {
- path: 'cordova/plugin/ProgressEvent'
- },
- requestFileSystem:{
- path: 'cordova/plugin/requestFileSystem'
- },
- resolveLocalFileSystemURI:{
- path: 'cordova/plugin/resolveLocalFileSystemURI'
- }
+
+ // example: cordova.commandProxy.add("Accelerometer",{getCurrentAcceleration: function(successCallback, errorCallback, options) {...},...);
+ add:function(id,proxyObj) {
+ console.log("adding proxy for " + id);
+ CommandProxyMap[id] = proxyObj;
+ return proxyObj;
+ },
+
+ // cordova.commandProxy.remove("Accelerometer");
+ remove:function(id) {
+ var proxy = CommandProxyMap[id];
+ delete CommandProxyMap[id];
+ CommandProxyMap[id] = null;
+ return proxy;
+ },
+
+ get:function(service,action) {
+ return ( CommandProxyMap[service] ? CommandProxyMap[service][action] : null );
}
};
-
});
// file: lib/tizen/exec.js
define("cordova/exec", function(require, exports, module) {
+
/**
* 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.
+ *
+ * @param {Function} successCB The success callback
+ * @param {Function} failCB 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
+ */
+/**
+ * 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.
*
@@ -900,14 +850,19 @@
* @param {String[]} [args] Zero or more arguments to pass to the method
*/
-var tizen = require('cordova/plugin/tizen/manager'),
+//console.log("TIZEN EXEC START");
+
+
+var manager = require('cordova/plugin/tizen/manager'),
cordova = require('cordova'),
utils = require('cordova/utils');
+//console.log("TIZEN EXEC START bis");
+
module.exports = function(successCB, failCB, service, action, args) {
try {
- var v = tizen.exec(successCB, failCB, service, action, args);
+ var v = manager.exec(successCB, failCB, service, action, args);
// If status is OK, then return value back to caller
if (v.status == cordova.callbackStatus.OK) {
@@ -945,54 +900,176 @@
}
};
+//console.log("TIZEN EXEC END ");
+
+/*
+var plugins = {
+ "Device": require('cordova/plugin/tizen/Device'),
+ "NetworkStatus": require('cordova/plugin/tizen/NetworkStatus'),
+ "Accelerometer": require('cordova/plugin/tizen/Accelerometer'),
+ "Battery": require('cordova/plugin/tizen/Battery'),
+ "Compass": require('cordova/plugin/tizen/Compass'),
+ //"Capture": require('cordova/plugin/tizen/Capture'), not yet available
+ "Camera": require('cordova/plugin/tizen/Camera'),
+ "FileTransfer": require('cordova/plugin/tizen/FileTransfer'),
+ "Media": require('cordova/plugin/tizen/Media'),
+ "Notification": require('cordova/plugin/tizen/Notification')
+};
+
+console.log("TIZEN EXEC START");
+
+module.exports = function(success, fail, service, action, args) {
+ try {
+ console.log("exec: " + service + "." + action);
+ plugins[service][action](success, fail, args);
+ }
+ catch(e) {
+ console.log("missing exec: " + service + "." + action);
+ console.log(args);
+ console.log(e);
+ console.log(e.stack);
+ }
+};
+
+console.log("TIZEN EXEC START");
+*/
+
+});
+
+// file: lib/common/modulemapper.js
+define("cordova/modulemapper", function(require, exports, module) {
+
+var builder = require('cordova/builder'),
+ moduleMap = define.moduleMap,
+ symbolList,
+ deprecationMap;
+
+exports.reset = function() {
+ symbolList = [];
+ deprecationMap = {};
+};
+
+function addEntry(strategy, moduleName, symbolPath, opt_deprecationMessage) {
+ if (!(moduleName in moduleMap)) {
+ throw new Error('Module ' + moduleName + ' does not exist.');
+ }
+ symbolList.push(strategy, moduleName, symbolPath);
+ if (opt_deprecationMessage) {
+ deprecationMap[symbolPath] = opt_deprecationMessage;
+ }
+}
+
+// Note: Android 2.3 does have Function.bind().
+exports.clobbers = function(moduleName, symbolPath, opt_deprecationMessage) {
+ addEntry('c', moduleName, symbolPath, opt_deprecationMessage);
+};
+
+exports.merges = function(moduleName, symbolPath, opt_deprecationMessage) {
+ addEntry('m', moduleName, symbolPath, opt_deprecationMessage);
+};
+
+exports.defaults = function(moduleName, symbolPath, opt_deprecationMessage) {
+ addEntry('d', moduleName, symbolPath, opt_deprecationMessage);
+};
+
+function prepareNamespace(symbolPath, context) {
+ if (!symbolPath) {
+ return context;
+ }
+ var parts = symbolPath.split('.');
+ var cur = context;
+ for (var i = 0, part; part = parts[i]; ++i) {
+ cur = cur[part] = cur[part] || {};
+ }
+ return cur;
+}
+
+exports.mapModules = function(context) {
+ var origSymbols = {};
+ context.CDV_origSymbols = origSymbols;
+ for (var i = 0, len = symbolList.length; i < len; i += 3) {
+ var strategy = symbolList[i];
+ var moduleName = symbolList[i + 1];
+ var symbolPath = symbolList[i + 2];
+ var lastDot = symbolPath.lastIndexOf('.');
+ var namespace = symbolPath.substr(0, lastDot);
+ var lastName = symbolPath.substr(lastDot + 1);
+
+ var module = require(moduleName);
+ var deprecationMsg = symbolPath in deprecationMap ? 'Access made to deprecated symbol: ' + symbolPath + '. ' + deprecationMsg : null;
+ var parentObj = prepareNamespace(namespace, context);
+ var target = parentObj[lastName];
+
+ if (strategy == 'm' && target) {
+ builder.recursiveMerge(target, module);
+ } else if ((strategy == 'd' && !target) || (strategy != 'd')) {
+ if (!(symbolPath in origSymbols)) {
+ origSymbols[symbolPath] = target;
+ }
+ builder.assignOrWrapInDeprecateGetter(parentObj, lastName, module, deprecationMsg);
+ }
+ }
+};
+
+exports.getOriginalSymbol = function(context, symbolPath) {
+ var origSymbols = context.CDV_origSymbols;
+ if (origSymbols && (symbolPath in origSymbols)) {
+ return origSymbols[symbolPath];
+ }
+ var parts = symbolPath.split('.');
+ var obj = context;
+ for (var i = 0; i < parts.length; ++i) {
+ obj = obj && obj[parts[i]];
+ }
+ return obj;
+};
+
+exports.loadMatchingModules = function(matchingRegExp) {
+ for (var k in moduleMap) {
+ if (matchingRegExp.exec(k)) {
+ require(k);
+ }
+ }
+};
+
+exports.reset();
+
+
});
// file: lib/tizen/platform.js
define("cordova/platform", function(require, exports, module) {
+
+//console.log("TIZEN PLATFORM START");
+
+
module.exports = {
id: "tizen",
- initialize: function() {},
- objects: {
- device: {
- path: "cordova/plugin/tizen/Device"
- },
- File: { // exists natively, override
- path: "cordova/plugin/File"
- },
- FileReader: { // exists natively, override
- path: "cordova/plugin/FileReader"
- },
- FileError: { //exists natively, override
- path: "cordova/plugin/FileError"
- }
- },
- merges: {
- MediaError: { // exists natively
- path: "cordova/plugin/tizen/MediaError"
- },
- navigator: {
- children: {
- device: {
- path: "cordova/plugin/tizen/Device"
- },
- contacts: {
- path: "cordova/plugin/tizen/contacts"
- },
- notification: {
- path: "cordova/plugin/tizen/Notification"
- }
- }
- },
- Contact: {
- path: "cordova/plugin/tizen/Contact"
- }
+ initialize: function() {
+
+ //console.log("TIZEN PLATFORM initialize start");
+
+ var modulemapper = require('cordova/modulemapper');
+
+ //modulemapper.loadMatchingModules(/cordova.*\/plugininit$/);
+
+ modulemapper.loadMatchingModules(/cordova.*\/symbols$/);
+
+ modulemapper.mapModules(window);
+
+ //console.log("TIZEN PLATFORM initialize end");
+
}
};
+//console.log("TIZEN PLATFORM START");
+
+
});
// file: lib/common/plugin/Acceleration.js
define("cordova/plugin/Acceleration", function(require, exports, module) {
+
var Acceleration = function(x, y, z, timestamp) {
this.x = x;
this.y = y;
@@ -1006,8 +1083,11 @@
// file: lib/common/plugin/Camera.js
define("cordova/plugin/Camera", function(require, exports, module) {
-var exec = require('cordova/exec'),
- Camera = require('cordova/plugin/CameraConstants');
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
+ Camera = require('cordova/plugin/CameraConstants'),
+ CameraPopoverHandle = require('cordova/plugin/CameraPopoverHandle');
var cameraExport = {};
@@ -1027,94 +1107,28 @@
* @param {Object} options
*/
cameraExport.getPicture = function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback != "function") {
- console.log("Camera Error: successCallback is not a function");
- return;
- }
+ argscheck.checkArgs('fFO', 'Camera.getPicture', arguments);
+ options = options || {};
+ var getValue = argscheck.getValue;
- // errorCallback optional
- if (errorCallback && (typeof errorCallback != "function")) {
- console.log("Camera Error: errorCallback is not a function");
- return;
- }
-
- var quality = 50;
- if (options && typeof options.quality == "number") {
- quality = options.quality;
- } else if (options && typeof options.quality == "string") {
- var qlity = parseInt(options.quality, 10);
- if (isNaN(qlity) === false) {
- quality = qlity.valueOf();
- }
- }
-
- var destinationType = Camera.DestinationType.FILE_URI;
- if (typeof options.destinationType == "number") {
- destinationType = options.destinationType;
- }
-
- var sourceType = Camera.PictureSourceType.CAMERA;
- if (typeof options.sourceType == "number") {
- sourceType = options.sourceType;
- }
-
- var targetWidth = -1;
- if (typeof options.targetWidth == "number") {
- targetWidth = options.targetWidth;
- } else if (typeof options.targetWidth == "string") {
- var width = parseInt(options.targetWidth, 10);
- if (isNaN(width) === false) {
- targetWidth = width.valueOf();
- }
- }
-
- var targetHeight = -1;
- if (typeof options.targetHeight == "number") {
- targetHeight = options.targetHeight;
- } else if (typeof options.targetHeight == "string") {
- var height = parseInt(options.targetHeight, 10);
- if (isNaN(height) === false) {
- targetHeight = height.valueOf();
- }
- }
-
- var encodingType = Camera.EncodingType.JPEG;
- if (typeof options.encodingType == "number") {
- encodingType = options.encodingType;
- }
-
- var mediaType = Camera.MediaType.PICTURE;
- if (typeof options.mediaType == "number") {
- mediaType = options.mediaType;
- }
- var allowEdit = false;
- if (typeof options.allowEdit == "boolean") {
- allowEdit = options.allowEdit;
- } else if (typeof options.allowEdit == "number") {
- allowEdit = options.allowEdit <= 0 ? false : true;
- }
- var correctOrientation = false;
- if (typeof options.correctOrientation == "boolean") {
- correctOrientation = options.correctOrientation;
- } else if (typeof options.correctOrientation == "number") {
- correctOrientation = options.correctOrientation <=0 ? false : true;
- }
- var saveToPhotoAlbum = false;
- if (typeof options.saveToPhotoAlbum == "boolean") {
- saveToPhotoAlbum = options.saveToPhotoAlbum;
- } else if (typeof options.saveToPhotoAlbum == "number") {
- saveToPhotoAlbum = options.saveToPhotoAlbum <=0 ? false : true;
- }
- var popoverOptions = null;
- if (typeof options.popoverOptions == "object") {
- popoverOptions = options.popoverOptions;
- }
+ var quality = getValue(options.quality, 50);
+ var destinationType = getValue(options.destinationType, Camera.DestinationType.FILE_URI);
+ var sourceType = getValue(options.sourceType, Camera.PictureSourceType.CAMERA);
+ var targetWidth = getValue(options.targetWidth, -1);
+ var targetHeight = getValue(options.targetHeight, -1);
+ var encodingType = getValue(options.encodingType, Camera.EncodingType.JPEG);
+ var mediaType = getValue(options.mediaType, Camera.MediaType.PICTURE);
+ var allowEdit = !!options.allowEdit;
+ 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();
};
cameraExport.cleanup = function(successCallback, errorCallback) {
@@ -1122,14 +1136,17 @@
};
module.exports = cameraExport;
+
});
// file: lib/common/plugin/CameraConstants.js
define("cordova/plugin/CameraConstants", function(require, exports, module) {
+
module.exports = {
DestinationType:{
DATA_URL: 0, // Return base64 encoded string
- FILE_URI: 1 // Return file uri (content://media/external/images/media/2 for Android)
+ FILE_URI: 1, // Return file uri (content://media/external/images/media/2 for Android)
+ NATIVE_URI: 2 // Return native uri (eg. asset-library://... for iOS)
},
EncodingType:{
JPEG: 0, // Return JPEG encoded image
@@ -1151,12 +1168,36 @@
ARROW_LEFT : 4,
ARROW_RIGHT : 8,
ARROW_ANY : 15
+ },
+ Direction:{
+ BACK: 0,
+ FRONT: 1
}
};
+
+});
+
+// file: lib/common/plugin/CameraPopoverHandle.js
+define("cordova/plugin/CameraPopoverHandle", function(require, exports, module) {
+
+var exec = require('cordova/exec');
+
+/**
+ * A handle to an image picker popover.
+ */
+var CameraPopoverHandle = function() {
+ this.setPosition = function(popoverOptions) {
+ console.log('CameraPopoverHandle.setPosition is only supported on iOS.');
+ };
+};
+
+module.exports = CameraPopoverHandle;
+
});
// file: lib/common/plugin/CameraPopoverOptions.js
define("cordova/plugin/CameraPopoverOptions", function(require, exports, module) {
+
var Camera = require('cordova/plugin/CameraConstants');
/**
@@ -1173,10 +1214,12 @@
};
module.exports = CameraPopoverOptions;
+
});
// file: lib/common/plugin/CaptureAudioOptions.js
define("cordova/plugin/CaptureAudioOptions", function(require, exports, module) {
+
/**
* Encapsulates all audio capture operation configuration options.
*/
@@ -1185,15 +1228,15 @@
this.limit = 1;
// Maximum duration of a single sound clip in seconds.
this.duration = 0;
- // The selected audio mode. Must match with one of the elements in supportedAudioModes array.
- this.mode = null;
};
module.exports = CaptureAudioOptions;
+
});
// file: lib/common/plugin/CaptureError.js
define("cordova/plugin/CaptureError", function(require, exports, module) {
+
/**
* The CaptureError interface encapsulates all errors in the Capture API.
*/
@@ -1213,25 +1256,27 @@
CaptureError.CAPTURE_NOT_SUPPORTED = 20;
module.exports = CaptureError;
+
});
// file: lib/common/plugin/CaptureImageOptions.js
define("cordova/plugin/CaptureImageOptions", function(require, exports, module) {
+
/**
* Encapsulates all image capture operation configuration options.
*/
var CaptureImageOptions = function(){
// Upper limit of images user can take. Value must be equal or greater than 1.
this.limit = 1;
- // The selected image mode. Must match with one of the elements in supportedImageModes array.
- this.mode = null;
};
module.exports = CaptureImageOptions;
+
});
// file: lib/common/plugin/CaptureVideoOptions.js
define("cordova/plugin/CaptureVideoOptions", function(require, exports, module) {
+
/**
* Encapsulates all video capture operation configuration options.
*/
@@ -1240,18 +1285,18 @@
this.limit = 1;
// Maximum duration of a single video clip in seconds.
this.duration = 0;
- // The selected video mode. Must match with one of the elements in supportedVideoModes array.
- this.mode = null;
};
module.exports = CaptureVideoOptions;
+
});
// file: lib/common/plugin/CompassError.js
define("cordova/plugin/CompassError", function(require, exports, module) {
+
/**
* CompassError.
- * An error code assigned by an implementation when an error has occured
+ * An error code assigned by an implementation when an error has occurred
* @constructor
*/
var CompassError = function(err) {
@@ -1262,22 +1307,26 @@
CompassError.COMPASS_NOT_SUPPORTED = 20;
module.exports = CompassError;
+
});
// file: lib/common/plugin/CompassHeading.js
define("cordova/plugin/CompassHeading", function(require, exports, module) {
+
var CompassHeading = function(magneticHeading, trueHeading, headingAccuracy, timestamp) {
- this.magneticHeading = (magneticHeading !== undefined ? magneticHeading : null);
- this.trueHeading = (trueHeading !== undefined ? trueHeading : null);
- this.headingAccuracy = (headingAccuracy !== undefined ? headingAccuracy : null);
- this.timestamp = (timestamp !== undefined ? timestamp : new Date().getTime());
+ this.magneticHeading = magneticHeading;
+ this.trueHeading = trueHeading;
+ this.headingAccuracy = headingAccuracy;
+ this.timestamp = timestamp || new Date().getTime();
};
module.exports = CompassHeading;
+
});
// file: lib/common/plugin/ConfigurationData.js
define("cordova/plugin/ConfigurationData", function(require, exports, module) {
+
/**
* Encapsulates a set of parameters that the capture device supports.
*/
@@ -1293,10 +1342,12 @@
}
module.exports = ConfigurationData;
+
});
// file: lib/common/plugin/Connection.js
define("cordova/plugin/Connection", function(require, exports, module) {
+
/**
* Network status
*/
@@ -1307,13 +1358,17 @@
CELL_2G: "2g",
CELL_3G: "3g",
CELL_4G: "4g",
+ CELL:"cellular",
NONE: "none"
};
+
});
// file: lib/common/plugin/Contact.js
define("cordova/plugin/Contact", function(require, exports, module) {
-var exec = require('cordova/exec'),
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils');
@@ -1398,7 +1453,8 @@
* @param errorCB error callback
*/
Contact.prototype.remove = function(successCB, errorCB) {
- var fail = function(code) {
+ argscheck.checkArgs('FF', 'Contact.remove', arguments);
+ var fail = errorCB && function(code) {
errorCB(new ContactError(code));
};
if (this.id === null) {
@@ -1416,50 +1472,26 @@
*/
Contact.prototype.clone = function() {
var clonedContact = utils.clone(this);
- var i;
clonedContact.id = null;
clonedContact.rawId = null;
+
+ function nullIds(arr) {
+ if (arr) {
+ for (var i = 0; i < arr.length; ++i) {
+ arr[i].id = null;
+ }
+ }
+ }
+
// Loop through and clear out any id's in phones, emails, etc.
- if (clonedContact.phoneNumbers) {
- for (i = 0; i < clonedContact.phoneNumbers.length; i++) {
- clonedContact.phoneNumbers[i].id = null;
- }
- }
- if (clonedContact.emails) {
- for (i = 0; i < clonedContact.emails.length; i++) {
- clonedContact.emails[i].id = null;
- }
- }
- if (clonedContact.addresses) {
- for (i = 0; i < clonedContact.addresses.length; i++) {
- clonedContact.addresses[i].id = null;
- }
- }
- if (clonedContact.ims) {
- for (i = 0; i < clonedContact.ims.length; i++) {
- clonedContact.ims[i].id = null;
- }
- }
- if (clonedContact.organizations) {
- for (i = 0; i < clonedContact.organizations.length; i++) {
- clonedContact.organizations[i].id = null;
- }
- }
- if (clonedContact.categories) {
- for (i = 0; i < clonedContact.categories.length; i++) {
- clonedContact.categories[i].id = null;
- }
- }
- if (clonedContact.photos) {
- for (i = 0; i < clonedContact.photos.length; i++) {
- clonedContact.photos[i].id = null;
- }
- }
- if (clonedContact.urls) {
- for (i = 0; i < clonedContact.urls.length; i++) {
- clonedContact.urls[i].id = null;
- }
- }
+ nullIds(clonedContact.phoneNumbers);
+ nullIds(clonedContact.emails);
+ nullIds(clonedContact.addresses);
+ nullIds(clonedContact.ims);
+ nullIds(clonedContact.organizations);
+ nullIds(clonedContact.categories);
+ nullIds(clonedContact.photos);
+ nullIds(clonedContact.urls);
return clonedContact;
};
@@ -1469,21 +1501,22 @@
* @param errorCB error callback
*/
Contact.prototype.save = function(successCB, errorCB) {
- var fail = function(code) {
- errorCB(new ContactError(code));
- };
+ argscheck.checkArgs('FFO', 'Contact.save', arguments);
+ var fail = errorCB && function(code) {
+ errorCB(new ContactError(code));
+ };
var success = function(result) {
- if (result) {
- if (typeof successCB === 'function') {
- var fullContact = require('cordova/plugin/contacts').create(result);
- successCB(convertIn(fullContact));
- }
- }
- else {
- // no Entry object returned
- fail(ContactError.UNKNOWN_ERROR);
- }
- };
+ if (result) {
+ if (successCB) {
+ var fullContact = require('cordova/plugin/contacts').create(result);
+ successCB(convertIn(fullContact));
+ }
+ }
+ else {
+ // no Entry object returned
+ fail(ContactError.UNKNOWN_ERROR);
+ }
+ };
var dupContact = convertOut(utils.clone(this));
exec(success, fail, "Contacts", "save", [dupContact]);
};
@@ -1495,6 +1528,7 @@
// file: lib/common/plugin/ContactAddress.js
define("cordova/plugin/ContactAddress", function(require, exports, module) {
+
/**
* Contact address.
* @constructor
@@ -1520,13 +1554,15 @@
};
module.exports = ContactAddress;
+
});
// file: lib/common/plugin/ContactError.js
define("cordova/plugin/ContactError", function(require, exports, module) {
+
/**
* ContactError.
- * An error code assigned by an implementation when an error has occured
+ * An error code assigned by an implementation when an error has occurred
* @constructor
*/
var ContactError = function(err) {
@@ -1545,10 +1581,12 @@
ContactError.PERMISSION_DENIED_ERROR = 20;
module.exports = ContactError;
+
});
// file: lib/common/plugin/ContactField.js
define("cordova/plugin/ContactField", function(require, exports, module) {
+
/**
* Generic contact field.
* @constructor
@@ -1565,10 +1603,12 @@
};
module.exports = ContactField;
+
});
// file: lib/common/plugin/ContactFindOptions.js
define("cordova/plugin/ContactFindOptions", function(require, exports, module) {
+
/**
* ContactFindOptions.
* @constructor
@@ -1582,10 +1622,12 @@
};
module.exports = ContactFindOptions;
+
});
// file: lib/common/plugin/ContactName.js
define("cordova/plugin/ContactName", function(require, exports, module) {
+
/**
* Contact name.
* @constructor
@@ -1606,10 +1648,12 @@
};
module.exports = ContactName;
+
});
// file: lib/common/plugin/ContactOrganization.js
define("cordova/plugin/ContactOrganization", function(require, exports, module) {
+
/**
* Contact organization.
* @constructor
@@ -1633,10 +1677,12 @@
};
module.exports = ContactOrganization;
+
});
// file: lib/common/plugin/Coordinates.js
define("cordova/plugin/Coordinates", function(require, exports, module) {
+
/**
* This class contains position information.
* @param {Object} lat
@@ -1690,7 +1736,9 @@
// file: lib/common/plugin/DirectoryEntry.js
define("cordova/plugin/DirectoryEntry", function(require, exports, module) {
-var utils = require('cordova/utils'),
+
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
exec = require('cordova/exec'),
Entry = require('cordova/plugin/Entry'),
FileError = require('cordova/plugin/FileError'),
@@ -1706,7 +1754,7 @@
* TODO: implement this!!! {FileSystem} filesystem on which the directory resides (readonly)
*/
var DirectoryEntry = function(name, fullPath) {
- DirectoryEntry.__super__.constructor.apply(this, [false, true, name, fullPath]);
+ DirectoryEntry.__super__.constructor.call(this, false, true, name, fullPath);
};
utils.extend(DirectoryEntry, Entry);
@@ -1722,16 +1770,17 @@
* Creates or looks up a directory
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a directory
- * @param {Flags} options to create or excluively create the directory
+ * @param {Flags} options to create or exclusively create the directory
* @param {Function} successCallback is called with the new entry
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getDirectory = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getDirectory', arguments);
+ var win = successCallback && function(result) {
var entry = new DirectoryEntry(result.name, result.fullPath);
successCallback(entry);
};
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(win, fail, "File", "getDirectory", [this.fullPath, path, options]);
@@ -1744,7 +1793,8 @@
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.removeRecursively = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ argscheck.checkArgs('FF', 'DirectoryEntry.removeRecursively', arguments);
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(successCallback, fail, "File", "removeRecursively", [this.fullPath]);
@@ -1754,17 +1804,18 @@
* Creates or looks up a file
*
* @param {DOMString} path either a relative or absolute path from this directory in which to look up or create a file
- * @param {Flags} options to create or excluively create the file
+ * @param {Flags} options to create or exclusively create the file
* @param {Function} successCallback is called with the new entry
* @param {Function} errorCallback is called with a FileError
*/
DirectoryEntry.prototype.getFile = function(path, options, successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
+ argscheck.checkArgs('sOFF', 'DirectoryEntry.getFile', arguments);
+ var win = successCallback && function(result) {
var FileEntry = require('cordova/plugin/FileEntry');
var entry = new FileEntry(result.name, result.fullPath);
successCallback(entry);
};
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(win, fail, "File", "getFile", [this.fullPath, path, options]);
@@ -1776,6 +1827,7 @@
// file: lib/common/plugin/DirectoryReader.js
define("cordova/plugin/DirectoryReader", function(require, exports, module) {
+
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError') ;
@@ -1784,6 +1836,7 @@
*/
function DirectoryReader(path) {
this.path = path || null;
+ this.hasReadEntries = false;
}
/**
@@ -1793,6 +1846,12 @@
* @param {Function} errorCallback is called with a FileError
*/
DirectoryReader.prototype.readEntries = function(successCallback, errorCallback) {
+ // If we've already read and passed on this directory's entries, return an empty list.
+ if (this.hasReadEntries) {
+ successCallback([]);
+ return;
+ }
+ var reader = this;
var win = typeof successCallback !== 'function' ? null : function(result) {
var retVal = [];
for (var i=0; i<result.length; i++) {
@@ -1809,6 +1868,7 @@
entry.fullPath = result[i].fullPath;
retVal.push(entry);
}
+ reader.hasReadEntries = true;
successCallback(retVal);
};
var fail = typeof errorCallback !== 'function' ? null : function(code) {
@@ -1823,7 +1883,9 @@
// file: lib/common/plugin/Entry.js
define("cordova/plugin/Entry", function(require, exports, module) {
-var exec = require('cordova/exec'),
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
Metadata = require('cordova/plugin/Metadata');
@@ -1842,8 +1904,8 @@
* (readonly)
*/
function Entry(isFile, isDirectory, name, fullPath, fileSystem) {
- this.isFile = (typeof isFile != 'undefined'?isFile:false);
- this.isDirectory = (typeof isDirectory != 'undefined'?isDirectory:false);
+ this.isFile = !!isFile;
+ this.isDirectory = !!isDirectory;
this.name = name || '';
this.fullPath = fullPath || '';
this.filesystem = fileSystem || null;
@@ -1858,15 +1920,16 @@
* {Function} is called with a FileError
*/
Entry.prototype.getMetadata = function(successCallback, errorCallback) {
- var success = typeof successCallback !== 'function' ? null : function(lastModified) {
- var metadata = new Metadata(lastModified);
- successCallback(metadata);
- };
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
- errorCallback(new FileError(code));
- };
+ argscheck.checkArgs('FF', 'Entry.getMetadata', arguments);
+ var success = successCallback && function(lastModified) {
+ var metadata = new Metadata(lastModified);
+ successCallback(metadata);
+ };
+ var fail = errorCallback && function(code) {
+ errorCallback(new FileError(code));
+ };
- exec(success, fail, "File", "getMetadata", [this.fullPath]);
+ exec(success, fail, "File", "getMetadata", [this.fullPath]);
};
/**
@@ -1880,8 +1943,8 @@
* {Object} keys and values to set
*/
Entry.prototype.setMetadata = function(successCallback, errorCallback, metadataObject) {
-
- exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
+ argscheck.checkArgs('FFO', 'Entry.setMetadata', arguments);
+ exec(successCallback, errorCallback, "File", "setMetadata", [this.fullPath, metadataObject]);
};
/**
@@ -1897,36 +1960,25 @@
* {Function} called with a FileError
*/
Entry.prototype.moveTo = function(parent, newName, successCallback, errorCallback) {
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
+ argscheck.checkArgs('oSFF', 'Entry.moveTo', arguments);
+ var fail = errorCallback && function(code) {
+ errorCallback(new FileError(code));
};
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
// source path
var srcPath = this.fullPath,
// entry name
name = newName || this.name,
success = function(entry) {
if (entry) {
- if (typeof successCallback === 'function') {
+ if (successCallback) {
// create appropriate Entry object
var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
+ successCallback(result);
}
}
else {
// no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
+ fail && fail(FileError.NOT_FOUND_ERR);
}
};
@@ -1947,18 +1999,11 @@
* {Function} called with a FileError
*/
Entry.prototype.copyTo = function(parent, newName, successCallback, errorCallback) {
- var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
+ argscheck.checkArgs('oSFF', 'Entry.copyTo', arguments);
+ var fail = errorCallback && function(code) {
+ errorCallback(new FileError(code));
};
- // user must specify parent Entry
- if (!parent) {
- fail(FileError.NOT_FOUND_ERR);
- return;
- }
-
// source path
var srcPath = this.fullPath,
// entry name
@@ -1966,20 +2011,15 @@
// success callback
success = function(entry) {
if (entry) {
- if (typeof successCallback === 'function') {
+ if (successCallback) {
// create appropriate Entry object
var result = (entry.isDirectory) ? new (require('cordova/plugin/DirectoryEntry'))(entry.name, entry.fullPath) : new (require('cordova/plugin/FileEntry'))(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
+ successCallback(result);
}
}
else {
// no Entry object returned
- fail(FileError.NOT_FOUND_ERR);
+ fail && fail(FileError.NOT_FOUND_ERR);
}
};
@@ -2016,7 +2056,8 @@
* @param errorCallback {Function} called with a FileError
*/
Entry.prototype.remove = function(successCallback, errorCallback) {
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ argscheck.checkArgs('FF', 'Entry.remove', arguments);
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(successCallback, fail, "File", "remove", [this.fullPath]);
@@ -2029,22 +2070,25 @@
* @param errorCallback {Function} called with a FileError
*/
Entry.prototype.getParent = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(result) {
+ argscheck.checkArgs('FF', 'Entry.getParent', arguments);
+ var win = successCallback && function(result) {
var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
var entry = new DirectoryEntry(result.name, result.fullPath);
successCallback(entry);
};
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(win, fail, "File", "getParent", [this.fullPath]);
};
module.exports = Entry;
+
});
// file: lib/common/plugin/File.js
define("cordova/plugin/File", function(require, exports, module) {
+
/**
* Constructor.
* name {DOMString} name of the file, without path information
@@ -2060,13 +2104,53 @@
this.type = type || null;
this.lastModifiedDate = lastModifiedDate || null;
this.size = size || 0;
+
+ // These store the absolute start and end for slicing the file.
+ this.start = 0;
+ this.end = this.size;
};
+/**
+ * Returns a "slice" of the file. Since Cordova Files don't contain the actual
+ * content, this really returns a File with adjusted start and end.
+ * Slices of slices are supported.
+ * start {Number} The index at which to start the slice (inclusive).
+ * end {Number} The index at which to end the slice (exclusive).
+ */
+File.prototype.slice = function(start, end) {
+ var size = this.end - this.start;
+ var newStart = 0;
+ var newEnd = size;
+ if (arguments.length) {
+ if (start < 0) {
+ newStart = Math.max(size + start, 0);
+ } else {
+ newStart = Math.min(size, start);
+ }
+ }
+
+ if (arguments.length >= 2) {
+ if (end < 0) {
+ newEnd = Math.max(size + end, 0);
+ } else {
+ newEnd = Math.min(end, size);
+ }
+ }
+
+ var newFile = new File(this.name, this.fullPath, this.type, this.lastModifiedData, this.size);
+ newFile.start = this.start + newStart;
+ newFile.end = this.start + newEnd;
+ return newFile;
+};
+
+
module.exports = File;
+
});
// file: lib/common/plugin/FileEntry.js
define("cordova/plugin/FileEntry", function(require, exports, module) {
+
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
Entry = require('cordova/plugin/Entry'),
@@ -2100,13 +2184,9 @@
var writer = new FileWriter(filePointer);
if (writer.fileName === null || writer.fileName === "") {
- if (typeof errorCallback === "function") {
- errorCallback(new FileError(FileError.INVALID_STATE_ERR));
- }
+ errorCallback && errorCallback(new FileError(FileError.INVALID_STATE_ERR));
} else {
- if (typeof successCallback === "function") {
- successCallback(writer);
- }
+ successCallback && successCallback(writer);
}
}, errorCallback);
};
@@ -2118,11 +2198,11 @@
* @param {Function} errorCallback is called with a FileError
*/
FileEntry.prototype.file = function(successCallback, errorCallback) {
- var win = typeof successCallback !== 'function' ? null : function(f) {
+ var win = successCallback && function(f) {
var file = new File(f.name, f.fullPath, f.type, f.lastModifiedDate, f.size);
successCallback(file);
};
- var fail = typeof errorCallback !== 'function' ? null : function(code) {
+ var fail = errorCallback && function(code) {
errorCallback(new FileError(code));
};
exec(win, fail, "File", "getFileMetadata", [this.fullPath]);
@@ -2130,10 +2210,12 @@
module.exports = FileEntry;
+
});
// file: lib/common/plugin/FileError.js
define("cordova/plugin/FileError", function(require, exports, module) {
+
/**
* FileError
*/
@@ -2159,13 +2241,19 @@
FileError.PATH_EXISTS_ERR = 12;
module.exports = FileError;
+
});
// file: lib/common/plugin/FileReader.js
define("cordova/plugin/FileReader", function(require, exports, module) {
+
var exec = require('cordova/exec'),
+ modulemapper = require('cordova/modulemapper'),
+ utils = require('cordova/utils'),
+ File = require('cordova/plugin/File'),
FileError = require('cordova/plugin/FileError'),
- ProgressEvent = require('cordova/plugin/ProgressEvent');
+ ProgressEvent = require('cordova/plugin/ProgressEvent'),
+ origFileReader = modulemapper.getOriginalSymbol(this, 'FileReader');
/**
* This class reads the mobile device file system.
@@ -2176,23 +2264,11 @@
* @constructor
*/
var FileReader = function() {
- this.fileName = "";
-
- this.readyState = 0; // FileReader.EMPTY
-
- // File data
- this.result = null;
-
- // Error
- this.error = null;
-
- // Event handlers
- this.onloadstart = null; // When the read starts.
- this.onprogress = null; // While reading (and decoding) file or fileBlob data, and reporting partial file data (progess.loaded/progress.total)
- this.onload = null; // When the read has successfully completed.
- this.onerror = null; // When the read has failed (see errors).
- this.onloadend = null; // When the request has completed (either in success or failure).
- this.onabort = null; // When the read has been aborted. For instance, by invoking the abort() method.
+ this._readyState = 0;
+ this._error = null;
+ this._result = null;
+ this._fileName = '';
+ this._realReader = origFileReader ? new origFileReader() : {};
};
// States
@@ -2200,17 +2276,66 @@
FileReader.LOADING = 1;
FileReader.DONE = 2;
+utils.defineGetter(FileReader.prototype, 'readyState', function() {
+ return this._fileName ? this._readyState : this._realReader.readyState;
+});
+
+utils.defineGetter(FileReader.prototype, 'error', function() {
+ return this._fileName ? this._error: this._realReader.error;
+});
+
+utils.defineGetter(FileReader.prototype, 'result', function() {
+ return this._fileName ? this._result: this._realReader.result;
+});
+
+function defineEvent(eventName) {
+ utils.defineGetterSetter(FileReader.prototype, eventName, function() {
+ return this._realReader[eventName] || null;
+ }, function(value) {
+ this._realReader[eventName] = value;
+ });
+}
+defineEvent('onloadstart'); // When the read starts.
+defineEvent('onprogress'); // While reading (and decoding) file or fileBlob data, and reporting partial file data (progress.loaded/progress.total)
+defineEvent('onload'); // When the read has successfully completed.
+defineEvent('onerror'); // When the read has failed (see errors).
+defineEvent('onloadend'); // When the request has completed (either in success or failure).
+defineEvent('onabort'); // When the read has been aborted. For instance, by invoking the abort() method.
+
+function initRead(reader, file) {
+ // Already loading something
+ if (reader.readyState == FileReader.LOADING) {
+ throw new FileError(FileError.INVALID_STATE_ERR);
+ }
+
+ reader._result = null;
+ reader._error = null;
+ reader._readyState = FileReader.LOADING;
+
+ if (typeof file.fullPath == 'string') {
+ reader._fileName = file.fullPath;
+ } else {
+ reader._fileName = '';
+ return true;
+ }
+
+ reader.onloadstart && reader.onloadstart(new ProgressEvent("loadstart", {target:reader}));
+}
+
/**
* Abort reading file.
*/
FileReader.prototype.abort = function() {
- this.result = null;
+ if (origFileReader && !this._fileName) {
+ return this._realReader.abort();
+ }
+ this._result = null;
- if (this.readyState == FileReader.DONE || this.readyState == FileReader.EMPTY) {
+ if (this._readyState == FileReader.DONE || this._readyState == FileReader.EMPTY) {
return;
}
- this.readyState = FileReader.DONE;
+ this._readyState = FileReader.DONE;
// If abort callback
if (typeof this.onabort === 'function') {
@@ -2229,43 +2354,26 @@
* @param encoding [Optional] (see http://www.iana.org/assignments/character-sets)
*/
FileReader.prototype.readAsText = function(file, encoding) {
- // Figure out pathing
- this.fileName = '';
- if (typeof file.fullPath === 'undefined') {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
+ if (initRead(this, file)) {
+ return this._realReader.readAsText(file, encoding);
}
// Default encoding is UTF-8
var enc = encoding ? encoding : "UTF-8";
-
var me = this;
+ var execArgs = [this._fileName, enc, file.start, file.end];
// Read file
exec(
// Success callback
function(r) {
// If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
+ if (me._readyState === FileReader.DONE) {
return;
}
// Save result
- me.result = r;
+ me._result = r;
// If onload callback
if (typeof me.onload === "function") {
@@ -2273,7 +2381,7 @@
}
// DONE state
- me.readyState = FileReader.DONE;
+ me._readyState = FileReader.DONE;
// If onloadend callback
if (typeof me.onloadend === "function") {
@@ -2283,18 +2391,18 @@
// Error callback
function(e) {
// If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
+ if (me._readyState === FileReader.DONE) {
return;
}
// DONE state
- me.readyState = FileReader.DONE;
+ me._readyState = FileReader.DONE;
// null result
- me.result = null;
+ me._result = null;
// Save error
- me.error = new FileError(e);
+ me._error = new FileError(e);
// If onerror callback
if (typeof me.onerror === "function") {
@@ -2305,7 +2413,7 @@
if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
- }, "File", "readAsText", [this.fileName, enc]);
+ }, "File", "readAsText", execArgs);
};
@@ -2317,42 +2425,27 @@
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsDataURL = function(file) {
- this.fileName = "";
- if (typeof file.fullPath === "undefined") {
- this.fileName = file;
- } else {
- this.fileName = file.fullPath;
- }
-
- // Already loading something
- if (this.readyState == FileReader.LOADING) {
- throw new FileError(FileError.INVALID_STATE_ERR);
- }
-
- // LOADING state
- this.readyState = FileReader.LOADING;
-
- // If loadstart callback
- if (typeof this.onloadstart === "function") {
- this.onloadstart(new ProgressEvent("loadstart", {target:this}));
+ if (initRead(this, file)) {
+ return this._realReader.readAsDataURL(file);
}
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) {
+ if (me._readyState === FileReader.DONE) {
return;
}
// DONE state
- me.readyState = FileReader.DONE;
+ me._readyState = FileReader.DONE;
// Save result
- me.result = r;
+ me._result = r;
// If onload callback
if (typeof me.onload === "function") {
@@ -2367,17 +2460,17 @@
// Error callback
function(e) {
// If DONE (cancelled), then don't do anything
- if (me.readyState === FileReader.DONE) {
+ if (me._readyState === FileReader.DONE) {
return;
}
// DONE state
- me.readyState = FileReader.DONE;
+ me._readyState = FileReader.DONE;
- me.result = null;
+ me._result = null;
// Save error
- me.error = new FileError(e);
+ me._error = new FileError(e);
// If onerror callback
if (typeof me.onerror === "function") {
@@ -2388,7 +2481,7 @@
if (typeof me.onloadend === "function") {
me.onloadend(new ProgressEvent("loadend", {target:me}));
}
- }, "File", "readAsDataURL", [this.fileName]);
+ }, "File", "readAsDataURL", execArgs);
};
/**
@@ -2397,8 +2490,62 @@
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsBinaryString = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('method "readAsBinaryString" is not supported at this time.');
+ if (initRead(this, file)) {
+ return this._realReader.readAsBinaryString(file);
+ }
+
+ 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);
};
/**
@@ -2407,15 +2554,71 @@
* @param file {File} File object containing file properties
*/
FileReader.prototype.readAsArrayBuffer = function(file) {
- // TODO - Can't return binary data to browser.
- console.log('This method is not supported at this time.');
+ if (initRead(this, file)) {
+ return this._realReader.readAsArrayBuffer(file);
+ }
+
+ 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;
+
});
// file: lib/common/plugin/FileSystem.js
define("cordova/plugin/FileSystem", function(require, exports, module) {
+
var DirectoryEntry = require('cordova/plugin/DirectoryEntry');
/**
@@ -2438,14 +2641,62 @@
// file: lib/common/plugin/FileTransfer.js
define("cordova/plugin/FileTransfer", function(require, exports, module) {
-var exec = require('cordova/exec'),
- FileTransferError = require('cordova/plugin/FileTransferError');
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
+ FileTransferError = require('cordova/plugin/FileTransferError'),
+ ProgressEvent = require('cordova/plugin/ProgressEvent');
+
+function newProgressEvent(result) {
+ var pe = new ProgressEvent();
+ pe.lengthComputable = result.lengthComputable;
+ pe.loaded = result.loaded;
+ pe.total = result.total;
+ 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;
/**
* FileTransfer uploads a file to a remote server.
* @constructor
*/
-var FileTransfer = function() {};
+var FileTransfer = function() {
+ this._id = ++idCounter;
+ this.onprogress = null; // optional callback
+};
/**
* Given an absolute file path, uploads a file on the device to a remote server
@@ -2458,18 +2709,33 @@
* @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.");
+ argscheck.checkArgs('ssFFO*', 'FileTransfer.upload', arguments);
// check for options
var fileKey = null;
var fileName = null;
var mimeType = null;
var params = null;
var chunkedMode = true;
+ var headers = null;
+ var httpMethod = null;
+ var basicAuthHeader = getBasicAuthHeader(server);
+ if (basicAuthHeader) {
+ options = options || {};
+ options.headers = options.headers || {};
+ options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+ }
+
if (options) {
fileKey = options.fileKey;
fileName = options.fileName;
mimeType = options.mimeType;
+ headers = options.headers;
+ httpMethod = options.httpMethod || "POST";
+ if (httpMethod.toUpperCase() == "PUT"){
+ httpMethod = "PUT";
+ } else {
+ httpMethod = "POST";
+ }
if (options.chunkedMode !== null || typeof options.chunkedMode != "undefined") {
chunkedMode = options.chunkedMode;
}
@@ -2481,12 +2747,22 @@
}
}
- var fail = function(e) {
- var error = new FileTransferError(e.code, e.source, e.target, e.http_status);
+ var fail = errorCallback && function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
errorCallback(error);
};
- exec(successCallback, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode]);
+ var self = this;
+ var win = function(result) {
+ if (typeof result.lengthComputable != "undefined") {
+ if (self.onprogress) {
+ self.onprogress(newProgressEvent(result));
+ }
+ } else {
+ successCallback && successCallback(result);
+ }
+ };
+ exec(win, fail, 'FileTransfer', 'upload', [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod]);
};
/**
@@ -2495,31 +2771,60 @@
* @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
+ * @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) {
- // sanity parameter checking
- if (!source || !target) throw new Error("FileTransfer.download requires source URI and target URI parameters at the minimum.");
+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) {
+ options = options || {};
+ options.headers = options.headers || {};
+ options.headers[basicAuthHeader.name] = basicAuthHeader.value;
+ }
+
+ var headers = null;
+ if (options) {
+ headers = options.headers || null;
+ }
+
var win = function(result) {
- var entry = null;
- if (result.isDirectory) {
- entry = new (require('cordova/plugin/DirectoryEntry'))();
+ if (typeof result.lengthComputable != "undefined") {
+ if (self.onprogress) {
+ return self.onprogress(newProgressEvent(result));
+ }
+ } else if (successCallback) {
+ 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);
}
- 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);
+ var fail = errorCallback && function(e) {
+ var error = new FileTransferError(e.code, e.source, e.target, e.http_status, e.body);
errorCallback(error);
};
- exec(win, errorCallback, 'FileTransfer', 'download', [source, target]);
+ exec(win, fail, 'FileTransfer', 'download', [source, target, trustAllHosts, this._id, headers]);
+};
+
+/**
+ * Aborts the ongoing file transfer on this object. The original error
+ * callback for the file transfer will be called if necessary.
+ */
+FileTransfer.prototype.abort = function() {
+ exec(null, null, 'FileTransfer', 'abort', [this._id]);
};
module.exports = FileTransfer;
@@ -2528,20 +2833,23 @@
// file: lib/common/plugin/FileTransferError.js
define("cordova/plugin/FileTransferError", function(require, exports, module) {
+
/**
* FileTransferError
* @constructor
*/
-var FileTransferError = function(code, source, target, status) {
+var FileTransferError = function(code, source, target, status, body) {
this.code = code || null;
this.source = source || null;
this.target = target || null;
this.http_status = status || null;
+ this.body = body || null;
};
FileTransferError.FILE_NOT_FOUND_ERR = 1;
FileTransferError.INVALID_URL_ERR = 2;
FileTransferError.CONNECTION_ERR = 3;
+FileTransferError.ABORT_ERR = 4;
module.exports = FileTransferError;
@@ -2549,6 +2857,7 @@
// file: lib/common/plugin/FileUploadOptions.js
define("cordova/plugin/FileUploadOptions", function(require, exports, module) {
+
/**
* Options to customize the HTTP request used to upload files.
* @constructor
@@ -2556,19 +2865,25 @@
* @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, httpMethod) {
this.fileKey = fileKey || null;
this.fileName = fileName || null;
this.mimeType = mimeType || null;
this.params = params || null;
+ this.headers = headers || null;
+ this.httpMethod = httpMethod || null;
};
module.exports = FileUploadOptions;
+
});
// file: lib/common/plugin/FileUploadResult.js
define("cordova/plugin/FileUploadResult", function(require, exports, module) {
+
/**
* FileUploadResult
* @constructor
@@ -2580,10 +2895,12 @@
};
module.exports = FileUploadResult;
+
});
// file: lib/common/plugin/FileWriter.js
define("cordova/plugin/FileWriter", function(require, exports, module) {
+
var exec = require('cordova/exec'),
FileError = require('cordova/plugin/FileError'),
ProgressEvent = require('cordova/plugin/ProgressEvent');
@@ -2658,9 +2975,32 @@
/**
* Writes data to the file
*
- * @param text to be written
+ * @param data text or blob to be written
*/
-FileWriter.prototype.write = function(text) {
+FileWriter.prototype.write = function(data) {
+
+ var that=this;
+ var supportsBinary = (typeof window.Blob !== 'undefined' && typeof window.ArrayBuffer !== 'undefined');
+ var isBinary;
+
+ // Check to see if the incoming data is a blob
+ if (data instanceof File || (supportsBinary && data instanceof Blob)) {
+ var fileReader = new FileReader();
+ fileReader.onload = function() {
+ // Call this method again, with the arraybuffer as argument
+ FileWriter.prototype.write.call(that, this.result);
+ };
+ if (supportsBinary) {
+ fileReader.readAsArrayBuffer(data);
+ } else {
+ fileReader.readAsText(data);
+ }
+ return;
+ }
+
+ // Mark data type for safer transport over the binary bridge
+ isBinary = supportsBinary && (data instanceof ArrayBuffer);
+
// Throw an exception if we are already writing a file
if (this.readyState === FileWriter.WRITING) {
throw new FileError(FileError.INVALID_STATE_ERR);
@@ -2726,7 +3066,7 @@
if (typeof me.onwriteend === "function") {
me.onwriteend(new ProgressEvent("writeend", {"target":me}));
}
- }, "File", "write", [this.fileName, text, this.position]);
+ }, "File", "write", [this.fileName, data, this.position, isBinary]);
};
/**
@@ -2752,7 +3092,7 @@
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;
@@ -2842,6 +3182,7 @@
// file: lib/common/plugin/Flags.js
define("cordova/plugin/Flags", function(require, exports, module) {
+
/**
* Supplies arguments to methods that lookup or create files and directories.
*
@@ -2857,10 +3198,117 @@
}
module.exports = Flags;
+
+});
+
+// file: lib/common/plugin/GlobalizationError.js
+define("cordova/plugin/GlobalizationError", function(require, exports, module) {
+
+
+/**
+ * Globalization error object
+ *
+ * @constructor
+ * @param code
+ * @param message
+ */
+var GlobalizationError = function(code, message) {
+ this.code = code || null;
+ this.message = message || '';
+};
+
+// Globalization error codes
+GlobalizationError.UNKNOWN_ERROR = 0;
+GlobalizationError.FORMATTING_ERROR = 1;
+GlobalizationError.PARSING_ERROR = 2;
+GlobalizationError.PATTERN_ERROR = 3;
+
+module.exports = GlobalizationError;
+
+});
+
+// file: lib/common/plugin/InAppBrowser.js
+define("cordova/plugin/InAppBrowser", function(require, exports, module) {
+
+var exec = require('cordova/exec');
+var channel = require('cordova/channel');
+var modulemapper = require('cordova/modulemapper');
+
+function InAppBrowser() {
+ this.channels = {
+ 'loadstart': channel.create('loadstart'),
+ 'loadstop' : channel.create('loadstop'),
+ 'loaderror' : channel.create('loaderror'),
+ 'exit' : channel.create('exit')
+ };
+}
+
+InAppBrowser.prototype = {
+ _eventHandler: function (event) {
+ if (event.type in this.channels) {
+ this.channels[event.type].fire(event);
+ }
+ },
+ close: function (eventname) {
+ exec(null, null, "InAppBrowser", "close", []);
+ },
+ show: function (eventname) {
+ exec(null, null, "InAppBrowser", "show", []);
+ },
+ addEventListener: function (eventname,f) {
+ if (eventname in this.channels) {
+ this.channels[eventname].subscribe(f);
+ }
+ },
+ removeEventListener: function(eventname, f) {
+ if (eventname in this.channels) {
+ this.channels[eventname].unsubscribe(f);
+ }
+ },
+
+ executeScript: function(injectDetails, cb) {
+ if (injectDetails.code) {
+ exec(cb, null, "InAppBrowser", "injectScriptCode", [injectDetails.code, !!cb]);
+ } else if (injectDetails.file) {
+ exec(cb, null, "InAppBrowser", "injectScriptFile", [injectDetails.file, !!cb]);
+ } else {
+ throw new Error('executeScript requires exactly one of code or file to be specified');
+ }
+ },
+
+ insertCSS: function(injectDetails, cb) {
+ if (injectDetails.code) {
+ exec(cb, null, "InAppBrowser", "injectStyleCode", [injectDetails.code, !!cb]);
+ } else if (injectDetails.file) {
+ exec(cb, null, "InAppBrowser", "injectStyleFile", [injectDetails.file, !!cb]);
+ } else {
+ throw new Error('insertCSS requires exactly one of code or file to be specified');
+ }
+ }
+};
+
+module.exports = function(strUrl, strWindowName, strWindowFeatures) {
+ var iab = new InAppBrowser();
+ var cb = function(eventname) {
+ iab._eventHandler(eventname);
+ };
+
+ // Don't catch calls that write to existing frames (e.g. named iframes).
+ if (window.frames && window.frames[strWindowName]) {
+ var origOpenFunc = modulemapper.getOriginalSymbol(window, 'open');
+ return origOpenFunc.apply(window, arguments);
+ }
+
+ exec(cb, cb, "InAppBrowser", "open", [strUrl, strWindowName, strWindowFeatures]);
+ return iab;
+};
+
+
});
// file: lib/common/plugin/LocalFileSystem.js
define("cordova/plugin/LocalFileSystem", function(require, exports, module) {
+
var exec = require('cordova/exec');
/**
@@ -2874,11 +3322,14 @@
LocalFileSystem.PERSISTENT = 1; //persistent
module.exports = LocalFileSystem;
+
});
// file: lib/common/plugin/Media.js
define("cordova/plugin/Media", function(require, exports, module) {
-var utils = require('cordova/utils'),
+
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
exec = require('cordova/exec');
var mediaObjects = {};
@@ -2896,25 +3347,7 @@
* statusCallback(int statusCode) - OPTIONAL
*/
var Media = function(src, successCallback, errorCallback, statusCallback) {
-
- // successCallback optional
- if (successCallback && (typeof successCallback !== "function")) {
- console.log("Media Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Media Error: errorCallback is not a function");
- return;
- }
-
- // statusCallback optional
- if (statusCallback && (typeof statusCallback !== "function")) {
- console.log("Media Error: statusCallback is not a function");
- return;
- }
-
+ argscheck.checkArgs('SFFF', 'Media', arguments);
this.id = utils.createUUID();
mediaObjects[this.id] = this;
this.src = src;
@@ -2959,7 +3392,6 @@
var me = this;
exec(function() {
me._position = 0;
- me.successCallback();
}, this.errorCallback, "Media", "stopPlayingAudio", [this.id]);
};
@@ -3005,14 +3437,14 @@
* 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]);
};
/**
@@ -3034,61 +3466,88 @@
* PRIVATE
*
* @param id The media object id (string)
- * @param status The status code (int)
- * @param msg The status message (string)
+ * @param msgType The 'type' of update this is
+ * @param value Use of value is determined by the msgType
*/
-Media.onStatus = function(id, msg, value) {
+Media.onStatus = function(id, msgType, value) {
+
var media = mediaObjects[id];
- // If state update
- if (msg === Media.MEDIA_STATE) {
- if (value === Media.MEDIA_STOPPED) {
- if (media.successCallback) {
- media.successCallback();
- }
- }
- if (media.statusCallback) {
- media.statusCallback(value);
+
+ if(media) {
+ switch(msgType) {
+ case Media.MEDIA_STATE :
+ media.statusCallback && media.statusCallback(value);
+ if(value == Media.MEDIA_STOPPED) {
+ media.successCallback && media.successCallback();
+ }
+ break;
+ case Media.MEDIA_DURATION :
+ media._duration = value;
+ break;
+ case Media.MEDIA_ERROR :
+ media.errorCallback && media.errorCallback(value);
+ break;
+ case Media.MEDIA_POSITION :
+ media._position = Number(value);
+ break;
+ default :
+ console.error && console.error("Unhandled Media.onStatus :: " + msgType);
+ break;
}
}
- else if (msg === Media.MEDIA_DURATION) {
- media._duration = value;
+ else {
+ console.error && console.error("Received Media.onStatus callback for unknown media :: " + id);
}
- else if (msg === Media.MEDIA_ERROR) {
- if (media.errorCallback) {
- // value should be a MediaError object when msg == MEDIA_ERROR
- media.errorCallback(value);
- }
- }
- else if (msg === Media.MEDIA_POSITION) {
- media._position = value;
- }
+
};
module.exports = Media;
+
});
// file: lib/common/plugin/MediaError.js
define("cordova/plugin/MediaError", function(require, exports, module) {
+
/**
* This class contains information about any Media errors.
- * @constructor
+*/
+/*
+ According to :: http://dev.w3.org/html5/spec-author-view/video.html#mediaerror
+ We should never be creating these objects, we should just implement the interface
+ which has 1 property for an instance, 'code'
+
+ instead of doing :
+ errorCallbackFunction( new MediaError(3,'msg') );
+we should simply use a literal :
+ errorCallbackFunction( {'code':3} );
*/
-var MediaError = function(code, msg) {
- this.code = (code !== undefined ? code : null);
- this.message = msg || "";
-};
-MediaError.MEDIA_ERR_NONE_ACTIVE = 0;
-MediaError.MEDIA_ERR_ABORTED = 1;
-MediaError.MEDIA_ERR_NETWORK = 2;
-MediaError.MEDIA_ERR_DECODE = 3;
-MediaError.MEDIA_ERR_NONE_SUPPORTED = 4;
+ var _MediaError = window.MediaError;
-module.exports = MediaError;
+
+if(!_MediaError) {
+ window.MediaError = _MediaError = function(code, msg) {
+ this.code = (typeof code != 'undefined') ? code : null;
+ this.message = msg || ""; // message is NON-standard! do not use!
+ };
+}
+
+_MediaError.MEDIA_ERR_NONE_ACTIVE = _MediaError.MEDIA_ERR_NONE_ACTIVE || 0;
+_MediaError.MEDIA_ERR_ABORTED = _MediaError.MEDIA_ERR_ABORTED || 1;
+_MediaError.MEDIA_ERR_NETWORK = _MediaError.MEDIA_ERR_NETWORK || 2;
+_MediaError.MEDIA_ERR_DECODE = _MediaError.MEDIA_ERR_DECODE || 3;
+_MediaError.MEDIA_ERR_NONE_SUPPORTED = _MediaError.MEDIA_ERR_NONE_SUPPORTED || 4;
+// TODO: MediaError.MEDIA_ERR_NONE_SUPPORTED is legacy, the W3 spec now defines it as below.
+// as defined by http://dev.w3.org/html5/spec-author-view/video.html#error-codes
+_MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED = _MediaError.MEDIA_ERR_SRC_NOT_SUPPORTED || 4;
+
+module.exports = _MediaError;
+
});
// file: lib/common/plugin/MediaFile.js
define("cordova/plugin/MediaFile", function(require, exports, module) {
+
var utils = require('cordova/utils'),
exec = require('cordova/exec'),
File = require('cordova/plugin/File'),
@@ -3122,34 +3581,13 @@
}
};
-// 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;
});
// file: lib/common/plugin/MediaFileData.js
define("cordova/plugin/MediaFileData", function(require, exports, module) {
+
/**
* MediaFileData encapsulates format information of a media file.
*
@@ -3168,10 +3606,12 @@
};
module.exports = MediaFileData;
+
});
// file: lib/common/plugin/Metadata.js
define("cordova/plugin/Metadata", function(require, exports, module) {
+
/**
* Information about the state of the file or directory
*
@@ -3182,10 +3622,12 @@
};
module.exports = Metadata;
+
});
// file: lib/common/plugin/Position.js
define("cordova/plugin/Position", function(require, exports, module) {
+
var Coordinates = require('cordova/plugin/Coordinates');
var Position = function(coords, timestamp) {
@@ -3203,6 +3645,7 @@
// file: lib/common/plugin/PositionError.js
define("cordova/plugin/PositionError", function(require, exports, module) {
+
/**
* Position error object
*
@@ -3220,10 +3663,12 @@
PositionError.TIMEOUT = 3;
module.exports = PositionError;
+
});
// file: lib/common/plugin/ProgressEvent.js
define("cordova/plugin/ProgressEvent", function(require, exports, module) {
+
// If ProgressEvent exists in global context, use it already, otherwise use our own polyfill
// Feature test: See if we can instantiate a native ProgressEvent;
// if so, use that approach,
@@ -3270,15 +3715,18 @@
})();
module.exports = ProgressEvent;
+
});
// file: lib/common/plugin/accelerometer.js
define("cordova/plugin/accelerometer", function(require, exports, module) {
+
/**
* This class provides access to device accelerometer data.
* @constructor
*/
-var utils = require("cordova/utils"),
+var argscheck = require('cordova/argscheck'),
+ utils = require("cordova/utils"),
exec = require("cordova/exec"),
Acceleration = require('cordova/plugin/Acceleration');
@@ -3335,17 +3783,14 @@
var accelerometer = {
/**
- * Asynchronously aquires the current acceleration.
+ * Asynchronously acquires the current acceleration.
*
* @param {Function} successCallback The function to call when the acceleration data is available
* @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
* @param {AccelerationOptions} options The options for getting the accelerometer data such as timeout. (OPTIONAL)
*/
getCurrentAcceleration: function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback !== "function") {
- throw "getCurrentAcceleration must be called with at least a success callback function as first parameter.";
- }
+ argscheck.checkArgs('fFO', 'accelerometer.getCurrentAcceleration', arguments);
var p;
var win = function(a) {
@@ -3354,7 +3799,7 @@
};
var fail = function(e) {
removeListeners(p);
- errorCallback(e);
+ errorCallback && errorCallback(e);
};
p = createCallbackPair(win, fail);
@@ -3366,7 +3811,7 @@
},
/**
- * Asynchronously aquires the acceleration repeatedly at a given interval.
+ * Asynchronously acquires the acceleration repeatedly at a given interval.
*
* @param {Function} successCallback The function to call each time the acceleration data is available
* @param {Function} errorCallback The function to call when there is an error getting the acceleration data. (OPTIONAL)
@@ -3374,20 +3819,16 @@
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
watchAcceleration: function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'accelerometer.watchAcceleration', arguments);
// Default interval (10 sec)
var frequency = (options && options.frequency && typeof options.frequency == 'number') ? options.frequency : 10000;
- // successCallback required
- if (typeof successCallback !== "function") {
- throw "watchAcceleration must be called with at least a success callback function as first parameter.";
- }
-
// Keep reference to watch id, and report accel readings as often as defined in frequency
var id = utils.createUUID();
var p = createCallbackPair(function(){}, function(e) {
removeListeners(p);
- errorCallback(e);
+ errorCallback && errorCallback(e);
});
listeners.push(p);
@@ -3402,8 +3843,8 @@
if (running) {
// If we're already running then immediately invoke the success callback
- // but only if we have retreived a value, sample code does not check for null ...
- if(accel) {
+ // but only if we have retrieved a value, sample code does not check for null ...
+ if (accel) {
successCallback(accel);
}
} else {
@@ -3432,8 +3873,20 @@
});
+// file: lib/common/plugin/accelerometer/symbols.js
+define("cordova/plugin/accelerometer/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Acceleration', 'Acceleration');
+modulemapper.defaults('cordova/plugin/accelerometer', 'navigator.accelerometer');
+
+});
+
// file: lib/common/plugin/battery.js
define("cordova/plugin/battery", function(require, exports, module) {
+
/**
* This class contains information about the current battery status.
* @constructor
@@ -3451,34 +3904,25 @@
this._level = null;
this._isPlugged = null;
// Create new event handlers on the window (returns a channel instance)
- var subscriptionEvents = {
- onSubscribe:this.onSubscribe,
- onUnsubscribe:this.onUnsubscribe
- };
this.channels = {
- batterystatus:cordova.addWindowEventHandler("batterystatus", subscriptionEvents),
- batterylow:cordova.addWindowEventHandler("batterylow", subscriptionEvents),
- batterycritical:cordova.addWindowEventHandler("batterycritical", subscriptionEvents)
+ batterystatus:cordova.addWindowEventHandler("batterystatus"),
+ batterylow:cordova.addWindowEventHandler("batterylow"),
+ batterycritical:cordova.addWindowEventHandler("batterycritical")
};
+ for (var key in this.channels) {
+ this.channels[key].onHasSubscribersChange = Battery.onHasSubscribersChange;
+ }
};
/**
* Event handlers for when callbacks get registered for the battery.
* Keep track of how many handlers we have so we can start and stop the native battery listener
* appropriately (and hopefully save on battery life!).
*/
-Battery.prototype.onSubscribe = function() {
- var me = battery;
+Battery.onHasSubscribersChange = function() {
// If we just registered the first handler, make sure native listener is started.
- if (handlers() === 1) {
- exec(me._status, me._error, "Battery", "start", []);
- }
-};
-
-Battery.prototype.onUnsubscribe = function() {
- var me = battery;
-
- // If we just unregistered the last handler, make sure native listener is stopped.
- if (handlers() === 0) {
+ if (this.numHandlers === 1 && handlers() === 1) {
+ exec(battery._status, battery._error, "Battery", "start", []);
+ } else if (handlers() === 0) {
exec(null, null, "Battery", "stop", []);
}
};
@@ -3521,10 +3965,34 @@
var battery = new Battery();
module.exports = battery;
+
+});
+
+// file: lib/common/plugin/battery/symbols.js
+define("cordova/plugin/battery/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/battery', 'navigator.battery');
+
+});
+
+// file: lib/common/plugin/camera/symbols.js
+define("cordova/plugin/camera/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Camera', 'navigator.camera');
+modulemapper.defaults('cordova/plugin/CameraConstants', 'Camera');
+modulemapper.defaults('cordova/plugin/CameraPopoverOptions', 'CameraPopoverOptions');
+
});
// file: lib/common/plugin/capture.js
define("cordova/plugin/capture", function(require, exports, module) {
+
var exec = require('cordova/exec'),
MediaFile = require('cordova/plugin/MediaFile');
@@ -3600,9 +4068,27 @@
});
+// file: lib/common/plugin/capture/symbols.js
+define("cordova/plugin/capture/symbols", function(require, exports, module) {
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/CaptureError', 'CaptureError');
+modulemapper.clobbers('cordova/plugin/CaptureAudioOptions', 'CaptureAudioOptions');
+modulemapper.clobbers('cordova/plugin/CaptureImageOptions', 'CaptureImageOptions');
+modulemapper.clobbers('cordova/plugin/CaptureVideoOptions', 'CaptureVideoOptions');
+modulemapper.clobbers('cordova/plugin/ConfigurationData', 'ConfigurationData');
+modulemapper.clobbers('cordova/plugin/MediaFile', 'MediaFile');
+modulemapper.clobbers('cordova/plugin/MediaFileData', 'MediaFileData');
+modulemapper.clobbers('cordova/plugin/capture', 'navigator.device.capture');
+
+});
+
// file: lib/common/plugin/compass.js
define("cordova/plugin/compass", function(require, exports, module) {
-var exec = require('cordova/exec'),
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
utils = require('cordova/utils'),
CompassHeading = require('cordova/plugin/CompassHeading'),
CompassError = require('cordova/plugin/CompassError'),
@@ -3617,23 +4103,13 @@
* @param {CompassOptions} options The options for getting the heading data (not used).
*/
getCurrentHeading:function(successCallback, errorCallback, options) {
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return;
- }
+ argscheck.checkArgs('fFO', 'compass.getCurrentHeading', arguments);
var win = function(result) {
var ch = new CompassHeading(result.magneticHeading, result.trueHeading, result.headingAccuracy, result.timestamp);
successCallback(ch);
};
- var fail = function(code) {
+ var fail = errorCallback && function(code) {
var ce = new CompassError(code);
errorCallback(ce);
};
@@ -3653,22 +4129,11 @@
* specifies to watch via a distance filter rather than time.
*/
watchHeading:function(successCallback, errorCallback, options) {
+ argscheck.checkArgs('fFO', 'compass.watchHeading', arguments);
// Default interval (100 msec)
var frequency = (options !== undefined && options.frequency !== undefined) ? options.frequency : 100;
var filter = (options !== undefined && options.filter !== undefined) ? options.filter : 0;
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Compass Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Compass Error: errorCallback is not a function");
- return;
- }
-
var id = utils.createUUID();
if (filter > 0) {
// is an iOS request for watch by filter, no timer needed
@@ -3692,8 +4157,8 @@
// Stop javascript timer & remove from timer list
if (id && timers[id]) {
if (timers[id] != "iOS") {
- clearInterval(timers[id]);
- } else {
+ clearInterval(timers[id]);
+ } else {
// is iOS watch by filter so call into device to stop
exec(null, null, "Compass", "stopHeading", []);
}
@@ -3703,10 +4168,24 @@
};
module.exports = compass;
+
+});
+
+// file: lib/common/plugin/compass/symbols.js
+define("cordova/plugin/compass/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/CompassHeading', 'CompassHeading');
+modulemapper.clobbers('cordova/plugin/CompassError', 'CompassError');
+modulemapper.clobbers('cordova/plugin/compass', 'navigator.compass');
+
});
// file: lib/common/plugin/console-via-logger.js
define("cordova/plugin/console-via-logger", function(require, exports, module) {
+
//------------------------------------------------------------------------------
var logger = require("cordova/plugin/logger");
@@ -3786,7 +4265,7 @@
console.assert = function(expression) {
if (expression) return;
- var message = utils.vformat(arguments[1], [].slice.call(arguments, 2));
+ var message = logger.format.apply(logger.format, [].slice.call(arguments, 1));
console.log("ASSERT: " + message);
};
@@ -3855,7 +4334,7 @@
//------------------------------------------------------------------------------
// return a new function that calls both functions passed as args
//------------------------------------------------------------------------------
-function wrapperedOrigCall(orgFunc, newFunc) {
+function wrappedOrigCall(orgFunc, newFunc) {
return function() {
var args = [].slice.call(arguments);
try { orgFunc.apply(WinConsole, args); } catch (e) {}
@@ -3870,7 +4349,7 @@
//------------------------------------------------------------------------------
for (var key in console) {
if (typeof WinConsole[key] == "function") {
- console[key] = wrapperedOrigCall(WinConsole[key], console[key]);
+ console[key] = wrappedOrigCall(WinConsole[key], console[key]);
}
}
@@ -3878,7 +4357,9 @@
// file: lib/common/plugin/contacts.js
define("cordova/plugin/contacts", function(require, exports, module) {
-var exec = require('cordova/exec'),
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils'),
Contact = require('cordova/plugin/Contact');
@@ -3897,13 +4378,9 @@
* @return array of Contacts matching search criteria
*/
find:function(fields, successCB, errorCB, options) {
- if (!successCB) {
- throw new TypeError("You must specify a success callback for the find command.");
- }
- if (!fields || (utils.isArray(fields) && fields.length === 0)) {
- if (typeof errorCB === "function") {
- errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
- }
+ argscheck.checkArgs('afFO', 'contacts.find', arguments);
+ if (!fields.length) {
+ errorCB && errorCB(new ContactError(ContactError.INVALID_ARGUMENT_ERROR));
} else {
var win = function(result) {
var cs = [];
@@ -3920,13 +4397,13 @@
* 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) {
- var i;
+ argscheck.checkArgs('O', 'contacts.create', arguments);
var contact = new Contact();
- for (i in properties) {
+ for (var i in properties) {
if (typeof contact[i] !== 'undefined' && properties.hasOwnProperty(i)) {
contact[i] = properties[i];
}
@@ -3939,9 +4416,28 @@
});
+// file: lib/common/plugin/contacts/symbols.js
+define("cordova/plugin/contacts/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/contacts', 'navigator.contacts');
+modulemapper.clobbers('cordova/plugin/Contact', 'Contact');
+modulemapper.clobbers('cordova/plugin/ContactAddress', 'ContactAddress');
+modulemapper.clobbers('cordova/plugin/ContactError', 'ContactError');
+modulemapper.clobbers('cordova/plugin/ContactField', 'ContactField');
+modulemapper.clobbers('cordova/plugin/ContactFindOptions', 'ContactFindOptions');
+modulemapper.clobbers('cordova/plugin/ContactName', 'ContactName');
+modulemapper.clobbers('cordova/plugin/ContactOrganization', 'ContactOrganization');
+
+});
+
// file: lib/common/plugin/device.js
define("cordova/plugin/device", function(require, exports, module) {
-var channel = require('cordova/channel'),
+
+var argscheck = require('cordova/argscheck'),
+ channel = require('cordova/channel'),
utils = require('cordova/utils'),
exec = require('cordova/exec');
@@ -3957,20 +4453,24 @@
this.available = false;
this.platform = null;
this.version = null;
- this.name = null;
this.uuid = null;
this.cordova = null;
+ this.model = null;
var me = this;
- channel.onCordovaReady.subscribeOnce(function() {
+ channel.onCordovaReady.subscribe(function() {
me.getInfo(function(info) {
+ var buildLabel = info.cordova;
+ if (buildLabel != CORDOVA_JS_BUILD_LABEL) {
+ buildLabel += ' JS=' + CORDOVA_JS_BUILD_LABEL;
+ }
me.available = true;
me.platform = info.platform;
me.version = info.version;
- me.name = info.name;
me.uuid = info.uuid;
- me.cordova = info.cordova;
+ me.cordova = buildLabel;
+ me.model = info.model;
channel.onCordovaInfoReady.fire();
},function(e) {
me.available = false;
@@ -3986,20 +4486,7 @@
* @param {Function} errorCallback The function to call when there is an error getting the heading data. (OPTIONAL)
*/
Device.prototype.getInfo = function(successCallback, errorCallback) {
-
- // successCallback required
- if (typeof successCallback !== "function") {
- console.log("Device Error: successCallback is not a function");
- return;
- }
-
- // errorCallback optional
- if (errorCallback && (typeof errorCallback !== "function")) {
- console.log("Device Error: errorCallback is not a function");
- return;
- }
-
- // Get info
+ argscheck.checkArgs('fF', 'Device.getInfo', arguments);
exec(successCallback, errorCallback, "Device", "getDeviceInfo", []);
};
@@ -4007,9 +4494,110 @@
});
+// file: lib/tizen/plugin/device/symbols.js
+define("cordova/plugin/device/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/tizen/Device', 'device');
+modulemapper.merges('cordova/plugin/tizen/Device', 'navigator.device');
+
+});
+
+// file: lib/common/plugin/echo.js
+define("cordova/plugin/echo", function(require, exports, module) {
+
+var exec = require('cordova/exec'),
+ utils = require('cordova/utils');
+
+/**
+ * Sends the given message through exec() to the Echo plugin, 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 = 'echo';
+ var messageIsMultipart = (utils.typeName(message) == "Array");
+ var args = messageIsMultipart ? message : [message];
+
+ if (utils.typeName(message) == 'ArrayBuffer') {
+ if (forceAsync) {
+ console.warn('Cannot echo ArrayBuffer with forced async, falling back to sync.');
+ }
+ action += 'ArrayBuffer';
+ } else if (messageIsMultipart) {
+ if (forceAsync) {
+ console.warn('Cannot echo MultiPart Array with forced async, falling back to sync.');
+ }
+ action += 'MultiPart';
+ } else if (forceAsync) {
+ action += 'Async';
+ }
+
+ exec(successCallback, errorCallback, "Echo", action, args);
+};
+
+
+});
+
+// file: lib/tizen/plugin/file/symbols.js
+define("cordova/plugin/file/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper'),
+ symbolshelper = require('cordova/plugin/file/symbolshelper');
+
+symbolshelper(modulemapper.defaults);
+modulemapper.clobbers('cordova/plugin/File', 'File');
+modulemapper.clobbers('cordova/plugin/FileReader', 'FileReader');
+modulemapper.clobbers('cordova/plugin/FileError', 'FileError');
+
+});
+
+// file: lib/common/plugin/file/symbolshelper.js
+define("cordova/plugin/file/symbolshelper", function(require, exports, module) {
+
+module.exports = function(exportFunc) {
+ exportFunc('cordova/plugin/DirectoryEntry', 'DirectoryEntry');
+ exportFunc('cordova/plugin/DirectoryReader', 'DirectoryReader');
+ exportFunc('cordova/plugin/Entry', 'Entry');
+ exportFunc('cordova/plugin/File', 'File');
+ exportFunc('cordova/plugin/FileEntry', 'FileEntry');
+ exportFunc('cordova/plugin/FileError', 'FileError');
+ exportFunc('cordova/plugin/FileReader', 'FileReader');
+ exportFunc('cordova/plugin/FileSystem', 'FileSystem');
+ exportFunc('cordova/plugin/FileUploadOptions', 'FileUploadOptions');
+ exportFunc('cordova/plugin/FileUploadResult', 'FileUploadResult');
+ exportFunc('cordova/plugin/FileWriter', 'FileWriter');
+ exportFunc('cordova/plugin/Flags', 'Flags');
+ exportFunc('cordova/plugin/LocalFileSystem', 'LocalFileSystem');
+ exportFunc('cordova/plugin/Metadata', 'Metadata');
+ exportFunc('cordova/plugin/ProgressEvent', 'ProgressEvent');
+ exportFunc('cordova/plugin/requestFileSystem', 'requestFileSystem');
+ exportFunc('cordova/plugin/resolveLocalFileSystemURI', 'resolveLocalFileSystemURI');
+};
+
+});
+
+// file: lib/common/plugin/filetransfer/symbols.js
+define("cordova/plugin/filetransfer/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/FileTransfer', 'FileTransfer');
+modulemapper.clobbers('cordova/plugin/FileTransferError', 'FileTransferError');
+
+});
+
// file: lib/common/plugin/geolocation.js
define("cordova/plugin/geolocation", function(require, exports, module) {
-var utils = require('cordova/utils'),
+
+var argscheck = require('cordova/argscheck'),
+ utils = require('cordova/utils'),
exec = require('cordova/exec'),
PositionError = require('cordova/plugin/PositionError'),
Position = require('cordova/plugin/Position');
@@ -4059,25 +4647,23 @@
var geolocation = {
lastPosition:null, // reference to last known (cached) position returned
/**
- * Asynchronously aquires the current position.
+ * Asynchronously acquires the current position.
*
* @param {Function} successCallback The function to call when the position data is available
* @param {Function} errorCallback The function to call when there is an error getting the heading position. (OPTIONAL)
* @param {PositionOptions} options The options for getting the position data. (OPTIONAL)
*/
getCurrentPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("getCurrentPosition must be called with at least one argument.");
- }
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
// Timer var that will fire an error callback if no position is retrieved from native
// before the "timeout" param provided expires
- var timeoutTimer = null;
+ var timeoutTimer = {timer:null};
var win = function(p) {
- clearTimeout(timeoutTimer);
- if (!timeoutTimer) {
+ clearTimeout(timeoutTimer.timer);
+ if (!(timeoutTimer.timer)) {
// Timeout already happened, or native fired error callback for
// this geo request.
// Don't continue with success callback.
@@ -4099,8 +4685,8 @@
successCallback(pos);
};
var fail = function(e) {
- clearTimeout(timeoutTimer);
- timeoutTimer = null;
+ clearTimeout(timeoutTimer.timer);
+ timeoutTimer.timer = null;
var err = new PositionError(e.code, e.message);
if (errorCallback) {
errorCallback(err);
@@ -4115,7 +4701,7 @@
} 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 {
@@ -4123,12 +4709,12 @@
// If the timeout value was not set to Infinity (default), then
// set up a timeout function that will fire the error callback
// if no successful position was retrieved before timeout expired.
- timeoutTimer = createTimeout(fail, options.timeout);
+ timeoutTimer.timer = createTimeout(fail, options.timeout);
} else {
// This is here so the check in the win function doesn't mess stuff up
// may seem weird but this guarantees timeoutTimer is
// always truthy before we call into native
- timeoutTimer = true;
+ timeoutTimer.timer = true;
}
exec(win, fail, "Geolocation", "getLocation", [options.enableHighAccuracy, options.maximumAge]);
}
@@ -4144,9 +4730,7 @@
* @return String The watch id that must be passed to #clearWatch to stop watching.
*/
watchPosition:function(successCallback, errorCallback, options) {
- if (arguments.length === 0) {
- throw new Error("watchPosition must be called with at least one argument.");
- }
+ argscheck.checkArgs('fFO', 'geolocation.getCurrentPosition', arguments);
options = parseParameters(options);
var id = utils.createUUID();
@@ -4155,7 +4739,7 @@
timers[id] = geolocation.getCurrentPosition(successCallback, errorCallback, options);
var fail = function(e) {
- clearTimeout(timers[id]);
+ clearTimeout(timers[id].timer);
var err = new PositionError(e.code, e.message);
if (errorCallback) {
errorCallback(err);
@@ -4163,9 +4747,9 @@
};
var win = function(p) {
- clearTimeout(timers[id]);
+ clearTimeout(timers[id].timer);
if (options.timeout !== Infinity) {
- timers[id] = createTimeout(fail, options.timeout);
+ timers[id].timer = createTimeout(fail, options.timeout);
}
var pos = new Position(
{
@@ -4194,8 +4778,8 @@
*/
clearWatch:function(id) {
if (id && timers[id] !== undefined) {
- clearTimeout(timers[id]);
- delete timers[id];
+ clearTimeout(timers[id].timer);
+ timers[id].timer = false;
exec(null, null, "Geolocation", "clearWatch", [id]);
}
}
@@ -4205,8 +4789,408 @@
});
+// file: lib/common/plugin/geolocation/symbols.js
+define("cordova/plugin/geolocation/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/geolocation', 'navigator.geolocation');
+modulemapper.clobbers('cordova/plugin/PositionError', 'PositionError');
+modulemapper.clobbers('cordova/plugin/Position', 'Position');
+modulemapper.clobbers('cordova/plugin/Coordinates', 'Coordinates');
+
+});
+
+// file: lib/common/plugin/globalization.js
+define("cordova/plugin/globalization", function(require, exports, module) {
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
+ GlobalizationError = require('cordova/plugin/GlobalizationError');
+
+var globalization = {
+
+/**
+* Returns the string identifier for the client's current language.
+* It returns the language identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the language,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The language identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
+* function () {});
+*/
+getPreferredLanguage:function(successCB, failureCB) {
+ argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
+ exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
+},
+
+/**
+* Returns the string identifier for the client's current locale setting.
+* It returns the locale identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the locale,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The locale identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
+* function () {});
+*/
+getLocaleName:function(successCB, failureCB) {
+ argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
+ exec(successCB, failureCB, "Globalization","getLocaleName", []);
+},
+
+
+/**
+* Returns a date formatted as a string according to the client's user preferences and
+* calendar using the time zone of the client. It returns the formatted date string to the
+* successCB callback with a properties object as a parameter. If there is an error
+* formatting the date, then the errorCB callback is invoked.
+*
+* The defaults are: formatLenght="short" and selector="date and time"
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.value {String}: The localized date string
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.dateToString(new Date(),
+* function (date) {alert('date:' + date.value + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {formatLength:'short'});
+*/
+dateToString:function(date, successCB, failureCB, options) {
+ argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
+ var dateValue = date.valueOf();
+ exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);
+},
+
+
+/**
+* Parses a date formatted as a string according to the client's user
+* preferences and calendar using the time zone of the client and returns
+* the corresponding date object. It returns the date to the successCB
+* callback with a properties object as a parameter. If there is an error
+* parsing the date string, then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {String} dateString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.year {Number}: The four digit year
+* Object.month {Number}: The month from (0 - 11)
+* Object.day {Number}: The day from (1 - 31)
+* Object.hour {Number}: The hour from (0 - 23)
+* Object.minute {Number}: The minute from (0 - 59)
+* Object.second {Number}: The second from (0 - 59)
+* Object.millisecond {Number}: The milliseconds (from 0 - 999),
+* not available on all platforms
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToDate('4/11/2011',
+* function (date) { alert('Month:' + date.month + '\n' +
+* 'Day:' + date.day + '\n' +
+* 'Year:' + date.year + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {selector:'date'});
+*/
+stringToDate:function(dateString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
+ exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);
+},
+
+
+/**
+* Returns a pattern string for formatting and parsing dates according to the client's
+* user preferences. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern,
+* then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.timezone {String}: The abbreviated name of the time zone on the client
+* Object.utc_offset {Number}: The current difference in seconds between the client's
+* time zone and coordinated universal time.
+* Object.dst_offset {Number}: The current daylight saving time offset in seconds
+* between the client's non-daylight saving's time zone
+* and the client's daylight saving's time zone.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getDatePattern(
+* function (date) {alert('pattern:' + date.pattern + '\n');},
+* function () {},
+* {formatLength:'short'});
+*/
+getDatePattern:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
+ exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);
+},
+
+
+/**
+* Returns an array of either the names of the months or days of the week
+* according to the client's user preferences and calendar. It returns the array of names to the
+* successCB callback with a properties object as a parameter. If there is an error obtaining the
+* names, then the errorCB callback is invoked.
+*
+* The defaults are: type="wide" and item="months"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'narrow' or 'wide'
+* item {String}: 'months', or 'days'
+*
+* @return Object.value {Array{String}}: The array of names starting from either
+* the first month in the year or the
+* first day of the week.
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getDateNames(function (names) {
+* for(var i = 0; i < names.value.length; i++) {
+* alert('Month:' + names.value[i] + '\n');}},
+* function () {});
+*/
+getDateNames:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
+ exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);
+},
+
+/**
+* Returns whether daylight savings time is in effect for a given date using the client's
+* time zone and calendar. It returns whether or not daylight savings time is in effect
+* to the successCB callback with a properties object as a parameter. If there is an error
+* reading the date, then the errorCB callback is invoked.
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
+* in effect for the given date and "false" indicate that it is not.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.isDayLightSavingsTime(new Date(),
+* function (date) {alert('dst:' + date.dst + '\n');}
+* function () {});
+*/
+isDayLightSavingsTime:function(date, successCB, failureCB) {
+ argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', arguments);
+ var dateValue = date.valueOf();
+ exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);
+},
+
+/**
+* Returns the first day of the week according to the client's user preferences and calendar.
+* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
+* It returns the day to the successCB callback with a properties object as a parameter.
+* If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {Number}: The number of the first day of the week.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getFirstDayOfWeek(function (day)
+* { alert('Day:' + day.value + '\n');},
+* function () {});
+*/
+getFirstDayOfWeek:function(successCB, failureCB) {
+ argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
+ exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
+},
+
+
+/**
+* Returns a number formatted as a string according to the client's user preferences.
+* It returns the formatted number string to the successCB callback with a properties object as a
+* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Number} number
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {String}: The formatted number string.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.numberToString(3.25,
+* function (number) {alert('number:' + number.value + '\n');},
+* function () {},
+* {type:'decimal'});
+*/
+numberToString:function(number, successCB, failureCB, options) {
+ argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
+ exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);
+},
+
+/**
+* Parses a number formatted as a string according to the client's user preferences and
+* returns the corresponding number. It returns the number to the successCB callback with a
+* properties object as a parameter. If there is an error parsing the number string, then
+* the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {String} numberString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {Number}: The parsed number.
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToNumber('1234.56',
+* function (number) {alert('Number:' + number.value + '\n');},
+* function () { alert('Error parsing number');});
+*/
+stringToNumber:function(numberString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
+ exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);
+},
+
+/**
+* Returns a pattern string for formatting and parsing numbers according to the client's user
+* preferences. It returns the pattern to the successCB callback with a properties object as a
+* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
+* The patterns follow Unicode Technical Standard #35.
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.symbol {String}: The symbol to be used when formatting and parsing
+* e.g., percent or currency symbol.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting numbers.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
+* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getNumberPattern(
+* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
+* function () {});
+*/
+getNumberPattern:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
+ exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);
+},
+
+/**
+* Returns a pattern string for formatting and parsing currency values according to the client's
+* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
+* callback is invoked.
+*
+* @param {String} currencyCode
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.code {String}: The ISO 4217 currency code for the pattern.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting currency.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.getCurrencyPattern('EUR',
+* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
+* function () {});
+*/
+getCurrencyPattern:function(currencyCode, successCB, failureCB) {
+ argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
+ exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);
+}
+
+};
+
+module.exports = globalization;
+
+});
+
+// file: lib/tizen/plugin/globalization/symbols.js
+define("cordova/plugin/globalization/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/tizen/Globalization', 'navigator.globalization');
+
+});
+
// file: lib/common/plugin/logger.js
define("cordova/plugin/logger", function(require, exports, module) {
+
//------------------------------------------------------------------------------
// The logger module exports the following properties/functions:
//
@@ -4234,10 +5218,13 @@
var utils = require('cordova/utils');
var UseConsole = true;
+var UseLogger = true;
var Queued = [];
var DeviceReady = false;
var CurrentLevel;
+var originalConsole = console;
+
/**
* Logging levels
*/
@@ -4279,7 +5266,7 @@
*
* 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.
*/
@@ -4298,8 +5285,7 @@
* Getter/Setter for the useConsole functionality
*
* When useConsole is true, the logger will log via the
- * browser 'console' object. Otherwise, it will use the
- * native Logger plugin.
+ * browser 'console' object.
*/
logger.useConsole = function (value) {
if (arguments.length) UseConsole = !!value;
@@ -4324,6 +5310,18 @@
};
/**
+ * Getter/Setter for the useLogger functionality
+ *
+ * When useLogger is true, the logger will log via the
+ * native Logger plugin.
+ */
+logger.useLogger = function (value) {
+ // Enforce boolean
+ if (arguments.length) UseLogger = !!value;
+ return UseLogger;
+};
+
+/**
* Logs a message at the LOG level.
*
* Parameters passed after message are used applied to
@@ -4375,10 +5373,10 @@
* Parameters passed after message are used applied to
* the message with utils.format()
*/
-logger.logLevel = function(level, message /* , ... */) {
+logger.logLevel = function(level /* , ... */) {
// format the message with the parameters
- var formatArgs = [].slice.call(arguments, 2);
- message = utils.vformat(message, formatArgs);
+ var formatArgs = [].slice.call(arguments, 1);
+ var message = logger.format.apply(logger.format, formatArgs);
if (LevelsMap[level] === null) {
throw new Error("invalid logging level: " + level);
@@ -4392,27 +5390,115 @@
return;
}
- // if not using the console, use the native logger
- if (!UseConsole) {
+ // Log using the native logger if that is enabled
+ if (UseLogger) {
exec(null, null, "Logger", "logLevel", [level, message]);
- return;
}
- // make sure console is not using logger
- if (console.__usingCordovaLogger) {
- throw new Error("console and logger are too intertwingly");
- }
+ // Log using the console if that is enabled
+ if (UseConsole) {
+ // make sure console is not using logger
+ if (console.__usingCordovaLogger) {
+ throw new Error("console and logger are too intertwingly");
+ }
- // log to the console
- switch (level) {
- case logger.LOG: console.log(message); break;
- case logger.ERROR: console.log("ERROR: " + message); break;
- case logger.WARN: console.log("WARN: " + message); break;
- case logger.INFO: console.log("INFO: " + message); break;
- case logger.DEBUG: console.log("DEBUG: " + message); break;
+ // log to the console
+ switch (level) {
+ case logger.LOG: originalConsole.log(message); break;
+ case logger.ERROR: originalConsole.log("ERROR: " + message); break;
+ case logger.WARN: originalConsole.log("WARN: " + message); break;
+ case logger.INFO: originalConsole.log("INFO: " + message); break;
+ case logger.DEBUG: originalConsole.log("DEBUG: " + message); break;
+ }
}
};
+
+/**
+ * Formats a string and arguments following it ala console.log()
+ *
+ * Any remaining arguments will be appended to the formatted string.
+ *
+ * for rationale, see FireBug's Console API:
+ * http://getfirebug.com/wiki/index.php/Console_API
+ */
+logger.format = function(formatString, args) {
+ return __format(arguments[0], [].slice.call(arguments,1)).join(' ');
+};
+
+
+//------------------------------------------------------------------------------
+/**
+ * Formats a string and arguments following it ala vsprintf()
+ *
+ * format chars:
+ * %j - format arg as JSON
+ * %o - format arg as JSON
+ * %c - format arg as ''
+ * %% - replace with '%'
+ * any other char following % will format it's
+ * arg via toString().
+ *
+ * Returns an array containing the formatted string and any remaining
+ * arguments.
+ */
+function __format(formatString, args) {
+ if (formatString === null || formatString === undefined) return [""];
+ if (arguments.length == 1) return [formatString.toString()];
+
+ if (typeof formatString != "string")
+ formatString = formatString.toString();
+
+ var pattern = /(.*?)%(.)(.*)/;
+ var rest = formatString;
+ var result = [];
+
+ while (args.length) {
+ var match = pattern.exec(rest);
+ if (!match) break;
+
+ var arg = args.shift();
+ rest = match[3];
+ result.push(match[1]);
+
+ if (match[2] == '%') {
+ result.push('%');
+ args.unshift(arg);
+ continue;
+ }
+
+ result.push(__formatted(arg, match[2]));
+ }
+
+ result.push(rest);
+
+ var remainingArgs = [].slice.call(args);
+ remainingArgs.unshift(result.join(''));
+ return remainingArgs;
+}
+
+function __formatted(object, formatChar) {
+
+ try {
+ switch(formatChar) {
+ case 'j':
+ case 'o': return JSON.stringify(object);
+ case 'c': return '';
+ }
+ }
+ catch (e) {
+ return "error JSON.stringify()ing argument: " + e;
+ }
+
+ if ((object === null) || (object === undefined)) {
+ return Object.prototype.toString.call(object);
+ }
+
+ return object.toString();
+}
+
+
+//------------------------------------------------------------------------------
// when deviceready fires, log queued messages
logger.__onDeviceReady = function() {
if (DeviceReady) return;
@@ -4432,55 +5518,48 @@
});
+// file: lib/common/plugin/logger/symbols.js
+define("cordova/plugin/logger/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/logger', 'cordova.logger');
+
+});
+
+// file: lib/tizen/plugin/media/symbols.js
+define("cordova/plugin/media/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/Media', 'Media');
+modulemapper.defaults('cordova/plugin/MediaError', 'MediaError');
+modulemapper.merges('cordova/plugin/tizen/MediaError', 'MediaError');
+
+});
+
// file: lib/common/plugin/network.js
define("cordova/plugin/network", function(require, exports, module) {
+
var exec = require('cordova/exec'),
cordova = require('cordova'),
- channel = require('cordova/channel');
+ channel = require('cordova/channel'),
+ utils = require('cordova/utils');
-var NetworkConnection = function () {
- this.type = null;
- this._firstRun = true;
- this._timer = null;
- this.timeout = 500;
-
- var me = this;
-
- channel.onCordovaReady.subscribeOnce(function() {
- me.getInfo(function (info) {
- me.type = info;
- if (info === "none") {
- // set a timer if still offline at the end of timer send the offline event
- me._timer = setTimeout(function(){
- cordova.fireDocumentEvent("offline");
- me._timer = null;
- }, me.timeout);
- } else {
- // If there is a current offline event pending clear it
- if (me._timer !== null) {
- clearTimeout(me._timer);
- me._timer = null;
- }
- cordova.fireDocumentEvent("online");
- }
-
- // should only fire this once
- if (me._firstRun) {
- me._firstRun = false;
- channel.onCordovaConnectionReady.fire();
- }
- },
- function (e) {
- // If we can't get the network info we should still tell Cordova
- // to fire the deviceready event.
- if (me._firstRun) {
- me._firstRun = false;
- channel.onCordovaConnectionReady.fire();
- }
- console.log("Error initializing Network Connection: " + e);
- });
+// Link the onLine property with the Cordova-supplied network info.
+// This works because we clobber the naviagtor object with our own
+// object in bootstrap.js.
+if (typeof navigator != 'undefined') {
+ utils.defineGetter(navigator, 'onLine', function() {
+ return this.connection.type != 'none';
});
-};
+}
+
+function NetworkConnection() {
+ this.type = 'unknown';
+}
/**
* Get connection info
@@ -4488,17 +5567,68 @@
* @param {Function} successCallback The function to call when the Connection data is available
* @param {Function} errorCallback The function to call when there is an error getting the Connection data. (OPTIONAL)
*/
-NetworkConnection.prototype.getInfo = function (successCallback, errorCallback) {
- // Get info
+NetworkConnection.prototype.getInfo = function(successCallback, errorCallback) {
exec(successCallback, errorCallback, "NetworkStatus", "getConnectionInfo", []);
};
-module.exports = new NetworkConnection();
+var me = new NetworkConnection();
+var timerId = null;
+var timeout = 500;
+
+channel.onCordovaReady.subscribe(function() {
+ me.getInfo(function(info) {
+ me.type = info;
+ if (info === "none") {
+ // set a timer if still offline at the end of timer send the offline event
+ timerId = setTimeout(function(){
+ cordova.fireDocumentEvent("offline");
+ timerId = null;
+ }, timeout);
+ } else {
+ // If there is a current offline event pending clear it
+ if (timerId !== null) {
+ clearTimeout(timerId);
+ timerId = null;
+ }
+ cordova.fireDocumentEvent("online");
+ }
+
+ // should only fire this once
+ if (channel.onCordovaConnectionReady.state !== 2) {
+ channel.onCordovaConnectionReady.fire();
+ }
+ },
+ function (e) {
+ // If we can't get the network info we should still tell Cordova
+ // to fire the deviceready event.
+ if (channel.onCordovaConnectionReady.state !== 2) {
+ channel.onCordovaConnectionReady.fire();
+ }
+ console.log("Error initializing Network Connection: " + e);
+ });
+});
+
+module.exports = me;
+
+});
+
+// file: lib/common/plugin/networkstatus/symbols.js
+define("cordova/plugin/networkstatus/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/network', 'navigator.network.connection', 'navigator.network.connection is deprecated. Use navigator.connection instead.');
+modulemapper.clobbers('cordova/plugin/network', 'navigator.connection');
+modulemapper.defaults('cordova/plugin/Connection', 'Connection');
+
});
// file: lib/common/plugin/notification.js
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.
@@ -4527,15 +5657,55 @@
* @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).");
+ }
+
+ // Some platforms 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" || platform.id == "windowsphone" || platform.id == "blackberry10") {
+ if (typeof _buttonLabels === 'string') {
+ var buttonLabelString = _buttonLabels;
+ _buttonLabels = _buttonLabels.split(","); // not crazy about changing the var type here
+ }
+ } 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"])
+ * @param {String} defaultText Textbox input value (default: "Default text")
+ */
+ prompt: function(message, resultCallback, title, buttonLabels, defaultText) {
+ var _message = (message || "Prompt message");
+ var _title = (title || "Prompt");
+ var _buttonLabels = (buttonLabels || ["OK","Cancel"]);
+ var _defaultText = (defaultText || "Default text");
+ exec(resultCallback, null, "Notification", "prompt", [_message, _title, _buttonLabels, _defaultText]);
+ },
+
+ /**
* Causes the device to vibrate.
*
* @param {Integer} mills The number of milliseconds to vibrate for.
@@ -4554,11 +5724,25 @@
exec(null, null, "Notification", "beep", [count]);
}
};
+
+});
+
+// file: lib/tizen/plugin/notification/symbols.js
+define("cordova/plugin/notification/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.defaults('cordova/plugin/notification', 'navigator.notification');
+modulemapper.merges('cordova/plugin/tizen/Notification', 'navigator.notification');
+
});
// file: lib/common/plugin/requestFileSystem.js
define("cordova/plugin/requestFileSystem", function(require, exports, module) {
-var FileError = require('cordova/plugin/FileError'),
+
+var argscheck = require('cordova/argscheck'),
+ FileError = require('cordova/plugin/FileError'),
FileSystem = require('cordova/plugin/FileSystem'),
exec = require('cordova/exec');
@@ -4570,10 +5754,9 @@
* @param errorCallback invoked if error occurs retrieving file system
*/
var requestFileSystem = function(type, size, successCallback, errorCallback) {
+ argscheck.checkArgs('nnFF', 'requestFileSystem', arguments);
var fail = function(code) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(code));
- }
+ errorCallback && errorCallback(new FileError(code));
};
if (type < 0 || type > 3) {
@@ -4582,7 +5765,7 @@
// if successful, return a FileSystem object
var success = function(file_system) {
if (file_system) {
- if (typeof successCallback === 'function') {
+ if (successCallback) {
// grab the name and root from the file system object
var result = new FileSystem(file_system.name, file_system.root);
successCallback(result);
@@ -4598,11 +5781,14 @@
};
module.exports = requestFileSystem;
+
});
// file: lib/common/plugin/resolveLocalFileSystemURI.js
define("cordova/plugin/resolveLocalFileSystemURI", function(require, exports, module) {
-var DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
+
+var argscheck = require('cordova/argscheck'),
+ DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
FileEntry = require('cordova/plugin/FileEntry'),
FileError = require('cordova/plugin/FileError'),
exec = require('cordova/exec');
@@ -4614,11 +5800,10 @@
* @param errorCallback invoked if error occurs retrieving file system entry
*/
module.exports = function(uri, successCallback, errorCallback) {
+ argscheck.checkArgs('sFF', 'resolveLocalFileSystemURI', arguments);
// error callback
var fail = function(error) {
- if (typeof errorCallback === 'function') {
- errorCallback(new FileError(error));
- }
+ errorCallback && errorCallback(new FileError(error));
};
// sanity check for 'not:valid:filename'
if(!uri || uri.split(":").length > 2) {
@@ -4631,15 +5816,10 @@
var success = function(entry) {
var result;
if (entry) {
- if (typeof successCallback === 'function') {
+ if (successCallback) {
// create appropriate Entry object
result = (entry.isDirectory) ? new DirectoryEntry(entry.name, entry.fullPath) : new FileEntry(entry.name, entry.fullPath);
- try {
- successCallback(result);
- }
- catch (e) {
- console.log('Error invoking callback: ' + e);
- }
+ successCallback(result);
}
}
else {
@@ -4655,6 +5835,7 @@
// file: lib/common/plugin/splashscreen.js
define("cordova/plugin/splashscreen", function(require, exports, module) {
+
var exec = require('cordova/exec');
var splashscreen = {
@@ -4667,64 +5848,106 @@
};
module.exports = splashscreen;
+
+});
+
+// file: lib/tizen/plugin/splashscreen/symbol.js
+define("cordova/plugin/splashscreen/symbol", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/tizen/SplashScreen', 'splashscreen'); /// is that correct??? PPL
+
+});
+
+// file: lib/common/plugin/splashscreen/symbols.js
+define("cordova/plugin/splashscreen/symbols", function(require, exports, module) {
+
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.clobbers('cordova/plugin/splashscreen', 'navigator.splashscreen');
+
});
// file: lib/tizen/plugin/tizen/Accelerometer.js
define("cordova/plugin/tizen/Accelerometer", function(require, exports, module) {
-var callback = null;
+
+var accelerometerCallback = null;
+
+//console.log("TIZEN ACCELEROMETER START");
module.exports = {
+
start: function (successCallback, errorCallback) {
- window.removeEventListener("devicemotion", callback);
- callback = function (motion) {
+
+ if (accelerometerCallback) {
+ window.removeEventListener("devicemotion", accelerometerCallback, true);
+ }
+
+ accelerometerCallback = function (motion) {
successCallback({
x: motion.accelerationIncludingGravity.x,
y: motion.accelerationIncludingGravity.y,
z: motion.accelerationIncludingGravity.z,
- timestamp: motion.timeStamp
+ timestamp: new Date().getTime()
});
};
- window.addEventListener("devicemotion", callback);
+ window.addEventListener("devicemotion", accelerometerCallback, true);
},
+
stop: function (successCallback, errorCallback) {
- window.removeEventListener("devicemotion", callback);
+ window.removeEventListener("devicemotion", accelerometerCallback, true);
+ accelerometerCallback = null;
}
};
+
+//console.log("TIZEN ACCELEROMETER END");
+
+
});
// file: lib/tizen/plugin/tizen/Battery.js
define("cordova/plugin/tizen/Battery", function(require, exports, module) {
+
/*global tizen:false */
-var id = null;
+var batteryListenerId = null;
+
+//console.log("TIZEN BATTERY START");
module.exports = {
start: function(successCallback, errorCallback) {
- var tizenSuccessCallback = function(power) {
+ var batterySuccessCallback = function(power) {
if (successCallback) {
successCallback({level: Math.round(power.level * 100), isPlugged: power.isCharging});
}
};
- if (id === null) {
- id = tizen.systeminfo.addPropertyValueChangeListener("Power", tizenSuccessCallback);
+ if (batteryListenerId === null) {
+ batteryListenerId = tizen.systeminfo.addPropertyValueChangeListener("BATTERY", batterySuccessCallback);
}
- tizen.systeminfo.getPropertyValue("Power", tizenSuccessCallback, errorCallback);
+
+ tizen.systeminfo.getPropertyValue("BATTERY", batterySuccessCallback, errorCallback);
},
stop: function(successCallback, errorCallback) {
- tizen.systeminfo.removePropertyValueChangeListener(id);
- id = null;
+ tizen.systeminfo.removePropertyValueChangeListener(batteryListenerId);
+ batteryListenerId = null;
}
};
+//console.log("TIZEN BATTERY END");
+
});
// file: lib/tizen/plugin/tizen/BufferLoader.js
define("cordova/plugin/tizen/BufferLoader", function(require, exports, module) {
+
/*
* Buffer Loader Object
* This class provides a sound buffer for one or more sounds
- * holded in a local file located by an url
+ * held in a local file located by an url
*
* uses W3C Web Audio API
*
@@ -4812,15 +6035,21 @@
// file: lib/tizen/plugin/tizen/Camera.js
define("cordova/plugin/tizen/Camera", function(require, exports, module) {
+
/*global tizen:false */
var Camera = require('cordova/plugin/CameraConstants');
-function makeReplyCallback(successCallback, errorCallback) {
+
+//console.log("TIZEN CAMERA START");
+
+
+function cameraMakeReplyCallback(successCallback, errorCallback) {
return {
onsuccess: function(reply) {
if (reply.length > 0) {
successCallback(reply[0].value);
- } else {
+ }
+ else {
errorCallback('Picture selection aborted');
}
},
@@ -4836,6 +6065,7 @@
sourceType = args[2],
encodingType = args[5],
mediaType = args[6];
+
// Not supported
/*
quality = args[0]
@@ -4846,63 +6076,84 @@
saveToPhotoAlbum = args[9]
*/
- if (destinationType !== Camera.DestinationType.FILE_URI) {
- errorCallback('DestinationType not supported');
- return;
- }
- if (mediaType !== Camera.MediaType.PICTURE) {
- errorCallback('MediaType not supported');
- return;
- }
+ if (destinationType !== Camera.DestinationType.FILE_URI) {
+ errorCallback('DestinationType not supported');
+ return;
+ }
- var mimeType;
- if (encodingType === Camera.EncodingType.JPEG) {
- mimeType = 'image/jpeg';
- } else if (encodingType === Camera.EncodingType.PNG) {
- mimeType = 'image/png';
- } else {
- mimeType = 'image/*';
- }
+ if (mediaType !== Camera.MediaType.PICTURE) {
+ errorCallback('MediaType not supported');
+ return;
+ }
- var serviceId;
- if (sourceType === Camera.PictureSourceType.CAMERA) {
- serviceId = 'http://tizen.org/appsvc/operation/create_content';
- } else {
- serviceId = 'http://tizen.org/appsvc/operation/pick';
- }
+ var mimeType;
+ if (encodingType === Camera.EncodingType.JPEG) {
+ mimeType = 'image/jpeg';
+ }
+ else if (encodingType === Camera.EncodingType.PNG) {
+ mimeType = 'image/png';
+ }
+ else {
+ mimeType = 'image/*';
+ }
- var service = new tizen.ApplicationService(serviceId, null, mimeType, null);
- tizen.application.launchService(service, null, null,
- function(error) { errorCallback(error.message); },
- makeReplyCallback(successCallback, errorCallback));
- }
+ var serviceId;
+ if (sourceType === Camera.PictureSourceType.CAMERA) {
+ serviceId = 'http://tizen.org/appcontrol/operation/create_content';
+ }
+ else {
+ serviceId = 'http://tizen.org/appcontrol/operation/pick';
+ }
+
+ var serviceControl = new tizen.ApplicationControl(
+ serviceId,
+ null,
+ mimeType,
+ null);
+
+ tizen.application.launchAppControl(
+ serviceControl,
+ null,
+ null,
+ function(error) {
+ errorCallback(error.message);
+ },
+ cameraMakeReplyCallback(successCallback, errorCallback)
+ );
+ }
};
+//console.log("TIZEN CAMERA END");
+
});
// file: lib/tizen/plugin/tizen/Compass.js
define("cordova/plugin/tizen/Compass", function(require, exports, module) {
+
var CompassError = require('cordova/plugin/CompassError'),
- callback = null, ready = false;
+ CompassHeading = require('cordova/plugin/CompassHeading');
+
+var compassCallback = null,
+ compassReady = false;
+
+//console.log("TIZEN COMPASS START");
module.exports = {
getHeading: function(successCallback, errorCallback) {
+
if (window.DeviceOrientationEvent !== undefined) {
- callback = function (orientation) {
+
+ compassCallback = function (orientation) {
var heading = 360 - orientation.alpha;
- if (ready) {
- successCallback({
- magneticHeading: heading,
- trueHeading: heading,
- headingAccuracy: 0,
- timestamp: orientation.timeStamp
- });
- window.removeEventListener("deviceorientation", callback);
+
+ if (compassReady) {
+ successCallback( new CompassHeading (heading, heading, 0, 0));
+ window.removeEventListener("deviceorientation", compassCallback, true);
}
- ready = true;
+ compassReady = true;
};
- ready = false; // workaround invalid first event value returned by WRT
- window.addEventListener("deviceorientation", callback);
+ compassReady = false; // workaround invalid first event value returned by WRT
+ window.addEventListener("deviceorientation", compassCallback, true);
}
else {
errorCallback(CompassError.COMPASS_NOT_SUPPORTED);
@@ -4910,19 +6161,31 @@
}
};
+//console.log("TIZEN COMPASS END");
+
+
});
// file: lib/tizen/plugin/tizen/Contact.js
define("cordova/plugin/tizen/Contact", function(require, exports, module) {
+
/*global tizen:false */
+//var ContactError = require('cordova/plugin/ContactError'),
+// ContactUtils = require('cordova/plugin/tizen/ContactUtils');
+
+// ------------------
+// Utility functions
+// ------------------
+
+
+//console.log("TIZEN CONTACT START");
+
+
var ContactError = require('cordova/plugin/ContactError'),
ContactUtils = require('cordova/plugin/tizen/ContactUtils'),
utils = require('cordova/utils'),
exec = require('cordova/exec');
-// ------------------
-// Utility functions
-// ------------------
/**
@@ -4957,20 +6220,30 @@
var traceTizenContact = function (tizenContact) {
console.log("cordova/plugin/tizen/Contact/ tizenContact.id " + tizenContact.id);
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.personId " + tizenContact.personId); //Tizen 2.0
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.addressBookId " + tizenContact.addressBookId); //Tizen 2.0
+
console.log("cordova/plugin/tizen/Contact/ tizenContact.lastUpdated " + tizenContact.lastUpdated);
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.isFavorite " + tizenContact.isFavorite); //Tizen 2.0
+
console.log("cordova/plugin/tizen/Contact/ tizenContact.name " + tizenContact.name);
- console.log("cordova/plugin/tizen/Contact/ tizenContact.account " + tizenContact.account);
+
+ //console.log("cordova/plugin/tizen/Contact/ tizenContact.account " + tizenContact.account); //Tizen 2.0
+
console.log("cordova/plugin/tizen/Contact/ tizenContact.addresses " + tizenContact.addresses);
console.log("cordova/plugin/tizen/Contact/ tizenContact.photoURI " + tizenContact.photoURI);
console.log("cordova/plugin/tizen/Contact/ tizenContact.phoneNumbers " + tizenContact.phoneNumbers);
console.log("cordova/plugin/tizen/Contact/ tizenContact.emails " + tizenContact.emails);
console.log("cordova/plugin/tizen/Contact/ tizenContact.birthday " + tizenContact.birthday);
- console.log("cordova/plugin/tizen/Contact/ tizenContact.organization " + tizenContact.organization);
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.anniversaries " + tizenContact.anniversaries);
+
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.organizations " + tizenContact.organizations);
console.log("cordova/plugin/tizen/Contact/ tizenContact.notes " + tizenContact.notes);
- console.log("cordova/plugin/tizen/Contact/ tizenContact.urls " + tizenContact.isFavorite);
- console.log("cordova/plugin/tizen/Contact/ tizenContact.isFavorite " + tizenContact.isFavorite);
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.urls " + tizenContact.urls);
console.log("cordova/plugin/tizen/Contact/ tizenContact.ringtonesURI " + tizenContact.ringtonesURI);
- console.log("cordova/plugin/tizen/Contact/ tizenContact.categories " + tizenContact.categories);
+ console.log("cordova/plugin/tizen/Contact/ tizenContact.groupIds " + tizenContact.groupIds); //Tizen 2.0
+
+ //console.log("cordova/plugin/tizen/Contact/ tizenContact.categories " + tizenContact.categories); //Tizen 2.0
};
@@ -5069,6 +6342,16 @@
tizenContact.name.prefix = contact.name.honorificPrefix;
}
}
+
+ //Tizen 2.0
+ if (contact.name.honorificSuffix) {
+ if (tizenContact.name === null) {
+ tizenContact.name = new tizen.ContactName();
+ }
+ if (tizenContact.name !== null) {
+ tizenContact.name.suffix = contact.name.honorificSuffix;
+ }
+ }
}
// nickname
@@ -5088,18 +6371,18 @@
tizenContact.name.nicknames = [];
}
- // note
+ // notes - Tizen 2.0 (was note)
if (contact.note !== null) {
- if (tizenContact.note === null) {
- tizenContact.note = [];
+ if (tizenContact.notes === null) {
+ tizenContact.notes = [];
}
- if (tizenContact.note !== null) {
- tizenContact.note[0] = contact.note;
+ if (tizenContact.notes !== null) {
+ tizenContact.notes[0] = contact.note;
}
}
// photos
- if (contact.photos && utils.isArray(contact.emails) && contact.emails.length > 0) {
+ if (contact.photos && utils.isArray(contact.photos) && contact.photos.length > 0) {
tizenContact.photoURI = contact.photos[0];
}
@@ -5112,7 +6395,7 @@
}
}
- // Tizen supports many addresses
+ // Tizen supports many email addresses
if (utils.isArray(contact.emails)) {
// if this is an update, re initialize email addresses
@@ -5127,15 +6410,12 @@
emailTypes.push (contact.emails[i].type);
- if (contact.emails[i].pref) {
- emailTypes.push ("PREF");
- }
-
emails.push(
new tizen.ContactEmailAddress(
contact.emails[i].value,
- emailTypes)
- );
+ emailTypes,
+ contact.emails[i].pref)); //Tizen 2.0
+
}
tizenContact.emails = emails.length > 0 ? emails : [];
}
@@ -5154,26 +6434,25 @@
for (i = 0; i < contact.phoneNumbers.length; i += 1) {
- if (!contact.phoneNumbers[i] || !contact.phoneNumbers[i].value) {
+ if (!contact.phoneNumbers[i]) {
continue;
}
- var phoneTypes = [];
- phoneTypes.push (contact.phoneNumbers[i].type);
+ var phoneTypes = [];
+ phoneTypes.push (contact.phoneNumbers[i].type);
- if (contact.phoneNumbers[i].pref) {
- phoneTypes.push ("PREF");
- }
phoneNumbers.push(
new tizen.ContactPhoneNumber(
contact.phoneNumbers[i].value,
- phoneTypes)
+ phoneTypes,
+ contact.phoneNumbers[i].pref) //Tizen 2.0
);
}
tizenContact.phoneNumbers = phoneNumbers.length > 0 ? phoneNumbers : [];
- } else {
+ }
+ else {
tizenContact.phoneNumbers = [];
}
@@ -5188,17 +6467,13 @@
for ( i = 0; i < contact.addresses.length; i += 1) {
address = contact.addresses[i];
- if (!address || address.id === undefined || address.pref === undefined || address.type === undefined || address.formatted === undefined) {
+ if (!address) {
continue;
}
var addressTypes = [];
addressTypes.push (address.type);
- if (address.pref) {
- addressTypes.push ("PREF");
- }
-
addresses.push(
new tizen.ContactAddress({
country: address.country,
@@ -5207,17 +6482,19 @@
streetAddress: address.streetAddress,
additionalInformation: "",
postalCode: address.postalCode,
+ isDefault: address.pref, //Tizen 2.0
types : addressTypes
}));
}
tizenContact.addresses = addresses.length > 0 ? addresses : [];
- } else{
+ }
+ else{
tizenContact.addresses = [];
}
- // copy first url found to BlackBerry 'webpage' field
+ // copy first url found to cordova 'urls' field
if (utils.isArray(contact.urls)) {
// if this is an update, re-initialize web page
if (update) {
@@ -5236,22 +6513,41 @@
urls.push( new tizen.ContactWebSite(url.value, url.type));
}
tizenContact.urls = urls.length > 0 ? urls : [];
- } else{
+ }
+ else{
tizenContact.urls = [];
}
- if (utils.isArray(contact.organizations && contact.organizations.length > 0) ) {
- // if this is an update, re-initialize org attributes
- var organization = contact.organizations[0];
+ if (utils.isArray(contact.organizations) && contact.organizations.length > 0 ) {
+ // if this is an update, re-initialize addresses
+ if (update) {
+ }
- tizenContact.organization = new tizen.ContacOrganization({
- name: organization.name,
- department: organization.department,
- office: "",
- title: organization.title,
- role: "",
- logoURI: ""
- });
+ var organizations = [],
+ organization = null;
+
+ for ( i = 0; i < contact.organizations.length; i += 1) {
+ organization = contact.organizations[i];
+
+ if (!organization) {
+ continue;
+ }
+
+ organizations.push(
+ new tizen.ContactOrganization({
+ name: organization.name,
+ department: organization.department,
+ title: organization.title,
+ role: "",
+ logoURI: ""
+ }));
+
+ }
+ tizenContact.organizations = organizations.length > 0 ? organizations : [];
+
+ }
+ else{
+ tizenContact.organizations = [];
}
// categories
@@ -5303,7 +6599,6 @@
return null;
}
-
var tizenAddress = new tizen.ContactAddress();
if (tizenAddress === null) {
@@ -5312,15 +6607,12 @@
typesAr.push(address.type);
- if (address.pref) {
- typesAr.push("PREF");
- }
-
tizenAddress.country = address.country || "";
tizenAddress.region = address.region || "";
tizenAddress.city = address.locality || "";
tizenAddress.streetAddress = address.streetAddress || "";
tizenAddress.postalCode = address.postalCode || "";
+ tizenAddress.isDefault = address.pref || false; //Tizen SDK 2.0
tizenAddress.types = typesAr || "";
return tizenAddress;
@@ -5377,11 +6669,12 @@
tizenContact = findByUniqueId(this.id);
}
-
// if contact was found, remove it
if (tizenContact) {
+ //var addressBook = tizen.contact.getDefaultAddressBook();
+ var addressBook = tizen.contact.getAddressBook(tizenContact.addressBookId); //Tizen SDk 2.0
- tizen.contact.getDefaultAddressBook().remove(tizenContact.id);
+ addressBook.remove(tizenContact.id);
if (typeof success === 'function') {
successCB(this);
@@ -5401,17 +6694,22 @@
}
};
+//console.log("TIZEN CONTACT END");
+
});
// file: lib/tizen/plugin/tizen/ContactUtils.js
define("cordova/plugin/tizen/ContactUtils", function(require, exports, module) {
+
/*global tizen:false */
-var ContactAddress = require('cordova/plugin/ContactAddress'),
+var Contact = require('cordova/plugin/Contact'),
+ ContactAddress = require('cordova/plugin/ContactAddress'),
ContactName = require('cordova/plugin/ContactName'),
ContactField = require('cordova/plugin/ContactField'),
ContactOrganization = require('cordova/plugin/ContactOrganization'),
- utils = require('cordova/utils'),
- Contact = require('cordova/plugin/Contact');
+ utils = require('cordova/utils');
+
+
/**
* Mappings for each Contact field that may be used in a find operation. Maps
@@ -5433,11 +6731,10 @@
"phoneNumbers" : ["phoneNumbers.number","phoneNumbers.types"],
"emails" : ["emails.types", "emails.email"],
"addresses" : ["addresses.country","addresses.region","addresses.city","addresses.streetAddress","addresses.postalCode","addresses.country","addresses.types"],
- "organizations" : ["organization.name","organization.department","organization.office", "organization.title"],
+ "organizations" : ["organizations.name","organizations.department","organizations.office", "organizations.title"],
"birthday" : ["birthday"],
"note" : ["notes"],
"photos" : ["photoURI"],
- "categories" : ["categories"],
"urls" : ["urls.url", "urls.type"]
};
@@ -5447,15 +6744,10 @@
*/
var allFields = [];
-(function initializeAllFieldsMapping() {
-
+(function() {
for ( var key in fieldMappings) {
allFields.push(key);
}
- // as we want it to be executed once
- function initializeAllFieldsMapping() {
- }
-
})();
/**
@@ -5473,14 +6765,17 @@
return null;
}
+ var isDefault = tizenAddress.isDefault; //Tizen 2.0
var streetAddress = tizenAddress.streetAddress;
var locality = tizenAddress.city || "";
var region = tizenAddress.region || "";
var postalCode = tizenAddress.postalCode || "";
var country = tizenAddress.country || "";
+
+ //TODO improve formatted
var formatted = streetAddress + ", " + locality + ", " + region + ", " + postalCode + ", " + country;
- var contact = new ContactAddress(null, type, formatted, streetAddress, locality, region, postalCode, country);
+ var contact = new ContactAddress(isDefault, type, formatted, streetAddress, locality, region, postalCode, country);
return contact;
};
@@ -5547,7 +6842,7 @@
}
}
- // fullfil tizen find attribute as a single or a composite attribute
+ // fulfill Tizen find attribute as a single or a composite attribute
if (attributesArray.length == 1 ) {
filterExpression = attributeFilter[0];
} else if (attributesArray.length > 1) {
@@ -5561,7 +6856,6 @@
},
-
/**
* Creates a Contact object from a Tizen Contact object, copying only
* the fields specified.
@@ -5591,7 +6885,8 @@
// nothing to do
if (!fields || !(utils.isArray(fields)) || fields.length === 0) {
return contact;
- } else if (fields.length === 1 && fields[0] === "*") {
+ }
+ else if (fields.length === 1 && fields[0] === "*") {
// Cordova enhancement to allow fields value of ["*"] to indicate
// all supported fields.
fields = allFields;
@@ -5609,7 +6904,6 @@
// name
if (field.indexOf('name') === 0) {
-
var formattedName = (tizenContact.name.prefix || "");
if (tizenContact.name.firstName) {
@@ -5627,67 +6921,64 @@
formattedName += (tizenContact.name.lastName || "");
}
+ //Tizen 2.0
+ if (tizenContact.name.suffix) {
+ formattedName += ' ';
+ formattedName += (tizenContact.name.suffix || "");
+ }
+
contact.name = new ContactName(
formattedName,
tizenContact.name.lastName,
tizenContact.name.firstName,
tizenContact.name.middleName,
tizenContact.name.prefix,
- null);
+ tizenContact.name.suffix);
}
-
- // phoneNumbers
+ // phoneNumbers - Tizen 2.0
else if (field.indexOf('phoneNumbers') === 0) {
-
var phoneNumbers = [];
for (index = 0 ; index < tizenContact.phoneNumbers.length ; ++index) {
-
phoneNumbers.push(
- new ContactField(
- 'PHONE',
- tizenContact.phoneNumbers[index].number,
- ((tizenContact.phoneNumbers[index].types[1]) && (tizenContact.emails[index].types[1] === "PREF") ) ? true : false));
+ new ContactField(
+ 'PHONE',
+ tizenContact.phoneNumbers[index].number,
+ tizenContact.phoneNumbers[index].isDefault));
}
-
-
contact.phoneNumbers = phoneNumbers.length > 0 ? phoneNumbers : null;
}
- // emails
+ // emails - Tizen 2.0
else if (field.indexOf('emails') === 0) {
-
var emails = [];
for (index = 0 ; index < tizenContact.emails.length ; ++index) {
-
emails.push(
new ContactField(
'EMAILS',
tizenContact.emails[index].email,
- ((tizenContact.emails[index].types[1]) && (tizenContact.emails[index].types[1] === "PREF") ) ? true : false));
+ tizenContact.emails[index].isDefault));
}
contact.emails = emails.length > 0 ? emails : null;
}
- // addresses
+ // addresses Tizen 2.0
else if (field.indexOf('addresses') === 0) {
-
var addresses = [];
+
for (index = 0 ; index < tizenContact.addresses.length ; ++index) {
-
addresses.push(
- new ContactAddress(
- ((tizenContact.addresses[index].types[1] && tizenContact.addresses[index].types[1] === "PREF") ? true : false),
- tizenContact.addresses[index].types[0] ? tizenContact.addresses[index].types[0] : "HOME",
- null,
- tizenContact.addresses[index].streetAddress,
- tizenContact.addresses[index].city,
- tizenContact.addresses[index].region,
- tizenContact.addresses[index].postalCode,
- tizenContact.addresses[index].country ));
+ new ContactAddress(
+ tizenContact.addresses[index].isDefault,
+ tizenContact.addresses[index].types[0] ? tizenContact.addresses[index].types[0] : "HOME",
+ null,
+ tizenContact.addresses[index].streetAddress,
+ tizenContact.addresses[index].city,
+ tizenContact.addresses[index].region,
+ tizenContact.addresses[index].postalCode,
+ tizenContact.addresses[index].country ));
}
-
contact.addresses = addresses.length > 0 ? addresses : null;
}
@@ -5698,52 +6989,28 @@
}
}
- // note only one in Tizen Contact
+ // note only one in Tizen Contact -Tizen 2.0
else if (field.indexOf('note') === 0) {
- if (tizenContact.note) {
- contact.note = tizenContact.note[0];
+ if (tizenContact.notes) {
+ contact.note = tizenContact.notes[0];
}
}
-
- // organizations
+ // organizations Tizen 2.0
else if (field.indexOf('organizations') === 0) {
-
var organizations = [];
- // there's only one organization in a Tizen Address
-
- if (tizenContact.organization) {
+ for (index = 0 ; index < tizenContact.organizations.length ; ++index) {
organizations.push(
new ContactOrganization(
- true,
+ (index === 0),
'WORK',
- tizenContact.organization.name,
- tizenContact.organization.department,
- tizenContact.organization.jobTitle));
+ tizenContact.organizations.name,
+ tizenContact.organizations.department,
+ tizenContact.organizations.jobTitle));
}
-
contact.organizations = organizations.length > 0 ? organizations : null;
}
- // categories
- else if (field.indexOf('categories') === 0) {
-
- var categories = [];
-
- if (tizenContact.categories) {
-
- for (index = 0 ; index < tizenContact.categories.length ; ++index) {
- categories.push(
- new ContactField(
- 'MAIN',
- tizenContact.categories,
- (index === 0) ));
- }
-
- contact.categories = categories.length > 0 ? categories : null;
- }
- }
-
// urls
else if (field.indexOf('urls') === 0) {
var urls = [];
@@ -5757,7 +7024,6 @@
(index === 0)));
}
}
-
contact.urls = urls.length > 0 ? urls : null;
}
@@ -5768,7 +7034,6 @@
if (tizenContact.photoURI) {
photos.push(new ContactField('URI', tizenContact.photoURI, true));
}
-
contact.photos = photos.length > 0 ? photos : null;
}
}
@@ -5781,47 +7046,56 @@
// file: lib/tizen/plugin/tizen/Device.js
define("cordova/plugin/tizen/Device", function(require, exports, module) {
+
/*global tizen:false */
var channel = require('cordova/channel');
-// Tell cordova channel to wait on the CordovaInfoReady event
-channel.waitForInitialization('onCordovaInfoReady');
+//console.log("TIZEN DEVICE START");
+
+
+// Tell cordova channel to wait on the CordovaInfoReady event - PPL is this useful?
+//channel.waitForInitialization('onCordovaInfoReady');
function Device() {
- this.version = null;
+ this.version = "2.1.0"; // waiting a working solution of the security error see below
this.uuid = null;
- this.name = null;
- this.cordova = "2.0.0";
+ this.model = null;
+ this.cordova = CORDOVA_JS_BUILD_LABEL;
this.platform = "Tizen";
-
- var me = this;
-
- function onSuccessCallback(sysInfoProp) {
- me.name = sysInfoProp.model;
- me.uuid = sysInfoProp.imei;
- me.version = sysInfoProp.version;
- channel.onCordovaInfoReady.fire();
- }
-
- function onErrorCallback(error) {
- console.log("error initializing cordova: " + error);
- }
-
- channel.onCordovaReady.subscribeOnce(function() {
- me.getDeviceInfo(onSuccessCallback, onErrorCallback);
- });
+
+ this.getDeviceInfo();
}
-Device.prototype.getDeviceInfo = function(success, fail, args) {
- tizen.systeminfo.getPropertyValue("Device", success, fail);
+Device.prototype.getDeviceInfo = function() {
+
+ var deviceCapabilities = tizen.systeminfo.getCapabilities();
+
+ if (deviceCapabilities) {
+ this.version = deviceCapabilities.platformVersion; // requires http://tizen.org/privilege/system (and not "systeminfo") privileges to be added in config.xml
+ this.uuid = deviceCapabilities.duid;
+ this.model = deviceCapabilities.platformName;
+
+ channel.onCordovaInfoReady.fire();
+ }
+ else {
+ console.log("error initializing cordova: ");
+ }
};
module.exports = new Device();
+//console.log("TIZEN DEVICE END");
+
+
+
});
// file: lib/tizen/plugin/tizen/File.js
define("cordova/plugin/tizen/File", function(require, exports, module) {
+
+
+//console.log("TIZEN FILE START");
+
/*global WebKitBlobBuilder:false */
var FileError = require('cordova/plugin/FileError'),
DirectoryEntry = require('cordova/plugin/DirectoryEntry'),
@@ -5847,341 +7121,578 @@
}
module.exports = {
- /* requestFileSystem */
+ /* common/equestFileSystem.js, args = [type, size] */
requestFileSystem: function(successCallback, errorCallback, args) {
var type = args[0],
size = args[1];
- nativeRequestFileSystem(type, size, function(nativeFs) {
- successCallback(new FileSystem(getFileSystemName(nativeFs), makeEntry(nativeFs.root)));
- }, function(error) {
- errorCallback(error.code);
- });
+ nativeRequestFileSystem(
+ type,
+ size,
+ function(nativeFs) {
+ successCallback(new FileSystem(getFileSystemName(nativeFs), makeEntry(nativeFs.root)));
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
},
- /* resolveLocalFileSystemURI */
+ /* common/resolveLocalFileSystemURI.js, args= [uri] */
resolveLocalFileSystemURI: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
},
- /* DirectoryReader */
+ /* common/DirectoryReader.js, args = [this.path] */
readEntries: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(dirEntry) {
- var reader = dirEntry.createReader();
- reader.readEntries(function(entries) {
- var retVal = [];
- for (var i = 0; i < entries.length; i++) {
- retVal.push(makeEntry(entries[i]));
- }
- successCallback(retVal);
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(dirEntry) {
+ var reader = dirEntry.createReader();
+
+ reader.readEntries(
+ function(entries) {
+ var retVal = [];
+ for (var i = 0; i < entries.length; i++) {
+ retVal.push(makeEntry(entries[i]));
+ }
+ successCallback(retVal);
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
- /* Entry */
+ /* common/Entry.js , args = [this.fullPath] */
getMetadata: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getMetadata(function(metaData) {
- successCallback(metaData.modificationTime);
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ entry.getMetadata(
+ function(metaData) {
+ successCallback(metaData.modificationTime);
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
+ /* args = [this.fullPath, metadataObject] */
+ /* PPL to be implemented */
+ setMetadata: function(successCallback, errorCallback, args) {
+ var uri = args[0],
+ metadata = args[1];
+
+ if (errorCallback) {
+ errorCallback(FileError.NOT_FOUND_ERR);
+ }
+ },
+
+
+ /* args = [srcPath, parent.fullPath, name] */
moveTo: function(successCallback, errorCallback, args) {
var srcUri = args[0],
parentUri = args[1],
name = args[2];
- nativeResolveLocalFileSystemURI(srcUri, function(source) {
- nativeResolveLocalFileSystemURI(parentUri, function(parent) {
- source.moveTo(parent, name, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ srcUri,
+ function(source) {
+ nativeResolveLocalFileSystemURI(
+ parentUri,
+ function(parent) {
+ source.moveTo(
+ parent,
+ name,
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
+ /* args = [srcPath, parent.fullPath, name] */
copyTo: function(successCallback, errorCallback, args) {
var srcUri = args[0],
parentUri = args[1],
name = args[2];
- nativeResolveLocalFileSystemURI(srcUri, function(source) {
- nativeResolveLocalFileSystemURI(parentUri, function(parent) {
- source.copyTo(parent, name, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- errorCallback(error.code);
- });
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ srcUri,
+ function(source) {
+ nativeResolveLocalFileSystemURI(
+ parentUri,
+ function(parent) {
+ source.copyTo(
+ parent,
+ name,
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
+
+ /* args = [this.fullPath] */
remove: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- if (entry.fullPath === "/") {
- errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
- } else {
- entry.remove(successCallback, function(error) {
- errorCallback(error.code);
- });
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ if (entry.fullPath === "/") {
+ errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ else {
+ entry.remove(
+ successCallback,
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ }
+ },
+ function(error) {
+ errorCallback(error.code);
}
- }, function(error) {
- errorCallback(error.code);
- });
+ );
},
+ /* args = [this.fullPath] */
getParent: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getParent(function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ entry.getParent(
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
- /* FileEntry */
+ /* common/FileEntry.js, args = [this.fullPath] */
getFileMetadata: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.file(function(file) {
- var retVal = new File(file.name, decodeURI(entry.toURL()), file.type, file.lastModifiedDate, file.size);
- successCallback(retVal);
- }, function(error) {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ entry.file(
+ function(file) {
+ var retVal = new File(file.name, decodeURI(entry.toURL()), file.type, file.lastModifiedDate, file.size);
+ successCallback(retVal);
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
- /* DirectoryEntry */
+ /* common/DirectoryEntry.js , args = [this.fullPath, path, options] */
getDirectory: function(successCallback, errorCallback, args) {
var uri = args[0],
path = args[1],
options = args[2];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getDirectory(path, options, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- if (error.code === FileError.INVALID_MODIFICATION_ERR) {
- if (options.create) {
- errorCallback(FileError.PATH_EXISTS_ERR);
- } else {
- errorCallback(FileError.ENCODING_ERR);
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ entry.getDirectory(
+ path,
+ options,
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ if (error.code === FileError.INVALID_MODIFICATION_ERR) {
+ if (options.create) {
+ errorCallback(FileError.PATH_EXISTS_ERR);
+ }
+ else {
+ errorCallback(FileError.ENCODING_ERR);
+ }
+ }
+ else {
+ errorCallback(error.code);
+ }
}
- } else {
- errorCallback(error.code);
- }
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
},
+ /* args = [this.fullPath] */
removeRecursively: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- if (entry.fullPath === "/") {
- errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
- } else {
- entry.removeRecursively(successCallback, function(error) {
- errorCallback(error.code);
- });
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ if (entry.fullPath === "/") {
+ errorCallback(FileError.NO_MODIFICATION_ALLOWED_ERR);
+ }
+ else {
+ entry.removeRecursively(
+ successCallback,
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ }
+ },
+ function(error) {
+ errorCallback(error.code);
}
- }, function(error) {
- errorCallback(error.code);
- });
+ );
},
+ /* args = [this.fullPath, path, options] */
getFile: function(successCallback, errorCallback, args) {
var uri = args[0],
path = args[1],
options = args[2];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- entry.getFile(path, options, function(entry) {
- successCallback(makeEntry(entry));
- }, function(error) {
- if (error.code === FileError.INVALID_MODIFICATION_ERR) {
- if (options.create) {
- errorCallback(FileError.PATH_EXISTS_ERR);
- } else {
- errorCallback(FileError.ENCODING_ERR);
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ entry.getFile(
+ path,
+ options,
+ function(entry) {
+ successCallback(makeEntry(entry));
+ },
+ function(error) {
+ if (error.code === FileError.INVALID_MODIFICATION_ERR) {
+ if (options.create) {
+ errorCallback(FileError.PATH_EXISTS_ERR);
+ }
+ else {
+ errorCallback(FileError.ENCODING_ERR);
+ }
+ }
+ else {
+ errorCallback(error.code);
+ }
}
- } else {
- errorCallback(error.code);
- }
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
},
- /* FileReader */
+ /* common/FileReader.js, args = execArgs = [filepath, encoding, file.start, file.end] */
readAsText: function(successCallback, errorCallback, args) {
var uri = args[0],
encoding = args[1];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onLoadEnd = function(evt) {
- if (!evt.target.error) {
- successCallback(evt.target.result);
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onLoadEnd = function(evt) {
+ if (!evt.target.error) {
+ successCallback(evt.target.result);
+ }
+ },
+ onError = function(evt) {
+ errorCallback(evt.target.error.code);
+ };
+
+ var reader = new NativeFileReader();
+
+ reader.onloadend = onLoadEnd;
+ reader.onerror = onError;
+
+ entry.file(
+ function(file) {
+ reader.readAsText(file, encoding);
+ },
+ function(error) {
+ errorCallback(error.code);
}
+ );
},
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- var reader = new NativeFileReader();
-
- reader.onloadend = onLoadEnd;
- reader.onerror = onError;
- entry.file(function(file) {
- reader.readAsText(file, encoding);
- }, function(error) {
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
+ /* args = execArgs = [this._fileName, file.start, file.end] */
readAsDataURL: function(successCallback, errorCallback, args) {
var uri = args[0];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onLoadEnd = function(evt) {
- if (!evt.target.error) {
- successCallback(evt.target.result);
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onLoadEnd = function(evt) {
+ if (!evt.target.error) {
+ successCallback(evt.target.result);
+ }
+ },
+ onError = function(evt) {
+ errorCallback(evt.target.error.code);
+ };
+
+ var reader = new NativeFileReader();
+
+ reader.onloadend = onLoadEnd;
+ reader.onerror = onError;
+ entry.file(
+ function(file) {
+ reader.readAsDataURL(file);
+ },
+ function(error) {
+ errorCallback(error.code);
}
+ );
},
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- var reader = new NativeFileReader();
-
- reader.onloadend = onLoadEnd;
- reader.onerror = onError;
- entry.file(function(file) {
- reader.readAsDataURL(file);
- }, function(error) {
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
- /* FileWriter */
+ /* args = execArgs = [this._fileName, file.start, file.end] */
+ /* PPL, to Be implemented , for now it is pasted from readAsText...*/
+ readAsBinaryString: function(successCallback, errorCallback, args) {
+ var uri = args[0];
+
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onLoadEnd = function(evt) {
+ if (!evt.target.error) {
+ successCallback(evt.target.result);
+ }
+ },
+ onError = function(evt) {
+ errorCallback(evt.target.error.code);
+ };
+
+ var reader = new NativeFileReader();
+
+ reader.onloadend = onLoadEnd;
+ reader.onerror = onError;
+
+ entry.file(
+ function(file) {
+ reader.readAsDataURL(file);
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+
+
+ /* args = execArgs = [this._fileName, file.start, file.end] */
+ /* PPL, to Be implemented , for now it is pasted from readAsText...*/
+ readAsArrayBuffer: function(successCallback, errorCallback, args) {
+ var uri = args[0];
+
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onLoadEnd = function(evt) {
+ if (!evt.target.error) {
+ successCallback(evt.target.result);
+ }
+ },
+ onError = function(evt) {
+ errorCallback(evt.target.error.code);
+ };
+
+ var reader = new NativeFileReader();
+
+ reader.onloadend = onLoadEnd;
+ reader.onerror = onError;
+
+ entry.file(
+ function(file) {
+ reader.readAsDataURL(file);
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+ function(error) {
+ errorCallback(error.code);
+ }
+ );
+ },
+
+ /* common/FileWriter.js, args = [this.fileName, text, this.position] */
write: function(successCallback, errorCallback, args) {
var uri = args[0],
text = args[1],
position = args[2];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onWriteEnd = function(evt) {
- if(!evt.target.error) {
- successCallback(evt.target.position - position);
- } else {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onWriteEnd = function(evt) {
+ if(!evt.target.error) {
+ successCallback(evt.target.position - position);
+ }
+ else {
+ errorCallback(evt.target.error.code);
+ }
+ },
+ onError = function(evt) {
errorCallback(evt.target.error.code);
+ };
+
+ entry.createWriter(
+ function(writer) {
+ var blob = new WebKitBlobBuilder();
+ blob.append(text);
+
+ writer.onwriteend = onWriteEnd;
+ writer.onerror = onError;
+
+ writer.seek(position);
+ writer.write(blob.getBlob('text/plain'));
+ },
+ function(error) {
+ errorCallback(error.code);
}
+ );
},
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- entry.createWriter(function(writer) {
- var blob = new WebKitBlobBuilder();
- blob.append(text);
-
- writer.onwriteend = onWriteEnd;
- writer.onerror = onError;
-
- writer.seek(position);
- writer.write(blob.getBlob('text/plain'));
- }, function(error) {
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
},
+ /* args = [this.fileName, size] */
truncate: function(successCallback, errorCallback, args) {
var uri = args[0],
size = args[1];
- nativeResolveLocalFileSystemURI(uri, function(entry) {
- var onWriteEnd = function(evt) {
- if(!evt.target.error) {
- successCallback(evt.target.length);
- } else {
+ nativeResolveLocalFileSystemURI(
+ uri,
+ function(entry) {
+ var onWriteEnd = function(evt) {
+ if(!evt.target.error) {
+ successCallback(evt.target.length);
+ }
+ else {
+ errorCallback(evt.target.error.code);
+ }
+ },
+ onError = function(evt) {
errorCallback(evt.target.error.code);
+ };
+
+ entry.createWriter(
+ function(writer) {
+ writer.onwriteend = onWriteEnd;
+ writer.onerror = onError;
+ writer.truncate(size);
+ },
+ function(error) {
+ errorCallback(error.code);
}
+ );
},
- onError = function(evt) {
- errorCallback(evt.target.error.code);
- };
-
- entry.createWriter(function(writer) {
- writer.onwriteend = onWriteEnd;
- writer.onerror = onError;
-
- writer.truncate(size);
- }, function(error) {
+ function(error) {
errorCallback(error.code);
- });
- }, function(error) {
- errorCallback(error.code);
- });
+ }
+ );
}
};
+
+//console.log("TIZEN FILE END");
+
+
});
// file: lib/tizen/plugin/tizen/FileTransfer.js
define("cordova/plugin/tizen/FileTransfer", function(require, exports, module) {
+
/*global WebKitBlobBuilder:false */
+
+
+//console.log("TIZEN FILE TRANSFER START");
+
var FileEntry = require('cordova/plugin/FileEntry'),
FileTransferError = require('cordova/plugin/FileTransferError'),
FileUploadResult = require('cordova/plugin/FileUploadResult');
@@ -6199,6 +7710,7 @@
}
module.exports = {
+ /* common/FileTransfer.js, args = [filePath, server, fileKey, fileName, mimeType, params, trustAllHosts, chunkedMode, headers, this._id, httpMethod] */
upload: function(successCallback, errorCallback, args) {
var filePath = args[0],
server = args[1],
@@ -6209,66 +7721,77 @@
/*trustAllHosts = args[6],*/
chunkedMode = args[7];
- nativeResolveLocalFileSystemURI(filePath, function(entry) {
- entry.file(function(file) {
- function uploadFile(blobFile) {
- var fd = new FormData();
+ nativeResolveLocalFileSystemURI(
+ filePath,
+ function(entry) {
+ entry.file(
+ function(file) {
+ function uploadFile(blobFile) {
+ var fd = new FormData();
- fd.append(fileKey, blobFile, fileName);
- for (var prop in params) {
- if(params.hasOwnProperty(prop)) {
- fd.append(prop, params[prop]);
+ fd.append(fileKey, blobFile, fileName);
+
+ for (var prop in params) {
+ if(params.hasOwnProperty(prop)) {
+ fd.append(prop, params[prop]);
+ }
+ }
+ var xhr = new XMLHttpRequest();
+
+ xhr.open("POST", server);
+
+ xhr.onload = function(evt) {
+ if (xhr.status == 200) {
+ var result = new FileUploadResult();
+ result.bytesSent = file.size;
+ result.responseCode = xhr.status;
+ result.response = xhr.response;
+ successCallback(result);
+ }
+ else if (xhr.status == 404) {
+ errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR));
+ }
+ else {
+ errorCallback(new FileTransferError(FileTransferError.CONNECTION_ERR));
+ }
+ };
+
+ xhr.ontimeout = function(evt) {
+ errorCallback(new FileTransferError(FileTransferError.CONNECTION_ERR));
+ };
+
+ xhr.send(fd);
}
+
+ var bytesPerChunk;
+
+ if (chunkedMode === true) {
+ bytesPerChunk = 1024 * 1024; // 1MB chunk sizes.
+ }
+ else {
+ bytesPerChunk = file.size;
+ }
+ var start = 0;
+ var end = bytesPerChunk;
+ while (start < file.size) {
+ var chunk = file.webkitSlice(start, end, mimeType);
+ uploadFile(chunk);
+ start = end;
+ end = start + bytesPerChunk;
+ }
+ },
+ function(error) {
+ errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
}
-
- var xhr = new XMLHttpRequest();
- xhr.open("POST", server);
- xhr.onload = function(evt) {
- if (xhr.status == 200) {
- var result = new FileUploadResult();
- result.bytesSent = file.size;
- result.responseCode = xhr.status;
- result.response = xhr.response;
- successCallback(result);
- } else if (xhr.status == 404) {
- errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR));
- } else {
- errorCallback(new FileTransferError(FileTransferError.CONNECTION_ERR));
- }
- };
- xhr.ontimeout = function(evt) {
- errorCallback(new FileTransferError(FileTransferError.CONNECTION_ERR));
- };
-
- xhr.send(fd);
- }
-
- var bytesPerChunk;
- if (chunkedMode === true) {
- bytesPerChunk = 1024 * 1024; // 1MB chunk sizes.
- } else {
- bytesPerChunk = file.size;
- }
- var start = 0;
- var end = bytesPerChunk;
- while (start < file.size) {
- var chunk = file.webkitSlice(start, end, mimeType);
- uploadFile(chunk);
- start = end;
- end = start + bytesPerChunk;
- }
+ );
},
function(error) {
errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
}
- );
- },
- function(error) {
- errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- }
);
},
+ /* args = [source, target, trustAllHosts, this._id, headers] */
download: function(successCallback, errorCallback, args) {
var url = args[0],
filePath = args[1];
@@ -6276,42 +7799,56 @@
var xhr = new XMLHttpRequest();
function writeFile(fileEntry) {
- fileEntry.createWriter(function(writer) {
- writer.onwriteend = function(evt) {
- if (!evt.target.error) {
- successCallback(new FileEntry(fileEntry.name, fileEntry.toURL()));
- } else {
+ fileEntry.createWriter(
+ function(writer) {
+ writer.onwriteend = function(evt) {
+ if (!evt.target.error) {
+ successCallback(new FileEntry(fileEntry.name, fileEntry.toURL()));
+ } else {
+ errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
+ }
+ };
+
+ writer.onerror = function(evt) {
errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- }
- };
+ };
- writer.onerror = function(evt) {
+ var builder = new WebKitBlobBuilder();
+ builder.append(xhr.response);
+
+ var blob = builder.getBlob();
+ writer.write(blob);
+ },
+ function(error) {
errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- };
-
- var builder = new WebKitBlobBuilder();
- builder.append(xhr.response);
- var blob = builder.getBlob();
- writer.write(blob);
- },
- function(error) {
- errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
+ }
+ );
}
xhr.onreadystatechange = function () {
if (xhr.readyState == xhr.DONE) {
if (xhr.status == 200 && xhr.response) {
- nativeResolveLocalFileSystemURI(getParentPath(filePath), function(dir) {
- dir.getFile(getFileName(filePath), {create: true}, writeFile, function(error) {
+ nativeResolveLocalFileSystemURI(
+ getParentPath(filePath),
+ function(dir) {
+ dir.getFile(
+ getFileName(filePath),
+ {create: true},
+ writeFile,
+ function(error) {
+ errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
+ }
+ );
+ },
+ function(error) {
errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
- }, function(error) {
- errorCallback(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR));
- });
- } else if (xhr.status == 404) {
+ }
+ );
+ }
+ else if (xhr.status == 404) {
errorCallback(new FileTransferError(FileTransferError.INVALID_URL_ERR));
- } else {
+ }
+ else {
errorCallback(new FileTransferError(FileTransferError.CONNECTION_ERR));
}
}
@@ -6320,66 +7857,590 @@
xhr.open("GET", url, true);
xhr.responseType = "arraybuffer";
xhr.send();
+ },
+
+
+ /* args = [this._id]); */
+ abort: function(successCallback, errorCallback, args) {
+ errorCallback(FileTransferError.ABORT_ERR);
}
+
};
+
+//console.log("TIZEN FILE TRANSFER END");
+
+
+});
+
+// file: lib/tizen/plugin/tizen/Globalization.js
+define("cordova/plugin/tizen/Globalization", function(require, exports, module) {
+
+
+/*global tizen:false */
+
+var argscheck = require('cordova/argscheck'),
+ exec = require('cordova/exec'),
+ GlobalizationError = require('cordova/plugin/GlobalizationError');
+
+var globalization = {
+
+/**
+* Returns the string identifier for the client's current language.
+* It returns the language identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the language,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The language identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getPreferredLanguage(function (language) {alert('language:' + language.value + '\n');},
+* function () {});
+*/
+getPreferredLanguage:function(successCB, failureCB) {
+ console.log('exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);');
+
+ tizen.systeminfo.getPropertyValue (
+ "LOCALE",
+ function (localeInfo) {
+ console.log("Cordova, getLocaleName, language is " + localeInfo.language);
+ successCB( {"value": localeInfo.language});
+ },
+ function(error) {
+ console.log("Cordova, getLocaleName, An error occurred " + error.message);
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot retrieve language name"));
+ }
+ );
+},
+
+/**
+* Returns the string identifier for the client's current locale setting.
+* It returns the locale identifier string to the successCB callback with a
+* properties object as a parameter. If there is an error getting the locale,
+* then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {String}: The locale identifier
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getLocaleName(function (locale) {alert('locale:' + locale.value + '\n');},
+* function () {});
+*/
+getLocaleName:function(successCB, failureCB) {
+ tizen.systeminfo.getPropertyValue (
+ "LOCALE",
+ function (localeInfo) {
+ console.log("Cordova, getLocaleName, locale name (country) is " + localeInfo.country);
+ successCB( {"value":localeInfo.language});
+ },
+ function(error) {
+ console.log("Cordova, getLocaleName, An error occurred " + error.message);
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot retrieve locale name"));
+ }
+ );
+},
+
+
+/**
+* Returns a date formatted as a string according to the client's user preferences and
+* calendar using the time zone of the client. It returns the formatted date string to the
+* successCB callback with a properties object as a parameter. If there is an error
+* formatting the date, then the errorCB callback is invoked.
+*
+* The defaults are: formatLenght="short" and selector="date and time"
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.value {String}: The localized date string
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.dateToString(new Date(),
+* function (date) {alert('date:' + date.value + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {formatLength:'short'});
+*/
+dateToString:function(date, successCB, failureCB, options) {
+ var dateValue = date.valueOf();
+ console.log('exec(successCB, failureCB, "Globalization", "dateToString", [{"date": dateValue, "options": options}]);');
+
+ var tzdate = null;
+ var format = null;
+
+ tzdate = new tizen.TZDate(date);
+
+ if (tzdate) {
+ if (options && (options.formatLength == 'short') ){
+ format = tzdate.toLocaleDateString();
+ }
+ else{
+ format = tzdate.toLocaleString();
+ }
+ console.log('Cordova, globalization, dateToString ' +format);
+ }
+
+ if (format)
+ {
+ successCB ({"value": format});
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.FORMATTING_ERROR , "cannot format date string"));
+ }
+},
+
+
+/**
+* Parses a date formatted as a string according to the client's user
+* preferences and calendar using the time zone of the client and returns
+* the corresponding date object. It returns the date to the successCB
+* callback with a properties object as a parameter. If there is an error
+* parsing the date string, then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {String} dateString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.year {Number}: The four digit year
+* Object.month {Number}: The month from (0 - 11)
+* Object.day {Number}: The day from (1 - 31)
+* Object.hour {Number}: The hour from (0 - 23)
+* Object.minute {Number}: The minute from (0 - 59)
+* Object.second {Number}: The second from (0 - 59)
+* Object.millisecond {Number}: The milliseconds (from 0 - 999),
+* not available on all platforms
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToDate('4/11/2011',
+* function (date) { alert('Month:' + date.month + '\n' +
+* 'Day:' + date.day + '\n' +
+* 'Year:' + date.year + '\n');},
+* function (errorCode) {alert(errorCode);},
+* {selector:'date'});
+*/
+stringToDate:function(dateString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "stringToDate", [{"dateString": dateString, "options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.PARSING_ERROR , "unsupported"));
+},
+
+
+/**
+* Returns a pattern string for formatting and parsing dates according to the client's
+* user preferences. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern,
+* then the errorCB callback is invoked.
+*
+* The defaults are: formatLength="short" and selector="date and time"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* formatLength {String}: 'short', 'medium', 'long', or 'full'
+* selector {String}: 'date', 'time', or 'date and time'
+*
+* @return Object.pattern {String}: The date and time pattern for formatting and parsing dates.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.timezone {String}: The abbreviated name of the time zone on the client
+* Object.utc_offset {Number}: The current difference in seconds between the client's
+* time zone and coordinated universal time.
+* Object.dst_offset {Number}: The current daylight saving time offset in seconds
+* between the client's non-daylight saving's time zone
+* and the client's daylight saving's time zone.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getDatePattern(
+* function (date) {alert('pattern:' + date.pattern + '\n');},
+* function () {},
+* {formatLength:'short'});
+*/
+getDatePattern:function(successCB, failureCB, options) {
+ console.log(' exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": options}]);');
+
+ var shortFormat = (options) ? ( options.formatLength === 'short') : true;
+
+ var formatString = tizen.time.getDateFormat ( shortFormat);
+
+
+ var current_datetime = tizen.time.getCurrentDateTime();
+
+ // probably will require some control of operation...
+ if (formatString)
+ {
+ successCB(
+ {
+ "pattern": formatString,
+ "timezone": current_datetime.getTimezoneAbbreviation(),
+ "utc_offset": current_datetime.difference(current_datetime.toUTC()).length,
+ "dst_offset": current_datetime.isDST()
+ }
+ );
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR , "cannot get pattern"));
+ }
+},
+
+
+/**
+* Returns an array of either the names of the months or days of the week
+* according to the client's user preferences and calendar. It returns the array of names to the
+* successCB callback with a properties object as a parameter. If there is an error obtaining the
+* names, then the errorCB callback is invoked.
+*
+* The defaults are: type="wide" and item="months"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'narrow' or 'wide'
+* item {String}: 'months', or 'days'
+*
+* @return Object.value {Array{String}}: The array of names starting from either
+* the first month in the year or the
+* first day of the week.
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getDateNames(function (names) {
+* for(var i = 0; i < names.value.length; i++) {
+* alert('Month:' + names.value[i] + '\n');}},
+* function () {});
+*/
+getDateNames:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": options}]);');
+
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns whether daylight savings time is in effect for a given date using the client's
+* time zone and calendar. It returns whether or not daylight savings time is in effect
+* to the successCB callback with a properties object as a parameter. If there is an error
+* reading the date, then the errorCB callback is invoked.
+*
+* @param {Date} date
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.dst {Boolean}: The value "true" indicates that daylight savings time is
+* in effect for the given date and "false" indicate that it is not.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.isDayLightSavingsTime(new Date(),
+* function (date) {alert('dst:' + date.dst + '\n');}
+* function () {});
+*/
+isDayLightSavingsTime:function(date, successCB, failureCB) {
+
+ var tzdate = null,
+ isDLS = false;
+
+ console.log('exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [{"date": dateValue}]);');
+ console.log("date " + date + " value " + date.valueOf()) ;
+
+ tzdate = new tizen.TZDate(date);
+ if (tzdate) {
+ isDLS = false | (tzdate && tzdate.isDST());
+
+ console.log ("Cordova, globalization, isDayLightSavingsTime, " + isDLS);
+
+ successCB({"dst":isDLS});
+ }
+ else {
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "cannot get information"));
+ }
+},
+
+/**
+* Returns the first day of the week according to the client's user preferences and calendar.
+* The days of the week are numbered starting from 1 where 1 is considered to be Sunday.
+* It returns the day to the successCB callback with a properties object as a parameter.
+* If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.value {Number}: The number of the first day of the week.
+*
+* @error GlobalizationError.UNKNOWN_ERROR
+*
+* Example
+* globalization.getFirstDayOfWeek(function (day)
+* { alert('Day:' + day.value + '\n');},
+* function () {});
+*/
+getFirstDayOfWeek:function(successCB, failureCB) {
+ argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);');
+
+ // there is no API to get the fist day of the week in Tizen Dvice API
+ successCB({value:1});
+
+ // first day of week is a settings in the date book app
+ // what about : getting the settings directly or asking the date book ?
+},
+
+
+/**
+* Returns a number formatted as a string according to the client's user preferences.
+* It returns the formatted number string to the successCB callback with a properties object as a
+* parameter. If there is an error formatting the number, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Number} number
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {String}: The formatted number string.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.numberToString(3.25,
+* function (number) {alert('number:' + number.value + '\n');},
+* function () {},
+* {type:'decimal'});
+*/
+numberToString:function(number, successCB, failureCB, options) {
+ argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "numberToString", [{"number": number, "options": options}]);');
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Parses a number formatted as a string according to the client's user preferences and
+* returns the corresponding number. It returns the number to the successCB callback with a
+* properties object as a parameter. If there is an error parsing the number string, then
+* the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {String} numberString
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.value {Number}: The parsed number.
+*
+* @error GlobalizationError.PARSING_ERROR
+*
+* Example
+* globalization.stringToNumber('1234.56',
+* function (number) {alert('Number:' + number.value + '\n');},
+* function () { alert('Error parsing number');});
+*/
+stringToNumber:function(numberString, successCB, failureCB, options) {
+ argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "stringToNumber", [{"numberString": numberString, "options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns a pattern string for formatting and parsing numbers according to the client's user
+* preferences. It returns the pattern to the successCB callback with a properties object as a
+* parameter. If there is an error obtaining the pattern, then the errorCB callback is invoked.
+*
+* The defaults are: type="decimal"
+*
+* @param {Function} successCB
+* @param {Function} errorCB
+* @param {Object} options {optional}
+* type {String}: 'decimal', "percent", or 'currency'
+*
+* @return Object.pattern {String}: The number pattern for formatting and parsing numbers.
+* The patterns follow Unicode Technical Standard #35.
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.symbol {String}: The symbol to be used when formatting and parsing
+* e.g., percent or currency symbol.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting numbers.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.positive {String}: The symbol to use for positive numbers when parsing and formatting.
+* Object.negative: {String}: The symbol to use for negative numbers when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.PATTERN_ERROR
+*
+* Example
+* globalization.getNumberPattern(
+* function (pattern) {alert('Pattern:' + pattern.pattern + '\n');},
+* function () {});
+*/
+getNumberPattern:function(successCB, failureCB, options) {
+ argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getNumberPattern", [{"options": options}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+},
+
+/**
+* Returns a pattern string for formatting and parsing currency values according to the client's
+* user preferences and ISO 4217 currency code. It returns the pattern to the successCB callback with a
+* properties object as a parameter. If there is an error obtaining the pattern, then the errorCB
+* callback is invoked.
+*
+* @param {String} currencyCode
+* @param {Function} successCB
+* @param {Function} errorCB
+*
+* @return Object.pattern {String}: The currency pattern for formatting and parsing currency values.
+* The patterns follow Unicode Technical Standard #35
+* http://unicode.org/reports/tr35/tr35-4.html
+* Object.code {String}: The ISO 4217 currency code for the pattern.
+* Object.fraction {Number}: The number of fractional digits to use when parsing and
+* formatting currency.
+* Object.rounding {Number}: The rounding increment to use when parsing and formatting.
+* Object.decimal: {String}: The decimal symbol to use for parsing and formatting.
+* Object.grouping: {String}: The grouping symbol to use for parsing and formatting.
+*
+* @error GlobalizationError.FORMATTING_ERROR
+*
+* Example
+* globalization.getCurrencyPattern('EUR',
+* function (currency) {alert('Pattern:' + currency.pattern + '\n');}
+* function () {});
+*/
+getCurrencyPattern:function(currencyCode, successCB, failureCB) {
+ argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
+ console.log('exec(successCB, failureCB, "Globalization", "getCurrencyPattern", [{"currencyCode": currencyCode}]);');
+
+ //not supported
+ failureCB(new GlobalizationError(GlobalizationError.UNKNOWN_ERROR , "unsupported"));
+}
+
+};
+
+module.exports = globalization;
+
});
// file: lib/tizen/plugin/tizen/Media.js
define("cordova/plugin/tizen/Media", function(require, exports, module) {
+
/*global Media:false, webkitURL:false */
var MediaError = require('cordova/plugin/MediaError'),
audioObjects = {};
+//console.log("TIZEN MEDIA START");
+
module.exports = {
+
+
create: function (successCallback, errorCallback, args) {
var id = args[0], src = args[1];
+
console.log("media::create() - id =" + id + ", src =" + src);
+
audioObjects[id] = new Audio(src);
+
audioObjects[id].onStalledCB = function () {
console.log("media::onStalled()");
- audioObjects[id].timer = window.setTimeout(function () {
- audioObjects[id].pause();
- if (audioObjects[id].currentTime !== 0)
- audioObjects[id].currentTime = 0;
- console.log("media::onStalled() - MEDIA_ERROR -> " + MediaError.MEDIA_ERR_ABORTED);
- var err = new MediaError(MediaError.MEDIA_ERR_ABORTED, "Stalled");
- Media.onStatus(id, Media.MEDIA_ERROR, err);
- }, 2000);
+
+ audioObjects[id].timer = window.setTimeout(
+ function () {
+ audioObjects[id].pause();
+
+ if (audioObjects[id].currentTime !== 0)
+ audioObjects[id].currentTime = 0;
+
+ console.log("media::onStalled() - MEDIA_ERROR -> " + MediaError.MEDIA_ERR_ABORTED);
+
+ var err = new MediaError(MediaError.MEDIA_ERR_ABORTED, "Stalled");
+
+ Media.onStatus(id, Media.MEDIA_ERROR, err);
+ },
+ 2000);
};
+
audioObjects[id].onEndedCB = function () {
console.log("media::onEndedCB() - MEDIA_STATE -> MEDIA_STOPPED");
+
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
};
+
audioObjects[id].onErrorCB = function () {
console.log("media::onErrorCB() - MEDIA_ERROR -> " + event.srcElement.error);
+
Media.onStatus(id, Media.MEDIA_ERROR, event.srcElement.error);
};
+
audioObjects[id].onPlayCB = function () {
console.log("media::onPlayCB() - MEDIA_STATE -> MEDIA_STARTING");
+
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STARTING);
};
+
audioObjects[id].onPlayingCB = function () {
console.log("media::onPlayingCB() - MEDIA_STATE -> MEDIA_RUNNING");
+
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_RUNNING);
};
+
audioObjects[id].onDurationChangeCB = function () {
console.log("media::onDurationChangeCB() - MEDIA_DURATION -> " + audioObjects[id].duration);
+
Media.onStatus(id, Media.MEDIA_DURATION, audioObjects[id].duration);
};
+
audioObjects[id].onTimeUpdateCB = function () {
console.log("media::onTimeUpdateCB() - MEDIA_POSITION -> " + audioObjects[id].currentTime);
+
Media.onStatus(id, Media.MEDIA_POSITION, audioObjects[id].currentTime);
};
+
audioObjects[id].onCanPlayCB = function () {
console.log("media::onCanPlayCB()");
+
window.clearTimeout(audioObjects[id].timer);
+
audioObjects[id].play();
};
},
+
startPlayingAudio: function (successCallback, errorCallback, args) {
var id = args[0], src = args[1], options = args[2];
+
console.log("media::startPlayingAudio() - id =" + id + ", src =" + src + ", options =" + options);
+
audioObjects[id].addEventListener('canplay', audioObjects[id].onCanPlayCB);
audioObjects[id].addEventListener('ended', audioObjects[id].onEndedCB);
audioObjects[id].addEventListener('timeupdate', audioObjects[id].onTimeUpdateCB);
@@ -6388,16 +8449,24 @@
audioObjects[id].addEventListener('play', audioObjects[id].onPlayCB);
audioObjects[id].addEventListener('error', audioObjects[id].onErrorCB);
audioObjects[id].addEventListener('stalled', audioObjects[id].onStalledCB);
+
audioObjects[id].play();
},
+
stopPlayingAudio: function (successCallback, errorCallback, args) {
var id = args[0];
+
window.clearTimeout(audioObjects[id].timer);
+
audioObjects[id].pause();
+
if (audioObjects[id].currentTime !== 0)
audioObjects[id].currentTime = 0;
+
console.log("media::stopPlayingAudio() - MEDIA_STATE -> MEDIA_STOPPED");
+
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_STOPPED);
+
audioObjects[id].removeEventListener('canplay', audioObjects[id].onCanPlayCB);
audioObjects[id].removeEventListener('ended', audioObjects[id].onEndedCB);
audioObjects[id].removeEventListener('timeupdate', audioObjects[id].onTimeUpdateCB);
@@ -6407,35 +8476,50 @@
audioObjects[id].removeEventListener('error', audioObjects[id].onErrorCB);
audioObjects[id].removeEventListener('error', audioObjects[id].onStalledCB);
},
+
seekToAudio: function (successCallback, errorCallback, args) {
+
var id = args[0], milliseconds = args[1];
+
console.log("media::seekToAudio()");
- audioObjects[id].currentTime = milliseconds;
+
+ audioObjects[id].currentTime = milliseconds;
successCallback( audioObjects[id].currentTime);
},
+
pausePlayingAudio: function (successCallback, errorCallback, args) {
var id = args[0];
+
console.log("media::pausePlayingAudio() - MEDIA_STATE -> MEDIA_PAUSED");
+
audioObjects[id].pause();
+
Media.onStatus(id, Media.MEDIA_STATE, Media.MEDIA_PAUSED);
},
+
getCurrentPositionAudio: function (successCallback, errorCallback, args) {
var id = args[0];
console.log("media::getCurrentPositionAudio()");
successCallback(audioObjects[id].currentTime);
},
+
release: function (successCallback, errorCallback, args) {
var id = args[0];
window.clearTimeout(audioObjects[id].timer);
console.log("media::release()");
},
+
setVolume: function (successCallback, errorCallback, args) {
var id = args[0], volume = args[1];
+
console.log("media::setVolume()");
+
audioObjects[id].volume = volume;
},
+
startRecordingAudio: function (successCallback, errorCallback, args) {
var id = args[0], src = args[1];
+
console.log("media::startRecordingAudio() - id =" + id + ", src =" + src);
function gotStreamCB(stream) {
@@ -6455,19 +8539,26 @@
}
successCallback();
},
+
stopRecordingAudio: function (successCallback, errorCallback, args) {
var id = args[0];
+
console.log("media::stopRecordingAudio() - id =" + id);
+
audioObjects[id].pause();
successCallback();
}
};
+//console.log("TIZEN MEDIA END");
+
+
});
// file: lib/tizen/plugin/tizen/MediaError.js
define("cordova/plugin/tizen/MediaError", function(require, exports, module) {
+
// The MediaError object already exists on Tizen. This prevents the Cordova
// version from being defined. This object is used to merge in differences
// between Tizen and Cordova MediaError objects.
@@ -6475,60 +8566,103 @@
MEDIA_ERR_NONE_ACTIVE : 0,
MEDIA_ERR_NONE_SUPPORTED : 4
};
+
});
// file: lib/tizen/plugin/tizen/NetworkStatus.js
define("cordova/plugin/tizen/NetworkStatus", function(require, exports, module) {
+
/*global tizen:false */
var Connection = require('cordova/plugin/Connection');
+//console.log("TIZEN CONNECTION AKA NETWORK STATUS START");
+
module.exports = {
getConnectionInfo: function (successCallback, errorCallback) {
+
var cncType = Connection.NONE;
var infoCount = 0;
+ var deviceCapabilities = null;
+ var timerId = 0;
+ var timeout = 300;
- function infoCB() {
+
+ function connectionCB() {
+
+ if (timerId !== null) {
+ clearTimeout(timerId);
+ timerId = null;
+ }
+
infoCount++;
- if (infoCount > 1)
- successCallback(cncType);
+
+ if (infoCount > 1) {
+ if (successCallback) {
+ successCallback(cncType);
+ }
+ }
}
function errorCB(error) {
- console.log("Error: " + error.code + "," + error.name + "," + error.message);
- infoCB();
+ console.log("Error: " + error.code + "," + error.name + "," + error.message);
+
+ if (errorCallback) {
+ errorCallback();
+ }
}
function wifiSuccessCB(wifi) {
- if ((wifi.status === "ON") && (wifi.ipAddress.length !== 0))
+ if ((wifi.status === "ON") && (wifi.ipAddress.length !== 0)) {
cncType = Connection.WIFI;
- infoCB();
+ }
+ connectionCB();
}
function cellularSuccessCB(cell) {
- if ((cncType === Connection.NONE) && (cell.status === "ON") && (cell.ipAddress.length !== 0))
+ if ((cncType === Connection.NONE) && (cell.status === "ON") && (cell.ipAddress.length !== 0)) {
cncType = Connection.CELL_2G;
- infoCB();
+ }
+ connectionCB();
}
- if (tizen.systeminfo.isSupported('WifiNetwork')) {
- tizen.systeminfo.getPropertyValue('WifiNetwork', wifiSuccessCB, errorCB);
+
+ deviceCapabilities = tizen.systeminfo.getCapabilities();
+
+
+ timerId = setTimeout( function(){
+ timerId = null;
+ infoCount = 1;
+ connectionCB();
+ }, timeout);
+
+
+ if (deviceCapabilities.wifi) {
+ tizen.systeminfo.getPropertyValue("WIFI_NETWORK", wifiSuccessCB, errorCB);
}
- if (tizen.systeminfo.isSupported('CellularNetwork')) {
- tizen.systeminfo.getPropertyValue('CellularNetwork', cellularSuccessCB, errorCB);
+ if (deviceCapabilities.telephony) {
+ tizen.systeminfo.getPropertyValue("CELLULAR_NETWORK", cellularSuccessCB, errorCB);
}
+
}
};
+//console.log("TIZEN CONNECTION AKA NETWORK STATUS END");
+
});
// file: lib/tizen/plugin/tizen/Notification.js
define("cordova/plugin/tizen/Notification", function(require, exports, module) {
+
var SoundBeat = require('cordova/plugin/tizen/SoundBeat');
/* TODO: get resource path from app environment? */
var soundBeat = new SoundBeat(["./sounds/beep.wav"]);
+
+//console.log("TIZEN NOTIFICATION START");
+
+
module.exports = {
alert: function(message, alertCallback, title, buttonName) {
@@ -6630,6 +8764,24 @@
}
},
+ prompt: function (message, promptCallback, title, buttonLabels) {
+ console.log ("message" , message);
+ console.log ("promptCallback" , promptCallback);
+ console.log ("title" , title);
+ console.log ("buttonLabels" , buttonLabels);
+
+ //a temporary implementation using window.prompt()
+ // note taht buttons are cancel ok (in that order)
+ // gonna to return based on having OK / Cancel
+ // ok is 1, cancel is 2
+
+ var result = prompt(message);
+
+ if (promptCallback && (typeof promptCallback == "function")) {
+ promptCallback((result === null) ? 2 : 1, result);
+ }
+ },
+
vibrate: function(milliseconds) {
console.log ("milliseconds" , milliseconds);
@@ -6637,7 +8789,7 @@
navigator.vibrate(milliseconds);
}
else {
- console.log ("cordova/plugin/tizen/Notification, vibrate API does not exists");
+ console.log ("cordova/plugin/tizen/Notification, vibrate API does not exist");
}
},
@@ -6647,12 +8799,14 @@
}
};
+//console.log("TIZEN NOTIFICATION END");
});
// file: lib/tizen/plugin/tizen/SoundBeat.js
define("cordova/plugin/tizen/SoundBeat", function(require, exports, module) {
+
/*global webkitAudioContext:false */
/*
* SoundBeat
@@ -6665,7 +8819,7 @@
*
* NOTE: the W3C Web Audio doc tells we do not need to recreate the audio
* context to play a sound but only the audiosourcenode (createBufferSource)
- * in the webkit implementation we have to.
+ * in the WebKit implementation we have to.
*
*/
@@ -6729,8 +8883,42 @@
});
+// file: lib/tizen/plugin/tizen/SplashScreen.js
+define("cordova/plugin/tizen/SplashScreen", function(require, exports, module) {
+
+var exec = require('cordova/exec'),
+ InAppBrowser = require('cordova/plugin/InAppBrowser');
+
+var splashscreen = {
+
+ window: null,
+
+
+ show:function() {
+ console.log ("tizen splashscreen show()");
+
+ // open a windows in splashscreen.window
+ // add DOM with an Image
+ window = window.open('splashscreen.html');
+
+
+ },
+ hide:function() {
+ console.log ("tizen splashscreen hide()");
+ //delete the window splashscreen.window
+ //set to null
+ window.close();
+ window = null;
+ }
+};
+
+module.exports = splashscreen;
+
+});
+
// file: lib/tizen/plugin/tizen/contacts.js
define("cordova/plugin/tizen/contacts", function(require, exports, module) {
+
/*global tizen:false */
var ContactError = require('cordova/plugin/ContactError'),
utils = require('cordova/utils'),
@@ -6798,8 +8986,21 @@
});
+// file: lib/tizen/plugin/tizen/contacts/symbols.js
+define("cordova/plugin/tizen/contacts/symbols", function(require, exports, module) {
+
+require('cordova/plugin/contacts/symbols');
+
+var modulemapper = require('cordova/modulemapper');
+
+modulemapper.merges('cordova/plugin/tizen/contacts', 'navigator.contacts');
+modulemapper.merges('cordova/plugin/tizen/Contact', 'Contact');
+
+});
+
// file: lib/tizen/plugin/tizen/manager.js
define("cordova/plugin/tizen/manager", function(require, exports, module) {
+
var cordova = require('cordova');
module.exports = {
@@ -6820,22 +9021,90 @@
});
+// file: lib/common/symbols.js
+define("cordova/symbols", function(require, exports, module) {
+
+var modulemapper = require('cordova/modulemapper');
+
+// Use merges here in case others symbols files depend on this running first,
+// but fail to declare the dependency with a require().
+modulemapper.merges('cordova', 'cordova');
+modulemapper.clobbers('cordova/exec', 'cordova.exec');
+modulemapper.clobbers('cordova/exec', 'Cordova.exec');
+
+});
+
// file: lib/common/utils.js
define("cordova/utils", function(require, exports, module) {
+
var utils = exports;
/**
+ * Defines a property getter / setter for obj[key].
+ */
+utils.defineGetterSetter = function(obj, key, getFunc, opt_setFunc) {
+ if (Object.defineProperty) {
+ var desc = {
+ get: getFunc,
+ configurable: true
+ };
+ if (opt_setFunc) {
+ desc.set = opt_setFunc;
+ }
+ Object.defineProperty(obj, key, desc);
+ } else {
+ obj.__defineGetter__(key, getFunc);
+ if (opt_setFunc) {
+ obj.__defineSetter__(key, opt_setFunc);
+ }
+ }
+};
+
+/**
+ * Defines a property getter for obj[key].
+ */
+utils.defineGetter = utils.defineGetterSetter;
+
+utils.arrayIndexOf = function(a, item) {
+ if (a.indexOf) {
+ return a.indexOf(item);
+ }
+ var len = a.length;
+ for (var i = 0; i < len; ++i) {
+ if (a[i] == item) {
+ return i;
+ }
+ }
+ return -1;
+};
+
+/**
+ * Returns whether the item was found in the array.
+ */
+utils.arrayRemove = function(a, item) {
+ var index = utils.arrayIndexOf(a, item);
+ if (index != -1) {
+ a.splice(index, 1);
+ }
+ return index != -1;
+};
+
+utils.typeName = function(val) {
+ return Object.prototype.toString.call(val).slice(8, -1);
+};
+
+/**
* Returns an indication of whether the argument is an array or not
*/
utils.isArray = function(a) {
- return Object.prototype.toString.call(a) == '[object Array]';
+ return utils.typeName(a) == 'Array';
};
/**
* Returns an indication of whether the argument is a Date or not
*/
utils.isDate = function(d) {
- return Object.prototype.toString.call(d) == '[object Date]';
+ return utils.typeName(d) == 'Date';
};
/**
@@ -6866,7 +9135,7 @@
};
/**
- * Returns a wrappered version of the function
+ * Returns a wrapped version of the function
*/
utils.close = function(context, func, params) {
if (typeof params == 'undefined') {
@@ -6911,69 +9180,13 @@
* Alerts a message in any available way: alert or console.log.
*/
utils.alert = function(msg) {
- if (alert) {
- alert(msg);
+ if (window.alert) {
+ window.alert(msg);
} else if (console && console.log) {
console.log(msg);
}
};
-/**
- * Formats a string and arguments following it ala sprintf()
- *
- * see utils.vformat() for more information
- */
-utils.format = function(formatString /* ,... */) {
- var args = [].slice.call(arguments, 1);
- return utils.vformat(formatString, args);
-};
-
-/**
- * Formats a string and arguments following it ala vsprintf()
- *
- * format chars:
- * %j - format arg as JSON
- * %o - format arg as JSON
- * %c - format arg as ''
- * %% - replace with '%'
- * any other char following % will format it's
- * arg via toString().
- *
- * for rationale, see FireBug's Console API:
- * http://getfirebug.com/wiki/index.php/Console_API
- */
-utils.vformat = function(formatString, args) {
- if (formatString === null || formatString === undefined) return "";
- if (arguments.length == 1) return formatString.toString();
- if (typeof formatString != "string") return formatString.toString();
-
- var pattern = /(.*?)%(.)(.*)/;
- var rest = formatString;
- var result = [];
-
- while (args.length) {
- var arg = args.shift();
- var match = pattern.exec(rest);
-
- if (!match) break;
-
- rest = match[3];
-
- result.push(match[1]);
-
- if (match[2] == '%') {
- result.push('%');
- args.unshift(arg);
- continue;
- }
-
- result.push(formatted(arg, match[2]));
- }
-
- result.push(rest);
-
- return result.join('');
-};
//------------------------------------------------------------------------------
function UUIDcreatePart(length) {
@@ -6988,76 +9201,57 @@
return uuidpart;
}
-//------------------------------------------------------------------------------
-function formatted(object, formatChar) {
-
- try {
- switch(formatChar) {
- case 'j':
- case 'o': return JSON.stringify(object);
- case 'c': return '';
- }
- }
- catch (e) {
- return "error JSON.stringify()ing argument: " + e;
- }
-
- if ((object === null) || (object === undefined)) {
- return Object.prototype.toString.call(object);
- }
-
- return object.toString();
-}
});
-
window.cordova = require('cordova');
-
// file: lib/scripts/bootstrap.js
+
(function (context) {
- var channel = require("cordova/channel"),
- _self = {
- boot: function () {
- /**
- * Create all cordova objects once page has fully loaded and native side is ready.
- */
- channel.join(function() {
- var builder = require('cordova/builder'),
- base = require('cordova/common'),
- platform = require('cordova/platform');
+ if (context._cordovaJsLoaded) {
+ throw new Error('cordova.js included multiple times.');
+ }
+ context._cordovaJsLoaded = true;
- // Drop the common globals into the window object, but be nice and don't overwrite anything.
- builder.build(base.objects).intoButDontClobber(window);
+ var channel = require('cordova/channel');
+ var platformInitChannelsArray = [channel.onNativeReady, channel.onPluginsReady];
- // Drop the platform-specific globals into the window object
- // and clobber any existing object.
- builder.build(platform.objects).intoAndClobber(window);
-
- // Merge the platform-specific overrides/enhancements into
- // the window object.
- if (typeof platform.merges !== 'undefined') {
- builder.build(platform.merges).intoAndMerge(window);
- }
-
- // Call the platform-specific initialization
- platform.initialize();
-
- // Fire event to notify that all objects are created
- channel.onCordovaReady.fire();
-
- // Fire onDeviceReady event once all constructors have run and
- // cordova info has been received from native side.
- channel.join(function() {
- require('cordova').fireDocumentEvent('deviceready');
- }, channel.deviceReadyChannelsArray);
-
- }, [ channel.onDOMContentLoaded, channel.onNativeReady ]);
+ function logUnfiredChannels(arr) {
+ for (var i = 0; i < arr.length; ++i) {
+ if (arr[i].state != 2) {
+ console.log('Channel not fired: ' + arr[i].type);
}
- };
+ }
+ }
- // boot up once native side is ready
- channel.onNativeReady.subscribeOnce(_self.boot);
+ window.setTimeout(function() {
+ if (channel.onDeviceReady.state != 2) {
+ console.log('deviceready has not fired after 5 seconds.');
+ logUnfiredChannels(platformInitChannelsArray);
+ logUnfiredChannels(channel.deviceReadyChannelsArray);
+ }
+ }, 5000);
+
+ // Replace navigator before any modules are required(), to ensure it happens as soon as possible.
+ // We replace it so that properties that can't be clobbered can instead be overridden.
+ function replaceNavigator(origNavigator) {
+ var CordovaNavigator = function() {};
+ CordovaNavigator.prototype = origNavigator;
+ var newNavigator = new CordovaNavigator();
+ // This work-around really only applies to new APIs that are newer than Function.bind.
+ // Without it, APIs such as getGamepads() break.
+ if (CordovaNavigator.bind) {
+ for (var key in origNavigator) {
+ if (typeof origNavigator[key] == 'function') {
+ newNavigator[key] = origNavigator[key].bind(origNavigator);
+ }
+ }
+ }
+ return newNavigator;
+ }
+ if (context.navigator) {
+ context.navigator = replaceNavigator(context.navigator);
+ }
// _nativeReady is global variable that the native side can set
// to signify that the native code is ready. It is a global since
@@ -7066,10 +9260,192 @@
channel.onNativeReady.fire();
}
+ /**
+ * Create all cordova objects once native side is ready.
+ */
+ channel.join(function() {
+ // Call the platform-specific initialization
+ require('cordova/platform').initialize();
+
+ // Fire event to notify that all objects are created
+ channel.onCordovaReady.fire();
+
+ // Fire onDeviceReady event once page has fully loaded, all
+ // constructors have run and cordova info has been received from native
+ // side.
+ // This join call is deliberately made after platform.initialize() in
+ // order that plugins may manipulate channel.deviceReadyChannelsArray
+ // if necessary.
+ channel.join(function() {
+ require('cordova').fireDocumentEvent('deviceready');
+ }, channel.deviceReadyChannelsArray);
+
+ }, platformInitChannelsArray);
+
}(window));
// file: lib/scripts/bootstrap-tizen.js
+
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();
+ }
+ }
+
+ function scriptErrorCallback(err) {
+ // Open Question: If a script path specified in cordova_plugins.js does not exist, do we fail for all?
+ // this is currently just continuing.
+ 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.onerror = scriptErrorCallback;
+ 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.js 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 onerror response handler will just call finishPluginLoading().
+ function handlePluginsObject(modules, path) {
+ // 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) {
+ try {
+ 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);
+ }
+ }
+ catch(err) {
+ // error with module, most likely clobbers, should we continue?
+ }
+ }
+ }
+
+ finishPluginLoading();
+ };
+
+ // Now inject the scripts.
+ for (var i = 0; i < modules.length; i++) {
+ injectScript(path + modules[i].file);
+ }
+ }
+
+ // Find the root of the app
+ var path = '';
+ var scripts = document.getElementsByTagName('script');
+ var term = 'cordova.js';
+ for (var n = scripts.length-1; n>-1; n--) {
+ var src = scripts[n].src;
+ if (src.indexOf(term) == (src.length - term.length)) {
+ path = src.substring(0, src.length - term.length);
+ break;
+ }
+ }
+
+ var plugins_json = path + 'cordova_plugins.json';
+ var plugins_js = path + 'cordova_plugins.js';
+
+ // One some phones (Windows) this xhr.open throws an Access Denied exception
+ // So lets keep trying, but with a script tag injection technique instead of XHR
+ var injectPluginScript = function injectPluginScript() {
+ try {
+ var script = document.createElement("script");
+ script.onload = function(){
+ var list = cordova.require("cordova/plugin_list");
+ handlePluginsObject(list,path);
+ };
+ script.onerror = function() {
+ // Error loading cordova_plugins.js, file not found or something
+ // this is an acceptable error, pre-3.0.0, so we just move on.
+ finishPluginLoading();
+ };
+ script.src = plugins_js;
+ document.head.appendChild(script);
+
+ } catch(err){
+ finishPluginLoading();
+ }
+ }
+
+
+ // Try to XHR the cordova_plugins.json file asynchronously.
+ var xhr = new XMLHttpRequest();
+ xhr.onload = function() {
+ // 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.
+ var obj;
+ try {
+ obj = (this.status == 0 || this.status == 200) && this.responseText && JSON.parse(this.responseText);
+ } catch (err) {
+ // obj will be undefined.
+ }
+ if (Array.isArray(obj) && obj.length > 0) {
+ handlePluginsObject(obj, path);
+ } else {
+ finishPluginLoading();
+ }
+ };
+ xhr.onerror = function() {
+ // In this case, the json file was not present, but XHR was allowed,
+ // so we should still try the script injection technique with the js file
+ // in case that is there.
+ injectPluginScript();
+ };
+ try { // we commented we were going to try, so let us actually try and catch
+ xhr.open('GET', plugins_json, true); // Async
+ xhr.send();
+ } catch(err){
+ injectPluginScript();
+ }
+}(window));
+
})();
\ No newline at end of file