From: Kent Sutherland Date: Sat, 13 Dec 2003 22:06:51 +0000 (+0000) Subject: Prefs window updates the remote server name each time. Fixed X-Git-Tag: v1.2~12 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/154ddd8b39891b174082df48f504f83d0a6a22d9 Prefs window updates the remote server name each time. Fixed numberOfSongsInPlaylistAtIndex to get from the current source. Fixed more bugs in MenuController having to do with upcoming songs and a remote source. iTunesRemote -playlist now returns the class of each playlist in the array too. The rebuildUpcomingSongsMenu and rebuildPlaylistsMenu don't throw exceptions anymore either, I hope. --- diff --git a/MenuController.m b/MenuController.m index 3916267..9c7f9b5 100755 --- a/MenuController.m +++ b/MenuController.m @@ -438,7 +438,6 @@ NS_HANDLER [[MainController sharedController] networkError:localException]; NS_ENDHANDLER - [_ratingMenu release]; [_upcomingSongsMenu release]; [_playlistsMenu release]; @@ -495,7 +494,6 @@ NS_ENDHANDLER ITDebugLog(@"Building \"Upcoming Songs\" menu."); - if (_currentPlaylist && !_playingRadio) { if (numSongs > 0) { int i; @@ -585,10 +583,10 @@ NSArray *curPlaylist = [playlists objectAtIndex:0]; NSString *name = [curPlaylist objectAtIndex:0]; ITDebugLog(@"Adding main source: %@", name); - for (i = 1; i < [curPlaylist count]; i++) { + for (i = 2; i < [curPlaylist count]; i++) { ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:i]); tempItem = [playlistsMenu addItemWithTitle:[curPlaylist objectAtIndex:i] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""]; - [tempItem setTag:i + 1]; + [tempItem setTag:i]; [tempItem setTarget:self]; } } @@ -606,17 +604,20 @@ NSString *name = [curPlaylist objectAtIndex:0]; NSMenu *submenu = [[NSMenu alloc] init]; ITDebugLog(@"Adding source: %@", name); - for (j = 1; j < [curPlaylist count]; j++) { + for (j = 2; j < [curPlaylist count]; j++) { ITDebugLog(@"Adding playlist: %@", [curPlaylist objectAtIndex:j]); tempItem = [submenu addItemWithTitle:[curPlaylist objectAtIndex:j] action:@selector(performPlaylistMenuAction:) keyEquivalent:@""]; - [tempItem setTag:(i * 1000) + (j + 1)]; + [tempItem setTag:(i * 1000) + j]; [tempItem setTarget:self]; + if ([[curPlaylist objectAtIndex:i] intValue] == ITMTRemoteiPodSource) { + [tempItem setEnabled:NO]; + } } [[playlistsMenu addItemWithTitle:name action:NULL keyEquivalent:@""] setSubmenu:[submenu autorelease]]; } if ( (source == ITMTRemoteSharedLibrarySource) || (source == ITMTRemoteiPodSource) || (source == ITMTRemoteGenericDeviceSource) || (source == ITMTRemoteCDSource) ){ - tempItem = [playlistsMenu itemAtIndex:(int)[[[MainController sharedController] currentRemote] currentSourceIndex] + [playlistsMenu numberOfItems] - 6]; + tempItem = [playlistsMenu itemAtIndex:(int)[[[MainController sharedController] currentRemote] currentSourceIndex] + [playlistsMenu numberOfItems] - 5]; [tempItem setState:NSOnState]; [[[tempItem submenu] itemAtIndex:_currentPlaylist - 1] setState:NSOnState]; } else if (source == ITMTRemoteLibrarySource && _currentPlaylist) { diff --git a/PreferencesController.m b/PreferencesController.m index 7bc3db8..1aee038 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -192,6 +192,7 @@ static PreferencesController *prefs = nil; NS_ENDHANDLER } + [self resetRemotePlayerTextFields]; [window center]; [NSApp activateIgnoringOtherApps:YES]; [window performSelector:@selector(makeKeyAndOrderFront:) withObject:self afterDelay:0.0]; diff --git a/iTunesRemote.m b/iTunesRemote.m index 5f3944c..c7d17a8 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -147,9 +147,37 @@ ITDebugLog(@"Getting playlists."); for (k = 1; k <= numSources ; k++) { const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cPly'), '----':obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() }",k] eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; + unsigned long fourcc = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k] eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; NSString *sourceName = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k] eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; + NSNumber *sourceClass; NSMutableArray *aSource = [[NSMutableArray alloc] init]; [aSource addObject:sourceName]; + + switch (fourcc) { + case 'kTun': + sourceClass = [NSNumber numberWithInt:ITMTRemoteRadioSource]; + break; + case 'kDev': + sourceClass = [NSNumber numberWithInt:ITMTRemoteGenericDeviceSource]; + break; + case 'kPod': + sourceClass = [NSNumber numberWithInt:ITMTRemoteiPodSource]; + break; + case 'kMCD': + case 'kACD': + sourceClass = [NSNumber numberWithInt:ITMTRemoteCDSource]; + break; + case 'kShd': + sourceClass = [NSNumber numberWithInt:ITMTRemoteSharedLibrarySource]; + break; + case 'kUnk': + case 'kLib': + default: + sourceClass = [NSNumber numberWithInt:ITMTRemoteLibrarySource]; + break; + } + + [aSource addObject:sourceClass]; for (i = 1; i <= numPlaylists; i++) { NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%u), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } } }",i,k]; NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; @@ -166,7 +194,7 @@ { int temp1; ITDebugLog(@"Getting number of songs in playlist at index %i", index); - temp1 = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() }",index] eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; + temp1 = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:[NSString stringWithFormat:@"kocl:type('cTrk'), '----':obj { form:'indx', want:type('cPly'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('ctnr'), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index] eventClass:@"core" eventID:@"cnte" appPSN:savedPSN]; ITDebugLog(@"Getting number of songs in playlist at index %i done", index); return temp1; } diff --git a/libValidate.a b/libValidate.a index 907ced5..34e2f0d 100755 Binary files a/libValidate.a and b/libValidate.a differ