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

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

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