+}*/
+
+//Full source awareness
+- (NSArray *)playlists
+{
+ unsigned long i, k;
+ SInt32 numSources = [ITSendAEWithString(@"kocl:type('cSrc'), '----':()", 'core', 'cnte', &savedPSN) int32Value];
+ NSMutableArray *allSources = [[NSMutableArray alloc] init];
+
+ ITDebugLog(@"Getting playlists.");
+ if (numSources == 0) {
+ ITDebugLog(@"No sources.");
+ return nil;
+ }
+
+ for (k = 1; k <= numSources ; k++) {
+ SInt32 numPlaylists = [ITSendAEWithString([NSString stringWithFormat:@"kocl:type('cPly'), '----':obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() }",k], 'core', 'cnte', &savedPSN) int32Value];
+ SInt32 fourcc = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pKnd'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k], 'core', 'getd', &savedPSN) int32Value];
+ NSString *sourceName = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k], 'core', 'getd', &savedPSN) stringValue];
+ SInt32 index = [ITSendAEWithString([NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pidx'), from:obj { form:'indx', want:type('cSrc'), seld:long(%u), from:() } }",k], 'core', 'getd', &savedPSN) int32Value];
+ unsigned long class;
+ if (sourceName) {
+ NSMutableArray *aSource = [[NSMutableArray alloc] init];
+ [aSource addObject:sourceName];
+ switch (fourcc) {
+ case 'kTun':
+ class = ITMTRemoteRadioSource;
+ break;
+ case 'kDev':
+ class = ITMTRemoteGenericDeviceSource;
+ break;
+ case 'kPod':
+ class = ITMTRemoteiPodSource;
+ break;
+ case 'kMCD':
+ case 'kACD':
+ class = ITMTRemoteCDSource;
+ break;
+ case 'kShd':
+ class = ITMTRemoteSharedLibrarySource;
+ break;
+ case 'kUnk':
+ case 'kLib':
+ default:
+ class = ITMTRemoteLibrarySource;
+ break;
+ }
+ ITDebugLog(@"Adding source %@ of type %i at index %i", sourceName, class, index);
+ [aSource addObject:[NSNumber numberWithInt:class]];
+ [aSource addObject:[NSNumber numberWithInt:index]];
+ 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 = [ITSendAEWithString(sendStr, 'core', 'getd', &savedPSN) stringValue];
+ ITDebugLog(@" - Adding playlist %@", theObj);
+ if (theObj) {
+ [aSource addObject:theObj];
+ }
+ }
+ [allSources addObject:[aSource autorelease]];
+ } else {
+ ITDebugLog(@"Source at index %i disappeared.", k);
+ }
+ }
+ ITDebugLog(@"Finished getting playlists.");
+ return [allSources autorelease];
+}
+
+- (NSArray *)artists
+{
+ NSAppleEventDescriptor *rawr = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pArt'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN);
+ int i;
+ NSMutableArray *array = [[NSMutableArray alloc] init];
+ NSArray *returnArray;
+ for (i = 1; i <= [rawr numberOfItems]; i++) {
+ NSString *artist = [[rawr descriptorAtIndex:i] stringValue];
+ if (artist && [artist length] && ![array containsObject:artist]) {
+ [array addObject:artist];
+ }
+ }
+ [array sortUsingSelector:@selector(caseInsensitiveCompare:)];
+ returnArray = [NSArray arrayWithArray:array];
+ [array release];
+ return returnArray;
+}
+
+- (NSArray *)albums
+{
+ NSAppleEventDescriptor *rawr = ITSendAEWithString(@"'----':obj { form:'prop', want:type('prop'), seld:type('pAlb'), from:obj { form:'indx', want:type('cTrk'), seld:abso($616C6C20$), from:obj { form:'indx', want:type('cPly'), seld:long(1), from:obj { form:'indx', want:type('cSrc'), seld:long(1), from:() } } } }", 'core', 'getd', &savedPSN);
+ int i;
+ NSMutableArray *array = [[NSMutableArray alloc] init];
+ NSArray *returnArray;
+ for (i = 1; i <= [rawr numberOfItems]; i++) {
+ NSString *album = [[rawr descriptorAtIndex:i] stringValue];
+ if (album && [album length] && ![array containsObject:album]) {
+ [array addObject:album];
+ }
+ }
+ [array sortUsingSelector:@selector(caseInsensitiveCompare:)];
+ returnArray = [NSArray arrayWithArray:array];
+ [array release];
+ return returnArray;