1
0
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

120 lines
2.4 KiB

14 years ago
//
// WRTStatusClient.m
// DDWRT-Monitor
//
// Created by Spike Grobstein on 5/30/11.
// Copyright 2011 Sadistech. All rights reserved.
//
#import "WRTStatusClient.h"
@implementation WRTStatusClient
14 years ago
- (id) initWithHostname:(NSString*)new_hostname port:(NSInteger*)new_port username:(NSString*)new_username password:(NSString*)new_password
14 years ago
{
self = [super init];
[self setHostname: new_hostname];
[self setPort: new_port];
[self setUsername: new_username];
[self setPassword: new_password];
return self;
}
#pragma mark -
- (NSMutableURLRequest*) buildRequest:(NSString*)uri
{
14 years ago
NSString *urlAddress = [NSString stringWithFormat:@"http://%@:%@@%@:%d/%@",
username,
password,
14 years ago
hostname,
port,
uri];
NSURL *url = [NSURL URLWithString:urlAddress];
//[self request:url]; // ---V
NSURLRequest *theRequest;
theRequest = [[NSMutableURLRequest alloc] initWithURL: url];
return [theRequest autorelease];
}
- (NSMutableURLRequest*) requestForBandwidthViewerForInterface:(NSString*)interface
{
14 years ago
NSString *endpoint = [NSString stringWithFormat:@"graph_if.svg?%@", interface];
14 years ago
return [self buildRequest:endpoint];
}
14 years ago
- (void) getStatusUpdate:(NSString*)uri delegate:(id)delegate
14 years ago
{
14 years ago
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:[self buildRequest: uri] delegate:delegate];
14 years ago
[theConnection autorelease];
14 years ago
// this function returns immediately
// the delegate will receive a function call with the following signature upon completion:
// - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
}
#pragma mark -
#pragma mark Accessors:
- (NSString*) getHostname
{
14 years ago
return hostname;
14 years ago
}
- (void) setHostname:(NSString*)new_hostname
{
14 years ago
NSString *old_hostname = hostname;
hostname = [new_hostname retain];
[old_hostname autorelease];
14 years ago
}
14 years ago
- (NSInteger *) getPort
14 years ago
{
14 years ago
return port;
14 years ago
}
14 years ago
- (void) setPort:(NSInteger *)new_port
14 years ago
{
14 years ago
port = new_port;
14 years ago
}
- (NSString*) getUsername
{
14 years ago
return username;
14 years ago
}
- (void) setUsername:(NSString*)new_username
{
14 years ago
NSString *old_username = username;
username = [new_username retain];
[old_username autorelease];
14 years ago
}
- (NSString*) getPassword
{
14 years ago
return password;
14 years ago
}
- (void) setPassword:(NSString*)new_password
{
14 years ago
NSString *old_password = password;
password = [new_password retain];
[old_password autorelease];
14 years ago
}
@end