diff options
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; } |