You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by st...@apache.org on 2013/09/14 03:03:36 UTC
git commit: updated cordova.js to use commandProxy
Updated Branches:
refs/heads/master c683a90e2 -> ee5c976fc
updated cordova.js to use commandProxy
Project: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/commit/ee5c976f
Tree: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/tree/ee5c976f
Diff: http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/diff/ee5c976f
Branch: refs/heads/master
Commit: ee5c976fca96fb17007e36419ffeec09776ba05f
Parents: c683a90
Author: Steven Gill <st...@gmail.com>
Authored: Fri Sep 13 18:03:28 2013 -0700
Committer: Steven Gill <st...@gmail.com>
Committed: Fri Sep 13 18:03:28 2013 -0700
----------------------------------------------------------------------
cordova-lib/cordova.js | 75 +++++++++++++++++++++++++++++++++------------
1 file changed, 55 insertions(+), 20 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-firefoxos/blob/ee5c976f/cordova-lib/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/cordova.js b/cordova-lib/cordova.js
index adc6833..ddb2df4 100644
--- a/cordova-lib/cordova.js
+++ b/cordova-lib/cordova.js
@@ -1,5 +1,5 @@
// Platform: firefoxos
-// 3.0.0-dev-54-g0627308
+// 3.0.0-dev-58-ged1894d
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
@@ -19,7 +19,7 @@
under the License.
*/
;(function() {
-var CORDOVA_JS_BUILD_LABEL = '3.0.0-dev-54-g0627308';
+var CORDOVA_JS_BUILD_LABEL = '3.0.0-dev-58-ged1894d';
// file: lib/scripts/require.js
var require,
@@ -790,17 +790,62 @@ module.exports = channel;
// file: lib/firefoxos/exec.js
define("cordova/exec", function(require, exports, module) {
-var firefoxos = require('cordova/platform');
-
-module.exports = function(success, fail, service, action, actionArgs) {
- var plugin = firefoxos.getPlugin(service);
- actionArgs.unshift(fail);
- actionArgs.unshift(success);
- plugin[action].apply(plugin, actionArgs);
+//var firefoxos = require('cordova/platform');
+var cordova = require('cordova');
+var commandProxy = require('cordova/firefoxos/commandProxy');
+
+module.exports = function(success, fail, service, action, args) {
+ var proxy = commandProxy.get(service,action);
+ if(proxy) {
+ var callbackId = service + cordova.callbackId++;
+ //console.log("EXEC:" + service + " : " + action);
+ if (typeof success == "function" || typeof fail == "function") {
+ cordova.callbacks[callbackId] = {success:success, fail:fail};
+ }
+ try {
+ proxy(success, fail, args);
+ }
+ catch(e) {
+ console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
+ }
+ }
+ else {
+ fail && fail("Missing Command Error");
+ }
};
});
+// file: lib/firefoxos/firefoxos/commandProxy.js
+define("cordova/firefoxos/commandProxy", function(require, exports, module) {
+
+
+// internal map of proxy function
+var CommandProxyMap = {};
+
+module.exports = {
+
+ // 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/firefoxos/init.js
define("cordova/init", function(require, exports, module) {
@@ -1032,23 +1077,13 @@ exports.reset();
// file: lib/firefoxos/platform.js
define("cordova/platform", function(require, exports, module) {
-var plugins = {};
-
module.exports = {
id: 'firefoxos',
cordovaVersion: '3.0.0',
bootstrap: function() {
+ require('cordova/modulemapper').clobbers('cordova/firefoxos/commandProxy', 'cordova.commandProxy');
require('cordova/channel').onNativeReady.fire();
- },
-
- registerPlugin: function(name, plugin) {
- plugins[name] = plugin;
- console.log('registered ' + name);
- },
-
- getPlugin: function(name) {
- return plugins[name];
}
};