Did some tinkering, nothing really useful done though. Removed a useless
[MenuTunes.git] / iTunesRemote.m
index a312eba..68890d3 100755 (executable)
     const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN];
     NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:numPlaylists];
     
     const signed long numPlaylists = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cPly'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN];
     NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:numPlaylists];
     
-    ITDebugLog(@"Getting playlists.");
-    
     for (i = 1; i <= numPlaylists; i++) {
         const long j = i;
         NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j];
         NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     for (i = 1; i <= numPlaylists; i++) {
         const long j = i;
         NSString *sendStr = [NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cPly'), seld:long(%lu), from:'null'() } }",(unsigned long)j];
         NSString *theObj = [[ITAppleEventCenter sharedCenter] sendAEWithSendString:sendStr eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
-        ITDebugLog(@"Adding playlist: %@", theObj);
         [playlists addObject:theObj];
     }
         [playlists addObject:theObj];
     }
-    ITDebugLog(@"Finished getting playlists.");
     return [playlists autorelease];
     return [playlists autorelease];
+    /*unsigned long i,k;
+    const signed long numSources = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"kocl:type('cSrc'), '----':()" eventClass:@"core" eventID:@"cnte" appPSN:savedPSN];
+    NSMutableArray *playlists = [[NSMutableArray alloc] initWithCapacity:1];
+    
+    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];
+        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];
+            [playlists addObject:theObj];
+        }
+    }
+    ITDebugLog(@"Finished getting playlists.");
+    return [playlists autorelease];*/
 }
 
 - (int)numberOfSongsInPlaylistAtIndex:(int)index
 }
 
 - (int)numberOfSongsInPlaylistAtIndex:(int)index
             ITDebugLog(@"Getting current source done. Source: CD.");
             return ITMTRemoteCDSource;
             break;
             ITDebugLog(@"Getting current source done. Source: CD.");
             return ITMTRemoteCDSource;
             break;
+        case 'kShd':
+            ITDebugLog(@"Getting current source done. Source: Shared Library.");
+            return ITMTRemoteSharedLibrarySource;
+            break;
         case 'kUnk':
         case 'kLib':
         case 'kUnk':
         case 'kLib':
-        case 'kShd':
         default:
             ITDebugLog(@"Getting current source done. Source: Library.");
             return ITMTRemoteLibrarySource;
         default:
             ITDebugLog(@"Getting current source done. Source: Library.");
             return ITMTRemoteLibrarySource;
     return finalString;
 }
 
     return finalString;
 }
 
+- (NSImage *)currentSongAlbumArt
+{
+    return nil;
+}
+
 - (float)currentSongRating
 {
     float temp1;
 - (float)currentSongRating
 {
     float temp1;
 - (NSString*)formatTimeInSeconds:(long)seconds {
     long final = seconds;
     NSString *finalString;
 - (NSString*)formatTimeInSeconds:(long)seconds {
     long final = seconds;
     NSString *finalString;
-    if (final > 60) {
+    if (final >= 60) {
         if (final > 3600) {
             finalString = [NSString stringWithFormat:@"%i:%@:%@",(final / 3600),[self zeroSixty:(int)((final % 3600) / 60)],[self zeroSixty:(int)((final % 3600) % 60)]];
         } else {
         if (final > 3600) {
             finalString = [NSString stringWithFormat:@"%i:%@:%@",(final / 3600),[self zeroSixty:(int)((final % 3600) / 60)],[self zeroSixty:(int)((final % 3600) % 60)]];
         } else {