You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2015/10/20 02:00:58 UTC
[3/5] cordova-browser git commit: added updated exec to cordova.js
built file
added updated exec to cordova.js built file
Project: http://git-wip-us.apache.org/repos/asf/cordova-browser/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-browser/commit/49ecb2a7
Tree: http://git-wip-us.apache.org/repos/asf/cordova-browser/tree/49ecb2a7
Diff: http://git-wip-us.apache.org/repos/asf/cordova-browser/diff/49ecb2a7
Branch: refs/heads/master
Commit: 49ecb2a76d9ba94066b20edc6f4eb2777c62b0f2
Parents: 22158b2
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Sep 15 17:16:11 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Sep 15 17:16:11 2015 -0700
----------------------------------------------------------------------
cordova-lib/cordova.js | 74 +++++++++++++++++++++++++++++++++++++--------
1 file changed, 62 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/49ecb2a7/cordova-lib/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/cordova.js b/cordova-lib/cordova.js
index 4616c92..72252f0 100644
--- a/cordova-lib/cordova.js
+++ b/cordova-lib/cordova.js
@@ -905,25 +905,75 @@ module.exports = function(success, fail, service, action, args) {
var proxy = execProxy.get(service, action);
+ args = args || [];
+
if (proxy) {
+
var callbackId = service + cordova.callbackId++;
-
- if (typeof success == "function" || typeof fail == "function") {
- cordova.callbacks[callbackId] = {success:success, fail:fail};
+
+ if (typeof success === "function" || typeof fail === "function") {
+ cordova.callbacks[callbackId] = {success: success, fail: fail};
}
-
try {
- proxy(success, fail, args);
+
+
+
+ // callbackOptions param represents additional optional parameters command could pass back, like keepCallback or
+ // custom callbackId, for example {callbackId: id, keepCallback: true, status: cordova.callbackStatus.JSON_EXCEPTION }
+ // CB-5806 [Windows8] Add keepCallback support to proxy
+ var onSuccess = function (result, callbackOptions) {
+ callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ // covering both undefined and null.
+ // strict null comparison was causing callbackStatus to be undefined
+ // and then no callback was called because of the check in cordova.callbackFromNative
+ // see CB-8996 Mobilespec app hang on windows
+ if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
+ callbackStatus = callbackOptions.status;
+ }
+ else {
+ callbackStatus = cordova.callbackStatus.OK;
+ }
+ cordova.callbackSuccess(callbackOptions.callbackId || callbackId,
+ {
+ status: callbackStatus,
+ message: result,
+ keepCallback: callbackOptions.keepCallback || false
+ });
+ };
+ var onError = function (err, callbackOptions) {
+ callbackOptions = callbackOptions || {};
+ var callbackStatus;
+ // covering both undefined and null.
+ // strict null comparison was causing callbackStatus to be undefined
+ // and then no callback was called because of the check in cordova.callbackFromNative
+ // note: status can be 0
+ if (callbackOptions.status !== undefined && callbackOptions.status !== null) {
+ callbackStatus = callbackOptions.status;
+ }
+ else {
+ callbackStatus = cordova.callbackStatus.OK;
+ }
+ cordova.callbackError(callbackOptions.callbackId || callbackId,
+ {
+ status: callbackStatus,
+ message: err,
+ keepCallback: callbackOptions.keepCallback || false
+ });
+ };
+ proxy(onSuccess, onError, args);
+
+ } catch (e) {
+ console.log("Exception calling native with command :: " + service + " :: " + action + " ::exception=" + e);
}
- catch(e) {
- // TODO throw maybe?
- var msg = "Exception calling :: " + service + " :: " + action + " ::exception=" + e;
- console.log(msg);
+ } else {
+
+ console.log("Error: exec proxy not found for :: " + service + " :: " + action);
+
+ if(typeof fail === "function" ) {
+ fail("Missing Command Error");
}
}
- else {
- fail && fail("Missing Command Error");
- }
};
});
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org