diff options
author | stuconnolly <stuart02@gmail.com> | 2009-07-21 16:47:11 +0000 |
---|---|---|
committer | stuconnolly <stuart02@gmail.com> | 2009-07-21 16:47:11 +0000 |
commit | 8b8f3e6cea540b17262aadf6d97a8ad28fe41c03 (patch) | |
tree | ad6bb7f53b03924aa24d0cf5822a27b3bd453592 /Source/SPSSHTunnel.m | |
parent | 383863f98dfc488db0181e01d39da1bb025d421b (diff) | |
download | sequelpro-8b8f3e6cea540b17262aadf6d97a8ad28fe41c03.tar.gz sequelpro-8b8f3e6cea540b17262aadf6d97a8ad28fe41c03.tar.bz2 sequelpro-8b8f3e6cea540b17262aadf6d97a8ad28fe41c03.zip |
Merge framework integration branch back to trunk. Summary of changes:
- Includes all custom code from subclasses CMMCPConnection and CMMCPResult, meaning they have subsequently been removed from the project.
- All previous Sequel Pro specific code in the above subclasses has been removed in favour of the delegate (currently set to TableDocumet) informing the framework of such information.
- All references to CMMCPConnection and CMMCPResult have subsequently been changed to MCPConnection and MCPResult.
- Framework includes MySQL 5.1.36 client libraries and source headers.
- Framework is now built as a 4-way (32/64 bit, i386/PPC arch) binary.
- All import references to <MCPKit_bundled/MCPKit_bundled.h> have been changed to <MCPKit/MCPKit.h>.
- New script 'build-mysql-client.sh' can be used to build the MySQL client libraries from the MySQL source. See the script's header for a list of available options or run it with no arguments to display it's usage.
Note that there are still a few changes to be made to the framework with regard to removing Sequel Pro specific calls to the delegate. These however can be made later on as they have no effect on functionality and are merely design changes.
Also, note that any future development done on the framework should be made to be as 'generic' as possible, with no Sequel Pro specific references. This should allow the framework to be integrated into another project without the need for SP specific code.
Diffstat (limited to 'Source/SPSSHTunnel.m')
-rw-r--r-- | Source/SPSSHTunnel.m | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/Source/SPSSHTunnel.m b/Source/SPSSHTunnel.m index 62fc61b2..5b765525 100644 --- a/Source/SPSSHTunnel.m +++ b/Source/SPSSHTunnel.m @@ -26,7 +26,6 @@ #import "KeyChain.h" #import <netinet/in.h> - @implementation SPSSHTunnel /* @@ -73,7 +72,7 @@ requestedResponse = NO; task = nil; localPort = 0; - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; return self; } @@ -160,8 +159,9 @@ - (void) connect { localPort = 0; + + if (connectionState != PROXY_STATE_IDLE || (!passwordInKeychain && !password)) return; [debugMessages removeAllObjects]; - if (connectionState != SPSSH_STATE_IDLE || (!passwordInKeychain && !password)) return; [NSThread detachNewThreadSelector:@selector(launchTask:) toTarget: self withObject: nil ]; } @@ -172,18 +172,18 @@ */ - (void) launchTask:(id) dummy { - if (connectionState != SPSSH_STATE_IDLE || task) return; + if (connectionState != PROXY_STATE_IDLE || task) return; NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSMutableArray *taskArguments; NSMutableDictionary *taskEnvironment; NSString *authenticationAppPath; - connectionState = SPSSH_STATE_CONNECTING; + connectionState = PROXY_STATE_CONNECTING; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; // Enforce a parent window being present for dialogs if (!parentWindow) { - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:@"SSH Tunnel started without a parent window. A parent window must be present."]; @@ -191,7 +191,7 @@ return; } - int connectionTimeout = [[[NSUserDefaults standardUserDefaults] objectForKey:@"ConnectionTimeout"] intValue]; + int connectionTimeout = [[[NSUserDefaults standardUserDefaults] objectForKey:@"ConnectionTimeoutValue"] intValue]; if (!connectionTimeout) connectionTimeout = 10; BOOL useKeepAlive = [[[NSUserDefaults standardUserDefaults] objectForKey:@"UseKeepAlive"] doubleValue]; double keepAliveInterval = [[[NSUserDefaults standardUserDefaults] objectForKey:@"KeepAliveInterval"] doubleValue]; @@ -233,7 +233,7 @@ // Abort if no local free port could be allocated if (!localPort || (useHostFallback && !localPortFallback)) { - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:NSLocalizedString(@"No local port could be allocated for the SSH Tunnel.", @"SSH tunnel could not be created because no local port could be allocated")]; @@ -320,8 +320,8 @@ [task waitUntilExit]; // If the task closed unexpectedly, alert appropriately - if (connectionState != SPSSH_STATE_IDLE) { - connectionState = SPSSH_STATE_IDLE; + if (connectionState != PROXY_STATE_IDLE) { + connectionState = PROXY_STATE_IDLE; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel has unexpectedly closed.", @"SSH tunnel unexpectedly closed")]; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; @@ -344,9 +344,9 @@ */ - (void)disconnect { - if (connectionState == SPSSH_STATE_IDLE) return; + if (connectionState == PROXY_STATE_IDLE) return; [task terminate]; - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } @@ -370,36 +370,36 @@ [debugMessages addObject:[NSString stringWithString:message]]; if ([message rangeOfString:@"Entering interactive session."].location != NSNotFound) { - connectionState = SPSSH_STATE_CONNECTED; + connectionState = PROXY_STATE_CONNECTED; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } if ([message rangeOfString:@"Connection established"].location != NSNotFound) { - connectionState = SPSSH_STATE_WAITING_FOR_AUTH; + connectionState = PROXY_STATE_WAITING_FOR_AUTH; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } if ([message rangeOfString:@"closed by remote host." ].location != NSNotFound) { - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; [task terminate]; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel was closed 'by the remote host'. This may indicate a networking issue or a network timeout.", @"SSH tunnel was closed by remote host message")]; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } if ([message rangeOfString:@"Permission denied (" ].location != NSNotFound || [message rangeOfString:@"No more authentication methods to try" ].location != NSNotFound) { - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; [task terminate]; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel could not authenticate with the remote host. Please check your password and ensure you still have access.", @"SSH tunnel authentication failed message")]; if (delegate) [delegate performSelectorOnMainThread:stateChangeSelector withObject:self waitUntilDone:NO]; } if ([message rangeOfString:@"connect failed: Connection refused" ].location != NSNotFound) { - connectionState = SPSSH_STATE_FORWARDING_FAILED; + connectionState = PROXY_STATE_FORWARDING_FAILED; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithString:NSLocalizedString(@"The SSH Tunnel was established successfully, but could not forward data to the remote port as the remote port refused the connection.", @"SSH tunnel forwarding port connection refused message")]; } if ([message rangeOfString:@"Operation timed out" ].location != NSNotFound) { - connectionState = SPSSH_STATE_IDLE; + connectionState = PROXY_STATE_IDLE; [task terminate]; if (lastError) [lastError release]; lastError = [[NSString alloc] initWithFormat:NSLocalizedString(@"The SSH Tunnel was unable to connect to host %@, or the request timed out.\n\nBe sure that the address is correct and that you have the necessary privileges, or try increasing the connection timeout (currently %i seconds).", @"SSH tunnel failed or timed out message"), sshHost, [[[NSUserDefaults standardUserDefaults] objectForKey:@"ConnectionTimeoutValue"] intValue]]; @@ -408,7 +408,7 @@ } } - if (connectionState != SPSSH_STATE_IDLE) { + if (connectionState != PROXY_STATE_IDLE) { [[standardError fileHandleForReading] waitForDataInBackgroundAndNotify]; } @@ -565,7 +565,7 @@ { delegate = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; - if (connectionState != SPSSH_STATE_IDLE) [self disconnect]; + if (connectionState != PROXY_STATE_IDLE) [self disconnect]; [sshHost release]; [sshLogin release]; [remoteHost release]; |