Return-Path: X-Original-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-callback-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9FF43CE12 for ; Fri, 3 Aug 2012 15:18:03 +0000 (UTC) Received: (qmail 67856 invoked by uid 500); 3 Aug 2012 15:18:03 -0000 Delivered-To: apmail-incubator-callback-commits-archive@incubator.apache.org Received: (qmail 67803 invoked by uid 500); 3 Aug 2012 15:18:03 -0000 Mailing-List: contact callback-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: callback-dev@incubator.apache.org Delivered-To: mailing list callback-commits@incubator.apache.org Received: (qmail 67689 invoked by uid 99); 3 Aug 2012 15:18:03 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 03 Aug 2012 15:18:03 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id D5A7E1B95C; Fri, 3 Aug 2012 15:18:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: agrieve@apache.org To: callback-commits@incubator.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [7/9] ios commit: Update CDVCamera and CDVCapture to new exec format. Message-Id: <20120803151802.D5A7E1B95C@tyr.zones.apache.org> Date: Fri, 3 Aug 2012 15:18:02 +0000 (UTC) Update CDVCamera and CDVCapture to new exec format. Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/886a4fc0 Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/886a4fc0 Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/886a4fc0 Branch: refs/heads/master Commit: 886a4fc0283061abaaa7593befc8ff7767e4faf5 Parents: 01eb22d Author: Andrew Grieve Authored: Fri Aug 3 09:55:26 2012 -0400 Committer: Andrew Grieve Committed: Fri Aug 3 11:16:58 2012 -0400 ---------------------------------------------------------------------- CordovaLib/Classes/CDVCamera.h | 4 +- CordovaLib/Classes/CDVCamera.m | 52 +++++++++++++++++---------------- CordovaLib/Classes/CDVCapture.h | 10 +++--- CordovaLib/Classes/CDVCapture.m | 26 +++++++++-------- 4 files changed, 48 insertions(+), 44 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/886a4fc0/CordovaLib/Classes/CDVCamera.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCamera.h b/CordovaLib/Classes/CDVCamera.h index d7f17ad..536b442 100644 --- a/CordovaLib/Classes/CDVCamera.h +++ b/CordovaLib/Classes/CDVCamera.h @@ -80,9 +80,9 @@ typedef NSUInteger CDVMediaType; * options: * quality: integer between 1 and 100 */ -- (void) takePicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void) takePicture:(CDVInvokedUrlCommand*)command; - (void) postImage:(UIImage*)anImage withFilename:(NSString*)filename toUrl:(NSURL*)url; -- (void) cleanup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void) cleanup:(CDVInvokedUrlCommand*)command; - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info; - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo; http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/886a4fc0/CordovaLib/Classes/CDVCamera.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCamera.m b/CordovaLib/Classes/CDVCamera.m index cc691a0..18cf26b 100644 --- a/CordovaLib/Classes/CDVCamera.m +++ b/CordovaLib/Classes/CDVCamera.m @@ -18,6 +18,7 @@ */ #import "CDVCamera.h" +#import "NSArray+Comparisons.h" #import "NSData+Base64.h" #import "NSDictionary+Extensions.h" #import @@ -49,24 +50,25 @@ static NSSet* org_apache_cordova_validArrowDirections; /* takePicture arguments: * INDEX ARGUMENT - * 0 callbackId - * 1 quality - * 2 destination type - * 3 source type - * 4 targetWidth - * 5 targetHeight - * 6 encodingType - * 7 mediaType - * 8 allowsEdit - * 9 correctOrientation - * 10 saveToPhotoAlbum + * 0 quality + * 1 destination type + * 2 source type + * 3 targetWidth + * 4 targetHeight + * 5 encodingType + * 6 mediaType + * 7 allowsEdit + * 8 correctOrientation + * 9 saveToPhotoAlbum */ -- (void) takePicture:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) takePicture:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil]; + NSArray* arguments = command.arguments; self.hasPendingOperation = NO; - NSString* sourceTypeString = [arguments objectAtIndex:3]; + NSString* sourceTypeString = [arguments objectAtIndex:2]; UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera; // default if (sourceTypeString != nil) { @@ -82,10 +84,10 @@ static NSSet* org_apache_cordova_validArrowDirections; } - bool allowEdit = [[arguments objectAtIndex:8] boolValue]; - NSNumber* targetWidth = [arguments objectAtIndex:4]; - NSNumber* targetHeight = [arguments objectAtIndex:5]; - NSNumber* mediaValue = [arguments objectAtIndex:7]; + bool allowEdit = [[arguments objectAtIndex:7] boolValue]; + NSNumber* targetWidth = [arguments objectAtIndex:3]; + NSNumber* targetHeight = [arguments objectAtIndex:4]; + NSNumber* mediaValue = [arguments objectAtIndex:6]; CDVMediaType mediaType = (mediaValue) ? [mediaValue intValue] : MediaTypePicture; CGSize targetSize = CGSizeMake(0, 0); @@ -106,13 +108,13 @@ static NSSet* org_apache_cordova_validArrowDirections; cameraPicker.webView = self.webView; cameraPicker.popoverSupported = [self popoverSupported]; - cameraPicker.correctOrientation = [[arguments objectAtIndex:9] boolValue]; - cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:10] boolValue]; + cameraPicker.correctOrientation = [[arguments objectAtIndex:8] boolValue]; + cameraPicker.saveToPhotoAlbum = [[arguments objectAtIndex:9] boolValue]; - cameraPicker.encodingType = ([arguments objectAtIndex:6]) ? [[arguments objectAtIndex:6] intValue] : EncodingTypeJPEG; + cameraPicker.encodingType = ([arguments objectAtIndex:5]) ? [[arguments objectAtIndex:5] intValue] : EncodingTypeJPEG; - cameraPicker.quality = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : 50; - cameraPicker.returnType = ([arguments objectAtIndex:2]) ? [[arguments objectAtIndex:2] intValue] : DestinationTypeFileUri; + cameraPicker.quality = ([arguments objectAtIndex:0]) ? [[arguments objectAtIndex:0] intValue] : 50; + cameraPicker.returnType = ([arguments objectAtIndex:1]) ? [[arguments objectAtIndex:1] intValue] : DestinationTypeFileUri; if (sourceType == UIImagePickerControllerSourceTypeCamera) { // we only allow taking pictures (no video) in this api @@ -164,9 +166,9 @@ static NSSet* org_apache_cordova_validArrowDirections; self.hasPendingOperation = YES; } -- (void) cleanup:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) cleanup:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; // empty the tmp directory NSFileManager* fileMgr = [[NSFileManager alloc] init]; http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/886a4fc0/CordovaLib/Classes/CDVCapture.h ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCapture.h b/CordovaLib/Classes/CDVCapture.h index 5ade19d..896d7dd 100644 --- a/CordovaLib/Classes/CDVCapture.h +++ b/CordovaLib/Classes/CDVCapture.h @@ -51,13 +51,13 @@ typedef NSUInteger CDVCaptureError; BOOL inUse; } @property BOOL inUse; -- (void) captureAudio:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; -- (void) captureImage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void) captureAudio:(CDVInvokedUrlCommand*)command; +- (void) captureImage:(CDVInvokedUrlCommand*)command; -(NSString*) processImage: (UIImage*) image type: (NSString*) mimeType forCallbackId: (NSString*)callbackId; -- (void) captureVideo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void) captureVideo:(CDVInvokedUrlCommand*)command; -(NSString*) processVideo: (NSString*) moviePath forCallbackId: (NSString*) callbackId; -- (void) getMediaModes: (NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; -- (void) getFormatData: (NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; +- (void) getMediaModes:(CDVInvokedUrlCommand*)command; +- (void) getFormatData:(CDVInvokedUrlCommand*)command; -(NSDictionary*) getMediaDictionaryFromPath: (NSString*) fullPath ofType: (NSString*) type; - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info; - (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo; http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/886a4fc0/CordovaLib/Classes/CDVCapture.m ---------------------------------------------------------------------- diff --git a/CordovaLib/Classes/CDVCapture.m b/CordovaLib/Classes/CDVCapture.m index 1627085..c33e90a 100644 --- a/CordovaLib/Classes/CDVCapture.m +++ b/CordovaLib/Classes/CDVCapture.m @@ -59,9 +59,10 @@ } return self; } -- (void) captureAudio:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) captureAudio:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSDictionary* options = [command.arguments objectAtIndex:0]; NSNumber* duration = [options objectForKey:@"duration"]; // the default value of duration is 0 so use nil (no duration) if default value if (duration) { @@ -94,9 +95,10 @@ } } -- (void) captureImage:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) captureImage:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; + NSDictionary* options = [command.arguments objectAtIndex:0]; NSString* mode = [options objectForKey:@"mode"]; //options could contain limit and mode neither of which are supported at this time @@ -193,9 +195,9 @@ return jsString; } -- (void) captureVideo:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) captureVideo:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; //options could contain limit, duration and mode, only duration is supported (but is not due to apple bug) // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property //NSNumber* duration = [options objectForKey:@"duration"]; @@ -278,7 +280,7 @@ return jsString; } -- (void) getMediaModes: (NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) getMediaModes:(CDVInvokedUrlCommand*)command { // NSString* callbackId = [arguments objectAtIndex:0]; //NSMutableDictionary* imageModes = nil; @@ -327,15 +329,15 @@ } -- (void) getFormatData: (NSMutableArray*)arguments withDict:(NSMutableDictionary*)options +- (void) getFormatData:(CDVInvokedUrlCommand*)command { - NSString* callbackId = [arguments objectAtIndex:0]; + NSString* callbackId = command.callbackId; // existence of fullPath checked on JS side - NSString* fullPath = [arguments objectAtIndex:1]; + NSString* fullPath = [command.arguments objectAtIndex:0]; // mimeType could be null NSString* mimeType = nil; - if ([arguments count] > 2) { - mimeType = [arguments objectAtIndex:2]; + if ([command.arguments count] > 1) { + mimeType = [command.arguments objectAtIndex:1]; } BOOL bError = NO; CDVCaptureError errorCode = CAPTURE_INTERNAL_ERR;