|
|
|
@ -127,6 +127,8 @@
|
|
|
|
|
|
|
|
|
|
NSStatusBar* bar = [NSStatusBar systemStatusBar];
|
|
|
|
|
_appMenu = [bar statusItemWithLength:NSVariableStatusItemLength];
|
|
|
|
|
[_appMenu setAction:@selector(refreshMenu:)];
|
|
|
|
|
[_appMenu setTarget:self];
|
|
|
|
|
[_appMenu retain];
|
|
|
|
|
|
|
|
|
|
//[self setMenubarText:@"000KB/s\n000KB/s"];
|
|
|
|
@ -137,7 +139,7 @@
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
[_appMenu setHighlightMode:YES];
|
|
|
|
|
[_appMenu setMenu:AppMenu];
|
|
|
|
|
//[_appMenu setMenu:AppMenu];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) hideMenubar
|
|
|
|
@ -351,9 +353,7 @@
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) throughputCallback:(NSData *)data
|
|
|
|
|
{
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Router.live.asp" delegate:self callback:@selector(doUpdateStatus:)];
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
|
|
NSString *key = [NSString stringWithFormat:@"%@:", [wrt_client getWanPort]];
|
|
|
|
@ -388,6 +388,8 @@
|
|
|
|
|
|
|
|
|
|
-(void)doUpdateStatus:(NSData *)data
|
|
|
|
|
{
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(wanRequestCallback:)];
|
|
|
|
|
|
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
|
|
NSString *ipconn = [wrt_client getKey:stringData key:@"ip_conntrack"];
|
|
|
|
@ -408,13 +410,14 @@
|
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
|
[menuClientsConnections setTitle:[NSString stringWithFormat:@"%@ Connection%@", ipconn, ([ipconn isEqualToString:@"1"] ? @"" : @"s")]];
|
|
|
|
|
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(wanRequestCallback:)];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) refreshMenu:(id)sender
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Refresh Menu");
|
|
|
|
|
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Router.live.asp" delegate:self callback:@selector(doUpdateStatus:)];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) refreshSystemMenu:(id)sender
|
|
|
|
@ -424,15 +427,13 @@
|
|
|
|
|
|
|
|
|
|
- (void) refreshWanMenu:(id)sender
|
|
|
|
|
{
|
|
|
|
|
NSLog(@"Refreshing Wan Menu");
|
|
|
|
|
//WRTRequest *wrtr = [[WRTRequest alloc] init];
|
|
|
|
|
|
|
|
|
|
//[wrtr doRequest:self requestSelector:@selector(wanRequestCallback:) uri:@"Status_Internet.live.asp"];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) wanRequestCallback:(NSData *)data
|
|
|
|
|
{
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Lan.live.asp" delegate:self callback:@selector(cbClientsRequest:)];
|
|
|
|
|
|
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
|
|
|
|
|
NSString *wanStatus = [wrt_client getKey:stringData key:@"wan_status"];
|
|
|
|
@ -506,7 +507,7 @@
|
|
|
|
|
|
|
|
|
|
- (void) refreshClientsMenu:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Lan.live.asp" delegate:self callback:@selector(cbClientsRequest:)];
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) cbClientsRequest:(NSData*)data
|
|
|
|
@ -533,7 +534,6 @@
|
|
|
|
|
|
|
|
|
|
NSArray *clientsData = [clientsStringData componentsSeparatedByString:@","];
|
|
|
|
|
|
|
|
|
|
long clientIndex;
|
|
|
|
|
NSMenu *clientMenu;
|
|
|
|
|
NSMenu *copyMenu;
|
|
|
|
|
NSMenuItem *copyMenuItem;
|
|
|
|
@ -543,13 +543,22 @@
|
|
|
|
|
unsigned long clientsCount = [clientsData count] / 4;
|
|
|
|
|
[menuClientsCount setTitle:[NSString stringWithFormat:@"%lu Active Client%@", clientsCount, (clientsCount > 1 ? @"s" : @"")]];
|
|
|
|
|
|
|
|
|
|
// Clear the old client data
|
|
|
|
|
unsigned long clientIndex;
|
|
|
|
|
unsigned long firstItem = [menuClients indexOfItem:menuClientsSeparator];
|
|
|
|
|
if ([menuClients numberOfItems] > firstItem) {
|
|
|
|
|
for (clientIndex = ([menuClients numberOfItems] - 1); clientIndex > (firstItem + 1); clientIndex--) {
|
|
|
|
|
[menuClients removeItemAtIndex:clientIndex];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (clientIndex = 0; clientIndex < [clientsData count]; clientIndex+=4) {
|
|
|
|
|
NSLog(@"Client: %@ IP: %@ MAC: %@ Connections: %@",
|
|
|
|
|
/*NSLog(@"Client: %@ IP: %@ MAC: %@ Connections: %@",
|
|
|
|
|
[clientsData objectAtIndex:clientIndex],
|
|
|
|
|
[clientsData objectAtIndex:clientIndex+1],
|
|
|
|
|
[clientsData objectAtIndex:clientIndex+2],
|
|
|
|
|
[clientsData objectAtIndex:clientIndex+3]);
|
|
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
clientMenu = [[NSMenu alloc] init];
|
|
|
|
|
|
|
|
|
|
// Hostname
|
|
|
|
@ -594,6 +603,8 @@
|
|
|
|
|
|
|
|
|
|
[menuClients addItem:clientItem];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[_appMenu popUpStatusItemMenu:AppMenu];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) copyParentMenuTitle:(id)sender
|
|
|
|
@ -608,19 +619,19 @@
|
|
|
|
|
|
|
|
|
|
double floatSize = theSize;
|
|
|
|
|
if (theSize<1023)
|
|
|
|
|
return([NSString stringWithFormat:@"%qx bytes",theSize]);
|
|
|
|
|
return([NSString stringWithFormat:@"%qxB",theSize]);
|
|
|
|
|
floatSize = floatSize / 1024;
|
|
|
|
|
if (floatSize<1023)
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1f KiB",floatSize]);
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1fKiB",floatSize]);
|
|
|
|
|
floatSize = floatSize / 1024;
|
|
|
|
|
if (floatSize<1023)
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1f MiB",floatSize]);
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1fMiB",floatSize]);
|
|
|
|
|
floatSize = floatSize / 1024;
|
|
|
|
|
if (floatSize<1023)
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1f GiB",floatSize]);
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1fGiB",floatSize]);
|
|
|
|
|
floatSize = floatSize / 1024;
|
|
|
|
|
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1f TiB",floatSize]);
|
|
|
|
|
return([NSString stringWithFormat:@"%1.1fTiB",floatSize]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|