incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [7/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/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
old mode 100755
new mode 100644
index 6dcb2af..4ec8119
--- a/CordovaLib/Classes/CDVLocation.m
+++ b/CordovaLib/Classes/CDVLocation.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,38 +17,36 @@
  under the License.
  */
 
-
 #import "CDVLocation.h"
 #import "CDVViewController.h"
 #import "NSArray+Comparisons.h"
 
 #pragma mark Constants
 
-#define kPGLocationErrorDomain          @"kPGLocationErrorDomain"
-#define kPGLocationDesiredAccuracyKey   @"desiredAccuracy"
-#define kPGLocationForcePromptKey       @"forcePrompt"
-#define kPGLocationDistanceFilterKey    @"distanceFilter"
-#define kPGLocationFrequencyKey         @"frequency"
+#define kPGLocationErrorDomain @"kPGLocationErrorDomain"
+#define kPGLocationDesiredAccuracyKey @"desiredAccuracy"
+#define kPGLocationForcePromptKey @"forcePrompt"
+#define kPGLocationDistanceFilterKey @"distanceFilter"
+#define kPGLocationFrequencyKey @"frequency"
 
 #pragma mark -
 #pragma mark Categories
 
-@interface NSError(JSONMethods)
+@interface NSError (JSONMethods)
 
-- (NSString*) JSONRepresentation;
+- (NSString*)JSONRepresentation;
 
 @end
 
-@interface CLLocation(JSONMethods)
+@interface CLLocation (JSONMethods)
 
-- (NSString*) JSONRepresentation;
+- (NSString*)JSONRepresentation;
 
 @end
 
+@interface CLHeading (JSONMethods)
 
-@interface CLHeading(JSONMethods)
-
-- (NSString*) JSONRepresentation;
+- (NSString*)JSONRepresentation;
 
 @end
 
@@ -58,11 +56,10 @@
 @implementation CDVHeadingData
 
 @synthesize headingStatus, headingInfo, headingCallbacks, headingFilter, headingTimestamp, timeout;
--(CDVHeadingData*) init
+- (CDVHeadingData*)init
 {
     self = (CDVHeadingData*)[super init];
-    if (self) 
-	{
+    if (self) {
         self.headingStatus = HEADINGSTOPPED;
         self.headingInfo = nil;
         self.headingCallbacks = nil;
@@ -78,11 +75,10 @@
 @implementation CDVLocationData
 
 @synthesize locationStatus, locationInfo, locationCallbacks, watchCallbacks;
--(CDVLocationData*) init
+- (CDVLocationData*)init
 {
     self = (CDVLocationData*)[super init];
-    if (self) 
-	{
+    if (self) {
         self.locationInfo = nil;
         self.locationCallbacks = nil;
         self.watchCallbacks = nil;
@@ -99,76 +95,68 @@
 
 @synthesize locationManager, headingData, locationData;
 
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
 {
     self = (CDVLocation*)[super initWithWebView:(UIWebView*)theWebView];
-    if (self) 
-	{
+    if (self) {
         self.locationManager = [[CLLocationManager alloc] init];
         self.locationManager.delegate = self; // Tells the location manager to send updates to this object
         __locationStarted = NO;
         __highAccuracyEnabled = NO;
-        self.headingData = nil;   
+        self.headingData = nil;
         self.locationData = nil;
     }
     return self;
 }
 
-- (BOOL) hasHeadingSupport
+- (BOOL)hasHeadingSupport
 {
-	BOOL headingInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(headingAvailable)]; // iOS 3.x
-	BOOL headingClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(headingAvailable)]; // iOS 4.x
-	
-	if (headingInstancePropertyAvailable) { // iOS 3.x
-		return [(id)self.locationManager headingAvailable];
-	} else if (headingClassPropertyAvailable) { // iOS 4.x
-		return [CLLocationManager headingAvailable];
-	} else { // iOS 2.x
-		return NO;
-	}
+    BOOL headingInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(headingAvailable)]; // iOS 3.x
+    BOOL headingClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(headingAvailable)]; // iOS 4.x
+
+    if (headingInstancePropertyAvailable) { // iOS 3.x
+        return [(id)self.locationManager headingAvailable];
+    } else if (headingClassPropertyAvailable) { // iOS 4.x
+        return [CLLocationManager headingAvailable];
+    } else { // iOS 2.x
+        return NO;
+    }
 }
 
-- (BOOL) isAuthorized
+- (BOOL)isAuthorized
 {
-	BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
-    if (authorizationStatusClassPropertyAvailable)
-    {
+    BOOL authorizationStatusClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
+
+    if (authorizationStatusClassPropertyAvailable) {
         NSUInteger authStatus = [CLLocationManager authorizationStatus];
-        return  (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
+        return (authStatus == kCLAuthorizationStatusAuthorized) || (authStatus == kCLAuthorizationStatusNotDetermined);
     }
-    
+
     // by default, assume YES (for iOS < 4.2)
     return YES;
 }
 
-- (BOOL) isLocationServicesEnabled
+- (BOOL)isLocationServicesEnabled
 {
-	BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
-	BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
-    
-	if (locationServicesEnabledClassPropertyAvailable) 
-	{ // iOS 4.x
-		return [CLLocationManager locationServicesEnabled];
-	} 
-	else if (locationServicesEnabledInstancePropertyAvailable) 
-	{ // iOS 2.x, iOS 3.x
-		return [(id)self.locationManager locationServicesEnabled];
-	} 
-	else 
-	{
-		return NO;
-	}
+    BOOL locationServicesEnabledInstancePropertyAvailable = [self.locationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 3.x
+    BOOL locationServicesEnabledClassPropertyAvailable = [CLLocationManager respondsToSelector:@selector(locationServicesEnabled)]; // iOS 4.x
+
+    if (locationServicesEnabledClassPropertyAvailable) { // iOS 4.x
+        return [CLLocationManager locationServicesEnabled];
+    } else if (locationServicesEnabledInstancePropertyAvailable) { // iOS 2.x, iOS 3.x
+        return [(id)self.locationManager locationServicesEnabled];
+    } else {
+        return NO;
+    }
 }
 
-- (void) startLocation:(BOOL) enableHighAccuracy
+- (void)startLocation:(BOOL)enableHighAccuracy
 {
-    if (![self isLocationServicesEnabled])
-	{
-        [self returnLocationError:PERMISSIONDENIED withMessage: @"Location services are not enabled."];
+    if (![self isLocationServicesEnabled]) {
+        [self returnLocationError:PERMISSIONDENIED withMessage:@"Location services are not enabled."];
         return;
     }
-    if (![self isAuthorized]) 
-    {
+    if (![self isAuthorized]) {
         NSString* message = nil;
         BOOL authStatusAvailable = [CLLocationManager respondsToSelector:@selector(authorizationStatus)]; // iOS 4.2+
         if (authStatusAvailable) {
@@ -180,12 +168,12 @@
                 message = @"Application's use of location services is restricted.";
             }
         }
-        //PERMISSIONDENIED is only PositionError that makes sense when authorization denied
-        [self returnLocationError:PERMISSIONDENIED withMessage: message];
-        
+        // PERMISSIONDENIED is only PositionError that makes sense when authorization denied
+        [self returnLocationError:PERMISSIONDENIED withMessage:message];
+
         return;
     }
-	
+
     // Tell the location manager to start notifying us of location updates. We
     // first stop, and then start the updating to ensure we get at least one
     // update, even if our location did not change.
@@ -206,35 +194,36 @@
     }
 }
 
-- (void) _stopLocation
+- (void)_stopLocation
 {
-    if (__locationStarted)
-	{
-		if (![self isLocationServicesEnabled]) {
-			return;
+    if (__locationStarted) {
+        if (![self isLocationServicesEnabled]) {
+            return;
         }
-        
-		[self.locationManager stopUpdatingLocation];
-		__locationStarted = NO;
+
+        [self.locationManager stopUpdatingLocation];
+        __locationStarted = NO;
         __highAccuracyEnabled = NO;
-	}
+    }
 }
 
-- (void) locationManager:(CLLocationManager *)manager
-     didUpdateToLocation:(CLLocation *)newLocation
-            fromLocation:(CLLocation *)oldLocation
+- (void)locationManager:(CLLocationManager*)manager
+    didUpdateToLocation:(CLLocation*)newLocation
+           fromLocation:(CLLocation*)oldLocation
 {
-	CDVLocationData* cData = self.locationData;
+    CDVLocationData* cData = self.locationData;
+
     cData.locationInfo = newLocation;
     if (self.locationData.locationCallbacks.count > 0) {
-        for (NSString *callbackId in self.locationData.locationCallbacks) {
+        for (NSString* callbackId in self.locationData.locationCallbacks) {
             [self returnLocationInfo:callbackId andKeepCallback:NO];
         }
+
         [self.locationData.locationCallbacks removeAllObjects];
     }
     if (self.locationData.watchCallbacks.count > 0) {
-        for (NSString *timerId in self.locationData.watchCallbacks) {
-            [self returnLocationInfo:[self.locationData.watchCallbacks objectForKey: timerId ] andKeepCallback:YES];
+        for (NSString* timerId in self.locationData.watchCallbacks) {
+            [self returnLocationInfo:[self.locationData.watchCallbacks objectForKey:timerId] andKeepCallback:YES];
         }
     } else {
         // No callbacks waiting on us anymore, turn off listening.
@@ -242,17 +231,15 @@
     }
 }
 
-- (void) getLocation:(CDVInvokedUrlCommand*)command
+- (void)getLocation:(CDVInvokedUrlCommand*)command
 {
-
     NSString* callbackId = command.callbackId;
     BOOL enableHighAccuracy = [[command.arguments objectAtIndex:0] boolValue];
 
-    if ([self isLocationServicesEnabled] == NO)
-    {
+    if ([self isLocationServicesEnabled] == NO) {
         NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-        [posError setObject: [NSNumber numberWithInt: PERMISSIONDENIED] forKey:@"code"];
-        [posError setObject: @"Location services are disabled." forKey: @"message"];
+        [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
+        [posError setObject:@"Location services are disabled." forKey:@"message"];
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
     } else {
@@ -263,69 +250,70 @@
         if (!lData.locationCallbacks) {
             lData.locationCallbacks = [NSMutableArray arrayWithCapacity:1];
         }
-        
-        if (!__locationStarted || __highAccuracyEnabled != enableHighAccuracy) {
+
+        if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
             // add the callbackId into the array so we can call back when get data
             [lData.locationCallbacks addObject:callbackId];
             // Tell the location manager to start notifying us of heading updates
-            [self startLocation: enableHighAccuracy];
-        }
-        else {
-            [self returnLocationInfo: callbackId andKeepCallback:NO]; 
+            [self startLocation:enableHighAccuracy];
+        } else {
+            [self returnLocationInfo:callbackId andKeepCallback:NO];
         }
     }
 }
-- (void) addWatch:(CDVInvokedUrlCommand*)command
+
+- (void)addWatch:(CDVInvokedUrlCommand*)command
 {
     NSString* callbackId = command.callbackId;
     NSString* timerId = [command.arguments objectAtIndex:0];
     BOOL enableHighAccuracy = [[command.arguments objectAtIndex:1] boolValue];
-    
+
     if (!self.locationData) {
         self.locationData = [[CDVLocationData alloc] init];
     }
     CDVLocationData* lData = self.locationData;
-    
+
     if (!lData.watchCallbacks) {
         lData.watchCallbacks = [NSMutableDictionary dictionaryWithCapacity:1];
     }
-    
+
     // add the callbackId into the dictionary so we can call back whenever get data
     [lData.watchCallbacks setObject:callbackId forKey:timerId];
-    
-    if ([self isLocationServicesEnabled] == NO)
-    {
+
+    if ([self isLocationServicesEnabled] == NO) {
         NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-        [posError setObject: [NSNumber numberWithInt: PERMISSIONDENIED] forKey:@"code"];
-        [posError setObject: @"Location services are disabled." forKey: @"message"];
+        [posError setObject:[NSNumber numberWithInt:PERMISSIONDENIED] forKey:@"code"];
+        [posError setObject:@"Location services are disabled." forKey:@"message"];
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
     } else {
-        if (!__locationStarted || __highAccuracyEnabled != enableHighAccuracy) {
+        if (!__locationStarted || (__highAccuracyEnabled != enableHighAccuracy)) {
             // Tell the location manager to start notifying us of location updates
-            [self startLocation: enableHighAccuracy];
+            [self startLocation:enableHighAccuracy];
         }
     }
 }
-- (void) clearWatch:(CDVInvokedUrlCommand*)command
+
+- (void)clearWatch:(CDVInvokedUrlCommand*)command
 {
     NSString* timerId = [command.arguments objectAtIndex:0];
+
     if (self.locationData && self.locationData.watchCallbacks && [self.locationData.watchCallbacks objectForKey:timerId]) {
         [self.locationData.watchCallbacks removeObjectForKey:timerId];
     }
 }
 
-- (void) stopLocation:(CDVInvokedUrlCommand*)command
+- (void)stopLocation:(CDVInvokedUrlCommand*)command
 {
     [self _stopLocation];
 }
 
-- (void)returnLocationInfo: (NSString*) callbackId andKeepCallback:(BOOL)keepCallback
+- (void)returnLocationInfo:(NSString*)callbackId andKeepCallback:(BOOL)keepCallback
 {
     CDVPluginResult* result = nil;
     NSString* jsString = nil;
     CDVLocationData* lData = self.locationData;
-    
+
     if (lData && !lData.locationInfo) {
         // return error
         result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:POSITIONUNAVAILABLE];
@@ -333,39 +321,45 @@
     } else if (lData && lData.locationInfo) {
         CLLocation* lInfo = lData.locationInfo;
         NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:8];
-        NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970]*1000)];
+        NSNumber* timestamp = [NSNumber numberWithDouble:([lInfo.timestamp timeIntervalSince1970] * 1000)];
         [returnInfo setObject:timestamp forKey:@"timestamp"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.speed] forKey:@"velocity"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.horizontalAccuracy] forKey:@"accuracy"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.course] forKey:@"heading"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.altitude] forKey:@"altitude"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.coordinate.latitude] forKey:@"latitude"];
-        [returnInfo setObject:[NSNumber numberWithDouble: lInfo.coordinate.longitude] forKey:@"longitude"];
-        
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: returnInfo];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.speed] forKey:@"velocity"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.verticalAccuracy] forKey:@"altitudeAccuracy"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.horizontalAccuracy] forKey:@"accuracy"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.course] forKey:@"heading"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.altitude] forKey:@"altitude"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.latitude] forKey:@"latitude"];
+        [returnInfo setObject:[NSNumber numberWithDouble:lInfo.coordinate.longitude] forKey:@"longitude"];
+
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
         [result setKeepCallbackAsBool:keepCallback];
-        
+
         jsString = [result toSuccessCallbackString:callbackId];
     }
     if (jsString) {
         [super writeJavascript:jsString];
     }
 }
-- (void)returnLocationError: (NSUInteger) errorCode withMessage: (NSString*) message
+
+- (void)returnLocationError:(NSUInteger)errorCode withMessage:(NSString*)message
 {
     NSMutableDictionary* posError = [NSMutableDictionary dictionaryWithCapacity:2];
-    [posError setObject: [NSNumber numberWithInt: errorCode] forKey:@"code"];
-    [posError setObject: message ? message : @"" forKey: @"message"];
+
+    [posError setObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
+    [posError setObject:message ? message:@"" forKey:@"message"];
     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsDictionary:posError];
-    for (NSString *callbackId in self.locationData.locationCallbacks) {
+
+    for (NSString* callbackId in self.locationData.locationCallbacks) {
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
     }
+
     [self.locationData.locationCallbacks removeAllObjects];
-    for (NSString *callbackId in self.locationData.watchCallbacks) {
+
+    for (NSString* callbackId in self.locationData.watchCallbacks) {
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
     }
 }
+
 // called to get the current heading
 // Will call location manager to startUpdatingHeading if necessary
 
@@ -374,12 +368,12 @@
     NSString* callbackId = command.callbackId;
     NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
     NSNumber* filter = [options valueForKey:@"filter"];
+
     if (filter) {
         [self watchHeadingFilter:command];
         return;
     }
-    if ([self hasHeadingSupport] == NO) 
-    {
+    if ([self hasHeadingSupport] == NO) {
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
     } else {
@@ -393,19 +387,17 @@
             hData.headingCallbacks = [NSMutableArray arrayWithCapacity:1];
         }
         // add the callbackId into the array so we can call back when get data
-        [hData.headingCallbacks addObject:callbackId]; 
-        
-        if (hData.headingStatus != HEADINGRUNNING && hData.headingStatus != HEADINGERROR) {
+        [hData.headingCallbacks addObject:callbackId];
+
+        if ((hData.headingStatus != HEADINGRUNNING) && (hData.headingStatus != HEADINGERROR)) {
             // Tell the location manager to start notifying us of heading updates
-            [self startHeadingWithFilter: 0.2];
-        }
-        else {
-            [self returnHeadingInfo: callbackId keepCallback:NO]; 
+            [self startHeadingWithFilter:0.2];
+        } else {
+            [self returnHeadingInfo:callbackId keepCallback:NO];
         }
     }
-    
-    
-} 
+}
+
 // called to request heading updates when heading changes by a certain amount (filter)
 - (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command
 {
@@ -413,6 +405,7 @@
     NSDictionary* options = [command.arguments objectAtIndex:0 withDefault:nil];
     NSNumber* filter = [options valueForKey:@"filter"];
     CDVHeadingData* hData = self.headingData;
+
     if ([self hasHeadingSupport] == NO) {
         CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:20];
         [super writeJavascript:[result toErrorCallbackString:callbackId]];
@@ -423,160 +416,157 @@
         }
         if (hData.headingStatus != HEADINGRUNNING) {
             // Tell the location manager to start notifying us of heading updates
-            [self startHeadingWithFilter: [filter doubleValue]];
+            [self startHeadingWithFilter:[filter doubleValue]];
         } else {
             // if already running check to see if due to existing watch filter
-            if (hData.headingFilter && ![hData.headingFilter isEqualToString:callbackId]){
+            if (hData.headingFilter && ![hData.headingFilter isEqualToString:callbackId]) {
                 // new watch filter being specified
                 // send heading data one last time to clear old successCallback
-                [self returnHeadingInfo:hData.headingFilter keepCallback: NO];
-            } 
-            
+                [self returnHeadingInfo:hData.headingFilter keepCallback:NO];
+            }
         }
         // save the new filter callback and update the headingFilter setting
         hData.headingFilter = callbackId;
         // check if need to stop and restart in order to change value???
         self.locationManager.headingFilter = [filter doubleValue];
-    } 
+    }
 }
-- (void)returnHeadingInfo: (NSString*) callbackId keepCallback: (BOOL) bRetain
+
+- (void)returnHeadingInfo:(NSString*)callbackId keepCallback:(BOOL)bRetain
 {
     CDVPluginResult* result = nil;
     NSString* jsString = nil;
     CDVHeadingData* hData = self.headingData;
-    
+
     self.headingData.headingTimestamp = [NSDate date];
-    
-    if (hData && hData.headingStatus == HEADINGERROR) {
+
+    if (hData && (hData.headingStatus == HEADINGERROR)) {
         // return error
         result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
         jsString = [result toErrorCallbackString:callbackId];
-    } else if (hData && hData.headingStatus == HEADINGRUNNING && hData.headingInfo) {
+    } else if (hData && (hData.headingStatus == HEADINGRUNNING) && hData.headingInfo) {
         // if there is heading info, return it
         CLHeading* hInfo = hData.headingInfo;
         NSMutableDictionary* returnInfo = [NSMutableDictionary dictionaryWithCapacity:4];
-        NSNumber* timestamp = [NSNumber numberWithDouble:([hInfo.timestamp timeIntervalSince1970]*1000)];
+        NSNumber* timestamp = [NSNumber numberWithDouble:([hInfo.timestamp timeIntervalSince1970] * 1000)];
         [returnInfo setObject:timestamp forKey:@"timestamp"];
-        [returnInfo setObject:[NSNumber numberWithDouble: hInfo.magneticHeading] forKey:@"magneticHeading"];
-        id trueHeading = __locationStarted ? (id)[NSNumber numberWithDouble:hInfo.trueHeading]:(id)[NSNull null];
+        [returnInfo setObject:[NSNumber numberWithDouble:hInfo.magneticHeading] forKey:@"magneticHeading"];
+        id trueHeading = __locationStarted ? (id)[NSNumber numberWithDouble : hInfo.trueHeading] : (id)[NSNull null];
         [returnInfo setObject:trueHeading forKey:@"trueHeading"];
-        [returnInfo setObject:[NSNumber numberWithDouble: hInfo.headingAccuracy] forKey:@"headingAccuracy"];
-        
-        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: returnInfo];
+        [returnInfo setObject:[NSNumber numberWithDouble:hInfo.headingAccuracy] forKey:@"headingAccuracy"];
+
+        result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:returnInfo];
         [result setKeepCallbackAsBool:bRetain];
-        
+
         jsString = [result toSuccessCallbackString:callbackId];
     }
     if (jsString) {
         [super writeJavascript:jsString];
     }
-    
-    
 }
 
-- (void) stopHeading:(CDVInvokedUrlCommand*)command
+- (void)stopHeading:(CDVInvokedUrlCommand*)command
 {
-    //CDVHeadingData* hData = self.headingData;
-    if (self.headingData && self.headingData.headingStatus != HEADINGSTOPPED)
-	{
-		if (self.headingData.headingFilter) {
+    // CDVHeadingData* hData = self.headingData;
+    if (self.headingData && (self.headingData.headingStatus != HEADINGSTOPPED)) {
+        if (self.headingData.headingFilter) {
             // callback one last time to clear callback
-            [self returnHeadingInfo: self.headingData.headingFilter keepCallback:NO];
+            [self returnHeadingInfo:self.headingData.headingFilter keepCallback:NO];
             self.headingData.headingFilter = nil;
         }
-        [self.locationManager stopUpdatingHeading];	
+        [self.locationManager stopUpdatingHeading];
         NSLog(@"heading STOPPED");
         self.headingData = nil;
-	}
-}	
-
+    }
+}
 
 // helper method to check the orientation and start updating headings
-- (void) startHeadingWithFilter: (CLLocationDegrees) filter
+- (void)startHeadingWithFilter:(CLLocationDegrees)filter
 {
-    if ([self.locationManager respondsToSelector: @selector(headingOrientation)]) {
+    if ([self.locationManager respondsToSelector:@selector(headingOrientation)]) {
         UIDeviceOrientation currentOrientation = [[UIDevice currentDevice] orientation];
         if (currentOrientation != UIDeviceOrientationUnknown) {
             CDVViewController* cdvViewController = (CDVViewController*)self.viewController;
-            
+
             if ([cdvViewController supportsOrientation:currentOrientation]) {
-                
                 self.locationManager.headingOrientation = (CLDeviceOrientation)currentOrientation;
                 // FYI UIDeviceOrientation and CLDeviceOrientation enums are currently the same
-            }   
+            }
         }
     }
     self.locationManager.headingFilter = filter;
     [self.locationManager startUpdatingHeading];
     self.headingData.headingStatus = HEADINGSTARTING;
 }
-- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager *)manager
+
+- (BOOL)locationManagerShouldDisplayHeadingCalibration:(CLLocationManager*)manager
 {
-	return YES;
+    return YES;
 }
 
-- (void) locationManager:(CLLocationManager *)manager
-        didUpdateHeading:(CLHeading *)heading
+- (void)locationManager:(CLLocationManager*)manager
+       didUpdateHeading:(CLHeading*)heading
 {
     CDVHeadingData* hData = self.headingData;
-    
+
     // normally we would clear the delegate to stop getting these notifications, but
     // we are sharing a CLLocationManager to get location data as well, so we do a nil check here
     // ideally heading and location should use their own CLLocationManager instances
     if (hData == nil) {
         return;
     }
-    
+
     // save the data for next call into getHeadingData
     hData.headingInfo = heading;
     BOOL bTimeout = NO;
     if (!hData.headingFilter && hData.headingTimestamp) {
-        bTimeout = fabs([hData.headingTimestamp timeIntervalSinceNow ]) > hData.timeout;
+        bTimeout = fabs([hData.headingTimestamp timeIntervalSinceNow]) > hData.timeout;
     }
-    
+
     if (hData.headingStatus == HEADINGSTARTING) {
         hData.headingStatus = HEADINGRUNNING; // so returnHeading info will work
-        //this is the first update
+
+        // this is the first update
         for (NSString* callbackId in hData.headingCallbacks) {
             [self returnHeadingInfo:callbackId keepCallback:NO];
         }
+
         [hData.headingCallbacks removeAllObjects];
     }
     if (hData.headingFilter) {
-        [self returnHeadingInfo: hData.headingFilter keepCallback:YES];
+        [self returnHeadingInfo:hData.headingFilter keepCallback:YES];
     } else if (bTimeout) {
         [self stopHeading:nil];
     }
     hData.headingStatus = HEADINGRUNNING;  // to clear any error
-    
 }
-- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error
+
+- (void)locationManager:(CLLocationManager*)manager didFailWithError:(NSError*)error
 {
     NSLog(@"locationManager::didFailWithError %@", [error localizedFailureReason]);
-	
+
     // Compass Error
-	if ([error code] == kCLErrorHeadingFailure)
-	{
-		CDVHeadingData* hData = self.headingData;
+    if ([error code] == kCLErrorHeadingFailure) {
+        CDVHeadingData* hData = self.headingData;
         if (hData) {
             if (hData.headingStatus == HEADINGSTARTING) {
                 // heading error during startup - report error
                 for (NSString* callbackId in hData.headingCallbacks) {
                     CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
-                    [super writeJavascript: [result toErrorCallbackString:callbackId]];
+                    [super writeJavascript:[result toErrorCallbackString:callbackId]];
                 }
+
                 [hData.headingCallbacks removeAllObjects];
             } // else for frequency watches next call to getCurrentHeading will report error
             if (hData.headingFilter) {
                 CDVPluginResult* resultFilter = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsInt:0];
-                [super writeJavascript: [resultFilter toErrorCallbackString:hData.headingFilter]];
+                [super writeJavascript:[resultFilter toErrorCallbackString:hData.headingFilter]];
             }
             hData.headingStatus = HEADINGERROR;
         }
-	} 
+    }
     // Location Error
-	else 
-	{
+    else {
         CDVLocationData* lData = self.locationData;
         if (lData && __locationStarted) {
             // TODO: probably have to once over the various error codes and return one of:
@@ -587,18 +577,17 @@
             if (error.code == kCLErrorDenied) {
                 positionError = PERMISSIONDENIED;
             }
-            [self returnLocationError:positionError withMessage: [error localizedDescription]];
-
+            [self returnLocationError:positionError withMessage:[error localizedDescription]];
         }
-	}
-    
-	[self.locationManager stopUpdatingLocation];
+    }
+
+    [self.locationManager stopUpdatingLocation];
     __locationStarted = NO;
 }
 
-- (void) dealloc 
+- (void)dealloc
 {
-	self.locationManager.delegate = nil;
+    self.locationManager.delegate = nil;
 }
 
 @end
@@ -606,39 +595,38 @@
 #pragma mark -
 #pragma mark CLLocation(JSONMethods)
 
-@implementation CLLocation(JSONMethods)
+@implementation CLLocation (JSONMethods)
 
-- (NSString*) JSONRepresentation
+- (NSString*)JSONRepresentation
 {
-	return [NSString stringWithFormat:
-            @"{ timestamp: %.00f, \
+    return [NSString stringWithFormat:
+        @"{ timestamp: %.00f, \
             coords: { latitude: %f, longitude: %f, altitude: %.02f, heading: %.02f, speed: %.02f, accuracy: %.02f, altitudeAccuracy: %.02f } \
-            }",
-            [self.timestamp timeIntervalSince1970] * 1000.0,
-            self.coordinate.latitude,
-            self.coordinate.longitude,
-            self.altitude,
-            self.course,
-            self.speed,
-            self.horizontalAccuracy,
-            self.verticalAccuracy
-			];
+            }"                                                                                                                                                                               ,
+        [self.timestamp timeIntervalSince1970] * 1000.0,
+        self.coordinate.latitude,
+        self.coordinate.longitude,
+        self.altitude,
+        self.course,
+        self.speed,
+        self.horizontalAccuracy,
+        self.verticalAccuracy
+    ];
 }
 
 @end
 
-
 #pragma mark NSError(JSONMethods)
 
-@implementation NSError(JSONMethods)
+@implementation NSError (JSONMethods)
 
-- (NSString*) JSONRepresentation
+- (NSString*)JSONRepresentation
 {
     return [NSString stringWithFormat:
-            @"{ code: %d, message: '%@'}", 
-			self.code, 
-			[self localizedDescription]
-            ];
+        @"{ code: %d, message: '%@'}",
+        self.code,
+        [self localizedDescription]
+    ];
 }
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVLogger.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLogger.h b/CordovaLib/Classes/CDVLogger.h
index 484a566..eeba63c 100644
--- a/CordovaLib/Classes/CDVLogger.h
+++ b/CordovaLib/Classes/CDVLogger.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,6 +21,6 @@
 
 @interface CDVLogger : CDVPlugin
 
-- (void) logLevel:(CDVInvokedUrlCommand*)command;
+- (void)logLevel:(CDVInvokedUrlCommand*)command;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVLogger.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLogger.m b/CordovaLib/Classes/CDVLogger.m
index bf4a36c..a37cf8a 100644
--- a/CordovaLib/Classes/CDVLogger.m
+++ b/CordovaLib/Classes/CDVLogger.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,17 +23,16 @@
 @implementation CDVLogger
 
 /* log a message */
-- (void) logLevel:(CDVInvokedUrlCommand*)command
+- (void)logLevel:(CDVInvokedUrlCommand*)command
 {
-    id level   = [command.arguments objectAtIndex:0];
+    id level = [command.arguments objectAtIndex:0];
     id message = [command.arguments objectAtIndex:1];
 
     if ([level isEqualToString:@"LOG"]) {
         NSLog(@"%@", message);
-    }
-    else {
+    } else {
         NSLog(@"%@: %@", level, message);
     }
 }
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVNotification.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.h b/CordovaLib/Classes/CDVNotification.h
index c6be279..1eedb54 100644
--- a/CordovaLib/Classes/CDVNotification.h
+++ b/CordovaLib/Classes/CDVNotification.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,14 +17,12 @@
  under the License.
  */
 
-
 #import <Foundation/Foundation.h>
 #import <UIKit/UIKit.h>
 #import <AudioToolbox/AudioServices.h>
 #import "CDVPlugin.h"
 
-@interface CDVNotification : CDVPlugin <UIAlertViewDelegate>{
-}
+@interface CDVNotification : CDVPlugin <UIAlertViewDelegate>{}
 
 - (void)alert:(CDVInvokedUrlCommand*)command;
 - (void)confirm:(CDVInvokedUrlCommand*)command;
@@ -32,8 +30,7 @@
 
 @end
 
-@interface CDVAlertView : UIAlertView {
-}
-@property(nonatomic, copy) NSString* callbackId;
+@interface CDVAlertView : UIAlertView {}
+@property (nonatomic, copy) NSString* callbackId;
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVNotification.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVNotification.m b/CordovaLib/Classes/CDVNotification.m
index 479ecd8..3feafb1 100644
--- a/CordovaLib/Classes/CDVNotification.m
+++ b/CordovaLib/Classes/CDVNotification.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,90 +17,87 @@
  under the License.
  */
 
-
 #import "CDVNotification.h"
 #import "NSDictionary+Extensions.h"
 
-
 @implementation CDVNotification
 
-- (void) showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSString*)buttons callbackId:(NSString*)callbackId
+- (void)showDialogWithMessage:(NSString*)message title:(NSString*)title buttons:(NSString*)buttons callbackId:(NSString*)callbackId
 {
-	CDVAlertView *alertView = [[CDVAlertView alloc]
-							  initWithTitle:title
-							  message:message 
-							  delegate:self 
-							  cancelButtonTitle:nil 
-							  otherButtonTitles:nil];
-	
-	alertView.callbackId = callbackId;
-
-	NSArray* labels = [buttons componentsSeparatedByString:@","];
-	int count = [labels count];
-	
-	for(int n = 0; n < count; n++)
-	{
-		[alertView addButtonWithTitle:[labels objectAtIndex:n]];
-	}
-	
-	[alertView show];
+    CDVAlertView* alertView = [[CDVAlertView alloc]
+            initWithTitle:title
+                  message:message
+                 delegate:self
+        cancelButtonTitle:nil
+        otherButtonTitles:nil];
+
+    alertView.callbackId = callbackId;
+
+    NSArray* labels = [buttons componentsSeparatedByString:@","];
+    int count = [labels count];
+
+    for (int n = 0; n < count; n++) {
+        [alertView addButtonWithTitle:[labels objectAtIndex:n]];
+    }
+
+    [alertView show];
 }
 
-- (void) alert:(CDVInvokedUrlCommand*)command
+- (void)alert:(CDVInvokedUrlCommand*)command
 {
-	NSString* callbackId = command.callbackId;
+    NSString* callbackId = command.callbackId;
     NSArray* arguments = command.arguments;
     int argc = [arguments count];
 
-	NSString* message = argc > 0 ? [arguments objectAtIndex:0] : nil;
-	NSString* title   = argc > 1 ? [arguments objectAtIndex:1] : nil;
-	NSString* buttons = argc > 2 ? [arguments objectAtIndex:2] : nil;
+    NSString* message = argc > 0 ?[arguments objectAtIndex:0] : nil;
+    NSString* title = argc > 1 ?[arguments objectAtIndex:1] : nil;
+    NSString* buttons = argc > 2 ?[arguments objectAtIndex:2] : nil;
 
-	if (!title) {
+    if (!title) {
         title = NSLocalizedString(@"Alert", @"Alert");
     }
-	if (!buttons) {
+    if (!buttons) {
         buttons = NSLocalizedString(@"OK", @"OK");
     }
-		
+
     [self showDialogWithMessage:message title:title buttons:buttons callbackId:callbackId];
 }
 
-- (void) confirm:(CDVInvokedUrlCommand*)command
-{   
-	NSString* callbackId = command.callbackId;
+- (void)confirm:(CDVInvokedUrlCommand*)command
+{
+    NSString* callbackId = command.callbackId;
     NSArray* arguments = command.arguments;
     int argc = [arguments count];
 
-	NSString* message = argc > 0 ? [arguments objectAtIndex:0] : nil;
-	NSString* title   = argc > 1 ? [arguments objectAtIndex:1] : nil;
-	NSString* buttons = argc > 2 ? [arguments objectAtIndex:2] : nil;
-	
-	if (!title) {
+    NSString* message = argc > 0 ?[arguments objectAtIndex:0] : nil;
+    NSString* title = argc > 1 ?[arguments objectAtIndex:1] : nil;
+    NSString* buttons = argc > 2 ?[arguments objectAtIndex:2] : nil;
+
+    if (!title) {
         title = NSLocalizedString(@"Confirm", @"Confirm");
     }
-	if (!buttons) {
+    if (!buttons) {
         buttons = NSLocalizedString(@"OK,Cancel", @"OK,Cancel");
     }
-    
+
     [self showDialogWithMessage:message title:title buttons:buttons callbackId:callbackId];
 }
 
 /**
- Callback invoked when an alert dialog's buttons are clicked.   
+ Callback invoked when an alert dialog's buttons are clicked.
  Passes the index + label back to JS
  */
-- (void) alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
+- (void)alertView:(UIAlertView*)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
 {
-	CDVAlertView* cdvAlertView = (CDVAlertView*) alertView;
-	CDVPluginResult* result = [CDVPluginResult resultWithStatus: CDVCommandStatus_OK messageAsInt: ++buttonIndex]; 
-    
-	[self writeJavascript:[result toSuccessCallbackString:cdvAlertView.callbackId]];
+    CDVAlertView* cdvAlertView = (CDVAlertView*)alertView;
+    CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsInt:++buttonIndex];
+
+    [self writeJavascript:[result toSuccessCallbackString:cdvAlertView.callbackId]];
 }
- 
-- (void) vibrate:(CDVInvokedUrlCommand*)command
+
+- (void)vibrate:(CDVInvokedUrlCommand*)command
 {
-	AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
+    AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
 }
 
 @end
@@ -109,5 +106,4 @@
 
 @synthesize callbackId;
 
-
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVPlugin.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.h b/CordovaLib/Classes/CDVPlugin.h
index edb8b6f..3079334 100644
--- a/CordovaLib/Classes/CDVPlugin.h
+++ b/CordovaLib/Classes/CDVPlugin.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
@@ -23,24 +23,23 @@
 #import "NSMutableArray+QueueAdditions.h"
 #import "CDVCommandDelegate.h"
 
-#define CDVPluginHandleOpenURLNotification	@"CDVPluginHandleOpenURLNotification"
+#define CDVPluginHandleOpenURLNotification @"CDVPluginHandleOpenURLNotification"
 
-@interface CDVPlugin : NSObject {
-}
+@interface CDVPlugin : NSObject {}
 
 @property (nonatomic, strong) UIWebView* webView;
 @property (nonatomic, strong) NSDictionary* settings;
 @property (nonatomic, strong) UIViewController* viewController;
-@property (nonatomic, strong) id<CDVCommandDelegate> commandDelegate;
+@property (nonatomic, strong) id <CDVCommandDelegate> commandDelegate;
 
 @property (readonly, assign) BOOL hasPendingOperation;
 
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView;
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings;
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView;
 
-- (void) handleOpenURL:(NSNotification*)notification;
-- (void) onAppTerminate;
-- (void) onMemoryWarning;
+- (void)handleOpenURL:(NSNotification*)notification;
+- (void)onAppTerminate;
+- (void)onMemoryWarning;
 
 /*
  // see initWithWebView implementation
@@ -50,10 +49,10 @@
  - (void) onOrientationDidChange {}
  */
 
-- (id) appDelegate;
+- (id)appDelegate;
 
-- (NSString*) writeJavascript:(NSString*)javascript;
-- (NSString*) success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
-- (NSString*) error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
+- (NSString*)writeJavascript:(NSString*)javascript;
+- (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
+- (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVPlugin.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPlugin.m b/CordovaLib/Classes/CDVPlugin.m
index c14f72c..67babb4 100644
--- a/CordovaLib/Classes/CDVPlugin.m
+++ b/CordovaLib/Classes/CDVPlugin.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,7 +17,6 @@
  under the License.
  */
 
-
 #import "CDVPlugin.h"
 
 @interface CDVPlugin ()
@@ -29,42 +28,42 @@
 @implementation CDVPlugin
 @synthesize webView, settings, viewController, commandDelegate, hasPendingOperation;
 
-
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView settings:(NSDictionary*)classSettings
 {
     self = [self initWithWebView:theWebView];
     if (self) {
         self.settings = classSettings;
         self.hasPendingOperation = NO;
-	}
+    }
     return self;
 }
 
-- (CDVPlugin*) initWithWebView:(UIWebView*)theWebView
+- (CDVPlugin*)initWithWebView:(UIWebView*)theWebView
 {
     self = [super init];
     if (self) {
-		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
-		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
-		[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
-        
-		self.webView = theWebView;
-		
-		// You can listen to more app notifications, see:
-		// http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
-		/*
-		 // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler, and also the removeObserver in dealloc
-		 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
-		 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
-		 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
-		 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
-		 */
-	}
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onAppTerminate) name:UIApplicationWillTerminateNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMemoryWarning) name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
+        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleOpenURL:) name:CDVPluginHandleOpenURLNotification object:nil];
+
+        self.webView = theWebView;
+
+        // You can listen to more app notifications, see:
+        // http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIApplication_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006728-CH3-DontLinkElementID_4
+
+        /*
+         // NOTE: if you want to use these, make sure you uncomment the corresponding notification handler, and also the removeObserver in dealloc
+         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onPause) name:UIApplicationDidEnterBackgroundNotification object:nil];
+         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onResume) name:UIApplicationWillEnterForegroundNotification object:nil];
+         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationWillChange) name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+         [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
+         */
+    }
     return self;
 }
 
 /*
-// NOTE: for onPause and onResume, calls into JavaScript must not call or trigger any blocking UI, like alerts 
+// NOTE: for onPause and onResume, calls into JavaScript must not call or trigger any blocking UI, like alerts
 - (void) onPause {}
 - (void) onResume {}
 - (void) onOrientationWillChange {}
@@ -72,59 +71,61 @@
 */
 
 /* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void) handleOpenURL:(NSNotification*)notification
+- (void)handleOpenURL:(NSNotification*)notification
 {
-	// override to handle urls sent to your app
-	// register your url schemes in your App-Info.plist
-	
-	NSURL* url = [notification object];
-	if ([url isKindOfClass:[NSURL class]]) {
-		/* Do your thing! */
-	}
+    // override to handle urls sent to your app
+    // register your url schemes in your App-Info.plist
+
+    NSURL* url = [notification object];
+
+    if ([url isKindOfClass:[NSURL class]]) {
+        /* Do your thing! */
+    }
 }
 
 /* NOTE: calls into JavaScript must not call or trigger any blocking UI, like alerts */
-- (void) onAppTerminate
+- (void)onAppTerminate
 {
-	// override this if you need to do any cleanup on app exit
+    // override this if you need to do any cleanup on app exit
 }
 
-- (void) onMemoryWarning
+- (void)onMemoryWarning
 {
-	// override to remove caches, etc
+    // override to remove caches, etc
 }
 
-- (void) dealloc
+- (void)dealloc
 {
-	[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
-	[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
-	[[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil];
-	/*
-	 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
-	 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
-	 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
-	 [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
-	 */
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillTerminateNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidReceiveMemoryWarningNotification object:nil];
+    [[NSNotificationCenter defaultCenter] removeObserver:self name:CDVPluginHandleOpenURLNotification object:nil];
+
+    /*
+     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidEnterBackgroundNotification object:nil];
+     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillEnterForegroundNotification object:nil];
+     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationWillChangeStatusBarOrientationNotification object:nil];
+     [[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidChangeStatusBarOrientationNotification object:nil];
+     */
 }
 
-- (id) appDelegate
+- (id)appDelegate
 {
-	return [[UIApplication sharedApplication] delegate];
+    return [[UIApplication sharedApplication] delegate];
 }
 
-- (NSString*) writeJavascript:(NSString*)javascript
+- (NSString*)writeJavascript:(NSString*)javascript
 {
-	return [self.webView stringByEvaluatingJavaScriptFromString:javascript];
+    return [self.webView stringByEvaluatingJavaScriptFromString:javascript];
 }
 
-- (NSString*) success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
+- (NSString*)success:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
 {
-	return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toSuccessCallbackString:callbackId]]];
+    return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toSuccessCallbackString:callbackId]]];
 }
 
-- (NSString*) error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
+- (NSString*)error:(CDVPluginResult*)pluginResult callbackId:(NSString*)callbackId
 {
-	return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toErrorCallbackString:callbackId]]];
+    return [self writeJavascript:[NSString stringWithFormat:@"setTimeout(function() { %@; }, 0);", [pluginResult toErrorCallbackString:callbackId]]];
 }
 
-@end
\ No newline at end of file
+@end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVPluginResult.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.h b/CordovaLib/Classes/CDVPluginResult.h
index c2df23b..6dd7d45 100644
--- a/CordovaLib/Classes/CDVPluginResult.h
+++ b/CordovaLib/Classes/CDVPluginResult.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,43 +20,40 @@
 #import <Foundation/Foundation.h>
 
 typedef enum {
-	CDVCommandStatus_NO_RESULT = 0,
-	CDVCommandStatus_OK,
-	CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION,
-	CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION,
-	CDVCommandStatus_INSTANTIATION_EXCEPTION,
-	CDVCommandStatus_MALFORMED_URL_EXCEPTION,
-	CDVCommandStatus_IO_EXCEPTION,
-	CDVCommandStatus_INVALID_ACTION,
-	CDVCommandStatus_JSON_EXCEPTION,
-	CDVCommandStatus_ERROR
+    CDVCommandStatus_NO_RESULT = 0,
+    CDVCommandStatus_OK,
+    CDVCommandStatus_CLASS_NOT_FOUND_EXCEPTION,
+    CDVCommandStatus_ILLEGAL_ACCESS_EXCEPTION,
+    CDVCommandStatus_INSTANTIATION_EXCEPTION,
+    CDVCommandStatus_MALFORMED_URL_EXCEPTION,
+    CDVCommandStatus_IO_EXCEPTION,
+    CDVCommandStatus_INVALID_ACTION,
+    CDVCommandStatus_JSON_EXCEPTION,
+    CDVCommandStatus_ERROR
 } CDVCommandStatus;
-	
-@interface CDVPluginResult : NSObject {
 
-}
+@interface CDVPluginResult : NSObject {}
 
 @property (nonatomic, strong, readonly) NSNumber* status;
 @property (nonatomic, strong, readonly) id message;
-@property (nonatomic, strong)			NSNumber* keepCallback;
-
--(CDVPluginResult*) init;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsString: (NSString*) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage;
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageToErrorObject: (int) errorCode;
-
-+(void) setVerbose:(BOOL)verbose;
-+(BOOL) isVerbose;
- 
--(void) setKeepCallbackAsBool: (BOOL) bKeepCallback;
-
-
--(NSString*) toJSONString;
--(NSString*) toSuccessCallbackString: (NSString*) callbackId;
--(NSString*) toErrorCallbackString: (NSString*) callbackId;
+@property (nonatomic, strong)           NSNumber* keepCallback;
+
+- (CDVPluginResult*)init;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage;
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode;
+
++ (void)setVerbose:(BOOL)verbose;
++ (BOOL)isVerbose;
+
+- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback;
+
+- (NSString*)toJSONString;
+- (NSString*)toSuccessCallbackString:(NSString*)callbackId;
+- (NSString*)toErrorCallbackString:(NSString*)callbackId;
 
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVPluginResult.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVPluginResult.m b/CordovaLib/Classes/CDVPluginResult.m
index 8630a9c..5343dce 100644
--- a/CordovaLib/Classes/CDVPluginResult.m
+++ b/CordovaLib/Classes/CDVPluginResult.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
@@ -21,132 +21,133 @@
 #import "JSONKit.h"
 #import "CDVDebug.h"
 
-@interface CDVPluginResult()
+@interface CDVPluginResult ()
 
--(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage;
+- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage;
 
 @end
 
-
 @implementation CDVPluginResult
 @synthesize status, message, keepCallback;
 
 static NSArray* org_apache_cordova_CommandStatusMsgs;
 
-+(void) initialize
++ (void)initialize
 {
-	org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects: @"No result",
-									  @"OK",
-									  @"Class not found",
-									  @"Illegal access",
-									  @"Instantiation error",
-									  @"Malformed url",
-									  @"IO error",
-									  @"Invalid action",
-									  @"JSON error",
-									  @"Error",
-									  nil];
+    org_apache_cordova_CommandStatusMsgs = [[NSArray alloc] initWithObjects:@"No result",
+        @"OK",
+        @"Class not found",
+        @"Illegal access",
+        @"Instantiation error",
+        @"Malformed url",
+        @"IO error",
+        @"Invalid action",
+        @"JSON error",
+        @"Error",
+        nil];
 }
-		
--(CDVPluginResult*) init
+
+- (CDVPluginResult*)init
+{
+    return [self initWithStatus:CDVCommandStatus_NO_RESULT message:nil];
+}
+
+- (CDVPluginResult*)initWithStatus:(CDVCommandStatus)statusOrdinal message:(id)theMessage
 {
-	return [self initWithStatus: CDVCommandStatus_NO_RESULT message: nil];
+    self = [super init];
+    if (self) {
+        status = [NSNumber numberWithInt:statusOrdinal];
+        message = theMessage;
+        keepCallback = [NSNumber numberWithBool:NO];
+    }
+    return self;
 }
 
--(CDVPluginResult*) initWithStatus:(CDVCommandStatus)statusOrdinal message: (id) theMessage {
-	self = [super init];
-	if(self) {
-		status = [NSNumber numberWithInt: statusOrdinal];
-		message = theMessage;
-		keepCallback = [NSNumber numberWithBool: NO];
-	}
-	return self;
-}		
-	
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: [org_apache_cordova_CommandStatusMsgs objectAtIndex: statusOrdinal]];
+    return [[self alloc] initWithStatus:statusOrdinal message:[org_apache_cordova_CommandStatusMsgs objectAtIndex:statusOrdinal]];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsString: (NSString*) theMessage
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsString:(NSString*)theMessage
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: theMessage];
+    return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsArray: (NSArray*) theMessage
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsArray:(NSArray*)theMessage
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: theMessage];
+    return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsInt: (int) theMessage
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsInt:(int)theMessage
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithInt: theMessage]];
+    return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithInt:theMessage]];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDouble: (double) theMessage
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDouble:(double)theMessage
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: [NSNumber numberWithDouble: theMessage]];
+    return [[self alloc] initWithStatus:statusOrdinal message:[NSNumber numberWithDouble:theMessage]];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageAsDictionary: (NSDictionary*) theMessage
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageAsDictionary:(NSDictionary*)theMessage
 {
-	return [[self alloc] initWithStatus: statusOrdinal message: theMessage];
+    return [[self alloc] initWithStatus:statusOrdinal message:theMessage];
 }
 
-+(CDVPluginResult*) resultWithStatus: (CDVCommandStatus) statusOrdinal messageToErrorObject: (int) errorCode 
++ (CDVPluginResult*)resultWithStatus:(CDVCommandStatus)statusOrdinal messageToErrorObject:(int)errorCode
 {
     NSDictionary* errDict = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:errorCode] forKey:@"code"];
-	return [[self alloc] initWithStatus: statusOrdinal message: errDict];
+
+    return [[self alloc] initWithStatus:statusOrdinal message:errDict];
 }
 
--(void) setKeepCallbackAsBool:(BOOL)bKeepCallback
+- (void)setKeepCallbackAsBool:(BOOL)bKeepCallback
 {
-	[self setKeepCallback: [NSNumber numberWithBool:bKeepCallback]];
+    [self setKeepCallback:[NSNumber numberWithBool:bKeepCallback]];
 }
 
--(NSString*) toJSONString{
+- (NSString*)toJSONString
+{
     NSString* resultString = [[NSDictionary dictionaryWithObjectsAndKeys:
-                               self.status, @"status",
-                               self.message ? self.message : [NSNull null], @"message",
-                               self.keepCallback, @"keepCallback",
-                               nil] cdvjk_JSONString];
-    
+            self.status, @"status",
+            self.message ? self.                                 message:[NSNull null], @"message",
+            self.keepCallback, @"keepCallback",
+            nil] cdvjk_JSONString];
+
     if ([[self class] isVerbose]) {
         NSLog(@"PluginResult:toJSONString - %@", resultString);
     }
-	return resultString;
+    return resultString;
 }
 
--(NSString*) toSuccessCallbackString: (NSString*) callbackId
+- (NSString*)toSuccessCallbackString:(NSString*)callbackId
 {
-	NSString* successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId, [self toJSONString]];			
-	
+    NSString* successCB = [NSString stringWithFormat:@"cordova.callbackSuccess('%@',%@);", callbackId, [self toJSONString]];
+
     if ([[self class] isVerbose]) {
         NSLog(@"PluginResult toSuccessCallbackString: %@", successCB);
     }
-	return successCB;
+    return successCB;
 }
 
--(NSString*) toErrorCallbackString: (NSString*) callbackId
+- (NSString*)toErrorCallbackString:(NSString*)callbackId
 {
-	NSString* errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self toJSONString]];
-	
+    NSString* errorCB = [NSString stringWithFormat:@"cordova.callbackError('%@',%@);", callbackId, [self toJSONString]];
+
     if ([[self class] isVerbose]) {
         NSLog(@"PluginResult toErrorCallbackString: %@", errorCB);
     }
-	return errorCB;
+    return errorCB;
 }
 
 static BOOL gIsVerbose = NO;
-+(void) setVerbose:(BOOL)verbose
++ (void)setVerbose:(BOOL)verbose
 {
     gIsVerbose = verbose;
 }
 
-+(BOOL) isVerbose
++ (BOOL)isVerbose
 {
     return gIsVerbose;
 }
 
-
 @end

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVReachability.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.h b/CordovaLib/Classes/CDVReachability.h
index b00fb95..5d5f22f 100644
--- a/CordovaLib/Classes/CDVReachability.h
+++ b/CordovaLib/Classes/CDVReachability.h
@@ -1,16 +1,16 @@
 /*
- 
+
  File: Reachability.h
  Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
- 
+
  Version: 2.2
- 
+
  Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Inc.
  ("Apple") in consideration of your agreement to the following terms, and your
  use, installation, modification or redistribution of this Apple software
  constitutes acceptance of these terms.  If you do not agree with these terms,
  please do not use, install, modify or redistribute this Apple software.
- 
+
  In consideration of your agreement to abide by the following terms, and subject
  to these terms, Apple grants you a personal, non-exclusive license, under
  Apple's copyrights in this original Apple software (the "Apple Software"), to
@@ -26,13 +26,13 @@
  including but not limited to any patent rights that may be infringed by your
  derivative works or by other works in which the Apple Software may be
  incorporated.
- 
+
  The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  COMBINATION WITH YOUR PRODUCTS.
- 
+
  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -40,50 +40,47 @@
  DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
  CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
  APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- 
+
  Copyright (C) 2010 Apple Inc. All Rights Reserved.
- 
-*/
 
+*/
 
 #import <Foundation/Foundation.h>
 #import <SystemConfiguration/SystemConfiguration.h>
 #import <netinet/in.h>
 
 typedef enum {
-	NotReachable = 0,
-	ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
-	ReachableViaWiFi  // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
+    NotReachable = 0,
+    ReachableViaWWAN, // this value has been swapped with ReachableViaWiFi for Cordova backwards compat. reasons
+    ReachableViaWiFi  // this value has been swapped with ReachableViaWWAN for Cordova backwards compat. reasons
 } NetworkStatus;
 #define kReachabilityChangedNotification @"kNetworkReachabilityChangedNotification"
 
-@interface CDVReachability: NSObject
+@interface CDVReachability : NSObject
 {
-	BOOL localWiFiRef;
-	SCNetworkReachabilityRef reachabilityRef;
+    BOOL localWiFiRef;
+    SCNetworkReachabilityRef reachabilityRef;
 }
 
-//reachabilityWithHostName- Use to check the reachability of a particular host name. 
-+ (CDVReachability*) reachabilityWithHostName: (NSString*) hostName;
+// reachabilityWithHostName- Use to check the reachability of a particular host name.
++ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
 
-//reachabilityWithAddress- Use to check the reachability of a particular IP address. 
-+ (CDVReachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
+// reachabilityWithAddress- Use to check the reachability of a particular IP address.
++ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
 
-//reachabilityForInternetConnection- checks whether the default route is available.  
+// reachabilityForInternetConnection- checks whether the default route is available.
 //  Should be used by applications that do not connect to a particular host
-+ (CDVReachability*) reachabilityForInternetConnection;
++ (CDVReachability*)reachabilityForInternetConnection;
 
-//reachabilityForLocalWiFi- checks whether a local wifi connection is available.
-+ (CDVReachability*) reachabilityForLocalWiFi;
+// reachabilityForLocalWiFi- checks whether a local wifi connection is available.
++ (CDVReachability*)reachabilityForLocalWiFi;
 
-//Start listening for reachability notifications on the current run loop
-- (BOOL) startNotifier;
-- (void) stopNotifier;
+// Start listening for reachability notifications on the current run loop
+- (BOOL)startNotifier;
+- (void)stopNotifier;
 
-- (NetworkStatus) currentReachabilityStatus;
-//WWAN may be available, but not active until a connection has been established.
-//WiFi may require a connection for VPN on Demand.
-- (BOOL) connectionRequired;
+- (NetworkStatus)currentReachabilityStatus;
+// WWAN may be available, but not active until a connection has been established.
+// WiFi may require a connection for VPN on Demand.
+- (BOOL)connectionRequired;
 @end
-
-

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/ecf289cc/CordovaLib/Classes/CDVReachability.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVReachability.m b/CordovaLib/Classes/CDVReachability.m
index ccd6e23..ec05595 100644
--- a/CordovaLib/Classes/CDVReachability.m
+++ b/CordovaLib/Classes/CDVReachability.m
@@ -1,16 +1,16 @@
 /*
- 
+
  File: Reachability.m
  Abstract: Basic demonstration of how to use the SystemConfiguration Reachablity APIs.
- 
+
  Version: 2.2
- 
+
  Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple Inc.
  ("Apple") in consideration of your agreement to the following terms, and your
  use, installation, modification or redistribution of this Apple software
  constitutes acceptance of these terms.  If you do not agree with these terms,
  please do not use, install, modify or redistribute this Apple software.
- 
+
  In consideration of your agreement to abide by the following terms, and subject
  to these terms, Apple grants you a personal, non-exclusive license, under
  Apple's copyrights in this original Apple software (the "Apple Software"), to
@@ -26,13 +26,13 @@
  including but not limited to any patent rights that may be infringed by your
  derivative works or by other works in which the Apple Software may be
  incorporated.
- 
+
  The Apple Software is provided by Apple on an "AS IS" basis.  APPLE MAKES NO
  WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
  WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
  COMBINATION WITH YOUR PRODUCTS.
- 
+
  IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
@@ -40,9 +40,9 @@
  DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF
  CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
  APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- 
+
  Copyright (C) 2010 Apple Inc. All Rights Reserved.
- 
+
 */
 
 #import <sys/socket.h>
@@ -58,225 +58,204 @@
 
 #define kShouldPrintReachabilityFlags 0
 
-static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags    flags, const char* comment)
+static void CDVPrintReachabilityFlags(SCNetworkReachabilityFlags flags, const char* comment)
 {
 #if kShouldPrintReachabilityFlags
-	
-    NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
-			(flags & kSCNetworkReachabilityFlagsIsWWAN)				  ? 'W' : '-',
-			(flags & kSCNetworkReachabilityFlagsReachable)            ? 'R' : '-',
-			
-			(flags & kSCNetworkReachabilityFlagsTransientConnection)  ? 't' : '-',
-			(flags & kSCNetworkReachabilityFlagsConnectionRequired)   ? 'c' : '-',
-			(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic)  ? 'C' : '-',
-			(flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
-			(flags & kSCNetworkReachabilityFlagsConnectionOnDemand)   ? 'D' : '-',
-			(flags & kSCNetworkReachabilityFlagsIsLocalAddress)       ? 'l' : '-',
-			(flags & kSCNetworkReachabilityFlagsIsDirect)             ? 'd' : '-',
-			comment
-			);
+        NSLog(@"Reachability Flag Status: %c%c %c%c%c%c%c%c%c %s\n",
+        (flags & kSCNetworkReachabilityFlagsIsWWAN)               ? 'W' : '-',
+        (flags & kSCNetworkReachabilityFlagsReachable)            ? 'R' : '-',
+
+        (flags & kSCNetworkReachabilityFlagsTransientConnection)  ? 't' : '-',
+        (flags & kSCNetworkReachabilityFlagsConnectionRequired)   ? 'c' : '-',
+        (flags & kSCNetworkReachabilityFlagsConnectionOnTraffic)  ? 'C' : '-',
+        (flags & kSCNetworkReachabilityFlagsInterventionRequired) ? 'i' : '-',
+        (flags & kSCNetworkReachabilityFlagsConnectionOnDemand)   ? 'D' : '-',
+        (flags & kSCNetworkReachabilityFlagsIsLocalAddress)       ? 'l' : '-',
+        (flags & kSCNetworkReachabilityFlagsIsDirect)             ? 'd' : '-',
+        comment
+        );
 #endif
 }
 
-
 @implementation CDVReachability
 
 static void CDVReachabilityCallback(SCNetworkReachabilityRef target, SCNetworkReachabilityFlags flags, void* info)
 {
-	#pragma unused (target, flags)
-//	NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
-//	NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
-    
+#pragma unused (target, flags)
+    //	NSCAssert(info != NULL, @"info was NULL in ReachabilityCallback");
+    //	NSCAssert([(NSObject*) info isKindOfClass: [Reachability class]], @"info was wrong class in ReachabilityCallback");
+
     // Converted the asserts above to conditionals, with safe return from the function
     if (info == NULL) {
         NSLog(@"info was NULL in ReachabilityCallback");
         return;
     }
-    
-    if (![(__bridge NSObject*) info isKindOfClass: [CDVReachability class]]) {
+
+    if (![(__bridge NSObject*) info isKindOfClass:[CDVReachability class]]) {
         NSLog(@"info was wrong class in ReachabilityCallback");
         return;
     }
 
-	//We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
-	// in case someon uses the Reachablity object in a different thread.
-	@autoreleasepool {
-        CDVReachability* noteObject = (__bridge CDVReachability*) info;
+    // We're on the main RunLoop, so an NSAutoreleasePool is not necessary, but is added defensively
+    // in case someon uses the Reachablity object in a different thread.
+    @autoreleasepool {
+        CDVReachability* noteObject = (__bridge CDVReachability*)info;
         // Post a notification to notify the client that the network reachability changed.
-        [[NSNotificationCenter defaultCenter] postNotificationName: kReachabilityChangedNotification object: noteObject];
-	}
+        [[NSNotificationCenter defaultCenter] postNotificationName:kReachabilityChangedNotification object:noteObject];
+    }
 }
 
-- (BOOL) startNotifier
+- (BOOL)startNotifier
 {
-	BOOL retVal = NO;
-	SCNetworkReachabilityContext	context = {0, (__bridge void *)(self), NULL, NULL, NULL};
-	if(SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context))
-	{
-		if(SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode))
-		{
-			retVal = YES;
-		}
-	}
-	return retVal;
+    BOOL retVal = NO;
+    SCNetworkReachabilityContext context = {0, (__bridge void*)(self), NULL, NULL, NULL};
+
+    if (SCNetworkReachabilitySetCallback(reachabilityRef, CDVReachabilityCallback, &context)) {
+        if (SCNetworkReachabilityScheduleWithRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode)) {
+            retVal = YES;
+        }
+    }
+    return retVal;
 }
 
-- (void) stopNotifier
+- (void)stopNotifier
 {
-	if(reachabilityRef!= NULL)
-	{
-		SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
-	}
+    if (reachabilityRef != NULL) {
+        SCNetworkReachabilityUnscheduleFromRunLoop(reachabilityRef, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
+    }
 }
 
-- (void) dealloc
+- (void)dealloc
 {
-	[self stopNotifier];
-	if(reachabilityRef!= NULL)
-	{
-		CFRelease(reachabilityRef);
-	}
+    [self stopNotifier];
+    if (reachabilityRef != NULL) {
+        CFRelease(reachabilityRef);
+    }
 }
 
-+ (CDVReachability*) reachabilityWithHostName: (NSString*) hostName;
++ (CDVReachability*)reachabilityWithHostName:(NSString*)hostName;
 {
-	CDVReachability* retVal = NULL;
-	SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
-	if(reachability!= NULL)
-	{
-		retVal= [[self alloc] init];
-		if(retVal!= NULL)
-		{
-			retVal->reachabilityRef = reachability;
-			retVal->localWiFiRef = NO;
-		}
-	}
-	return retVal;
+    CDVReachability* retVal = NULL;
+    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(NULL, [hostName UTF8String]);
+    if (reachability != NULL) {
+        retVal = [[self alloc] init];
+        if (retVal != NULL) {
+            retVal->reachabilityRef = reachability;
+            retVal->localWiFiRef = NO;
+        }
+    }
+    return retVal;
 }
 
-+ (CDVReachability*) reachabilityWithAddress: (const struct sockaddr_in*) hostAddress;
++ (CDVReachability*)reachabilityWithAddress:(const struct sockaddr_in*)hostAddress;
 {
-	SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
-	CDVReachability* retVal = NULL;
-	if(reachability!= NULL)
-	{
-		retVal= [[self alloc] init];
-		if(retVal!= NULL)
-		{
-			retVal->reachabilityRef = reachability;
-			retVal->localWiFiRef = NO;
-		}
-	}
-	return retVal;
+    SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr*)hostAddress);
+    CDVReachability* retVal = NULL;
+    if (reachability != NULL) {
+        retVal = [[self alloc] init];
+        if (retVal != NULL) {
+            retVal->reachabilityRef = reachability;
+            retVal->localWiFiRef = NO;
+        }
+    }
+    return retVal;
 }
 
-+ (CDVReachability*) reachabilityForInternetConnection;
++ (CDVReachability*)reachabilityForInternetConnection;
 {
-	struct sockaddr_in zeroAddress;
-	bzero(&zeroAddress, sizeof(zeroAddress));
-	zeroAddress.sin_len = sizeof(zeroAddress);
-	zeroAddress.sin_family = AF_INET;
-	return [self reachabilityWithAddress: &zeroAddress];
+    struct sockaddr_in zeroAddress;
+    bzero(&zeroAddress, sizeof(zeroAddress));
+    zeroAddress.sin_len = sizeof(zeroAddress);
+    zeroAddress.sin_family = AF_INET;
+    return [self reachabilityWithAddress:&zeroAddress];
 }
 
-+ (CDVReachability*) reachabilityForLocalWiFi;
++ (CDVReachability*)reachabilityForLocalWiFi;
 {
-	struct sockaddr_in localWifiAddress;
-	bzero(&localWifiAddress, sizeof(localWifiAddress));
-	localWifiAddress.sin_len = sizeof(localWifiAddress);
-	localWifiAddress.sin_family = AF_INET;
-	// IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
-	localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
-	CDVReachability* retVal = [self reachabilityWithAddress: &localWifiAddress];
-	if(retVal!= NULL)
-	{
-		retVal->localWiFiRef = YES;
-	}
-	return retVal;
+    struct sockaddr_in localWifiAddress;
+    bzero(&localWifiAddress, sizeof(localWifiAddress));
+    localWifiAddress.sin_len = sizeof(localWifiAddress);
+    localWifiAddress.sin_family = AF_INET;
+    // IN_LINKLOCALNETNUM is defined in <netinet/in.h> as 169.254.0.0
+    localWifiAddress.sin_addr.s_addr = htonl(IN_LINKLOCALNETNUM);
+    CDVReachability* retVal = [self reachabilityWithAddress:&localWifiAddress];
+    if (retVal != NULL) {
+        retVal->localWiFiRef = YES;
+    }
+    return retVal;
 }
 
 #pragma mark Network Flag Handling
 
-- (NetworkStatus) localWiFiStatusForFlags: (SCNetworkReachabilityFlags) flags
+- (NetworkStatus)localWiFiStatusForFlags:(SCNetworkReachabilityFlags)flags
 {
-	CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags");
-
-	BOOL retVal = NotReachable;
-	if((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect))
-	{
-		retVal = ReachableViaWiFi;	
-	}
-	return retVal;
+    CDVPrintReachabilityFlags(flags, "localWiFiStatusForFlags");
+
+    BOOL retVal = NotReachable;
+    if ((flags & kSCNetworkReachabilityFlagsReachable) && (flags & kSCNetworkReachabilityFlagsIsDirect)) {
+        retVal = ReachableViaWiFi;
+    }
+    return retVal;
 }
 
-- (NetworkStatus) networkStatusForFlags: (SCNetworkReachabilityFlags) flags
+- (NetworkStatus)networkStatusForFlags:(SCNetworkReachabilityFlags)flags
 {
-	CDVPrintReachabilityFlags(flags, "networkStatusForFlags");
-	if ((flags & kSCNetworkReachabilityFlagsReachable) == 0)
-	{
-		// if target host is not reachable
-		return NotReachable;
-	}
-
-	BOOL retVal = NotReachable;
-	
-	if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0)
-	{
-		// if target host is reachable and no connection is required
-		//  then we'll assume (for now) that your on Wi-Fi
-		retVal = ReachableViaWiFi;
-	}
-	
-	
-	if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) ||
-		(flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))
-	{
-			// ... and the connection is on-demand (or on-traffic) if the
-			//     calling application is using the CFSocketStream or higher APIs
-
-			if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0)
-			{
-				// ... and no [user] intervention is needed
-				retVal = ReachableViaWiFi;
-			}
-		}
-	
-	if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN)
-	{
-		// ... but WWAN connections are OK if the calling application
-		//     is using the CFNetwork (CFSocketStream?) APIs.
-		retVal = ReachableViaWWAN;
-	}
-	return retVal;
+    CDVPrintReachabilityFlags(flags, "networkStatusForFlags");
+    if ((flags & kSCNetworkReachabilityFlagsReachable) == 0) {
+        // if target host is not reachable
+        return NotReachable;
+    }
+
+    BOOL retVal = NotReachable;
+
+    if ((flags & kSCNetworkReachabilityFlagsConnectionRequired) == 0) {
+        // if target host is reachable and no connection is required
+        //  then we'll assume (for now) that your on Wi-Fi
+        retVal = ReachableViaWiFi;
+    }
+
+    if ((((flags & kSCNetworkReachabilityFlagsConnectionOnDemand) != 0) ||
+            ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0))) {
+        // ... and the connection is on-demand (or on-traffic) if the
+        //     calling application is using the CFSocketStream or higher APIs
+
+        if ((flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0) {
+            // ... and no [user] intervention is needed
+            retVal = ReachableViaWiFi;
+        }
+    }
+
+    if ((flags & kSCNetworkReachabilityFlagsIsWWAN) == kSCNetworkReachabilityFlagsIsWWAN) {
+        // ... but WWAN connections are OK if the calling application
+        //     is using the CFNetwork (CFSocketStream?) APIs.
+        retVal = ReachableViaWWAN;
+    }
+    return retVal;
 }
 
-- (BOOL) connectionRequired;
+- (BOOL)connectionRequired;
 {
-	NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
-	SCNetworkReachabilityFlags flags;
-	if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
-	{
-		return (flags & kSCNetworkReachabilityFlagsConnectionRequired);
-	}
-	return NO;
+    NSAssert(reachabilityRef != NULL, @"connectionRequired called with NULL reachabilityRef");
+    SCNetworkReachabilityFlags flags;
+    if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
+        return flags & kSCNetworkReachabilityFlagsConnectionRequired;
+    }
+    return NO;
 }
 
-- (NetworkStatus) currentReachabilityStatus
+- (NetworkStatus)currentReachabilityStatus
 {
-	NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
-	NetworkStatus retVal = NotReachable;
-	SCNetworkReachabilityFlags flags;
-	if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags))
-	{
-		if(localWiFiRef)
-		{
-			retVal = [self localWiFiStatusForFlags: flags];
-		}
-		else
-		{
-			retVal = [self networkStatusForFlags: flags];
-		}
-	}
-	return retVal;
+    NSAssert(reachabilityRef != NULL, @"currentNetworkStatus called with NULL reachabilityRef");
+    NetworkStatus retVal = NotReachable;
+    SCNetworkReachabilityFlags flags;
+    if (SCNetworkReachabilityGetFlags(reachabilityRef, &flags)) {
+        if (localWiFiRef) {
+            retVal = [self localWiFiStatusForFlags:flags];
+        } else {
+            retVal = [self networkStatusForFlags:flags];
+        }
+    }
+    return retVal;
 }
+
 @end


Mime
View raw message