diff options
Diffstat (limited to 'Frameworks/MCPKit/MCPFoundationKit')
4 files changed, 115 insertions, 91 deletions
diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h index 609830ce..ad30fa07 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.h @@ -38,101 +38,21 @@ typedef struct { BOOL *lastPingSuccessPointer; } MCPConnectionPingDetails; -@protocol MCPConnectionProxy; - @class MCPResult, MCPStreamingResult; - -@interface NSObject (MCPConnectionDelegate) - -/** - * - */ -- (void)willQueryString:(NSString *)query connection:(id)connection; - -/** - * - */ -- (void)queryGaveError:(NSString *)error connection:(id)connection; - -/** - * - */ -- (void)showErrorWithTitle:(NSString *)error message:(NSString *)connection; - -/** - * - */ -- (NSString *)keychainPasswordForConnection:(id)connection; - -/** - * - */ -- (NSString *)onReconnectShouldSelectDatabase:(id)connection; - -/** - * - */ -- (void)noConnectionAvailable:(id)connection; - -/** - * - */ -- (MCPConnectionCheck)connectionLost:(id)connection; - -/** - * - */ -- (NSString *)connectionID; - -/** - * - */ -- (NSString *)database; - -/** - * - */ -- (BOOL)navigatorSchemaPathExistsForDatabase:(NSString*)dbname; - -/** - * - */ -- (NSArray*)allDatabaseNames; - -/** - * - */ -- (NSArray*)allSystemDatabaseNames; - -/** - * - */ -- (NSArray*)allTableNames; - -/** - * - */ -- (NSArray*)allViewNames; - -/** - * - */ -- (NSArray*)allSchemaKeys; - -@end +@protocol MCPConnectionProxy, MCPConnectionDelegate; @interface MCPConnection : NSObject { - MYSQL *mConnection; /* The inited MySQL connection. */ - BOOL mConnected; /* Reflect the fact that the connection is already in place or not. */ - NSStringEncoding mEncoding; /* The encoding used by MySQL server, to ISO-1 default. */ - NSTimeZone *mTimeZone; /* The time zone of the session. */ - NSUInteger mConnectionFlags; /* The flags to be used for the connection to the database. */ + MYSQL *mConnection; + BOOL mConnected; + NSStringEncoding mEncoding; + NSTimeZone *mTimeZone; + NSUInteger mConnectionFlags; - id delegate; /* Connection delegate */ + id <MCPConnectionDelegate> delegate; - /* Anything that performs a mysql_net_read is not thread-safe: mysql queries, pings */ - /* Always lock the connection first. Don't use this lock directly, use the lockConnection method! */ + // Anything that performs a mysql_net_read is not thread-safe: mysql queries, pings + // Always lock the connection first. Don't use this lock directly, use the lockConnection method! NSConditionLock *connectionLock; BOOL useKeepAlive; diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m index 15eaae82..f503db55 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnection.m @@ -60,6 +60,25 @@ static BOOL sTruncateLongFieldInLogs = YES; @end +/** + * Note that these aren't actually delegate methods, but are defined because queryDbStructureWithUserInfo needs + * them. We define them here to supress compiler warnings. + * + * TODO: Remove along with queryDbStructureWithUserInfo + */ +@interface MCPConnection (MCPConnectionDelegate) + +- (NSString *)database; +- (NSString *)connectionID; + +- (NSArray *)allDatabaseNames; +- (NSArray *)allSystemDatabaseNames; +- (NSArray *)allTableNames; +- (NSArray *)allViewNames; +- (NSArray *)allSchemaKeys; + +@end + @implementation MCPConnection // Synthesize ivars @@ -2222,6 +2241,8 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) /** * Updates the dict containing the structure of all available databases (mainly for completion/navigator) * executed on a new connection. + * + * TODO: Split this entire method out of MCPKit if possible */ - (void)queryDbStructureWithUserInfo:(NSDictionary*)userInfo { @@ -2331,7 +2352,7 @@ void pingThreadCleanup(MCPConnectionPingDetails *pingDetails) return; } - // Retrieve the tables and views for this database from SPTablesList (TODO: split out of MCPKit) + // Retrieve the tables and views for this database from SPTablesList NSMutableArray *tablesAndViews = [NSMutableArray array]; for (id aTable in [[[self delegate] valueForKeyPath:@"tablesListInstance"] allTableNames]) { NSDictionary *aTableDict = [NSDictionary dictionaryWithObjectsAndKeys: diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h new file mode 100644 index 00000000..3cbba325 --- /dev/null +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPConnectionDelegate.h @@ -0,0 +1,81 @@ +// +// $Id$ +// +// MCPConnectionDelegate.h +// MCPKit +// +// Created by Stuart Connolly (stuconnolly.com) on October 20, 2010. +// Copyright (c) 2010 Stuart Connolly. All rights reserved. +// +// Forked by the Sequel Pro team (sequelpro.com), April 2009 +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation; either version 2 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// More info at <http://mysql-cocoa.sourceforge.net/> +// More info at <http://code.google.com/p/sequel-pro/> + +@protocol MCPConnectionDelegate + +/** + * + * @param query + * @param connection + */ +- (void)willQueryString:(NSString *)query connection:(id)connection; + +/** + * + * @param error + * @param connection + */ +- (void)queryGaveError:(NSString *)error connection:(id)connection; + +/** + * + * + * @param error + * @param message + */ +- (void)showErrorWithTitle:(NSString *)error message:(NSString *)message; + +/** + * + * + * @param connection + */ +- (NSString *)keychainPasswordForConnection:(id)connection; + +/** + * + * + * @param connection + */ +- (NSString *)onReconnectShouldSelectDatabase:(id)connection; + +/** + * + * + * @param connection + */ +- (void)noConnectionAvailable:(id)connection; + +/** + * + * + * @param connection + */ +- (MCPConnectionCheck)connectionLost:(id)connection; + +@end diff --git a/Frameworks/MCPKit/MCPFoundationKit/MCPKit.h b/Frameworks/MCPKit/MCPFoundationKit/MCPKit.h index b83ebb69..57e6d62d 100644 --- a/Frameworks/MCPKit/MCPFoundationKit/MCPKit.h +++ b/Frameworks/MCPKit/MCPFoundationKit/MCPKit.h @@ -36,7 +36,9 @@ #import <MCPKit/MCPNumber.h> #import <MCPKit/MCPResultPlus.h> #import <MCPKit/MCPFastQueries.h> -#import <MCPKit/MCPConnectionProxy.h> #import <MCPKit/MCPGeometryData.h> +#import <MCPKit/MCPConnectionProxy.h> +#import <MCPKit/MCPConnectionDelegate.h> + #import "mysql.h" |