X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/31ab86a87f78edfdd32810db1ff708ca8f5eaaca..081a5fa6db149252a499575da751c45f340312bd:/iTunesRemote.m?ds=sidebyside diff --git a/iTunesRemote.m b/iTunesRemote.m index 36a38db..5781211 100755 --- a/iTunesRemote.m +++ b/iTunesRemote.m @@ -1,151 +1,106 @@ +/* Copyright (c) 2002 - 2003 by iThink Software. All Rights Reserved. */ + #import "iTunesRemote.h" @implementation iTunesRemote -+ (id)remote -{ ++ (id)remote { return [[[iTunesRemote alloc] init] autorelease]; } -- (NSString *)title -{ +- (id)valueOfProperty:(ITMTRemoteProperty)property { + // Get from Info.plist return nil; } -- (NSString *)information; -{ +- (NSDictionary *)propertiesAndValues { + // Get from Info.plist return nil; } -- (NSImage *)icon -{ - return nil; +- (ITMTPlayerStyle)playerStyle { + return ITMTSinglePlayerStyle; } -- (BOOL)begin -{ - return NO; +- (BOOL)activate { + if ( !_activated ) { + if ( [self iTunesIsRunning] ) { + _currentPSN = [self iTunesPSN]; + } else { + if ( [self launchiTunes] ) { + _currentPSN = [self iTunesPSN]; + } else { + return NO; + } + } + if ( ( _player = [iTunesPlayer sharedPlayerForRemote:self] ) ) { + _activated = YES; + return YES; + } + } else { + return NO; + } } -- (BOOL)halt -{ - return NO; +- (BOOL)deactivate { + if ( _activated ) { + _currentPSN = kNoProcess; + _player = nil; + _activated = NO; + return YES; + } else { + return NO; + } } -- (NSArray *)sources -{ - return nil; +- (ITMTPlayer *)currentPlayer { + if (_activated) { + return _player; + } else { + return nil; + } } -- (int)currentSourceIndex -{ - return nil; -} - -- (NSArray *)playlistsForCurrentSource -{ - return nil; +- (NSArray *)players { + if (_activated) { + return [NSArray arrayWithObject:_player]; + } else { + return nil; + } } -- (int)currentPlaylistIndex -{ - return nil; -} - -- (NSString *)songTitleAtIndex -{ - return nil; -} - -- (int)currentSongIndex -{ - return nil; -} - -- (NSString *)currentSongTitle -{ - return nil; -} - -- (NSString *)currentSongArtist -{ - return nil; -} - -- (NSString *)currentSongAlbum -{ - return nil; -} - -- (NSString *)currentSongGenre -{ - return nil; -} +#pragma mark - +#pragma mark INTERNAL METHODS +#pragma mark - -- (NSString *)currentSongLength -{ - return nil; -} - -- (NSString *)currentSongRemaining -{ - return nil; -} - -- (NSArray *)eqPresets; -{ - return nil; -} - -- (BOOL)play -{ - return NO; -} - -- (BOOL)pause -{ - return NO; -} - -- (BOOL)goToNextSong -{ - return NO; -} - -- (BOOL)goToPreviousSong -{ - return NO; -} - -- (BOOL)goToNextPlaylist -{ - return NO; -} - -- (BOOL)goToPreviousPlaylist -{ +- (BOOL)launchiTunes { return NO; } -- (BOOL)switchToSourceAtIndex:(int)index -{ - return NO; -} - -- (BOOL)switchToPlaylistAtIndex:(int)index -{ +- (BOOL)iTunesIsRunning { return NO; } -- (BOOL)switchToSongAtIndex:(int)index -{ - return NO; -} - -- (BOOL)switchToEQAtIndex:(int)index -{ - return NO; +- (ProcessSerialNumber)iTunesPSN +{ + ProcessSerialNumber number; + number.highLongOfPSN = kNoProcess; + number.lowLongOfPSN = 0; + + while ( (GetNextProcess(&number) == noErr) ) + { + CFStringRef name; + if ( (CopyProcessName(&number, &name) == noErr) ) + { + if ([(NSString *)name isEqualToString:@"iTunes"]) + { + return number; + } + [(NSString *)name release]; + } + } + return number; } @end