From 616ff6ad61cfc198ff23200bdb450c24d9436073 Mon Sep 17 00:00:00 2001 From: Joseph Spiros Date: Tue, 11 Mar 2003 00:24:43 +0000 Subject: [PATCH] Plugin API changes --- ITMTRemote.h | 38 ++++++++++++++++++++++++-------------- ITMTRemote.m | 6 +++--- MenuTunes.h | 2 +- MenuTunes.m | 10 +++++----- iTunesRemote.m | 16 ++++++++-------- 5 files changed, 41 insertions(+), 31 deletions(-) diff --git a/ITMTRemote.h b/ITMTRemote.h index 693d908..dd6ca6b 100755 --- a/ITMTRemote.h +++ b/ITMTRemote.h @@ -29,11 +29,17 @@ #import typedef enum { - stopped = -1, - paused, - playing, - rewinding, - forwarding + ITMTRemotePlayerNotRunning = -1, + ITMTRemotePlayerLaunching, + ITMTRemotePlayerRunning +} ITMTRemotePlayerRunningStatus; + +typedef enum { + ITMTRemotePlayerStopped = -1, + ITMTRemotePlayerPaused, + ITMTRemotePlayerPlaying, + ITMTRemotePlayerRewinding, + ITMTRemotePlayerForwarding } ITMTRemotePlayerState; /*! @protocol ITMTRemote @@ -55,23 +61,23 @@ typedef enum { */ + (id)remote; -/*! @method title: +/*! @method pluginTitle: * @abstract Returns the title of the plugin, which should be player name. * @result An NSString containing the title. */ -- (NSString *)title; +- (NSString *)pluginTitle; -/*! @method description: +/*! @method pluginInformation: * @abstract Returns a description of the remote. * @result An NSString containing the description. */ -- (NSString *)information; +- (NSString *)pluginInformation; -/*! @method icon: +/*! @method pluginIcon: * @abstract Returns a icon for the remote. * @result An NSImage containing the icon. */ -- (NSImage *)icon; +- (NSImage *)pluginIcon; /*! @method begin: * @abstract Sent when the plugin should begin operation. @@ -85,11 +91,15 @@ typedef enum { */ - (BOOL)halt; -/*! @method isAppRunning: +- (NSString *)playerFullName; + +- (NSString *)playerSimpleName; + +/*! @method playerRunningStatus: * @abstract Returns controlled application's running status (is or isn't running). * @result BOOL of the controlled application's running status. */ -- (BOOL)isAppRunning; +- (ITMTRemotePlayerRunningStatus)playerRunningStatus; /*! @method playerState: * @abstract Returns controlled application's playing state. @@ -125,7 +135,7 @@ typedef enum { - (BOOL)pause; - (BOOL)goToNextSong; - (BOOL)goToPreviousSong; -- (BOOL)fastForward; +- (BOOL)forward; - (BOOL)rewind; - (BOOL)switchToPlaylistAtIndex:(int)index; diff --git a/ITMTRemote.m b/ITMTRemote.m index 78922f4..c003989 100755 --- a/ITMTRemote.m +++ b/ITMTRemote.m @@ -33,14 +33,14 @@ return NO; } -- (BOOL)isAppRunning +- (ITMTRemotePlayerRunningStatus)playerRunningStatus { - return NO; + return ITMTRemotePlayerNotRunning; } - (ITMTRemotePlayerState)playerState { - return stopped; + return ITMTRemotePlayerStopped; } - (NSArray *)playlists diff --git a/MenuTunes.h b/MenuTunes.h index 92aade2..69791b9 100755 --- a/MenuTunes.h +++ b/MenuTunes.h @@ -36,7 +36,7 @@ int lastPlaylistIndex; BOOL isPlayingRadio; - BOOL isAppRunning; + ITMTRemotePlayerRunningStatus isAppRunning; BOOL didHaveAlbumName; BOOL didHaveArtistName; //Helper variable for creating the menu diff --git a/MenuTunes.m b/MenuTunes.m index 2f3b083..9115c10 100755 --- a/MenuTunes.m +++ b/MenuTunes.m @@ -44,7 +44,7 @@ menu = [[NSMenu alloc] initWithTitle:@""]; - if ([currentRemote isAppRunning]) { + if ( ( [currentRemote remotePlayerStatus] == ITMTRemotePlayerRunning ) ) { [self remotePlayerLaunched:nil]; } else { [self remotePlayerTerminated:nil]; @@ -322,7 +322,7 @@ NSMenuItem *menuItem; NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; - if (!isAppRunning) { + if ( ( isAppRunning = ITMTRemotePlayerNotRunning ) ) { return; } @@ -698,7 +698,7 @@ - (void)remotePlayerLaunched:(NSNotification *)note { - isAppRunning = YES; + isAppRunning = ITMTRemotePlayerRunning; //Restart the timer refreshTimer = [NSTimer scheduledTimerWithTimeInterval:3.0 target:self selector:@selector(timerUpdate) userInfo:nil repeats:YES]; @@ -715,7 +715,7 @@ - (void)remotePlayerTerminated:(NSNotification *)note { - isAppRunning = NO; + isAppRunning = ITMTRemotePlayerNotRunning; [menu release]; menu = [[NSMenu alloc] initWithTitle:@""]; @@ -832,7 +832,7 @@ - (void)closePreferences { - if (isAppRunning) { + if ( ( isAppRunning == ITMTRemotePlayerRunning) ) { [self setupHotKeys]; } [prefsController release]; diff --git a/iTunesRemote.m b/iTunesRemote.m index e479c63..d50d55d 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -43,7 +43,7 @@ return YES; } -- (BOOL)isAppRunning +- (ITMTRemotePlayerRunningStatus)playerRunningStatus { NSArray *apps = [[NSWorkspace sharedWorkspace] launchedApplications]; int i; @@ -52,10 +52,10 @@ for (i = 0; i < count; i++) { if ([[[apps objectAtIndex:i] objectForKey:@"NSApplicationName"] isEqualToString:@"iTunes"]) { - return YES; + return ITMTRemotePlayerRunning; } } - return NO; + return ITMTRemotePlayerNotRunning; } - (ITMTRemotePlayerState)playerState @@ -66,15 +66,15 @@ { default: case 'kPSS': - return stopped; + return ITMTRemotePlayerStopped; case 'kPSP': - return playing; + return ITMTRemotePlayerPlaying; case 'kPSp': - return paused; + return ITMTRemotePlayerPaused; case 'kPSR': - return rewinding; + return ITMTRemotePlayerRewinding; case 'kPSF': - return forwarding; + return ITMTRemotePlayerForwarding; } return stopped; -- 2.20.1