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.

121 lines
2.4 KiB

13 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
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port username:(NSString*)new_username password:(NSString*)new_password
13 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
{
13 years ago
NSString *urlAddress = [NSString stringWithFormat:@"http://%@:%@@%@:%d/%@",
username,
password,
13 years ago
hostname,
port,
uri];
NSLog(@"Building request form %@", urlAddress);
13 years ago
NSURL *url = [NSURL URLWithString:urlAddress];
//[self request:url]; // ---V
NSURLRequest *theRequest;
theRequest = [[NSMutableURLRequest alloc] initWithURL: url];
return [theRequest autorelease];
}
- (NSMutableURLRequest*) requestForBandwidthViewerForInterface:(NSString*)interface
{
13 years ago
NSString *endpoint = [NSString stringWithFormat:@"graph_if.svg?%@", interface];
13 years ago
return [self buildRequest:endpoint];
}
13 years ago
- (void) getStatusUpdate:(NSString*)uri delegate:(id)delegate
13 years ago
{
13 years ago
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:[self buildRequest: uri] delegate:delegate];
13 years ago
[theConnection autorelease];
13 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
{
13 years ago
return hostname;
13 years ago
}
- (void) setHostname:(NSString*)new_hostname
{
13 years ago
NSString *old_hostname = hostname;
hostname = [new_hostname retain];
[old_hostname autorelease];
13 years ago
}
- (int) getPort
13 years ago
{
13 years ago
return port;
13 years ago
}
- (void) setPort:(int)new_port
13 years ago
{
13 years ago
port = new_port;
13 years ago
}
- (NSString*) getUsername
{
13 years ago
return username;
13 years ago
}
- (void) setUsername:(NSString*)new_username
{
13 years ago
NSString *old_username = username;
username = [new_username retain];
[old_username autorelease];
13 years ago
}
- (NSString*) getPassword
{
13 years ago
return password;
13 years ago
}
- (void) setPassword:(NSString*)new_password
{
13 years ago
NSString *old_password = password;
password = [new_password retain];
[old_password autorelease];
13 years ago
}
@end