diff --git a/DDWRT_MonitorAppDelegate.h b/DDWRT_MonitorAppDelegate.h
index 82c1b5d..2720e7b 100644
--- a/DDWRT_MonitorAppDelegate.h
+++ b/DDWRT_MonitorAppDelegate.h
@@ -90,6 +90,7 @@
- (void) terminate:(id)sender;
- (void) initialize;
- (void) deinitialize;
+- (void) showInitAlert;
- (IBAction) showBandwidthViewer:(id)sender;
# pragma mark Menu Methods:
diff --git a/DDWRT_MonitorAppDelegate.m b/DDWRT_MonitorAppDelegate.m
index 4d5fed3..d732fed 100644
--- a/DDWRT_MonitorAppDelegate.m
+++ b/DDWRT_MonitorAppDelegate.m
@@ -10,23 +10,23 @@
@implementation DDWRT_MonitorAppDelegate
-
# pragma mark -
# pragma mark Application Delegates:
- (void) awakeFromNib
{
-
- // Insert code here to initialize your application
- [self showMenubar];
+ // Insert code here to initialize your application
defaults = [NSUserDefaults standardUserDefaults];
// check if the app is configured yet
- if (![defaults boolForKey:@"configured"]) {
+ if (![defaults boolForKey:@"configured"] || [[defaults stringForKey:@"hostname"] length] == 0) {
+ [self showInitAlert];
[self initDefaults];
} else {
[self initialize];
}
+
+ [self showMenubar];
}
- (void) dealloc {
@@ -34,10 +34,13 @@
[_appMenu release];
[ConfigPanel release];
[BandwidthViewer release];
+
[super dealloc];
}
- (void) terminate:(id)sender {
+ [self deinitialize];
+
[[NSUserDefaults standardUserDefaults] synchronize];
[self dealloc];
[[NSApplication sharedApplication] terminate:self];
@@ -64,6 +67,7 @@
if (_updateTimer != nil) {
[_updateTimer invalidate];
_updateTimer = nil;
+ [_updateTimer release];
}
[wrt_update_client release];
@@ -73,6 +77,16 @@
wrt_request_client = nil;
}
+- (void) showInitAlert
+{
+ NSAlert *alert = [[[NSAlert alloc] init] autorelease];
+ [alert addButtonWithTitle:@"OK"];
+ [alert setMessageText:@"First Launch!"];
+ [alert setInformativeText:@"In order to conitnue, you must first provide your router settings."];
+ [alert setAlertStyle:NSInformationalAlertStyle];
+ [alert runModal];
+}
+
- (IBAction) showBandwidthViewer:(id)sender
{
[ [BandwidthViewerWebView mainFrame] loadRequest: [wrt_update_client requestForBandwidthViewerForInterface:[wrt_update_client getWanPort]] ];
@@ -150,7 +164,7 @@
// do any other initialization you want to do here - e.g. the starting default values.
[defaults setValue:@"http" forKey:@"protocol"];
- [defaults setValue:@"192.168.1.1" forKey:@"hostname"];
+ [defaults setValue:@"" forKey:@"hostname"];
[defaults setInteger:80 forKey:@"port"];
[defaults setValue:@"" forKey:@"username"];
[defaults setValue:@"" forKey:@"password"];
@@ -161,7 +175,6 @@
[defaults setBool:YES forKey:@"configured"];
- // TODO: Add modal alert "First launch" here...
[self showConfigPanel:self];
}
@@ -205,8 +218,6 @@
[configFieldHostname setStringValue:hostname];
}
- // TODO
-
[configFieldPort setIntValue:[defaults integerForKey:@"port"]];
[configFieldRefresh setIntegerValue:[defaults integerForKey:@"refreshTime"]];
@@ -226,12 +237,23 @@
- (IBAction) hideConfigPanel:(id)sender
{
- if (hostname == nil && [[sender title] isEqualToString:@"Cancel"]) {
- // TODO: Add modal alert "will quit if not configured"
- [self terminate:nil];
+ if ([hostname length] == 0 && [[sender title] isEqualToString:@"Cancel"]) {
+ NSAlert *alert = [NSAlert alertWithMessageText:@"Application Not Configured!"
+ defaultButton:@"Cancel" alternateButton:@"Ok" otherButton:nil
+ informativeTextWithFormat:@"The application will quit now."
+ ];
+
+ [alert setAlertStyle:NSCriticalAlertStyle];
+
+ NSInteger button = [alert runModal];
+
+ if (button != NSAlertDefaultReturn) {
+ [self terminate:nil];
+ [ConfigPanel orderOut:nil];
+ }
+ } else {
+ [ConfigPanel orderOut:nil];
}
-
- [ConfigPanel orderOut:nil];
}
- (IBAction) setConfigProtocol:(id)sender
@@ -362,7 +384,6 @@
- (void) getRouterData:(NSData *)data
{
- NSLog(@"Gathering status data");
if (data != nil) {
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
@@ -370,20 +391,18 @@
_statusStringData = [newStringData retain];
} else {
- NSLog(@"No data received yet");
+ _statusStringData = @"";
+ _statusDataRequestNumber = 0;
}
switch (_statusDataRequestNumber++) {
case 0:
- NSLog(@"Status 0");
[wrt_request_client getStatusUpdate:@"Status_Router.live.asp" delegate:self callback:@selector(getRouterData:)];
break;
case 1:
- NSLog(@"Status 1");
[wrt_request_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(getRouterData:)];
break;
case 2:
- NSLog(@"Status 2");
[wrt_request_client getStatusUpdate:@"Status_Lan.live.asp" delegate:self callback:@selector(getRouterData:)];
break;
case 3:
@@ -395,9 +414,6 @@
// Show the menu
[_appMenu popUpStatusItemMenu:AppMenu];
-
- _statusStringData = @"";
- _statusDataRequestNumber = 0;
break;
}
}
diff --git a/English.lproj/MainMenu.xib b/English.lproj/MainMenu.xib
index 14fd394..a9444eb 100644
--- a/English.lproj/MainMenu.xib
+++ b/English.lproj/MainMenu.xib
@@ -1260,22 +1260,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
754
-
-
-
- menu
-
-
-
- 756
-
configFieldHostname
@@ -1468,14 +1452,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
811
-
-
- delegate
-
-
-
- 812
-
delegate
@@ -1484,14 +1460,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
813
-
-
- delegate
-
-
-
- 814
-
menuClientsCount
@@ -1564,6 +1532,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
826
+
+
+ delegate
+
+
+
+ 841
+
@@ -2616,7 +2592,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
- 840
+ 841
@@ -2634,6 +2610,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
saveConfig:
setConfigProtocol:
setConfigRefresh:
+ showBandwidthViewer:
showConfigPanel:
@@ -2645,6 +2622,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
id
id
id
+ id
@@ -2657,6 +2635,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
saveConfig:
setConfigProtocol:
setConfigRefresh:
+ showBandwidthViewer:
showConfigPanel:
@@ -2685,6 +2664,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA
setConfigRefresh:
id
+
+ showBandwidthViewer:
+ id
+
showConfigPanel:
id