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:56 UTC

[1/5] cordova-browser git commit: More verbose execution model to match other platforms

Repository: cordova-browser
Updated Branches:
  refs/heads/master 1d2725bfc -> e497b0a68


More verbose execution model to match other platforms


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

Branch: refs/heads/master
Commit: 826d18d99a3f9b8d60e7d5a7c05bedb14ab055cd
Parents: e467d6a
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Sep 15 16:58:26 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Sep 15 16:58:26 2015 -0700

----------------------------------------------------------------------
 cordova-js-src/exec.js | 91 ++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 77 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/826d18d9/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 744282e..58b7004 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -19,30 +19,93 @@
  *
 */
 
+/*jslint sloppy:true, plusplus:true*/
+/*global require, module, console */
+
 var cordova = require('cordova');
 var execProxy = require('cordova/exec/proxy');
 
-module.exports = function(success, fail, service, action, args) {
+/**
+ * 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.
+ *
+ * @param {Function} success    The success callback
+ * @param {Function} fail       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
+ */
+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);
-        }
-        catch(e) {
-            // TODO throw maybe?
-            var msg = "Exception calling :: " + service + " :: " + action  + " ::exception=" + e;
-            console.log(msg);
+
+            
+
+            // 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);
         }
-    }
-    else {
+    } else {
+        console.log("Error: exec proxy not found for :: " + service + " :: " + action);
         fail && fail("Missing Command Error");
     }
-};
+};
\ No newline at end of file


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[2/5] cordova-browser git commit: fix lint error

Posted by pu...@apache.org.
fix lint error


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

Branch: refs/heads/master
Commit: 22158b234480a36a12686ce369af7fa62d587ea5
Parents: 826d18d
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Tue Sep 15 17:10:02 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Tue Sep 15 17:10:02 2015 -0700

----------------------------------------------------------------------
 cordova-js-src/exec.js | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/22158b23/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 58b7004..2cc0328 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -105,7 +105,11 @@ module.exports = function (success, fail, service, action, args) {
             console.log("Exception calling native with command :: " + service + " :: " + action  + " ::exception=" + e);
         }
     } else {
+
         console.log("Error: exec proxy not found for :: " + service + " :: " + action);
-        fail && fail("Missing Command Error");
+        
+        if(typeof fail === "function" ) {
+            fail("Missing Command Error");
+        }
     }
-};
\ No newline at end of file
+};


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[4/5] cordova-browser git commit: Removed irrelevant out of context comment

Posted by pu...@apache.org.
Removed irrelevant out of context comment


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

Branch: refs/heads/master
Commit: 347ff1c6e601d7620ac97f81c4b599f7036dbeb0
Parents: 49ecb2a
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Oct 19 16:53:05 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Oct 19 16:53:05 2015 -0700

----------------------------------------------------------------------
 cordova-js-src/exec.js | 1 -
 cordova-lib/cordova.js | 1 -
 2 files changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/347ff1c6/cordova-js-src/exec.js
----------------------------------------------------------------------
diff --git a/cordova-js-src/exec.js b/cordova-js-src/exec.js
index 2cc0328..97f736a 100644
--- a/cordova-js-src/exec.js
+++ b/cordova-js-src/exec.js
@@ -58,7 +58,6 @@ module.exports = function (success, fail, service, action, 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;

http://git-wip-us.apache.org/repos/asf/cordova-browser/blob/347ff1c6/cordova-lib/cordova.js
----------------------------------------------------------------------
diff --git a/cordova-lib/cordova.js b/cordova-lib/cordova.js
index 72252f0..672f76e 100644
--- a/cordova-lib/cordova.js
+++ b/cordova-lib/cordova.js
@@ -920,7 +920,6 @@ module.exports = function(success, fail, service, action, 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;


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[5/5] cordova-browser git commit: Merge branch 'CB-9669'

Posted by pu...@apache.org.
Merge branch 'CB-9669'


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

Branch: refs/heads/master
Commit: e497b0a68b434a92d99aa3899a043cb8359bee68
Parents: 1d2725b 347ff1c
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Mon Oct 19 17:00:31 2015 -0700
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Mon Oct 19 17:00:31 2015 -0700

----------------------------------------------------------------------
 cordova-js-src/exec.js | 92 ++++++++++++++++++++++++++++++++++++++-------
 cordova-lib/cordova.js | 73 +++++++++++++++++++++++++++++------
 2 files changed, 140 insertions(+), 25 deletions(-)
----------------------------------------------------------------------



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


[3/5] cordova-browser git commit: added updated exec to cordova.js built file

Posted by pu...@apache.org.
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