You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by mm...@apache.org on 2013/02/25 14:41:00 UTC

[49/50] ios commit: [ios]: update Echo to support testing MultiPart

[ios]: update Echo to support testing MultiPart


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

Branch: refs/heads/multipart_plugin_result
Commit: 2d19cd040869f600e7079d974455ae4a28e11d31
Parents: 6bb1a85
Author: Michal Mocny <mm...@gmail.com>
Authored: Fri Feb 22 11:19:40 2013 -0500
Committer: Michal Mocny <mm...@gmail.com>
Committed: Mon Feb 25 08:38:09 2013 -0500

----------------------------------------------------------------------
 CordovaLib/Classes/CDVEcho.m         |    7 ++++++
 CordovaLib/Classes/CDVPluginResult.m |   32 ++++++++++++++++------------
 hooks/pre-commit                     |    1 +
 3 files changed, 26 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2d19cd04/CordovaLib/Classes/CDVEcho.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVEcho.m b/CordovaLib/Classes/CDVEcho.m
index 916e315..c74990d 100644
--- a/CordovaLib/Classes/CDVEcho.m
+++ b/CordovaLib/Classes/CDVEcho.m
@@ -51,4 +51,11 @@
     [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
 }
 
+- (void)echoMultiPart:(CDVInvokedUrlCommand*)command
+{
+    CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsMultipart:command.arguments];
+
+    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
+}
+
 @end

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2d19cd04/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index a8f5689..a03e005 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.m
@@ -35,10 +35,18 @@ static NSArray* org_apache_cordova_CommandStatusMsgs;
 
 id messageFromArrayBuffer(NSData* data)
 {
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-        @"ArrayBuffer", @"CDVType",
-        [data base64EncodedString], @"data",
-        nil];
+    return @{
+        @"CDVType" : @"ArrayBuffer",
+        @"data" :[data base64EncodedString]
+    };
+}
+
+id massageMessage(id message)
+{
+    if ([message isKindOfClass:[NSData class]]) {
+        return messageFromArrayBuffer(message);
+    }
+    return message;
 }
 
 id messageFromMultipart(NSArray* theMessages)
@@ -46,17 +54,13 @@ id messageFromMultipart(NSArray* theMessages)
     NSMutableArray* messages = [NSMutableArray arrayWithArray:theMessages];
 
     for (NSUInteger i = 0; i < messages.count; ++i) {
-        id message = [messages objectAtIndex:i];
-
-        if ([message isKindOfClass:[NSData class]]) {
-            [messages replaceObjectAtIndex:i withObject:messageFromArrayBuffer(message)];
-        }
+        [messages replaceObjectAtIndex:i withObject:massageMessage([messages objectAtIndex:i])];
     }
 
-    return [NSDictionary dictionaryWithObjectsAndKeys:
-        @"MultiPart", @"CDVType",
-        messages, @"messages",
-        nil];
+    return @{
+        @"CDVType" : @"MultiPart",
+        @"messages" : messages
+    };
 }
 
 + (void)initialize
@@ -137,7 +141,7 @@ id messageFromMultipart(NSArray* theMessages)
 
 + (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
 {
-    NSDictionary* errDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
+    NSDictionary* errDict = @{@"code": [NSNumber numberWithInt:errorCode]};
 
     return [[self alloc] initWithStatus:statusOrdinal message:errDict];
 }

http://git-wip-us.apache.org/repos/asf/cordova-ios/blob/2d19cd04/hooks/pre-commit
----------------------------------------------------------------------
diff --git a/hooks/pre-commit b/hooks/pre-commit
index 7a420c9..03ff08c 100755
--- a/hooks/pre-commit
+++ b/hooks/pre-commit
@@ -20,6 +20,7 @@
 
 # Redirect output to stderr.
 exec 1>&2
+test $SKIP_UNCRUSTIFY && exit 0
 
 RET=0
 files=$(bin/uncrustify.sh --filter $(git diff --cached --name-only))