1 #import "MainController.h"
2 #import "MenuController.h"
3 #import "PreferencesController.h"
4 #import "NetworkController.h"
5 #import "NetworkObject.h"
6 #import <ITKit/ITHotKeyCenter.h>
7 #import <ITKit/ITHotKey.h>
8 #import <ITKit/ITKeyCombo.h>
9 #import <ITKit/ITCategory-NSMenu.h>
10 #import "StatusWindow.h"
11 #import "StatusWindowController.h"
12 #import "StatusItemHack.h"
14 @interface NSMenu (MenuImpl)
18 @interface NSCarbonMenuImpl:NSObject
24 + (void)setupForNoMenuBar;
28 - (void)itemChanged:fp8;
29 - (void)itemAdded:fp8;
30 - (void)itemRemoved:fp8;
31 - (void)performActionWithHighlightingForItemAtIndex:(int)fp8;
32 - (void)performMenuAction:(SEL)fp8 withTarget:fp12;
33 - (void)setupCarbonMenuBar;
34 - (void)setAsMainCarbonMenuBar;
35 - (void)clearAsMainCarbonMenuBar;
36 - (void)popUpMenu:fp8 atLocation:(NSPoint)fp12 width:(float)fp20 forView:fp24 withSelectedItem:(int)fp28 withFont:fp32;
37 - (void)_popUpContextMenu:fp8 withEvent:fp12 forView:fp16 withFont:fp20;
38 - (void)_popUpContextMenu:fp8 withEvent:fp12 forView:fp16;
42 @implementation NSImage (SmoothAdditions)
44 - (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
47 NSImageRep *rep = [self bestRepresentationForDevice:nil];
49 newImage = [[NSImage alloc] initWithSize:scaledSize];
52 [[NSGraphicsContext currentContext] setImageInterpolation:NSImageInterpolationHigh];
53 [[NSGraphicsContext currentContext] setShouldAntialias:YES];
54 [rep drawInRect:NSMakeRect(3, 3, scaledSize.width - 6, scaledSize.height - 6)];
56 [newImage unlockFocus];
57 return [newImage autorelease];
62 @interface MainController(Private)
63 - (ITMTRemote *)loadRemote;
64 - (void)setLatestSongIdentifier:(NSString *)newIdentifier;
65 - (void)applicationLaunched:(NSNotification *)note;
66 - (void)applicationTerminated:(NSNotification *)note;
69 static MainController *sharedController;
71 @implementation MainController
73 + (MainController *)sharedController
75 return sharedController;
78 /*************************************************************************/
80 #pragma mark INITIALIZATION/DEALLOCATION METHODS
81 /*************************************************************************/
85 if ( ( self = [super init] ) ) {
86 sharedController = self;
88 remoteArray = [[NSMutableArray alloc] initWithCapacity:1];
89 [[PreferencesController sharedPrefs] setController:self];
90 statusWindowController = [StatusWindowController sharedController];
91 menuController = [[MenuController alloc] init];
92 df = [[NSUserDefaults standardUserDefaults] retain];
99 - (void)applicationDidFinishLaunching:(NSNotification *)note
101 //Turn on debug mode if needed
102 if ([df boolForKey:@"ITDebugMode"]) {
106 if (([df integerForKey:@"appVersion"] < 1200) && ([df integerForKey:@"SongsInAdvance"] > 0)) {
107 [df removePersistentDomainForName:@"com.ithinksw.menutunes"];
109 [[PreferencesController sharedPrefs] registerDefaults];
110 [[StatusWindowController sharedController] showPreferencesUpdateWindow];
113 currentRemote = [self loadRemote];
114 [[self currentRemote] begin];
116 //Turn on network stuff if needed
117 networkController = [[NetworkController alloc] init];
118 if ([df boolForKey:@"enableSharing"]) {
119 [self setServerStatus:YES];
120 } else if ([df boolForKey:@"useSharedPlayer"]) {
121 [self checkForRemoteServerAndConnectImmediately:YES];
124 //Setup for notification of the remote player launching or quitting
125 [[[NSWorkspace sharedWorkspace] notificationCenter]
127 selector:@selector(applicationTerminated:)
128 name:NSWorkspaceDidTerminateApplicationNotification
131 [[[NSWorkspace sharedWorkspace] notificationCenter]
133 selector:@selector(applicationLaunched:)
134 name:NSWorkspaceDidLaunchApplicationNotification
137 if (![df objectForKey:@"menu"]) { // If this is nil, defaults have never been registered.
138 [[PreferencesController sharedPrefs] registerDefaults];
141 if ([df boolForKey:@"ITMTNoStatusItem"]) {
144 [StatusItemHack install];
145 statusItem = [[ITStatusItem alloc]
146 initWithStatusBar:[NSStatusBar systemStatusBar]
147 withLength:NSSquareStatusItemLength];
150 /*bling = [[MTBlingController alloc] init];
152 registerTimer = [[NSTimer scheduledTimerWithTimeInterval:10.0
154 selector:@selector(blingTime)
156 repeats:YES] retain];*/
159 if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
160 [self applicationLaunched:nil];
162 if ([df boolForKey:@"LaunchPlayerWithMT"])
165 [self applicationTerminated:nil];
168 [self networkError:localException];
171 [statusItem setImage:[NSImage imageNamed:@"MenuNormal"]];
172 [statusItem setAlternateImage:[NSImage imageNamed:@"MenuInverted"]];
174 [networkController startRemoteServerSearch];
176 [self performSelector:@selector(rawr) withObject:nil afterDelay:1.0];
178 bling = [[MTBlingController alloc] init];
180 registerTimer = [[NSTimer scheduledTimerWithTimeInterval:10.0
182 selector:@selector(blingTime)
184 repeats:YES] retain];
192 - (void)applicationDidBecomeActive:(NSNotification *)note
194 if (_open && !blinged && ![NSApp mainWindow] && ![[StatusWindow sharedWindow] isVisible]) {
195 [[MainController sharedController] showPreferences];
199 - (ITMTRemote *)loadRemote
201 NSString *folderPath = [[NSBundle mainBundle] builtInPlugInsPath];
202 ITDebugLog(@"Gathering remotes.");
204 NSArray *bundlePathList = [NSBundle pathsForResourcesOfType:@"remote" inDirectory:folderPath];
205 NSEnumerator *enumerator = [bundlePathList objectEnumerator];
206 NSString *bundlePath;
208 while ( (bundlePath = [enumerator nextObject]) ) {
209 NSBundle* remoteBundle = [NSBundle bundleWithPath:bundlePath];
212 Class remoteClass = [remoteBundle principalClass];
214 if ([remoteClass conformsToProtocol:@protocol(ITMTRemote)] &&
215 [(NSObject *)remoteClass isKindOfClass:[NSObject class]]) {
216 id remote = [remoteClass remote];
217 ITDebugLog(@"Adding remote at path %@", bundlePath);
218 [remoteArray addObject:remote];
223 // if ( [remoteArray count] > 0 ) { // UNCOMMENT WHEN WE HAVE > 1 PLUGIN
224 // if ( [remoteArray count] > 1 ) {
225 // [remoteArray sortUsingSelector:@selector(sortAlpha:)];
227 // [self loadModuleAccessUI]; //Comment out this line to disable remote visibility
230 // NSLog(@"%@", [remoteArray objectAtIndex:0]); //DEBUG
231 return [remoteArray objectAtIndex:0];
234 /*************************************************************************/
236 #pragma mark INSTANCE METHODS
237 /*************************************************************************/
239 /*- (void)startTimerInNewThread
241 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
242 NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
243 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5
245 selector:@selector(timerUpdate)
247 repeats:YES] retain];
249 ITDebugLog(@"Timer started.");
253 - (void)setBlingTime:(NSDate*)date
255 NSMutableDictionary *globalPrefs;
257 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
259 [globalPrefs setObject:date forKey:@"ITMTTrialStart"];
260 [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
262 [globalPrefs removeObjectForKey:@"ITMTTrialStart"];
263 [globalPrefs removeObjectForKey:@"ITMTTrialVers"];
265 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
267 [globalPrefs release];
270 - (NSDate*)getBlingTime
273 return [[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialStart"];
278 NSDate *now = [NSDate date];
279 if (![self blingBling]) {
280 if ( (! [self getBlingTime] ) || ([now timeIntervalSinceDate:[self getBlingTime]] < 0) ) {
281 [self setBlingTime:now];
282 } else if ([[[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialVers"] intValue] < MT_CURRENT_VERSION) {
283 if ([now timeIntervalSinceDate:[self getBlingTime]] >= 345600) {
284 [self setBlingTime:[now addTimeInterval:-259200]];
286 NSMutableDictionary *globalPrefs;
288 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
289 [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
290 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
292 [globalPrefs release];
296 if ( ([now timeIntervalSinceDate:[self getBlingTime]] >= 604800) && (blinged != YES) ) {
298 [statusItem setEnabled:NO];
299 [[ITHotKeyCenter sharedCenter] setEnabled:NO];
300 if ([refreshTimer isValid]) {
301 [refreshTimer invalidate];
302 [refreshTimer release];
305 [statusWindowController showRegistrationQueryWindow];
309 [statusItem setEnabled:YES];
310 [[ITHotKeyCenter sharedCenter] setEnabled:YES];
311 if (![refreshTimer isValid]) {
312 [refreshTimer release];
313 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
315 selector:@selector(timerUpdate)
317 repeats:YES] retain];
321 [self setBlingTime:nil];
332 if ( ! ([bling checkDone] == 2475) ) {
339 - (BOOL)songIsPlaying
341 NSString *identifier = nil;
343 identifier = [[self currentRemote] playerStateUniqueIdentifier];
345 [self networkError:localException];
347 return ( ! ([identifier isEqualToString:@"0-0"]) );
350 - (BOOL)radioIsPlaying
352 ITMTRemotePlayerPlaylistClass class = nil;
354 class = [[self currentRemote] currentPlaylistClass];
356 [self networkError:localException];
358 return (class == ITMTRemotePlayerRadioPlaylist );
363 NSString *identifier = nil;
365 identifier = [[self currentRemote] playerStateUniqueIdentifier];
367 [self networkError:localException];
369 return ( ! [identifier isEqualToString:_latestSongIdentifier] );
372 - (NSString *)latestSongIdentifier
374 return _latestSongIdentifier;
377 - (void)setLatestSongIdentifier:(NSString *)newIdentifier
379 ITDebugLog(@"Setting latest song identifier:");
380 ITDebugLog(@" - Identifier: %@", newIdentifier);
381 [_latestSongIdentifier autorelease];
382 _latestSongIdentifier = [newIdentifier retain];
387 NSString *identifier = [[self currentRemote] playerStateUniqueIdentifier];
388 if (refreshTimer && identifier == nil) {
389 if ([statusItem isEnabled]) {
390 [statusItem setToolTip:@"iTunes not responding."];
392 [statusItem setEnabled:NO];
394 } else if (![statusItem isEnabled]) {
395 [statusItem setEnabled:YES];
396 [statusItem setToolTip:_toolTip];
400 if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
401 ITDebugLog(@"The song changed. '%@'", _latestSongIdentifier);
402 if ([df boolForKey:@"runScripts"]) {
403 NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]];
404 NSEnumerator *scriptsEnum = [scripts objectEnumerator];
405 NSString *nextScript;
406 ITDebugLog(@"Running AppleScripts for song change.");
407 while ( (nextScript = [scriptsEnum nextObject]) ) {
409 NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
410 ITDebugLog(@"Running script: %@", nextScript);
411 if (!currentScript || ![currentScript executeAndReturnError:nil]) {
412 ITDebugLog(@"Error running script %@.", nextScript);
414 [currentScript release];
419 [statusItem setEnabled:NO];
422 latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
424 if ([menuController rebuildSubmenus]) {
425 if ( [df boolForKey:@"showSongInfoOnChange"] ) {
426 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
428 [self setLatestSongIdentifier:identifier];
429 //Create the tooltip for the status item
430 if ( [df boolForKey:@"showToolTip"] ) {
431 NSString *artist = [[self currentRemote] currentSongArtist];
432 NSString *title = [[self currentRemote] currentSongTitle];
433 ITDebugLog(@"Creating status item tooltip.");
435 _toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title];
439 _toolTip = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
441 [statusItem setToolTip:_toolTip];
443 [statusItem setToolTip:nil];
447 [self networkError:localException];
450 [statusItem setEnabled:YES];
453 if ([networkController isConnectedToServer]) {
454 [statusItem setMenu:([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) ? [menuController menu] : [menuController menuForNoPlayer]];
460 ITDebugLog(@"Menu clicked.");
462 if (([[self currentRemote] playerStateUniqueIdentifier] == nil) && playerRunningState == ITMTRemotePlayerRunning) {
464 if ([statusItem isEnabled]) {
465 [statusItem setToolTip:NSLocalizedString(@"iTunesNotResponding", @"iTunes is not responding.")];
467 [statusItem setEnabled:NO];
469 NSMenu *menu = [[NSMenu alloc] init];
470 [menu addItemWithTitle:NSLocalizedString(@"iTunesNotResponding", @"iTunes is not responding.") action:nil keyEquivalent:@""];
471 [statusItem setMenu:[menu autorelease]];
474 } else if (![statusItem isEnabled]) {
475 [statusItem setEnabled:YES];
476 [statusItem setToolTip:_toolTip];
480 if ([networkController isConnectedToServer]) {
481 //Used the cached version
486 if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
487 [statusItem setMenu:[menuController menu]];
489 [statusItem setMenu:[menuController menuForNoPlayer]];
492 [self networkError:localException];
496 - (void)trackChanged:(NSNotification *)note
498 //If we're running the timer, shut it off since we don't need it!
499 if (refreshTimer && [refreshTimer isValid]) {
500 ITDebugLog(@"Invalidating refresh timer.");
501 [refreshTimer invalidate];
502 [refreshTimer release];
506 if (![self songChanged]) {
509 NSString *identifier = [[self currentRemote] playerStateUniqueIdentifier];
510 if ( [df boolForKey:@"showSongInfoOnChange"] ) {
511 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
513 [_lastTrackInfo release];
514 _lastTrackInfo = [[note userInfo] retain];
516 [self setLatestSongIdentifier:identifier];
517 ITDebugLog(@"The song changed. '%@'", _latestSongIdentifier);
518 if ([df boolForKey:@"runScripts"]) {
519 NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]];
520 NSEnumerator *scriptsEnum = [scripts objectEnumerator];
521 NSString *nextScript;
522 ITDebugLog(@"Running AppleScripts for song change.");
523 while ( (nextScript = [scriptsEnum nextObject]) ) {
525 NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
526 ITDebugLog(@"Running script: %@", nextScript);
527 if (!currentScript || ![currentScript executeAndReturnError:nil]) {
528 ITDebugLog(@"Error running script %@.", nextScript);
530 [currentScript release];
534 [statusItem setEnabled:NO];
537 latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
539 if ([menuController rebuildSubmenus]) {
540 /*if ( [df boolForKey:@"showSongInfoOnChange"] ) {
541 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
543 [self setLatestSongIdentifier:identifier];
544 //Create the tooltip for the status item
545 if ( [df boolForKey:@"showToolTip"] ) {
546 ITDebugLog(@"Creating status item tooltip.");
547 NSString *artist = [_lastTrackInfo objectForKey:@"Artist"], *title = [_lastTrackInfo objectForKey:@"Name"];
549 _toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title];
553 _toolTip = NSLocalizedString(@"noSongPlaying", @"No song is playing.");;
555 [statusItem setToolTip:_toolTip];
557 [statusItem setToolTip:nil];
561 [self networkError:localException];
564 [statusItem setEnabled:YES];
566 if ([networkController isConnectedToServer]) {
567 [statusItem setMenu:([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) ? [menuController menu] : [menuController menuForNoPlayer]];
580 ITMTRemotePlayerPlayingState state = [[self currentRemote] playerPlayingState];
581 ITDebugLog(@"Play/Pause toggled");
582 if (state == ITMTRemotePlayerPlaying) {
583 [[self currentRemote] pause];
584 } else if ((state == ITMTRemotePlayerForwarding) || (state == ITMTRemotePlayerRewinding)) {
585 [[self currentRemote] pause];
586 [[self currentRemote] play];
588 [[self currentRemote] play];
591 [self networkError:localException];
601 ITDebugLog(@"Going to next song.");
603 [[self currentRemote] goToNextSong];
605 [self networkError:localException];
614 ITDebugLog(@"Going to previous song.");
616 [[self currentRemote] goToPreviousSong];
618 [self networkError:localException];
627 ITDebugLog(@"Fast forwarding.");
629 [[self currentRemote] forward];
631 [self networkError:localException];
640 ITDebugLog(@"Rewinding.");
642 [[self currentRemote] rewind];
644 [self networkError:localException];
651 - (void)selectPlaylistAtIndex:(int)index
653 ITDebugLog(@"Selecting playlist %i", index);
655 [[self currentRemote] switchToPlaylistAtIndex:(index % 1000) ofSourceAtIndex:(index / 1000)];
656 //[[self currentRemote] switchToPlaylistAtIndex:index];
658 [self networkError:localException];
665 - (void)selectSongAtIndex:(int)index
667 ITDebugLog(@"Selecting song %i", index);
669 [[self currentRemote] switchToSongAtIndex:index];
671 [self networkError:localException];
678 - (void)selectSongRating:(int)rating
680 ITDebugLog(@"Selecting song rating %i", rating);
682 [[self currentRemote] setCurrentSongRating:(float)rating / 100.0];
684 [self networkError:localException];
691 - (void)selectEQPresetAtIndex:(int)index
693 ITDebugLog(@"Selecting EQ preset %i", index);
696 [[self currentRemote] setEqualizerEnabled:![[self currentRemote] equalizerEnabled]];
698 [[self currentRemote] switchToEQAtIndex:index];
701 [self networkError:localException];
708 - (void)makePlaylistWithTerm:(NSString *)term ofType:(int)type
710 ITDebugLog(@"Making playlist with term %@, type %i", term, type);
712 [[self currentRemote] makePlaylistWithTerm:term ofType:type];
714 [self networkError:localException];
716 ITDebugLog(@"Done making playlist");
721 ITDebugLog(@"Beginning show player.");
722 //if ( ( playerRunningState == ITMTRemotePlayerRunning) ) {
723 ITDebugLog(@"Showing player interface.");
725 [[self currentRemote] showPrimaryInterface];
727 [self networkError:localException];
730 ITDebugLog(@"Launching player.");
733 if ( (path = [df stringForKey:@"CustomPlayerPath"]) ) {
735 pathITDebugLog(@"Showing player interface."); = [[self currentRemote] playerFullName];
737 if (![[NSWorkspace sharedWorkspace] launchApplication:path]) {
738 ITDebugLog(@"Error Launching Player");
741 [self networkError:localException];
744 ITDebugLog(@"Finished show player.");
747 - (void)showPreferences
749 ITDebugLog(@"Show preferences.");
750 [[PreferencesController sharedPrefs] showPrefsWindow:self];
753 - (void)showPreferencesAndClose
755 ITDebugLog(@"Show preferences.");
756 [[PreferencesController sharedPrefs] showPrefsWindow:self];
757 [[StatusWindow sharedWindow] setLocked:NO];
758 [[StatusWindow sharedWindow] vanish:self];
759 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
762 - (void)showTestWindow
764 [self showCurrentTrackInfo];
767 - (void)quitMenuTunes
769 ITDebugLog(@"Quitting MenuTunes.");
770 [NSApp terminate:self];
776 - (MenuController *)menuController
778 return menuController;
781 - (void)closePreferences
783 ITDebugLog(@"Preferences closed.");
784 if ( ( playerRunningState == ITMTRemotePlayerRunning) ) {
789 - (ITMTRemote *)currentRemote
791 if ([networkController isConnectedToServer] && ![[networkController networkObject] isValid]) {
792 [self networkError:nil];
795 return currentRemote;
806 NSEnumerator *hotKeyEnumerator = [[[ITHotKeyCenter sharedCenter] allHotKeys] objectEnumerator];
807 ITHotKey *nextHotKey;
808 ITDebugLog(@"Clearing hot keys.");
809 while ( (nextHotKey = [hotKeyEnumerator nextObject]) ) {
810 [[ITHotKeyCenter sharedCenter] unregisterHotKey:nextHotKey];
812 ITDebugLog(@"Done clearing hot keys.");
818 ITDebugLog(@"Setting up hot keys.");
820 if (playerRunningState == ITMTRemotePlayerNotRunning && ![[NetworkController sharedController] isConnectedToServer]) {
824 if ([df objectForKey:@"PlayPause"] != nil) {
825 ITDebugLog(@"Setting up play pause hot key.");
826 hotKey = [[ITHotKey alloc] init];
827 [hotKey setName:@"PlayPause"];
828 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PlayPause"]]];
829 [hotKey setTarget:self];
830 [hotKey setAction:@selector(playPause)];
831 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
834 if ([df objectForKey:@"NextTrack"] != nil) {
835 ITDebugLog(@"Setting up next track hot key.");
836 hotKey = [[ITHotKey alloc] init];
837 [hotKey setName:@"NextTrack"];
838 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"NextTrack"]]];
839 [hotKey setTarget:self];
840 [hotKey setAction:@selector(nextSong)];
841 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
844 if ([df objectForKey:@"PrevTrack"] != nil) {
845 ITDebugLog(@"Setting up previous track hot key.");
846 hotKey = [[ITHotKey alloc] init];
847 [hotKey setName:@"PrevTrack"];
848 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PrevTrack"]]];
849 [hotKey setTarget:self];
850 [hotKey setAction:@selector(prevSong)];
851 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
854 if ([df objectForKey:@"FastForward"] != nil) {
855 ITDebugLog(@"Setting up fast forward hot key.");
856 hotKey = [[ITHotKey alloc] init];
857 [hotKey setName:@"FastForward"];
858 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"FastForward"]]];
859 [hotKey setTarget:self];
860 [hotKey setAction:@selector(fastForward)];
861 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
864 if ([df objectForKey:@"Rewind"] != nil) {
865 ITDebugLog(@"Setting up rewind hot key.");
866 hotKey = [[ITHotKey alloc] init];
867 [hotKey setName:@"Rewind"];
868 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"Rewind"]]];
869 [hotKey setTarget:self];
870 [hotKey setAction:@selector(rewind)];
871 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
874 if ([df objectForKey:@"ShowPlayer"] != nil) {
875 ITDebugLog(@"Setting up show player hot key.");
876 hotKey = [[ITHotKey alloc] init];
877 [hotKey setName:@"ShowPlayer"];
878 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]]];
879 [hotKey setTarget:self];
880 [hotKey setAction:@selector(showPlayer)];
881 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
884 if ([df objectForKey:@"TrackInfo"] != nil) {
885 ITDebugLog(@"Setting up track info hot key.");
886 hotKey = [[ITHotKey alloc] init];
887 [hotKey setName:@"TrackInfo"];
888 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"TrackInfo"]]];
889 [hotKey setTarget:self];
890 [hotKey setAction:@selector(showCurrentTrackInfo)];
891 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
894 if ([df objectForKey:@"UpcomingSongs"] != nil) {
895 ITDebugLog(@"Setting up upcoming songs hot key.");
896 hotKey = [[ITHotKey alloc] init];
897 [hotKey setName:@"UpcomingSongs"];
898 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"UpcomingSongs"]]];
899 [hotKey setTarget:self];
900 [hotKey setAction:@selector(showUpcomingSongs)];
901 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
904 if ([df objectForKey:@"ToggleLoop"] != nil) {
905 ITDebugLog(@"Setting up toggle loop hot key.");
906 hotKey = [[ITHotKey alloc] init];
907 [hotKey setName:@"ToggleLoop"];
908 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleLoop"]]];
909 [hotKey setTarget:self];
910 [hotKey setAction:@selector(toggleLoop)];
911 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
914 if ([df objectForKey:@"ToggleShuffle"] != nil) {
915 ITDebugLog(@"Setting up toggle shuffle hot key.");
916 hotKey = [[ITHotKey alloc] init];
917 [hotKey setName:@"ToggleShuffle"];
918 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleShuffle"]]];
919 [hotKey setTarget:self];
920 [hotKey setAction:@selector(toggleShuffle)];
921 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
924 if ([df objectForKey:@"IncrementVolume"] != nil) {
925 ITDebugLog(@"Setting up increment volume hot key.");
926 hotKey = [[ITHotKey alloc] init];
927 [hotKey setName:@"IncrementVolume"];
928 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementVolume"]]];
929 [hotKey setTarget:self];
930 [hotKey setAction:@selector(incrementVolume)];
931 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
934 if ([df objectForKey:@"DecrementVolume"] != nil) {
935 ITDebugLog(@"Setting up decrement volume hot key.");
936 hotKey = [[ITHotKey alloc] init];
937 [hotKey setName:@"DecrementVolume"];
938 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementVolume"]]];
939 [hotKey setTarget:self];
940 [hotKey setAction:@selector(decrementVolume)];
941 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
944 if ([df objectForKey:@"IncrementRating"] != nil) {
945 ITDebugLog(@"Setting up increment rating hot key.");
946 hotKey = [[ITHotKey alloc] init];
947 [hotKey setName:@"IncrementRating"];
948 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementRating"]]];
949 [hotKey setTarget:self];
950 [hotKey setAction:@selector(incrementRating)];
951 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
954 if ([df objectForKey:@"DecrementRating"] != nil) {
955 ITDebugLog(@"Setting up decrement rating hot key.");
956 hotKey = [[ITHotKey alloc] init];
957 [hotKey setName:@"DecrementRating"];
958 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementRating"]]];
959 [hotKey setTarget:self];
960 [hotKey setAction:@selector(decrementRating)];
961 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
964 if ([df objectForKey:@"PopupMenu"] != nil) {
965 ITDebugLog(@"Setting up popup menu hot key.");
966 hotKey = [[ITHotKey alloc] init];
967 [hotKey setName:@"PopupMenu"];
968 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PopupMenu"]]];
969 [hotKey setTarget:self];
970 [hotKey setAction:@selector(popupMenu)];
971 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
975 for (i = 0; i <= 5; i++) {
976 NSString *curName = [NSString stringWithFormat:@"SetRating%i", i];
977 if ([df objectForKey:curName] != nil) {
978 ITDebugLog(@"Setting up set rating %i hot key.", i);
979 hotKey = [[ITHotKey alloc] init];
980 [hotKey setName:curName];
981 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:curName]]];
982 [hotKey setTarget:self];
983 [hotKey setAction:@selector(setRating:)];
984 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
987 ITDebugLog(@"Finished setting up hot keys.");
990 - (void)showCurrentTrackInfo
992 ITMTRemotePlayerSource source = 0;
993 NSString *title = nil;
994 NSString *album = nil;
995 NSString *artist = nil;
996 NSString *composer = nil;
997 NSString *time = nil;
998 NSString *track = nil;
1003 ITDebugLog(@"Showing track info status window.");
1006 source = [[self currentRemote] currentSource];
1007 title = [[self currentRemote] currentSongTitle];
1009 [self networkError:localException];
1013 if ( [df boolForKey:@"showAlbumArtwork"] ) {
1014 NSSize oldSize, newSize;
1016 art = [[self currentRemote] currentSongAlbumArt];
1017 oldSize = [art size];
1018 if (oldSize.width > oldSize.height) newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width));
1019 else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110);
1020 art = [[[[NSImage alloc] initWithData:[art TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize];
1022 [self networkError:localException];
1026 if ( [df boolForKey:@"showAlbum"] ) {
1028 album = [[self currentRemote] currentSongAlbum];
1030 [self networkError:localException];
1034 if ( [df boolForKey:@"showArtist"] ) {
1036 artist = [[self currentRemote] currentSongArtist];
1038 [self networkError:localException];
1042 if ( [df boolForKey:@"showComposer"] ) {
1044 composer = [[self currentRemote] currentSongComposer];
1046 [self networkError:localException];
1050 if ( [df boolForKey:@"showTime"] ) {
1052 time = [NSString stringWithFormat:@"%@: %@ / %@",
1053 NSLocalizedString(@"time", @"Time"),
1054 [[self currentRemote] currentSongElapsed],
1055 [[self currentRemote] currentSongLength]];
1057 [self networkError:localException];
1061 if ( [df boolForKey:@"showTrackNumber"] ) {
1066 trackNo = [[self currentRemote] currentSongTrack];
1067 trackCount = [[self currentRemote] currentAlbumTrackCount];
1069 [self networkError:localException];
1072 if ( (trackNo > 0) || (trackCount > 0) ) {
1073 track = [NSString stringWithFormat:@"%@: %i %@ %i",
1074 @"Track", trackNo, @"of", trackCount];
1078 if ( [df boolForKey:@"showTrackRating"] ) {
1079 float currentRating = 0;
1082 currentRating = [[self currentRemote] currentSongRating];
1084 [self networkError:localException];
1087 if (currentRating >= 0.0) {
1088 rating = ( currentRating * 5 );
1092 if ( [df boolForKey:@"showPlayCount"] && ![self radioIsPlaying] && [[self currentRemote] currentSource] == ITMTRemoteLibrarySource ) {
1094 playCount = [[self currentRemote] currentSongPlayCount];
1096 [self networkError:localException];
1100 title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
1102 ITDebugLog(@"Showing current track info status window.");
1103 [statusWindowController showSongInfoWindowWithSource:source
1115 - (void)showUpcomingSongs
1119 numSongs = [[self currentRemote] numberOfSongsInPlaylistAtIndex:[[self currentRemote] currentPlaylistIndex]];
1121 [self networkError:localException];
1124 ITDebugLog(@"Showing upcoming songs status window.");
1127 int numSongsInAdvance = [df integerForKey:@"SongsInAdvance"];
1128 NSMutableArray *songList = [NSMutableArray arrayWithCapacity:numSongsInAdvance];
1129 int curTrack = [[self currentRemote] currentSongIndex];
1132 for (i = curTrack + 1; i <= curTrack + numSongsInAdvance; i++) {
1133 if (i <= numSongs) {
1134 [songList addObject:[[self currentRemote] songTitleAtIndex:i]];
1138 if ([songList count] == 0) {
1139 [songList addObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")];
1142 [statusWindowController showUpcomingSongsWindowWithTitles:songList];
1144 [statusWindowController showUpcomingSongsWindowWithTitles:[NSArray arrayWithObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")]];
1147 [self networkError:localException];
1156 NSMenu *menu = [statusItem menu];
1157 [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]];
1162 - (void)incrementVolume
1165 float volume = [[self currentRemote] volume];
1166 float dispVol = volume;
1167 ITDebugLog(@"Incrementing volume.");
1176 ITDebugLog(@"Setting volume to %f", volume);
1177 [[self currentRemote] setVolume:volume];
1179 // Show volume status window
1180 [statusWindowController showVolumeWindowWithLevel:dispVol];
1182 [self networkError:localException];
1186 - (void)decrementVolume
1189 float volume = [[self currentRemote] volume];
1190 float dispVol = volume;
1191 ITDebugLog(@"Decrementing volume.");
1200 ITDebugLog(@"Setting volume to %f", volume);
1201 [[self currentRemote] setVolume:volume];
1203 //Show volume status window
1204 [statusWindowController showVolumeWindowWithLevel:dispVol];
1206 [self networkError:localException];
1210 - (void)incrementRating
1213 float rating = [[self currentRemote] currentSongRating];
1214 ITDebugLog(@"Incrementing rating.");
1216 if ([[self currentRemote] currentPlaylistIndex] == 0) {
1217 ITDebugLog(@"No song playing, rating change aborted.");
1225 ITDebugLog(@"Setting rating to %f", rating);
1226 [[self currentRemote] setCurrentSongRating:rating];
1228 //Show rating status window
1229 [statusWindowController showRatingWindowWithRating:rating];
1231 [self networkError:localException];
1235 - (void)decrementRating
1238 float rating = [[self currentRemote] currentSongRating];
1239 ITDebugLog(@"Decrementing rating.");
1241 if ([[self currentRemote] currentPlaylistIndex] == 0) {
1242 ITDebugLog(@"No song playing, rating change aborted.");
1250 ITDebugLog(@"Setting rating to %f", rating);
1251 [[self currentRemote] setCurrentSongRating:rating];
1253 //Show rating status window
1254 [statusWindowController showRatingWindowWithRating:rating];
1256 [self networkError:localException];
1260 - (void)setRating:(ITHotKey *)sender
1262 int stars = [[sender name] characterAtIndex:9] - 48;
1263 [self selectSongRating:stars * 20];
1264 [statusWindowController showRatingWindowWithRating:(float)stars / 5.0];
1270 ITMTRemotePlayerRepeatMode repeatMode = [[self currentRemote] repeatMode];
1271 ITDebugLog(@"Toggling repeat mode.");
1272 switch (repeatMode) {
1273 case ITMTRemotePlayerRepeatOff:
1274 repeatMode = ITMTRemotePlayerRepeatAll;
1276 case ITMTRemotePlayerRepeatAll:
1277 repeatMode = ITMTRemotePlayerRepeatOne;
1279 case ITMTRemotePlayerRepeatOne:
1280 repeatMode = ITMTRemotePlayerRepeatOff;
1283 ITDebugLog(@"Setting repeat mode to %i", repeatMode);
1284 [[self currentRemote] setRepeatMode:repeatMode];
1286 //Show loop status window
1287 [statusWindowController showRepeatWindowWithMode:repeatMode];
1289 [self networkError:localException];
1293 - (void)toggleShuffle
1296 BOOL newShuffleEnabled = ( ! [[self currentRemote] shuffleEnabled] );
1297 ITDebugLog(@"Toggling shuffle mode.");
1298 [[self currentRemote] setShuffleEnabled:newShuffleEnabled];
1299 //Show shuffle status window
1300 ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled);
1301 [statusWindowController showShuffleWindow:newShuffleEnabled];
1303 [self networkError:localException];
1307 - (void)registerNowOK
1309 [[StatusWindow sharedWindow] setLocked:NO];
1310 [[StatusWindow sharedWindow] vanish:self];
1311 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1316 - (void)registerNowCancel
1318 [[StatusWindow sharedWindow] setLocked:NO];
1319 [[StatusWindow sharedWindow] vanish:self];
1320 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1322 [NSApp terminate:self];
1325 /*************************************************************************/
1327 #pragma mark NETWORK HANDLERS
1328 /*************************************************************************/
1330 - (void)setServerStatus:(BOOL)newStatus
1334 [networkController setServerStatus:YES];
1337 [networkController setServerStatus:NO];
1341 - (int)connectToServer
1344 ITDebugLog(@"Attempting to connect to shared remote.");
1345 result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
1348 [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
1349 currentRemote = [[[networkController networkObject] remote] retain];
1351 [self setupHotKeys];
1352 //playerRunningState = ITMTRemotePlayerRunning;
1353 playerRunningState = [[self currentRemote] playerRunningState];
1355 [refreshTimer invalidate];
1357 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
1359 selector:@selector(timerUpdate)
1361 repeats:YES] retain];
1363 ITDebugLog(@"Connection successful.");
1365 } else if (result == 0) {
1366 ITDebugLog(@"Connection failed.");
1367 currentRemote = [remoteArray objectAtIndex:0];
1370 //Do something about the password being invalid
1371 ITDebugLog(@"Connection failed.");
1372 currentRemote = [remoteArray objectAtIndex:0];
1377 - (BOOL)disconnectFromServer
1379 ITDebugLog(@"Disconnecting from shared remote.");
1381 [currentRemote release];
1382 currentRemote = [remoteArray objectAtIndex:0];
1383 [networkController disconnect];
1385 if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
1386 [self applicationLaunched:nil];
1388 [self applicationTerminated:nil];
1396 - (void)checkForRemoteServer
1398 [self checkForRemoteServerAndConnectImmediately:NO];
1401 - (void)checkForRemoteServerAndConnectImmediately:(BOOL)connectImmediately
1403 ITDebugLog(@"Checking for remote server.");
1404 if (!_checkingForServer) {
1405 if (!_serverCheckLock) {
1406 _serverCheckLock = [[NSLock alloc] init];
1408 [_serverCheckLock lock];
1409 _checkingForServer = YES;
1410 [_serverCheckLock unlock];
1411 [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:[NSNumber numberWithBool:connectImmediately]];
1415 - (void)runRemoteServerCheck:(id)sender
1417 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1418 ITDebugLog(@"Remote server check running.");
1419 if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
1420 ITDebugLog(@"Remote server found.");
1421 if ([sender boolValue]) {
1422 [self performSelectorOnMainThread:@selector(connectToServer) withObject:nil waitUntilDone:NO];
1424 [self performSelectorOnMainThread:@selector(remoteServerFound:) withObject:nil waitUntilDone:NO];
1427 ITDebugLog(@"Remote server not found.");
1428 [self performSelectorOnMainThread:@selector(remoteServerNotFound:) withObject:nil waitUntilDone:NO];
1430 [_serverCheckLock lock];
1431 _checkingForServer = NO;
1432 [_serverCheckLock unlock];
1436 - (void)remoteServerFound:(id)sender
1438 if (![networkController isServerOn] && ![networkController isConnectedToServer]) {
1439 [[StatusWindowController sharedController] showReconnectQueryWindow];
1443 - (void)remoteServerNotFound:(id)sender
1445 if (![[NetworkController sharedController] isConnectedToServer]) {
1446 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1450 - (void)networkError:(NSException *)exception
1452 ITDebugLog(@"Remote exception thrown: %@: %@", [exception name], [exception reason]);
1453 if ( ((exception == nil) || [[exception name] isEqualToString:NSPortTimeoutException]) && [networkController isConnectedToServer]) {
1454 //NSRunCriticalAlertPanel(@"Remote MenuTunes Disconnected", @"The MenuTunes server you were connected to stopped responding or quit. MenuTunes will revert back to the local player.", @"OK", nil, nil);
1455 [[StatusWindowController sharedController] showNetworkErrorQueryWindow];
1456 if ([self disconnectFromServer]) {
1457 [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
1458 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1460 ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
1467 /*if ([self connectToServer] == 0) {
1468 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1470 [self checkForRemoteServerAndConnectImmediately:YES];
1471 [[StatusWindow sharedWindow] setLocked:NO];
1472 [[StatusWindow sharedWindow] vanish:self];
1473 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1476 - (void)cancelReconnect
1478 [[StatusWindow sharedWindow] setLocked:NO];
1479 [[StatusWindow sharedWindow] vanish:self];
1480 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1483 /*************************************************************************/
1485 #pragma mark WORKSPACE NOTIFICATION HANDLERS
1486 /*************************************************************************/
1488 - (void)applicationLaunched:(NSNotification *)note
1491 if (!note || ([[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[[self currentRemote] playerFullName]] && ![[NetworkController sharedController] isConnectedToServer])) {
1492 ITDebugLog(@"Remote application launched.");
1493 playerRunningState = ITMTRemotePlayerRunning;
1494 [[self currentRemote] begin];
1495 [self setLatestSongIdentifier:@""];
1497 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
1499 selector:@selector(timerUpdate)
1501 repeats:YES] retain];
1502 //[NSThread detachNewThreadSelector:@selector(startTimerInNewThread) toTarget:self withObject:nil];
1503 if (![df boolForKey:@"UsePollingOnly"]) {
1504 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(trackChanged:) name:@"ITMTTrackChanged" object:nil];
1506 [self setupHotKeys];
1509 [self networkError:localException];
1513 - (void)applicationTerminated:(NSNotification *)note
1516 if (!note || [[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[[self currentRemote] playerFullName]] && ![[NetworkController sharedController] isConnectedToServer]) {
1517 ITDebugLog(@"Remote application terminated.");
1518 playerRunningState = ITMTRemotePlayerNotRunning;
1519 [[self currentRemote] halt];
1520 [refreshTimer invalidate];
1521 [refreshTimer release];
1523 [[NSNotificationCenter defaultCenter] removeObserver:self];
1524 [statusItem setEnabled:YES];
1525 [statusItem setToolTip:@"iTunes not running."];
1526 [self clearHotKeys];
1529 if ([df objectForKey:@"ShowPlayer"] != nil) {
1531 ITDebugLog(@"Setting up show player hot key.");
1532 hotKey = [[ITHotKey alloc] init];
1533 [hotKey setName:@"ShowPlayer"];
1534 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]]];
1535 [hotKey setTarget:self];
1536 [hotKey setAction:@selector(showPlayer)];
1537 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
1541 [self networkError:localException];
1546 /*************************************************************************/
1548 #pragma mark NSApplication DELEGATE METHODS
1549 /*************************************************************************/
1551 - (void)applicationWillTerminate:(NSNotification *)note
1553 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
1554 [networkController stopRemoteServerSearch];
1555 [self clearHotKeys];
1556 [[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
1560 /*************************************************************************/
1562 #pragma mark DEALLOCATION METHOD
1563 /*************************************************************************/
1567 [self applicationTerminated:nil];
1569 [statusItem release];
1570 [statusWindowController release];
1571 [menuController release];
1572 [networkController release];
1573 [_serverCheckLock release];