diff options
author | rowanbeentje <rowan@beent.je> | 2009-06-14 20:30:52 +0000 |
---|---|---|
committer | rowanbeentje <rowan@beent.je> | 2009-06-14 20:30:52 +0000 |
commit | 3502af9a810b51116cd93358c608722e3714f4c0 (patch) | |
tree | dd17f7d4ff32b0346c03deaaac36da761a3ae56b /Source/CMMCPConnection.m | |
parent | 8f880b82a86b2bfe6bbf70ff934096b8a720bb20 (diff) | |
download | sequelpro-3502af9a810b51116cd93358c608722e3714f4c0.tar.gz sequelpro-3502af9a810b51116cd93358c608722e3714f4c0.tar.bz2 sequelpro-3502af9a810b51116cd93358c608722e3714f4c0.zip |
Add support for titlebar connection status images, and use for SSH tunnels.
- Add view and code to support drawing a connection status icon at the left of the titlebar
- Use for SSH tunnels; completes Issue #114.
- Remove reference to an image resource "j" in the DBView - fixes console log errors.
Diffstat (limited to 'Source/CMMCPConnection.m')
-rw-r--r-- | Source/CMMCPConnection.m | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index db45a3d8..6654948b 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -239,7 +239,10 @@ static void forcePingTimeout(int signalNumber); theRet = mysql_real_connect(mConnection, theHost, theLogin, thePass, NULL, connectionPort, theSocket, mConnectionFlags); thePass = NULL; if (theRet != mConnection) { - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } return mConnected = NO; } @@ -260,7 +263,10 @@ static void forcePingTimeout(int signalNumber); { [super disconnect]; - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } if( serverVersionString != nil ) { [serverVersionString release]; @@ -358,16 +364,19 @@ static void forcePingTimeout(int signalNumber); [connectionTunnel setConnectionStateChangeSelector:nil delegate:nil]; if ([connectionTunnel state] != SPSSH_STATE_IDLE) [connectionTunnel disconnect]; [connectionTunnel connect]; + [delegate setStatusIconToImageWithName:@"ssh-connecting"]; NSDate *tunnelStartDate = [NSDate date], *interfaceInteractionTimer; // Allow the tunnel to attempt to connect in a loop while (1) { if ([connectionTunnel state] == SPSSH_STATE_CONNECTED) { + [delegate setStatusIconToImageWithName:@"ssh-connected"]; connectionPort = [connectionTunnel localPort]; break; } if ([[NSDate date] timeIntervalSinceDate:tunnelStartDate] > (connectionTimeout + 1)) { [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; break; } @@ -449,6 +458,12 @@ static void forcePingTimeout(int signalNumber); { int newState = [theTunnel state]; + if (delegate && [delegate respondsToSelector:@selector(setStatusIconToImageWithName:)]) { + if (newState == SPSSH_STATE_IDLE) [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + else if (newState == SPSSH_STATE_CONNECTED) [delegate setStatusIconToImageWithName:@"ssh-connected"]; + else [delegate setStatusIconToImageWithName:@"ssh-connecting"]; + } + // Restart the tunnel if it dies if (mConnected && newState == SPSSH_STATE_IDLE && currentSSHTunnelState == SPSSH_STATE_CONNECTED) { currentSSHTunnelState = newState; @@ -614,7 +629,10 @@ static void forcePingTimeout(int signalNumber); [self startKeepAliveTimerResettingState:YES]; return YES; } - if (connectionTunnel) [connectionTunnel disconnect]; + if (connectionTunnel) { + [connectionTunnel disconnect]; + [delegate setStatusIconToImageWithName:@"ssh-disconnected"]; + } return NO; } |