Worked on it some... see the TODO file for bugs I've fixed, or might have
authorJoseph Spiros <joseph.spiros@ithinksw.com>
Mon, 14 Apr 2003 07:35:21 +0000 (07:35 +0000)
committerJoseph Spiros <joseph.spiros@ithinksw.com>
Mon, 14 Apr 2003 07:35:21 +0000 (07:35 +0000)
fixed, etc. I also added some notes in there.. Matt should check them out
and modify the bugs themself as he sees fit.

ITMTRemote.h
ITMTRemote.m
OldMainController.m
TODO.rtf
iTunesRemote.h
iTunesRemote.m

index 2d55b42..c58ab65 100755 (executable)
@@ -209,6 +209,16 @@ typedef enum {
  */
 - (NSString *)songTitleAtIndex:(int)index;
 
+/*!
+ * @method currentAlbumTrackCount:
+ */
+- (int)currentAlbumTrackCount;
+
+/*!
+ * @method currentSongTrack:
+ */
+- (int)currentSongTrack;
+
 /*!
  * @method currentSongUniqueIdentifier:
  */
@@ -259,16 +269,6 @@ typedef enum {
  */
 - (BOOL)setCurrentSongRating:(float)rating;
 
-/*!
- * @method equalizerEnabled
- */
-- (BOOL)equalizerEnabled;
-
-/*!
- * @method setEqualizerEnabled:
- */
-- (BOOL)setEqualizerEnabled:(BOOL)enabled;
-
 /*!
  * @method eqPresets
  */
index 5cd7733..80cccb7 100755 (executable)
     return nil;
 }
 
+- (int)currentAlbumTrackCount
+{
+    return nil;
+}
+
+- (int)currentSongTrack
+{
+    return nil;
+}
+
 - (NSString *)currentSongUniqueIdentifier
 {
     return nil;
     return NO;
 }
 
-- (BOOL)equalizerEnabled
+/* - (BOOL)equalizerEnabled
 {
     return NO;
 }
 - (BOOL)setEqualizerEnabled:(BOOL)enabled
 {
     return NO;
-}
+} */
 
 - (NSArray *)eqPresets
 {
index f1d170d..8160644 100755 (executable)
     }
     
     isAppRunning = ITMTRemotePlayerRunning;
+    NSLog(@"applicationTerminated");
 }
 
 - (void)applicationTerminated:(NSNotification *)note
     lastSongIdentifier = [[currentRemote currentSongUniqueIdentifier] retain];
     
     //If we're in a playlist or radio mode
-    if ( (trackInfoIndex > -1) && (playlist || isPlayingRadio) ) {
+    if ( (trackInfoIndex > -1) ) {
         NSString *title;
         
-        if ( (i = [menu indexOfItemWithTitle:@"No Song"]) && (i > -1) ) {
-            [menu removeItemAtIndex:i];
-            [menu insertItemWithTitle:@"Now Playing" action:NULL keyEquivalent:@"" atIndex:i];
+        if ( (i = [menu indexOfItemWithTitle:@"No Song"]) ) {
+            if ( (i > -1) ) {
+                [menu removeItemAtIndex:i];
+                [menu insertItemWithTitle:@"Now Playing" action:NULL keyEquivalent:@"" atIndex:i-1];
+            }
         }
         
         title = [currentRemote currentSongTitle];
             }
             
             if ([defaults boolForKey:@"showTrackRating"]) {
+                if (title) { //Check to see if there's a song playing
                 [menu insertItemWithTitle:[NSString stringWithFormat:@"         %@", [[ratingMenu itemAtIndex:[currentRemote currentSongRating] * 5] title]] action:nil keyEquivalent:@"" atIndex:trackInfoIndex + 1];
+                }
             }
             
             if ([defaults boolForKey:@"showArtist"]) {
                 }
             }
             
+            if ([defaults boolForKey:@"showTrackNumber"]) {
+                int track = [currentRemote currentSongTrack];
+                int total = [currentRemote currentAlbumTrackCount];
+                if (total > 0) {
+                    [menu insertItemWithTitle:[NSString stringWithFormat:@"  Track %i of %i", track, total] action:nil keyEquivalent:@"" atIndex:trackInfoIndex + 1];
+                }
+            }
+            
             if ([defaults boolForKey:@"showAlbum"]) {
                 NSString *album = [currentRemote currentSongAlbum];
                 if ([album length] > 0) {
 - (void)rebuildEQPresetsMenu
 {
     NSArray *eqPresets = [currentRemote eqPresets];
-    NSMenuItem *enabledItem;
     int i;
     
-    [eqMenu release];
+    [eqMenu autorelease];
     eqMenu = [[NSMenu alloc] initWithTitle:@""];
     
-    enabledItem = [eqMenu addItemWithTitle:@"Enabled"
-                          action:@selector(selectEQPreset:)
-                          keyEquivalent:@""];
-    [enabledItem setTag:-1];
-    
-    if ([currentRemote equalizerEnabled]) {
-        [enabledItem setState:NSOnState];
-    }
-    
-    [eqMenu addItem:[NSMenuItem separatorItem]];
-    
     for (i = 0; i < [eqPresets count]; i++) {
-        NSString *name = [eqPresets objectAtIndex:i];
+        NSString *name;
         NSMenuItem *tempItem;
-       if (name) {
+       if ( ( name = [eqPresets objectAtIndex:i] ) ) {
             tempItem = [[NSMenuItem alloc] initWithTitle:name action:@selector(selectEQPreset:) keyEquivalent:@""];
             [tempItem setTag:i];
             [eqMenu addItem:tempItem];
-            [tempItem release];
+            [tempItem autorelease];
        }
     }
     [eqItem setSubmenu:eqMenu];
     [eqItem setEnabled:YES];
     
-    [[eqMenu itemAtIndex:[currentRemote currentEQPresetIndex] + 1] setState:NSOnState];
+    [[eqMenu itemAtIndex:([currentRemote currentEQPresetIndex] - 1)] setState:NSOnState];
 }
 
 - (void)updateRatingMenu
     int curSet = [currentRemote currentEQPresetIndex];
     int item = [sender tag];
     
-    if (item == -1) {
-        [currentRemote setEqualizerEnabled:![currentRemote equalizerEnabled]];
-    } else {
-        [currentRemote setEqualizerEnabled:YES];
-        [currentRemote switchToEQAtIndex:item];
-        [[eqMenu itemAtIndex:curSet + 1] setState:NSOffState];
-        [[eqMenu itemAtIndex:item + 2] setState:NSOnState];
-    }
+    [currentRemote switchToEQAtIndex:item];
+    [[eqMenu itemAtIndex:curSet - 1] setState:NSOffState];
+    [[eqMenu itemAtIndex:item] setState:NSOnState];
 }
 
 - (void)selectSongRating:(id)sender
         //Space -- ARGH!
         case 49:
         {
+            // Haven't tested this, though it should work.
+            unichar buffer;
+            [[NSString stringWithString:@"Space"] getCharacters:&buffer];
+            charcode = buffer;
             /*MenuRef menuRef = _NSGetCarbonMenu([item menu]);
             NSLog(@"%@", menuRef);
             SetMenuItemCommandKey(menuRef, 0, NO, 49);
             SetMenuItemModifiers(menuRef, 0, kMenuNoCommandModifier);
             SetMenuItemKeyGlyph(menuRef, 0, kMenuBlankGlyph);
             charcode = 'b';*/
+            
         }
         break;
         
index a5a1623..141520f 100755 (executable)
--- a/TODO.rtf
+++ b/TODO.rtf
@@ -1,7 +1,7 @@
 {\rtf1\mac\ansicpg10000\cocoartf102
 {\fonttbl\f0\fnil\fcharset77 Futura-CondensedExtraBold;\f1\fswiss\fcharset77 Helvetica;\f2\fswiss\fcharset77 Helvetica-Bold;
 \f3\fnil\fcharset77 Monaco;}
-{\colortbl;\red255\green255\blue255;\red198\green198\blue198;\red198\green198\blue198;}
+{\colortbl;\red255\green255\blue255;\red198\green198\blue198;}
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
 
 \f0\b\fs72 \cf0 MenuTunes Issues\
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
       Status: Analyze\
-       Issue: Menu - Rebuild speed is abyssmal.  It needs to take less than half a second.\
+       Issue: Menu - Rebuild speed is abyssmal.  It needs to take less than half a second. (Note [Joe] I believe something (not sure what) I did tonight fixed this.. double check for me, though, as I wasn't the one who reported this bug)\
 \
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
       Status: Analyze\
-       Issue: HotKeys - FKeys (F1 - F15) must be made to work without a modifier key.\
+       Issue: HotKeys - FKeys (F1 - F15) must be made to work without a modifier key. (Note [Joe] Might want to make this 1.1, or even 1.0.1, as this actually requires us to do some research, and we might not have time)\
 \
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
       Status: Analyze\
-       Issue: HotKeys - Hotkeys which use the space bar must show the word "Space" in the menu.\
+       Issue: HotKeys - Hotkeys which use the space bar must show the word "Space" in the menu. (Note [Joe] I believe the code I added for this will work, though since hotkeys won't save, I can't test it...)\
 \
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
                                \'a5 Rating changed (show song info window, forcing rating to show)\
                                \'a5 Loop mode changed (show loop mode window)\
                                \'a5 Shuffle mode changed (show shuffle mode window)\
-\
-    Priority: SHOWSTOPPER\
-       Owner: Kent Sutherland\
-      Status: Assigned\
-       Issue: Hot Keys (Preferences) - Changing hot keys in the prefs has no effect.\
 \
     Priority: SHOWSTOPPER\
        Owner: Matthew Judy\
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
       Status: Assigned\
-       Issue: Menu - Shows "No Song" when one is playing. (if not in a playlist?)\
+       Issue: Menu - Shows "No Song" when one is playing. (if not in a playlist?) (Note [Joe] this is misleading, it still shows the song's info, it just says "No Song" at the beginning of the Song info block. Also, I'm not exactly sure how it couldn't be in a playlist, at least, using the iTunes plugin, since even the Library is a playlist)\
 \
     Priority: SHOWSTOPPER\
        Owner: Joseph Spiros\
       Status: Assigned\
-       Issue: Menu - Show <Player> - Does not work.\
+       Issue: iTunesRemote - Show iTunes - Is not Fully Implemented.\
 \
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
       Status: Assigned\
-       Issue: Menu - Song Info displayed twice in menu if MT is launched when iTunes is already open.\
+       Issue: Menu - Song Info displayed twice in menu if MT is launched when iTunes is already open. (Note [Joe] Haven't been able to reproduce this)\
 \
     Priority: SHOWSTOPPER\
        Owner: Kent Sutherland\
     Priority: Important\
        Owner: Kent Sutherland\
       Status: Assigned\
-       Issue: Hot Keys (Preferences) - Migrate to new style.\
+       Issue: Hot Keys (Preferences) - Migrate to new style. (Note [Joe] Move this to a 1.1 future feature... we don't have time, and old style works great, apart from above problem)\
        \
 \pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
 \cf2     Priority: SHOWSTOPPER\
-\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
-\cf3        Owner: Kent Sutherland\
+       Owner: Kent Sutherland\
       Status: Closed\
        Issue: Preferences (Menu) - Show Player - Needs to show the player name (Show iTunes).\
        \
index 384c24c..04b1cdb 100755 (executable)
@@ -17,6 +17,4 @@
     ProcessSerialNumber iTunesPSN;
 }
 - (ProcessSerialNumber)iTunesPSN;
-- (void)applicationLaunched:(NSNotification *)note;
-- (void)applicationTerminated:(NSNotification *)note;
 @end
index 0723d73..0f537fb 100755 (executable)
     return [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"'----':obj { form:'prop', want:type('prop'), seld:type('pnam'), from:obj { form:'indx', want:type('cTrk'), seld:long(%lu), from:obj { form:'prop', want:type('prop'), seld:type('pPla'), from:'null'() } } }",index] eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
 }
 
+- (int)currentAlbumTrackCount
+{
+    return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrC" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
+}
+
+- (int)currentSongTrack
+{
+    return [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pTrN" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
+}
+
 - (NSString *)currentSongUniqueIdentifier
 {
     return [NSString stringWithFormat:@"%i-%i", [self currentPlaylistIndex], [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pDID" fromObjectByKey:@"pTrk" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN]];
     return YES;
 }
 
-- (BOOL)equalizerEnabled
+/* - (BOOL)equalizerEnabled
 {
     int thingy = [[ITAppleEventCenter sharedCenter] sendAEWithSendStringForNumber:@"'----':obj { form:type('prop'), want:type('prop'), seld:type('pEQ '), from:() }" eventClass:@"core" eventID:@"getd" appPSN:iTunesPSN];
     NSLog(@"Debug equalizerEnabled: %i", thingy);
-    return thingy;    
+    return thingy;
 }
 
 - (BOOL)setEqualizerEnabled:(BOOL)enabled
 {
     [[ITAppleEventCenter sharedCenter] sendAEWithSendString:[NSString stringWithFormat:@"data:long(%lu), '----':obj { form:'prop', want:type('prop'), seld:type('pEQ '), from:'null'() }",enabled] eventClass:@"core" eventID:@"setd" appPSN:iTunesPSN];
     return YES;
-}
+} */
 
 - (NSArray *)eqPresets
 {
     return number;
 }
 
-- (void)applicationLaunched:(NSNotification *)note
-{
-    NSDictionary *info = [note userInfo];
-
-    if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
-        iTunesPSN.highLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberHigh"] longValue];
-        iTunesPSN.lowLongOfPSN = [[info objectForKey:@"NSApplicationProcessSerialNumberLow"] longValue];
-
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidLaunchNotification" object:nil];
-    }
-}
-
-- (void)applicationTerminated:(NSNotification *)note
-{
-    NSDictionary *info = [note userInfo];
-
-    if ([[info objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) {
-        iTunesPSN.highLongOfPSN = kNoProcess;
-        [[NSNotificationCenter defaultCenter] postNotificationName:@"ITMTRemoteAppDidTerminateNotification" object:nil];
-    }
-}
-
 @end