1
0
Fork 0

Added some of the NSURL delegate methods

master
Matthieu Lalonde 13 years ago
parent 9ca91187d3
commit cc68591a5c

@ -19,9 +19,9 @@
IBOutlet WebView* BandwidthViewerWebView;
IBOutlet id configFieldHostname;
IBOutlet id configFieldProtocol;
IBOutlet id configFieldProtocolHTTP;
IBOutlet id configFieldProtocolHTTPS;
IBOutlet NSMatrix *configFieldProtocol;
IBOutlet NSButtonCell *configFieldProtocolHTTP;
IBOutlet NSButtonCell *configFieldProtocolHTTPS;
IBOutlet id configFieldPort;
IBOutlet id configFieldRefresh;
IBOutlet id configLabelRefresh;
@ -55,6 +55,7 @@
// application prefs:
NSString *hostname;
NSString *protocol;
int port;
NSString *username;
NSString *password;

@ -33,7 +33,7 @@
[self readDefaults];
// initialize the client
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port username:username password:password];
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port protocol:protocol username:username password:password];
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
//[_readTimer fire];
@ -59,7 +59,8 @@
{
NSLog(@"Creating new user defaults");
// do any other initialization you want to do here - e.g. the starting default values.
// do any other initialization you want to do here - e.g. the starting default values.
[defaults setValue:@"http" forKey:@"protocol"];
[defaults setValue:@"192.168.1.1" forKey:@"hostname"];
[defaults setInteger:80 forKey:@"port"];
[defaults setValue:@"" forKey:@"username"];
@ -82,6 +83,7 @@
- (void) readDefaults
{
hostname = [defaults valueForKey:@"hostname"];
protocol = [defaults valueForKey:@"protocol"];
port = [defaults integerForKey:@"port"];
username = [defaults valueForKey:@"username"];
password = [defaults valueForKey:@"password"];
@ -95,6 +97,7 @@
{
// do any other initialization you want to do here - e.g. the starting default values.
[defaults setValue:hostname forKey:@"hostname"];
[defaults setValue:protocol forKey:@"protocol"];
[defaults setInteger:port forKey:@"port"];
[defaults setValue:username forKey:@"username"];
[defaults setValue:password forKey:@"password"];
@ -157,7 +160,6 @@
- (void) setMenubarText:(NSString *)menubarText
{
// Todo set proper line height
NSFontManager *fontManager = [NSFontManager sharedFontManager];
NSFont *menuFont = [fontManager fontWithFamily:@"Lucida Grande" traits:NSBoldFontMask weight:10 size:8];
@ -182,6 +184,8 @@
[configFieldHostname setStringValue:hostname];
}
// TODO
[configFieldPort setIntValue:[defaults integerForKey:@"port"]];
[configFieldRefresh setIntegerValue:[defaults integerForKey:@"refreshTime"]];
@ -204,26 +208,23 @@
}
- (void) showBandwidthViewer:(id)sender
{
{
// NSString *urlAddress = [NSString stringWithFormat:@"https://%@:%d/graph_if.svg?ppp1",
// [[NSUserDefaults standardUserDefaults] stringForKey:@"hostname"],
// [[NSUserDefaults standardUserDefaults] integerForKey:@"port"]];
// NSLog(@"%@", urlAddress);
//
[BandwidthViewer makeKeyAndOrderFront:nil];
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:@"ppp1"] retain];
[ [BandwidthViewerWebView mainFrame] loadRequest: request ];
[BandwidthViewer makeKeyAndOrderFront:nil];
NSURLRequest *request = [[wrt_client requestForBandwidthViewerForInterface:@"ppp0"] retain];
[ [BandwidthViewerWebView mainFrame] loadRequest: request ];
}
- (void) hideBandwidthViewer:(id)sender
{
[BandwidthViewer orderOut:nil];
[BandwidthViewer release];
}
- (void) setConfigHostname:(id)sender
@ -314,9 +315,9 @@
port = [configFieldPort intValue];
[defaults setInteger:port forKey:@"port"];
NSLog(@"Got %@ for %@", hostname, [configFieldHostname stringValue]);
//NSLog(@"%@", [configFieldProtocol str]);
//NSLog(@"%d", [configFieldProtocol state]);
//NSLog(@"%d", [configFieldProtocolHTTP state]);
//NSLog(@"%d", [configFieldProtocolHTTPS state]);
refreshTime = [configFieldRefresh integerValue];
[defaults setInteger:refreshTime forKey:@"refreshTime"];
@ -408,11 +409,14 @@
//[wrtr doRequest:self requestSelector:@selector(wanRequestCallback:) uri:@"Status_Internet.live.asp"];
//[wrt_client getStatusUpdate:@"Status_Bandwidth.asp" delegate:wanRequestCallback];
[wrt_client getStatusUpdate:@"Status_Bandwidth.asp" delegate:self callback:@selector(wanRequestCallback:)];
}
- (void) wanRequestCallback:(NSData *)data
{
NSLog(@"Received callback for request");
NSLog(@"Length: %lu", [data length]);
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(@"%@", stringData);
/*

@ -558,6 +558,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{129, 55}, {125, 17}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="635692332"/>
<bool key="NSEnabled">YES</bool>
<object class="NSSliderCell" key="NSCell" id="272108650">
@ -585,6 +586,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 56}, {62, 14}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="166127716"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="341827300">
@ -618,6 +620,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{79, 56}, {45, 14}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="307276419"/>
<int key="NSTag">1</int>
<bool key="NSEnabled">YES</bool>
@ -637,6 +640,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{82, 125}, {171, 16}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="163286529"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="795612448">
@ -673,6 +677,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 125}, {62, 14}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="808975838"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="826089764">
@ -690,6 +695,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 105}, {62, 14}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="348326688"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="667385484">
@ -707,6 +713,7 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{82, 103}, {126, 18}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="925158413"/>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">1</int>
@ -721,7 +728,11 @@
<reference key="NSControlView" ref="348326688"/>
<int key="NSTag">1</int>
<int key="NSButtonFlags">1211912703</int>
<int key="NSButtonFlags2">0</int>
<int key="NSButtonFlags2">2</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
<string key="NSResourceName">NSRadioButton</string>
</object>
<object class="NSButtonImageSource" key="NSAlternateImage" id="649191357">
<string key="NSImageName">NSRadioButton</string>
</object>
@ -743,7 +754,7 @@
<int key="NSPeriodicInterval">75</int>
</object>
</object>
<string key="NSCellSize">{61, 18}</string>
<string key="NSCellSize">{56, 18}</string>
<string key="NSIntercellSpacing">{4, 2}</string>
<int key="NSMatrixFlags">1151868928</int>
<string key="NSCellClass">NSActionCell</string>
@ -816,6 +827,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{82, 82}, {39, 16}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1066090534"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="794333226">
@ -835,6 +847,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 82}, {62, 14}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="1065807232"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="1037922107">
@ -852,6 +865,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 32}, {74, 18}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="170030078"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="809457279">
@ -880,6 +894,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{15, 12}, {76, 18}}</string>
<reference key="NSSuperview" ref="812058280"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="371817589"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="1072996452">
@ -901,11 +916,13 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{1, 1}, {272, 152}}</string>
<reference key="NSSuperview" ref="306918856"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="588704663"/>
</object>
</object>
<string key="NSFrame">{{17, 41}, {274, 168}}</string>
<reference key="NSSuperview" ref="284387334"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="812058280"/>
<string key="NSOffsets">{0, 0}</string>
<object class="NSTextFieldCell" key="NSTitleCell">
@ -930,6 +947,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{156, 195}, {135, 17}}</string>
<reference key="NSSuperview" ref="284387334"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="7094024"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="190007600">
@ -950,6 +968,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">289</int>
<string key="NSFrame">{{213, 20}, {75, 17}}</string>
<reference key="NSSuperview" ref="284387334"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="373752751">
<int key="NSCellFlags">-2080244224</int>
@ -970,6 +990,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{130, 20}, {75, 17}}</string>
<reference key="NSSuperview" ref="284387334"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="179819426"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="367012609">
@ -992,6 +1013,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<object class="NSPSMatrix" key="NSDrawMatrix"/>
<string key="NSFrame">{{20, 20}, {16, 16}}</string>
<reference key="NSSuperview" ref="284387334"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="184594776"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<int key="NSpiFlags">20746</int>
@ -1000,6 +1022,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{7, 11}, {308, 232}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="306918856"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2048, 1130}}</string>
@ -1050,26 +1073,31 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrameSize">{555, 275}</string>
<reference key="NSSuperview" ref="40768770"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSViewIsLayerTreeHost">YES</bool>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<string key="FrameName"/>
<string key="GroupName"/>
<object class="WebPreferences" key="Preferences">
<string key="Identifier"/>
<string key="Identifier">BandwidthViewer</string>
<object class="NSMutableDictionary" key="Values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>WebKitDefaultFixedFontSize</string>
<string>WebKitDefaultFontSize</string>
<string>WebKitMinimumFontSize</string>
<string>BandwidthViewerWebKitDefaultFixedFontSize</string>
<string>BandwidthViewerWebKitDefaultFontSize</string>
<string>BandwidthViewerWebKitJavaEnabled</string>
<string>BandwidthViewerWebKitJavaScriptCanOpenWindowsAutomatically</string>
<string>BandwidthViewerWebKitJavaScriptEnabled</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="12"/>
<integer value="12"/>
<integer value="1"/>
<integer value="14"/>
<boolean value="NO"/>
<boolean value="NO"/>
<boolean value="YES"/>
</object>
</object>
</object>
@ -1079,6 +1107,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<string key="NSFrame">{{7, 11}, {555, 275}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="519676712"/>
<bool key="NSViewIsLayerTreeHost">YES</bool>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
</object>
@ -1444,14 +1474,6 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">805</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1033903501"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">806</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">menuWanTrafficIn</string>
@ -1484,6 +1506,38 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
<int key="connectionID">810</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">configFieldProtocol</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="348326688"/>
</object>
<int key="connectionID">811</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="492386921"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">812</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1033903501"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">813</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="206781734"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">814</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
@ -2536,9 +2590,313 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">810</int>
<int key="maxID">814</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">DDWRT_MonitorAppDelegate</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="actions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>refreshClientsMenu:</string>
<string>refreshMenu:</string>
<string>refreshSystemMenu:</string>
<string>refreshWanMenu:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>refreshClientsMenu:</string>
<string>refreshMenu:</string>
<string>refreshSystemMenu:</string>
<string>refreshWanMenu:</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBActionInfo">
<string key="name">refreshClientsMenu:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">refreshMenu:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">refreshSystemMenu:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo">
<string key="name">refreshWanMenu:</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>AppMenu</string>
<string>BandwidthViewer</string>
<string>BandwidthViewerWebView</string>
<string>ConfigPanel</string>
<string>configButtonSave</string>
<string>configFieldHostname</string>
<string>configFieldPort</string>
<string>configFieldProtocol</string>
<string>configFieldProtocolHTTP</string>
<string>configFieldProtocolHTTPS</string>
<string>configFieldRefresh</string>
<string>configFieldShowIcon</string>
<string>configFieldUseBytes</string>
<string>configLabelRefresh</string>
<string>configLabelStatus</string>
<string>configStateStatus</string>
<string>menuConnections</string>
<string>menuLoad</string>
<string>menuUptime</string>
<string>menuWanBandwidthGraph</string>
<string>menuWanDNS</string>
<string>menuWanDNSItem0</string>
<string>menuWanDNSItem1</string>
<string>menuWanDNSItem2</string>
<string>menuWanIP</string>
<string>menuWanSeparator</string>
<string>menuWanStatus</string>
<string>menuWanTrafficIn</string>
<string>menuWanTrafficOut</string>
<string>menuWanUptime</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenu</string>
<string>NSPanel</string>
<string>WebView</string>
<string>NSPanel</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>NSMatrix</string>
<string>NSButtonCell</string>
<string>NSButtonCell</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>NSProgressIndicator</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
<string>id</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>AppMenu</string>
<string>BandwidthViewer</string>
<string>BandwidthViewerWebView</string>
<string>ConfigPanel</string>
<string>configButtonSave</string>
<string>configFieldHostname</string>
<string>configFieldPort</string>
<string>configFieldProtocol</string>
<string>configFieldProtocolHTTP</string>
<string>configFieldProtocolHTTPS</string>
<string>configFieldRefresh</string>
<string>configFieldShowIcon</string>
<string>configFieldUseBytes</string>
<string>configLabelRefresh</string>
<string>configLabelStatus</string>
<string>configStateStatus</string>
<string>menuConnections</string>
<string>menuLoad</string>
<string>menuUptime</string>
<string>menuWanBandwidthGraph</string>
<string>menuWanDNS</string>
<string>menuWanDNSItem0</string>
<string>menuWanDNSItem1</string>
<string>menuWanDNSItem2</string>
<string>menuWanIP</string>
<string>menuWanSeparator</string>
<string>menuWanStatus</string>
<string>menuWanTrafficIn</string>
<string>menuWanTrafficOut</string>
<string>menuWanUptime</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">AppMenu</string>
<string key="candidateClassName">NSMenu</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">BandwidthViewer</string>
<string key="candidateClassName">NSPanel</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">BandwidthViewerWebView</string>
<string key="candidateClassName">WebView</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">ConfigPanel</string>
<string key="candidateClassName">NSPanel</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configButtonSave</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldHostname</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldPort</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldProtocol</string>
<string key="candidateClassName">NSMatrix</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldProtocolHTTP</string>
<string key="candidateClassName">NSButtonCell</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldProtocolHTTPS</string>
<string key="candidateClassName">NSButtonCell</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldRefresh</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldShowIcon</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configFieldUseBytes</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configLabelRefresh</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configLabelStatus</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">configStateStatus</string>
<string key="candidateClassName">NSProgressIndicator</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuConnections</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuLoad</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuUptime</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanBandwidthGraph</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanDNS</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanDNSItem0</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanDNSItem1</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanDNSItem2</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanIP</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanSeparator</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanStatus</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanTrafficIn</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanTrafficOut</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">menuWanUptime</string>
<string key="candidateClassName">id</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/DDWRT_MonitorAppDelegate.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">WebView</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">reloadFromOrigin:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">reloadFromOrigin:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">reloadFromOrigin:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/WebView.h</string>
</object>
</object>
</object>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes"/>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
@ -2557,12 +2915,14 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSMenuCheckmark</string>
<string>NSMenuMixedState</string>
<string>NSRadioButton</string>
<string>NSSwitch</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>{9, 8}</string>
<string>{7, 2}</string>
<string>{16, 15}</string>
<string>{15, 15}</string>
</object>
</object>

@ -13,28 +13,37 @@
BOOL wrtReachable;
@private
NSString *hostname;
NSString *protocol;
int port;
NSString *username;
NSString *password;
//NSMutableData *receivedData;
//NSURLRequest *theRequest;
//NSURLConnection *theConnection;
NSMutableData *receivedData;
NSURLRequest *theRequest;
NSURLConnection *theConnection;
//id delegate;
//SEL callback;
//SEL errorCallback;
id delegate;
SEL callback;
SEL errorCallback;
}
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port username:(NSString*)new_username password:(NSString*)new_password;
@property(nonatomic, retain) NSMutableData *receivedData;
@property(nonatomic, retain) id delegate;
@property(nonatomic) SEL callback;
@property(nonatomic) SEL errorCallback;
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port protocol:(NSString*)new_protocol username:(NSString*)new_username password:(NSString*)new_password;
- (NSMutableURLRequest*) buildRequest:(NSString*)uri;
- (NSMutableURLRequest*) requestForBandwidthViewerForInterface:(NSString*)interface;
- (void) getStatusUpdate:(NSString*)uri delegate:(id)delegate;
- (void) getStatusUpdate:(NSString*)uri delegate:(id)requestDelegate callback:(SEL)requestSelector;
- (NSString*) getHostname;
- (void) setHostname:(NSString*)new_hostname;
- (NSString*) getProtocol;
- (void) setProtocol:(NSString*)new_protocol;
- (int) getPort;
- (void) setPort:(int)new_port;

@ -11,39 +11,45 @@
@implementation WRTStatusClient
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port username:(NSString*)new_username password:(NSString*)new_password
@synthesize receivedData;
@synthesize delegate;
@synthesize callback;
@synthesize errorCallback;
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port protocol:(NSString*)new_protocol username:(NSString*)new_username password:(NSString*)new_password
{
self = [super init];
[self setHostname: new_hostname];
[self setPort: new_port];
[self setUsername: new_username];
[self setPassword: new_password];
return self;
self = [super init];
[self setHostname: new_hostname];
[self setProtocol: new_protocol];
[self setPort: new_port];
[self setUsername: new_username];
[self setPassword: new_password];
return self;
}
#pragma mark -
- (NSMutableURLRequest*) buildRequest:(NSString*)uri
{
NSString *urlAddress = [NSString stringWithFormat:@"http://%@:%@@%@:%d/%@",
username,
password,
hostname,
port,
uri];
NSString *urlAddress = [NSString stringWithFormat:@"%@://%@:%@@%@:%d/%@",
protocol,
username,
password,
hostname,
port,
uri];
NSLog(@"Building request form %@", urlAddress);
NSURL *url = [NSURL URLWithString:urlAddress];
//[self request:url]; // ---V
theRequest = [[NSMutableURLRequest alloc] initWithURL: url];
NSURLRequest *theRequest;
theRequest = [[NSMutableURLRequest alloc] initWithURL: url];
return [theRequest autorelease];
return [theRequest autorelease];
}
- (NSMutableURLRequest*) requestForBandwidthViewerForInterface:(NSString*)interface
@ -53,17 +59,22 @@
return [self buildRequest:endpoint];
}
- (void) getStatusUpdate:(NSString*)uri delegate:(id)delegate
- (void) getStatusUpdate:(NSString*)uri delegate:(id)requestDelegate callback:(SEL)requestSelector
{
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:[self buildRequest: uri] delegate:delegate];
self.delegate = requestDelegate;
self.callback = requestSelector;
theConnection = [[NSURLConnection alloc] initWithRequest:[self buildRequest: uri] delegate:self];
if (theConnection) {
receivedData = [[NSMutableData data] retain];
}
[theConnection autorelease];
// this function returns immediately
// the delegate will receive a function call with the following signature upon completion:
// - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
// this function returns immediately
// the delegate will receive a function call with the following signature upon completion:
// - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
}
@ -82,6 +93,18 @@
[old_hostname autorelease];
}
- (NSString*) getProtocol
{
return protocol;
}
- (void) setProtocol:(NSString *)new_protocol
{
NSString *old_protocol = protocol;
protocol = [new_protocol retain];
[old_protocol autorelease];
}
- (int) getPort
{
return port;
@ -116,5 +139,72 @@
[old_password autorelease];
}
#pragma mark -
#pragma mark NSURLConnection Delegate Methods:
-(void)connection:(NSURLConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge
{
NSLog(@"1");
if ([challenge previousFailureCount] == 0) {
NSLog(@"1.1.1");
NSURLCredential *newCredential;
newCredential = [NSURLCredential credentialWithUser:username password:password persistence:NSURLCredentialPersistenceForSession];
NSLog(@"1.1.2");
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
} else {
NSLog(@"1.2");
[[challenge sender] cancelAuthenticationChallenge:challenge];
// TODO Pop up authentication error
NSLog(@"Invalid Username or Password");
}
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
NSLog(@"2");
[receivedData setLength:0];
}
-(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
{
NSLog(@"4");
//[connection release];
//[receivedData release];
//[theRequest release];
//TODO Return alert
NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
if (errorCallback) {
[delegate performSelector:errorCallback withObject:error];
}
}
-(void)connectionDidFinishLoading:(NSURLConnection *)connection
{
NSLog(@"5");
// TODO: Return the data
if (delegate && callback) {
if ([delegate respondsToSelector:self.callback]) {
[delegate performSelector:self.callback withObject:receivedData];
} else {
// TODO: Return no data
NSLog(@"No response data from delegate");
}
} else {
NSLog(@"Invalid delegate callback");
}
//[theConnection release];
//[receivedData release];
//[theRequest release];
}
@end

Loading…
Cancel
Save