1
0
Fork 0

Sorry but... bunch of stuff and some left overs for later...

master
Matthieu Lalonde 14 years ago
parent 140c7a6bdd
commit f4dfc568e1

@ -0,0 +1,420 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">10J869</string>
<string key="IBDocument.InterfaceBuilderVersion">1306</string>
<string key="IBDocument.AppKitVersion">1038.35</string>
<string key="IBDocument.HIToolboxVersion">461.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1306</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSView</string>
<string>NSForm</string>
<string>NSWindowTemplate</string>
<string>NSFormCell</string>
<string>NSButtonCell</string>
<string>NSButton</string>
<string>NSCustomObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.values" ref="0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">NSObject</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="754296154">
<string key="NSClassName">WRTStatusClient</string>
</object>
<object class="NSWindowTemplate" id="951097172">
<int key="NSWindowStyleMask">1</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{320, 343}, {340, 115}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">WRT Login</string>
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<object class="NSView" key="NSWindowView" id="758866843">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSForm" id="461501777">
<reference key="NSNextResponder" ref="758866843"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{20, 43}, {300, 52}}</string>
<reference key="NSSuperview" ref="758866843"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="139921341"/>
<int key="NSViewLayerContentsRedrawPolicy">2</int>
<bool key="NSEnabled">YES</bool>
<int key="NSNumRows">2</int>
<int key="NSNumCols">1</int>
<object class="NSMutableArray" key="NSCells">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSFormCell" id="580960606">
<int key="NSCellFlags">343014977</int>
<int key="NSCellFlags2">205521920</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="787405369">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">13</double>
<int key="NSfFlags">1044</int>
</object>
<reference key="NSControlView" ref="461501777"/>
<double key="NSTitleWidth">70.93603515625</double>
<object class="NSCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">67108864</int>
<string key="NSContents">Username:</string>
<reference key="NSSupport" ref="787405369"/>
<reference key="NSControlView" ref="461501777"/>
</object>
</object>
<object class="NSFormCell" id="560111005">
<int key="NSCellFlags">343014977</int>
<int key="NSCellFlags2">205521920</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="787405369"/>
<reference key="NSControlView" ref="461501777"/>
<int key="NSTag">1</int>
<double key="NSTitleWidth">70.93603515625</double>
<object class="NSCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">67108864</int>
<string key="NSContents">Password:</string>
<reference key="NSSupport" ref="787405369"/>
<reference key="NSControlView" ref="461501777"/>
</object>
</object>
</object>
<string key="NSCellSize">{300, 22}</string>
<string key="NSIntercellSpacing">{1, 8}</string>
<int key="NSMatrixFlags">67633152</int>
<string key="NSCellClass">NSActionCell</string>
<object class="NSFormCell" key="NSProtoCell" id="202400798">
<int key="NSCellFlags">343014976</int>
<int key="NSCellFlags2">205521920</int>
<string key="NSContents"/>
<reference key="NSSupport" ref="787405369"/>
<double key="NSTitleWidth">70.93603515625</double>
<object class="NSCell" key="NSTitleCell">
<int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">67108864</int>
<string key="NSContents">Field:</string>
<reference key="NSSupport" ref="787405369"/>
</object>
</object>
<int key="NSSelectedRow">-1</int>
<int key="NSSelectedCol">-1</int>
<object class="NSColor" key="NSBackgroundColor">
<int key="NSColorSpace">6</int>
<string key="NSCatalogName">System</string>
<string key="NSColorName">controlColor</string>
<object class="NSColor" key="NSColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MC42NjY2NjY2NjY3AA</bytes>
</object>
</object>
<object class="NSColor" key="NSCellBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<reference key="NSFont" ref="787405369"/>
</object>
<object class="NSButton" id="139921341">
<reference key="NSNextResponder" ref="758866843"/>
<int key="NSvFlags">268</int>
<string key="NSFrame">{{260, 18}, {60, 17}}</string>
<reference key="NSSuperview" ref="758866843"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="185560641">
<int key="NSCellFlags">-2080244224</int>
<int key="NSCellFlags2">134348800</int>
<string key="NSContents">Login</string>
<object class="NSFont" key="NSSupport">
<string key="NSName">LucidaGrande</string>
<double key="NSSize">11</double>
<int key="NSfFlags">3100</int>
</object>
<reference key="NSControlView" ref="139921341"/>
<int key="NSButtonFlags">-2038152961</int>
<int key="NSButtonFlags2">164</int>
<string key="NSAlternateContents"/>
<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
</object>
</object>
<string key="NSFrame">{{7, 11}, {340, 115}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="461501777"/>
</object>
<string key="NSScreenRect">{{0, 0}, {2048, 1130}}</string>
<string key="NSMaxSize">{1e+13, 1e+13}</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="951097172"/>
<reference key="destination" ref="754296154"/>
</object>
<int key="connectionID">19</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">credentialsView</string>
<reference key="source" ref="754296154"/>
<reference key="destination" ref="758866843"/>
</object>
<int key="connectionID">20</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">hideCredentialsWindow</string>
<reference key="source" ref="754296154"/>
<reference key="destination" ref="139921341"/>
</object>
<int key="connectionID">24</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">11</int>
<reference key="object" ref="754296154"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="951097172"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="758866843"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">14</int>
<reference key="object" ref="758866843"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="461501777"/>
<reference ref="139921341"/>
</object>
<reference key="parent" ref="951097172"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="461501777"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="202400798"/>
<reference ref="580960606"/>
<reference ref="560111005"/>
</object>
<reference key="parent" ref="758866843"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">16</int>
<reference key="object" ref="202400798"/>
<reference key="parent" ref="461501777"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">17</int>
<reference key="object" ref="580960606"/>
<reference key="parent" ref="461501777"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">18</int>
<reference key="object" ref="560111005"/>
<reference key="parent" ref="461501777"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">21</int>
<reference key="object" ref="139921341"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="185560641"/>
</object>
<reference key="parent" ref="758866843"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">22</int>
<reference key="object" ref="185560641"/>
<reference key="parent" ref="139921341"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>11.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>13.NSWindowTemplate.visibleAtLaunch</string>
<string>14.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>16.IBPluginDependency</string>
<string>17.IBPluginDependency</string>
<string>18.CustomClassName</string>
<string>18.IBPluginDependency</string>
<string>21.IBPluginDependency</string>
<string>22.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>NSSecureTextFormCell</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">24</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">WRTStatusClient</string>
<string key="superclassName">NSObject</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>buttonLogin</string>
<string>credentialsWindow</string>
<string>fieldPassword</string>
<string>fieldUsername</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSButton</string>
<string>NSWindow</string>
<string>NSSecureTextFieldCell</string>
<string>NSFormCell</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>buttonLogin</string>
<string>credentialsWindow</string>
<string>fieldPassword</string>
<string>fieldUsername</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">buttonLogin</string>
<string key="candidateClassName">NSButton</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">credentialsWindow</string>
<string key="candidateClassName">NSWindow</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">fieldPassword</string>
<string key="candidateClassName">NSSecureTextFieldCell</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">fieldUsername</string>
<string key="candidateClassName">NSFormCell</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/WRTStatusClient.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>

@ -17,6 +17,7 @@
F2511F5C13914A120053990C /* MenuIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = F2511F5B13914A120053990C /* MenuIcon.png */; };
F2511FFB1391543E0053990C /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F2511FFA1391543E0053990C /* WebKit.framework */; };
F25120A213918CD10053990C /* AppIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = F25120A113918CD10053990C /* AppIcon.icns */; };
F2736BD0139BDAC20019957B /* CredenialsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = F2736BCF139BDAC20019957B /* CredenialsView.xib */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@ -38,6 +39,7 @@
F2511F5B13914A120053990C /* MenuIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = MenuIcon.png; sourceTree = "<group>"; };
F2511FFA1391543E0053990C /* WebKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = WebKit.framework; path = System/Library/Frameworks/WebKit.framework; sourceTree = SDKROOT; };
F25120A113918CD10053990C /* AppIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = AppIcon.icns; sourceTree = "<group>"; };
F2736BCF139BDAC20019957B /* CredenialsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CredenialsView.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -120,6 +122,7 @@
8D1107310486CEB800E47090 /* DDWRT_Monitor-Info.plist */,
089C165CFE840E0CC02AAC07 /* InfoPlist.strings */,
1DDD58140DA1D0A300B32029 /* MainMenu.xib */,
F2736BCF139BDAC20019957B /* CredenialsView.xib */,
);
name = Resources;
sourceTree = "<group>";
@ -190,6 +193,7 @@
F2511F5C13914A120053990C /* MenuIcon.png in Resources */,
F25120A213918CD10053990C /* AppIcon.icns in Resources */,
F215851213931CF000853C55 /* MenuIconDisabled.png in Resources */,
F2736BD0139BDAC20019957B /* CredenialsView.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

@ -120,6 +120,8 @@
- (void) cbClientsRequest:(NSData *)data;
- (void) saveConfig:(id)sender;
- (void) updateStatus;
- (void) updateThroughput:(NSTimer *)timer;
- (void) throughputCallback:(NSData *)data;
- (void) doUpdateStatus:(NSData *)data;

@ -19,8 +19,6 @@
// Insert code here to initialize your application
[self showMenubar];
_wrtReachable = false;
defaults = [NSUserDefaults standardUserDefaults];
// check if the app is configured yet
@ -39,8 +37,9 @@
// initialize the client
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port protocol:protocol username:username password:password];
[wrt_client registerStatusCallback:self callback:@selector(updateStatus)];
[wrt_client getConnectionStatus];
[self updateThroughput:nil];
}
- (void) deinitialize
@ -127,8 +126,8 @@
{
NSLog(@"Showing Menu Item");
NSStatusBar* bar = [NSStatusBar systemStatusBar];
_appMenu = [bar statusItemWithLength:NSVariableStatusItemLength];
NSStatusBar *bar = [NSStatusBar systemStatusBar];
_appMenu = [bar statusItemWithLength:NSVariableStatusItemLength];
[_appMenu setAction:@selector(refreshMenu:)];
[_appMenu setTarget:self];
[_appMenu retain];
@ -147,9 +146,9 @@
- (void) hideMenubar
{
[_appMenu release];
_appMenu = nil;
_appMenu = nil;
[AppMenu release];
AppMenu = nil;
AppMenu = nil;
}
- (void) showMenubarIcon:(BOOL)enabled
@ -208,7 +207,6 @@
[configFieldProtocolHTTPS setState:1];
}
[ConfigPanel makeKeyAndOrderFront:nil];
}
@ -288,6 +286,30 @@
}
- (void) refreshMenu:(id)sender
{
NSLog(@"Refresh Menu");
if ([wrt_client getWrtReachable] == true) {
[_readTimer invalidate];
_readTimer = nil;
[wrt_client getStatusUpdate:@"Status_Router.live.asp" delegate:self callback:@selector(doUpdateStatus:)];
} else {
[_appMenu popUpStatusItemMenu:AppMenu];
}
}
- (void) refreshSystemMenu:(id)sender
{
}
- (void) refreshWanMenu:(id)sender
{
}
- (void) saveConfig:(id)sender
{
[self deinitialize];
@ -295,9 +317,9 @@
[configStateStatus startAnimation:nil];
[configStateStatus setHidden:false];
hostname = [configFieldHostname stringValue];
hostname = [configFieldHostname stringValue];
port = [configFieldPort intValue];
port = [configFieldPort intValue];
if ([configFieldProtocolHTTP state] == 1) {
protocol = @"http";
@ -305,15 +327,9 @@
protocol = @"https";
}
refreshTime = [configFieldRefresh integerValue];
refreshTime = [configFieldRefresh integerValue];
useBytes = ([configFieldUseBytes state] == 1 ? true: false);
if ([configFieldShowIcon state] == NSOffState && [defaults boolForKey:@"showMenuIcon"] == true) {
[self hideMenubarIcon];
} else if ([configFieldShowIcon state] == NSOnState && [defaults boolForKey:@"showMenuIcon"] == false) {
[self showMenubarIcon:[wrt_client wrtReachable]];
}
useBytes = ([configFieldUseBytes state] == 1 ? true: false);
showMenuIcon = ([configFieldShowIcon state] == 1 ? true: false);
@ -329,44 +345,44 @@
[self hideConfigPanel:nil];
}
- (void) updateThroughput:(NSTimer *)timer
- (void) updateStatus
{
//NSLog(@"Status %@ wan port: %@", ([wrt_client wrtReachable] ? @"Up" : @"Down"), [wrt_client getWanPort]);
if ([wrt_client wrtReachable] == true && _wrtReachable == false) {
_wrtReachable = true;
NSLog(@"Status %@ wan port: %@", ([wrt_client getWrtReachable] ? @"Up" : @"Down"), [wrt_client getWanPort]);
if ([wrt_client getWrtReachable] == true) {
if (showMenuIcon == true) {
[self showMenubarIcon:true];
} else {
[self hideMenubarIcon];
}
} else if ([wrt_client wrtReachable] == false && _wrtReachable == true) {
_wrtReachable = false;
if (_readTimer == nil) {
_readTimer = [NSTimer scheduledTimerWithTimeInterval:refreshTime+1 target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
[_readTimer fire];
}
} else if ([wrt_client getWrtReachable] == false) {
[self showMenubarIcon:false];
}
if (_wrtReachable == true) {
[wrt_client getStatusUpdate:[NSString stringWithFormat:@"fetchif.cgi?%@", [wrt_client getWanPort]] delegate:self callback:@selector(throughputCallback:)];
}
if (_readTimer == nil) {
_readTimer = [NSTimer scheduledTimerWithTimeInterval:refreshTime+1 target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
[_readTimer fire];
[_readTimer invalidate];
_readTimer = nil;
}
}
- (void) updateThroughput:(NSTimer *)timer
{
NSLog(@"Status %@ wan port: %@", ([wrt_client getWrtReachable] ? @"Up" : @"Down"), [wrt_client getWanPort]);
[wrt_client getStatusUpdate:[NSString stringWithFormat:@"fetchif.cgi?%@", [wrt_client getWanPort]] delegate:self callback:@selector(throughputCallback:)];
}
- (void) throughputCallback:(NSData *)data
{
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
NSLog(stringData);
NSString *key = [NSString stringWithFormat:@"%@:", [wrt_client getWanPort]];
stringData = [stringData substringFromIndex:([stringData rangeOfString:key].location + [key length])];
NSArray *parts = [stringData componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
NSArray *filteredArray = [parts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF != ''"]];
stringData = [filteredArray componentsJoinedByString:@" "];
NSArray *listItems = [stringData componentsSeparatedByString:@" "];
NSArray *listItems = [parts filteredArrayUsingPredicate:[NSPredicate predicateWithFormat:@"SELF != ''"]];
uint64_t ifIn = strtoull([[listItems objectAtIndex:0] UTF8String], NULL, 0);
uint64_t ifOut = strtoull([[listItems objectAtIndex:8] UTF8String], NULL, 0);
@ -451,30 +467,6 @@
*/
}
- (void) refreshMenu:(id)sender
{
NSLog(@"Refresh Menu");
if ([wrt_client wrtReachable] == true) {
[_readTimer invalidate];
_readTimer = nil;
[wrt_client getStatusUpdate:@"Status_Router.live.asp" delegate:self callback:@selector(doUpdateStatus:)];
} else {
[_appMenu popUpStatusItemMenu:AppMenu];
}
}
- (void) refreshSystemMenu:(id)sender
{
}
- (void) refreshWanMenu:(id)sender
{
}
- (void) wanRequestCallback:(NSData *)data
{
[wrt_client getStatusUpdate:@"Status_Lan.live.asp" delegate:self callback:@selector(cbClientsRequest:)];

@ -533,7 +533,7 @@
<object class="NSWindowTemplate" id="206781734">
<int key="NSWindowStyleMask">273</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{247, 277}, {308, 232}}</string>
<string key="NSWindowRect">{{961, 833}, {308, 232}}</string>
<int key="NSWTFlags">611844096</int>
<string key="NSWindowTitle">Preferences</string>
<string key="NSWindowClass">NSPanel</string>
@ -969,6 +969,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<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>
@ -977,9 +978,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="179819426"/>
<int key="NSButtonFlags">-2038152961</int>
<int key="NSButtonFlags2">268435620</int>
<int key="NSButtonFlags2">164</int>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent">s</string>
<string type="base64-UTF8" key="NSKeyEquivalent">DQ</string>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
@ -999,9 +1000,9 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="NSSupport" ref="26"/>
<reference key="NSControlView" ref="184594776"/>
<int key="NSButtonFlags">-2038152961</int>
<int key="NSButtonFlags2">164</int>
<int key="NSButtonFlags2">268435620</int>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
<string key="NSKeyEquivalent">.</string>
<int key="NSPeriodicDelay">400</int>
<int key="NSPeriodicInterval">75</int>
</object>
@ -1037,12 +1038,12 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<int key="NSWindowStyleMask">8219</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{823, 723}, {555, 275}}</string>
<int key="NSWTFlags">611844096</int>
<int key="NSWTFlags">-461897728</int>
<string key="NSWindowTitle">Bandwidth Viewer</string>
<string key="NSWindowClass">NSPanel</string>
<nil key="NSViewClass"/>
<object class="NSView" key="NSWindowView" id="40768770">
<nil key="NSNextResponder"/>
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
@ -1072,6 +1073,7 @@ 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>
@ -1104,6 +1106,8 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
</object>
</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>
@ -2658,7 +2662,7 @@ AAMAAAABAAEAAAFTAAMAAAAEAAAFwgAAAAAACAAIAAgACAABAAEAAQABA</bytes>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">826</int>
<int key="maxID">833</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">

@ -28,17 +28,28 @@
id delegate;
SEL callback;
SEL errorCallback;
id statusDelegate;
SEL statusCallbac;
IBOutlet NSWindow *credentialsWindow;
IBOutlet NSFormCell *fieldUsername;
IBOutlet NSSecureTextFieldCell *fieldPassword;
IBOutlet NSButton *buttonLogin;
}
@property BOOL wrtReachable;
@property(nonatomic, retain) NSMutableData *receivedData;
@property(nonatomic, retain) id delegate;
@property(nonatomic) SEL callback;
@property(nonatomic) SEL errorCallback;
@property(nonatomic, retain) id statusDelegate;
@property(nonatomic) SEL statusCallback;
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port protocol:(NSString*)new_protocol username:(NSString*)new_username password:(NSString*)new_password;
- (void) registerStatusCallback:(id)status_delegate callback:(SEL)status_callback;
- (NSMutableURLRequest*) buildRequest:(NSString*)uri;
- (NSMutableURLRequest*) requestForBandwidthViewerForInterface:(NSString*)interface;
- (void) getStatusUpdate:(NSString*)uri delegate:(id)requestDelegate callback:(SEL)requestSelector;
@ -46,6 +57,9 @@
-(NSString *)getKey:(NSString *)stringData key:(NSString *)key;
- (BOOL) getWrtReachable;
- (void) setWrtReachable:(BOOL)new_wrtReachable;
- (NSString*) getWanPort;
- (void) setWanPort:(NSString*)new_wanport;
@ -64,5 +78,7 @@
- (NSString*) getPassword;
- (void) setPassword:(NSString*)new_password;
- (void) showCredentialsWindow;
- (IBAction) hideCredentialsWindow;
@end

@ -11,13 +11,14 @@
@implementation WRTStatusClient
@synthesize wrtReachable;
@synthesize receivedData;
@synthesize delegate;
@synthesize callback;
@synthesize errorCallback;
@synthesize statusDelegate;
@synthesize statusCallback;
- (id) initWithHostname:(NSString*)new_hostname port:(int)new_port protocol:(NSString*)new_protocol username:(NSString*)new_username password:(NSString*)new_password
{
self = [super init];
@ -36,6 +37,12 @@
#pragma mark -
- (void) registerStatusCallback:(id)status_delegate callback:(SEL)status_callback
{
statusDelegate = status_delegate;
statusCallback = status_callback;
}
- (NSMutableURLRequest*) buildRequest:(NSString*)uri
{
NSString *urlAddress = [NSString stringWithFormat:@"%@://%@:%d/%@",
@ -44,7 +51,8 @@
port,
uri];
//NSLog(@"Building request form %@", urlAddress);
NSLog(@"Building request form %@", urlAddress);
NSURL *url = [NSURL URLWithString:urlAddress];
@ -100,15 +108,12 @@
- (void) cbConnectionStatus:(NSData *)data
{
if (data == nil) {
wrtReachable = false;
[self setWrtReachable:false];
} else {
NSString *stringData = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
//Bandwidth Monitoring
NSRange pageValid = [stringData rangeOfString:@"Bandwidth Monitoring"];
NSRange pageValid = [stringData rangeOfString:@"Bandwidth Monitoring"];
if (pageValid.location != NSNotFound) {
wrtReachable = true;
// grab the wan port name
NSRange startRange = [stringData rangeOfString:@"WAN</h2>"];
stringData = [stringData substringFromIndex:startRange.location];
@ -117,8 +122,9 @@
stringData = [stringData substringFromIndex:(startRange.location + [key length])];
NSRange endRange = [stringData rangeOfString:@"\""];
[self setWanPort:[stringData substringToIndex:endRange.location]];
[self setWrtReachable:true];
} else {
wrtReachable = false;
[self setWrtReachable:false];
wanPort = nil;
}
}
@ -157,6 +163,23 @@
#pragma mark -
#pragma mark Accessors:
- (BOOL) getWrtReachable
{
return wrtReachable;
}
- (void) setWrtReachable:(BOOL)new_wrtReachable
{
BOOL old_wrtReachable = wrtReachable;
wrtReachable = new_wrtReachable;
if (old_wrtReachable != new_wrtReachable && statusDelegate && statusCallback) {
if ([statusDelegate respondsToSelector:statusCallback]) {
[statusDelegate performSelector:statusCallback withObject:nil];
}
}
}
- (NSString*) getWanPort
{
return wanPort;
@ -228,16 +251,32 @@
[old_password autorelease];
}
#pragma mark -
#pragma mark Credential Window Methods:
- (void) showCredentialsWindow
{
[credentialsWindow makeKeyAndOrderFront:nil];
}
- (IBAction) hideCredentialsWindow
{
[self setUsername:[fieldUsername stringValue]];
[self setPassword:[fieldPassword stringValue]];
}
#pragma mark -
#pragma mark NSURLConnection Delegate Methods:
- (BOOL)connection:(NSURLConnection *)connection canAuthenticateAgainstProtectionSpace:(NSURLProtectionSpace *)protectionSpace
{
return NO; // FIXME Turning this to NO should use keychain, but it doesn't
NSLog(@"1.0.1");
return NO; // FIXME this need to return YES if an entry doesn't already exist in the keychain and the user will need to be prompted for credentials
}
- (BOOL)connectionShouldUseCredentialStorage:(NSURLConnection *)connection
{
NSLog(@"1.0.2");
return YES;
}
@ -253,7 +292,6 @@
[[challenge sender] useCredential:newCredential forAuthenticationChallenge:challenge];
} else {
NSLog(@"1.2");
wrtReachable = false;
[[challenge sender] cancelAuthenticationChallenge:challenge];
// TODO Pop up authentication error
NSLog(@"Invalid Username or Password");
@ -281,7 +319,7 @@
//TODO Return alert
NSLog(@"Connection failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSURLErrorFailingURLStringErrorKey]);
wrtReachable = false;
[self setWrtReachable:false];
if (errorCallback) {
[delegate performSelector:errorCallback withObject:error];

Loading…
Cancel
Save