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];
184 - (void)applicationWillBecomeActive:(NSNotification *)note
187 [[MainController sharedController] showPreferences];
191 - (ITMTRemote *)loadRemote
193 NSString *folderPath = [[NSBundle mainBundle] builtInPlugInsPath];
194 ITDebugLog(@"Gathering remotes.");
196 NSArray *bundlePathList = [NSBundle pathsForResourcesOfType:@"remote" inDirectory:folderPath];
197 NSEnumerator *enumerator = [bundlePathList objectEnumerator];
198 NSString *bundlePath;
200 while ( (bundlePath = [enumerator nextObject]) ) {
201 NSBundle* remoteBundle = [NSBundle bundleWithPath:bundlePath];
204 Class remoteClass = [remoteBundle principalClass];
206 if ([remoteClass conformsToProtocol:@protocol(ITMTRemote)] &&
207 [(NSObject *)remoteClass isKindOfClass:[NSObject class]]) {
208 id remote = [remoteClass remote];
209 ITDebugLog(@"Adding remote at path %@", bundlePath);
210 [remoteArray addObject:remote];
215 // if ( [remoteArray count] > 0 ) { // UNCOMMENT WHEN WE HAVE > 1 PLUGIN
216 // if ( [remoteArray count] > 1 ) {
217 // [remoteArray sortUsingSelector:@selector(sortAlpha:)];
219 // [self loadModuleAccessUI]; //Comment out this line to disable remote visibility
222 // NSLog(@"%@", [remoteArray objectAtIndex:0]); //DEBUG
223 return [remoteArray objectAtIndex:0];
226 /*************************************************************************/
228 #pragma mark INSTANCE METHODS
229 /*************************************************************************/
231 /*- (void)startTimerInNewThread
233 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
234 NSRunLoop *runLoop = [NSRunLoop currentRunLoop];
235 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:0.5
237 selector:@selector(timerUpdate)
239 repeats:YES] retain];
241 ITDebugLog(@"Timer started.");
245 - (void)setBlingTime:(NSDate*)date
247 NSMutableDictionary *globalPrefs;
249 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
251 [globalPrefs setObject:date forKey:@"ITMTTrialStart"];
252 [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
254 [globalPrefs removeObjectForKey:@"ITMTTrialStart"];
255 [globalPrefs removeObjectForKey:@"ITMTTrialVers"];
257 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
259 [globalPrefs release];
262 - (NSDate*)getBlingTime
265 return [[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialStart"];
270 NSDate *now = [NSDate date];
271 if (![self blingBling]) {
272 if ( (! [self getBlingTime] ) || ([now timeIntervalSinceDate:[self getBlingTime]] < 0) ) {
273 [self setBlingTime:now];
274 } else if ([[[df persistentDomainForName:@".GlobalPreferences"] objectForKey:@"ITMTTrialVers"] intValue] < MT_CURRENT_VERSION) {
275 if ([now timeIntervalSinceDate:[self getBlingTime]] >= 345600) {
276 [self setBlingTime:[now addTimeInterval:-259200]];
278 NSMutableDictionary *globalPrefs;
280 globalPrefs = [[df persistentDomainForName:@".GlobalPreferences"] mutableCopy];
281 [globalPrefs setObject:[NSNumber numberWithInt:MT_CURRENT_VERSION] forKey:@"ITMTTrialVers"];
282 [df setPersistentDomain:globalPrefs forName:@".GlobalPreferences"];
284 [globalPrefs release];
288 if ( ([now timeIntervalSinceDate:[self getBlingTime]] >= 604800) && (blinged != YES) ) {
290 [statusItem setEnabled:NO];
292 if ([refreshTimer isValid]) {
293 [refreshTimer invalidate];
294 [refreshTimer release];
297 [statusWindowController showRegistrationQueryWindow];
301 [statusItem setEnabled:YES];
303 if (![refreshTimer isValid]) {
304 [refreshTimer release];
305 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
307 selector:@selector(timerUpdate)
309 repeats:YES] retain];
313 [self setBlingTime:nil];
324 if ( ! ([bling checkDone] == 2475) ) {
331 - (BOOL)songIsPlaying
333 NSString *identifier = nil;
335 identifier = [[self currentRemote] playerStateUniqueIdentifier];
337 [self networkError:localException];
339 return ( ! ([identifier isEqualToString:@"0-0"]) );
342 - (BOOL)radioIsPlaying
344 ITMTRemotePlayerPlaylistClass class = nil;
346 class = [[self currentRemote] currentPlaylistClass];
348 [self networkError:localException];
350 return (class == ITMTRemotePlayerRadioPlaylist );
355 NSString *identifier = nil;
357 identifier = [[self currentRemote] playerStateUniqueIdentifier];
359 [self networkError:localException];
361 return ( ! [identifier isEqualToString:_latestSongIdentifier] );
364 - (NSString *)latestSongIdentifier
366 return _latestSongIdentifier;
369 - (void)setLatestSongIdentifier:(NSString *)newIdentifier
371 ITDebugLog(@"Setting latest song identifier:");
372 ITDebugLog(@" - Identifier: %@", newIdentifier);
373 [_latestSongIdentifier autorelease];
374 _latestSongIdentifier = [newIdentifier retain];
379 NSString *identifier = [[self currentRemote] playerStateUniqueIdentifier];
380 if (refreshTimer && identifier == nil) {
381 if ([statusItem isEnabled]) {
382 [statusItem setToolTip:@"iTunes not responding."];
383 [[ITHotKeyCenter sharedCenter] setEnabled:NO];
385 [statusItem setEnabled:NO];
387 } else if (![statusItem isEnabled]) {
388 [statusItem setEnabled:YES];
389 [statusItem setToolTip:_toolTip];
390 [[ITHotKeyCenter sharedCenter] setEnabled:YES];
394 if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
395 ITDebugLog(@"The song changed. '%@'", _latestSongIdentifier);
396 if ([df boolForKey:@"runScripts"]) {
397 NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]];
398 NSEnumerator *scriptsEnum = [scripts objectEnumerator];
399 NSString *nextScript;
400 ITDebugLog(@"Running AppleScripts for song change.");
401 while ( (nextScript = [scriptsEnum nextObject]) ) {
403 NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
404 ITDebugLog(@"Running script: %@", nextScript);
405 if (!currentScript || ![currentScript executeAndReturnError:nil]) {
406 ITDebugLog(@"Error running script %@.", nextScript);
408 [currentScript release];
413 [statusItem setEnabled:NO];
416 latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
418 if ([menuController rebuildSubmenus]) {
419 if ( [df boolForKey:@"showSongInfoOnChange"] ) {
420 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
422 [self setLatestSongIdentifier:identifier];
423 //Create the tooltip for the status item
424 if ( [df boolForKey:@"showToolTip"] ) {
425 NSString *artist = [[self currentRemote] currentSongArtist];
426 NSString *title = [[self currentRemote] currentSongTitle];
427 ITDebugLog(@"Creating status item tooltip.");
429 _toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title];
433 _toolTip = @"No Song Playing";
435 [statusItem setToolTip:_toolTip];
437 [statusItem setToolTip:nil];
441 [self networkError:localException];
444 [statusItem setEnabled:YES];
447 if ([networkController isConnectedToServer]) {
448 [statusItem setMenu:([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) ? [menuController menu] : [menuController menuForNoPlayer]];
454 ITDebugLog(@"Menu clicked.");
456 if (([[self currentRemote] playerStateUniqueIdentifier] == nil) && playerRunningState == ITMTRemotePlayerRunning) {
458 if ([statusItem isEnabled]) {
459 [statusItem setToolTip:@"iTunes not responding."];
460 [[ITHotKeyCenter sharedCenter] setEnabled:NO];
462 [statusItem setEnabled:NO];
464 NSMenu *menu = [[NSMenu alloc] init];
465 [menu addItemWithTitle:@"iTunes Not Responding" action:nil keyEquivalent:@""];
466 [statusItem setMenu:[menu autorelease]];
469 } else if (![statusItem isEnabled]) {
470 [statusItem setEnabled:YES];
471 [statusItem setToolTip:_toolTip];
472 [[ITHotKeyCenter sharedCenter] setEnabled:YES];
476 if ([networkController isConnectedToServer]) {
477 //Used the cached version
482 if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
483 [statusItem setMenu:[menuController menu]];
485 [statusItem setMenu:[menuController menuForNoPlayer]];
488 [self networkError:localException];
492 - (void)trackChanged:(NSNotification *)note
494 //If we're running the timer, shut it off since we don't need it!
495 if (refreshTimer && [refreshTimer isValid]) {
496 ITDebugLog(@"Invalidating refresh timer.");
497 [refreshTimer invalidate];
498 [refreshTimer release];
502 if (![self songChanged]) {
505 NSString *identifier = [[self currentRemote] playerStateUniqueIdentifier];
506 if ( [df boolForKey:@"showSongInfoOnChange"] ) {
507 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
509 [_lastTrackInfo release];
510 _lastTrackInfo = [[note userInfo] retain];
512 [self setLatestSongIdentifier:identifier];
513 ITDebugLog(@"The song changed. '%@'", _latestSongIdentifier);
514 if ([df boolForKey:@"runScripts"]) {
515 NSArray *scripts = [[NSFileManager defaultManager] directoryContentsAtPath:[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"]];
516 NSEnumerator *scriptsEnum = [scripts objectEnumerator];
517 NSString *nextScript;
518 ITDebugLog(@"Running AppleScripts for song change.");
519 while ( (nextScript = [scriptsEnum nextObject]) ) {
521 NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
522 ITDebugLog(@"Running script: %@", nextScript);
523 if (!currentScript || ![currentScript executeAndReturnError:nil]) {
524 ITDebugLog(@"Error running script %@.", nextScript);
526 [currentScript release];
530 [statusItem setEnabled:NO];
533 latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
535 if ([menuController rebuildSubmenus]) {
536 /*if ( [df boolForKey:@"showSongInfoOnChange"] ) {
537 [self performSelector:@selector(showCurrentTrackInfo) withObject:nil afterDelay:0.0];
539 [self setLatestSongIdentifier:identifier];
540 //Create the tooltip for the status item
541 if ( [df boolForKey:@"showToolTip"] ) {
542 ITDebugLog(@"Creating status item tooltip.");
543 NSString *artist = [_lastTrackInfo objectForKey:@"Artist"], *title = [_lastTrackInfo objectForKey:@"Name"];
545 _toolTip = [NSString stringWithFormat:@"%@ - %@", artist, title];
549 _toolTip = @"No Song Playing";
551 [statusItem setToolTip:_toolTip];
553 [statusItem setToolTip:nil];
557 [self networkError:localException];
560 [statusItem setEnabled:YES];
562 if ([networkController isConnectedToServer]) {
563 [statusItem setMenu:([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) ? [menuController menu] : [menuController menuForNoPlayer]];
576 ITMTRemotePlayerPlayingState state = [[self currentRemote] playerPlayingState];
577 ITDebugLog(@"Play/Pause toggled");
578 if (state == ITMTRemotePlayerPlaying) {
579 [[self currentRemote] pause];
580 } else if ((state == ITMTRemotePlayerForwarding) || (state == ITMTRemotePlayerRewinding)) {
581 [[self currentRemote] pause];
582 [[self currentRemote] play];
584 [[self currentRemote] play];
587 [self networkError:localException];
597 ITDebugLog(@"Going to next song.");
599 [[self currentRemote] goToNextSong];
601 [self networkError:localException];
610 ITDebugLog(@"Going to previous song.");
612 [[self currentRemote] goToPreviousSong];
614 [self networkError:localException];
623 ITDebugLog(@"Fast forwarding.");
625 [[self currentRemote] forward];
627 [self networkError:localException];
636 ITDebugLog(@"Rewinding.");
638 [[self currentRemote] rewind];
640 [self networkError:localException];
647 - (void)selectPlaylistAtIndex:(int)index
649 ITDebugLog(@"Selecting playlist %i", index);
651 [[self currentRemote] switchToPlaylistAtIndex:(index % 1000) ofSourceAtIndex:(index / 1000)];
652 //[[self currentRemote] switchToPlaylistAtIndex:index];
654 [self networkError:localException];
661 - (void)selectSongAtIndex:(int)index
663 ITDebugLog(@"Selecting song %i", index);
665 [[self currentRemote] switchToSongAtIndex:index];
667 [self networkError:localException];
674 - (void)selectSongRating:(int)rating
676 ITDebugLog(@"Selecting song rating %i", rating);
678 [[self currentRemote] setCurrentSongRating:(float)rating / 100.0];
680 [self networkError:localException];
687 - (void)selectEQPresetAtIndex:(int)index
689 ITDebugLog(@"Selecting EQ preset %i", index);
692 [[self currentRemote] setEqualizerEnabled:![[self currentRemote] equalizerEnabled]];
694 [[self currentRemote] switchToEQAtIndex:index];
697 [self networkError:localException];
704 - (void)makePlaylistWithTerm:(NSString *)term ofType:(int)type
706 ITDebugLog(@"Making playlist with term %@, type %i", term, type);
708 [[self currentRemote] makePlaylistWithTerm:term ofType:type];
710 [self networkError:localException];
712 ITDebugLog(@"Done making playlist");
717 ITDebugLog(@"Beginning show player.");
718 //if ( ( playerRunningState == ITMTRemotePlayerRunning) ) {
719 ITDebugLog(@"Showing player interface.");
721 [[self currentRemote] showPrimaryInterface];
723 [self networkError:localException];
726 ITDebugLog(@"Launching player.");
729 if ( (path = [df stringForKey:@"CustomPlayerPath"]) ) {
731 pathITDebugLog(@"Showing player interface."); = [[self currentRemote] playerFullName];
733 if (![[NSWorkspace sharedWorkspace] launchApplication:path]) {
734 ITDebugLog(@"Error Launching Player");
737 [self networkError:localException];
740 ITDebugLog(@"Finished show player.");
743 - (void)showPreferences
745 ITDebugLog(@"Show preferences.");
746 [[PreferencesController sharedPrefs] showPrefsWindow:self];
749 - (void)showPreferencesAndClose
751 ITDebugLog(@"Show preferences.");
752 [[PreferencesController sharedPrefs] showPrefsWindow:self];
753 [[StatusWindow sharedWindow] setLocked:NO];
754 [[StatusWindow sharedWindow] vanish:self];
755 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
758 - (void)showTestWindow
760 [self showCurrentTrackInfo];
763 - (void)quitMenuTunes
765 ITDebugLog(@"Quitting MenuTunes.");
766 [NSApp terminate:self];
772 - (MenuController *)menuController
774 return menuController;
777 - (void)closePreferences
779 ITDebugLog(@"Preferences closed.");
780 if ( ( playerRunningState == ITMTRemotePlayerRunning) ) {
785 - (ITMTRemote *)currentRemote
787 if ([networkController isConnectedToServer] && ![[networkController networkObject] isValid]) {
788 [self networkError:nil];
791 return currentRemote;
802 NSEnumerator *hotKeyEnumerator = [[[ITHotKeyCenter sharedCenter] allHotKeys] objectEnumerator];
803 ITHotKey *nextHotKey;
804 ITDebugLog(@"Clearing hot keys.");
805 while ( (nextHotKey = [hotKeyEnumerator nextObject]) ) {
806 [[ITHotKeyCenter sharedCenter] unregisterHotKey:nextHotKey];
808 ITDebugLog(@"Done clearing hot keys.");
814 ITDebugLog(@"Setting up hot keys.");
816 if (playerRunningState == ITMTRemotePlayerNotRunning && ![[NetworkController sharedController] isConnectedToServer]) {
820 if ([df objectForKey:@"PlayPause"] != nil) {
821 ITDebugLog(@"Setting up play pause hot key.");
822 hotKey = [[ITHotKey alloc] init];
823 [hotKey setName:@"PlayPause"];
824 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PlayPause"]]];
825 [hotKey setTarget:self];
826 [hotKey setAction:@selector(playPause)];
827 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
830 if ([df objectForKey:@"NextTrack"] != nil) {
831 ITDebugLog(@"Setting up next track hot key.");
832 hotKey = [[ITHotKey alloc] init];
833 [hotKey setName:@"NextTrack"];
834 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"NextTrack"]]];
835 [hotKey setTarget:self];
836 [hotKey setAction:@selector(nextSong)];
837 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
840 if ([df objectForKey:@"PrevTrack"] != nil) {
841 ITDebugLog(@"Setting up previous track hot key.");
842 hotKey = [[ITHotKey alloc] init];
843 [hotKey setName:@"PrevTrack"];
844 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PrevTrack"]]];
845 [hotKey setTarget:self];
846 [hotKey setAction:@selector(prevSong)];
847 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
850 if ([df objectForKey:@"FastForward"] != nil) {
851 ITDebugLog(@"Setting up fast forward hot key.");
852 hotKey = [[ITHotKey alloc] init];
853 [hotKey setName:@"FastForward"];
854 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"FastForward"]]];
855 [hotKey setTarget:self];
856 [hotKey setAction:@selector(fastForward)];
857 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
860 if ([df objectForKey:@"Rewind"] != nil) {
861 ITDebugLog(@"Setting up rewind hot key.");
862 hotKey = [[ITHotKey alloc] init];
863 [hotKey setName:@"Rewind"];
864 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"Rewind"]]];
865 [hotKey setTarget:self];
866 [hotKey setAction:@selector(rewind)];
867 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
870 if ([df objectForKey:@"ShowPlayer"] != nil) {
871 ITDebugLog(@"Setting up show player hot key.");
872 hotKey = [[ITHotKey alloc] init];
873 [hotKey setName:@"ShowPlayer"];
874 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]]];
875 [hotKey setTarget:self];
876 [hotKey setAction:@selector(showPlayer)];
877 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
880 if ([df objectForKey:@"TrackInfo"] != nil) {
881 ITDebugLog(@"Setting up track info hot key.");
882 hotKey = [[ITHotKey alloc] init];
883 [hotKey setName:@"TrackInfo"];
884 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"TrackInfo"]]];
885 [hotKey setTarget:self];
886 [hotKey setAction:@selector(showCurrentTrackInfo)];
887 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
890 if ([df objectForKey:@"UpcomingSongs"] != nil) {
891 ITDebugLog(@"Setting up upcoming songs hot key.");
892 hotKey = [[ITHotKey alloc] init];
893 [hotKey setName:@"UpcomingSongs"];
894 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"UpcomingSongs"]]];
895 [hotKey setTarget:self];
896 [hotKey setAction:@selector(showUpcomingSongs)];
897 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
900 if ([df objectForKey:@"ToggleLoop"] != nil) {
901 ITDebugLog(@"Setting up toggle loop hot key.");
902 hotKey = [[ITHotKey alloc] init];
903 [hotKey setName:@"ToggleLoop"];
904 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleLoop"]]];
905 [hotKey setTarget:self];
906 [hotKey setAction:@selector(toggleLoop)];
907 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
910 if ([df objectForKey:@"ToggleShuffle"] != nil) {
911 ITDebugLog(@"Setting up toggle shuffle hot key.");
912 hotKey = [[ITHotKey alloc] init];
913 [hotKey setName:@"ToggleShuffle"];
914 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ToggleShuffle"]]];
915 [hotKey setTarget:self];
916 [hotKey setAction:@selector(toggleShuffle)];
917 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
920 if ([df objectForKey:@"IncrementVolume"] != nil) {
921 ITDebugLog(@"Setting up increment volume hot key.");
922 hotKey = [[ITHotKey alloc] init];
923 [hotKey setName:@"IncrementVolume"];
924 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementVolume"]]];
925 [hotKey setTarget:self];
926 [hotKey setAction:@selector(incrementVolume)];
927 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
930 if ([df objectForKey:@"DecrementVolume"] != nil) {
931 ITDebugLog(@"Setting up decrement volume hot key.");
932 hotKey = [[ITHotKey alloc] init];
933 [hotKey setName:@"DecrementVolume"];
934 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementVolume"]]];
935 [hotKey setTarget:self];
936 [hotKey setAction:@selector(decrementVolume)];
937 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
940 if ([df objectForKey:@"IncrementRating"] != nil) {
941 ITDebugLog(@"Setting up increment rating hot key.");
942 hotKey = [[ITHotKey alloc] init];
943 [hotKey setName:@"IncrementRating"];
944 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"IncrementRating"]]];
945 [hotKey setTarget:self];
946 [hotKey setAction:@selector(incrementRating)];
947 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
950 if ([df objectForKey:@"DecrementRating"] != nil) {
951 ITDebugLog(@"Setting up decrement rating hot key.");
952 hotKey = [[ITHotKey alloc] init];
953 [hotKey setName:@"DecrementRating"];
954 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"DecrementRating"]]];
955 [hotKey setTarget:self];
956 [hotKey setAction:@selector(decrementRating)];
957 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
960 if ([df objectForKey:@"PopupMenu"] != nil) {
961 ITDebugLog(@"Setting up popup menu hot key.");
962 hotKey = [[ITHotKey alloc] init];
963 [hotKey setName:@"PopupMenu"];
964 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"PopupMenu"]]];
965 [hotKey setTarget:self];
966 [hotKey setAction:@selector(popupMenu)];
967 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
971 for (i = 0; i <= 5; i++) {
972 NSString *curName = [NSString stringWithFormat:@"SetRating%i", i];
973 if ([df objectForKey:curName] != nil) {
974 ITDebugLog(@"Setting up set rating %i hot key.", i);
975 hotKey = [[ITHotKey alloc] init];
976 [hotKey setName:curName];
977 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:curName]]];
978 [hotKey setTarget:self];
979 [hotKey setAction:@selector(setRating:)];
980 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
983 ITDebugLog(@"Finished setting up hot keys.");
986 - (void)showCurrentTrackInfo
988 ITMTRemotePlayerSource source = 0;
989 NSString *title = nil;
990 NSString *album = nil;
991 NSString *artist = nil;
992 NSString *composer = nil;
993 NSString *time = nil;
994 NSString *track = nil;
999 ITDebugLog(@"Showing track info status window.");
1002 source = [[self currentRemote] currentSource];
1003 title = [[self currentRemote] currentSongTitle];
1005 [self networkError:localException];
1009 if ( [df boolForKey:@"showAlbumArtwork"] ) {
1010 NSSize oldSize, newSize;
1012 art = [[self currentRemote] currentSongAlbumArt];
1013 oldSize = [art size];
1014 if (oldSize.width > oldSize.height) newSize = NSMakeSize(110,oldSize.height * (110.0f / oldSize.width));
1015 else newSize = NSMakeSize(oldSize.width * (110.0f / oldSize.height),110);
1016 art = [[[[NSImage alloc] initWithData:[art TIFFRepresentation]] autorelease] imageScaledSmoothlyToSize:newSize];
1018 [self networkError:localException];
1022 if ( [df boolForKey:@"showAlbum"] ) {
1024 album = [[self currentRemote] currentSongAlbum];
1026 [self networkError:localException];
1030 if ( [df boolForKey:@"showArtist"] ) {
1032 artist = [[self currentRemote] currentSongArtist];
1034 [self networkError:localException];
1038 if ( [df boolForKey:@"showComposer"] ) {
1040 composer = [[self currentRemote] currentSongComposer];
1042 [self networkError:localException];
1046 if ( [df boolForKey:@"showTime"] ) {
1048 time = [NSString stringWithFormat:@"%@: %@ / %@",
1049 NSLocalizedString(@"time", @"Time"),
1050 [[self currentRemote] currentSongElapsed],
1051 [[self currentRemote] currentSongLength]];
1053 [self networkError:localException];
1057 if ( [df boolForKey:@"showTrackNumber"] ) {
1062 trackNo = [[self currentRemote] currentSongTrack];
1063 trackCount = [[self currentRemote] currentAlbumTrackCount];
1065 [self networkError:localException];
1068 if ( (trackNo > 0) || (trackCount > 0) ) {
1069 track = [NSString stringWithFormat:@"%@: %i %@ %i",
1070 @"Track", trackNo, @"of", trackCount];
1074 if ( [df boolForKey:@"showTrackRating"] ) {
1075 float currentRating = 0;
1078 currentRating = [[self currentRemote] currentSongRating];
1080 [self networkError:localException];
1083 if (currentRating >= 0.0) {
1084 rating = ( currentRating * 5 );
1088 if ( [df boolForKey:@"showPlayCount"] && ![self radioIsPlaying] && [[self currentRemote] currentSource] == ITMTRemoteLibrarySource ) {
1090 playCount = [[self currentRemote] currentSongPlayCount];
1092 [self networkError:localException];
1096 title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
1098 ITDebugLog(@"Showing current track info status window.");
1099 [statusWindowController showSongInfoWindowWithSource:source
1111 - (void)showUpcomingSongs
1115 numSongs = [[self currentRemote] numberOfSongsInPlaylistAtIndex:[[self currentRemote] currentPlaylistIndex]];
1117 [self networkError:localException];
1120 ITDebugLog(@"Showing upcoming songs status window.");
1123 int numSongsInAdvance = [df integerForKey:@"SongsInAdvance"];
1124 NSMutableArray *songList = [NSMutableArray arrayWithCapacity:numSongsInAdvance];
1125 int curTrack = [[self currentRemote] currentSongIndex];
1128 for (i = curTrack + 1; i <= curTrack + numSongsInAdvance; i++) {
1129 if (i <= numSongs) {
1130 [songList addObject:[[self currentRemote] songTitleAtIndex:i]];
1134 if ([songList count] == 0) {
1135 [songList addObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")];
1138 [statusWindowController showUpcomingSongsWindowWithTitles:songList];
1140 [statusWindowController showUpcomingSongsWindowWithTitles:[NSArray arrayWithObject:NSLocalizedString(@"noUpcomingSongs", @"No upcoming songs.")]];
1143 [self networkError:localException];
1152 NSMenu *menu = [statusItem menu];
1153 [(NSCarbonMenuImpl *)[menu _menuImpl] popUpMenu:menu atLocation:[NSEvent mouseLocation] width:1 forView:nil withSelectedItem:-30 withFont:[NSFont menuFontOfSize:32]];
1158 - (void)incrementVolume
1161 float volume = [[self currentRemote] volume];
1162 float dispVol = volume;
1163 ITDebugLog(@"Incrementing volume.");
1172 ITDebugLog(@"Setting volume to %f", volume);
1173 [[self currentRemote] setVolume:volume];
1175 // Show volume status window
1176 [statusWindowController showVolumeWindowWithLevel:dispVol];
1178 [self networkError:localException];
1182 - (void)decrementVolume
1185 float volume = [[self currentRemote] volume];
1186 float dispVol = volume;
1187 ITDebugLog(@"Decrementing volume.");
1196 ITDebugLog(@"Setting volume to %f", volume);
1197 [[self currentRemote] setVolume:volume];
1199 //Show volume status window
1200 [statusWindowController showVolumeWindowWithLevel:dispVol];
1202 [self networkError:localException];
1206 - (void)incrementRating
1209 float rating = [[self currentRemote] currentSongRating];
1210 ITDebugLog(@"Incrementing rating.");
1212 if ([[self currentRemote] currentPlaylistIndex] == 0) {
1213 ITDebugLog(@"No song playing, rating change aborted.");
1221 ITDebugLog(@"Setting rating to %f", rating);
1222 [[self currentRemote] setCurrentSongRating:rating];
1224 //Show rating status window
1225 [statusWindowController showRatingWindowWithRating:rating];
1227 [self networkError:localException];
1231 - (void)decrementRating
1234 float rating = [[self currentRemote] currentSongRating];
1235 ITDebugLog(@"Decrementing rating.");
1237 if ([[self currentRemote] currentPlaylistIndex] == 0) {
1238 ITDebugLog(@"No song playing, rating change aborted.");
1246 ITDebugLog(@"Setting rating to %f", rating);
1247 [[self currentRemote] setCurrentSongRating:rating];
1249 //Show rating status window
1250 [statusWindowController showRatingWindowWithRating:rating];
1252 [self networkError:localException];
1256 - (void)setRating:(ITHotKey *)sender
1258 int stars = [[sender name] characterAtIndex:9] - 48;
1259 [self selectSongRating:stars * 20];
1260 [statusWindowController showRatingWindowWithRating:(float)stars / 5.0];
1266 ITMTRemotePlayerRepeatMode repeatMode = [[self currentRemote] repeatMode];
1267 ITDebugLog(@"Toggling repeat mode.");
1268 switch (repeatMode) {
1269 case ITMTRemotePlayerRepeatOff:
1270 repeatMode = ITMTRemotePlayerRepeatAll;
1272 case ITMTRemotePlayerRepeatAll:
1273 repeatMode = ITMTRemotePlayerRepeatOne;
1275 case ITMTRemotePlayerRepeatOne:
1276 repeatMode = ITMTRemotePlayerRepeatOff;
1279 ITDebugLog(@"Setting repeat mode to %i", repeatMode);
1280 [[self currentRemote] setRepeatMode:repeatMode];
1282 //Show loop status window
1283 [statusWindowController showRepeatWindowWithMode:repeatMode];
1285 [self networkError:localException];
1289 - (void)toggleShuffle
1292 BOOL newShuffleEnabled = ( ! [[self currentRemote] shuffleEnabled] );
1293 ITDebugLog(@"Toggling shuffle mode.");
1294 [[self currentRemote] setShuffleEnabled:newShuffleEnabled];
1295 //Show shuffle status window
1296 ITDebugLog(@"Setting shuffle mode to %i", newShuffleEnabled);
1297 [statusWindowController showShuffleWindow:newShuffleEnabled];
1299 [self networkError:localException];
1303 - (void)registerNowOK
1305 [[StatusWindow sharedWindow] setLocked:NO];
1306 [[StatusWindow sharedWindow] vanish:self];
1307 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1312 - (void)registerNowCancel
1314 [[StatusWindow sharedWindow] setLocked:NO];
1315 [[StatusWindow sharedWindow] vanish:self];
1316 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1318 [NSApp terminate:self];
1321 /*************************************************************************/
1323 #pragma mark NETWORK HANDLERS
1324 /*************************************************************************/
1326 - (void)setServerStatus:(BOOL)newStatus
1330 [networkController setServerStatus:YES];
1333 [networkController setServerStatus:NO];
1337 - (int)connectToServer
1340 ITDebugLog(@"Attempting to connect to shared remote.");
1341 result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
1344 [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
1345 currentRemote = [[[networkController networkObject] remote] retain];
1347 [self setupHotKeys];
1348 //playerRunningState = ITMTRemotePlayerRunning;
1349 playerRunningState = [[self currentRemote] playerRunningState];
1351 [refreshTimer invalidate];
1353 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
1355 selector:@selector(timerUpdate)
1357 repeats:YES] retain];
1359 ITDebugLog(@"Connection successful.");
1361 } else if (result == 0) {
1362 ITDebugLog(@"Connection failed.");
1363 currentRemote = [remoteArray objectAtIndex:0];
1366 //Do something about the password being invalid
1367 ITDebugLog(@"Connection failed.");
1368 currentRemote = [remoteArray objectAtIndex:0];
1373 - (BOOL)disconnectFromServer
1375 ITDebugLog(@"Disconnecting from shared remote.");
1377 [currentRemote release];
1378 currentRemote = [remoteArray objectAtIndex:0];
1379 [networkController disconnect];
1381 if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
1382 [self applicationLaunched:nil];
1384 [self applicationTerminated:nil];
1392 - (void)checkForRemoteServer
1394 [self checkForRemoteServerAndConnectImmediately:NO];
1397 - (void)checkForRemoteServerAndConnectImmediately:(BOOL)connectImmediately
1399 ITDebugLog(@"Checking for remote server.");
1400 if (!_checkingForServer) {
1401 if (!_serverCheckLock) {
1402 _serverCheckLock = [[NSLock alloc] init];
1404 [_serverCheckLock lock];
1405 _checkingForServer = YES;
1406 [_serverCheckLock unlock];
1407 [NSThread detachNewThreadSelector:@selector(runRemoteServerCheck:) toTarget:self withObject:[NSNumber numberWithBool:connectImmediately]];
1411 - (void)runRemoteServerCheck:(id)sender
1413 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
1414 ITDebugLog(@"Remote server check running.");
1415 if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
1416 ITDebugLog(@"Remote server found.");
1417 if ([sender boolValue]) {
1418 [self performSelectorOnMainThread:@selector(connectToServer) withObject:nil waitUntilDone:NO];
1420 [self performSelectorOnMainThread:@selector(remoteServerFound:) withObject:nil waitUntilDone:NO];
1423 ITDebugLog(@"Remote server not found.");
1424 [self performSelectorOnMainThread:@selector(remoteServerNotFound:) withObject:nil waitUntilDone:NO];
1426 [_serverCheckLock lock];
1427 _checkingForServer = NO;
1428 [_serverCheckLock unlock];
1432 - (void)remoteServerFound:(id)sender
1434 if (![networkController isServerOn] && ![networkController isConnectedToServer]) {
1435 [[StatusWindowController sharedController] showReconnectQueryWindow];
1439 - (void)remoteServerNotFound:(id)sender
1441 if (![[NetworkController sharedController] isConnectedToServer]) {
1442 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1446 - (void)networkError:(NSException *)exception
1448 ITDebugLog(@"Remote exception thrown: %@: %@", [exception name], [exception reason]);
1449 if ( ((exception == nil) || [[exception name] isEqualToString:NSPortTimeoutException]) && [networkController isConnectedToServer]) {
1450 //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);
1451 [[StatusWindowController sharedController] showNetworkErrorQueryWindow];
1452 if ([self disconnectFromServer]) {
1453 [[PreferencesController sharedPrefs] resetRemotePlayerTextFields];
1454 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1456 ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
1463 /*if ([self connectToServer] == 0) {
1464 [NSTimer scheduledTimerWithTimeInterval:90.0 target:self selector:@selector(checkForRemoteServer) userInfo:nil repeats:NO];
1466 [self checkForRemoteServerAndConnectImmediately:YES];
1467 [[StatusWindow sharedWindow] setLocked:NO];
1468 [[StatusWindow sharedWindow] vanish:self];
1469 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1472 - (void)cancelReconnect
1474 [[StatusWindow sharedWindow] setLocked:NO];
1475 [[StatusWindow sharedWindow] vanish:self];
1476 [[StatusWindow sharedWindow] setIgnoresMouseEvents:YES];
1479 /*************************************************************************/
1481 #pragma mark WORKSPACE NOTIFICATION HANDLERS
1482 /*************************************************************************/
1484 - (void)applicationLaunched:(NSNotification *)note
1487 if (!note || ([[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[[self currentRemote] playerFullName]] && ![[NetworkController sharedController] isConnectedToServer])) {
1488 ITDebugLog(@"Remote application launched.");
1489 playerRunningState = ITMTRemotePlayerRunning;
1490 [[self currentRemote] begin];
1491 [self setLatestSongIdentifier:@""];
1493 refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:([networkController isConnectedToServer] ? 10.0 : 0.5)
1495 selector:@selector(timerUpdate)
1497 repeats:YES] retain];
1498 //[NSThread detachNewThreadSelector:@selector(startTimerInNewThread) toTarget:self withObject:nil];
1499 if (![df boolForKey:@"UsePollingOnly"]) {
1500 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(trackChanged:) name:@"ITMTTrackChanged" object:nil];
1502 [self setupHotKeys];
1505 [self networkError:localException];
1509 - (void)applicationTerminated:(NSNotification *)note
1512 if (!note || [[[note userInfo] objectForKey:@"NSApplicationName"] isEqualToString:[[self currentRemote] playerFullName]] && ![[NetworkController sharedController] isConnectedToServer]) {
1513 ITDebugLog(@"Remote application terminated.");
1514 playerRunningState = ITMTRemotePlayerNotRunning;
1515 [[self currentRemote] halt];
1516 [refreshTimer invalidate];
1517 [refreshTimer release];
1519 [[NSNotificationCenter defaultCenter] removeObserver:self];
1520 [statusItem setEnabled:YES];
1521 [statusItem setToolTip:@"iTunes not running."];
1522 [self clearHotKeys];
1525 if ([df objectForKey:@"ShowPlayer"] != nil) {
1527 ITDebugLog(@"Setting up show player hot key.");
1528 hotKey = [[ITHotKey alloc] init];
1529 [hotKey setName:@"ShowPlayer"];
1530 [hotKey setKeyCombo:[ITKeyCombo keyComboWithPlistRepresentation:[df objectForKey:@"ShowPlayer"]]];
1531 [hotKey setTarget:self];
1532 [hotKey setAction:@selector(showPlayer)];
1533 [[ITHotKeyCenter sharedCenter] registerHotKey:[hotKey autorelease]];
1537 [self networkError:localException];
1542 /*************************************************************************/
1544 #pragma mark NSApplication DELEGATE METHODS
1545 /*************************************************************************/
1547 - (void)applicationWillTerminate:(NSNotification *)note
1549 [[[NSWorkspace sharedWorkspace] notificationCenter] removeObserver:self];
1550 [networkController stopRemoteServerSearch];
1551 [self clearHotKeys];
1552 [[NSStatusBar systemStatusBar] removeStatusItem:statusItem];
1556 /*************************************************************************/
1558 #pragma mark DEALLOCATION METHOD
1559 /*************************************************************************/
1563 [self applicationTerminated:nil];
1565 [statusItem release];
1566 [statusWindowController release];
1567 [menuController release];
1568 [networkController release];
1569 [_serverCheckLock release];