1
0
Fork 0

Added some modal alerts for first run and cancel prefs save on first run.

master
Matthieu Lalonde 13 years ago
parent 9b30a400f2
commit 7b495f22a9

@ -90,6 +90,7 @@
- (void) terminate:(id)sender;
- (void) initialize;
- (void) deinitialize;
- (void) showInitAlert;
- (IBAction) showBandwidthViewer:(id)sender;
# pragma mark Menu Methods:

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

@ -1260,22 +1260,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">754</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">menu</string>
<reference key="source" ref="284387334"/>
<reference key="destination" ref="1033903501"/>
</object>
<int key="connectionID">755</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">menu</string>
<reference key="source" ref="40768770"/>
<reference key="destination" ref="1033903501"/>
</object>
<int key="connectionID">756</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">configFieldHostname</string>
@ -1468,14 +1452,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">811</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="492386921"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">812</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
@ -1484,14 +1460,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">813</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="206781734"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">814</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">menuClientsCount</string>
@ -1564,6 +1532,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">826</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1050"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">841</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -2616,7 +2592,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">840</int>
<int key="maxID">841</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
@ -2634,6 +2610,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>saveConfig:</string>
<string>setConfigProtocol:</string>
<string>setConfigRefresh:</string>
<string>showBandwidthViewer:</string>
<string>showConfigPanel:</string>
</object>
<object class="NSMutableArray" key="dict.values">
@ -2645,6 +2622,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
@ -2657,6 +2635,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string>saveConfig:</string>
<string>setConfigProtocol:</string>
<string>setConfigRefresh:</string>
<string>showBandwidthViewer:</string>
<string>showConfigPanel:</string>
</object>
<object class="NSMutableArray" key="dict.values">
@ -2685,6 +2664,10 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<string key="name">setConfigRefresh:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showBandwidthViewer:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">showConfigPanel:</string>
<string key="candidateClassName">id</string>

Loading…
Cancel
Save