|
|
@ -28,17 +28,19 @@
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[self initDefaults];
|
|
|
|
[self initDefaults];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NSLog(@"Reading defaults...");
|
|
|
|
NSLog(@"Reading defaults...");
|
|
|
|
[self readDefaults];
|
|
|
|
[self readDefaults];
|
|
|
|
|
|
|
|
|
|
|
|
// initialize the client
|
|
|
|
// initialize the client
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port protocol:protocol username:username password:password];
|
|
|
|
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port protocol:protocol username:username password:password];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[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];
|
|
|
|
|
|
|
|
|
|
|
|
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
|
|
|
|
//[self updateThroughput];
|
|
|
|
//[_readTimer fire];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
[self updateThroughput];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
|
@ -112,6 +114,7 @@
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) terminate:(id)sender {
|
|
|
|
- (void) terminate:(id)sender {
|
|
|
|
|
|
|
|
[_readTimer invalidate];
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
|
[self dealloc];
|
|
|
|
[self dealloc];
|
|
|
|
[[NSApplication sharedApplication] terminate:self];
|
|
|
|
[[NSApplication sharedApplication] terminate:self];
|
|
|
@ -280,31 +283,6 @@
|
|
|
|
[self configSaveRequestCallback:nil];
|
|
|
|
[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
|
|
|
|
-(void)configSaveRequestCallback:(NSData *)data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// TODO check that the request is actually successful
|
|
|
|
// TODO check that the request is actually successful
|
|
|
@ -344,8 +322,9 @@
|
|
|
|
[self hideConfigPanel:nil];
|
|
|
|
[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];
|
|
|
|
//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"];
|
|
|
@ -372,7 +351,7 @@
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
|
{
|
|
|
|
{
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
/*
|
|
|
|
NSString *ipconn = [self getKey:stringData key:@"ip_conntrack"];
|
|
|
|
NSString *ipconn = [self getKey:stringData key:@"ip_conntrack"];
|
|
|
|
|
|
|
|
|
|
|
|
NSString *wanip = [self getKey:stringData key:@"ipinfo"];
|
|
|
|
NSString *wanip = [self getKey:stringData key:@"ipinfo"];
|
|
|
@ -389,7 +368,7 @@
|
|
|
|
[menuUptime setTitle:uptime];
|
|
|
|
[menuUptime setTitle:uptime];
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
[menuConnections setTitle:[NSString stringWithFormat:@"Connections: %@", ipconn]];
|
|
|
|
[menuConnections setTitle:[NSString stringWithFormat:@"Connections: %@", ipconn]];*/
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (void) refreshMenu:(id)sender
|
|
|
|
- (void) refreshMenu:(id)sender
|
|
|
@ -489,7 +468,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- (void) refreshClientsMenu:(id)sender
|
|
|
|
- (void) refreshClientsMenu:(id)sender
|
|
|
|
{
|
|
|
|
{
|
|
|
|
[self updateThroughput];
|
|
|
|
[self updateThroughput:nil];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
- (NSString *) stringFromFileSize:(unsigned long long)theSize
|
|
|
|
- (NSString *) stringFromFileSize:(unsigned long long)theSize
|
|
|
|