diff --git a/DDWRT-Monitor.xcodeproj/project.xcworkspace/xcuserdata/spike.xcuserdatad/UserInterfaceState.xcuserstate b/DDWRT-Monitor.xcodeproj/project.xcworkspace/xcuserdata/spike.xcuserdatad/UserInterfaceState.xcuserstate
index 3e7eab5..4173438 100644
--- a/DDWRT-Monitor.xcodeproj/project.xcworkspace/xcuserdata/spike.xcuserdatad/UserInterfaceState.xcuserstate
+++ b/DDWRT-Monitor.xcodeproj/project.xcworkspace/xcuserdata/spike.xcuserdatad/UserInterfaceState.xcuserstate
@@ -2753,9 +2753,9 @@
PrimaryDocumentVisibleCharacterRange
HideAllIssues
PrimaryDocumentSelectedCharacterRange
- 328577815.02909499
- {511, 1147}
- {815, 0}
+ 328580003.38722801
+ {365, 1061}
+ {264, 0}
$class
@@ -2801,9 +2801,9 @@
- 328578404.99264902
- {733, 885}
- {1321, 0}
+ 328580305.561315
+ {986, 774}
+ {1484, 0}
$class
@@ -2897,9 +2897,9 @@
- 328578489.274598
- {1044, 1134}
- {2148, 0}
+ 328580360.92351502
+ {243, 1168}
+ {855, 0}
$class
@@ -3088,9 +3088,9 @@
- 328577639.88812602
- {46, 1054}
- {712, 83}
+ 328580124.29944998
+ {144, 988}
+ {966, 0}
$class
@@ -3586,7 +3586,7 @@
323
NS.time
- 328578485.318919
+ 328580357.79140002
$classes
@@ -3597,7 +3597,7 @@
$classname
NSDate
- Today at 7:48 PM
+ Today at 8:19 PM
106
$class
@@ -3775,7 +3775,7 @@
340
- file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.m
+ file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.h
$class
@@ -3793,7 +3793,7 @@
342
- file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.h
+ file://localhost/Users/spike/Downloads/DDWRT-Monitor/WRTStatusClient.m
$class
@@ -4602,7 +4602,7 @@
IDECollapsedTypes
IDERecentFilteringEnabled
IDECollapsedGroups
- {{0, 0}, {259, 632}}
+ {{0, 0}, {244, 632}}
$class
@@ -5362,10 +5362,10 @@
- 328578489.277578
- {1044, 1134}
- {2148, 0}
- -initDefaults
+ 328580360.92557901
+ {243, 1168}
+ {855, 0}
+ -awakeFromNib
$class
diff --git a/DDWRT_MonitorAppDelegate.h b/DDWRT_MonitorAppDelegate.h
index f69c56a..ce7751a 100644
--- a/DDWRT_MonitorAppDelegate.h
+++ b/DDWRT_MonitorAppDelegate.h
@@ -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;
diff --git a/DDWRT_MonitorAppDelegate.m b/DDWRT_MonitorAppDelegate.m
index 00ed349..d368659 100644
--- a/DDWRT_MonitorAppDelegate.m
+++ b/DDWRT_MonitorAppDelegate.m
@@ -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"];
+
}