os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServDatabaseMarshall.h
First public contribution.
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __LOGSERVDATABASEMARSHALL__
17 #define __LOGSERVDATABASEMARSHALL__
21 #include "LogServBackupObserver.h"
22 #include "LogServDatabaseTransactionInterface.h"
23 #include <centralrepository.h>
26 class MLogServBackupInterface;
27 class CLogServResourceInterpreter;
28 class CLogServSecurity;
31 Implements MLogServBackupObserver and MLogServDatabaseTransactionInterface interfaces.
32 Owns and provides access to strings, config and types caches.
34 @see CLogServCacheConfig
35 @see CLogServCacheStrings
36 @see CLogServCacheTypes
37 @see MLogServBackupObserver
38 @see MLogServDatabaseTransactionInterface
41 class CLogServDatabaseMarshall : public CBase, public MLogServBackupObserver, public MLogServDatabaseTransactionInterface
44 static CLogServDatabaseMarshall* NewL(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
45 ~CLogServDatabaseMarshall();
46 inline const TDesC& DatabaseName() const;
47 inline void SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface);
50 CLogServDatabaseMarshall(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
53 // From MLogServDatabaseTransactionInterface
55 TInt DTICommitAndEnd();
57 TInt DTIExecuteSql(const TDesC& aStatement, TDbTextComparison aComparison = EDbCompareNormal);
58 TBool DTIInTransaction() const;
59 TBool DTIDatabaseIsDamaged() const;
60 CLogServResourceInterpreter& DTIResourceInterface() const;
61 MLogServDatabaseChangeInterface& DTIChangeInterface() const;
62 CLogServCacheConfig& DTICacheConfig() const;
63 CLogServCacheStrings& DTICacheStrings() const;
64 CLogServCacheTypes& DTICacheTypes() const;
65 RDbDatabase& DTIDatabase();
66 TBool DTIIsAllowed(TEventOp aEventOp, const RMessage2& aMessage, TUid aEventType, const char* aDiagnostic = 0) const;
67 const RArray<TUid>& DTIUidsOfStandardTypes();
69 // From MLogServBackupObserver
70 void BOHandleEventL(TLogServBackupEvent aEvent);
73 void DatabaseLocateL();
75 void DatabaseCreateL(const TDesC& aFileName);
78 void CreateTypesL(TBool aReadOnly = EFalse);
79 void CreateIndiciesL();
80 void CreateConfigurationL();
82 void ReadRepositoryFileConfigurationL(TLogConfig& aConfig, CRepository& repository) const;
83 void ReadResourceFileConfigurationL(TLogConfig& aConfig) const;
85 void MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn);
87 inline void RestoreStandardTypesL();
90 TBool DbTableCntCheckL();
91 TInt AlterDbIfOldFmtL();
92 TInt AlterEventTblIfOldFmt(CDbColSet& aEventTblColSet);
93 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM
94 TInt AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet);
101 RFs& iFsSession;//File server interface handle
102 CLogServResourceInterpreter& iResourceInterface;//Used to access resources
103 MLogServDatabaseChangeInterface* iChangeInterface;//Used to access change interface
104 HBufC* iDatabaseName;//So we know what to open after a backup
105 MLogServBackupInterface& iBackupInterface;//Notifies us when a backup takes place
106 RDbNamedDatabase iDatabase;//The actual log database
107 CLogServCacheConfig* iCacheConfig;//Config table cache
108 CLogServCacheStrings* iCacheStrings;//String table cache
109 CLogServCacheTypes* iCacheTypes;//Type table cache
110 CLogEventType* iEventType;//Used to get event type TUid from the cache before calling the security manager
111 CLogServSecurity* iSecurity;//Platform security implementation
112 RArray<TUid> iStandardTypeUids;//Needed here for use by views during backups. When a backup is in progress, access to CacheTypes isn't allowed.
116 inline const TDesC& CLogServDatabaseMarshall::DatabaseName() const
118 return *iDatabaseName;
121 inline void CLogServDatabaseMarshall::SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface)
123 // Bit ugly, but anyway...
124 iChangeInterface = &aChangeInterface;
127 inline void CLogServDatabaseMarshall::RestoreStandardTypesL()
129 // Force LogServCacheTypes to read the TUids of all built-in types.
130 // The ETrue argument will stop LogServCacheTypes from writing the results
131 // into the database - i.e. a read-only operation on the cache types.