|
|
|
@ -14,44 +14,23 @@
|
|
|
|
|
|
|
|
|
|
//- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
|
|
|
|
|
- (void) awakeFromNib
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Spike debug start.");
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:@"router" port:80 username:@"spike" password:@"aaaassss"];
|
|
|
|
|
|
|
|
|
|
[wrt_client getStatusUpdate:@"graph_if.svg?vlan2" delegate: self];
|
|
|
|
|
|
|
|
|
|
NSLog(@"Spike debug end.");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Insert code here to initialize your application
|
|
|
|
|
[self showMenubar];
|
|
|
|
|
|
|
|
|
|
_wrtReachable = false;
|
|
|
|
|
|
|
|
|
|
// initialize defaults
|
|
|
|
|
NSString *hostname = [[NSUserDefaults standardUserDefaults] stringForKey:@"hostname"];
|
|
|
|
|
|
|
|
|
|
if (hostname == nil) // App first run: set up user defaults.
|
|
|
|
|
defaults = [NSUserDefaults standardUserDefaults];
|
|
|
|
|
|
|
|
|
|
// check if the app is configured yet
|
|
|
|
|
if (![defaults boolForKey:@"configured"])
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:nil];
|
|
|
|
|
|
|
|
|
|
NSLog(@"Creating new user defaults");
|
|
|
|
|
|
|
|
|
|
// do any other initialization you want to do here - e.g. the starting default values.
|
|
|
|
|
//[[NSUserDefaults standardUserDefaults] setObject:@"192.168.1.1" foKey:@"hostname"];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"showMenuIcon"];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:YES forKey:@"useBytes"];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:80 forKey:@"port"];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:4 forKey:@"refreshTime"];
|
|
|
|
|
|
|
|
|
|
// sync the defaults to disk
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] registerDefaults:appDefaults];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
|
|
|
|
|
// TODO: Add modal alert "First launch" here...
|
|
|
|
|
[self showConfigPanel:nil];
|
|
|
|
|
[self initDefaults];
|
|
|
|
|
} else {
|
|
|
|
|
[self readDefaults];
|
|
|
|
|
NSLog(@"Using existing user defaults");
|
|
|
|
|
|
|
|
|
|
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
|
|
|
|
@ -59,9 +38,9 @@
|
|
|
|
|
|
|
|
|
|
[self updateThroughput];
|
|
|
|
|
|
|
|
|
|
WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
[wrtr doRequest:self requestSelector:@selector(doUpdateStatus:) uri:@"Status_Router.live.asp"];
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(doUpdateStatus:) uri:@"Status_Router.live.asp"];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -75,6 +54,32 @@
|
|
|
|
|
[super dealloc];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) initDefaults
|
|
|
|
|
{
|
|
|
|
|
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:nil];
|
|
|
|
|
|
|
|
|
|
NSLog(@"Creating new user defaults");
|
|
|
|
|
|
|
|
|
|
// do any other initialization you want to do here - e.g. the starting default values.
|
|
|
|
|
//[[NSUserDefaults standardUserDefaults] setObject:@"192.168.1.1" foKey:@"hostname"];
|
|
|
|
|
[defaults setBool:YES forKey:@"showMenuIcon"];
|
|
|
|
|
[defaults setBool:YES forKey:@"useBytes"];
|
|
|
|
|
[defaults setInteger:80 forKey:@"port"];
|
|
|
|
|
[defaults setInteger:4 forKey:@"refreshTime"];
|
|
|
|
|
|
|
|
|
|
// sync the defaults to disk
|
|
|
|
|
[defaults registerDefaults:appDefaults];
|
|
|
|
|
[defaults synchronize];
|
|
|
|
|
|
|
|
|
|
// TODO: Add modal alert "First launch" here...
|
|
|
|
|
[self showConfigPanel:self];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) readDefaults
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) terminate:(id)sender {
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
[self dealloc];
|
|
|
|
@ -241,9 +246,9 @@
|
|
|
|
|
[configStateStatus startAnimation:nil];
|
|
|
|
|
[configStateStatus setHidden:false];
|
|
|
|
|
|
|
|
|
|
WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
[wrtr doRequest:self requestSelector:@selector(configSaveRequestCallback:) uri:@"Status_Router.live.asp"];
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(configSaveRequestCallback:) uri:@"Status_Router.live.asp"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key
|
|
|
|
@ -308,9 +313,9 @@
|
|
|
|
|
- (void) updateThroughput
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
[wrtr doRequest:self requestSelector:@selector(throughputCallback:) uri:@"fetchif.cgi?ppp1"];
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(throughputCallback:) uri:@"fetchif.cgi?ppp1"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) throughputCallback:(NSData *)data
|
|
|
|
@ -367,9 +372,9 @@
|
|
|
|
|
- (void) refreshWanMenu:(id)sender
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Refreshing Wan Menu");
|
|
|
|
|
WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
[wrtr doRequest:self requestSelector:@selector(wanRequestCallback:) uri:@"Status_Internet.live.asp"];
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(wanRequestCallback:) uri:@"Status_Internet.live.asp"];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) wanRequestCallback:(NSData *)data
|
|
|
|
|