From: Kent Sutherland Date: Wed, 18 Feb 2004 21:36:50 +0000 (+0000) Subject: Hopefully fixed one last bug with the multisource playlists. Added some X-Git-Tag: v1.3~28 X-Git-Url: http://git.ithinksw.org/MenuTunes.git/commitdiff_plain/62c12e7f7c182a22969de8ebb233db31d9965454 Hopefully fixed one last bug with the multisource playlists. Added some iPod NSLog test code. --- diff --git a/MainController.h b/MainController.h index ae6f7fd..08722af 100755 --- a/MainController.h +++ b/MainController.h @@ -19,6 +19,8 @@ #import #import "MTBlingController.h" +#define MT_CURRENT_VERSION 1300 + @class StatusWindowController, MenuController, NetworkController; @interface MainController : NSObject @@ -54,6 +56,8 @@ - (void)blingNow; - (BOOL)blingBling; +- (void)timerUpdate; + - (void)playPause; - (void)nextSong; - (void)prevSong; diff --git a/MainController.m b/MainController.m index a543288..6f14518 100755 --- a/MainController.m +++ b/MainController.m @@ -36,7 +36,6 @@ @interface MainController(Private) - (ITMTRemote *)loadRemote; -- (void)timerUpdate; - (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 setObject:[NSNumber numberWithInt:1200] forKey:@"ITMTTrialVers"]; + [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"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]; - } 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]; - [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]; diff --git a/MenuController.m b/MenuController.m index f416474..4b4ee50 100755 --- a/MenuController.m +++ b/MenuController.m @@ -22,7 +22,7 @@ - (NSMenu *)eqMenu; - (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers onItem:(id )item; -- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name; +- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name; @end @implementation MenuController @@ -438,6 +438,7 @@ NS_HANDLER [[MainController sharedController] networkError:localException]; NS_ENDHANDLER + ITDebugLog(@"Releasing old submenus."); [_ratingMenu release]; [_upcomingSongsMenu release]; [_playlistsMenu release]; @@ -574,9 +575,6 @@ 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 @@ -606,7 +604,14 @@ 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++) { @@ -981,7 +986,7 @@ 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]; diff --git a/PreferencesController.m b/PreferencesController.m index 726f1e8..dcbc6af 100755 --- a/PreferencesController.m +++ b/PreferencesController.m @@ -536,7 +536,7 @@ static PreferencesController *prefs = nil; @"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"]; @@ -770,6 +770,8 @@ static PreferencesController *prefs = nil; 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"]]; diff --git a/iTunesRemote.m b/iTunesRemote.m index 0702568..397353c 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -168,7 +168,7 @@ 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; @@ -198,10 +198,9 @@ 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]; @@ -262,9 +261,9 @@ - (ITMTRemotePlayerPlaylistClass)currentPlaylistClass { - int realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; - + int realResult; ITDebugLog(@"Getting current playlist class"); + realResult = [[ITAppleEventCenter sharedCenter] sendTwoTierAEWithRequestedKeyForNumber:@"pcls" fromObjectByKey:@"pPla" eventClass:@"core" eventID:@"getd" appPSN:savedPSN]; switch (realResult) { case 'cLiP':