os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServDatabaseMarshall.h
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#ifndef __LOGSERVDATABASEMARSHALL__
sl@0
    17
#define __LOGSERVDATABASEMARSHALL__
sl@0
    18
sl@0
    19
#include <d32dbms.h>
sl@0
    20
#include <logcli.h>
sl@0
    21
#include "LogServBackupObserver.h"
sl@0
    22
#include "LogServDatabaseTransactionInterface.h"
sl@0
    23
#include <centralrepository.h>
sl@0
    24
sl@0
    25
// Classes referenced
sl@0
    26
class MLogServBackupInterface;
sl@0
    27
class CLogServResourceInterpreter;
sl@0
    28
class CLogServSecurity;
sl@0
    29
sl@0
    30
/**
sl@0
    31
Implements MLogServBackupObserver and MLogServDatabaseTransactionInterface interfaces.
sl@0
    32
Owns and provides access to strings, config and types caches.  
sl@0
    33
sl@0
    34
@see CLogServCacheConfig
sl@0
    35
@see CLogServCacheStrings
sl@0
    36
@see CLogServCacheTypes
sl@0
    37
@see MLogServBackupObserver
sl@0
    38
@see MLogServDatabaseTransactionInterface
sl@0
    39
@internalComponent
sl@0
    40
*/
sl@0
    41
class CLogServDatabaseMarshall : public CBase, public MLogServBackupObserver, public MLogServDatabaseTransactionInterface
sl@0
    42
	{
sl@0
    43
public:
sl@0
    44
	static CLogServDatabaseMarshall* NewL(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
sl@0
    45
	~CLogServDatabaseMarshall();
sl@0
    46
    inline const TDesC& DatabaseName() const;
sl@0
    47
    inline void SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface);
sl@0
    48
sl@0
    49
private:
sl@0
    50
	CLogServDatabaseMarshall(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
sl@0
    51
	void ConstructL();
sl@0
    52
sl@0
    53
// From MLogServDatabaseTransactionInterface
sl@0
    54
	TInt DTIBegin();
sl@0
    55
	TInt DTICommitAndEnd();
sl@0
    56
	void DTIRollBack();
sl@0
    57
	TInt DTIExecuteSql(const TDesC& aStatement, TDbTextComparison aComparison = EDbCompareNormal);
sl@0
    58
	TBool DTIInTransaction() const;
sl@0
    59
	TBool DTIDatabaseIsDamaged() const;
sl@0
    60
	CLogServResourceInterpreter& DTIResourceInterface() const;
sl@0
    61
	MLogServDatabaseChangeInterface& DTIChangeInterface() const;
sl@0
    62
	CLogServCacheConfig& DTICacheConfig() const;
sl@0
    63
	CLogServCacheStrings& DTICacheStrings() const;
sl@0
    64
	CLogServCacheTypes& DTICacheTypes() const;
sl@0
    65
	RDbDatabase& DTIDatabase();
sl@0
    66
	TBool DTIIsAllowed(TEventOp aEventOp, const RMessage2& aMessage, TUid aEventType, const char* aDiagnostic = 0) const;
sl@0
    67
	const RArray<TUid>& DTIUidsOfStandardTypes();
sl@0
    68
sl@0
    69
// From MLogServBackupObserver
sl@0
    70
	void BOHandleEventL(TLogServBackupEvent aEvent);
sl@0
    71
sl@0
    72
// Internal methods
sl@0
    73
	void DatabaseLocateL();
sl@0
    74
	void DatabaseOpenL();
sl@0
    75
	void DatabaseCreateL(const TDesC& aFileName);
sl@0
    76
	//
sl@0
    77
	void CreateTablesL();
sl@0
    78
	void CreateTypesL(TBool aReadOnly = EFalse);
sl@0
    79
	void CreateIndiciesL();
sl@0
    80
	void CreateConfigurationL();
sl@0
    81
	//	
sl@0
    82
	void ReadRepositoryFileConfigurationL(TLogConfig& aConfig, CRepository& repository) const;
sl@0
    83
	void ReadResourceFileConfigurationL(TLogConfig& aConfig) const;
sl@0
    84
	//
sl@0
    85
	void MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn);
sl@0
    86
	//
sl@0
    87
	inline void RestoreStandardTypesL();
sl@0
    88
sl@0
    89
    TInt DoDbOpen();
sl@0
    90
    TBool DbTableCntCheckL();
sl@0
    91
    TInt AlterDbIfOldFmtL(); 
sl@0
    92
    TInt AlterEventTblIfOldFmt(CDbColSet& aEventTblColSet); 
sl@0
    93
#ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
sl@0
    94
    TInt AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet);
sl@0
    95
#endif    
sl@0
    96
    void DbDelete();
sl@0
    97
    TInt DbCreate();
sl@0
    98
    void CreateCachesL();
sl@0
    99
	
sl@0
   100
private:
sl@0
   101
	RFs& iFsSession;//File server interface handle
sl@0
   102
	CLogServResourceInterpreter& iResourceInterface;//Used to access resources
sl@0
   103
	MLogServDatabaseChangeInterface* iChangeInterface;//Used to access change interface
sl@0
   104
	HBufC* iDatabaseName;//So we know what to open after a backup
sl@0
   105
	MLogServBackupInterface& iBackupInterface;//Notifies us when a backup takes place
sl@0
   106
	RDbNamedDatabase iDatabase;//The actual log database
sl@0
   107
	CLogServCacheConfig* iCacheConfig;//Config table cache
sl@0
   108
	CLogServCacheStrings* iCacheStrings;//String table cache
sl@0
   109
	CLogServCacheTypes* iCacheTypes;//Type table cache
sl@0
   110
 	CLogEventType* iEventType;//Used to get event type TUid from the cache before calling the security manager
sl@0
   111
 	CLogServSecurity* iSecurity;//Platform security implementation
sl@0
   112
 	RArray<TUid> iStandardTypeUids;//Needed here for use by views during backups. When a backup is in progress, access to CacheTypes isn't allowed.
sl@0
   113
sl@0
   114
	};
sl@0
   115
sl@0
   116
inline const TDesC& CLogServDatabaseMarshall::DatabaseName() const
sl@0
   117
	{
sl@0
   118
	return *iDatabaseName;
sl@0
   119
	}
sl@0
   120
sl@0
   121
inline void CLogServDatabaseMarshall::SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface)
sl@0
   122
	{
sl@0
   123
	// Bit ugly, but anyway...
sl@0
   124
	iChangeInterface = &aChangeInterface;
sl@0
   125
	}
sl@0
   126
	
sl@0
   127
inline void CLogServDatabaseMarshall::RestoreStandardTypesL()
sl@0
   128
	{
sl@0
   129
	// Force LogServCacheTypes to read the TUids of all built-in types.
sl@0
   130
	// The ETrue argument will stop LogServCacheTypes from writing the results
sl@0
   131
	// into the database - i.e. a read-only operation on the cache types.
sl@0
   132
	CreateTypesL(ETrue);
sl@0
   133
	}
sl@0
   134
sl@0
   135
#endif