Removed the evil "Requires Checkbox" button as per Joe's request.
[MenuTunes.git] / PreferencesController.m
index 3919848..fa8d29d 100755 (executable)
@@ -192,6 +192,7 @@ static PreferencesController *prefs = nil;
         NS_ENDHANDLER
     }
 
         NS_ENDHANDLER
     }
 
+    [self resetRemotePlayerTextFields];
     [window center];
     [NSApp activateIgnoringOtherApps:YES];
     [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0];
     [window center];
     [NSApp activateIgnoringOtherApps:YES];
     [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0];
@@ -237,35 +238,36 @@ static PreferencesController *prefs = nil;
         [df setBool:state forKey:@"enableSharing"];
         //Disable/enable the use of shared player options
         [useSharedMenuTunesCheckbox setEnabled:!state];
         [df setBool:state forKey:@"enableSharing"];
         //Disable/enable the use of shared player options
         [useSharedMenuTunesCheckbox setEnabled:!state];
-        [usePasswordCheckbox setEnabled:state];
         [passwordTextField setEnabled:state];
         [nameTextField setEnabled:state];
         [selectSharedPlayerButton setEnabled:NO];
         [controller setServerStatus:state]; //Set server status
     } else if ( [sender tag] == 5015 ) {
         [df setObject:[sender stringValue] forKey:@"sharedPlayerName"];
         [passwordTextField setEnabled:state];
         [nameTextField setEnabled:state];
         [selectSharedPlayerButton setEnabled:NO];
         [controller setServerStatus:state]; //Set server status
     } else if ( [sender tag] == 5015 ) {
         [df setObject:[sender stringValue] forKey:@"sharedPlayerName"];
-    } else if ( [sender tag] == 5020 ) {
-        [df setBool:SENDER_STATE forKey:@"enableSharingPassword"];
+        [[NetworkController sharedController] resetServerName];
     } else if ( [sender tag] == 5030 ) {
         //Set the server password
         const char *instring = [[sender stringValue] UTF8String];
     } else if ( [sender tag] == 5030 ) {
         //Set the server password
         const char *instring = [[sender stringValue] UTF8String];
-        const char *password = "password";
+        const char *password = "p4s5w0rdMT1.2";
         unsigned char *result;
         NSData *hashedPass, *passwordStringHash;
         unsigned char *result;
         NSData *hashedPass, *passwordStringHash;
+        if ([[sender stringValue] length] == 0) {
+            [df setObject:[NSData data] forKey:@"sharedPlayerPassword"];
+            return;
+        }
         result = SHA1(instring, strlen(instring), NULL);
         hashedPass = [NSData dataWithBytes:result length:strlen(result)];
         result = SHA1(password, strlen(password), NULL);
         passwordStringHash = [NSData dataWithBytes:result length:strlen(result)];
         if (![hashedPass isEqualToData:passwordStringHash]) {
             [df setObject:hashedPass forKey:@"sharedPlayerPassword"];
         result = SHA1(instring, strlen(instring), NULL);
         hashedPass = [NSData dataWithBytes:result length:strlen(result)];
         result = SHA1(password, strlen(password), NULL);
         passwordStringHash = [NSData dataWithBytes:result length:strlen(result)];
         if (![hashedPass isEqualToData:passwordStringHash]) {
             [df setObject:hashedPass forKey:@"sharedPlayerPassword"];
-            [sender setStringValue:@"password"];
+            [sender setStringValue:@"p4s5w0rdMT1.2"];
         }
     } else if ( [sender tag] == 5040 ) {
         BOOL state = SENDER_STATE;
         [df setBool:state forKey:@"useSharedPlayer"];
         //Disable/enable the use of sharing options
         [shareMenuTunesCheckbox setEnabled:!state];
         }
     } else if ( [sender tag] == 5040 ) {
         BOOL state = SENDER_STATE;
         [df setBool:state forKey:@"useSharedPlayer"];
         //Disable/enable the use of sharing options
         [shareMenuTunesCheckbox setEnabled:!state];
-        [usePasswordCheckbox setEnabled:NO];
         [passwordTextField setEnabled:NO];
         [nameTextField setEnabled:NO];
         [selectSharedPlayerButton setEnabled:state];
         [passwordTextField setEnabled:NO];
         [nameTextField setEnabled:NO];
         [selectSharedPlayerButton setEnabled:state];
@@ -384,7 +386,7 @@ static PreferencesController *prefs = nil;
     
         BOOL entryEffectValid = YES;
         BOOL exitEffectValid  = YES;
     
         BOOL entryEffectValid = YES;
         BOOL exitEffectValid  = YES;
-        
+                
         [df setInteger:[sender selectedRow] forKey:@"statusWindowVerticalPosition"];
         [df setInteger:[sender selectedColumn] forKey:@"statusWindowHorizontalPosition"];
         [sw setVerticalPosition:[sender selectedRow]];
         [df setInteger:[sender selectedRow] forKey:@"statusWindowVerticalPosition"];
         [df setInteger:[sender selectedColumn] forKey:@"statusWindowHorizontalPosition"];
         [sw setVerticalPosition:[sender selectedRow]];
@@ -416,8 +418,7 @@ static PreferencesController *prefs = nil;
             [vanishEffectPopup selectItemAtIndex:[[vanishEffectPopup menu] indexOfItemWithRepresentedObject:[[sw exitEffect] class]]];
         }
         
             [vanishEffectPopup selectItemAtIndex:[[vanishEffectPopup menu] indexOfItemWithRepresentedObject:[[sw exitEffect] class]]];
         }
         
-        // Update the window's position.
-        // Yeah, do that.
+        [(MainController *)controller showCurrentTrackInfo];
         
     } else if ( [sender tag] == 2020) {
     
         
     } else if ( [sender tag] == 2020) {
     
@@ -485,8 +486,8 @@ static PreferencesController *prefs = nil;
         }
 
     } else if ( [sender tag] == 2095) {
         }
 
     } else if ( [sender tag] == 2095) {
-        [sw vanish:self];
         [df setInteger:[sender indexOfSelectedItem] forKey:@"statusWindowSizing"];
         [df setInteger:[sender indexOfSelectedItem] forKey:@"statusWindowSizing"];
+        [(MainController *)controller showCurrentTrackInfo];
     }
     
     [df synchronize];
     }
     
     [df synchronize];
@@ -846,7 +847,6 @@ static PreferencesController *prefs = nil;
         [useSharedMenuTunesCheckbox setEnabled:NO];
         [selectSharedPlayerButton setEnabled:NO];
         [passwordTextField setEnabled:YES];
         [useSharedMenuTunesCheckbox setEnabled:NO];
         [selectSharedPlayerButton setEnabled:NO];
         [passwordTextField setEnabled:YES];
-        [usePasswordCheckbox setEnabled:YES];
         [nameTextField setEnabled:YES];
     } else if ([df boolForKey:@"useSharedPlayer"]) {
         [useSharedMenuTunesCheckbox setState:NSOnState];
         [nameTextField setEnabled:YES];
     } else if ([df boolForKey:@"useSharedPlayer"]) {
         [useSharedMenuTunesCheckbox setState:NSOnState];
@@ -863,9 +863,10 @@ static PreferencesController *prefs = nil;
     [nameTextField setStringValue:serverName];
     
     [selectPlayerBox setContentView:zeroConfView];
     [nameTextField setStringValue:serverName];
     
     [selectPlayerBox setContentView:zeroConfView];
-    [usePasswordCheckbox setState:([df boolForKey:@"enableSharingPassword"] ? NSOnState : NSOffState)];
-    if ([df dataForKey:@"sharedPlayerPassword"]) {
-        [passwordTextField setStringValue:@"password"];
+    if ([[df dataForKey:@"sharedPlayerPassword"] length]) {
+        [passwordTextField setStringValue:@"p4s5w0rdMT1.2"];
+    } else {
+        [passwordTextField setStringValue:@""];
     }
     if ([df stringForKey:@"sharedPlayerHost"]) {
         [hostTextField setStringValue:[df stringForKey:@"sharedPlayerHost"]];
     }
     if ([df stringForKey:@"sharedPlayerHost"]) {
         [hostTextField setStringValue:[df stringForKey:@"sharedPlayerHost"]];