os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServDatabaseMarshall.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #ifndef __LOGSERVDATABASEMARSHALL__
    17 #define __LOGSERVDATABASEMARSHALL__
    18 
    19 #include <d32dbms.h>
    20 #include <logcli.h>
    21 #include "LogServBackupObserver.h"
    22 #include "LogServDatabaseTransactionInterface.h"
    23 #include <centralrepository.h>
    24 
    25 // Classes referenced
    26 class MLogServBackupInterface;
    27 class CLogServResourceInterpreter;
    28 class CLogServSecurity;
    29 
    30 /**
    31 Implements MLogServBackupObserver and MLogServDatabaseTransactionInterface interfaces.
    32 Owns and provides access to strings, config and types caches.  
    33 
    34 @see CLogServCacheConfig
    35 @see CLogServCacheStrings
    36 @see CLogServCacheTypes
    37 @see MLogServBackupObserver
    38 @see MLogServDatabaseTransactionInterface
    39 @internalComponent
    40 */
    41 class CLogServDatabaseMarshall : public CBase, public MLogServBackupObserver, public MLogServDatabaseTransactionInterface
    42 	{
    43 public:
    44 	static CLogServDatabaseMarshall* NewL(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
    45 	~CLogServDatabaseMarshall();
    46     inline const TDesC& DatabaseName() const;
    47     inline void SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface);
    48 
    49 private:
    50 	CLogServDatabaseMarshall(RFs& aFsSession, CLogServResourceInterpreter& aResourceInterface, MLogServBackupInterface& aBackupInterface);
    51 	void ConstructL();
    52 
    53 // From MLogServDatabaseTransactionInterface
    54 	TInt DTIBegin();
    55 	TInt DTICommitAndEnd();
    56 	void DTIRollBack();
    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();
    68 
    69 // From MLogServBackupObserver
    70 	void BOHandleEventL(TLogServBackupEvent aEvent);
    71 
    72 // Internal methods
    73 	void DatabaseLocateL();
    74 	void DatabaseOpenL();
    75 	void DatabaseCreateL(const TDesC& aFileName);
    76 	//
    77 	void CreateTablesL();
    78 	void CreateTypesL(TBool aReadOnly = EFalse);
    79 	void CreateIndiciesL();
    80 	void CreateConfigurationL();
    81 	//	
    82 	void ReadRepositoryFileConfigurationL(TLogConfig& aConfig, CRepository& repository) const;
    83 	void ReadResourceFileConfigurationL(TLogConfig& aConfig) const;
    84 	//
    85 	void MakeColumnAutoIncremetingL(const TDesC& aTable, const TDesC& aColumn);
    86 	//
    87 	inline void RestoreStandardTypesL();
    88 
    89     TInt DoDbOpen();
    90     TBool DbTableCntCheckL();
    91     TInt AlterDbIfOldFmtL(); 
    92     TInt AlterEventTblIfOldFmt(CDbColSet& aEventTblColSet); 
    93 #ifdef SYMBIAN_ENABLE_EVENTLOGGER_DUALSIM	
    94     TInt AlterEventTblIfNoSimIdL(CDbColSet& aEventTblColSet);
    95 #endif    
    96     void DbDelete();
    97     TInt DbCreate();
    98     void CreateCachesL();
    99 	
   100 private:
   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.
   113 
   114 	};
   115 
   116 inline const TDesC& CLogServDatabaseMarshall::DatabaseName() const
   117 	{
   118 	return *iDatabaseName;
   119 	}
   120 
   121 inline void CLogServDatabaseMarshall::SetChangeInterface(MLogServDatabaseChangeInterface& aChangeInterface)
   122 	{
   123 	// Bit ugly, but anyway...
   124 	iChangeInterface = &aChangeInterface;
   125 	}
   126 	
   127 inline void CLogServDatabaseMarshall::RestoreStandardTypesL()
   128 	{
   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.
   132 	CreateTypesL(ETrue);
   133 	}
   134 
   135 #endif