Skip to content

Commit

Permalink
Deactivate CLLocation Manager when in Background
Browse files Browse the repository at this point in the history
  • Loading branch information
plaetzchen committed Feb 2, 2012
1 parent 27ba2fd commit 6addb06
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Hoccer/Crypto/RSA.m
Expand Up @@ -33,7 +33,7 @@ + (RSA*)sharedInstance {
instance = [[RSA alloc] init];
if ([instance getPrivateKeyRef] == nil || [instance getPublicKeyRef] == nil) {
NSLog(@"There are no keys! PANIC!");
//[instance generateKeyPairKeys];
[instance generateKeyPairKeys];
}
});
//[instance getCertificate];
Expand Down
Expand Up @@ -62,6 +62,8 @@
- (BOOL)hasLocation;
- (BOOL)hasBSSID;
- (BOOL)hasEnvironment;
- (void)deactivateLocation;
- (void)activateLocation;
+ (NSError *)messageForLocationInformation: (NSDictionary *)hoccabilityInfo;

@end
Expand Up @@ -146,6 +146,13 @@ - (void)updateHoccability {
}
}

- (void)deactivateLocation{
[locationManager stopUpdatingLocation];
}
- (void)activateLocation{
[locationManager startUpdatingLocation];
}

+ (NSError *)messageForLocationInformation: (NSDictionary *)hoccabilityInfo {
NSInteger hoc = [[hoccabilityInfo objectForKey:@"quality"] intValue];

Expand Down
13 changes: 9 additions & 4 deletions Hoccer/HoccerClient/HCLinccer.m
Expand Up @@ -235,7 +235,8 @@ - (void)storePublicKey:(NSString *)theKey forClient:(NSDictionary *)client clien

- (void)reactivate {
isRegistered = NO;

[environmentController activateLocation];

[self updateEnvironment];
self.groupId = nil;
}
Expand All @@ -251,9 +252,11 @@ - (void)disconnect {
}
[self.updateTimer invalidate];
self.updateTimer = nil;

[environmentController deactivateLocation];
[httpClient deleteURI:[uri stringByAppendingPathComponent:@"/environment"]
success:@selector(httpClientDidDelete:)];


}


Expand Down Expand Up @@ -467,8 +470,10 @@ - (void)updateEnvironment {
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"autoKey"]){
NSData *pubKey = [[RSA sharedInstance] getPublicKeyBits];
NSString *pubKeyAsString = [pubKey asBase64EncodedString];
[environment setObject:pubKeyAsString forKey:@"pubkey"];
}
if (pubKeyAsString){
[environment setObject:pubKeyAsString forKey:@"pubkey"];
}
}

NSString *enviromentAsString = [environment yajl_JSONString];

Expand Down

0 comments on commit 6addb06

Please sign in to comment.