- //Get our preferred menu
- myItems = [[[NSUserDefaults standardUserDefaults] arrayForKey:@"menu"] mutableCopy];
- if (myItems == nil)
- {
- myItems = [[NSMutableArray alloc] initWithObjects:@"Play/Pause", @"Next Track", @"Previous Track", @"Fast Forward", @"Rewind", @"<separator>", @"Upcoming Songs", @"Playlists", @"EQ Presets", @"<separator>", @"PreferencesÉ", @"Quit", @"<separator>", @"Current Track Info", nil];
- [[NSUserDefaults standardUserDefaults] setObject:myItems forKey:@"menu"];
+ //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
+ }
+
+ [window center];
+ [NSApp activateIgnoringOtherApps:YES];
+ [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0];
+}
+
+- (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"];
+ }
+ [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];
+ [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"];
+ } else if ( [sender tag] == 5020 ) {
+ [df setBool:SENDER_STATE forKey:@"enableSharingPassword"];
+ } else if ( [sender tag] == 5030 ) {
+ //Set the server password
+ const char *instring = [[sender stringValue] UTF8String];
+ const char *password = "password";
+ unsigned char *result;
+ NSData *hashedPass, *passwordStringHash;
+ 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"];