iPod NSLog test code.
#import <ITMTRemote/ITMTRemote.h>
#import "MTBlingController.h"
+#define MT_CURRENT_VERSION 1300
+
@class StatusWindowController, MenuController, NetworkController;
@interface MainController : NSObject
- (void)blingNow;
- (BOOL)blingBling;
+- (void)timerUpdate;
+
- (void)playPause;
- (void)nextSong;
- (void)prevSong;
@interface MainController(Private)
- (ITMTRemote *)loadRemote;
-- (void)timerUpdate;
- (void)setLatestSongIdentifier:(NSString *)newIdentifier;
- (void)applicationLaunched:(NSNotification *)note;
- (void)applicationTerminated:(NSNotification *)note;
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"];
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];
- (NSMenu *)eqMenu;
- (void)setKeyEquivalentForCode:(short)code andModifiers:(long)modifiers
onItem:(id <NSMenuItem>)item;
-- (BOOL)iPodAtPathAutomaticallyUpdates:(NSString *)name;
+- (BOOL)iPodWithNameAutomaticallyUpdates:(NSString *)name;
@end
@implementation MenuController
NS_HANDLER
[[MainController sharedController] networkError:localException];
NS_ENDHANDLER
+ ITDebugLog(@"Releasing old submenus.");
[_ratingMenu release];
[_upcomingSongsMenu release];
[_playlistsMenu release];
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
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(@"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];
@"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"];
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"]];
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;
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];
- (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':