git.ithinksw.org
/
MenuTunes.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed a bunch of the networking crashes and bugs appearing. All with just 5 lines...
[MenuTunes.git]
/
MainController.m
diff --git
a/MainController.m
b/MainController.m
index
940766c
..
c235a8f
100755
(executable)
--- a/
MainController.m
+++ b/
MainController.m
@@
-10,11
+10,7
@@
#import "StatusWindowController.h"
#import "StatusItemHack.h"
#import "StatusWindowController.h"
#import "StatusItemHack.h"
-@interface NSImage (WeeAdditions)
-- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize;
-@end
-
-@implementation NSImage (WeeAdditions)
+@implementation NSImage (SmoothAdditions)
- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
{
- (NSImage *)imageScaledSmoothlyToSize:(NSSize)scaledSize
{
@@
-264,7
+260,7
@@
static MainController *sharedController;
[self setupHotKeys];
if (![refreshTimer isValid]) {
[refreshTimer release];
[self setupHotKeys];
if (![refreshTimer isValid]) {
[refreshTimer release];
- refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:
0.5
+ refreshTimer = [[NSTimer scheduledTimerWithTimeInterval:
([networkController isConnectedToServer] ? 10.0 : 0.5)
target:self
selector:@selector(timerUpdate)
userInfo:nil
target:self
selector:@selector(timerUpdate)
userInfo:nil
@@
-330,17
+326,14
@@
static MainController *sharedController;
- (void)setLatestSongIdentifier:(NSString *)newIdentifier
{
- (void)setLatestSongIdentifier:(NSString *)newIdentifier
{
- ITDebugLog(@"Setting latest song identifier to %@", newIdentifier);
+ ITDebugLog(@"Setting latest song identifier:");
+ ITDebugLog(@" - Identifier: %@", newIdentifier);
[_latestSongIdentifier autorelease];
[_latestSongIdentifier autorelease];
- _latestSongIdentifier = [newIdentifier
copy
];
+ _latestSongIdentifier = [newIdentifier
retain
];
}
- (void)timerUpdate
{
}
- (void)timerUpdate
{
- if ([networkController isConnectedToServer]) {
- [statusItem setMenu:[menuController menu]];
- }
-
if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
ITDebugLog(@"The song changed.");
if ( [self songChanged] && (timerUpdating != YES) && (playerRunningState == ITMTRemotePlayerRunning) ) {
ITDebugLog(@"The song changed.");
@@
-352,7
+345,7
@@
static MainController *sharedController;
while ( (nextScript = [scriptsEnum nextObject]) ) {
NSDictionary *error;
NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
while ( (nextScript = [scriptsEnum nextObject]) ) {
NSDictionary *error;
NSAppleScript *currentScript = [[NSAppleScript alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSHomeDirectory() stringByAppendingPathComponent:@"Library/Application Support/MenuTunes/Scripts"] stringByAppendingPathComponent:nextScript]] error:&error];
-
NS
Log(@"Running script: %@", nextScript);
+
ITDebug
Log(@"Running script: %@", nextScript);
if (!currentScript || ![currentScript executeAndReturnError:nil]) {
ITDebugLog(@"Error running script %@.", nextScript);
}
if (!currentScript || ![currentScript executeAndReturnError:nil]) {
ITDebugLog(@"Error running script %@.", nextScript);
}
@@
-361,6
+354,7
@@
static MainController *sharedController;
}
timerUpdating = YES;
}
timerUpdating = YES;
+ [statusItem setEnabled:NO];
NS_DURING
latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
NS_DURING
latestPlaylistClass = [[self currentRemote] currentPlaylistClass];
@@
-394,6
+388,11
@@
static MainController *sharedController;
NS_ENDHANDLER
timerUpdating = NO;
NS_ENDHANDLER
timerUpdating = NO;
+ [statusItem setEnabled:YES];
+ }
+
+ if ([networkController isConnectedToServer]) {
+ [statusItem setMenu:[menuController menu]];
}
}
}
}
@@
-632,7
+631,7
@@
static MainController *sharedController;
ITHotKey *hotKey;
ITDebugLog(@"Setting up hot keys.");
ITHotKey *hotKey;
ITDebugLog(@"Setting up hot keys.");
- if (playerRunningState == ITMTRemotePlayerNotRunning) {
+ if (playerRunningState == ITMTRemotePlayerNotRunning
&& ![[NetworkController sharedController] isConnectedToServer]
) {
return;
}
return;
}
@@
-770,6
+769,8
@@
static MainController *sharedController;
NSImage *art = nil;
int rating = -1;
NSImage *art = nil;
int rating = -1;
+ ITDebugLog(@"Showing track info status window.");
+
NS_DURING
source = [[self currentRemote] currentSource];
title = [[self currentRemote] currentSongTitle];
NS_DURING
source = [[self currentRemote] currentSource];
title = [[self currentRemote] currentSongTitle];
@@
-777,8
+778,6
@@
static MainController *sharedController;
[self networkError:localException];
NS_ENDHANDLER
[self networkError:localException];
NS_ENDHANDLER
- ITDebugLog(@"Showing track info status window.");
-
if ( title ) {
if ( [df boolForKey:@"showAlbum"] ) {
if ( title ) {
if ( [df boolForKey:@"showAlbum"] ) {
@@
-863,6
+862,7
@@
static MainController *sharedController;
} else {
title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
}
} else {
title = NSLocalizedString(@"noSongPlaying", @"No song is playing.");
}
+ ITDebugLog(@"Showing current track info status window.");
[statusWindowController showSongInfoWindowWithSource:source
title:title
album:album
[statusWindowController showSongInfoWindowWithSource:source
title:title
album:album
@@
-1119,6
+1119,12
@@
static MainController *sharedController;
[currentRemote release];
currentRemote = [remoteArray objectAtIndex:0];
[networkController disconnect];
[currentRemote release];
currentRemote = [remoteArray objectAtIndex:0];
[networkController disconnect];
+
+ if ([[self currentRemote] playerRunningState] == ITMTRemotePlayerRunning) {
+ [self applicationLaunched:nil];
+ } else {
+ [self applicationTerminated:nil];
+ }
[self timerUpdate];
return YES;
}
[self timerUpdate];
return YES;
}