1
0
Fork 0

More tweaking

Enabled keychain check, that is if the credentials already exist they will be used, otherwise it still needs to be in the plist
master
Matthieu Lalonde 14 years ago
parent 2afe6fad40
commit cb418d81fe

@ -310,7 +310,7 @@
if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) { if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) {
[self hideMenubarIcon]; [self hideMenubarIcon];
} else if ([configFieldShowIcon state] == NSOnState && [defaults boolForKey:@"showMenuIcon"] == false) { } else if ([configFieldShowIcon state] == NSOnState && [defaults boolForKey:@"showMenuIcon"] == false) {
[self showMenubarIcon:false]; [self showMenubarIcon:[wrt_client wrtReachable]];
} }
showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false); showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false);
@ -388,25 +388,53 @@
[wrt_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(wanRequestCallback:)]; [wrt_client getStatusUpdate:@"Status_Internet.live.asp" delegate:self callback:@selector(wanRequestCallback:)];
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", stringData);
NSString *ipconn = [wrt_client getKey:stringData key:@"ip_conntrack"]; 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"]; NSString *wanip = [wrt_client getKey:stringData key:@"ipinfo"];
NSRange startRange = [wanip rangeOfString:@" "]; NSRange startRange = [wanip rangeOfString:@" "];
wanip = [wanip substringFromIndex:(startRange.location+1)]; wanip = [wanip substringFromIndex:(startRange.location+1)];
[menuWanIP setTitle:wanip];
NSString *uptime = [wrt_client getKey:stringData key:@"uptime"]; NSString *uptime = [wrt_client getKey:stringData key:@"uptime"];
NSString *loadSplit = @", load average: "; NSString *loadSplit = @", load average: ";
if ([uptime length] > 0) {
NSString *load = [uptime substringFromIndex:[uptime rangeOfString:loadSplit].location+[loadSplit length]]; NSString *load = [uptime substringFromIndex:[uptime rangeOfString:loadSplit].location+[loadSplit length]];
uptime = [uptime substringToIndex:[uptime rangeOfString:@", load"].location]; // Cut the load uptime = [uptime substringToIndex:[uptime rangeOfString:@", load"].location]; // Cut the load
uptime = [uptime substringFromIndex:[uptime rangeOfString:@" "].location+1]; // Trim uptime = [uptime substringFromIndex:[uptime rangeOfString:@" "].location+1]; // Trim
uptime = [uptime stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[uptime substringToIndex:1] uppercaseString]]; // UCFirst uptime = [uptime stringByReplacingCharactersInRange:NSMakeRange(0,1) withString:[[uptime substringToIndex:1] uppercaseString]]; // UCFirst
[menuWanIP setTitle:wanip];
[menuUptime setTitle:uptime]; [menuUptime setTitle:uptime];
//[menuUptime setHidden:false];
[menuLoad setTitle:load]; [menuLoad setTitle:load];
[menuLoad setHidden:false]; [menuLoad setHidden:false];
[menuClientsConnections setTitle:[NSString stringWithFormat:@"%@ Connection%@", ipconn, ([ipconn isEqualToString:@"1"] ? @"" : @"s")]]; //[[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"];
// 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 - (void) refreshMenu:(id)sender
@ -598,7 +626,8 @@
[clientMenu addItem:clientMenuItem]; [clientMenu addItem:clientMenuItem];
// Connections // 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]; [clientMenu addItem:clientMenuItem];
clientItem = [[NSMenuItem alloc] initWithTitle:[clientsData objectAtIndex:clientIndex] action:nil keyEquivalent:@""]; clientItem = [[NSMenuItem alloc] initWithTitle:[clientsData objectAtIndex:clientIndex] action:nil keyEquivalent:@""];

@ -7,7 +7,7 @@
// //
#import "WRTStatusClient.h" #import "WRTStatusClient.h"
#import <Security/Security.h>
@implementation WRTStatusClient @implementation WRTStatusClient
@ -233,21 +233,21 @@
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace - (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{ {
return YES; // FIXME Turning this to NO should use keychain, but it doesn't return NO; // FIXME Turning this to NO should use keychain, but it doesn't
} }
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection - (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{ {
return YES; return YES;
} }
/*
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge -(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{ {
NSLog(@"1"); NSLog(@"1");
if ([challenge previousFailureCount] == 0) { if ([challenge previousFailureCount] == 0) {
NSLog(@"1.1.1"); NSLog(@"1.1.1");
NSURLCredential *newCredential; NSURLCredential *newCredential;
newCredential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession]; newCredential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistencePermanent];
NSLog(@"1.1.2"); NSLog(@"1.1.2");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge]; [[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
@ -259,7 +259,7 @@
NSLog(@"Invalid Username or Password"); NSLog(@"Invalid Username or Password");
} }
} }
*/
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{ {
//NSLog(@"2"); //NSLog(@"2");

Loading…
Cancel
Save