X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/b5dfd502c729e9535246a5bde4d9463696f0ed11..0b83e13fdd374e0ac55397663cedb94bf8df197f:/MainController.m diff --git a/MainController.m b/MainController.m index bd93fca..bffb59c 100755 --- a/MainController.m +++ b/MainController.m @@ -64,7 +64,7 @@ static MainController *sharedController; if ([df boolForKey:@"enableSharing"]) { [self setServerStatus:YES]; } else if ([df boolForKey:@"useSharedPlayer"]) { - if (![self connectToServer]) { + if ([self connectToServer] == 0) { [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES]; } } @@ -244,7 +244,7 @@ static MainController *sharedController; - (BOOL)songIsPlaying { - NSString *identifier; + NSString *identifier = nil; NS_DURING identifier = [[self currentRemote] playerStateUniqueIdentifier]; NS_HANDLER @@ -255,7 +255,7 @@ static MainController *sharedController; - (BOOL)radioIsPlaying { - ITMTRemotePlayerPlaylistClass class; + ITMTRemotePlayerPlaylistClass class = nil; NS_DURING class = [[self currentRemote] currentPlaylistClass]; NS_HANDLER @@ -266,7 +266,7 @@ static MainController *sharedController; - (BOOL)songChanged { - NSString *identifier; + NSString *identifier = nil; NS_DURING identifier = [[self currentRemote] playerStateUniqueIdentifier]; NS_HANDLER @@ -476,6 +476,11 @@ static MainController *sharedController; [[PreferencesController sharedPrefs] showPrefsWindow:self]; } +- (void)showTestWindow +{ + [self showCurrentTrackInfo]; +} + - (void)quitMenuTunes { ITDebugLog(@"Quitting MenuTunes."); @@ -648,8 +653,8 @@ static MainController *sharedController; - (void)showCurrentTrackInfo { - ITMTRemotePlayerSource source; - NSString *title; + ITMTRemotePlayerSource source = 0; + NSString *title = nil; NSString *album = nil; NSString *artist = nil; NSString *time = nil; @@ -695,8 +700,8 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTrackNumber"] ) { - int trackNo; - int trackCount; + int trackNo = 0; + int trackCount = 0; NS_DURING trackNo = [[self currentRemote] currentSongTrack]; @@ -712,7 +717,7 @@ static MainController *sharedController; } if ( [df boolForKey:@"showTrackRating"] ) { - float currentRating; + float currentRating = 0; NS_DURING currentRating = [[self currentRemote] currentSongRating]; @@ -740,8 +745,7 @@ static MainController *sharedController; - (void)showUpcomingSongs { - int numSongs; - + int numSongs = 0; NS_DURING numSongs = [[self currentRemote] numberOfSongsInPlaylistAtIndex:[[self currentRemote] currentPlaylistIndex]]; NS_HANDLER @@ -751,8 +755,8 @@ static MainController *sharedController; ITDebugLog(@"Showing upcoming songs status window."); NS_DURING if (numSongs > 0) { - NSMutableArray *songList = [NSMutableArray arrayWithCapacity:5]; int numSongsInAdvance = [df integerForKey:@"SongsInAdvance"]; + NSMutableArray *songList = [NSMutableArray arrayWithCapacity:numSongsInAdvance]; int curTrack = [[self currentRemote] currentSongIndex]; int i; @@ -762,6 +766,10 @@ static MainController *sharedController; } } + if ([songList count] == 0) { + [songList addObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")]; + } + [statusWindowController showUpcomingSongsWindowWithTitles:songList]; } else { [statusWindowController showUpcomingSongsWindowWithTitles:[NSArray arrayWithObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")]]; @@ -943,7 +951,7 @@ static MainController *sharedController; } } -- (BOOL)connectToServer +- (int)connectToServer { int result; ITDebugLog(@"Attempting to connect to shared remote."); @@ -954,16 +962,16 @@ static MainController *sharedController; currentRemote = [[[networkController networkObject] remote] retain]; [self timerUpdate]; ITDebugLog(@"Connection successful."); - return YES; + return 1; } else if (result == 0) { ITDebugLog(@"Connection failed."); currentRemote = [remoteArray objectAtIndex:0]; - return NO; + return 0; } else { //Do something about the password being invalid ITDebugLog(@"Connection failed."); currentRemote = [remoteArray objectAtIndex:0]; - return NO; + return -1; } } @@ -1009,7 +1017,7 @@ static MainController *sharedController; - (void)reconnect { - if (![self connectToServer]) { + if ([self connectToServer] == 0) { [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES]; } [[StatusWindow sharedWindow] setLocked:NO];