You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ag...@apache.org on 2012/09/21 17:16:14 UTC

[6/11] bin/uncrustify.sh --all

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVFileTransfer.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.h b/CordovaLib/Classes/CDVFileTransfer.h
old mode 100755
new mode 100644
index d29d423..76c6a95
--- a/CordovaLib/Classes/CDVFileTransfer.h
+++ b/CordovaLib/Classes/CDVFileTransfer.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,12 +17,11 @@
  under the License.
  */
 
-
 #import <Foundation/Foundation.h>
 #import "CDVPlugin.h"
 
 enum CDVFileTransferError {
-	FILE_NOT_FOUND_ERR = 1,
+    FILE_NOT_FOUND_ERR = 1,
     INVALID_URL_ERR = 2,
     CONNECTION_ERR = 3,
     CONNECTION_ABORTED = 4
@@ -30,7 +29,7 @@ enum CDVFileTransferError {
 typedef int CDVFileTransferError;
 
 enum CDVFileTransferDirection {
-	CDV_TRANSFER_UPLOAD = 1,
+    CDV_TRANSFER_UPLOAD = 1,
     CDV_TRANSFER_DOWNLOAD = 2,
 };
 typedef int CDVFileTransferDirection;
@@ -38,28 +37,24 @@ typedef int CDVFileTransferDirection;
 // Magic value within the options dict used to set a cookie.
 extern NSString* const kOptionsKeyCookie;
 
-@interface CDVFileTransfer : CDVPlugin {
-    
-}
+@interface CDVFileTransfer : CDVPlugin {}
 
-- (void) upload:(CDVInvokedUrlCommand*)command;
-- (void) download:(CDVInvokedUrlCommand*)command;
-- (NSString*) escapePathComponentForUrlString:(NSString*)urlString;
+- (void)upload:(CDVInvokedUrlCommand*)command;
+- (void)download:(CDVInvokedUrlCommand*)command;
+- (NSString*)escapePathComponentForUrlString:(NSString*)urlString;
 
 // Visible for testing.
-- (NSURLRequest*) requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData;
--(NSMutableDictionary*) createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
+- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData;
+- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target;
 
--(NSMutableDictionary*) createFileTransferError:(int)code 
-                                  AndSource:(NSString*)source 
-                                  AndTarget:(NSString*)target 
-                                  AndHttpStatus:(int)httpStatus;
+- (NSMutableDictionary*)createFileTransferError:(int)code
+       AndSource                                   :(NSString*)source
+       AndTarget                                   :(NSString*)target
+   AndHttpStatus                               :(int)httpStatus;
 @property (readonly) NSMutableDictionary* activeTransfers;
 @end
 
-
-@interface CDVFileTransferDelegate : NSObject {
-}
+@interface CDVFileTransferDelegate : NSObject {}
 
 @property (strong) NSMutableData* responseData; // atomic
 @property (nonatomic, strong) CDVFileTransfer* command;
@@ -73,5 +68,4 @@ extern NSString* const kOptionsKeyCookie;
 @property (nonatomic, assign) NSInteger bytesTransfered;
 @property (nonatomic, assign) NSInteger bytesExpected;
 
-
-@end;
\ No newline at end of file
+@end;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
old mode 100755
new mode 100644
index d6be705..c0471ed
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.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
@@ -36,21 +36,21 @@ static const NSUInteger kStreamBufferSize = 32768;
 NSString* const kOptionsKeyCookie = @"__cookie";
 // Form boundary for multi-part requests.
 NSString* const kFormBoundary = @"*****org.apache.cordova.formBoundary";
-  
-
 
 // Writes the given data to the stream in a blocking way.
 // If successful, returns bytesToWrite.
 // If the stream was closed on the other end, returns 0.
 // If there was an error, returns -1.
-static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
+static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
+{
     UInt8* bytes = (UInt8*)[data bytes];
     NSUInteger bytesToWrite = [data length];
     NSUInteger totalBytesWritten = 0;
+
     while (totalBytesWritten < bytesToWrite) {
         CFIndex result = CFWriteStreamWrite(stream,
-              bytes + totalBytesWritten,
-              bytesToWrite - totalBytesWritten);
+            bytes + totalBytesWritten,
+            bytesToWrite - totalBytesWritten);
         if (result < 0) {
             CFStreamError error = CFWriteStreamGetError(stream);
             NSLog(@"WriteStreamError domain: %ld error: %ld", error.domain, error.error);
@@ -60,15 +60,17 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
         }
         totalBytesWritten += result;
     }
+
     return totalBytesWritten;
 }
 
 @implementation CDVFileTransfer
 @synthesize activeTransfers;
 
-- (NSString*) escapePathComponentForUrlString:(NSString*)urlString
+- (NSString*)escapePathComponentForUrlString:(NSString*)urlString
 {
     NSRange schemeAndHostRange = [urlString rangeOfString:@"://.*?/" options:NSRegularExpressionSearch];
+
     if (schemeAndHostRange.length == 0) {
         return urlString;
     }
@@ -77,21 +79,22 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
     NSString* schemeAndHost = [urlString substringToIndex:schemeAndHostEndIndex];
     NSString* pathComponent = [urlString substringFromIndex:schemeAndHostEndIndex];
     pathComponent = [pathComponent stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
-    
+
     return [schemeAndHost stringByAppendingString:pathComponent];
 }
 
-- (void) applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req {
+- (void)applyRequestHeaders:(NSDictionary*)headers toRequest:(NSMutableURLRequest*)req
+{
     [req setValue:@"XMLHttpRequest" forHTTPHeaderField:@"X-Requested-With"];
 
-    NSString* userAgent = [[self.webView request] valueForHTTPHeaderField:@"User-Agent"];    
+    NSString* userAgent = [[self.webView request] valueForHTTPHeaderField:@"User-Agent"];
     if (userAgent) {
-        [req setValue: userAgent forHTTPHeaderField:@"User-Agent"];
+        [req setValue:userAgent forHTTPHeaderField:@"User-Agent"];
     }
-    
+
     for (NSString* headerName in headers) {
         id value = [headers objectForKey:headerName];
-        if (!value || value == [NSNull null]) {
+        if (!value || (value == [NSNull null])) {
             value = @"null";
         }
 
@@ -101,6 +104,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
         if (![value isKindOfClass:[NSArray class]]) {
             value = [NSArray arrayWithObject:value];
         }
+
         // Then, append all header values.
         for (id __strong subValue in value) {
             // Convert from an NSNumber -> NSString.
@@ -114,9 +118,10 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
     }
 }
 
-- (NSURLRequest*) requestForUploadCommand:(CDVInvokedUrlCommand *)command fileData:(NSData *)fileData {
+- (NSURLRequest*)requestForUploadCommand:(CDVInvokedUrlCommand*)command fileData:(NSData*)fileData
+{
     // arguments order from js: [filePath, server, fileKey, fileName, mimeType, params, debug, chunkedMode]
-    // however, params is a JavaScript object and during marshalling is put into the options dict, 
+    // however, params is a JavaScript object and during marshalling is put into the options dict,
     // thus debug and chunkedMode are the 6th and 7th arguments
     NSArray* arguments = command.arguments;
     NSString* target = (NSString*)[arguments objectAtIndex:0];
@@ -125,7 +130,7 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
     NSString* fileName = [arguments objectAtIndex:3 withDefault:@"no-filename"];
     NSString* mimeType = [arguments objectAtIndex:4 withDefault:nil];
     NSDictionary* options = [arguments objectAtIndex:5 withDefault:nil];
-//  NSString* trustAllHosts = (NSString*)[arguments objectAtIndex:6]; // allow self-signed certs
+    //  NSString* trustAllHosts = (NSString*)[arguments objectAtIndex:6]; // allow self-signed certs
     BOOL chunkedMode = [[arguments objectAtIndex:7 withDefault:[NSNumber numberWithBool:YES]] boolValue];
     NSDictionary* headers = [arguments objectAtIndex:8 withDefault:nil];
 
@@ -141,72 +146,71 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
 
     // NSURL does not accepts URLs with spaces in the path. We escape the path in order
     // to be more lenient.
-    NSURL *url = [NSURL URLWithString:server];
-    
+    NSURL* url = [NSURL URLWithString:server];
+
     if (!url) {
         errorCode = INVALID_URL_ERR;
         NSLog(@"File Transfer Error: Invalid server URL %@", server);
     } else if (!fileData) {
         errorCode = FILE_NOT_FOUND_ERR;
     }
-    
-    if(errorCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [self createFileTransferError:errorCode AndSource:target AndTarget:server]];
-        
+
+    if (errorCode > 0) {
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self createFileTransferError:errorCode AndSource:target AndTarget:server]];
+
         [self writeJavascript:[result toErrorCallbackString:command.callbackId]];
         return nil;
     }
-    
-    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
-	[req setHTTPMethod:@"POST"];
-	
-//    Magic value to set a cookie
-	if([options objectForKey:kOptionsKeyCookie]) {
-		[req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"];
-		[req setHTTPShouldHandleCookies:NO];
-	}
-    
-	NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary];
-	[req setValue:contentType forHTTPHeaderField:@"Content-Type"];
+
+    NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
+    [req setHTTPMethod:@"POST"];
+
+    //    Magic value to set a cookie
+    if ([options objectForKey:kOptionsKeyCookie]) {
+        [req setValue:[options objectForKey:kOptionsKeyCookie] forHTTPHeaderField:@"Cookie"];
+        [req setHTTPShouldHandleCookies:NO];
+    }
+
+    NSString* contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", kFormBoundary];
+    [req setValue:contentType forHTTPHeaderField:@"Content-Type"];
     [self applyRequestHeaders:headers toRequest:req];
-    
+
     NSData* formBoundaryData = [[NSString stringWithFormat:@"--%@\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
-	NSMutableData *postBodyBeforeFile = [NSMutableData data];
-
-	for (NSString* key in options) {
-		id val = [options objectForKey:key];
-		if(!val || val == [NSNull null] || [key isEqualToString:kOptionsKeyCookie]) {
-			continue;	
-		}
-		// if it responds to stringValue selector (eg NSNumber) get the NSString
-		if ([val respondsToSelector:@selector(stringValue)]) {
-			val = [val stringValue];
-		}
-		// finally, check whether it is a NSString (for dataUsingEncoding selector below)
-		if (![val isKindOfClass:[NSString class]]) {
-			continue;
-		}
-		
-		[postBodyBeforeFile appendData:formBoundaryData];
-		[postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
-		[postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
-		[postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
-	}
-    
-	[postBodyBeforeFile appendData:formBoundaryData];
-	[postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
+    NSMutableData* postBodyBeforeFile = [NSMutableData data];
+
+    for (NSString* key in options) {
+        id val = [options objectForKey:key];
+        if (!val || (val == [NSNull null]) || [key isEqualToString:kOptionsKeyCookie]) {
+            continue;
+        }
+        // if it responds to stringValue selector (eg NSNumber) get the NSString
+        if ([val respondsToSelector:@selector(stringValue)]) {
+            val = [val stringValue];
+        }
+        // finally, check whether it is a NSString (for dataUsingEncoding selector below)
+        if (![val isKindOfClass:[NSString class]]) {
+            continue;
+        }
+
+        [postBodyBeforeFile appendData:formBoundaryData];
+        [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", key] dataUsingEncoding:NSUTF8StringEncoding]];
+        [postBodyBeforeFile appendData:[val dataUsingEncoding:NSUTF8StringEncoding]];
+        [postBodyBeforeFile appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]];
+    }
+
+    [postBodyBeforeFile appendData:formBoundaryData];
+    [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", fileKey, fileName] dataUsingEncoding:NSUTF8StringEncoding]];
     if (mimeType != nil) {
         [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]];
     }
     [postBodyBeforeFile appendData:[[NSString stringWithFormat:@"Content-Length: %d\r\n\r\n", [fileData length]] dataUsingEncoding:NSUTF8StringEncoding]];
 
     DLog(@"fileData length: %d", [fileData length]);
- 	NSData *postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
+    NSData* postBodyAfterFile = [[NSString stringWithFormat:@"\r\n--%@--\r\n", kFormBoundary] dataUsingEncoding:NSUTF8StringEncoding];
 
     NSUInteger totalPayloadLength = [postBodyBeforeFile length] + [fileData length] + [postBodyAfterFile length];
     [req setValue:[[NSNumber numberWithInteger:totalPayloadLength] stringValue] forHTTPHeaderField:@"Content-Length"];
-	
-    
+
     if (chunkedMode) {
         CFReadStreamRef readStream = NULL;
         CFWriteStreamRef writeStream = NULL;
@@ -214,36 +218,39 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
         [req setHTTPBodyStream:CFBridgingRelease(readStream)];
 
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            if (CFWriteStreamOpen(writeStream)) {
-                NSData* chunks[] = { postBodyBeforeFile, fileData, postBodyAfterFile };
-                int numChunks = sizeof(chunks) / sizeof(chunks[0]);
-                for (int i = 0; i < numChunks; ++i) {
-                    CFIndex result = WriteDataToStream(chunks[i], writeStream);
-                    if (result <= 0) {
-                        break;
+                if (CFWriteStreamOpen (writeStream)) {
+                    NSData* chunks[] = {postBodyBeforeFile, fileData, postBodyAfterFile};
+                    int numChunks = sizeof (chunks) / sizeof (chunks[0]);
+
+                    for (int i = 0; i < numChunks; ++i) {
+                        CFIndex result = WriteDataToStream (chunks[i], writeStream);
+                        if (result <= 0) {
+                            break;
+                        }
                     }
+                } else {
+                    NSLog (@"FileTransfer: Failed to open writeStream");
                 }
-            } else {
-                NSLog(@"FileTransfer: Failed to open writeStream");
-            }
-            CFWriteStreamClose(writeStream);
-            CFRelease(writeStream);
-        });
+                CFWriteStreamClose (writeStream);
+                CFRelease (writeStream);
+            });
     } else {
         [postBodyBeforeFile appendData:fileData];
         [postBodyBeforeFile appendData:postBodyAfterFile];
-    	[req setHTTPBody:postBodyBeforeFile];
-    }    
-	return req;
+        [req setHTTPBody:postBodyBeforeFile];
+    }
+    return req;
 }
 
-- (CDVFileTransferDelegate*) delegateForUploadCommand:(CDVInvokedUrlCommand *)command {
+- (CDVFileTransferDelegate*)delegateForUploadCommand:(CDVInvokedUrlCommand*)command
+{
     NSString* target = [command.arguments objectAtIndex:0];
     NSString* server = [command.arguments objectAtIndex:1];
     NSString* objectId = [command.arguments objectAtIndex:9];
 
     CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-	delegate.command = self;
+
+    delegate.command = self;
     delegate.callbackId = command.callbackId;
     delegate.direction = CDV_TRANSFER_UPLOAD;
     delegate.objectId = objectId;
@@ -252,24 +259,28 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
     return delegate;
 }
 
-- (NSData*) fileDataForUploadCommand:(CDVInvokedUrlCommand*)command {
+- (NSData*)fileDataForUploadCommand:(CDVInvokedUrlCommand*)command
+{
     NSString* target = (NSString*)[command.arguments objectAtIndex:0];
     NSError* __autoreleasing err = nil;
     // Extract the path part out of a file: URL.
-    NSString* filePath = [target hasPrefix:@"/"] ? [target copy] : [[NSURL URLWithString:target] path];
+    NSString* filePath = [target hasPrefix:@"/"] ?[target copy] :[[NSURL URLWithString:target] path];
 
     // Memory map the file so that it can be read efficiently even if it is large.
     NSData* fileData = [NSData dataWithContentsOfFile:filePath options:NSDataReadingMappedIfSafe error:&err];
+
     if (err != nil) {
         NSLog(@"Error opening file %@: %@", target, err);
     }
     return fileData;
 }
 
-- (void) upload:(CDVInvokedUrlCommand*)command {
+- (void)upload:(CDVInvokedUrlCommand*)command
+{
     // fileData and req are split into helper functions to ease the unit testing of delegateForUpload.
     NSData* fileData = [self fileDataForUploadCommand:command];
     NSURLRequest* req = [self requestForUploadCommand:command fileData:fileData];
+
     if (req == nil) {
         return;
     }
@@ -279,242 +290,243 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
     if (activeTransfers == nil) {
         activeTransfers = [[NSMutableDictionary alloc] init];
     }
-    
+
     [activeTransfers setObject:delegate forKey:delegate.objectId];
 }
 
-- (void) abort:(CDVInvokedUrlCommand*)command {
+- (void)abort:(CDVInvokedUrlCommand*)command
+{
     NSString* objectId = [command.arguments objectAtIndex:0];
-    
-    CDVFileTransferDelegate *delegate = [activeTransfers objectForKey:objectId];
+
+    CDVFileTransferDelegate* delegate = [activeTransfers objectForKey:objectId];
+
     if (delegate != nil) {
         [delegate.connection cancel];
         [activeTransfers removeObjectForKey:objectId];
-        
-        CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]];
-        
+
+        CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self createFileTransferError:CONNECTION_ABORTED AndSource:delegate.source AndTarget:delegate.target]];
+
         [self writeJavascript:[result toErrorCallbackString:delegate.callbackId]];
     }
 }
 
-- (void) download:(CDVInvokedUrlCommand*)command {
+- (void)download:(CDVInvokedUrlCommand*)command
+{
     DLog(@"File Transfer downloading file...");
-    NSString * sourceUrl = [command.arguments objectAtIndex:0];
-    NSString * filePath = [command.arguments objectAtIndex:1];
-//  NSString* trustAllHosts = (NSString*)[arguments objectAtIndex:6]; // allow self-signed certs
-    NSString * objectId = [command.arguments objectAtIndex:3];
-    CDVPluginResult *result = nil;
+    NSString* sourceUrl = [command.arguments objectAtIndex:0];
+    NSString* filePath = [command.arguments objectAtIndex:1];
+    //  NSString* trustAllHosts = (NSString*)[arguments objectAtIndex:6]; // allow self-signed certs
+    NSString* objectId = [command.arguments objectAtIndex:3];
+    CDVPluginResult* result = nil;
     CDVFileTransferError errorCode = 0;
 
     NSURL* file;
-    
+
     if ([filePath hasPrefix:@"/"]) {
         file = [NSURL fileURLWithPath:filePath];
     } else {
         file = [NSURL URLWithString:filePath];
     }
-    
-    NSURL *url = [NSURL URLWithString:sourceUrl];
-    
+
+    NSURL* url = [NSURL URLWithString:sourceUrl];
+
     if (!url) {
         errorCode = INVALID_URL_ERR;
         NSLog(@"File Transfer Error: Invalid server URL %@", sourceUrl);
-    } else if(![file isFileURL]) {
+    } else if (![file isFileURL]) {
         errorCode = FILE_NOT_FOUND_ERR;
         NSLog(@"File Transfer Error: Invalid file path or URL %@", filePath);
     }
-    
-    if(errorCode > 0) {
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [self createFileTransferError:errorCode AndSource:sourceUrl AndTarget:filePath]];
-        
+
+    if (errorCode > 0) {
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[self createFileTransferError:errorCode AndSource:sourceUrl AndTarget:filePath]];
+
         [self writeJavascript:[result toErrorCallbackString:command.callbackId]];
         return;
     }
-    
-    NSMutableURLRequest *req = [NSMutableURLRequest requestWithURL:url];
+
+    NSMutableURLRequest* req = [NSMutableURLRequest requestWithURL:url];
     [self applyRequestHeaders:nil toRequest:req];
 
     CDVFileTransferDelegate* delegate = [[CDVFileTransferDelegate alloc] init];
-	delegate.command = self;
+    delegate.command = self;
     delegate.direction = CDV_TRANSFER_DOWNLOAD;
     delegate.callbackId = command.callbackId;
     delegate.objectId = objectId;
     delegate.source = sourceUrl;
     delegate.target = filePath;
-	
+
     delegate.connection = [NSURLConnection connectionWithRequest:req delegate:delegate];
-    
+
     if (activeTransfers == nil) {
         activeTransfers = [[NSMutableDictionary alloc] init];
     }
-    
+
     [activeTransfers setObject:delegate forKey:delegate.objectId];
 }
 
--(NSMutableDictionary*) createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target
+- (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target
 {
     NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:3];
-    [result setObject: [NSNumber numberWithInt:code] forKey:@"code"];
-	[result setObject: source forKey:@"source"];
-	[result setObject: target forKey:@"target"];
+
+    [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
+    [result setObject:source forKey:@"source"];
+    [result setObject:target forKey:@"target"];
     NSLog(@"FileTransferError %@", result);
-    
+
     return result;
 }
 
--(NSMutableDictionary*) createFileTransferError:(int)code 
-                                      AndSource:(NSString*)source 
-                                      AndTarget:(NSString*)target 
-                                      AndHttpStatus:(int)httpStatus 
+- (NSMutableDictionary*)createFileTransferError:(int)code
+                                      AndSource:(NSString*)source
+                                      AndTarget:(NSString*)target
+                                  AndHttpStatus:(int)httpStatus
 {
     NSMutableDictionary* result = [NSMutableDictionary dictionaryWithCapacity:4];
-    [result setObject: [NSNumber numberWithInt:code] forKey:@"code"];
-	[result setObject: source forKey:@"source"];
-	[result setObject: target forKey:@"target"];
-	[result setObject: [NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
+
+    [result setObject:[NSNumber numberWithInt:code] forKey:@"code"];
+    [result setObject:source forKey:@"source"];
+    [result setObject:target forKey:@"target"];
+    [result setObject:[NSNumber numberWithInt:httpStatus] forKey:@"http_status"];
     NSLog(@"FileTransferError %@", result);
-    
+
     return result;
 }
 
 @end
 
-
 @implementation CDVFileTransferDelegate
 
 @synthesize callbackId, connection, source, target, responseData, command, bytesTransfered, bytesExpected, direction, responseCode, objectId;
 
-
-- (void)connectionDidFinishLoading:(NSURLConnection *)connection 
+- (void)connectionDidFinishLoading:(NSURLConnection*)connection
 {
     NSString* uploadResponse = nil;
     BOOL downloadResponse;
     NSMutableDictionary* uploadResult;
     CDVPluginResult* result;
     NSError* __autoreleasing error = nil;
-    NSString *parentPath;
+    NSString* parentPath;
     BOOL bDirRequest = NO;
     BOOL errored = NO;
-    CDVFile * file;
-    
+    CDVFile* file;
+
     NSLog(@"File Transfer Finished with response code %d", self.responseCode);
-         
-    if(self.direction == CDV_TRANSFER_UPLOAD)
-    {
-        if(self.responseCode >= 200 && self.responseCode < 300)
-        {
+
+    if (self.direction == CDV_TRANSFER_UPLOAD) {
+        if ((self.responseCode >= 200) && (self.responseCode < 300)) {
             // create dictionary to return FileUploadResult object
             uploadResponse = [[NSString alloc] initWithData:self.responseData encoding:NSUTF8StringEncoding];
             uploadResult = [NSMutableDictionary dictionaryWithCapacity:3];
             if (uploadResponse != nil) {
-                [uploadResult setObject: [uploadResponse stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey: @"response"];
+                [uploadResult setObject:[uploadResponse stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] forKey:@"response"];
             }
-            [uploadResult setObject:[NSNumber numberWithInt: self.bytesTransfered] forKey:@"bytesSent"];
-            [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey: @"responseCode"];
-            result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: uploadResult];            
-        } 
-        else 
-        {                  
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus: self.responseCode]];
+            [uploadResult setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"bytesSent"];
+            [uploadResult setObject:[NSNumber numberWithInt:self.responseCode] forKey:@"responseCode"];
+            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadResult];
+        } else {
+            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode]];
             errored = YES;
         }
     }
-    if(self.direction == CDV_TRANSFER_DOWNLOAD)
-    {
+    if (self.direction == CDV_TRANSFER_DOWNLOAD) {
         DLog(@"Write file %@", target);
-        //error=[[NSError alloc]init];
+        // error=[[NSError alloc]init];
 
-        if(self.responseCode >= 200 && self.responseCode < 300)
-        {
+        if ((self.responseCode >= 200) && (self.responseCode < 300)) {
             @try {
-                parentPath = [ self.target stringByDeletingLastPathComponent ];
-                
+                parentPath = [self.target stringByDeletingLastPathComponent];
+
                 // check if the path exists => create directories if needed
-                if(![[NSFileManager defaultManager] fileExistsAtPath:parentPath ]) [[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:nil];
-                
+                if (![[NSFileManager defaultManager] fileExistsAtPath:parentPath]) {
+                    [[NSFileManager defaultManager] createDirectoryAtPath:parentPath withIntermediateDirectories:YES attributes:nil error:nil];
+                }
+
                 downloadResponse = [self.responseData writeToFile:self.target options:NSDataWritingFileProtectionNone error:&error];
-                
-                if ( downloadResponse == NO ) {
+
+                if (downloadResponse == NO) {
                     // send our results back
-                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:INVALID_URL_ERR AndSource:source AndTarget:target AndHttpStatus: self.responseCode ]];
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[command createFileTransferError:INVALID_URL_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode]];
                     errored = YES;
                 } else {
                     DLog(@"File Transfer Download success");
-                    
+
                     file = [[CDVFile alloc] init];
-                    
-                    result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [file getDirectoryEntry: target isDirectory: bDirRequest]];
+
+                    result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[file getDirectoryEntry:target isDirectory:bDirRequest]];
                 }
             }
-            @catch (id exception) {
+            @catch(id exception) {
                 // jump back to main thread
-                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:source AndTarget:target AndHttpStatus: self.responseCode ]];
+                result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[command createFileTransferError:FILE_NOT_FOUND_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode]];
                 errored = YES;
             }
         } else {
-            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus: self.responseCode]];
+            result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode]];
             errored = YES;
         }
     }
-    
-    if(!errored) {
-        [self.command writeJavascript:[result toSuccessCallbackString: callbackId]];
+
+    if (!errored) {
+        [self.command writeJavascript:[result toSuccessCallbackString:callbackId]];
     } else {
-        [self.command writeJavascript:[result toErrorCallbackString: callbackId]];
+        [self.command writeJavascript:[result toErrorCallbackString:callbackId]];
     }
-    
-    //remove connection for activeTransfers
+
+    // remove connection for activeTransfers
     [command.activeTransfers removeObjectForKey:objectId];
 }
 
-- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
+- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse*)response
 {
-    NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
+    NSHTTPURLResponse* httpResponse = (NSHTTPURLResponse*)response;
+
     self.responseCode = [httpResponse statusCode];
     self.bytesExpected = [response expectedContentLength];
 }
 
-- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error 
+- (void)connection:(NSURLConnection*)connection didFailWithError:(NSError*)error
 {
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError: CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus: self.responseCode]];
+    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:[command createFileTransferError:CONNECTION_ERR AndSource:source AndTarget:target AndHttpStatus:self.responseCode]];
+
     NSLog(@"File Transfer Error: %@", [error localizedDescription]);
-    
-    //remove connection for activeTransfers
+
+    // remove connection for activeTransfers
     [command.activeTransfers removeObjectForKey:objectId];
-    
-    [self.command writeJavascript:[result toErrorCallbackString: callbackId]];
+
+    [self.command writeJavascript:[result toErrorCallbackString:callbackId]];
 }
 
-- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
+- (void)connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
 {
     self.bytesTransfered += data.length;
     [self.responseData appendData:data];
-    
+
     BOOL lengthComputable = (self.bytesExpected != NSURLResponseUnknownLength);
     NSMutableDictionary* downloadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-    [downloadProgress setObject:[NSNumber numberWithBool: lengthComputable] forKey:@"lengthComputable"];
-    [downloadProgress setObject:[NSNumber numberWithInt: self.bytesTransfered] forKey:@"loaded"];
-    [downloadProgress setObject:[NSNumber numberWithInt: self.bytesExpected] forKey:@"total"];
-    
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: downloadProgress ];
-    [result setKeepCallbackAsBool:true];
-    [self.command writeJavascript:[result toSuccessCallbackString: callbackId ]];
+    [downloadProgress setObject:[NSNumber numberWithBool:lengthComputable] forKey:@"lengthComputable"];
+    [downloadProgress setObject:[NSNumber numberWithInt:self.bytesTransfered] forKey:@"loaded"];
+    [downloadProgress setObject:[NSNumber numberWithInt:self.bytesExpected] forKey:@"total"];
 
-    
+    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:downloadProgress];
+    [result setKeepCallbackAsBool:true];
+    [self.command writeJavascript:[result toSuccessCallbackString:callbackId]];
 }
-- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
+
+- (void)connection:(NSURLConnection*)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite
 {
     NSMutableDictionary* uploadProgress = [NSMutableDictionary dictionaryWithCapacity:3];
-   
-    [uploadProgress setObject:[NSNumber numberWithBool: true] forKey:@"lengthComputable"];
-    [uploadProgress setObject:[NSNumber numberWithInt: totalBytesWritten] forKey:@"loaded"];
-    [uploadProgress setObject:[NSNumber numberWithInt: totalBytesExpectedToWrite] forKey:@"total"];
-    CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsDictionary: uploadProgress ];
-    [result setKeepCallbackAsBool:true]; 
-    [self.command writeJavascript:[result toSuccessCallbackString: callbackId ]];
-    
+
+    [uploadProgress setObject:[NSNumber numberWithBool:true] forKey:@"lengthComputable"];
+    [uploadProgress setObject:[NSNumber numberWithInt:totalBytesWritten] forKey:@"loaded"];
+    [uploadProgress setObject:[NSNumber numberWithInt:totalBytesExpectedToWrite] forKey:@"total"];
+    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:uploadProgress];
+    [result setKeepCallbackAsBool:true];
+    [self.command writeJavascript:[result toSuccessCallbackString:callbackId]];
+
     self.bytesTransfered = totalBytesWritten;
 }
+
 /* TESTING ONLY CODE
 // use ONLY for testing with self signed certificates
 // uncomment and modify server name in connectiondidReceiveAuthenticationChallenge
@@ -525,30 +537,29 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream) {
 
 - (void)connection:(NSURLConnection *) connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge*)challenge
 {
-	if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
-	{
+    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust])
+    {
         //NSLog(@"challenge host: %@", challenge.protectionSpace.host);
-		// we only trust our own domain
-		if ([challenge.protectionSpace.host isEqualToString:@"serverName.domain.com"]){
+        // we only trust our own domain
+        if ([challenge.protectionSpace.host isEqualToString:@"serverName.domain.com"]){
             NSURLCredential* myCredential = [NSURLCredential credentialForTrust: challenge.protectionSpace.serverTrust];
-            
+
             [challenge.sender useCredential:myCredential forAuthenticationChallenge:challenge];
-			
-		}
-	}
-    
-	[challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
+
+        }
+    }
+
+    [challenge.sender continueWithoutCredentialForAuthenticationChallenge:challenge];
 }
 // uncomment the above two methods for testing servers with self signed certificates
 // END TESTING ONLY CODE
  */
-- (id) init
+- (id)init
 {
     if ((self = [super init])) {
-		self.responseData = [NSMutableData data];
+        self.responseData = [NSMutableData data];
     }
     return self;
 }
 
 @end;
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVInvokedUrlCommand.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.h b/CordovaLib/Classes/CDVInvokedUrlCommand.h
index ff7f1ff..15a1df6 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.h
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.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
@@ -19,32 +19,30 @@
 
 #import <Foundation/Foundation.h>
 
-
 @interface CDVInvokedUrlCommand : NSObject {
-	NSString* _callbackId;
-	NSString* _className;
-	NSString* _methodName;
-	NSArray* _arguments;
+    NSString* _callbackId;
+    NSString* _className;
+    NSString* _methodName;
+    NSArray* _arguments;
 }
 
-@property(nonatomic, readonly) NSArray* arguments;
-@property(nonatomic, readonly) NSString* callbackId;
-@property(nonatomic, readonly) NSString* className;
-@property(nonatomic, readonly) NSString* methodName;
+@property (nonatomic, readonly) NSArray* arguments;
+@property (nonatomic, readonly) NSString* callbackId;
+@property (nonatomic, readonly) NSString* className;
+@property (nonatomic, readonly) NSString* methodName;
 
-+ (CDVInvokedUrlCommand*) commandFromJson:(NSArray*)jsonEntry;
++ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry;
 
-- (id) initWithArguments:(NSArray*)arguments
-              callbackId:(NSString*)callbackId
-               className:(NSString*)className
-              methodName:(NSString*)methodName;
-              
-- (id) initFromJson:(NSArray*)jsonEntry;
+- (id)initWithArguments:(NSArray*)arguments
+   callbackId          :(NSString*)callbackId
+    className           :(NSString*)className
+   methodName          :(NSString*)methodName;
+
+- (id)initFromJson:(NSArray*)jsonEntry;
 
 // The first NSDictionary found in the arguments will be returned in legacyDict.
 // The arguments array with be prepended with the callbackId and have the first
 // dict removed from it.
-- (void) legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict;
-
+- (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVInvokedUrlCommand.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVInvokedUrlCommand.m b/CordovaLib/Classes/CDVInvokedUrlCommand.m
index eaeb5c8..fe67986 100644
--- a/CordovaLib/Classes/CDVInvokedUrlCommand.m
+++ b/CordovaLib/Classes/CDVInvokedUrlCommand.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
@@ -27,29 +27,29 @@
 @synthesize className = _className;
 @synthesize methodName = _methodName;
 
-+ (CDVInvokedUrlCommand*) commandFromJson:(NSArray*)jsonEntry
++ (CDVInvokedUrlCommand*)commandFromJson:(NSArray*)jsonEntry
 {
     return [[CDVInvokedUrlCommand alloc] initFromJson:jsonEntry];
 }
-              
-- (id) initFromJson:(NSArray*)jsonEntry
+
+- (id)initFromJson:(NSArray*)jsonEntry
 {
     id tmp = [jsonEntry objectAtIndex:0];
     NSString* callbackId = tmp == [NSNull null] ? nil : tmp;
     NSString* className = [jsonEntry objectAtIndex:1];
     NSString* methodName = [jsonEntry objectAtIndex:2];
     NSMutableArray* arguments = [jsonEntry objectAtIndex:3];
-    
+
     return [self initWithArguments:arguments
                         callbackId:callbackId
                          className:className
                         methodName:methodName];
 }
 
-- (id) initWithArguments:(NSArray*)arguments
-              callbackId:(NSString*)callbackId
-               className:(NSString*)className
-              methodName:(NSString*)methodName
+- (id)initWithArguments:(NSArray*)arguments
+             callbackId:(NSString*)callbackId
+              className:(NSString*)className
+             methodName:(NSString*)methodName
 {
     self = [super init];
     if (self != nil) {
@@ -61,8 +61,10 @@
     return self;
 }
 
-- (void) legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict {
+- (void)legacyArguments:(NSMutableArray**)legacyArguments andDict:(NSMutableDictionary**)legacyDict
+{
     NSMutableArray* newArguments = [NSMutableArray arrayWithArray:_arguments];
+
     for (NSUInteger i = 0; i < [newArguments count]; ++i) {
         if ([[newArguments objectAtIndex:i] isKindOfClass:[NSDictionary class]]) {
             if (legacyDict != NULL) {
@@ -72,6 +74,7 @@
             break;
         }
     }
+
     // Legacy (two versions back) has no callbackId.
     if (_callbackId != nil) {
         [newArguments insertObject:_callbackId atIndex:0];
@@ -81,5 +84,4 @@
     }
 }
 
-
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVLocalStorage.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.h b/CordovaLib/Classes/CDVLocalStorage.h
index 02ae2c5..686e519 100644
--- a/CordovaLib/Classes/CDVLocalStorage.h
+++ b/CordovaLib/Classes/CDVLocalStorage.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
@@ -19,24 +19,24 @@
 
 #import "CDVPlugin.h"
 
-#define kCDVLocalStorageErrorDomain         @"kCDVLocalStorageErrorDomain" 
-#define kCDVLocalStorageFileOperationError  1
+#define kCDVLocalStorageErrorDomain @"kCDVLocalStorageErrorDomain"
+#define kCDVLocalStorageFileOperationError 1
 
-@interface CDVLocalStorage : CDVPlugin < UIWebViewDelegate >
+@interface CDVLocalStorage : CDVPlugin <UIWebViewDelegate>
 
 @property (nonatomic, readonly, strong) NSMutableArray* backupInfo;
 
-- (BOOL) shouldBackup;
-- (BOOL) shouldRestore;
-- (void) backup:(CDVInvokedUrlCommand*)command;
-- (void) restore:(CDVInvokedUrlCommand*)command;
+- (BOOL)shouldBackup;
+- (BOOL)shouldRestore;
+- (void)backup:(CDVInvokedUrlCommand*)command;
+- (void)restore:(CDVInvokedUrlCommand*)command;
 
-+ (void) __verifyAndFixDatabaseLocations;
++ (void)__verifyAndFixDatabaseLocations;
 // Visible for testing.
-+ (BOOL) __verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
-                                              bundlePath:(NSString*)bundlePath
-                                             fileManager:(NSFileManager*)fileManager;
-+ (void) __restoreThenRemoveBackupLocations;
++ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
+    bundlePath                                          :(NSString*)bundlePath
+   fileManager                                         :(NSFileManager*)fileManager;
++ (void)__restoreThenRemoveBackupLocations;
 @end
 
 @interface CDVBackupInfo : NSObject
@@ -45,7 +45,7 @@
 @property (nonatomic, copy) NSString* backup;
 @property (nonatomic, copy) NSString* label;
 
-- (BOOL) shouldBackup;
-- (BOOL) shouldRestore;
+- (BOOL)shouldBackup;
+- (BOOL)shouldRestore;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVLocalStorage.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocalStorage.m b/CordovaLib/Classes/CDVLocalStorage.m
index 2200761..51a3f1a 100644
--- a/CordovaLib/Classes/CDVLocalStorage.m
+++ b/CordovaLib/Classes/CDVLocalStorage.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
@@ -23,194 +23,189 @@
 @interface CDVLocalStorage ()
 
 @property (nonatomic, readwrite, strong) NSMutableArray* backupInfo;  // array of CDVBackupInfo objects
-@property (nonatomic, readwrite, unsafe_unretained) id<UIWebViewDelegate> webviewDelegate;
+@property (nonatomic, readwrite, unsafe_unretained) id <UIWebViewDelegate> webviewDelegate;
 
 @end
 
-
 @implementation CDVLocalStorage
 
 @synthesize backupInfo, webviewDelegate;
 
-
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
 {
     self = (CDVLocalStorage*)[super initWithWebView:theWebView];
-    if (self) 
-    {
-        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive) 
+    if (self) {
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResignActive)
                                                      name:UIApplicationWillResignActiveNotification object:nil];
-        
+
         self.backupInfo = [[self class] createBackupInfo];
-        
+
         // over-ride current webview delegate (for restore reasons)
         self.webviewDelegate = theWebView.delegate;
         theWebView.delegate = self;
-        
+
         // verify the and fix the iOS 5.1 database locations once
         [[self class] __verifyAndFixDatabaseLocations];
     }
-    
+
     return self;
 }
 
 #pragma mark -
 #pragma mark Plugin interface methods
 
-+ (NSMutableArray*) createBackupInfo
++ (NSMutableArray*)createBackupInfo
 {
     NSMutableArray* backupInfo = [NSMutableArray arrayWithCapacity:3];
-    
+
     // set up common folders
-    NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)objectAtIndex:0];
-    NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+    NSString* appLibraryFolder = [NSSearchPathForDirectoriesInDomains (NSLibraryDirectory, NSUserDomainMask, YES) objectAtIndex:0];
+    NSString* appDocumentsFolder = [NSSearchPathForDirectoriesInDomains (NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
     NSString* backupsFolder = [appDocumentsFolder stringByAppendingPathComponent:@"Backups"];
-    
+
     // create the backups folder
     [[NSFileManager defaultManager] createDirectoryAtPath:backupsFolder withIntermediateDirectories:YES attributes:nil error:nil];
-    
-    //////////// LOCALSTORAGE
-    
-    NSString *original = [[appLibraryFolder stringByAppendingPathComponent:
-                           (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/LocalStorage"]
-                          stringByAppendingPathComponent:@"file__0.localstorage"];
-    
-    NSString *backup = [backupsFolder stringByAppendingPathComponent:@"localstorage.appdata.db"];
-    
+
+    // ////////// LOCALSTORAGE
+
+    NSString* original = [[appLibraryFolder stringByAppendingPathComponent           :
+            (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches":@"WebKit/LocalStorage"]
+        stringByAppendingPathComponent:@"file__0.localstorage"];
+
+    NSString* backup = [backupsFolder stringByAppendingPathComponent:@"localstorage.appdata.db"];
+
     CDVBackupInfo* backupItem = [[CDVBackupInfo alloc] init];
     backupItem.backup = backup;
     backupItem.original = original;
     backupItem.label = @"localStorage database";
-    
+
     [backupInfo addObject:backupItem];
-    
-    //////////// WEBSQL MAIN DB
-    
-    original = [[appLibraryFolder stringByAppendingPathComponent:
-                 (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/Databases"]
-                stringByAppendingPathComponent:@"Databases.db"];
-    
+
+    // ////////// WEBSQL MAIN DB
+
+    original = [[appLibraryFolder stringByAppendingPathComponent                     :
+            (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches":@"WebKit/Databases"]
+        stringByAppendingPathComponent:@"Databases.db"];
+
     backup = [backupsFolder stringByAppendingPathComponent:@"websqlmain.appdata.db"];
-    
+
     backupItem = [[CDVBackupInfo alloc] init];
     backupItem.backup = backup;
     backupItem.original = original;
     backupItem.label = @"websql main database";
-    
+
     [backupInfo addObject:backupItem];
-    
-    //////////// WEBSQL DATABASES
-    
-    original = [[appLibraryFolder stringByAppendingPathComponent:
-                 (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches" : @"WebKit/Databases"]
-                stringByAppendingPathComponent:@"file__0"];
-    
+
+    // ////////// WEBSQL DATABASES
+
+    original = [[appLibraryFolder stringByAppendingPathComponent                     :
+            (IsAtLeastiOSVersion(@"5.1") && !IsAtLeastiOSVersion(@"6.0")) ? @"Caches":@"WebKit/Databases"]
+        stringByAppendingPathComponent:@"file__0"];
+
     backup = [backupsFolder stringByAppendingPathComponent:@"websqldbs.appdata.db"];
-    
+
     backupItem = [[CDVBackupInfo alloc] init];
     backupItem.backup = backup;
     backupItem.original = original;
     backupItem.label = @"websql databases";
-    
+
     [backupInfo addObject:backupItem];
-    
+
     return backupInfo;
 }
 
-+ (BOOL) copyFrom:(NSString*)src to:(NSString*)dest error:(NSError* __autoreleasing*)error
++ (BOOL)copyFrom:(NSString*)src to:(NSString*)dest error:(NSError * __autoreleasing*)error
 {
     NSFileManager* fileManager = [NSFileManager defaultManager];
-    
-    if (![fileManager fileExistsAtPath:src]) {
 
+    if (![fileManager fileExistsAtPath:src]) {
         NSString* errorString = [NSString stringWithFormat:@"%@ file does not exist.", src];
         if (error != NULL) {
-            (*error) = [NSError errorWithDomain:kCDVLocalStorageErrorDomain 
-                                           code:kCDVLocalStorageFileOperationError 
-                                       userInfo:[NSDictionary dictionaryWithObject:errorString 
-                                                 forKey:NSLocalizedDescriptionKey]];
+            (*error) = [NSError errorWithDomain:kCDVLocalStorageErrorDomain
+                                           code:kCDVLocalStorageFileOperationError
+                                       userInfo:[NSDictionary dictionaryWithObject:errorString
+                                                                            forKey:NSLocalizedDescriptionKey]];
         }
         return NO;
     }
-    
+
     // generate unique filepath in temp directory
     CFUUIDRef uuidRef = CFUUIDCreate(kCFAllocatorDefault);
     CFStringRef uuidString = CFUUIDCreateString(kCFAllocatorDefault, uuidRef);
-    NSString* tempBackup = [[NSTemporaryDirectory() stringByAppendingPathComponent:(__bridge NSString*)uuidString]stringByAppendingPathExtension:@"bak"];
+    NSString* tempBackup = [[NSTemporaryDirectory () stringByAppendingPathComponent:(__bridge NSString*)uuidString] stringByAppendingPathExtension:@"bak"];
     CFRelease(uuidString);
     CFRelease(uuidRef);
-    
+
     BOOL destExists = [fileManager fileExistsAtPath:dest];
-    
+
     // backup the dest
     if (destExists && ![fileManager copyItemAtPath:dest toPath:tempBackup error:error]) {
         return NO;
-    } 
-    
+    }
+
     // remove the dest
-    if (destExists && ![fileManager removeItemAtPath:dest error:error]) { 
+    if (destExists && ![fileManager removeItemAtPath:dest error:error]) {
         return NO;
     }
-    
+
     // create path to dest
     if (!destExists && ![fileManager createDirectoryAtPath:[dest stringByDeletingLastPathComponent] withIntermediateDirectories:YES attributes:nil error:error]) {
         return NO;
     }
-    
+
     // copy src to dest
     if ([fileManager copyItemAtPath:src toPath:dest error:error]) {
         // success - cleanup - delete the backup to the dest
         if ([fileManager fileExistsAtPath:tempBackup]) {
-            [fileManager removeItemAtPath:tempBackup error:error]; 
+            [fileManager removeItemAtPath:tempBackup error:error];
         }
         return YES;
-
     } else {
         // failure - we restore the temp backup file to dest
         [fileManager copyItemAtPath:tempBackup toPath:dest error:error];
         // cleanup - delete the backup to the dest
         if ([fileManager fileExistsAtPath:tempBackup]) {
-            [fileManager removeItemAtPath:tempBackup error:error]; 
+            [fileManager removeItemAtPath:tempBackup error:error];
         }
         return NO;
     }
 }
 
-- (BOOL) shouldBackup
+- (BOOL)shouldBackup
 {
     for (CDVBackupInfo* info in self.backupInfo) {
         if ([info shouldBackup]) {
             return YES;
         }
     }
+
     return NO;
 }
 
-- (BOOL) shouldRestore
+- (BOOL)shouldRestore
 {
     for (CDVBackupInfo* info in self.backupInfo) {
         if ([info shouldRestore]) {
             return YES;
         }
     }
+
     return NO;
 }
-                
+
 /* copy from webkitDbLocation to persistentDbLocation */
-- (void) backup:(CDVInvokedUrlCommand*)command
+- (void)backup:(CDVInvokedUrlCommand*)command
 {
     NSString* callbackId = command.callbackId;
 
     NSError* __autoreleasing error = nil;
     CDVPluginResult* result = nil;
     NSString* message = nil;
-    
-    for (CDVBackupInfo* info in self.backupInfo)
-    {
-        if ([info shouldBackup])
-        {
+
+    for (CDVBackupInfo* info in self.backupInfo) {
+        if ([info shouldBackup]) {
             [[self class] copyFrom:info.original to:info.backup error:&error];
-            
+
             if (callbackId) {
                 if (error == nil) {
                     message = [NSString stringWithFormat:@"Backed up: %@", info.label];
@@ -218,7 +213,6 @@
 
                     result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
                     [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:callbackId] waitUntilDone:NO];
-
                 } else {
                     message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) backup: %@", info.label, [error localizedDescription]];
                     NSLog(@"%@", message);
@@ -232,31 +226,28 @@
 }
 
 /* copy from persistentDbLocation to webkitDbLocation */
-- (void) restore:(CDVInvokedUrlCommand*)command
+- (void)restore:(CDVInvokedUrlCommand*)command
 {
     NSString* callbackId = command.callbackId;
-    
+
     NSError* __autoreleasing error = nil;
     CDVPluginResult* result = nil;
     NSString* message = nil;
-    
-    for (CDVBackupInfo* info in self.backupInfo)
-    {
-        if ([info shouldRestore])
-        {
+
+    for (CDVBackupInfo* info in self.backupInfo) {
+        if ([info shouldRestore]) {
             [[self class] copyFrom:info.backup to:info.original error:&error];
-            
+
             if (error == nil) {
                 message = [NSString stringWithFormat:@"Restored: %@", info.label];
                 NSLog(@"%@", message);
-                
+
                 result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:message];
                 [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toSuccessCallbackString:callbackId] waitUntilDone:NO];
-                
             } else {
                 message = [NSString stringWithFormat:@"Error in CDVLocalStorage (%@) restore: %@", info.label, [error localizedDescription]];
                 NSLog(@"%@", message);
-                
+
                 result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:message];
                 [self performSelectorOnMainThread:@selector(writeJavascript:) withObject:[result toErrorCallbackString:callbackId] waitUntilDone:NO];
             }
@@ -264,13 +255,13 @@
     }
 }
 
-+ (void) __verifyAndFixDatabaseLocations
++ (void)__verifyAndFixDatabaseLocations
 {
     NSBundle* mainBundle = [NSBundle mainBundle];
     NSString* bundlePath = [[mainBundle bundlePath] stringByDeletingLastPathComponent];
     NSString* bundleIdentifier = [[mainBundle infoDictionary] objectForKey:@"CFBundleIdentifier"];
     NSString* appPlistPath = [bundlePath stringByAppendingPathComponent:[NSString stringWithFormat:@"Library/Preferences/%@.plist", bundleIdentifier]];
-    
+
     NSMutableDictionary* appPlistDict = [NSMutableDictionary dictionaryWithContentsOfFile:appPlistPath];
     BOOL modified = [[self class] __verifyAndFixDatabaseLocationsWithAppPlistDict:appPlistDict
                                                                        bundlePath:bundlePath
@@ -279,31 +270,29 @@
     if (modified) {
         BOOL ok = [appPlistDict writeToFile:appPlistPath atomically:YES];
         [[NSUserDefaults standardUserDefaults] synchronize];
-        NSLog(@"Fix applied for database locations?: %@", ok? @"YES":@"NO");    
+        NSLog(@"Fix applied for database locations?: %@", ok ? @"YES" : @"NO");
     }
 }
 
-+ (BOOL) __verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
-                                              bundlePath:(NSString*)bundlePath
-                                             fileManager:(NSFileManager*)fileManager
++ (BOOL)__verifyAndFixDatabaseLocationsWithAppPlistDict:(NSMutableDictionary*)appPlistDict
+                                             bundlePath:(NSString*)bundlePath
+                                            fileManager:(NSFileManager*)fileManager
 {
     NSString* libraryCaches = @"Library/Caches";
     NSString* libraryWebKit = @"Library/WebKit";
-    
+
     NSArray* keysToCheck = [NSArray arrayWithObjects:
-                            @"WebKitLocalStorageDatabasePathPreferenceKey", 
-                            @"WebDatabaseDirectory", 
-                            nil];
-    
+        @"WebKitLocalStorageDatabasePathPreferenceKey",
+        @"WebDatabaseDirectory",
+        nil];
+
     BOOL dirty = NO;
-    
-    for (NSString* key in keysToCheck) 
-    {
+
+    for (NSString* key in keysToCheck) {
         NSString* value = [appPlistDict objectForKey:key];
         // verify key exists, and path is in app bundle, if not - fix
-        if (value != nil && ![value hasPrefix:bundlePath]) 
-        {
-            // the pathSuffix to use may be wrong - OTA upgrades from < 5.1 to 5.1 do keep the old path Library/WebKit, 
+        if ((value != nil) && ![value hasPrefix:bundlePath]) {
+            // the pathSuffix to use may be wrong - OTA upgrades from < 5.1 to 5.1 do keep the old path Library/WebKit,
             // while Xcode synced ones do change the storage location to Library/Caches
             NSString* newBundlePath = [bundlePath stringByAppendingPathComponent:libraryCaches];
             if (![fileManager fileExistsAtPath:newBundlePath]) {
@@ -313,16 +302,16 @@
             dirty = YES;
         }
     }
-    return dirty;    
+
+    return dirty;
 }
 
-+ (void) __restoreThenRemoveBackupLocations
++ (void)__restoreThenRemoveBackupLocations
 {
     NSMutableArray* backupInfo = [CDVLocalStorage createBackupInfo];
     NSFileManager* manager = [NSFileManager defaultManager];
-    
-    for (CDVBackupInfo* info in backupInfo)
-    {
+
+    for (CDVBackupInfo* info in backupInfo) {
         if ([manager fileExistsAtPath:info.backup]) {
             [self copyFrom:info.backup to:info.original error:nil];
             [manager removeItemAtPath:info.backup error:nil];
@@ -334,66 +323,63 @@
 #pragma mark -
 #pragma mark Notification handlers
 
-- (void) onResignActive
+- (void)onResignActive
 {
     UIDevice* device = [UIDevice currentDevice];
     NSNumber* exitsOnSuspend = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"UIApplicationExitsOnSuspend"];
 
     BOOL isMultitaskingSupported = [device respondsToSelector:@selector(isMultitaskingSupported)] && [device isMultitaskingSupported];
+
     if (exitsOnSuspend == nil) { // if it's missing, it should be NO (i.e. multi-tasking on by default)
         exitsOnSuspend = [NSNumber numberWithBool:NO];
     }
-    
-    if (exitsOnSuspend)
-    {
+
+    if (exitsOnSuspend) {
         [self backup:nil];
-    } 
-    else if (isMultitaskingSupported) 
-    {
+    } else if (isMultitaskingSupported) {
         __block UIBackgroundTaskIdentifier backgroundTaskID = UIBackgroundTaskInvalid;
-        
+
         backgroundTaskID = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
-            [[UIApplication sharedApplication] endBackgroundTask: backgroundTaskID];
-            backgroundTaskID = UIBackgroundTaskInvalid;
-            NSLog(@"Background task to backup WebSQL/LocalStorage expired.");
-        }];
-        CDVLocalStorage __unsafe_unretained *weakSelf = self;
+                [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
+                backgroundTaskID = UIBackgroundTaskInvalid;
+                NSLog (@"Background task to backup WebSQL/LocalStorage expired.");
+            }];
+        CDVLocalStorage __unsafe_unretained* weakSelf = self;
         dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
-            
-            [weakSelf backup:nil];
-            
-            [[UIApplication sharedApplication] endBackgroundTask: backgroundTaskID];
-            backgroundTaskID = UIBackgroundTaskInvalid;
-        });
+                [weakSelf backup:nil];
+
+                [[UIApplication sharedApplication] endBackgroundTask:backgroundTaskID];
+                backgroundTaskID = UIBackgroundTaskInvalid;
+            });
     }
 }
 
-- (void) onAppTerminate
+- (void)onAppTerminate
 {
-    [self onResignActive];    
+    [self onResignActive];
 }
 
 #pragma mark -
 #pragma mark UIWebviewDelegate implementation and forwarding
 
-- (void) webViewDidStartLoad:(UIWebView*)theWebView
+- (void)webViewDidStartLoad:(UIWebView*)theWebView
 {
     [self restore:nil];
-    
+
     return [self.webviewDelegate webViewDidStartLoad:theWebView];
 }
 
-- (void) webViewDidFinishLoad:(UIWebView*)theWebView 
+- (void)webViewDidFinishLoad:(UIWebView*)theWebView
 {
     return [self.webviewDelegate webViewDidFinishLoad:theWebView];
 }
 
-- (void) webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error 
+- (void)webView:(UIWebView*)theWebView didFailLoadWithError:(NSError*)error
 {
     return [self.webviewDelegate webView:theWebView didFailLoadWithError:error];
 }
 
-- (BOOL) webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
+- (BOOL)webView:(UIWebView*)theWebView shouldStartLoadWithRequest:(NSURLRequest*)request navigationType:(UIWebViewNavigationType)navigationType
 {
     return [self.webviewDelegate webView:theWebView shouldStartLoadWithRequest:request navigationType:navigationType];
 }
@@ -401,10 +387,8 @@
 #pragma mark -
 #pragma mark Over-rides
 
-
 @end
 
-
 #pragma mark -
 #pragma mark CDVBackupInfo implementation
 
@@ -412,66 +396,67 @@
 
 @synthesize original, backup, label;
 
-- (BOOL) file:(NSString*)aPath isNewerThanFile:(NSString*)bPath
+- (BOOL)file:(NSString*)aPath isNewerThanFile:(NSString*)bPath
 {
     NSFileManager* fileManager = [NSFileManager defaultManager];
     NSError* __autoreleasing error = nil;
 
     NSDictionary* aPathAttribs = [fileManager attributesOfItemAtPath:aPath error:&error];
     NSDictionary* bPathAttribs = [fileManager attributesOfItemAtPath:bPath error:&error];
-    
+
     NSDate* aPathModDate = [aPathAttribs objectForKey:NSFileModificationDate];
     NSDate* bPathModDate = [bPathAttribs objectForKey:NSFileModificationDate];
-    
-    if (nil == aPathModDate && nil == bPathModDate) {
+
+    if ((nil == aPathModDate) && (nil == bPathModDate)) {
         return NO;
     }
-    
-    return ([aPathModDate compare:bPathModDate] == NSOrderedDescending || bPathModDate == nil);
+
+    return [aPathModDate compare:bPathModDate] == NSOrderedDescending || bPathModDate == nil;
 }
 
-- (BOOL) item:(NSString*)aPath isNewerThanItem:(NSString*)bPath
+- (BOOL)item:(NSString*)aPath isNewerThanItem:(NSString*)bPath
 {
     NSFileManager* fileManager = [NSFileManager defaultManager];
-    
+
     BOOL aPathIsDir = NO, bPathIsDir = NO;
     BOOL aPathExists = [fileManager fileExistsAtPath:aPath isDirectory:&aPathIsDir];
+
     [fileManager fileExistsAtPath:bPath isDirectory:&bPathIsDir];
-    
-    if (!aPathExists) { 
+
+    if (!aPathExists) {
         return NO;
     }
-    
-    if (!(aPathIsDir && bPathIsDir)){ // just a file
+
+    if (!(aPathIsDir && bPathIsDir)) { // just a file
         return [self file:aPath isNewerThanFile:bPath];
     }
-    
+
     // essentially we want rsync here, but have to settle for our poor man's implementation
-    // we get the files in aPath, and see if it is newer than the file in bPath 
+    // we get the files in aPath, and see if it is newer than the file in bPath
     // (it is newer if it doesn't exist in bPath) if we encounter the FIRST file that is newer,
     // we return YES
     NSDirectoryEnumerator* directoryEnumerator = [fileManager enumeratorAtPath:aPath];
     NSString* path;
-    
+
     while ((path = [directoryEnumerator nextObject])) {
         NSString* aPathFile = [aPath stringByAppendingPathComponent:path];
         NSString* bPathFile = [bPath stringByAppendingPathComponent:path];
-        
+
         BOOL isNewer = [self file:aPathFile isNewerThanFile:bPathFile];
         if (isNewer) {
             return YES;
         }
     }
-    
+
     return NO;
 }
 
-- (BOOL) shouldBackup
+- (BOOL)shouldBackup
 {
     return [self item:self.original isNewerThanItem:self.backup];
 }
 
-- (BOOL) shouldRestore
+- (BOOL)shouldRestore
 {
     return [self item:self.backup isNewerThanItem:self.original];
 }

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
old mode 100755
new mode 100644
index 292b161..ae31557
--- a/CordovaLib/Classes/CDVLocation.h
+++ b/CordovaLib/Classes/CDVLocation.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,15 +17,14 @@
  under the License.
  */
 
-
 #import <UIKit/UIKit.h>
 #import <CoreLocation/CoreLocation.h>
 #import "CDVPlugin.h"
 
 enum CDVHeadingStatus {
-	HEADINGSTOPPED = 0,
+    HEADINGSTOPPED = 0,
     HEADINGSTARTING,
-	HEADINGRUNNING,
+    HEADINGRUNNING,
     HEADINGERROR
 };
 typedef NSUInteger CDVHeadingStatus;
@@ -38,8 +37,7 @@ enum CDVLocationStatus {
 typedef NSUInteger CDVLocationStatus;
 
 // simple object to keep track of heading information
-@interface CDVHeadingData : NSObject {
-}
+@interface CDVHeadingData : NSObject {}
 
 @property (nonatomic, assign) CDVHeadingStatus headingStatus;
 @property (nonatomic, strong) CLHeading* headingInfo;
@@ -53,9 +51,9 @@ typedef NSUInteger CDVLocationStatus;
 // simple ojbect to keep track of location information
 @interface CDVLocationData : NSObject {
     CDVLocationStatus locationStatus;
-    NSMutableArray*  locationCallbacks;
-    NSMutableDictionary*  watchCallbacks;
-    CLLocation*      locationInfo;
+    NSMutableArray* locationCallbacks;
+    NSMutableDictionary* watchCallbacks;
+    CLLocation* locationInfo;
 }
 
 @property (nonatomic, assign) CDVLocationStatus locationStatus;
@@ -65,44 +63,42 @@ typedef NSUInteger CDVLocationStatus;
 
 @end
 
-@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate> {
-    @private BOOL      __locationStarted;
-    @private BOOL      __highAccuracyEnabled;
-    CDVHeadingData*    headingData;
-    CDVLocationData*   locationData;
+@interface CDVLocation : CDVPlugin <CLLocationManagerDelegate>{
+    @private BOOL __locationStarted;
+    @private BOOL __highAccuracyEnabled;
+    CDVHeadingData* headingData;
+    CDVLocationData* locationData;
 }
 
-@property (nonatomic, strong) CLLocationManager *locationManager;
+@property (nonatomic, strong) CLLocationManager* locationManager;
 @property (strong) CDVHeadingData* headingData;
 @property (nonatomic, strong) CDVLocationData* locationData;
 
+- (BOOL)hasHeadingSupport;
+- (void)getLocation:(CDVInvokedUrlCommand*)command;
+- (void)addWatch:(CDVInvokedUrlCommand*)command;
+- (void)clearWatch:(CDVInvokedUrlCommand*)command;
+- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback;
+- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message;
+- (void)startLocation:(BOOL)enableHighAccuracy;
 
-- (BOOL) hasHeadingSupport;
-- (void) getLocation:(CDVInvokedUrlCommand*)command;
-- (void) addWatch:(CDVInvokedUrlCommand*)command;
-- (void) clearWatch:(CDVInvokedUrlCommand*)command;
-- (void)returnLocationInfo: (NSString*) callbackId andKeepCallback:(BOOL)keepCallback;
-- (void) returnLocationError: (NSUInteger) errorCode withMessage: (NSString*) message;
-- (void) startLocation: (BOOL) enableHighAccuracy;
-
-- (void) locationManager:(CLLocationManager *)manager
-    didUpdateToLocation:(CLLocation *)newLocation
-           fromLocation:(CLLocation *)oldLocation;
+- (void)locationManager:(CLLocationManager*)manager
+   didUpdateToLocation :(CLLocation*)newLocation
+          fromLocation        :(CLLocation*)oldLocation;
 
-- (void)locationManager:(CLLocationManager *)manager
-       didFailWithError:(NSError *)error;
+- (void)locationManager:(CLLocationManager*)manager
+   didFailWithError    :(NSError*)error;
 
-- (BOOL) isLocationServicesEnabled;
+- (BOOL)isLocationServicesEnabled;
 
 - (void)getHeading:(CDVInvokedUrlCommand*)command;
-- (void)returnHeadingInfo: (NSString*) callbackId keepCallback: (BOOL) bRetain;
+- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain;
 - (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command;
 - (void)stopHeading:(CDVInvokedUrlCommand*)command;
-- (void) startHeadingWithFilter: (CLLocationDegrees) filter;
-- (void)locationManager:(CLLocationManager *)manager
-	   didUpdateHeading:(CLHeading *)heading;
+- (void)startHeadingWithFilter:(CLLocationDegrees)filter;
+- (void)locationManager:(CLLocationManager*)manager
+   didUpdateHeading    :(CLHeading*)heading;
 
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager;
+- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager;
 
 @end
-