|
|
|
@ -310,7 +310,7 @@
|
|
|
|
|
if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) {
|
|
|
|
|
[self hideMenubarIcon];
|
|
|
|
|
} else if ([configFieldShowIcon state] == NSOnState && [defaults boolForKey:@"showMenuIcon"] == false) {
|
|
|
|
|
[self showMenubarIcon:false];
|
|
|
|
|
[self showMenubarIcon:[wrt_client wrtReachable]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false);
|
|
|
|
@ -388,25 +388,53 @@
|
|
|
|
|
[wrt_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(wanRequestCallback:)];
|
|
|
|
|
|
|
|
|
|
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
|
|
|
|
|
NSLog(@"%@", stringData);
|
|
|
|
|
|
|
|
|
|
NSString *ipconn = [wrt_client getKey:stringData key:@"ip_conntrack"];
|
|
|
|
|
[menuClientsConnections setTitle:[NSString stringWithFormat:@"%@ Connection%@", ipconn, ([ipconn isEqualToString:@"1"] ? @"" : @"s")]];
|
|
|
|
|
|
|
|
|
|
NSString *wanip = [wrt_client getKey:stringData key:@"ipinfo"];
|
|
|
|
|
NSRange startRange = [wanip rangeOfString:@" "];
|
|
|
|
|
wanip = [wanip substringFromIndex:(startRange.location+1)];
|
|
|
|
|
[menuWanIP setTitle:wanip];
|
|
|
|
|
|
|
|
|
|
NSString *uptime = [wrt_client getKey:stringData key:@"uptime"];
|
|
|
|
|
NSString *loadSplit = @", load average: ";
|
|
|
|
|
NSString *load = [uptime substringFromIndex:[uptime rangeOfString:loadSplit].location+[loadSplit length]];
|
|
|
|
|
uptime = [uptime substringToIndex:[uptime rangeOfString:@", load"].location]; // Cut the load
|
|
|
|
|
uptime = [uptime substringFromIndex:[uptime rangeOfString:@" "].location+1]; // Trim
|
|
|
|
|
uptime = [uptime stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[uptime substringToIndex:1] uppercaseString]]; // UCFirst
|
|
|
|
|
if ([uptime length] > 0) {
|
|
|
|
|
NSString *load = [uptime substringFromIndex:[uptime rangeOfString:loadSplit].location+[loadSplit length]];
|
|
|
|
|
uptime = [uptime substringToIndex:[uptime rangeOfString:@", load"].location]; // Cut the load
|
|
|
|
|
uptime = [uptime substringFromIndex:[uptime rangeOfString:@" "].location+1]; // Trim
|
|
|
|
|
uptime = [uptime stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[uptime substringToIndex:1] uppercaseString]]; // UCFirst
|
|
|
|
|
[menuUptime setTitle:uptime];
|
|
|
|
|
//[menuUptime setHidden:false];
|
|
|
|
|
|
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
|
//[[AppMenu itemAtIndex:2] setHidden:false];
|
|
|
|
|
} else {
|
|
|
|
|
[menuUptime setTitle:@"Connected"];
|
|
|
|
|
//[menuUptime setHidden:true];
|
|
|
|
|
[menuLoad setHidden:true];
|
|
|
|
|
//[[AppMenu itemAtIndex:2] setHidden:true];
|
|
|
|
|
}
|
|
|
|
|
/*
|
|
|
|
|
NSString *memInfo = [wrt_client getKey:stringData key:@"mem_info"];
|
|
|
|
|
|
|
|
|
|
[menuWanIP setTitle:wanip];
|
|
|
|
|
[menuUptime setTitle:uptime];
|
|
|
|
|
[menuLoad setTitle:load];
|
|
|
|
|
[menuLoad setHidden:false];
|
|
|
|
|
[menuClientsConnections setTitle:[NSString stringWithFormat:@"%@ Connection%@", ipconn, ([ipconn isEqualToString:@"1"] ? @"" : @"s")]];
|
|
|
|
|
// Remove any white spaces
|
|
|
|
|
NSArray *parts = [memInfo componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
|
|
|
|
|
NSArray *filteredArray = [parts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF != ''"]];
|
|
|
|
|
memInfo = [filteredArray componentsJoinedByString:@" "];
|
|
|
|
|
parts = nil;
|
|
|
|
|
filteredArray = nil;
|
|
|
|
|
|
|
|
|
|
// Remove any quotes
|
|
|
|
|
parts = [memInfo componentsSeparatedByCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"\'"]];
|
|
|
|
|
filteredArray = [parts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF != ''"]];
|
|
|
|
|
memInfo = [filteredArray componentsJoinedByString:@""];
|
|
|
|
|
|
|
|
|
|
NSArray *memData = [memInfo componentsSeparatedByString:@","];
|
|
|
|
|
unsigned long memTotal = strtoull([[memData objectAtIndex:17] UTF8String], NULL, 0);
|
|
|
|
|
unsigned long memFree = strtoull([[memData objectAtIndex:21] UTF8String], NULL, 0);
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) refreshMenu:(id)sender
|
|
|
|
@ -598,10 +626,11 @@
|
|
|
|
|
[clientMenu addItem:clientMenuItem];
|
|
|
|
|
|
|
|
|
|
// Connections
|
|
|
|
|
clientMenuItem = [[NSMenuItem alloc] initWithTitle:[clientsData objectAtIndex:(clientIndex+3)] action:nil keyEquivalent:@""];
|
|
|
|
|
unsigned long conn = strtoull([[clientsData objectAtIndex:(clientIndex+3)] UTF8String], NULL, 0);
|
|
|
|
|
clientMenuItem = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%d Connection%@", conn, (conn > 1 ? @"s" : @"")] action:nil keyEquivalent:@""];
|
|
|
|
|
[clientMenu addItem:clientMenuItem];
|
|
|
|
|
|
|
|
|
|
clientItem = [[NSMenuItem alloc] initWithTitle:[clientsData objectAtIndex:clientIndex] action:nil keyEquivalent:@""];
|
|
|
|
|
clientItem = [[NSMenuItem alloc] initWithTitle:[clientsData objectAtIndex:clientIndex] action:nil keyEquivalent:@""];
|
|
|
|
|
[clientItem setSubmenu:clientMenu];
|
|
|
|
|
|
|
|
|
|
[menuClients addItem:clientItem];
|
|
|
|
|