sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // sl@0: sl@0: #ifndef __SQLDBSESSION_H__ sl@0: #define __SQLDBSESSION_H__ sl@0: sl@0: #include //RSqlDatabase::TIsolationLevel sl@0: #include "SqlUtil.h" //TSqlSrvFunction sl@0: sl@0: //Forward declarations sl@0: struct sqlite3; sl@0: class RSqlStatementSession; sl@0: class TSqlResourceTestData; sl@0: class CSqlSecurityPolicy; sl@0: class RSqlBufFlat; sl@0: class TSqlFhCmdFunctor; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// RSqlDbSession ///////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: RSqlDbSession class is used for establishing a connection with the database server. sl@0: It can be used also for: sl@0: - executing SQL statements or a set of SQL statements, separated with ";"; sl@0: - attaching/detaching databases; sl@0: - copying databases; sl@0: - deleting databases; sl@0: - retrieving last error messages; sl@0: sl@0: @internalComponent sl@0: */ sl@0: NONSHARABLE_CLASS(RSqlDbSession) : public RSessionBase sl@0: { sl@0: //RSqlDbSession class hides all details about the communication with the database server. sl@0: //No database specific header files should be seen or used outside the session class. sl@0: sl@0: friend class RSqlStatementSession; sl@0: friend class TSqlResourceTestData; sl@0: sl@0: public: sl@0: inline RSqlDbSession(); sl@0: TInt Connect(TSqlSrvFunction aFunction, const TDesC& aDbFileName, const TDesC8& aSecurityPolicyData, const TDesC8* aConfig); sl@0: TInt Attach(const TDesC& aDbFileName, const TDesC& aDbName); sl@0: inline TInt Detach(const TDesC& aDbName); sl@0: static TInt CopyDatabase(const TDesC& aSrcDbFileName, const TDesC& aDestDbFileName); sl@0: static TInt DeleteDatabase(const TDesC& aDbFileName); sl@0: TPtrC LastErrorMessage(); sl@0: TInt64 LastInsertedRowId(); sl@0: inline TInt Exec(const TDesC& aSqlStmt); sl@0: inline TInt Exec(const TDesC8& aSqlStmt); sl@0: inline void Exec(const TDesC& aSqlStmt, TRequestStatus& aStatus); sl@0: inline void Exec(const TDesC8& aSqlStmt, TRequestStatus& aStatus); sl@0: inline TInt SetIsolationLevel(RSqlDatabase::TIsolationLevel aIsolationLevel); sl@0: TInt GetSecurityPolicy(RSqlBufFlat& aSecurityPolicyBuf); sl@0: inline TInt ExecScalarFullSelect(const TDesC& aSqlStmt, TSqlColumnType aType, TDes8& aRes); sl@0: inline TInt ExecScalarFullSelect(const TDesC8& aSqlStmt, TSqlColumnType aType, TDes8& aRes); sl@0: void Close(); sl@0: sl@0: inline TInt SendReceive(TInt aFunction); sl@0: inline void SendReceive(TInt aFunction, TRequestStatus& aStatus); sl@0: inline TInt SendReceive(TInt aFunction,const TIpcArgs& aArgs); sl@0: inline void SendReceive(TInt aFunction,const TIpcArgs& aArgs, TRequestStatus& aStatus); sl@0: sl@0: private: sl@0: enum TDbfAction {EDbfCreate, EDbfOpen}; sl@0: TInt DoCreateSession(); sl@0: TInt InitResourceTestData(); sl@0: TInt CreateAndSendFileHandle(TSqlFhCmdFunctor& aFhCmdSender, TDbfAction aDbfAction); sl@0: TInt DoConnect(TSqlSrvFunction aFunction, const TDesC& aDbFileName, const TDesC8& aSecurityPolicyData, const TDesC8* aConfig); sl@0: sl@0: private: sl@0: HBufC* iLastErrorMessage; sl@0: sl@0: }; sl@0: sl@0: #include "SqlDbSession.inl" sl@0: sl@0: #endif //__SQLDBSESSION_H__