like 99 left.
appearanceEffectPopup = NSPopUpButton;
appearanceSpeedSlider = NSSlider;
artistCheckbox = NSButton;
+ clientPasswordTextField = NSTextField;
hostTextField = NSTextField;
hotKeysTableView = NSTableView;
launchAtLoginCheckbox = NSButton;
<key>634</key>
<string>386 421 380 180 0 0 1152 746 </string>
<key>639</key>
- <string>412 313 380 122 0 0 1152 746 </string>
+ <string>386 450 380 122 0 0 1152 746 </string>
</dict>
<key>IBFramework Version</key>
<string>349.0</string>
<key>IBOpenObjects</key>
<array>
<integer>6</integer>
+ <integer>699</integer>
+ <integer>624</integer>
</array>
<key>IBSystem Version</key>
<string>7B85</string>
- (BOOL)connectToServer
{
+ int result;
ITDebugLog(@"Attempting to connect to shared remote.");
+ result = [networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]];
//Connect
- if ([networkController connectToHost:[df stringForKey:@"sharedPlayerHost"]]) {
+ if (result == 1) {
currentRemote = [[[networkController networkObject] remote] retain];
[self timerUpdate];
//[refreshTimer invalidate];
ITDebugLog(@"Connection successful.");
return YES;
- } else {
+ } else if (result == 0) {
ITDebugLog(@"Connection failed.");
currentRemote = [remoteArray objectAtIndex:0];
return NO;
+ } else if (result == -1) {
+ ITDebugLog(@"Connection failed.");
+ currentRemote = [remoteArray objectAtIndex:0];
+ return NO;
+ //Do something about the password being invalid
}
}
if ([networkController checkForServerAtHost:[df stringForKey:@"sharedPlayerHost"]]) {
ITDebugLog(@"Remote server found.");
[timer invalidate];
- [[StatusWindowController sharedController] showReconnectQueryWindow];
+ if (![networkController isConnectedToServer]) {
+ [[StatusWindowController sharedController] showReconnectQueryWindow];
+ }
} else {
ITDebugLog(@"Remote server not found.");
}
- (void)networkError:(NSException *)exception
{
ITDebugLog(@"Remote exception thrown: %@: %@", [exception name], [exception reason]);
- if ([[exception name] isEqualToString:NSPortTimeoutException]) {
+ NSLog(@"%@", [exception reason]);
+ 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 ([networkController isConnectedToServer] && [self disconnectFromServer]) {
+ if ([self disconnectFromServer]) {
[NSTimer scheduledTimerWithTimeInterval:45 target:self selector:@selector(checkForRemoteServer:) userInfo:nil repeats:YES];
} else {
ITDebugLog(@"CRITICAL ERROR, DISCONNECTING!");
- (void)stopRemoteServerSearch;
- (void)setServerStatus:(BOOL)status;
-- (BOOL)connectToHost:(NSString *)host;
+- (int)connectToHost:(NSString *)host;
- (BOOL)checkForServerAtHost:(NSString *)host;
- (BOOL)disconnect;
- (BOOL)isServerOn;
}
}
-- (BOOL)connectToHost:(NSString *)host
+- (int)connectToHost:(NSString *)host
{
NSData *fullPass = [[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"];
unsigned char buffer;
if (![clientProxy sendPassword:[[NSUserDefaults standardUserDefaults] dataForKey:@"connectPassword"]]) {
ITDebugLog(@"Invalid password!");
[self disconnect];
- if ( NSRunCriticalAlertPanel(@"Invalid Password", @"The MenuTunes server you attempted to connect to rejected your password. Would you like to try to reconnect?.", @"Yes", @"No", nil) == NSOKButton ) {
- return [self connectToHost:host];
- } else {
- return NO;
- }
+ return -1;
}
}
ITDebugLog(@"Connected to host: %@", host);
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(disconnect) name:NSConnectionDidDieNotification object:clientConnection];
- connectedToServer = YES;
- return YES;
+ connectedToServer = 1;
+ return 1;
}
- (BOOL)disconnect
IBOutlet NSPopUpButton *appearanceEffectPopup;
IBOutlet NSSlider *appearanceSpeedSlider;
IBOutlet NSButton *artistCheckbox;
+ IBOutlet NSTextField *clientPasswordTextField;
IBOutlet NSTextField *hostTextField;
IBOutlet NSTableView *hotKeysTableView;
IBOutlet NSButton *launchAtLoginCheckbox;
[selectSharedPlayerButton setEnabled:state];
if (state) {
+ [selectedPlayerTextField setStringValue:[[[NetworkController sharedController] networkObject] serverName]];
+ [locationTextField setStringValue:[[NetworkController sharedController] remoteHost]];
[controller connectToServer];
} else {
+ [selectedPlayerTextField setStringValue:@"No shared player selected."];
+ [locationTextField setStringValue:@"-"];
[controller disconnectFromServer];
+
}
} else if ( [sender tag] == 5050 ) {
//Do nothing on table view click
[NSApp endSheet:selectPlayerSheet];
[selectPlayerSheet orderOut:nil];
+ [self changeSharingSetting:clientPasswordTextField];
+
if ([selectPlayerBox contentView] == manualView) {
[df setObject:[hostTextField stringValue] forKey:@"sharedPlayerHost"];
} else {
if ([sharingTableView selectedRow] > -1) {
- [df setObject:[NSString stringWithCString:inet_ntoa((*(struct sockaddr_in*)[[[[NetworkController sharedController] remoteServices] objectAtIndex:[sharingTableView selectedRow]] bytes]).sin_addr)] forKey:@"sharedPlayerHost"];
+ [df setObject:[NSString stringWithCString:inet_ntoa((*(struct sockaddr_in*)[[[[[[NetworkController sharedController] remoteServices] objectAtIndex:[sharingTableView selectedRow]] addresses] objectAtIndex:0] bytes]).sin_addr)] forKey:@"sharedPlayerHost"];
}
}