Hopefully fixed one last bug with the multisource playlists. Added some
authorKent Sutherland <ksuther@ithinksw.com>
Wed, 18 Feb 2004 21:36:50 +0000 (21:36 +0000)
committerKent Sutherland <ksuther@ithinksw.com>
Wed, 18 Feb 2004 21:36:50 +0000 (21:36 +0000)
iPod NSLog test code.

MainController.h
MainController.m
MenuController.m
PreferencesController.m
iTunesRemote.m

index ae6f7fd..08722af 100755 (executable)
@@ -19,6 +19,8 @@
 #import <ITMTRemote/ITMTRemote.h>
 #import "MTBlingController.h"
 
 #import <ITMTRemote/ITMTRemote.h>
 #import "MTBlingController.h"
 
+#define MT_CURRENT_VERSION 1300
+
 @class StatusWindowController, MenuController, NetworkController;
 
 @interface MainController : NSObject
 @class StatusWindowController, MenuController, NetworkController;
 
 @interface MainController : NSObject
@@ -54,6 +56,8 @@
 - (void)blingNow;
 - (BOOL)blingBling;
 
 - (void)blingNow;
 - (BOOL)blingBling;
 
+- (void)timerUpdate;
+
 - (void)playPause;
 - (void)nextSong;
 - (void)prevSong;
 - (void)playPause;
 - (void)nextSong;
 - (void)prevSong;
index a543288..6f14518 100755 (executable)
@@ -36,7 +36,6 @@
 
 @interface MainController(Private)
 - (ITMTRemote *)loadRemote;
 
 @interface MainController(Private)
 - (ITMTRemote *)loadRemote;
-- (void)timerUpdate;
 - (void)setLatestSongIdentifier:(NSString *)newIdentifier;
 - (void)applicationLaunched:(NSNotification *)note;
 - (void)applicationTerminated:(NSNotification *)note;
 - (void)setLatestSongIdentifier:(NSString *)newIdentifier;
 - (void)applicationLaunched:(NSNotification *)note;
 - (void)applicationTerminated:(NSNotification *)note;
@@ -214,7 +213,7 @@ static MainController *sharedController;
     globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
     if (date) {
         [globalPrefs setObject:date forKey:@"ITMTTrialStart"];
     globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
     if (date) {
         [globalPrefs setObject:date forKey:@"ITMTTrialStart"];
-        [globalPrefs setObject:[NSNumber numberWithInt:1200] forKey:@"ITMTTrialVers"];
+        [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
     } else {
         [globalPrefs removeObjectForKey:@"ITMTTrialStart"];
         [globalPrefs removeObjectForKey:@"ITMTTrialVers"];
     } else {
         [globalPrefs removeObjectForKey:@"ITMTTrialStart"];
         [globalPrefs removeObjectForKey:@"ITMTTrialVers"];
@@ -236,14 +235,14 @@ static MainController *sharedController;
     if (![self blingBling]) {
         if ( (! [self getBlingTime] ) || ([now timeIntervalSinceDate:[self getBlingTime]] < 0) ) {
             [self setBlingTime:now];
     if (![self blingBling]) {
         if ( (! [self getBlingTime] ) || ([now timeIntervalSinceDate:[self getBlingTime]] < 0) ) {
             [self setBlingTime:now];
-        } else if ([[[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialVers"] intValue] < 1200) {
+        } else if ([[[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialVers"] intValue] < MT_CURRENT_VERSION) {
             if ([now timeIntervalSinceDate:[self getBlingTime]] >= 345600) {
                 [self setBlingTime:[now addTimeInterval:-259200]];
             } else {
                 NSMutableDictionary *globalPrefs;
                 [df synchronize];
                 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
             if ([now timeIntervalSinceDate:[self getBlingTime]] >= 345600) {
                 [self setBlingTime:[now addTimeInterval:-259200]];
             } else {
                 NSMutableDictionary *globalPrefs;
                 [df synchronize];
                 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
-                [globalPrefs setObject:[NSNumber numberWithInt:1200] forKey:@"ITMTTrialVers"];
+                [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
                 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
                 [df synchronize];
                 [globalPrefs release];
                 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
                 [df synchronize];
                 [globalPrefs release];
index f416474..4b4ee50 100755 (executable)
@@ -22,7 +22,7 @@
 - (NSMenu *)eqMenu;
 - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
         onItem:(id <NSMenuItem>)item;
 - (NSMenu *)eqMenu;
 - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
         onItem:(id <NSMenuItem>)item;
-- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name;
+- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name;
 @end
 
 @implementation MenuController
 @end
 
 @implementation MenuController
     NS_HANDLER
         [[MainController sharedController] networkError:localException];
     NS_ENDHANDLER
     NS_HANDLER
         [[MainController sharedController] networkError:localException];
     NS_ENDHANDLER
+    ITDebugLog(@"Releasing old submenus.");
     [_ratingMenu release];
     [_upcomingSongsMenu release];
     [_playlistsMenu release];
     [_ratingMenu release];
     [_upcomingSongsMenu release];
     [_playlistsMenu release];
     int i, j;
     NS_DURING
         playlists = [[[MainController sharedController] currentRemote] playlists];
     int i, j;
     NS_DURING
         playlists = [[[MainController sharedController] currentRemote] playlists];
-        /*playlists = [NSArray arrayWithObjects:
-                        [NSArray arrayWithObjects:@"Library", [NSNumber numberWithInt:-1], @"Library", @"Playlist", nil],
-                        [NSArray arrayWithObjects:@"Radio", [NSNumber numberWithInt:1], @"Radio", nil], nil];*/
     NS_HANDLER
         [[MainController sharedController] networkError:localException];
     NS_ENDHANDLER
     NS_HANDLER
         [[MainController sharedController] networkError:localException];
     NS_ENDHANDLER
         NSMenu *submenu = [[NSMenu alloc] init];
         ITDebugLog(@"Adding source: %@", name);
         
         NSMenu *submenu = [[NSMenu alloc] init];
         ITDebugLog(@"Adding source: %@", name);
         
-        if ( ([[curPlaylist objectAtIndex:i] intValue] == ITMTRemoteiPodSource) && [self iPodAtPathAutomaticallyUpdates:[curPlaylist objectAtIndex:j]] ) {
+        if ([[curPlaylist objectAtIndex:1] intValue] == ITMTRemoteiPodSource) {
+            NSLog(@"We have an iPod!");
+            NSLog(@"This iPod is named %@!", name);
+            NSLog(@"Does it update automagically?");
+            NSLog(@"Result: %i", [self iPodWithNameAutomaticallyUpdates:name]);
+        }
+        
+        if ( ([[curPlaylist objectAtIndex:1] intValue] == ITMTRemoteiPodSource) && [self iPodWithNameAutomaticallyUpdates:name] ) {
             ITDebugLog(@"Invalid iPod source.");
         } else {
             for (j = 2; j < [curPlaylist count]; j++) {
             ITDebugLog(@"Invalid iPod source.");
         } else {
             for (j = 2; j < [curPlaylist count]; j++) {
     ITDebugLog(@"Done setting key equivalent on menu item: %@", [item title]);
 }
 
     ITDebugLog(@"Done setting key equivalent on menu item: %@", [item title]);
 }
 
-- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name
+- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name
 {
     NSArray *volumes = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
     NSEnumerator *volEnum = [volumes objectEnumerator];
 {
     NSArray *volumes = [[NSWorkspace sharedWorkspace] mountedLocalVolumePaths];
     NSEnumerator *volEnum = [volumes objectEnumerator];
index 726f1e8..dcbc6af 100755 (executable)
@@ -536,7 +536,7 @@ static PreferencesController *prefs = nil;
         @"quit",
         nil] forKey:@"menu"];
 
         @"quit",
         nil] forKey:@"menu"];
 
-    [df setInteger:1200 forKey:@"appVersion"];
+    [df setInteger:MT_CURRENT_VERSION forKey:@"appVersion"];
     [df setInteger:5 forKey:@"SongsInAdvance"];
 //  [df setBool:YES forKey:@"showName"];  // Song info will always show song title.
     [df setBool:YES forKey:@"showArtist"];
     [df setInteger:5 forKey:@"SongsInAdvance"];
 //  [df setBool:YES forKey:@"showName"];  // Song info will always show song title.
     [df setBool:YES forKey:@"showArtist"];
@@ -770,6 +770,8 @@ static PreferencesController *prefs = nil;
     int selectedBGStyle;
     id anItem;
     
     int selectedBGStyle;
     id anItem;
     
+    [df setInteger:MT_CURRENT_VERSION forKey:@"appVersion"];
+    
     ITDebugLog(@"Setting up preferences UI.");
     // Fill in the number of songs in advance to show field
     [songsInAdvance setIntValue:[df integerForKey:@"SongsInAdvance"]];
     ITDebugLog(@"Setting up preferences UI.");
     // Fill in the number of songs in advance to show field
     [songsInAdvance setIntValue:[df integerForKey:@"SongsInAdvance"]];
index 0702568..397353c 100755 (executable)
         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];
         unsigned long class;
         NSMutableArray *aSource = [[NSMutableArray alloc] init];
         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];
         unsigned long class;
         NSMutableArray *aSource = [[NSMutableArray alloc] init];
-        [aSource addObject:sourceName];
+        [aSource addObject:[[sourceName copy] autorelease]];
         switch (fourcc) {
             case 'kTun':
                 class = ITMTRemoteRadioSource;
         switch (fourcc) {
             case 'kTun':
                 class = ITMTRemoteRadioSource;
             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];
             ITDebugLog(@" - Adding playlist %@", theObj);
             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];
             ITDebugLog(@" - Adding playlist %@", theObj);
-            [aSource addObject:theObj];
+            [aSource addObject:[[theObj copy] autorelease]];
         }
         }
-        [allSources addObject:aSource];
-        [aSource release];
+        [allSources addObject:[aSource autorelease]];
     }
     ITDebugLog(@"Finished getting playlists.");
     return [allSources autorelease];
     }
     ITDebugLog(@"Finished getting playlists.");
     return [allSources autorelease];
 
 - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass
 {
 
 - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass
 {
-    int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
-    
+    int realResult;
     ITDebugLog(@"Getting current playlist class");
     ITDebugLog(@"Getting current playlist class");
+    realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN];
     switch (realResult)
           {
           case 'cLiP':
     switch (realResult)
           {
           case 'cLiP':