Prefs window updates the remote server name each time. Fixed
authorKent Sutherland <ksuther@ithinksw.com>
Sat, 13 Dec 2003 22:06:51 +0000 (22:06 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Sat, 13 Dec 2003 22:06:51 +0000 (22:06 +0000)
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.

MenuController.m
PreferencesController.m
iTunesRemote.m
libValidate.a

index 3916267..9c7f9b5 100755 (executable)
     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) {
index 7bc3db8..1aee038 100755 (executable)
@@ -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];
index 5f3944c..c7d17a8 100755 (executable)
     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;
 }
index 907ced5..34e2f0d 100755 (executable)
Binary files a/libValidate.a and b/libValidate.a differ