diff options
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h | 2 | ||||
-rw-r--r-- | Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m | 14 | ||||
-rw-r--r-- | Source/TableDocument.m | 22 |
3 files changed, 29 insertions, 9 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index a6457494..4a0f7485 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -54,6 +54,8 @@ static inline NSData* NSStringDataUsingLossyEncoding(NSString* self, int encodin - (void)queryGaveError:(NSString *)error connection:(id)connection; - (BOOL)connectionEncodingViaLatin1:(id)connection; - (NSString *)keychainPasswordForConnection:(id)connection; +- (NSString *)onReconnectShouldSelectDatabase:(id)connection; +- (NSString *)onReconnectShouldUseEncoding:(id)connection; - (MCPConnectionCheck)connectionLost:(id)connection; @end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 55fbca84..2871070f 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -371,13 +371,13 @@ static BOOL sTruncateLongFieldInLogs = YES; BOOL currentEncodingUsesLatin1Transport = NO; NSString *currentDatabase = nil; - // Store the current database and encoding so they can be re-set if reconnection was successful - if (delegate && [delegate valueForKey:@"selectedDatabase"]) { - currentDatabase = [NSString stringWithString:[delegate valueForKey:@"selectedDatabase"]]; + // Store the currently selected database and encoding so they can be re-set if reconnection was successful + if (delegate && [delegate respondsToSelector:@selector(onReconnectShouldSelectDatabase:)]) { + currentDatabase = [NSString stringWithString:[delegate onReconnectShouldSelectDatabase:self]]; } - if (delegate && [delegate valueForKey:@"_encoding"]) { - currentEncoding = [NSString stringWithString:[delegate valueForKey:@"_encoding"]]; + if (delegate && [delegate respondsToSelector:@selector(onReconnectShouldUseEncoding:)]) { + currentEncoding = [NSString stringWithString:[delegate onReconnectShouldUseEncoding:self]]; } if (delegate && [delegate respondsToSelector:@selector(connectionEncodingViaLatin1:)]) { @@ -681,8 +681,8 @@ static void forcePingTimeout(int signalNumber) connectionStartTime = mach_absolute_time(); [self fetchMaxAllowedPacket]; - if (delegate && [delegate valueForKey:@"_encoding"]) { - [self queryString:[NSString stringWithFormat:@"/*!40101 SET NAMES '%@' */", [NSString stringWithString:[delegate valueForKey:@"_encoding"]]]]; + if (delegate && [delegate respondsToSelector:@selector(onReconnectShouldUseEncoding:)]) { + [self queryString:[NSString stringWithFormat:@"/*!40101 SET NAMES '%@' */", [NSString stringWithString:[delegate onReconnectShouldUseEncoding:self]]]]; if (delegate && [delegate respondsToSelector:@selector(connectionEncodingViaLatin1:)]) { if ([delegate connectionEncodingViaLatin1:self]) [self queryString:@"/*!40101 SET CHARACTER_SET_RESULTS=latin1 */"]; } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index 8302f553..c3a5b3da 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -2024,7 +2024,7 @@ #pragma mark MCPKit connection delegate methods /** - * Invoked when framework is about to perform a query. + * Invoked when the framework is about to perform a query. */ - (void)willQueryString:(NSString *)query connection:(id)connection { @@ -2034,7 +2034,7 @@ } /** - * Invoked when the query just executed resulted in an error. + * Invoked when the query just executed by the framework resulted in an error. */ - (void)queryGaveError:(NSString *)error connection:(id)connection { @@ -2042,6 +2042,24 @@ } /** + * Invoked when the framework is in the process of reconnecting to the server and needs to know + * which database to select. + */ +- (NSString *)onReconnectShouldSelectDatabase:(id)connection +{ + return selectedDatabase; +} + +/** + * Invoked when the framework is in the process of reconnecting to the server and needs to know + * what encoding to use for the connection. + */ +- (NSString *)onReconnectShouldUseEncoding:(id)connection +{ + return _encoding; +} + +/** * Invoked when the current connection needs a password from the Keychain. */ - (NSString *)keychainPasswordForConnection:(MCPConnection *)connection |