1
0
Fork 0

Added proper use of detected wan port, enabled status timer, modified license for CC BY-SH-NC

master
Matthieu Lalonde 14 years ago
parent f44983df4c
commit 051581253e

@ -2,8 +2,8 @@
// DDWRT_MonitorAppDelegate.h
// DDWRT-Monitor
//
// Created by Matthieu Lalonde on 11-05-27.
// Copyright 2011 __MyCompanyName__. All rights reserved.
// Created by Matthieu Lalonde & Spike Grobstein on 11-05-27.
// Copyleft 2011 Spurf CC BY-SH-NC. Some rights reserved.
//
#import <Cocoa/Cocoa.h>

@ -2,8 +2,8 @@
// DDWRT_MonitorAppDelegate.m
// DDWRT-Monitor
//
// Created by Matthieu Lalonde on 11-05-27.
// Copyright 2011 __MyCompanyName__. All rights reserved.
// Created by Matthieu Lalonde & Spike Grobstein on 11-05-27.
// Copyleft 2011 Spurf CC BY-SH-NC. Some rights reserved.
//
#import "DDWRT_MonitorAppDelegate.h"
@ -36,8 +36,9 @@
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];
NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client getWanPort]);
_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
[_readTimer fire];
//[self updateThroughput];
@ -219,7 +220,7 @@
//
[BandwidthViewer makeKeyAndOrderFront:nil];
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:@"ppp0"] retain];
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:[wrt_client getWanPort]] retain];
[ [BandwidthViewerWebView mainFrame] loadRequest: request ];
}
@ -324,7 +325,15 @@
- (void) updateThroughput:(NSTimer*)timer
{
NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client wanPort]);
NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client getWanPort]);
if ([wrt_client wrtReachable] == true && _wrtReachable == false) {
_wrtReachable = true;
[self showMenubarIcon:true];
} else if ([wrt_client wrtReachable] == false && _wrtReachable == true) {
_wrtReachable = false;
[self showMenubarIcon:false];
}
//WRTRequest *wrtr = [[WRTRequest alloc] init];
//[wrtr doRequest:self requestSelector:@selector(throughputCallback:) uri:@"fetchif.cgi?ppp1"];

@ -1,17 +0,0 @@
//
// WRTRequestParser.h
// DDWRT-Monitor
//
// Created by Matthieu Lalonde on 11-06-02.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface WRTRequestParser : NSObject {
@private
}
@end

@ -1,29 +0,0 @@
//
// WRTRequestParser.m
// DDWRT-Monitor
//
// Created by Matthieu Lalonde on 11-06-02.
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
#import "WRTRequestParser.h"
@implementation WRTRequestParser
- (id)init
{
self = [super init];
if (self) {
// Initialization code here.
}
return self;
}
- (void)dealloc
{
[super dealloc];
}
@end

@ -2,17 +2,17 @@
// WRTStatusClient.h
// DDWRT-Monitor
//
// Created by Spike Grobstein on 5/30/11.
// Copyright 2011 Sadistech. All rights reserved.
// Created by Matthieu Lalonde & Spike Grobstein on 11-05-27.
// Copyleft 2011 Spurf CC BY-SH-NC. Some rights reserved.
//
#import <Foundation/Foundation.h>
@interface WRTStatusClient : NSObject {
@private
BOOL wrtReachable;
NSString *wanPort;
@private
NSString *hostname;
NSString *protocol;
int port;
@ -29,7 +29,6 @@
}
@property BOOL wrtReachable;
@property(nonatomic, retain) NSString *wanPort;
@property(nonatomic, retain) NSMutableData *receivedData;
@property(nonatomic, retain) id delegate;
@ -45,6 +44,9 @@
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key;
- (NSString*) getWanPort;
- (void) setWanPort:(NSString*)new_wanport;
- (NSString*) getHostname;
- (void) setHostname:(NSString*)new_hostname;

@ -2,8 +2,8 @@
// WRTStatusClient.m
// DDWRT-Monitor
//
// Created by Spike Grobstein on 5/30/11.
// Copyright 2011 Sadistech. All rights reserved.
// Created by Matthieu Lalonde & Spike Grobstein on 11-05-27.
// Copyleft 2011 Spurf CC BY-SH-NC. Some rights reserved.
//
#import "WRTStatusClient.h"
@ -12,7 +12,6 @@
@implementation WRTStatusClient
@synthesize wrtReachable;
@synthesize wanPort;
@synthesize receivedData;
@synthesize delegate;
@ -30,6 +29,7 @@
[self setPassword: new_password];
wrtReachable = false;
wanPort = nil;
return self;
}
@ -106,7 +106,10 @@
startRange = [stringData rangeOfString:key];
stringData = [stringData substringFromIndex:(startRange.location + [key length])];
NSRange endRange = [stringData rangeOfString:@"\""];
wanPort = [stringData substringToIndex:endRange.location];
[self setWanPort:[stringData substringToIndex:endRange.location]];
} else {
wrtReachable = false;
wanPort = nil;
}
}
}
@ -142,6 +145,19 @@
#pragma mark -
#pragma mark Accessors:
- (NSString*) getWanPort
{
return wanPort;
}
- (void) setWanPort:(NSString*)new_wanport
{
NSString *old_wanport = hostname;
wanPort = [new_wanport retain];
[old_wanport autorelease];
}
- (NSString*) getHostname
{
return hostname;
@ -229,9 +245,7 @@
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
NSLog(@"3 %lu", [data length]);
[receivedData appendData:data];
NSLog(@"3 %lu", [receivedData length]);
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error

Loading…
Cancel
Save