Skip to content

Commit

Permalink
Fix database stuff in socket client
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronpk committed Jan 13, 2012
1 parent 8ed0fe8 commit 1739bda
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 27 deletions.
39 changes: 14 additions & 25 deletions Classes/GeoloqiSocketClient.m
Expand Up @@ -115,20 +115,18 @@ - (void)startMonitoringLocation {

// Open the GeoLoqi database => LQDatabase
[LqDatabase openDB:&db];

[LqDatabase createTableNamed: @"LQ_DATA" withField1:@"TIME_STAMP" andField2:@"DATA_PACKET" database:db];

//Network Connectivity check -- dbhan
//[[NSNotificationCenter defaultCenter] addObserver:self // observer
// selector:@selector(handleNetworkChange:) // selector
// name:kReachabilityChangedNotification // notification name
// object:nil]; // sender - not specified
// Init Reachablility class and ask the notifications to start
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];

//[[NSNotificationCenter defaultCenter] postNotificationName:LQTrackingStartedNotification object:self];

// Disabling significant location changes. 12/8/10 -ap
/*
[locationManager startMonitoringSignificantLocationChanges];
if (significantUpdatesOnly) {
DLog(@"Significant updates on.");
[locationManager stopUpdatingLocation];
} else {
DLog(@"Starting location updates");
[locationManager startUpdatingLocation];
}
*/
}

- (void)stopMonitoringLocation {
Expand All @@ -149,8 +147,9 @@ - (void)locationManager:(CLLocationManager *)manager
NSData *raw;
DLog(@"Updated to location %@ from %@", newLocation, oldLocation);

// horizontalAccuracy is negative when the location is invalid, so completely ignore it in this case
if(newLocation.horizontalAccuracy < 0){
// horizontalAccuracy is negative when the location is invalid, so completely ignore it in this case.
// Also ignore bad positions because they aren't useful.
if(newLocation.horizontalAccuracy < 0 || newLocation.horizontalAccuracy > 500){
return;
}

Expand All @@ -174,21 +173,11 @@ - (void)locationManager:(CLLocationManager *)manager
LQUpdatePacket *packet = (LQUpdatePacket *)[data bytes];


[LqDatabase createTableNamed: @"LQ_DATA" withField1:@"TIME_STAMP" andField2:@"DATA_PACKET" database:db];
[LqDatabase insertRecordIntoTableNamed:@"LQ_DATA"
withField1:@"TIME_STAMP"
field1Value:packet->f.date
andField2:@"DATA_PACKET" field2Value:data database:db];

//Network Connectivity check -- dhan
//[[NSNotificationCenter defaultCenter] addObserver:self // observer
// selector:@selector(handleNetworkChange:) // selector
// name:kReachabilityChangedNotification // notification name
// object:nil]; // sender - not specified
// Init Reachablility class and ask the notifications to start
reachability = [Reachability reachabilityForInternetConnection];
[reachability startNotifier];

// What is the current connectivity status?
NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];

Expand Down
4 changes: 3 additions & 1 deletion Classes/MapAttackAppDelegate.m
Expand Up @@ -88,7 +88,9 @@ - (void)authenticationDidSucceed:(NSNotificationCenter *)notification
// name:LQAuthenticationFailedNotification
// object:nil];

geoloqi = [[GeoloqiSocketClient alloc] init];
// geoloqi = [[GeoloqiSocketClient alloc] init]; wtf?


if (tabBarController.modalViewController && [tabBarController.modalViewController isKindOfClass:[authViewController class]])
[tabBarController dismissModalViewControllerAnimated:YES];

Expand Down
13 changes: 12 additions & 1 deletion Classes/MapViewController.m
Expand Up @@ -12,9 +12,13 @@
#import "AuthView.h"
#import "MapAttackAppDelegate.h"


#define MAX_ICON_SIZE 32
#define DEFAULT_ICON_SIZE 72

@implementation MapViewController

@synthesize webView, activityIndicator;
@synthesize webView, activityIndicator; //, mSlider;

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
Expand All @@ -33,6 +37,13 @@ - (void)loadView {
}
*/

//- (void)awakeFromNib {
// [mSlider setMaxValue: MAX_ICON_SIZE];
// [mSlider setDoubleValue: DEFAULT_ICON_SIZE];
//}



- (void)loadURL:(NSString *)url {
// If we don't have authentication tokens here, then pop up the login page to get their email and initials
if(![[LQClient single] isLoggedIn]) {
Expand Down

0 comments on commit 1739bda

Please sign in to comment.