diff --git a/Classes/BuschJaegerConfiguration.m b/Classes/BuschJaegerConfiguration.m index fba971e52..56bb97463 100644 --- a/Classes/BuschJaegerConfiguration.m +++ b/Classes/BuschJaegerConfiguration.m @@ -106,7 +106,6 @@ static NSString *const CONFIGURATION_HOME_AP_KEY = @"CONFIGURATION_HOME_AP_KEY"; certificate = NULL; valid = FALSE; [self reloadCertificates]; - homeAP = [[[NSUserDefaults standardUserDefaults] dataForKey:CONFIGURATION_HOME_AP_KEY] retain]; } return self; } @@ -361,6 +360,7 @@ static NSString *const CONFIGURATION_HOME_AP_KEY = @"CONFIGURATION_HOME_AP_KEY"; - (BOOL)loadFile:(NSString*)file { [self reset]; + homeAP = [[[NSUserDefaults standardUserDefaults] dataForKey:CONFIGURATION_HOME_AP_KEY] retain]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSString *databaseDocumentPath = [LinphoneManager documentFile:file]; @@ -406,7 +406,6 @@ static NSString *const CONFIGURATION_HOME_AP_KEY = @"CONFIGURATION_HOME_AP_KEY"; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"username_preference"]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"domain_preference"]; [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"password_preference"]; - [[NSUserDefaults standardUserDefaults] removeObjectForKey:CONFIGURATION_HOME_AP_KEY]; [LinphoneLogger log:LinphoneLoggerDebug format:@"Download ok"]; if([self parseConfig:[NSString stringWithUTF8String:[data bytes]] delegate:delegate]) { valid = TRUE; @@ -480,11 +479,7 @@ static NSString *const CONFIGURATION_HOME_AP_KEY = @"CONFIGURATION_HOME_AP_KEY"; NSError *error = nil; NSData *data = nil; data = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error delegate:self]; - if(data == nil) { - dispatch_async(dispatch_get_main_queue(), ^{ - [delegate buschJaegerConfigurationError:[error localizedDescription]]; - }); - } else { + if(data != nil) { NSHTTPURLResponse *urlResponse = (NSHTTPURLResponse*) response; if(urlResponse.statusCode == 200) { NSString *dataString = [[NSString alloc] initWithBytes:[data bytes] length:[data length] encoding: NSUTF8StringEncoding]; @@ -594,6 +589,7 @@ static NSString *const CONFIGURATION_HOME_AP_KEY = @"CONFIGURATION_HOME_AP_KEY"; - (BOOL)removeHistory:(History*)ahistory delegate:(id)delegate { + [history removeObject:ahistory]; NSString *url = [NSString stringWithFormat:@"%@/cgi-bin/adduser.cgi?type=delhistory&id=%d", [self getGateway], ahistory.ID]; NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:5]; if(request != nil) { diff --git a/Classes/BuschJaegerHistoryTableViewController.m b/Classes/BuschJaegerHistoryTableViewController.m index 6818cb217..c9c31618b 100644 --- a/Classes/BuschJaegerHistoryTableViewController.m +++ b/Classes/BuschJaegerHistoryTableViewController.m @@ -108,6 +108,7 @@ #pragma mark - BuschJaegerConfigurationDelegate Functions - (void)buschJaegerConfigurationSuccess { + } - (void)buschJaegerConfigurationError:(NSString *)error { diff --git a/Classes/BuschJaegerMainView.m b/Classes/BuschJaegerMainView.m index 23c9011c1..f3b459f66 100644 --- a/Classes/BuschJaegerMainView.m +++ b/Classes/BuschJaegerMainView.m @@ -301,7 +301,13 @@ static BuschJaegerMainView* mainViewInstance=nil; 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 } - [self updateIconBadge:nil]; + LinphoneCallLog *log = linphone_call_get_call_log(call); + if(log != NULL && log->status == LinphoneCallMissed) { + // We can't use the comparison method, we can be in background mode and the application + // will no send/update the http request + int missed = [[UIApplication sharedApplication] applicationIconBadgeNumber]; + [[UIApplication sharedApplication] setApplicationIconBadgeNumber:++missed]; + } break; } default: diff --git a/Classes/BuschJaegerWelcomeView.m b/Classes/BuschJaegerWelcomeView.m index e0490cb4d..97d5eee9b 100644 --- a/Classes/BuschJaegerWelcomeView.m +++ b/Classes/BuschJaegerWelcomeView.m @@ -67,12 +67,21 @@ name:kLinphoneConfigurationUpdate object:nil]; [self updateConfiguration:[LinphoneManager instance].configuration]; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(applicationWillEnterForeground:) + name:UIApplicationWillEnterForegroundNotification + object:nil]; + [self performSelector:@selector(reloadHistory) withObject:self afterDelay:1.0]; [self reloadHistory]; } - (void)viewWillDisappear:(BOOL)animated{ [super viewWillDisappear:animated]; + [[NSNotificationCenter defaultCenter] removeObserver:self + name:UIApplicationWillEnterForegroundNotification + object:nil]; + // Remove observer [[NSNotificationCenter defaultCenter] removeObserver:self name:kLinphoneConfigurationUpdate @@ -98,6 +107,10 @@ #pragma mark - Event Functions +- (void)applicationWillEnterForeground:(NSNotification*)notif { + [self reloadHistory]; +} + - (void)configurationUpdateEvent: (NSNotification*) notif { BuschJaegerConfiguration *configuration = [notif.userInfo objectForKey:@"configuration"]; [self updateConfiguration:configuration];