NS_HANDLER
[[MainController sharedController] networkError:localException];
NS_ENDHANDLER
-
[_ratingMenu release];
[_upcomingSongsMenu release];
[_playlistsMenu release];
NS_ENDHANDLER
ITDebugLog(@"Building \"Upcoming Songs\" menu.");
-
if (_currentPlaylist && !_playingRadio) {
if (numSongs > 0) {
int i;
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];
}
}
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) {
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];
{
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;
}