sl@0: // Copyright (c) 2002-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 __LOGSERVDATABASEMARSHALL__ sl@0: #define __LOGSERVDATABASEMARSHALL__ sl@0: sl@0: #include sl@0: #include sl@0: #include "LogServBackupObserver.h" sl@0: #include "LogServDatabaseTransactionInterface.h" sl@0: #include sl@0: sl@0: // Classes referenced sl@0: class MLogServBackupInterface; sl@0: class CLogServResourceInterpreter; sl@0: class CLogServSecurity; sl@0: sl@0: /** sl@0: Implements MLogServBackupObserver and MLogServDatabaseTransactionInterface interfaces. sl@0: Owns and provides access to strings, config and types caches. sl@0: sl@0: @see CLogServCacheConfig sl@0: @see CLogServCacheStrings sl@0: @see CLogServCacheTypes sl@0: @see MLogServBackupObserver sl@0: @see MLogServDatabaseTransactionInterface sl@0: @internalComponent sl@0: */ sl@0: class CLogServDatabaseMarshall : public CBase, public MLogServBackupObserver, public MLogServDatabaseTransactionInterface sl@0: { sl@0: public: sl@0: static CLogServDatabaseMarshall* NewL(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface); sl@0: ~CLogServDatabaseMarshall(); sl@0: inline const TDesC& DatabaseName() const; sl@0: inline void SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface); sl@0: sl@0: private: sl@0: CLogServDatabaseMarshall(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface); sl@0: void ConstructL(); sl@0: sl@0: // From MLogServDatabaseTransactionInterface sl@0: TInt DTIBegin(); sl@0: TInt DTICommitAndEnd(); sl@0: void DTIRollBack(); sl@0: TInt DTIExecuteSql(const TDesC& aStatement, TDbTextComparison aComparison = EDbCompareNormal); sl@0: TBool DTIInTransaction() const; sl@0: TBool DTIDatabaseIsDamaged() const; sl@0: CLogServResourceInterpreter& DTIResourceInterface() const; sl@0: MLogServDatabaseChangeInterface& DTIChangeInterface() const; sl@0: CLogServCacheConfig& DTICacheConfig() const; sl@0: CLogServCacheStrings& DTICacheStrings() const; sl@0: CLogServCacheTypes& DTICacheTypes() const; sl@0: RDbDatabase& DTIDatabase(); sl@0: TBool DTIIsAllowed(TEventOp aEventOp, const RMessage2& aMessage, TUid aEventType, const char* aDiagnostic = 0) const; sl@0: const RArray& DTIUidsOfStandardTypes(); sl@0: sl@0: // From MLogServBackupObserver sl@0: void BOHandleEventL(TLogServBackupEvent aEvent); sl@0: sl@0: // Internal methods sl@0: void DatabaseLocateL(); sl@0: void DatabaseOpenL(); sl@0: void DatabaseCreateL(const TDesC& aFileName); sl@0: // sl@0: void CreateTablesL(); sl@0: void CreateTypesL(TBool aReadOnly = EFalse); sl@0: void CreateIndiciesL(); sl@0: void CreateConfigurationL(); sl@0: // sl@0: void ReadRepositoryFileConfigurationL(TLogConfig& aConfig, CRepository& repository) const; sl@0: void ReadResourceFileConfigurationL(TLogConfig& aConfig) const; sl@0: // sl@0: void MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn); sl@0: // sl@0: inline void RestoreStandardTypesL(); sl@0: sl@0: TInt DoDbOpen(); sl@0: TBool DbTableCntCheckL(); sl@0: TInt AlterDbIfOldFmtL(); sl@0: TInt AlterEventTblIfOldFmt(CDbColSet& aEventTblColSet); sl@0: #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM sl@0: TInt AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet); sl@0: #endif sl@0: void DbDelete(); sl@0: TInt DbCreate(); sl@0: void CreateCachesL(); sl@0: sl@0: private: sl@0: RFs& iFsSession;//File server interface handle sl@0: CLogServResourceInterpreter& iResourceInterface;//Used to access resources sl@0: MLogServDatabaseChangeInterface* iChangeInterface;//Used to access change interface sl@0: HBufC* iDatabaseName;//So we know what to open after a backup sl@0: MLogServBackupInterface& iBackupInterface;//Notifies us when a backup takes place sl@0: RDbNamedDatabase iDatabase;//The actual log database sl@0: CLogServCacheConfig* iCacheConfig;//Config table cache sl@0: CLogServCacheStrings* iCacheStrings;//String table cache sl@0: CLogServCacheTypes* iCacheTypes;//Type table cache sl@0: CLogEventType* iEventType;//Used to get event type TUid from the cache before calling the security manager sl@0: CLogServSecurity* iSecurity;//Platform security implementation sl@0: RArray iStandardTypeUids;//Needed here for use by views during backups. When a backup is in progress, access to CacheTypes isn't allowed. sl@0: sl@0: }; sl@0: sl@0: inline const TDesC& CLogServDatabaseMarshall::DatabaseName() const sl@0: { sl@0: return *iDatabaseName; sl@0: } sl@0: sl@0: inline void CLogServDatabaseMarshall::SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface) sl@0: { sl@0: // Bit ugly, but anyway... sl@0: iChangeInterface = &aChangeInterface; sl@0: } sl@0: sl@0: inline void CLogServDatabaseMarshall::RestoreStandardTypesL() sl@0: { sl@0: // Force LogServCacheTypes to read the TUids of all built-in types. sl@0: // The ETrue argument will stop LogServCacheTypes from writing the results sl@0: // into the database - i.e. a read-only operation on the cache types. sl@0: CreateTypesL(ETrue); sl@0: } sl@0: sl@0: #endif