1
0
Fork 0

implemented readDefaults function and tweaked some shit to better jive with WRTStatusClient

master
Spike Grobstein 14 years ago
parent 0ef2a69fb7
commit 3c196d9f7e

@ -2753,9 +2753,9 @@
<string>PrimaryDocumentVisibleCharacterRange</string>
<string>HideAllIssues</string>
<string>PrimaryDocumentSelectedCharacterRange</string>
<real>328577815.02909499</real>
<string>{511, 1147}</string>
<string>{815, 0}</string>
<real>328580003.38722801</real>
<string>{365, 1061}</string>
<string>{264, 0}</string>
<dict>
<key>$class</key>
<dict>
@ -2801,9 +2801,9 @@
</dict>
</array>
</dict>
<real>328578404.99264902</real>
<string>{733, 885}</string>
<string>{1321, 0}</string>
<real>328580305.561315</real>
<string>{986, 774}</string>
<string>{1484, 0}</string>
<dict>
<key>$class</key>
<dict>
@ -2897,9 +2897,9 @@
</dict>
</array>
</dict>
<real>328578489.274598</real>
<string>{1044, 1134}</string>
<string>{2148, 0}</string>
<real>328580360.92351502</real>
<string>{243, 1168}</string>
<string>{855, 0}</string>
<dict>
<key>$class</key>
<dict>
@ -3088,9 +3088,9 @@
</dict>
</array>
</dict>
<real>328577639.88812602</real>
<string>{46, 1054}</string>
<string>{712, 83}</string>
<real>328580124.29944998</real>
<string>{144, 988}</string>
<string>{966, 0}</string>
<dict>
<key>$class</key>
<dict>
@ -3586,7 +3586,7 @@
<integer>323</integer>
</dict>
<key>NS.time</key>
<real>328578485.318919</real>
<real>328580357.79140002</real>
</dict>
<dict>
<key>$classes</key>
@ -3597,7 +3597,7 @@
<key>$classname</key>
<string>NSDate</string>
</dict>
<string>Today at 7:48 PM</string>
<string>Today at 8:19 PM</string>
<integer>106</integer>
<dict>
<key>$class</key>
@ -3775,7 +3775,7 @@
<integer>340</integer>
</dict>
</dict>
<string>file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.m</string>
<string>file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.h</string>
<dict>
<key>$class</key>
<dict>
@ -3793,7 +3793,7 @@
<integer>342</integer>
</dict>
</dict>
<string>file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.h</string>
<string>file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.m</string>
<dict>
<key>$class</key>
<dict>
@ -4602,7 +4602,7 @@
<string>IDECollapsedTypes</string>
<string>IDERecentFilteringEnabled</string>
<string>IDECollapsedGroups</string>
<string>{{0, 0}, {259, 632}}</string>
<string>{{0, 0}, {244, 632}}</string>
<dict>
<key>$class</key>
<dict>
@ -5362,10 +5362,10 @@
</dict>
</array>
</dict>
<real>328578489.277578</real>
<string>{1044, 1134}</string>
<string>{2148, 0}</string>
<string>-initDefaults</string>
<real>328580360.92557901</real>
<string>{243, 1168}</string>
<string>{855, 0}</string>
<string>-awakeFromNib</string>
<dict>
<key>$class</key>
<dict>

@ -52,6 +52,19 @@
NSUserDefaults *defaults;
// application prefs:
NSString *hostname;
int port;
NSString *username;
NSString *password;
int refreshTime;
bool useBytes;
bool showMenuIcon;
// end app prefs
NSStatusItem *_appMenu;
NSAlert *modalWindow;

@ -14,9 +14,7 @@
//- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
- (void) awakeFromNib
{
wrt_client = [[WRTStatusClient alloc] initWithHostname:@"router" port:80 username:@"spike" password:@"aaaassss"];
{
// Insert code here to initialize your application
[self showMenubar];
@ -29,19 +27,22 @@
if (![defaults boolForKey:@"configured"])
{
[self initDefaults];
} else {
[self readDefaults];
NSLog(@"Using existing user defaults");
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
//[_readTimer fire];
[self updateThroughput];
//WRTRequest *wrtr = [[WRTRequest alloc] init];
//[wrtr doRequest:self requestSelector:@selector(doUpdateStatus:) uri:@"Status_Router.live.asp"];
}
}
NSLog(@"Reading defaults...");
[self readDefaults];
// initialize the client
wrt_client = [[WRTStatusClient alloc] initWithHostname:hostname port:port username:username password:password];
//_readTimer = [NSTimer scheduledTimerWithTimeInterval:[[NSUserDefaults standardUserDefaults] integerForKey:@"refreshTime"] target:self selector:@selector(updateThroughput:) userInfo:nil repeats:YES];
//[_readTimer fire];
[self updateThroughput];
//WRTRequest *wrtr = [[WRTRequest alloc] init];
//[wrtr doRequest:self requestSelector:@selector(doUpdateStatus:) uri:@"Status_Router.live.asp"];
}
- (void) dealloc {
@ -56,19 +57,21 @@
- (void) initDefaults
{
NSDictionary *appDefaults = [NSDictionary dictionaryWithObjectsAndKeys:nil];
NSLog(@"Creating new user defaults");
// do any other initialization you want to do here - e.g. the starting default values.
//[[NSUserDefaults standardUserDefaults] setObject:@"192.168.1.1" foKey:@"hostname"];
[defaults setValue:@"192.168.1.1" forKey:@"hostname"];
[defaults setInteger:80 forKey:@"port"];
[defaults setValue:@"" forKey:@"username"];
[defaults setValue:@"" forKey:@"password"];
[defaults setBool:YES forKey:@"showMenuIcon"];
[defaults setBool:YES forKey:@"useBytes"];
[defaults setInteger:80 forKey:@"port"];
[defaults setInteger:4 forKey:@"refreshTime"];
// sync the defaults to disk
[defaults registerDefaults:appDefaults];
//[defaults registerDefaults:appDefaults];
[defaults synchronize];
// TODO: Add modal alert "First launch" here...
@ -77,6 +80,15 @@
- (void) readDefaults
{
hostname = [defaults valueForKey:@"hostname"];
port = [defaults integerForKey:@"port"];
username = [defaults valueForKey:@"username"];
password = [defaults valueForKey:@"password"];
showMenuIcon = [defaults boolForKey:@"showMenuIcon"];
useBytes = [defaults boolForKey:@"useBytes"];
refreshTime = [defaults integerForKey:@"refreshTime"];
}

Loading…
Cancel
Save