+ //Change the launch player checkbox to the proper name
+ NS_DURING
+ [launchPlayerAtLaunchCheckbox setTitle:[NSString stringWithFormat:@"Launch %@ when MenuTunes launches", [[controller currentRemote] playerSimpleName]]]; //This isn't localized...
+ NS_HANDLER
+ [controller networkError:localException];
+ NS_ENDHANDLER
+ }
+
+ [self resetRemotePlayerTextFields];
+ [launchAtLoginCheckbox becomeFirstResponder];
+ [NSApp activateIgnoringOtherApps:YES];
+ [window center];
+ [window orderFrontRegardless];
+ [window makeKeyWindow];
+}
+
+- (IBAction)showTestWindow:(id)sender
+{
+ [controller showTestWindow];
+}
+
+- (IBAction)changeGeneralSetting:(id)sender
+{
+ ITDebugLog(@"Changing general setting of tag %i.", [sender tag]);
+ if ( [sender tag] == 1010) {
+ [self setLaunchesAtLogin:SENDER_STATE];
+ } else if ( [sender tag] == 1020) {
+ [df setBool:SENDER_STATE forKey:@"LaunchPlayerWithMT"];
+ } else if ( [sender tag] == 1030) {
+ [df setInteger:[sender intValue] forKey:@"SongsInAdvance"];
+
+ } else if ( [sender tag] == 1040) {
+ // This will not be executed. Song info always shows the title of the song.
+ // [df setBool:SENDER_STATE forKey:@"showName"];
+ } else if ( [sender tag] == 1050) {
+ [df setBool:SENDER_STATE forKey:@"showArtist"];
+ } else if ( [sender tag] == 1060) {
+ [df setBool:SENDER_STATE forKey:@"showAlbum"];
+ } else if ( [sender tag] == 1070) {
+ [df setBool:SENDER_STATE forKey:@"showTime"];
+ } else if ( [sender tag] == 1080) {
+ [df setBool:SENDER_STATE forKey:@"showTrackNumber"];
+ } else if ( [sender tag] == 1090) {
+ [df setBool:SENDER_STATE forKey:@"showTrackRating"];
+ } else if ( [sender tag] == 1100) {
+ [df setBool:SENDER_STATE forKey:@"showAlbumArtwork"];
+ } else if ( [sender tag] == 1110) {
+ [df setBool:SENDER_STATE forKey:@"runScripts"];
+ if (SENDER_STATE) {
+ [runScriptsCheckbox setState:NSOnState];
+ [showScriptsButton setEnabled:YES];
+ } else {
+ [showScriptsButton setEnabled:NO];
+ }
+ } else if ( [sender tag] == 1120) {
+ mkdir([[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] cString], 0744);
+ [[NSWorkspace sharedWorkspace] openFile:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]];
+ }
+ [df synchronize];
+}
+
+- (IBAction)changeSharingSetting:(id)sender
+{
+ ITDebugLog(@"Changing sharing setting of tag %i.", [sender tag]);
+ if ( [sender tag] == 5010 ) {
+ BOOL state = SENDER_STATE;
+ [df setBool:state forKey:@"enableSharing"];
+ //Disable/enable the use of shared player options
+ [useSharedMenuTunesCheckbox 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"];
+ [[NetworkController sharedController] resetServerName];
+ } else if ( [sender tag] == 5030 ) {
+ //Set the server password
+ const char *instring = [[sender stringValue] UTF8String];
+ const char *password = "p4s5w0rdMT1.2";
+ 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"];
+ [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];
+ [passwordTextField setEnabled:NO];
+ [nameTextField setEnabled:NO];
+ [selectSharedPlayerButton setEnabled:state];