//// PGTSConnection.h// BaseTen//// Copyright (C) 2008 Marko Karppinen & Co. LLC.//// Before using this software, please review the available licensing options// by visiting http://www.karppinen.fi/baseten/licensing/ or by contacting// us at sales@karppinen.fi. Without an additional license, this software// may be distributed only in compliance with the GNU General Public License.////// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License, version 2.0,// as published by the Free Software Foundation.//// 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA//// $Id$//#import <CoreFoundation/CoreFoundation.h>#import <Foundation/Foundation.h>#import <SystemConfiguration/SCNetworkReachability.h>#import <BaseTen/BXOpenSSLCompatibility.h>#import <BaseTen/libpq-fe.h>#import <BaseTen/PGTSCertificateVerificationDelegate.h>@classPGTSConnection;@classPGTSResultSet;@classPGTSConnector;@classPGTSQueryDescription;@classPGTSMetadataContainer;@classPGTSDatabaseDescription;@classPGTSNotification;@classPGTSQuery;@protocolPGTSConnectorDelegate;@protocolPGTSConnectionDelegate<NSObject>-(void)PGTSConnectionFailed:(PGTSConnection*)connection;-(void)PGTSConnectionEstablished:(PGTSConnection*)connection;-(void)PGTSConnectionLost:(PGTSConnection*)connectionerror:(NSError*)error;-(void)PGTSConnection:(PGTSConnection*)connectiongotNotification:(PGTSNotification*)notification;-(void)PGTSConnection:(PGTSConnection*)connectionreceivedNotice:(NSError*)notice;-(FILE*)PGTSConnectionTraceFile:(PGTSConnection*)connection;-(void)PGTSConnection:(PGTSConnection*)connectionnetworkStatusChanged:(SCNetworkConnectionFlags)newFlags;//Optional section of the protocol either as an interface or @optional.#if __MAC_OS_X_VERSION_10_5 <= __MAC_OS_X_VERSION_MAX_ALLOWED@optional#else@end@interfaceNSObject(PGTSConnectionDelegate)#endif-(void)PGTSConnection:(PGTSConnection*)connectionsentQueryString:(constchar*)queryString;-(void)PGTSConnection:(PGTSConnection*)connectionsentQuery:(PGTSQuery*)query;-(void)PGTSConnection:(PGTSConnection*)connectionreceivedResultSet:(PGTSResultSet*)res;@endenumPGTSConnectionError{kPGTSConnectionErrorNone=0,kPGTSConnectionErrorUnknown,kPGTSConnectionErrorSSLUnavailable,kPGTSConnectionErrorPasswordRequired,kPGTSConnectionErrorInvalidPassword,kPGTSConnectionErrorSSLError,kPGTSConnectionErrorSSLCertificateVerificationFailed};@interfacePGTSConnection:NSObject{PGconn*mConnection;NSMutableArray*mQueue;idmConnector;PGTSMetadataContainer*mMetadataContainer;NSMutableDictionary*mPGTypes;id<PGTSCertificateVerificationDelegate>mCertificateVerificationDelegate;//WeakCFRunLoopRefmRunLoop;CFSocketRefmSocket;CFRunLoopSourceRefmSocketSource;SCNetworkReachabilityRefmReachability;id<PGTSConnectionDelegate>mDelegate;//WeakBOOLmDidDisconnectOnSleep;BOOLmProcessingNotifications;BOOLmLogsQueries;}-(id)init;-(void)dealloc;-(void)connectAsync:(NSDictionary*)connectionDictionary;-(BOOL)connectSync:(NSDictionary*)connectionDictionary;-(void)resetAsync;-(BOOL)resetSync;-(void)disconnect;-(id<PGTSConnectionDelegate>)delegate;-(void)setDelegate:(id<PGTSConnectionDelegate>)anObject;-(PGTSDatabaseDescription*)databaseDescription;-(void)reloadDatabaseDescription;-(id)deserializationDictionary;-(NSError*)connectionError;-(NSString*)errorString;-(ConnStatusType)connectionStatus;-(PGTransactionStatusType)transactionStatus;-(BOOL)usedPassword;-(PGconn*)pgConnection;-(int)backendPID;-(SSL*)SSLStruct;-(CFSocketRef)socket;-(BOOL)canSend;-(void)setCFRunLoop:(CFRunLoopRef)aRef;-(id<PGTSCertificateVerificationDelegate>)certificateVerificationDelegate;-(void)setCertificateVerificationDelegate:(id<PGTSCertificateVerificationDelegate>)anObject;-(BOOL)logsQueries;-(void)setLogsQueries:(BOOL)flag;-(void)logIfNeeded:(PGTSResultSet*)res;@end@interfacePGTSConnection(Queries)-(PGTSResultSet*)executeQuery:(NSString*)queryString;-(PGTSResultSet*)executeQuery:(NSString*)queryStringparameters:(id)p1,...;-(PGTSResultSet*)executeQuery:(NSString*)queryStringparameterArray:(NSArray*)parameters;-(int)sendQuery:(NSString*)queryStringdelegate:(id)delegatecallback:(SEL)callback;-(int)sendQuery:(NSString*)queryStringdelegate:(id)delegatecallback:(SEL)callbackparameters:(id)p1,...;-(int)sendQuery:(NSString*)queryStringdelegate:(id)delegatecallback:(SEL)callbackparameterArray:(NSArray*)parameters;-(int)sendQuery:(NSString*)queryStringdelegate:(id)delegatecallback:(SEL)callbackparameterArray:(NSArray*)parametersuserInfo:(id)userInfo;@end