From 2ca51225df3ee5badc4029761db3f32a68bfb140 Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Sat, 28 Feb 2009 01:47:25 +0000 Subject: Applies connection checks and keepalive logic to select database/refresh databases queries. This fixes Issue #176. --- Source/CMMCPConnection.m | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'Source/CMMCPConnection.m') diff --git a/Source/CMMCPConnection.m b/Source/CMMCPConnection.m index 5319f42f..11f60b97 100644 --- a/Source/CMMCPConnection.m +++ b/Source/CMMCPConnection.m @@ -286,6 +286,23 @@ WARNING : incomplete implementation. Please, send your fixes. */ +/* + * Modified version of selectDB to be used in Sequel Pro. + * Checks the connection exists, and handles keepalive, otherwise calling the parent implementation. + */ +- (BOOL) selectDB:(NSString *) dbName +{ + if (!mConnected) return NO; + [self stopKeepAliveTimer]; + if (![self checkConnection]) return NO; + if ([super selectDB:dbName]) { + [self startKeepAliveTimerResettingState:YES]; + return YES; + } + return NO; +} + + /* * Modified version of queryString to be used in Sequel Pro. * Error checks extensively - if this method fails, it will ask how to proceed and loop depending @@ -336,6 +353,20 @@ WARNING : incomplete implementation. Please, send your fixes. } +/* + * Modified version of selectDB to be used in Sequel Pro. + * Checks the connection exists, and handles keepalive, otherwise calling the parent implementation. + */ +- (MCPResult *) listDBsLike:(NSString *) dbsName +{ + if (!mConnected) return NO; + [self stopKeepAliveTimer]; + if (![self checkConnection]) return [[[MCPResult alloc] init] autorelease]; + [self startKeepAliveTimerResettingState:YES]; + return [super listDBsLike:dbsName]; +} + + /* * Checks whether the connection to the server is still active. If not, prompts for what approach to take, * offering to retry, reconnect or disconnect the connection. -- cgit v1.2.3