1
0
Fork 0

Added removal of previous client menu items, changed routine so the menu items on update on menu click

master
Matthieu Lalonde 14 years ago
parent caeebacb4b
commit 355c28895d

@ -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
@ -352,8 +354,6 @@
- (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,12 +410,13 @@
[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:)];
}
@ -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,7 +619,7 @@
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.1fKiB",floatSize]);

@ -2631,7 +2631,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">823</int>
<int key="maxID">824</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">

Loading…
Cancel
Save