From d3f915740dfd426f3688f509e5167583a4bfddcf Mon Sep 17 00:00:00 2001 From: Matthieu Lalonde Date: Sat, 4 Jun 2011 17:46:48 -0400 Subject: [PATCH] Some more cleaning up.... --- DDWRT_MonitorAppDelegate.m | 28 +++++++--------------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/DDWRT_MonitorAppDelegate.m b/DDWRT_MonitorAppDelegate.m index 5150922..110deee 100644 --- a/DDWRT_MonitorAppDelegate.m +++ b/DDWRT_MonitorAppDelegate.m @@ -27,7 +27,6 @@ if (![defaults boolForKey:@"configured"]) { [self initDefaults]; - [self showConfigPanel:nil]; } else { [self initialize]; } @@ -87,20 +86,17 @@ [defaults setBool:YES forKey:@"configured"]; - // sync the defaults to disk - [defaults synchronize]; - // TODO: Add modal alert "First launch" here... [self showConfigPanel:self]; } - (void) readDefaults { - hostname = [defaults valueForKey:@"hostname"]; - protocol = [defaults valueForKey:@"protocol"]; - port = [defaults integerForKey:@"port"]; - username = [defaults valueForKey:@"username"]; - password = [defaults valueForKey:@"password"]; + hostname = [defaults valueForKey:@"hostname"]; + protocol = [defaults valueForKey:@"protocol"]; + port = [defaults integerForKey:@"port"]; + username = [defaults valueForKey:@"username"]; + password = [defaults valueForKey:@"password"]; showMenuIcon = [defaults boolForKey:@"showMenuIcon"]; useBytes = [defaults boolForKey:@"useBytes"]; @@ -303,30 +299,19 @@ [configStateStatus startAnimation:nil]; [configStateStatus setHidden:false]; - //WRTRequest *wrtr = [[WRTRequest alloc] init]; - - // TODO check that the request is actually successful - hostname = [configFieldHostname stringValue]; - [defaults setValue:hostname forKey:@"hostname"]; port = [configFieldPort intValue]; - [defaults setInteger:port forKey:@"port"]; - //NSLog(@"%d", [configFieldProtocol state]); if ([configFieldProtocolHTTP state] == 1) { protocol = @"http"; } else if ([configFieldProtocolHTTPS state] == 1) { protocol = @"https"; } - [defaults setValue:protocol forKey:@"protocol"]; - refreshTime = [configFieldRefresh integerValue]; - [defaults setInteger:refreshTime forKey:@"refreshTime"]; useBytes = ([configFieldUseBytes state] == 1 ? true: false); - [defaults setBool:useBytes forKey:@"useBytes"]; if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) { [self hideMenubarIcon]; @@ -335,11 +320,12 @@ } showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false); - [defaults setBool:showMenuIcon forKey:@"showMenuIcon"]; [configStateStatus stopAnimation:nil]; [configStateStatus setHidden:true]; + [self writeDefaults]; + [defaults synchronize]; [self initialize];