Added new password panel. MORE conformity/bugfixes.
[MenuTunes.git] / MainController.m
index a9e67e9..bd93fca 100755 (executable)
@@ -42,6 +42,7 @@ static MainController *sharedController;
         statusWindowController = [StatusWindowController sharedController];
         menuController = [[MenuController alloc] init];
         df = [[NSUserDefaults standardUserDefaults] retain];
+        [[PreferencesController sharedPrefs] setController:self];
         timerUpdating = NO;
         blinged = NO;
     }
@@ -472,7 +473,6 @@ static MainController *sharedController;
 - (void)showPreferences
 {
     ITDebugLog(@"Show preferences.");
-    [[PreferencesController sharedPrefs] setController:self];
     [[PreferencesController sharedPrefs] showPrefsWindow:self];
 }
 
@@ -950,20 +950,20 @@ static MainController *sharedController;
     result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
     //Connect
     if (result == 1) {
+        [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
         currentRemote = [[[networkController networkObject] remote] retain];
         [self timerUpdate];
-        //[refreshTimer invalidate];
         ITDebugLog(@"Connection successful.");
         return YES;
     } else if (result == 0) {
         ITDebugLog(@"Connection failed.");
         currentRemote = [remoteArray objectAtIndex:0];
         return NO;
-    } else if (result == -1) {
+    } else {
+        //Do something about the password being invalid
         ITDebugLog(@"Connection failed.");
         currentRemote = [remoteArray objectAtIndex:0];
         return NO;
-        //Do something about the password being invalid
     }
 }
 
@@ -999,6 +999,7 @@ static MainController *sharedController;
     if ([[exception name] isEqualToString:NSPortTimeoutException] && [networkController isConnectedToServer]) {
         NSRunCriticalAlertPanel(@"Remote MenuTunes Disconnected", @"The MenuTunes server you were connected to stopped responding or quit. MenuTunes will revert back to the local player.", @"OK", nil, nil);
         if ([self disconnectFromServer]) {
+            [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
             [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES];
         } else {
             ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
@@ -1075,8 +1076,8 @@ static MainController *sharedController;
 
 - (void)applicationWillTerminate:(NSNotification *)note
 {
-    [self clearHotKeys];
     [networkController stopRemoteServerSearch];
+    [self clearHotKeys];
     [[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
 }
 
@@ -1097,5 +1098,4 @@ static MainController *sharedController;
     [super dealloc];
 }
 
-
 @end
\ No newline at end of file