cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mmo...@apache.org
Subject [48/50] js commit: ios: change exec to support multipart messages
Date Mon, 25 Feb 2013 13:40:49 GMT
ios: change exec to support multipart messages

Adding a new CDVType: MultiPart message type, which has an array of
messages, each of which must be "massaged" the same way as single
messages are (e.g. deserialize ArrayBuffers).

Right now, multipart messages are delivered as a single array argument
to the callback, because exec callbacks do not support multiple js
arugments at the moment.  This would be a good thing to change in the
future.


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

Branch: refs/heads/multipart_plugin_result
Commit: c03988ec05e218431f2b594ae32511a9e0fd1504
Parents: aa5548f
Author: Michal Mocny <mmocny@gmail.com>
Authored: Mon Feb 11 17:07:18 2013 -0500
Committer: Michal Mocny <mmocny@gmail.com>
Committed: Mon Feb 25 08:33:16 2013 -0500

----------------------------------------------------------------------
 lib/ios/exec.js |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-js/blob/c03988ec/lib/ios/exec.js
----------------------------------------------------------------------
diff --git a/lib/ios/exec.js b/lib/ios/exec.js
index 58e73d2..20c9dbe 100644
--- a/lib/ios/exec.js
+++ b/lib/ios/exec.js
@@ -86,7 +86,10 @@ function massageArgsJsToNative(args) {
 }
 
 function massagePayloadNativeToJs(payload) {
-    if (payload && payload.hasOwnProperty('CDVType') && payload.CDVType ==
'ArrayBuffer') {
+    if (!payload || !payload.hasOwnProperty('CDVType')) {
+        return payload;
+    }
+    if (payload.CDVType == 'ArrayBuffer') {
         var stringToArrayBuffer = function(str) {
             var ret = new Uint8Array(str.length);
             for (var i = 0; i < str.length; i++) {
@@ -98,6 +101,11 @@ function massagePayloadNativeToJs(payload) {
             return stringToArrayBuffer(atob(b64));
         };
         payload = base64ToArrayBuffer(payload.data);
+    } else if (payload.CDVType == 'MultiPart') {
+        payload = payload.messages;
+        payload.forEach(function(e,i) {
+            payload[i] = massagePayloadNativeToJs(e);
+        });
     }
     return payload;
 }


Mime
View raw message