|
|
@ -33,7 +33,7 @@
|
|
|
|
[self readDefaults];
|
|
|
|
[self readDefaults];
|
|
|
|
|
|
|
|
|
|
|
|
// initialize the client
|
|
|
|
// initialize the client
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port username:username password:password];
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:&port username:username password:password];
|
|
|
|
|
|
|
|
|
|
|
|
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
|
|
|
|
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
|
|
|
|
//[_readTimer fire];
|
|
|
|
//[_readTimer fire];
|
|
|
@ -57,7 +57,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
- (void) initDefaults
|
|
|
|
- (void) initDefaults
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"Creating new user defaults");
|
|
|
|
NSLog(@"Creating new user defaults");
|
|
|
|
|
|
|
|
|
|
|
|
// do any other initialization you want to do here - e.g. the starting default values.
|
|
|
|
// do any other initialization you want to do here - e.g. the starting default values.
|
|
|
@ -90,8 +89,6 @@
|
|
|
|
showMenuIcon = [defaults boolForKey:@"showMenuIcon"];
|
|
|
|
showMenuIcon = [defaults boolForKey:@"showMenuIcon"];
|
|
|
|
useBytes = [defaults boolForKey:@"useBytes"];
|
|
|
|
useBytes = [defaults boolForKey:@"useBytes"];
|
|
|
|
refreshTime = [defaults integerForKey:@"refreshTime"];
|
|
|
|
refreshTime = [defaults integerForKey:@"refreshTime"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) writeDefaults
|
|
|
|
- (void) writeDefaults
|
|
|
@ -178,32 +175,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
- (void) showConfigPanel:(id)sender
|
|
|
|
- (void) showConfigPanel:(id)sender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[configFieldShowIcon setState:([[NSUserDefaults standardUserDefaults] boolForKey:@"showMenuIcon"] ? 1 : 0)];
|
|
|
|
[configFieldShowIcon setState:([defaults boolForKey:@"showMenuIcon"] ? 1 : 0)];
|
|
|
|
[configFieldUseBytes setState:([[NSUserDefaults standardUserDefaults] boolForKey:@"useBytes"] ? 1 : 0)];
|
|
|
|
[configFieldUseBytes setState:([defaults boolForKey:@"useBytes"] ? 1 : 0)];
|
|
|
|
|
|
|
|
|
|
|
|
NSString *hostname = [[NSUserDefaults standardUserDefaults] stringForKey:@"hostname"];
|
|
|
|
|
|
|
|
if (hostname != nil) {
|
|
|
|
if (hostname != nil) {
|
|
|
|
[configFieldHostname setStringValue:hostname];
|
|
|
|
[configFieldHostname setStringValue:hostname];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[configFieldPort setIntValue:[[NSUserDefaults standardUserDefaults] integerForKey:@"port"]];
|
|
|
|
[configFieldPort setIntValue:[defaults integerForKey:@"port"]];
|
|
|
|
|
|
|
|
|
|
|
|
[configFieldRefresh setIntegerValue:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"]];
|
|
|
|
[configFieldRefresh setIntegerValue:[defaults integerForKey:@"refreshTime"]];
|
|
|
|
|
|
|
|
|
|
|
|
[configLabelRefresh setStringValue:[NSString stringWithFormat:@"%d s", ([[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] + 1)]];
|
|
|
|
[configLabelRefresh setStringValue:[NSString stringWithFormat:@"%d s", ([defaults integerForKey:@"refreshTime"] + 1)]];
|
|
|
|
|
|
|
|
|
|
|
|
[ConfigPanel makeKeyAndOrderFront:nil];
|
|
|
|
[ConfigPanel makeKeyAndOrderFront:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) hideConfigPanel:(id)sender
|
|
|
|
- (void) hideConfigPanel:(id)sender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSString *hostname = [[NSUserDefaults standardUserDefaults] stringForKey:@"hostname"];
|
|
|
|
/*NSString *hostname = [[NSUserDefaults standardUserDefaults] stringForKey:@"hostname"];
|
|
|
|
|
|
|
|
|
|
|
|
if (hostname == nil && [[sender title] isEqualToString:@"Cancel"]) {
|
|
|
|
if (hostname == nil && [[sender title] isEqualToString:@"Cancel"]) {
|
|
|
|
// TODO: Add modal alert "will quit if not configured"
|
|
|
|
// TODO: Add modal alert "will quit if not configured"
|
|
|
|
[self terminate:nil];
|
|
|
|
[self terminate:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
[ConfigPanel orderOut:nil];
|
|
|
|
[ConfigPanel orderOut:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -220,7 +216,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
[BandwidthViewer makeKeyAndOrderFront:nil];
|
|
|
|
[BandwidthViewer makeKeyAndOrderFront:nil];
|
|
|
|
|
|
|
|
|
|
|
|
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:@"vlan2"] retain];
|
|
|
|
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:@"ppp1"] retain];
|
|
|
|
|
|
|
|
|
|
|
|
[ [BandwidthViewerWebView mainFrame] loadRequest: request ];
|
|
|
|
[ [BandwidthViewerWebView mainFrame] loadRequest: request ];
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -280,6 +276,7 @@
|
|
|
|
//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"];
|
|
|
|
|
|
|
|
[self configSaveRequestCallback:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key
|
|
|
|
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key
|
|
|
@ -311,39 +308,43 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO check that the request is actually successful
|
|
|
|
// TODO check that the request is actually successful
|
|
|
|
|
|
|
|
|
|
|
|
NSString *hostname = [configFieldHostname stringValue];
|
|
|
|
hostname = [configFieldHostname stringValue];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:hostname forKey:@"hostname"];
|
|
|
|
[defaults setValue:hostname forKey:@"hostname"];
|
|
|
|
|
|
|
|
|
|
|
|
NSString *port = [configFieldPort stringValue];
|
|
|
|
port = [configFieldPort intValue];
|
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:port forKey:@"port"];
|
|
|
|
[defaults setInteger:port forKey:@"port"];
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"Got %@", hostname);
|
|
|
|
NSLog(@"Got %@ for %@", hostname, [configFieldHostname stringValue]);
|
|
|
|
|
|
|
|
|
|
|
|
//NSLog(@"%@", [configFieldProtocol str]);
|
|
|
|
//NSLog(@"%@", [configFieldProtocol str]);
|
|
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setInteger:[configFieldRefresh integerValue] forKey:@"refreshTime"];
|
|
|
|
refreshTime = [configFieldRefresh integerValue];
|
|
|
|
|
|
|
|
[defaults setInteger:refreshTime forKey:@"refreshTime"];
|
|
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:([configFieldUseBytes state] == 1 ? true: false) forKey:@"useBytes"];
|
|
|
|
useBytes = ([configFieldUseBytes state] == 1 ? true: false);
|
|
|
|
|
|
|
|
[defaults setBool:useBytes forKey:@"useBytes"];
|
|
|
|
|
|
|
|
|
|
|
|
if ([configFieldShowIcon state] == NSOffState && [[NSUserDefaults standardUserDefaults] boolForKey:@"showMenuIcon"] == true) {
|
|
|
|
if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) {
|
|
|
|
[self hideMenubarIcon];
|
|
|
|
[self hideMenubarIcon];
|
|
|
|
} else if ([configFieldShowIcon state] == NSOnState && [[NSUserDefaults standardUserDefaults] boolForKey:@"showMenuIcon"] == false) {
|
|
|
|
} else if ([configFieldShowIcon state] == NSOnState && [defaults boolForKey:@"showMenuIcon"] == false) {
|
|
|
|
[self showMenubarIcon:false];
|
|
|
|
[self showMenubarIcon:false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] setBool:([configFieldShowIcon state] == 1 ? true: false) forKey:@"showMenuIcon"];
|
|
|
|
showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false);
|
|
|
|
|
|
|
|
[defaults setBool:showMenuIcon forKey:@"showMenuIcon"];
|
|
|
|
|
|
|
|
|
|
|
|
[configStateStatus stopAnimation:nil];
|
|
|
|
[configStateStatus stopAnimation:nil];
|
|
|
|
[configStateStatus setHidden:true];
|
|
|
|
[configStateStatus setHidden:true];
|
|
|
|
|
|
|
|
|
|
|
|
[self doUpdateStatus:data];
|
|
|
|
[defaults synchronize];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//[self doUpdateStatus:data];
|
|
|
|
|
|
|
|
|
|
|
|
[self hideConfigPanel:nil];
|
|
|
|
[self hideConfigPanel:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) updateThroughput
|
|
|
|
- (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"];
|
|
|
@ -352,7 +353,7 @@
|
|
|
|
- (void) throughputCallback:(NSData *)data
|
|
|
|
- (void) throughputCallback:(NSData *)data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
NSDate *start = [NSDate date];
|
|
|
|
/*NSDate *start = [NSDate date];
|
|
|
|
NSTimeInterval timeInterval = [start timeIntervalSinceNow];
|
|
|
|
NSTimeInterval timeInterval = [start timeIntervalSinceNow];
|
|
|
|
NSLog(@"%f", timeInterval);
|
|
|
|
NSLog(@"%f", timeInterval);
|
|
|
|
|
|
|
|
|
|
|
@ -364,7 +365,7 @@
|
|
|
|
unsigned long long ifIn = [NSNumber numberWithString:[listItems objectAtIndex:0]];
|
|
|
|
unsigned long long ifIn = [NSNumber numberWithString:[listItems objectAtIndex:0]];
|
|
|
|
unsigned long long ifOut = [NSNumber numberWithString:[listItems objectAtIndex:8]];
|
|
|
|
unsigned long long ifOut = [NSNumber numberWithString:[listItems objectAtIndex:8]];
|
|
|
|
|
|
|
|
|
|
|
|
NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];
|
|
|
|
NSTimeInterval currentTime = [NSDate timeIntervalSinceReferenceDate];*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
@ -406,12 +407,15 @@
|
|
|
|
//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"];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Bandwidth.asp" delegate:wanRequestCallback];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) wanRequestCallback:(NSData *)data
|
|
|
|
- (void) wanRequestCallback:(NSData *)data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
NSLog(@"%@", stringData);
|
|
|
|
|
|
|
|
/*
|
|
|
|
NSString *wanStatus = [self getKey:stringData key:@"wan_status"];
|
|
|
|
NSString *wanStatus = [self getKey:stringData key:@"wan_status"];
|
|
|
|
NSString *wanName = [self getKey:stringData key:@"wan_shortproto"];
|
|
|
|
NSString *wanName = [self getKey:stringData key:@"wan_shortproto"];
|
|
|
|
if ([wanName isEqualToString:@"pppoe"] == true) {
|
|
|
|
if ([wanName isEqualToString:@"pppoe"] == true) {
|
|
|
@ -437,7 +441,6 @@
|
|
|
|
[menuWanBandwidthGraph setEnabled:true];
|
|
|
|
[menuWanBandwidthGraph setEnabled:true];
|
|
|
|
[menuWanTrafficIn setHidden:false];
|
|
|
|
[menuWanTrafficIn setHidden:false];
|
|
|
|
[menuWanTrafficOut setHidden:false];
|
|
|
|
[menuWanTrafficOut setHidden:false];
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
[menuWanUptime setHidden:true];
|
|
|
|
[menuWanUptime setHidden:true];
|
|
|
|
[menuWanSeparator setHidden:true];
|
|
|
|
[menuWanSeparator setHidden:true];
|
|
|
@ -476,7 +479,7 @@
|
|
|
|
[menuWanDNSItem2 setTitle: wanDNS2];
|
|
|
|
[menuWanDNSItem2 setTitle: wanDNS2];
|
|
|
|
[menuWanDNSItem2 setHidden:false];
|
|
|
|
[menuWanDNSItem2 setHidden:false];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
[stringData release];
|
|
|
|
[stringData release];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -509,7 +512,6 @@
|
|
|
|
- (void) connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
|
|
|
|
- (void) connection:(NSURLConnection*)connection didReceiveData:(NSData*)data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSLog(@"Delegate Received: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
|
|
|
NSLog(@"Delegate Received: %@", [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
@end
|
|
|
|