From 8d5a5f8f771f1e14f240e834e6d6d387b50fcc7d Mon Sep 17 00:00:00 2001 From: Yann Diorcet Date: Tue, 29 Jan 2013 16:41:11 +0100 Subject: [PATCH] Fix station cell remove history update in background mode --- Classes/BuschJaegerMainView.m | 73 +++++++++++++++++++++++-- Classes/BuschJaegerUtils.m | 2 +- Classes/LinphoneUI/UIHistoryCell.xib | 2 +- Classes/LinphoneUI/UIStationCell.m | 1 + Classes/LinphoneUI/UIStationCell.xib | 1 - Resources/en.lproj/Localizable.strings | Bin 5708 -> 5846 bytes 6 files changed, 70 insertions(+), 9 deletions(-) diff --git a/Classes/BuschJaegerMainView.m b/Classes/BuschJaegerMainView.m index 557ece5da..4e0ffc290 100644 --- a/Classes/BuschJaegerMainView.m +++ b/Classes/BuschJaegerMainView.m @@ -90,14 +90,21 @@ static BuschJaegerMainView* mainViewInstance=nil; assert (!mainViewInstance); mainViewInstance = self; loadCount = 0; - historyTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 - target: self - selector: @selector(updateIconBadge:) - userInfo: nil - repeats: YES]; + historyTimer = nil; historyQueue = [[NSOperationQueue alloc] init]; historyQueue.name = @"History queue"; historyQueue.maxConcurrentOperationCount = 1; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationWillEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationWillEnterBackground:) + name:UIApplicationDidEnterBackgroundNotification + object:nil]; + [self applicationWillEnterForeground:nil]; } - (id)init { @@ -125,6 +132,12 @@ static BuschJaegerMainView* mainViewInstance=nil; } - (void)dealloc { + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIApplicationWillEnterForegroundNotification + object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIApplicationDidEnterBackgroundNotification + object:nil]; [navigationController release]; [callView release]; [settingsView release]; @@ -236,6 +249,24 @@ static BuschJaegerMainView* mainViewInstance=nil; #pragma mark - Event Functions +- (void)applicationWillEnterForeground:(NSNotification*)notif { + if(historyTimer != nil) { + historyTimer = [NSTimer scheduledTimerWithTimeInterval: 10.0 + target: self + selector: @selector(updateIconBadge:) + userInfo: nil + repeats: YES]; + } + +} + + +- (void)applicationWillEnterBackground:(NSNotification*)notif { + [historyTimer invalidate]; + historyTimer = nil; +} + + - (void)updateIconBadge:(id)info { if([historyQueue operationCount] == 0) { [historyQueue addOperationWithBlock:^(void) { @@ -315,6 +346,35 @@ static BuschJaegerMainView* mainViewInstance=nil; case LinphoneCallError: case LinphoneCallEnd: { + if(linphone_call_get_reason(call) == LinphoneReasonBusy) { + NSString *contactName = NSLocalizedString(@"Unknown", nil); + + // Extract caller address + const LinphoneAddress* addr = linphone_call_get_remote_address(call); + if(addr) { + char *address = linphone_address_as_string_uri_only(addr); + if(address != NULL) { + contactName = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:address]]; + ms_free(address); + } + } + + // Find caller in outdoor stations + NSSet *outstations = [[LinphoneManager instance] configuration].outdoorStations; + for(OutdoorStation *os in outstations) { + if([[FastAddressBook normalizeSipURI:os.address] isEqualToString:contactName]) { + contactName = os.name; + break; + } + } + UIAlertView* error = [[UIAlertView alloc] initWithTitle:@"Welcome" + message: [NSString stringWithFormat:NSLocalizedString(@"%@ is busy",nil), contactName] + delegate:nil + cancelButtonTitle:NSLocalizedString(@"Continue",nil) + otherButtonTitles:nil,nil]; + [error show]; + [error release]; + } [self dismissIncomingCall:call]; if ((linphone_core_get_calls([LinphoneManager getLc]) == NULL)) { [navigationController popToViewController:welcomeView animated:FALSE]; // No animation... Come back when Apple have learned how to create a good framework @@ -353,7 +413,8 @@ static BuschJaegerMainView* mainViewInstance=nil; otherButtonTitles:nil,nil]; [error show]; [error release]; - AudioServicesPlayAlertSound([LinphoneManager instance].sounds.level); + // Not working during a call + // AudioServicesPlayAlertSound([LinphoneManager instance].sounds.level); } } diff --git a/Classes/BuschJaegerUtils.m b/Classes/BuschJaegerUtils.m index cc762340d..74548b9f2 100644 --- a/Classes/BuschJaegerUtils.m +++ b/Classes/BuschJaegerUtils.m @@ -71,7 +71,7 @@ if(layer.delegate == nil) { [layer setFrame:layer.superlayer.bounds]; } else if([layer.delegate isKindOfClass:[UIView class]]) { - [layer setFrame:((UIView *)layer.delegate).bounds]; + [layer setFrame:((UIView *)layer.delegate).frame]; } } if([layer respondsToSelector:@selector(sublayers)]) { diff --git a/Classes/LinphoneUI/UIHistoryCell.xib b/Classes/LinphoneUI/UIHistoryCell.xib index a10593a5f..9fb6bfbba 100644 --- a/Classes/LinphoneUI/UIHistoryCell.xib +++ b/Classes/LinphoneUI/UIHistoryCell.xib @@ -50,7 +50,7 @@ - 292 + 290 {{59, 20}, {130, 21}} diff --git a/Classes/LinphoneUI/UIStationCell.m b/Classes/LinphoneUI/UIStationCell.m index 20e250315..e52d374e8 100644 --- a/Classes/LinphoneUI/UIStationCell.m +++ b/Classes/LinphoneUI/UIStationCell.m @@ -79,6 +79,7 @@ shadow.layer.name = @"BuschJaegerLayer"; shadow.clipsToBounds = NO; shadow.layer.shadowOpacity = 0.9f; + [cellBackgroundView setFrame:[shadow bounds]]; [cellBackgroundView.superview insertSubview:shadow belowSubview:cellBackgroundView]; [shadow addSubview:cellBackgroundView]; } diff --git a/Classes/LinphoneUI/UIStationCell.xib b/Classes/LinphoneUI/UIStationCell.xib index c455943a3..28ec639c1 100644 --- a/Classes/LinphoneUI/UIStationCell.xib +++ b/Classes/LinphoneUI/UIStationCell.xib @@ -56,7 +56,6 @@ {{147, 44}, {27, 36}} - _NS:9 NO IBCocoaTouchFramework diff --git a/Resources/en.lproj/Localizable.strings b/Resources/en.lproj/Localizable.strings index 43899b43f750d6e1a166be433473903483f7d48a..2ef83376b00d9d28c67bd6c6480307374455bc4d 100644 GIT binary patch delta 64 xcmX@3b4_