|
|
|
@ -35,10 +35,12 @@
|
|
|
|
|
// initialize the client
|
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port protocol:protocol username:username password:password];
|
|
|
|
|
|
|
|
|
|
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
|
|
|
|
|
//[_readTimer fire];
|
|
|
|
|
[wrt_client getConnectionStatus];
|
|
|
|
|
NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client wanPort]);
|
|
|
|
|
_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:NO];
|
|
|
|
|
[_readTimer fire];
|
|
|
|
|
|
|
|
|
|
[self updateThroughput];
|
|
|
|
|
//[self updateThroughput];
|
|
|
|
|
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
@ -112,6 +114,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) terminate:(id)sender {
|
|
|
|
|
[_readTimer invalidate];
|
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
|
[self dealloc];
|
|
|
|
|
[[NSApplication sharedApplication] terminate:self];
|
|
|
|
@ -280,31 +283,6 @@
|
|
|
|
|
[self configSaveRequestCallback:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key
|
|
|
|
|
{
|
|
|
|
|
NSString *keyString = [NSString stringWithFormat:@"%@::", key];
|
|
|
|
|
NSString *returnData;
|
|
|
|
|
NSRange formatValid = [stringData rangeOfString:@"}"];
|
|
|
|
|
|
|
|
|
|
if (formatValid.location != NSNotFound) {
|
|
|
|
|
NSRange startRange = [stringData rangeOfString:keyString];
|
|
|
|
|
|
|
|
|
|
if (startRange.location != NSNotFound) {
|
|
|
|
|
|
|
|
|
|
returnData = [NSString stringWithString:stringData];
|
|
|
|
|
returnData = [returnData substringFromIndex:(startRange.location + [keyString length])];
|
|
|
|
|
returnData = [returnData substringToIndex:[returnData rangeOfString:@"}"].location];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
returnData = [returnData stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//[keyString release];
|
|
|
|
|
|
|
|
|
|
return returnData;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
-(void)configSaveRequestCallback:(NSData *)data
|
|
|
|
|
{
|
|
|
|
|
// TODO check that the request is actually successful
|
|
|
|
@ -344,8 +322,9 @@
|
|
|
|
|
[self hideConfigPanel:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) updateThroughput
|
|
|
|
|
- (void) updateThroughput:(NSTimer*)timer
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client wanPort]);
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(throughputCallback:) uri:@"fetchif.cgi?ppp1"];
|
|
|
|
@ -372,7 +351,7 @@
|
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
|
|
{
|
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
NSString *ipconn = [self getKey:stringData key:@"ip_conntrack"];
|
|
|
|
|
|
|
|
|
|
NSString *wanip = [self getKey:stringData key:@"ipinfo"];
|
|
|
|
@ -389,7 +368,7 @@
|
|
|
|
|
[menuUptime setTitle:uptime];
|
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
|
[menuConnections setTitle:[NSString stringWithFormat:@"Connections: %@", ipconn]];
|
|
|
|
|
[menuConnections setTitle:[NSString stringWithFormat:@"Connections: %@", ipconn]];*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) refreshMenu:(id)sender
|
|
|
|
@ -489,7 +468,7 @@
|
|
|
|
|
|
|
|
|
|
- (void) refreshClientsMenu:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[self updateThroughput];
|
|
|
|
|
[self updateThroughput:nil];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (NSString *) stringFromFileSize:(unsigned long long)theSize
|
|
|
|
|