cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhigg...@apache.org
Subject js commit: CB-5334 [BlackBerry10] Add command proxy to exec
Date Sun, 10 Nov 2013 22:41:36 GMT
Updated Branches:
  refs/heads/master d5e4e9ea0 -> c9de1bc0d


CB-5334 [BlackBerry10] Add command proxy to exec


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

Branch: refs/heads/master
Commit: c9de1bc0dbc903754b3d78982f962dab0d256f8e
Parents: d5e4e9e
Author: Bryan Higgins <bryan@bryanhiggins.net>
Authored: Sun Nov 10 17:40:26 2013 -0500
Committer: Bryan Higgins <bryan@bryanhiggins.net>
Committed: Sun Nov 10 17:41:18 2013 -0500

----------------------------------------------------------------------
 lib/blackberry10/exec.js | 51 ++++++++++++++++++++++++++-----------------
 1 file changed, 31 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c9de1bc0/lib/blackberry10/exec.js
----------------------------------------------------------------------
diff --git a/lib/blackberry10/exec.js b/lib/blackberry10/exec.js
index d7d2cff..6e896f4 100644
--- a/lib/blackberry10/exec.js
+++ b/lib/blackberry10/exec.js
@@ -19,7 +19,8 @@
  *
 */
 
-var cordova = require('cordova');
+var cordova = require('cordova'),
+    execProxy = require('cordova/exec/proxy');
 
 function RemoteFunctionCall(functionUri) {
     var params = {};
@@ -54,6 +55,7 @@ module.exports = function (success, fail, service, action, args) {
     var uri = service + "/" + action,
     request = new RemoteFunctionCall(uri),
     callbackId = service + cordova.callbackId++,
+    proxy,
     response,
     name,
     didSucceed;
@@ -63,30 +65,39 @@ module.exports = function (success, fail, service, action, args) {
         fail: fail
     };
 
-    request.addParam("callbackId", callbackId);
+    proxy = execProxy.get(service, action);
 
-    for (name in args) {
-        if (Object.hasOwnProperty.call(args, name)) {
-            request.addParam(name, args[name]);
-        }
+    if (proxy) {
+        proxy(success, fail, args);
     }
 
-    response = request.makeSyncCall();
+    else {
+
+        request.addParam("callbackId", callbackId);
+
+        for (name in args) {
+            if (Object.hasOwnProperty.call(args, name)) {
+                request.addParam(name, args[name]);
+            }
+        }
+        
+        response = request.makeSyncCall();
 
-    if (response.code < 0) {
-        if (fail) {
-            fail(response.msg, response);
+        if (response.code < 0) {
+            if (fail) {
+                fail(response.msg, response);
+            }
+            delete cordova.callbacks[callbackId];
+        } else {
+            didSucceed = response.code === cordova.callbackStatus.OK || response.code ===
cordova.callbackStatus.NO_RESULT;
+            cordova.callbackFromNative(
+                callbackId,
+                didSucceed,
+                response.code,
+                [ didSucceed ? response.data : response.msg ],
+                !!response.keepCallback
+            );
         }
-        delete cordova.callbacks[callbackId];
-    } else {
-        didSucceed = response.code === cordova.callbackStatus.OK || response.code === cordova.callbackStatus.NO_RESULT;
-        cordova.callbackFromNative(
-            callbackId,
-            didSucceed,
-            response.code,
-            [ didSucceed ? response.data : response.msg ],
-            !!response.keepCallback
-        );
     }
 
 };


Mime
View raw message