incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [8/11] bin/uncrustify.sh --all
Date Fri, 21 Sep 2012 15:16:14 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVSound.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.h b/CordovaLib/Classes/CDVSound.h
old mode 100755
new mode 100644
index 78a7afa..7fbd52c
--- a/CordovaLib/Classes/CDVSound.h
+++ b/CordovaLib/Classes/CDVSound.h
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,61 +17,57 @@
  under the License.
  */
 
-
 #import <Foundation/Foundation.h>
 #import <AudioToolbox/AudioServices.h>
 #import <AVFoundation/AVFoundation.h>
 
 #import "CDVPlugin.h"
 
-
-
-
 enum CDVMediaError {
-	MEDIA_ERR_ABORTED = 1,
-	MEDIA_ERR_NETWORK = 2,
-	MEDIA_ERR_DECODE = 3,
-	MEDIA_ERR_NONE_SUPPORTED = 4
+    MEDIA_ERR_ABORTED = 1,
+    MEDIA_ERR_NETWORK = 2,
+    MEDIA_ERR_DECODE = 3,
+    MEDIA_ERR_NONE_SUPPORTED = 4
 };
 typedef NSUInteger CDVMediaError;
 
 enum CDVMediaStates {
-	MEDIA_NONE = 0,
-	MEDIA_STARTING = 1,
-	MEDIA_RUNNING = 2,
-	MEDIA_PAUSED = 3,
-	MEDIA_STOPPED = 4
+    MEDIA_NONE = 0,
+    MEDIA_STARTING = 1,
+    MEDIA_RUNNING = 2,
+    MEDIA_PAUSED = 3,
+    MEDIA_STOPPED = 4
 };
 typedef NSUInteger CDVMediaStates;
 
 enum CDVMediaMsg {
-	MEDIA_STATE = 1,
-	MEDIA_DURATION = 2,
+    MEDIA_STATE = 1,
+    MEDIA_DURATION = 2,
     MEDIA_POSITION = 3,
-	MEDIA_ERROR = 9
+    MEDIA_ERROR = 9
 };
 typedef NSUInteger CDVMediaMsg;
 
 @interface CDVAudioPlayer : AVAudioPlayer
 {
-	NSString* mediaId;
+    NSString* mediaId;
 }
-@property (nonatomic,copy) NSString* mediaId;
+@property (nonatomic, copy) NSString* mediaId;
 @end
 
 @interface CDVAudioRecorder : AVAudioRecorder
 {
-	NSString* mediaId;
+    NSString* mediaId;
 }
-@property (nonatomic,copy) NSString* mediaId;
+@property (nonatomic, copy) NSString* mediaId;
 @end
-	
+
 @interface CDVAudioFile : NSObject
 {
-	NSString* resourcePath;
-	NSURL* resourceURL;
-	CDVAudioPlayer* player;
-	CDVAudioRecorder* recorder;
+    NSString* resourcePath;
+    NSURL* resourceURL;
+    CDVAudioPlayer* player;
+    CDVAudioRecorder* recorder;
     NSNumber* volume;
 }
 
@@ -86,44 +82,51 @@ typedef NSUInteger CDVMediaMsg;
 
 @interface CDVSound : CDVPlugin <AVAudioPlayerDelegate, AVAudioRecorderDelegate>
 {
-	NSMutableDictionary* soundCache;
+    NSMutableDictionary* soundCache;
     AVAudioSession* avSession;
 }
 @property (nonatomic, strong) NSMutableDictionary* soundCache;
 @property (nonatomic, strong) AVAudioSession* avSession;
-//DEPRECATED
-- (void) play:(CDVInvokedUrlCommand*)command __attribute__((deprecated));	  	
-- (void) pause:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
-- (void) stop:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
 // DEPRECATED
+- (void)play:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+
+- (void)pause:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
 
-- (void) startPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void) pausePlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void) stopPlayingAudio:(CDVInvokedUrlCommand*)command;
-- (void) seekToAudio:(CDVInvokedUrlCommand*)command;
-- (void) release:(CDVInvokedUrlCommand*)command;
-- (void) getCurrentPositionAudio:(CDVInvokedUrlCommand*)command;
+- (void)stop:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
 
 // DEPRECATED
-- (void) getCurrentPosition:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
-- (void) prepare:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+
+- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command;
+- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command;
+- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command;
+- (void)seekToAudio:(CDVInvokedUrlCommand*)command;
+- (void)release:(CDVInvokedUrlCommand*)command;
+- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command;
+
 // DEPRECATED
+- (void)getCurrentPosition:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
 
-- (BOOL) hasAudioSession;
+- (void)prepare:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+
+// DEPRECATED
+
+- (BOOL)hasAudioSession;
 
 // helper methods
-- (CDVAudioFile*) audioFileForResource:(NSString*) resourcePath withId: (NSString*)mediaId;
-- (BOOL) prepareToPlay: (CDVAudioFile*) audioFile withId: (NSString*)mediaId;
-- (NSString*) createMediaErrorWithCode: (CDVMediaError) code message: (NSString*) message;
+- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId;
+- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId;
+- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message;
 
 // DEPRECATED
-- (void) startAudioRecord:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
-- (void) stopAudioRecord:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+- (void)startAudioRecord:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+
+- (void)stopAudioRecord:(CDVInvokedUrlCommand*)command __attribute__((deprecated));
+
 // DEPRECATED
 
-- (void) startRecordingAudio:(CDVInvokedUrlCommand*)command;
-- (void) stopRecordingAudio:(CDVInvokedUrlCommand*)command;
+- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command;
+- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command;
 
-- (void) setVolume:(CDVInvokedUrlCommand*)command;
+- (void)setVolume:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVSound.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSound.m b/CordovaLib/Classes/CDVSound.m
index c4a3319..ccff3e3 100644
--- a/CordovaLib/Classes/CDVSound.m
+++ b/CordovaLib/Classes/CDVSound.m
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,14 +17,13 @@
  under the License.
  */
 
-
 #import "CDVSound.h"
 #import "CDVViewController.h"
 #import "NSArray+Comparisons.h"
 
-#define DOCUMENTS_SCHEME_PREFIX		@"documents://"
-#define HTTP_SCHEME_PREFIX			@"http://"
-#define HTTPS_SCHEME_PREFIX			@"https://"
+#define DOCUMENTS_SCHEME_PREFIX @"documents://"
+#define HTTP_SCHEME_PREFIX @"http://"
+#define HTTPS_SCHEME_PREFIX @"https://"
 
 @implementation CDVSound
 
@@ -32,34 +31,32 @@
 
 // Maps a url for a resource path
 // "Naked" resource paths are assumed to be from the www folder as its base
-- (NSURL*) urlForResource:(NSString*)resourcePath
+- (NSURL*)urlForResource:(NSString*)resourcePath
 {
-	NSURL* resourceURL = nil;
+    NSURL* resourceURL = nil;
     NSString* filePath = nil;
-	
+
     // first try to find HTTP:// or Documents:// resources
-    
-    if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]){
+
+    if ([resourcePath hasPrefix:HTTP_SCHEME_PREFIX] || [resourcePath hasPrefix:HTTPS_SCHEME_PREFIX]) {
         // if it is a http url, use it
         NSLog(@"Will use resource '%@' from the Internet.", resourcePath);
         resourceURL = [NSURL URLWithString:resourcePath];
     } else if ([resourcePath hasPrefix:DOCUMENTS_SCHEME_PREFIX]) {
-        filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/",[CDVViewController applicationDocumentsDirectory]]];
-       NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
+        filePath = [resourcePath stringByReplacingOccurrencesOfString:DOCUMENTS_SCHEME_PREFIX withString:[NSString stringWithFormat:@"%@/", [CDVViewController applicationDocumentsDirectory]]];
+        NSLog(@"Will use resource '%@' from the documents folder with path = %@", resourcePath, filePath);
     } else {
         // attempt to find file path in www directory
         filePath = [self.commandDelegate pathForResource:resourcePath];
         if (filePath != nil) {
             NSLog(@"Found resource '%@' in the web folder.", filePath);
-        }else {
+        } else {
             filePath = resourcePath;
             NSLog(@"Will attempt to use file resource '%@'", filePath);
-            
         }
-
     }
     // check that file exists for all but HTTP_SHEME_PREFIX
-    if(filePath != nil) {
+    if (filePath != nil) {
         // try to access file
         NSFileManager* fMgr = [[NSFileManager alloc] init];
         if (![fMgr fileExistsAtPath:filePath]) {
@@ -69,61 +66,63 @@
             // it's a valid file url, use it
             resourceURL = [NSURL fileURLWithPath:filePath];
         }
-    }     
-	return resourceURL;
+    }
+    return resourceURL;
 }
 
 // Creates or gets the cached audio file resource object
-- (CDVAudioFile*) audioFileForResource:(NSString*) resourcePath withId: (NSString*)mediaId
+- (CDVAudioFile*)audioFileForResource:(NSString*)resourcePath withId:(NSString*)mediaId
 {
-	BOOL bError = NO;
-	CDVMediaError errcode = MEDIA_ERR_NONE_SUPPORTED;
+    BOOL bError = NO;
+    CDVMediaError errcode = MEDIA_ERR_NONE_SUPPORTED;
     NSString* errMsg = @"";
-	NSString* jsString = nil;
-	CDVAudioFile* audioFile = nil;
-	NSURL* resourceURL = nil;
-	
-	if ([self soundCache] == nil) {
-		[self setSoundCache: [NSMutableDictionary dictionaryWithCapacity:1]];
-	}else {
-		audioFile = [[self soundCache] objectForKey: mediaId];
-	}
-	if (audioFile == nil){
-		// validate resourcePath and create
-	
-		if (resourcePath == nil || ![resourcePath isKindOfClass:[NSString class]] || [resourcePath isEqualToString:@""]){
-			bError = YES;
-			errcode = MEDIA_ERR_ABORTED;
-			errMsg = @"invalid media src argument";
-		} else {
-			resourceURL = [self urlForResource:resourcePath];
-		}
-
-		if (resourceURL == nil) {
-			bError = YES;
-			errcode = MEDIA_ERR_ABORTED;
-			errMsg = [NSString stringWithFormat: @"Cannot use audio file from resource '%@'", resourcePath];
-		}
-		if (bError) {
-			//jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, errcode];
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR,[self createMediaErrorWithCode: errcode message: errMsg]];
-			[super writeJavascript:jsString];
-		} else {
-			audioFile = [[CDVAudioFile alloc] init];
-			audioFile.resourcePath = resourcePath;
-			audioFile.resourceURL = resourceURL;
-			[[self soundCache] setObject:audioFile forKey: mediaId];
-		}
-	}
-	return audioFile;
+    NSString* jsString = nil;
+    CDVAudioFile* audioFile = nil;
+    NSURL* resourceURL = nil;
+
+    if ([self soundCache] == nil) {
+        [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
+    } else {
+        audioFile = [[self soundCache] objectForKey:mediaId];
+    }
+    if (audioFile == nil) {
+        // validate resourcePath and create
+
+        if ((resourcePath == nil) || ![resourcePath isKindOfClass:[NSString class]] || [resourcePath isEqualToString:@""]) {
+            bError = YES;
+            errcode = MEDIA_ERR_ABORTED;
+            errMsg = @"invalid media src argument";
+        } else {
+            resourceURL = [self urlForResource:resourcePath];
+        }
+
+        if (resourceURL == nil) {
+            bError = YES;
+            errcode = MEDIA_ERR_ABORTED;
+            errMsg = [NSString stringWithFormat:@"Cannot use audio file from resource '%@'", resourcePath];
+        }
+        if (bError) {
+            // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, errcode];
+            jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:errcode message:errMsg]];
+            [super writeJavascript:jsString];
+        } else {
+            audioFile = [[CDVAudioFile alloc] init];
+            audioFile.resourcePath = resourcePath;
+            audioFile.resourceURL = resourceURL;
+            [[self soundCache] setObject:audioFile forKey:mediaId];
+        }
+    }
+    return audioFile;
 }
-// returns whether or not audioSession is available - creates it if necessary 
-- (BOOL) hasAudioSession
+
+// returns whether or not audioSession is available - creates it if necessary
+- (BOOL)hasAudioSession
 {
     BOOL bSession = YES;
+
     if (!self.avSession) {
         NSError* error = nil;
-        
+
         self.avSession = [AVAudioSession sharedInstance];
         if (error) {
             // is not fatal if can't get AVAudioSession , just log the error
@@ -134,34 +133,36 @@
     }
     return bSession;
 }
+
 // helper function to create a error object string
-- (NSString*) createMediaErrorWithCode: (CDVMediaError) code message: (NSString*) message
+- (NSString*)createMediaErrorWithCode:(CDVMediaError)code message:(NSString*)message
 {
     NSMutableDictionary* errorDict = [NSMutableDictionary dictionaryWithCapacity:2];
-    [errorDict setObject: [NSNumber numberWithUnsignedInt: code] forKey:@"code"];
-    [errorDict setObject: message ? message : @"" forKey: @"message"];
+
+    [errorDict setObject:[NSNumber numberWithUnsignedInt:code] forKey:@"code"];
+    [errorDict setObject:message ? message:@"" forKey:@"message"];
     return [errorDict cdvjk_JSONString];
-    
 }
+
 // DEPRECATED
-- (void) play:(CDVInvokedUrlCommand*)command
+- (void)play:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"play is DEPRECATED!  Use startPlayingAudio.");
     [self startPlayingAudio:command];
 }
 
-- (void) create:(CDVInvokedUrlCommand*)command
+- (void)create:(CDVInvokedUrlCommand*)command
 {
-	NSString* callbackId = command.callbackId;
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+    NSString* mediaId = [command.arguments objectAtIndex:0];
     NSString* resourcePath = [command.arguments objectAtIndex:1];
-    
+
     CDVPluginResult* result;
-    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId: mediaId];
-    
+    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId];
+
     if (audioFile == nil) {
         NSString* errorMessage = [NSString stringWithFormat:@"Failed to initialize Media file with path %@", resourcePath];
-        NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR,[self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: errorMessage]];
+        NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMessage]];
         [super writeJavascript:jsString];
     } else {
         result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
@@ -169,56 +170,58 @@
     }
 }
 
-- (void) setVolume:(CDVInvokedUrlCommand*)command
+- (void)setVolume:(CDVInvokedUrlCommand*)command
 {
-    NSString* callbackId = command.callbackId; 
-    #pragma unused(callbackId)
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+
+#pragma unused(callbackId)
+    NSString* mediaId = [command.arguments objectAtIndex:0];
     NSNumber* volume = [command.arguments objectAtIndex:1 withDefault:[NSNumber numberWithFloat:1.0]];
-    
+
     CDVAudioFile* audioFile;
-	if ([self soundCache] == nil) {
-		[self setSoundCache: [NSMutableDictionary dictionaryWithCapacity:1]];
-	} else {
-		audioFile = [[self soundCache] objectForKey: mediaId];
+    if ([self soundCache] == nil) {
+        [self setSoundCache:[NSMutableDictionary dictionaryWithCapacity:1]];
+    } else {
+        audioFile = [[self soundCache] objectForKey:mediaId];
         audioFile.volume = volume;
         [[self soundCache] setObject:audioFile forKey:mediaId];
-	}
-    
+    }
+
     // don't care for any callbacks
 }
 
-- (void) startPlayingAudio:(CDVInvokedUrlCommand*)command
+- (void)startPlayingAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* callbackId = command.callbackId;
-    #pragma unused(callbackId)
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+
+#pragma unused(callbackId)
+    NSString* mediaId = [command.arguments objectAtIndex:0];
     NSString* resourcePath = [command.arguments objectAtIndex:1];
     NSDictionary* options = [command.arguments objectAtIndex:2 withDefault:nil];
-    
-	BOOL bError = NO;
-	NSString* jsString = nil;
-	
-	CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId: mediaId];
-	
-	if (audioFile != nil) {
-		if (audioFile.player == nil){
+
+    BOOL bError = NO;
+    NSString* jsString = nil;
+
+    CDVAudioFile* audioFile = [self audioFileForResource:resourcePath withId:mediaId];
+
+    if (audioFile != nil) {
+        if (audioFile.player == nil) {
             bError = [self prepareToPlay:audioFile withId:mediaId];
-		}	
-		if (!bError){
-			// audioFile.player != nil  or player was sucessfully created
+        }
+        if (!bError) {
+            // audioFile.player != nil  or player was sucessfully created
             // get the audioSession and set the category to allow Playing when device is locked or ring/silent switch engaged
             if ([self hasAudioSession]) {
                 NSError* __autoreleasing err = nil;
                 NSNumber* playAudioWhenScreenIsLocked = [options objectForKey:@"playAudioWhenScreenIsLocked"];
                 BOOL bPlayAudioWhenScreenIsLocked = YES;
-                if (playAudioWhenScreenIsLocked != nil) { 
+                if (playAudioWhenScreenIsLocked != nil) {
                     bPlayAudioWhenScreenIsLocked = [playAudioWhenScreenIsLocked boolValue];
                 }
-                
-                NSString* sessionCategory = bPlayAudioWhenScreenIsLocked? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient;
+
+                NSString* sessionCategory = bPlayAudioWhenScreenIsLocked ? AVAudioSessionCategoryPlayback : AVAudioSessionCategorySoloAmbient;
                 [self.avSession setCategory:sessionCategory error:&err];
-                if (![self.avSession  setActive: YES error: &err]){
+                if (![self.avSession setActive:YES error:&err]) {
                     // other audio with higher priority that does not allow mixing could cause this to fail
                     NSLog(@"Unable to play audio: %@", [err localizedFailureReason]);
                     bError = YES;
@@ -228,77 +231,77 @@
                 NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
                 NSNumber* loopOption = [options objectForKey:@"numberOfLoops"];
                 NSInteger numberOfLoops = 0;
-                if (loopOption != nil) { 
+                if (loopOption != nil) {
                     numberOfLoops = [loopOption intValue] - 1;
                 }
                 audioFile.player.numberOfLoops = numberOfLoops;
-                if(audioFile.player.isPlaying){
+                if (audioFile.player.isPlaying) {
                     [audioFile.player stop];
                     audioFile.player.currentTime = 0;
                 }
                 if (audioFile.volume != nil) {
                     audioFile.player.volume = [audioFile.volume floatValue];
                 }
-                
+
                 [audioFile.player play];
-                double position = round(audioFile.player.duration * 1000)/1000;
-                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
+                double position = round(audioFile.player.duration * 1000) / 1000;
+                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_DURATION, position, @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
                 [super writeJavascript:jsString];
-                
             }
         }
         if (bError) {
-			/*  I don't see a problem playing previously recorded audio so removing this section - BG
-			NSError* error;
-			// try loading it one more time, in case the file was recorded previously
-			audioFile.player = [[ AVAudioPlayer alloc ] initWithContentsOfURL:audioFile.resourceURL error:&error];
-			if (error != nil) {
-				NSLog(@"Failed to initialize AVAudioPlayer: %@\n", error);
-				audioFile.player = nil;
-			} else {
-				NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
-				audioFile.player.numberOfLoops = numberOfLoops;
-				[audioFile.player play];
-			} */
-			// error creating the session or player
-			//jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR,  MEDIA_ERR_NONE_SUPPORTED];
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_NONE_SUPPORTED message: nil]];
-			[super writeJavascript:jsString];
-		}
-	}
-	// else audioFile was nil - error already returned from audioFile for resource
-	return;
+            /*  I don't see a problem playing previously recorded audio so removing this section - BG
+            NSError* error;
+            // try loading it one more time, in case the file was recorded previously
+            audioFile.player = [[ AVAudioPlayer alloc ] initWithContentsOfURL:audioFile.resourceURL error:&error];
+            if (error != nil) {
+                NSLog(@"Failed to initialize AVAudioPlayer: %@\n", error);
+                audioFile.player = nil;
+            } else {
+                NSLog(@"Playing audio sample '%@'", audioFile.resourcePath);
+                audioFile.player.numberOfLoops = numberOfLoops;
+                [audioFile.player play];
+            } */
+            // error creating the session or player
+            // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR,  MEDIA_ERR_NONE_SUPPORTED];
+            jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_NONE_SUPPORTED message:nil]];
+            [super writeJavascript:jsString];
+        }
+    }
+    // else audioFile was nil - error already returned from audioFile for resource
+    return;
 }
-- (BOOL) prepareToPlay: (CDVAudioFile*) audioFile withId: (NSString*) mediaId
+
+- (BOOL)prepareToPlay:(CDVAudioFile*)audioFile withId:(NSString*)mediaId
 {
     BOOL bError = NO;
     NSError* __autoreleasing playerError = nil;
-    
+
     // create the player
     NSURL* resourceURL = audioFile.resourceURL;
+
     if ([resourceURL isFileURL]) {
-        audioFile.player = [[ CDVAudioPlayer alloc ] initWithContentsOfURL:resourceURL error:&playerError];
+        audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:resourceURL error:&playerError];
     } else {
-        NSURLRequest *request = [NSURLRequest requestWithURL:resourceURL];
-        NSURLResponse * __autoreleasing response = nil;
+        NSURLRequest* request = [NSURLRequest requestWithURL:resourceURL];
+        NSURLResponse* __autoreleasing response = nil;
         NSData* data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&playerError];
         if (playerError) {
             NSLog(@"Unable to download audio from: %@", [resourceURL absoluteString]);
         } else {
-            
             // bug in AVAudioPlayer when playing downloaded data in NSData - we have to download the file and play from disk
             CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
             CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
-            NSString* filePath = [NSString stringWithFormat:@"%@/%@.mp3", [NSTemporaryDirectory() stringByStandardizingPath], uuidString];
+            NSString* filePath = [NSString stringWithFormat:@"%@/%@.mp3", [NSTemporaryDirectory ()stringByStandardizingPath], uuidString];
             CFRelease(uuidString);
             CFRelease(uuidRef);
-            
-            [data writeToFile:filePath atomically:YES];            
+
+            [data writeToFile:filePath atomically:YES];
             NSURL* fileURL = [NSURL fileURLWithPath:filePath];
-            audioFile.player = [[ CDVAudioPlayer alloc ] initWithContentsOfURL:fileURL error:&playerError];
+            audioFile.player = [[CDVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&playerError];
         }
     }
-    
+
     if (playerError != nil) {
         NSLog(@"Failed to initialize AVAudioPlayer: %@\n", [playerError localizedDescription]);
         audioFile.player = nil;
@@ -318,21 +321,21 @@
 // Calls the success call back immediately as there is no mechanism to determine that the file is loaded
 // other than the return from prepareToPlay.  Thus, IMHO not really worth calling
 
-- (void) prepare:(CDVInvokedUrlCommand*)command
+- (void)prepare:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"prepare is DEPRECATED! Recoding will be prepared when startPlayingAudio is called");
-    
-	NSString* callbackId = command.callbackId; 
-    
+
+    NSString* callbackId = command.callbackId;
+
     NSString* mediaId = [command.arguments objectAtIndex:0];
     BOOL bError = NO;
     CDVMediaStates state = MEDIA_STARTING;
     NSString* jsString = nil;
-    
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
+
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
     if (audioFile == nil) {
         // did not already exist, try to create
-        audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId: mediaId];
+        audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId:mediaId];
         if (audioFile == nil) {
             // create failed
             bError = YES;
@@ -345,298 +348,290 @@
             state = MEDIA_RUNNING;
         }
     }
-    
+
     if (!bError) {
-        
         // NSLog(@"Prepared audio sample '%@' for playback.", audioFile.resourcePath);
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, state, [result toSuccessCallbackString:callbackId]];
-        
-	} else {
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_NONE_SUPPORTED message: nil]];   
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, state, [result toSuccessCallbackString:callbackId]];
+    } else {
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_NONE_SUPPORTED message:nil]];
     }
     if (jsString) {
         [super writeJavascript:jsString];
     }
-	
 }
 
 // DEPRECATED
-- (void) stop:(CDVInvokedUrlCommand*)command
+- (void)stop:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"stop is DEPRECATED!  Use stopPlayingAudio.");
     [self stopPlayingAudio:command];
 }
 
-- (void) stopPlayingAudio:(CDVInvokedUrlCommand*)command
+- (void)stopPlayingAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* mediaId = [command.arguments objectAtIndex:0];
-    CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
-	NSString* jsString = nil;
+    NSString* mediaId = [command.arguments objectAtIndex:0];
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
+    NSString* jsString = nil;
 
-	if (audioFile != nil && audioFile.player!= nil) {
+    if ((audioFile != nil) && (audioFile.player != nil)) {
         NSLog(@"Stopped playing audio sample '%@'", audioFile.resourcePath);
         [audioFile.player stop];
         audioFile.player.currentTime = 0;
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
-	}  // ignore if no media playing 
-    if (jsString){
-        [super writeJavascript: jsString];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
+    }  // ignore if no media playing
+    if (jsString) {
+        [super writeJavascript:jsString];
     }
 }
+
 // DEPRECATED
-- (void) pause:(CDVInvokedUrlCommand*)command
+- (void)pause:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"pause is DEPRECATED!  Use pausePlayingAudio.");
     [self pausePlayingAudio:command];
 }
 
-- (void) pausePlayingAudio:(CDVInvokedUrlCommand*)command
+- (void)pausePlayingAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* mediaId = [command.arguments objectAtIndex:0];
     NSString* jsString = nil;
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
-	
-	if (audioFile != nil && audioFile.player != nil) {
-            NSLog(@"Paused playing audio sample '%@'", audioFile.resourcePath);
-			[audioFile.player pause];
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_PAUSED];
-	} 
-    // ignore if no media playing
-      
-    
-    if (jsString){
-        [super writeJavascript: jsString];
-    }
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
 
+    if ((audioFile != nil) && (audioFile.player != nil)) {
+        NSLog(@"Paused playing audio sample '%@'", audioFile.resourcePath);
+        [audioFile.player pause];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_PAUSED];
+    }
+    // ignore if no media playing
 
+    if (jsString) {
+        [super writeJavascript:jsString];
+    }
 }
-- (void) seekToAudio:(CDVInvokedUrlCommand*)command
+
+- (void)seekToAudio:(CDVInvokedUrlCommand*)command
 {
-	//args:
+    // args:
     // 0 = Media id
     // 1 = path to resource
     // 2 = seek to location in milliseconds
-	
-	NSString* mediaId = [command.arguments objectAtIndex:0];
 
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
+    NSString* mediaId = [command.arguments objectAtIndex:0];
+
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
     double position = [[command.arguments objectAtIndex:1] doubleValue];
-	
-    if (audioFile != nil && audioFile.player != nil && position){
-        double posInSeconds = position/1000;
+
+    if ((audioFile != nil) && (audioFile.player != nil) && position) {
+        double posInSeconds = position / 1000;
         audioFile.player.currentTime = posInSeconds;
-        NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%f);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, posInSeconds];
+        NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%f);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, posInSeconds];
 
-        [super writeJavascript: jsString];
-        
+        [super writeJavascript:jsString];
     }
-    
-	return;
-    
+
+    return;
 }
 
-- (void) release:(CDVInvokedUrlCommand*)command
+- (void)release:(CDVInvokedUrlCommand*)command
 {
     NSString* mediaId = [command.arguments objectAtIndex:0];
 
-	if (mediaId != nil){
-		CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
-		if (audioFile != nil){
-			if (audioFile.player && [audioFile.player isPlaying]){
-				[audioFile.player stop];
-			}
-			if(audioFile.recorder && [audioFile.recorder isRecording]){
-				[audioFile.recorder stop];
-			}
+    if (mediaId != nil) {
+        CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
+        if (audioFile != nil) {
+            if (audioFile.player && [audioFile.player isPlaying]) {
+                [audioFile.player stop];
+            }
+            if (audioFile.recorder && [audioFile.recorder isRecording]) {
+                [audioFile.recorder stop];
+            }
             if (self.avSession) {
-                [self.avSession setActive:NO error: nil];
+                [self.avSession setActive:NO error:nil];
                 self.avSession = nil;
             }
-			[[self soundCache] removeObjectForKey: mediaId];
-			NSLog(@"Media with id %@ released", mediaId);
-		}
-	}
+            [[self soundCache] removeObjectForKey:mediaId];
+            NSLog(@"Media with id %@ released", mediaId);
+        }
+    }
 }
+
 // DEPRECATED
-- (void) getCurrentPosition:(CDVInvokedUrlCommand*)command
+- (void)getCurrentPosition:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"getCurrentPosition is DEPRECATED!  Use getCurrentPositionAudio.");
     [self getCurrentPositionAudio:command];
 }
 
-- (void) getCurrentPositionAudio:(CDVInvokedUrlCommand*)command
+- (void)getCurrentPositionAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* callbackId = command.callbackId;
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+    NSString* mediaId = [command.arguments objectAtIndex:0];
+
 #pragma unused(mediaId)
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
     double position = -1;
-	
-    if (audioFile != nil && audioFile.player != nil && [audioFile.player isPlaying]){ 
-            position = round(audioFile.player.currentTime *1000)/1000;
+
+    if ((audioFile != nil) && (audioFile.player != nil) && [audioFile.player isPlaying]) {
+        position = round(audioFile.player.currentTime * 1000) / 1000;
     }
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble: position];
-	NSString* jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%.3f);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
+    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDouble:position];
+    NSString* jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%.3f);\n%@", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_POSITION, position, [result toSuccessCallbackString:callbackId]];
     [super writeJavascript:jsString];
-    
-	return;
-		
+
+    return;
 }
+
 // DEPRECATED
-- (void) startAudioRecord:(CDVInvokedUrlCommand*)command
+- (void)startAudioRecord:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"startAudioRecord is DEPRECATED!  Use startRecordingAudio.");
     [self startRecordingAudio:command];
 }
 
-- (void) startRecordingAudio:(CDVInvokedUrlCommand*)command
+- (void)startRecordingAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* callbackId = command.callbackId;
+    NSString* callbackId = command.callbackId;
+
 #pragma unused(callbackId)
-	
-	NSString* mediaId = [command.arguments objectAtIndex:0];
-	CDVAudioFile* audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId: mediaId];
+
+    NSString* mediaId = [command.arguments objectAtIndex:0];
+    CDVAudioFile* audioFile = [self audioFileForResource:[command.arguments objectAtIndex:1] withId:mediaId];
     NSString* jsString = nil;
     NSString* errorMsg = @"";
-    
-	if (audioFile != nil) {
-		
-		NSError* __autoreleasing error = nil;
-
-		if (audioFile.recorder != nil) {
-			[audioFile.recorder stop];
-			audioFile.recorder = nil;
-		}
+
+    if (audioFile != nil) {
+        NSError* __autoreleasing error = nil;
+
+        if (audioFile.recorder != nil) {
+            [audioFile.recorder stop];
+            audioFile.recorder = nil;
+        }
         // get the audioSession and set the category to allow recording when device is locked or ring/silent switch engaged
         if ([self hasAudioSession]) {
             [self.avSession setCategory:AVAudioSessionCategoryRecord error:nil];
-            if (![self.avSession  setActive: YES error: &error]){
+            if (![self.avSession setActive:YES error:&error]) {
                 // other audio with higher priority that does not allow mixing could cause this to fail
-                errorMsg = [NSString stringWithFormat: @"Unable to record audio: %@", [error localizedFailureReason]];
-                //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
-                jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: errorMsg] ];
+                errorMsg = [NSString stringWithFormat:@"Unable to record audio: %@", [error localizedFailureReason]];
+                // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
+                jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
                 [super writeJavascript:jsString];
                 return;
             }
         }
-        
-        // create a new recorder for each start record 
+
+        // create a new recorder for each start record
         audioFile.recorder = [[CDVAudioRecorder alloc] initWithURL:audioFile.resourceURL settings:nil error:&error];
-        
-		if (error != nil) {
-			errorMsg = [NSString stringWithFormat: @"Failed to initialize AVAudioRecorder: %@\n", [error  localizedFailureReason]];
-			audioFile.recorder = nil;
+
+        if (error != nil) {
+            errorMsg = [NSString stringWithFormat:@"Failed to initialize AVAudioRecorder: %@\n", [error  localizedFailureReason]];
+            audioFile.recorder = nil;
             if (self.avSession) {
                 [self.avSession setActive:NO error:nil];
             }
-			//jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
-			jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: errorMsg]];
-			
-		} else {
-			audioFile.recorder.delegate = self;
-			audioFile.recorder.mediaId = mediaId;
-			[audioFile.recorder record];
-			NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
-            jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
-		}
-	} else {
+            // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_ABORTED];
+            jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:errorMsg]];
+        } else {
+            audioFile.recorder.delegate = self;
+            audioFile.recorder.mediaId = mediaId;
+            [audioFile.recorder record];
+            NSLog(@"Started recording audio sample '%@'", audioFile.resourcePath);
+            jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_RUNNING];
+        }
+    } else {
         // file does not exist
         NSLog(@"Could not start recording audio, file '%@' does not exist.", audioFile.resourcePath);
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_ABORTED message: @"File to record to does not exist"]];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_ABORTED message:@"File to record to does not exist"]];
     }
     if (jsString) {
-       [super writeJavascript:jsString]; 
+        [super writeJavascript:jsString];
     }
-	return;
+    return;
 }
+
 // DEPRECATED
-- (void) stopAudioRecord:(CDVInvokedUrlCommand*)command
+- (void)stopAudioRecord:(CDVInvokedUrlCommand*)command
 {
     NSLog(@"stopAudioRecord is DEPRECATED!  Use stopRecordingAudio.");
     [self stopRecordingAudio:command];
 }
 
-- (void) stopRecordingAudio:(CDVInvokedUrlCommand*)command
+- (void)stopRecordingAudio:(CDVInvokedUrlCommand*)command
 {
-	NSString* mediaId = [command.arguments objectAtIndex:0];
+    NSString* mediaId = [command.arguments objectAtIndex:0];
 
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
     NSString* jsString = nil;
-	
-	if (audioFile != nil && audioFile.recorder != nil) {
-		NSLog(@"Stopped recording audio sample '%@'", audioFile.resourcePath);
-		[audioFile.recorder stop];
+
+    if ((audioFile != nil) && (audioFile.recorder != nil)) {
+        NSLog(@"Stopped recording audio sample '%@'", audioFile.resourcePath);
+        [audioFile.recorder stop];
         // no callback - that will happen in audioRecorderDidFinishRecording
-	} 
+    }
     // ignore if no media recording
     if (jsString) {
-        [super writeJavascript:jsString]; 
-    }}
+        [super writeJavascript:jsString];
+    }
+}
 
 - (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
 {
+    CDVAudioRecorder* aRecorder = (CDVAudioRecorder*)recorder;
+    NSString* mediaId = aRecorder.mediaId;
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
+    NSString* jsString = nil;
 
-	CDVAudioRecorder* aRecorder = (CDVAudioRecorder*)recorder;
-	NSString* mediaId = aRecorder.mediaId;
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
-	NSString* jsString = nil;
-
-	
-	if (audioFile != nil) {
-		NSLog(@"Finished recording audio sample '%@'", audioFile.resourcePath);
+    if (audioFile != nil) {
+        NSLog(@"Finished recording audio sample '%@'", audioFile.resourcePath);
     }
-    if (flag){
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
+    if (flag) {
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
     } else {
-        //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_DECODE message:nil]];
+        // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
     }
     if (self.avSession) {
         [self.avSession setActive:NO error:nil];
     }
     [super writeJavascript:jsString];
-	
 }
 
-- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag 
+- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag
 {
-	CDVAudioPlayer* aPlayer = (CDVAudioPlayer*)player;
-	NSString* mediaId = aPlayer.mediaId;
-	CDVAudioFile* audioFile = [[self soundCache] objectForKey: mediaId];
+    CDVAudioPlayer* aPlayer = (CDVAudioPlayer*)player;
+    NSString* mediaId = aPlayer.mediaId;
+    CDVAudioFile* audioFile = [[self soundCache] objectForKey:mediaId];
     NSString* jsString = nil;
-		
-	if (audioFile != nil) {
-		NSLog(@"Finished playing audio sample '%@'", audioFile.resourcePath);
+
+    if (audioFile != nil) {
+        NSLog(@"Finished playing audio sample '%@'", audioFile.resourcePath);
     }
-    if (flag){
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
-        
+    if (flag) {
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_STATE, MEDIA_STOPPED];
     } else {
-        //jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
-        jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode: MEDIA_ERR_DECODE message:nil]];
-        
+        // jsString = [NSString stringWithFormat: @"%@(\"%@\",%d,%d);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, MEDIA_ERR_DECODE];
+        jsString = [NSString stringWithFormat:@"%@(\"%@\",%d,%@);", @"cordova.require('cordova/plugin/Media').onStatus", mediaId, MEDIA_ERROR, [self createMediaErrorWithCode:MEDIA_ERR_DECODE message:nil]];
     }
     if (self.avSession) {
         [self.avSession setActive:NO error:nil];
     }
-    [super writeJavascript: jsString];
-	
+    [super writeJavascript:jsString];
 }
 
-- (void) onMemoryWarning
+- (void)onMemoryWarning
 {
-	[[self soundCache] removeAllObjects];
-	[self setSoundCache: nil];
-    [self setAvSession: nil];
-	
-	[super onMemoryWarning];
+    [[self soundCache] removeAllObjects];
+    [self setSoundCache:nil];
+    [self setAvSession:nil];
+
+    [super onMemoryWarning];
 }
-- (void) dealloc
+
+- (void)dealloc
 {
     [[self soundCache] removeAllObjects];
-    
 }
+
 @end
 
 @implementation CDVAudioFile
@@ -646,7 +641,6 @@
 @synthesize player, volume;
 @synthesize recorder;
 
-
 @end
 @implementation CDVAudioPlayer
 @synthesize mediaId;
@@ -657,4 +651,3 @@
 @synthesize mediaId;
 
 @end
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVSplashScreen.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.h b/CordovaLib/Classes/CDVSplashScreen.h
index d5bb5c4..b0d8615 100644
--- a/CordovaLib/Classes/CDVSplashScreen.h
+++ b/CordovaLib/Classes/CDVSplashScreen.h
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -20,11 +20,9 @@
 #import <Foundation/Foundation.h>
 #import "CDVPlugin.h"
 
+@interface CDVSplashScreen : CDVPlugin {}
 
-@interface CDVSplashScreen : CDVPlugin {
-}
-
-- (void) show:(CDVInvokedUrlCommand*)command;
-- (void) hide:(CDVInvokedUrlCommand*)command;
+- (void)show:(CDVInvokedUrlCommand*)command;
+- (void)hide:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVSplashScreen.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVSplashScreen.m b/CordovaLib/Classes/CDVSplashScreen.m
index 43fc4dd..2512328 100644
--- a/CordovaLib/Classes/CDVSplashScreen.m
+++ b/CordovaLib/Classes/CDVSplashScreen.m
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -17,18 +17,16 @@
  under the License.
  */
 
-
 #import "CDVSplashScreen.h"
 #import "CDVViewController.h"
 
 @implementation CDVSplashScreen
 
-
-- (void) __show:(BOOL)show
+- (void)__show:(BOOL)show
 {
     // Legacy support - once deprecated classes removed, clean this up
-    id<UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
-    
+    id <UIApplicationDelegate> delegate = [[UIApplication sharedApplication] delegate];
+
     if ([delegate respondsToSelector:@selector(viewController)]) {
         id vc = [delegate performSelector:@selector(viewController)];
         if ([vc isKindOfClass:[CDVViewController class]]) {
@@ -38,14 +36,14 @@
     }
 }
 
-- (void) show:(CDVInvokedUrlCommand*)command
+- (void)show:(CDVInvokedUrlCommand*)command
 {
-	[self __show:YES];
+    [self __show:YES];
 }
 
-- (void) hide:(CDVInvokedUrlCommand*)command
+- (void)hide:(CDVInvokedUrlCommand*)command
 {
-	[self __show:NO];
+    [self __show:NO];
 }
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVURLProtocol.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.h b/CordovaLib/Classes/CDVURLProtocol.h
index ff4b77a..055b88c 100644
--- a/CordovaLib/Classes/CDVURLProtocol.h
+++ b/CordovaLib/Classes/CDVURLProtocol.h
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -21,30 +21,28 @@
 
 @class CDVViewController;
 
-@interface CDVURLProtocol : NSURLProtocol {
-}
+@interface CDVURLProtocol : NSURLProtocol {}
 
-+ (void) registerPGHttpURLProtocol 
++ (void)registerPGHttpURLProtocol
 #ifdef __clang__
-    __attribute__ ((deprecated("No longer required.")));
+       __attribute__ ((deprecated ("No longer required.")));
 #else
-    __attribute__ ((deprecated()));
+       __attribute__((deprecated()));
 #endif
 
-+ (void) registerURLProtocol
+   + (void)registerURLProtocol
 #ifdef __clang__
-    __attribute__ ((deprecated("No longer required.")));
+       __attribute__ ((deprecated ("No longer required.")));
 #else
-    __attribute__ ((deprecated()));
+       __attribute__((deprecated()));
 #endif
 
-+ (void)registerViewController:(CDVViewController*)viewController;
+   + (void)registerViewController:(CDVViewController*)viewController;
 + (void)unregisterViewController:(CDVViewController*)viewController;
 @end
 
-@interface CDVHTTPURLResponse : NSHTTPURLResponse {
-} 
+@interface CDVHTTPURLResponse : NSHTTPURLResponse {}
 
-- (CDVHTTPURLResponse*) initWithUnauthorizedURL:(NSURL*)url;
+- (CDVHTTPURLResponse*)initWithUnauthorizedURL:(NSURL*)url;
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVURLProtocol.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVURLProtocol.m b/CordovaLib/Classes/CDVURLProtocol.m
index 48133f8..a9ae519 100644
--- a/CordovaLib/Classes/CDVURLProtocol.m
+++ b/CordovaLib/Classes/CDVURLProtocol.m
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -28,21 +28,20 @@ static NSMutableSet* gRegisteredControllers = nil;
 
 @implementation CDVURLProtocol
 
-+ (void) registerPGHttpURLProtocol {
-}
++ (void)registerPGHttpURLProtocol {}
 
-+ (void) registerURLProtocol {
-}
++ (void)registerURLProtocol {}
 
 // Called to register the URLProtocol, and to make it away of an instance of
 // a ViewController.
-+ (void)registerViewController:(CDVViewController*)viewController {
++ (void)registerViewController:(CDVViewController*)viewController
+{
     if (gRegisteredControllers == nil) {
         [NSURLProtocol registerClass:[CDVURLProtocol class]];
         gRegisteredControllers = [[NSMutableSet alloc] initWithCapacity:8];
         // The whitelist doesn't change, so grab the first one and store it.
         gWhitelist = viewController.whitelist;
-        
+
         // Note that we grab the whitelist from the first viewcontroller for now - but this will change
         // when we allow a registered viewcontroller to have its own whitelist (e.g InAppBrowser)
         // Differentiating the requests will be through the 'vc' http header below as used for the js->objc bridge.
@@ -51,21 +50,21 @@ static NSMutableSet* gRegisteredControllers = nil;
             NSLog(@"WARNING: NO whitelist has been set in CDVURLProtocol.");
         }
     }
-    @synchronized (gRegisteredControllers) {
+    @synchronized(gRegisteredControllers) {
         [gRegisteredControllers addObject:[NSNumber numberWithLongLong:(long long)viewController]];
     }
 }
 
-+ (void)unregisterViewController:(CDVViewController*)viewController {
++ (void)unregisterViewController:(CDVViewController*)viewController
+{
     [gRegisteredControllers removeObject:viewController];
 }
 
-
-+ (BOOL) canInitWithRequest:(NSURLRequest *)theRequest
++ (BOOL)canInitWithRequest:(NSURLRequest*)theRequest
 {
     NSURL* theUrl = [theRequest URL];
     NSString* theScheme = [theUrl scheme];
-    
+
     if ([[theUrl path] isEqualToString:@"/!gap_exec"]) {
         NSString* viewControllerAddressStr = [theRequest valueForHTTPHeaderField:@"vc"];
         if (viewControllerAddressStr == nil) {
@@ -74,12 +73,12 @@ static NSMutableSet* gRegisteredControllers = nil;
         }
         long long viewControllerAddress = [viewControllerAddressStr longLongValue];
         // Ensure that the CDVViewController has not been dealloc'ed.
-        @synchronized (gRegisteredControllers) {
+        @synchronized(gRegisteredControllers) {
             if (![gRegisteredControllers containsObject:[NSNumber numberWithLongLong:viewControllerAddress]]) {
                 return NO;
             }
-            CDVViewController* viewController = (__bridge CDVViewController*)(void *)viewControllerAddress;
-            
+            CDVViewController* viewController = (__bridge CDVViewController*)(void*)viewControllerAddress;
+
             NSString* queuedCommandsJSON = [theRequest valueForHTTPHeaderField:@"cmds"];
             if ([queuedCommandsJSON length] > 0) {
                 [viewController performSelectorOnMainThread:@selector(executeCommandsFromJson:) withObject:queuedCommandsJSON waitUntilDone:NO];
@@ -88,77 +87,73 @@ static NSMutableSet* gRegisteredControllers = nil;
             }
         }
         return NO;
-	}
-    
-    
+    }
+
     // we only care about http and https connections
-	if ([gWhitelist schemeIsAllowed:theScheme])
-    {
+    if ([gWhitelist schemeIsAllowed:theScheme]) {
         // if it FAILS the whitelist, we return TRUE, so we can fail the connection later
         return ![gWhitelist URLIsAllowed:theUrl];
     }
-    
+
     return NO;
 }
 
-+ (NSURLRequest*) canonicalRequestForRequest:(NSURLRequest*) request 
++ (NSURLRequest*)canonicalRequestForRequest:(NSURLRequest*)request
 {
-    //NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd));
+    // NSLog(@"%@ received %@", self, NSStringFromSelector(_cmd));
     return request;
 }
 
-- (void) startLoading
-{    
-    //NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd));
+- (void)startLoading
+{
+    // NSLog(@"%@ received %@ - start", self, NSStringFromSelector(_cmd));
     NSURL* url = [[self request] URL];
     NSString* body = [gWhitelist errorStringForURL:url];
 
     CDVHTTPURLResponse* response = [[CDVHTTPURLResponse alloc] initWithUnauthorizedURL:url];
-    
+
     [[self client] URLProtocol:self didReceiveResponse:response cacheStoragePolicy:NSURLCacheStorageNotAllowed];
-    
-    [[self client] URLProtocol:self didLoadData:[body dataUsingEncoding:NSASCIIStringEncoding]];
 
-    [[self client] URLProtocolDidFinishLoading:self];                
+    [[self client] URLProtocol:self didLoadData:[body dataUsingEncoding:NSASCIIStringEncoding]];
 
+    [[self client] URLProtocolDidFinishLoading:self];
 }
 
-- (void) stopLoading
+- (void)stopLoading
 {
     // do any cleanup here
 }
 
-+ (BOOL) requestIsCacheEquivalent: (NSURLRequest*)requestA toRequest: (NSURLRequest*)requestB 
++ (BOOL)requestIsCacheEquivalent:(NSURLRequest*)requestA toRequest:(NSURLRequest*)requestB
 {
     return NO;
 }
 
 @end
 
-
-
 @implementation CDVHTTPURLResponse
 
-- (id) initWithUnauthorizedURL:(__unsafe_unretained NSURL*)url
+- (id)initWithUnauthorizedURL:(__unsafe_unretained NSURL*)url
 {
     NSInteger statusCode = 401;
     NSDictionary* __unsafe_unretained headerFields = [NSDictionary dictionaryWithObject:@"Digest realm = \"Cordova.plist/ExternalHosts\"" forKey:@"WWW-Authenticate"];
     double requestTime = 1;
-    
+
     SEL selector = NSSelectorFromString(@"initWithURL:statusCode:headerFields:requestTime:");
     NSMethodSignature* signature = [self methodSignatureForSelector:selector];
-    
+
     NSInvocation* inv = [NSInvocation invocationWithMethodSignature:signature];
+
     [inv setTarget:self];
     [inv setSelector:selector];
     [inv setArgument:&url atIndex:2];
     [inv setArgument:&statusCode atIndex:3];
     [inv setArgument:&headerFields atIndex:4];
     [inv setArgument:&requestTime atIndex:5];
-    
+
     [inv invoke];
-    
+
     return self;
 }
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVViewController.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.h b/CordovaLib/Classes/CDVViewController.h
index 4003551..c867814 100644
--- a/CordovaLib/Classes/CDVViewController.h
+++ b/CordovaLib/Classes/CDVViewController.h
@@ -6,9 +6,9 @@
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
- 
+
  http://www.apache.org/licenses/LICENSE-2.0
- 
+
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -24,10 +24,7 @@
 #import "CDVCommandDelegate.h"
 #import "CDVWhitelist.h"
 
-
-@interface CDVViewController : UIViewController<UIWebViewDelegate, CDVCommandDelegate> {
-	
-}
+@interface CDVViewController : UIViewController <UIWebViewDelegate, CDVCommandDelegate>{}
 
 @property (nonatomic, strong) IBOutlet CDVCordovaView* webView;
 
@@ -36,31 +33,31 @@
 @property (nonatomic, readonly, strong) NSDictionary* settings;
 @property (nonatomic, readonly, strong) CDVWhitelist* whitelist; // readonly for public
 @property (nonatomic, readonly, assign) BOOL loadFromString;
-@property (nonatomic, readwrite, copy) NSString* invokeString __attribute__ ((deprecated));
+@property (nonatomic, readwrite, copy)NSString * invokeString __attribute__((deprecated));
 
 @property (nonatomic, readwrite, assign) BOOL useSplashScreen;
 @property (nonatomic, readonly, strong) IBOutlet UIActivityIndicatorView* activityView;
-@property (nonatomic, readonly, strong) UIImageView *imageView;
-@property (nonatomic, readwrite, strong) id<CDVCommandDelegate> commandDelegate;
+@property (nonatomic, readonly, strong) UIImageView* imageView;
+@property (nonatomic, readwrite, strong) id <CDVCommandDelegate> commandDelegate;
 
 @property (nonatomic, readwrite, copy) NSString* wwwFolderName;
 @property (nonatomic, readwrite, copy) NSString* startPage;
 
-+ (NSDictionary*) getBundlePlist:(NSString*)plistName;
-+ (NSString*) applicationDocumentsDirectory;
++ (NSDictionary*)getBundlePlist:(NSString*)plistName;
++ (NSString*)applicationDocumentsDirectory;
 
-- (void) dispose;
-- (void) printMultitaskingInfo;
-- (void) createGapView;
-- (CDVCordovaView*) newCordovaViewWithFrame:(CGRect)bounds;
+- (void)dispose;
+- (void)printMultitaskingInfo;
+- (void)createGapView;
+- (CDVCordovaView*)newCordovaViewWithFrame:(CGRect)bounds;
 
-- (int) executeCommandsFromJson:(NSString*)queuedCommandsJSON;
-- (void) flushCommandQueue;
+- (int)executeCommandsFromJson:(NSString*)queuedCommandsJSON;
+- (void)flushCommandQueue;
 
-- (void) javascriptAlert:(NSString*)text;
-- (NSString*) appURLScheme;
+- (void)javascriptAlert:(NSString*)text;
+- (NSString*)appURLScheme;
 
-- (NSArray*) parseInterfaceOrientations:(NSArray*)orientations;
-- (BOOL) supportsOrientation:(UIInterfaceOrientation)orientation;
+- (NSArray*)parseInterfaceOrientations:(NSArray*)orientations;
+- (BOOL)supportsOrientation:(UIInterfaceOrientation)orientation;
 
 @end


Mime
View raw message