Fix multiple issues

This commit is contained in:
Yann Diorcet 2013-01-28 15:14:42 +01:00
parent fd58711cdc
commit 5a080ea946
4 changed files with 24 additions and 8 deletions

View file

@ -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<BuschJaegerConfigurationDelegate>)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) {

View file

@ -108,6 +108,7 @@
#pragma mark - BuschJaegerConfigurationDelegate Functions
- (void)buschJaegerConfigurationSuccess {
}
- (void)buschJaegerConfigurationError:(NSString *)error {

View file

@ -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:

View file

@ -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];