You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by gt...@apache.org on 2013/10/29 04:41:31 UTC

js commit: Created common exec proxy module

Updated Branches:
  refs/heads/master 4e7d30d26 -> c6817556d


Created common exec proxy module

Since windows8 and firefox both used the exact same module
(commandProxy) I refactored this to a common/exec/proxy module.

I left the original commandProxy modules in for old plugin support
but will now log to the console to point to the new module.


Project: http://git-wip-us.apache.org/repos/asf/cordova-js/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-js/commit/c6817556
Tree: http://git-wip-us.apache.org/repos/asf/cordova-js/tree/c6817556
Diff: http://git-wip-us.apache.org/repos/asf/cordova-js/diff/c6817556

Branch: refs/heads/master
Commit: c6817556d90cc4e500c4f480b6e106b1b52d3002
Parents: 4e7d30d
Author: Gord Tanner <gt...@gmail.com>
Authored: Mon Oct 28 23:22:07 2013 -0400
Committer: Gord Tanner <gt...@gmail.com>
Committed: Mon Oct 28 23:22:07 2013 -0400

----------------------------------------------------------------------
 lib/common/exec/proxy.js                | 46 ++++++++++++++++++++++++++++
 lib/firefoxos/exec.js                   |  4 +--
 lib/firefoxos/firefoxos/commandProxy.js | 27 ++--------------
 lib/firefoxos/platform.js               |  2 +-
 lib/windows8/exec.js                    |  4 +--
 lib/windows8/platform.js                |  2 +-
 lib/windows8/windows8/commandProxy.js   | 27 ++--------------
 7 files changed, 56 insertions(+), 56 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/common/exec/proxy.js
----------------------------------------------------------------------
diff --git a/lib/common/exec/proxy.js b/lib/common/exec/proxy.js
new file mode 100644
index 0000000..e640003
--- /dev/null
+++ b/lib/common/exec/proxy.js
@@ -0,0 +1,46 @@
+/*
+ *
+ * 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.
+ *
+*/
+
+
+// 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 );
+    }
+};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/firefoxos/exec.js
----------------------------------------------------------------------
diff --git a/lib/firefoxos/exec.js b/lib/firefoxos/exec.js
index 6d12c17..60410ee 100644
--- a/lib/firefoxos/exec.js
+++ b/lib/firefoxos/exec.js
@@ -21,10 +21,10 @@
 
 //var firefoxos = require('cordova/platform');
 var cordova = require('cordova');
-var commandProxy = require('cordova/firefoxos/commandProxy');
+var execProxy = require('cordova/exec/proxy');
 
 module.exports = function(success, fail, service, action, args) {
-    var proxy = commandProxy.get(service,action);
+    var proxy = execProxy.get(service,action);
     if(proxy) {
         var callbackId = service + cordova.callbackId++;
         //console.log("EXEC:" + service + " : " + action);

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/firefoxos/firefoxos/commandProxy.js
----------------------------------------------------------------------
diff --git a/lib/firefoxos/firefoxos/commandProxy.js b/lib/firefoxos/firefoxos/commandProxy.js
index e640003..cbdf720 100644
--- a/lib/firefoxos/firefoxos/commandProxy.js
+++ b/lib/firefoxos/firefoxos/commandProxy.js
@@ -19,28 +19,5 @@
  *
 */
 
-
-// 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 );
-    }
-};
\ No newline at end of file
+console.log('WARNING: please require cordova/exec/proxy instead');
+module.exports = require('cordova/exec/proxy');

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/firefoxos/platform.js
----------------------------------------------------------------------
diff --git a/lib/firefoxos/platform.js b/lib/firefoxos/platform.js
index 07ba3b1..a413195 100644
--- a/lib/firefoxos/platform.js
+++ b/lib/firefoxos/platform.js
@@ -24,7 +24,7 @@ module.exports = {
     cordovaVersion: '3.0.0',
 
     bootstrap: function() {
-        require('cordova/modulemapper').clobbers('cordova/firefoxos/commandProxy', 'cordova.commandProxy');
+        require('cordova/modulemapper').clobbers('cordova/exec/proxy', 'cordova.commandProxy');
         require('cordova/channel').onNativeReady.fire();
     }
 };

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/windows8/exec.js
----------------------------------------------------------------------
diff --git a/lib/windows8/exec.js b/lib/windows8/exec.js
index a8717a3..6720572 100644
--- a/lib/windows8/exec.js
+++ b/lib/windows8/exec.js
@@ -23,7 +23,7 @@
 /*global require, module, console */
 
 var cordova = require('cordova');
-var commandProxy = require('cordova/windows8/commandProxy');
+var execProxy = require('cordova/exec/proxy');
 
 /**
  * Execute a cordova command.  It is up to the native side whether this action
@@ -41,7 +41,7 @@ var commandProxy = require('cordova/windows8/commandProxy');
  */
 module.exports = function (success, fail, service, action, args) {
 
-    var proxy = commandProxy.get(service, action),
+    var proxy = execProxy.get(service, action),
         callbackId,
         onSuccess,
         onError;

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/windows8/platform.js
----------------------------------------------------------------------
diff --git a/lib/windows8/platform.js b/lib/windows8/platform.js
index 09bc8ad..67a564c 100755
--- a/lib/windows8/platform.js
+++ b/lib/windows8/platform.js
@@ -27,7 +27,7 @@ module.exports = {
             channel = cordova.require('cordova/channel'),
             modulemapper = require('cordova/modulemapper');
 
-        modulemapper.clobbers('cordova/windows8/commandProxy', 'cordova.commandProxy');
+        modulemapper.clobbers('cordova/exec/proxy', 'cordova.commandProxy');
         channel.onNativeReady.fire();
 
         var onWinJSReady = function () {

http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c6817556/lib/windows8/windows8/commandProxy.js
----------------------------------------------------------------------
diff --git a/lib/windows8/windows8/commandProxy.js b/lib/windows8/windows8/commandProxy.js
index e640003..cbdf720 100644
--- a/lib/windows8/windows8/commandProxy.js
+++ b/lib/windows8/windows8/commandProxy.js
@@ -19,28 +19,5 @@
  *
 */
 
-
-// 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 );
-    }
-};
\ No newline at end of file
+console.log('WARNING: please require cordova/exec/proxy instead');
+module.exports = require('cordova/exec/proxy');