os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServDatabaseMarshall.h
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServDatabaseMarshall.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,135 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __LOGSERVDATABASEMARSHALL__
1.20 +#define __LOGSERVDATABASEMARSHALL__
1.21 +
1.22 +#include <d32dbms.h>
1.23 +#include <logcli.h>
1.24 +#include "LogServBackupObserver.h"
1.25 +#include "LogServDatabaseTransactionInterface.h"
1.26 +#include <centralrepository.h>
1.27 +
1.28 +// Classes referenced
1.29 +class MLogServBackupInterface;
1.30 +class CLogServResourceInterpreter;
1.31 +class CLogServSecurity;
1.32 +
1.33 +/**
1.34 +Implements MLogServBackupObserver and MLogServDatabaseTransactionInterface interfaces.
1.35 +Owns and provides access to strings, config and types caches.
1.36 +
1.37 +@see CLogServCacheConfig
1.38 +@see CLogServCacheStrings
1.39 +@see CLogServCacheTypes
1.40 +@see MLogServBackupObserver
1.41 +@see MLogServDatabaseTransactionInterface
1.42 +@internalComponent
1.43 +*/
1.44 +class CLogServDatabaseMarshall : public CBase, public MLogServBackupObserver, public MLogServDatabaseTransactionInterface
1.45 + {
1.46 +public:
1.47 + static CLogServDatabaseMarshall* NewL(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
1.48 + ~CLogServDatabaseMarshall();
1.49 + inline const TDesC& DatabaseName() const;
1.50 + inline void SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface);
1.51 +
1.52 +private:
1.53 + CLogServDatabaseMarshall(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
1.54 + void ConstructL();
1.55 +
1.56 +// From MLogServDatabaseTransactionInterface
1.57 + TInt DTIBegin();
1.58 + TInt DTICommitAndEnd();
1.59 + void DTIRollBack();
1.60 + TInt DTIExecuteSql(const TDesC& aStatement, TDbTextComparison aComparison = EDbCompareNormal);
1.61 + TBool DTIInTransaction() const;
1.62 + TBool DTIDatabaseIsDamaged() const;
1.63 + CLogServResourceInterpreter& DTIResourceInterface() const;
1.64 + MLogServDatabaseChangeInterface& DTIChangeInterface() const;
1.65 + CLogServCacheConfig& DTICacheConfig() const;
1.66 + CLogServCacheStrings& DTICacheStrings() const;
1.67 + CLogServCacheTypes& DTICacheTypes() const;
1.68 + RDbDatabase& DTIDatabase();
1.69 + TBool DTIIsAllowed(TEventOp aEventOp, const RMessage2& aMessage, TUid aEventType, const char* aDiagnostic = 0) const;
1.70 + const RArray<TUid>& DTIUidsOfStandardTypes();
1.71 +
1.72 +// From MLogServBackupObserver
1.73 + void BOHandleEventL(TLogServBackupEvent aEvent);
1.74 +
1.75 +// Internal methods
1.76 + void DatabaseLocateL();
1.77 + void DatabaseOpenL();
1.78 + void DatabaseCreateL(const TDesC& aFileName);
1.79 + //
1.80 + void CreateTablesL();
1.81 + void CreateTypesL(TBool aReadOnly = EFalse);
1.82 + void CreateIndiciesL();
1.83 + void CreateConfigurationL();
1.84 + //
1.85 + void ReadRepositoryFileConfigurationL(TLogConfig& aConfig, CRepository& repository) const;
1.86 + void ReadResourceFileConfigurationL(TLogConfig& aConfig) const;
1.87 + //
1.88 + void MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn);
1.89 + //
1.90 + inline void RestoreStandardTypesL();
1.91 +
1.92 + TInt DoDbOpen();
1.93 + TBool DbTableCntCheckL();
1.94 + TInt AlterDbIfOldFmtL();
1.95 + TInt AlterEventTblIfOldFmt(CDbColSet& aEventTblColSet);
1.96 +#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
1.97 + TInt AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet);
1.98 +#endif
1.99 + void DbDelete();
1.100 + TInt DbCreate();
1.101 + void CreateCachesL();
1.102 +
1.103 +private:
1.104 + RFs& iFsSession;//File server interface handle
1.105 + CLogServResourceInterpreter& iResourceInterface;//Used to access resources
1.106 + MLogServDatabaseChangeInterface* iChangeInterface;//Used to access change interface
1.107 + HBufC* iDatabaseName;//So we know what to open after a backup
1.108 + MLogServBackupInterface& iBackupInterface;//Notifies us when a backup takes place
1.109 + RDbNamedDatabase iDatabase;//The actual log database
1.110 + CLogServCacheConfig* iCacheConfig;//Config table cache
1.111 + CLogServCacheStrings* iCacheStrings;//String table cache
1.112 + CLogServCacheTypes* iCacheTypes;//Type table cache
1.113 + CLogEventType* iEventType;//Used to get event type TUid from the cache before calling the security manager
1.114 + CLogServSecurity* iSecurity;//Platform security implementation
1.115 + RArray<TUid> iStandardTypeUids;//Needed here for use by views during backups. When a backup is in progress, access to CacheTypes isn't allowed.
1.116 +
1.117 + };
1.118 +
1.119 +inline const TDesC& CLogServDatabaseMarshall::DatabaseName() const
1.120 + {
1.121 + return *iDatabaseName;
1.122 + }
1.123 +
1.124 +inline void CLogServDatabaseMarshall::SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface)
1.125 + {
1.126 + // Bit ugly, but anyway...
1.127 + iChangeInterface = &aChangeInterface;
1.128 + }
1.129 +
1.130 +inline void CLogServDatabaseMarshall::RestoreStandardTypesL()
1.131 + {
1.132 + // Force LogServCacheTypes to read the TUids of all built-in types.
1.133 + // The ETrue argument will stop LogServCacheTypes from writing the results
1.134 + // into the database - i.e. a read-only operation on the cache types.
1.135 + CreateTypesL(ETrue);
1.136 + }
1.137 +
1.138 +#endif