X-Git-Url: http://git.ithinksw.org/MenuTunes.git/blobdiff_plain/da05d51282a00722e05f2c777db5cc3d0623d348..ec1969da79832d035791a9d6647242fffe0b176a:/MainController.m?ds=inline diff --git a/MainController.m b/MainController.m index 341eb8d..5637bae 100755 --- a/MainController.m +++ b/MainController.m @@ -64,7 +64,7 @@ static MainController *sharedController; if ([df boolForKey:@"enableSharing"]) { [self setServerStatus:YES]; } else if ([df boolForKey:@"useSharedPlayer"]) { - if (![self connectToServer]) { + if ([self connectToServer] == 0) { [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES]; } } @@ -943,27 +943,27 @@ static MainController *sharedController; } } -- (BOOL)connectToServer +- (int)connectToServer { int result; ITDebugLog(@"Attempting to connect to shared remote."); result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]]; //Connect if (result == 1) { + [[PreferencesController sharedPrefs] resetRemotePlayerTextFields]; currentRemote = [[[networkController networkObject] remote] retain]; [self timerUpdate]; - //[refreshTimer invalidate]; ITDebugLog(@"Connection successful."); - return YES; + return 1; } else if (result == 0) { ITDebugLog(@"Connection failed."); currentRemote = [remoteArray objectAtIndex:0]; - return NO; + return 0; } else { //Do something about the password being invalid ITDebugLog(@"Connection failed."); currentRemote = [remoteArray objectAtIndex:0]; - return NO; + return -1; } } @@ -999,6 +999,7 @@ static MainController *sharedController; if ([[exception name] isEqualToString:NSPortTimeoutException] && [networkController isConnectedToServer]) { 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); if ([self disconnectFromServer]) { + [[PreferencesController sharedPrefs] resetRemotePlayerTextFields]; [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES]; } else { ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!"); @@ -1008,7 +1009,7 @@ static MainController *sharedController; - (void)reconnect { - if (![self connectToServer]) { + if ([self connectToServer] == 0) { [NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES]; } [[StatusWindow sharedWindow] setLocked:NO]; @@ -1075,8 +1076,8 @@ static MainController *sharedController; - (void)applicationWillTerminate:(NSNotification *)note { - [self clearHotKeys]; [networkController stopRemoteServerSearch]; + [self clearHotKeys]; [[NSStatusBar systemStatusBar] removeStatusItem:statusItem]; } @@ -1097,5 +1098,4 @@ static MainController *sharedController; [super dealloc]; } - @end \ No newline at end of file