Update CDVLocation to new exec format.

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

Branch: refs/heads/master
Commit: 8e97f5001e2a16733357679d5bcfe98bbf379b3a
Parents: 8da8fbc
Author: Andrew Grieve <agri...@chromium.org>
Authored: Fri Aug 3 11:05:51 2012 -0400
Committer: Andrew Grieve <agri...@chromium.org>
Committed: Fri Aug 3 11:16:59 2012 -0400

----------------------------------------------------------------------
 CordovaLib/Classes/CDVLocation.h       |   13 ++++-----
 CordovaLib/Classes/CDVLocation.m       |   40 ++++++++++++++-------------
 CordovaLib/Classes/CDVViewController.m |    2 +-
 3 files changed, 28 insertions(+), 27 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/8e97f500/CordovaLib/Classes/CDVLocation.h
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.h b/CordovaLib/Classes/CDVLocation.h
index d820c9c..292b161 100755
--- a/CordovaLib/Classes/CDVLocation.h
+++ b/CordovaLib/Classes/CDVLocation.h
@@ -78,9 +78,9 @@ typedef NSUInteger CDVLocationStatus;
 
 
 - (BOOL) hasHeadingSupport;
-- (void) getLocation:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options;
-- (void) addWatch:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options;
-- (void) clearWatch:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options;
+- (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;
@@ -94,11 +94,10 @@ typedef NSUInteger CDVLocationStatus;
 
 - (BOOL) isLocationServicesEnabled;
 
-- (void)getHeading:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options;
+- (void)getHeading:(CDVInvokedUrlCommand*)command;
 - (void)returnHeadingInfo: (NSString*) callbackId keepCallback: (BOOL) bRetain;
-- (void)watchHeadingFilter:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options;
-- (void)stopHeading:(NSMutableArray*)arguments
-                  withDict:(NSMutableDictionary*)options;
+- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command;
+- (void)stopHeading:(CDVInvokedUrlCommand*)command;
 - (void) startHeadingWithFilter: (CLLocationDegrees) filter;
 - (void)locationManager:(CLLocationManager *)manager
           didUpdateHeading:(CLHeading *)heading;

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/8e97f500/CordovaLib/Classes/CDVLocation.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVLocation.m b/CordovaLib/Classes/CDVLocation.m
index 87103a7..58e105b 100755
--- a/CordovaLib/Classes/CDVLocation.m
+++ b/CordovaLib/Classes/CDVLocation.m
@@ -20,6 +20,7 @@
 
 #import "CDVLocation.h"
 #import "CDVViewController.h"
+#import "NSArray+Comparisons.h"
 
 #pragma mark Constants
 
@@ -241,11 +242,11 @@
     }
 }
 
-- (void) getLocation:(NSMutableArray *)arguments withDict:(NSMutableDictionary 
*)options
+- (void) getLocation:(CDVInvokedUrlCommand*)command
 {
-    NSUInteger argc = [arguments count];
-    NSString* callbackId = (argc > 0)? [arguments objectAtIndex:0] : 
@"INVALID";
-    BOOL enableHighAccuracy = [[arguments objectAtIndex:1] boolValue];
+
+    NSString* callbackId = command.callbackId;
+    BOOL enableHighAccuracy = [[command.arguments objectAtIndex:0] boolValue];
 
     if ([self isLocationServicesEnabled] == NO)
     {
@@ -274,11 +275,11 @@
         }
     }
 }
-- (void) addWatch:(NSMutableArray *)arguments withDict:(NSMutableDictionary 
*)options
+- (void) addWatch:(CDVInvokedUrlCommand*)command
 {
-    NSString* callbackId = [arguments objectAtIndex:0];
-    NSString* timerId = [arguments objectAtIndex:1];
-    BOOL enableHighAccuracy = [[arguments objectAtIndex:2] boolValue];
+    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];
@@ -306,16 +307,15 @@
         }
     }
 }
-- (void) clearWatch:(NSMutableArray *)arguments withDict:(NSMutableDictionary 
*)options
+- (void) clearWatch:(CDVInvokedUrlCommand*)command
 {
-    //NSString* callbackId = [arguments objectAtIndex:0];
-    NSString* timerId = [arguments objectAtIndex:1];
+    NSString* timerId = [command.arguments objectAtIndex:0];
     if (self.locationData && self.locationData.watchCallbacks && 
[self.locationData.watchCallbacks objectForKey:timerId]) {
         [self.locationData.watchCallbacks removeObjectForKey:timerId];
     }
 }
 
-- (void) stopLocation:(NSMutableArray *)arguments 
withDict:(NSMutableDictionary *)options
+- (void) stopLocation:(CDVInvokedUrlCommand*)command
 {
     [self _stopLocation];
 }
@@ -369,12 +369,13 @@
 // called to get the current heading
 // Will call location manager to startUpdatingHeading if necessary
 
-- (void)getHeading:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options
+- (void)getHeading:(CDVInvokedUrlCommand*)command
 {
-    NSString* callbackId = [arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+    NSDictionary* options = [command.arguments objectAtIndex:0 
withDefault:nil];
     NSNumber* filter = [options valueForKey:@"filter"];
     if (filter) {
-        [self watchHeadingFilter: arguments withDict: options];
+        [self watchHeadingFilter:command];
         return;
     }
     if ([self hasHeadingSupport] == NO) 
@@ -406,9 +407,10 @@
     
 } 
 // called to request heading updates when heading changes by a certain amount 
(filter)
-- (void)watchHeadingFilter:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options
+- (void)watchHeadingFilter:(CDVInvokedUrlCommand*)command
 {
-    NSString* callbackId = [arguments objectAtIndex:0];
+    NSString* callbackId = command.callbackId;
+    NSDictionary* options = [command.arguments objectAtIndex:0 
withDefault:nil];
     NSNumber* filter = [options valueForKey:@"filter"];
     CDVHeadingData* hData = self.headingData;
     if ([self hasHeadingSupport] == NO) {
@@ -472,7 +474,7 @@
     
 }
 
-- (void) stopHeading:(NSMutableArray*)arguments 
withDict:(NSMutableDictionary*)options
+- (void) stopHeading:(CDVInvokedUrlCommand*)command
 {
     //CDVHeadingData* hData = self.headingData;
     if (self.headingData && self.headingData.headingStatus != HEADINGSTOPPED)
@@ -544,7 +546,7 @@
     if (hData.headingFilter) {
         [self returnHeadingInfo: hData.headingFilter keepCallback:YES];
     } else if (bTimeout) {
-        [self stopHeading:nil withDict:nil];
+        [self stopHeading:nil];
     }
     hData.headingStatus = HEADINGRUNNING;  // to clear any error
     

http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/8e97f500/CordovaLib/Classes/CDVViewController.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVViewController.m 
b/CordovaLib/Classes/CDVViewController.m
index dc98cd7..ecdb65f 100644
--- a/CordovaLib/Classes/CDVViewController.m
+++ b/CordovaLib/Classes/CDVViewController.m
@@ -215,7 +215,7 @@
      */
     
     if ([enableLocation boolValue]) {
-        [[self.commandDelegate getCommandInstance:@"Geolocation"] 
getLocation:nil withDict:nil];
+        [[self.commandDelegate getCommandInstance:@"Geolocation"] 
getLocation:nil];
     }
     
     /*

Reply via email to