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 __LOGSERVVIEW_H__ sl@0: #define __LOGSERVVIEW_H__ sl@0: sl@0: #include sl@0: #include "LOGQUERY.H" sl@0: #include "LogCliServShared.h" sl@0: #include "LogServBackupObserver.h" sl@0: #include "LogServDatabaseChangeObserver.h" sl@0: #include "LogServDatabaseTransactionInterface.h" sl@0: sl@0: // Classes referenced sl@0: class CLogPackage; sl@0: class CLogServViewLockObserver; sl@0: class CLogServViewChangeManager; sl@0: class MLogServDatabaseTransactionInterface; sl@0: class MLogServBackupInterface; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// CLogServViewBase ///////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Base class for the view that the LogEng server can create. sl@0: Implements MLogServBackupObserver and MLogServDatabaseChangeObserver interfaces. sl@0: sl@0: @see MLogServBackupObserver sl@0: @see MLogServDatabaseChangeObserver sl@0: @internalComponent sl@0: */ sl@0: class CLogServViewBase : public CBase, public MLogServBackupObserver, public MLogServDatabaseChangeObserver sl@0: { sl@0: public: sl@0: ~CLogServViewBase(); sl@0: void RequestChangeNotifications(const RMessage2& aMessage); sl@0: void RequestChangeNotificationsCancel(); sl@0: void RequestLockStatusChanges(const RMessage2& aMessage); sl@0: void RequestLockStatusChangesCancel(); sl@0: void RequestChangesL(const RMessage2& aMessage); sl@0: void SetupL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); sl@0: virtual TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType)=0; sl@0: virtual void RemoveL(const RMessage2& aMessage); sl@0: virtual void ClearDuplicatesL(const RMessage2& aMessage); sl@0: virtual void SetFlagsL(const RMessage2& aMessage); sl@0: inline TLogViewId ViewId() const; sl@0: TInt Count() const; sl@0: TLogId At(TInt aIndex) const; sl@0: inline TBool ViewIsReady() const; sl@0: sl@0: protected: sl@0: CLogServViewBase(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewType aType, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: sl@0: void ConstructL(); sl@0: static void DestroyList(TAny *aPtr); sl@0: sl@0: private: // FROM MLogServDatabaseChangeObserver sl@0: void DCOHandleChangeEventsL(const CLogChangeDefinition& aChanges); sl@0: // FROM MLogServBackupObserver sl@0: void BOHandleEventL(TLogServBackupEvent aEvent); sl@0: sl@0: void InitializeColumnsL(RDbRowSet& aRowSet); sl@0: inline TInt ClientSideCursorPosition() const; sl@0: // sl@0: void ResetViewContentsL(RDbRowSet& aRowSet); sl@0: void PrepareViewContentsL(const TDesC& aSQL); sl@0: TInt RebuildViewContentsIfNecessary(); sl@0: void DoHandleChangeEventsL(const CLogChangeDefinition& aChanges); sl@0: void RebuildViewL(); sl@0: TBool IsAllowed(TEventOp aEventOp, TUint8 aEventTypeIndex); sl@0: sl@0: protected: sl@0: MLogServDatabaseTransactionInterface& iDatabase; sl@0: CLogPackage& iPackage; sl@0: sl@0: private: sl@0: MLogServBackupInterface& iBackupInterface; sl@0: TLogViewType iType;//The type of view that this object represents sl@0: TLogViewId iViewId;//The id of this view sl@0: RArray iViewContents;//An array which contains the log ids of all the items in this view sl@0: TBool iViewContentsReady; sl@0: HBufC* iSql;//The SQL filter/condition which is used to build this view sl@0: TBool iRebuildViewContents;//A flag to indicate that we need to rebuild the view because handling a change notification failed (e.g due to OOM). sl@0: CLogServViewLockObserver* iLockChangeObserver;//Manages lock change events sl@0: CLogServViewChangeManager* iChangeManager;//Manages change events for this view sl@0: const RMessage2& iMessage;//Passed in the constructor by the LogServOperationFactory - used to check security sl@0: /** sl@0: Data structure for storage of cached security information sl@0: @internalComponent sl@0: */ sl@0: struct SStandardTypeSecurity sl@0: { sl@0: TUid eventType; sl@0: TBool readAccess; sl@0: TBool writeAccess; sl@0: }; sl@0: RArray iStandardTypeSecurityCache; sl@0: static TDbColNo iIdColNo; sl@0: static TDbColNo iTypeColNo; sl@0: static TDbColNo iFlagColNo[KLogFlagsCount]; sl@0: sl@0: }; sl@0: sl@0: /** sl@0: Returns the id of this view sl@0: */ sl@0: inline TLogViewId CLogServViewBase::ViewId() const sl@0: { sl@0: return iViewId; sl@0: } sl@0: sl@0: /** sl@0: Is the view ready? sl@0: */ sl@0: inline TBool CLogServViewBase::ViewIsReady() const sl@0: { sl@0: return (iViewContentsReady && iSql); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// CLogServViewLockObserver //////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: Implements MLogServBackupObserver interface. sl@0: An instance of this class is data member of CLogServViewBase. sl@0: It is used every time when the client side requests notification regarding the view status. sl@0: The view status changes to "locked" during the backup/restore operations. sl@0: sl@0: @see CLogServViewBase sl@0: @see MLogServBackupObserver sl@0: @internalComponent sl@0: */ sl@0: class CLogServViewLockObserver : public CBase, public MLogServBackupObserver sl@0: { sl@0: public: sl@0: static CLogServViewLockObserver* NewL(MLogServBackupInterface& aBackupInterface); sl@0: ~CLogServViewLockObserver(); sl@0: void RequestLockStatusChanges(const RMessage2& aMessage); sl@0: void RequestLockStatusChangesCancel(); sl@0: sl@0: private: sl@0: CLogServViewLockObserver(MLogServBackupInterface& aBackupInterface); sl@0: void ConstructL(); sl@0: // FROM MLogServBackupObserver sl@0: void BOHandleEventL(TLogServBackupEvent aEvent); sl@0: sl@0: inline TBool HaveLockStatusChangePointer() const; sl@0: void CompleteLockStatusChangeMessage(TInt aCompletionCode); sl@0: sl@0: private: sl@0: MLogServBackupInterface& iBackupInterface; sl@0: RArray iLockEvents;//Holds state changes when the client isn't able to receive them immediately. sl@0: RMessagePtr2 iLockStatusChangeMessage;//Completed when the view is locked/unlocked sl@0: sl@0: }; sl@0: sl@0: inline TBool CLogServViewLockObserver::HaveLockStatusChangePointer() const sl@0: { sl@0: return (iLockStatusChangeMessage != RMessagePtr2()); sl@0: } sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// CLogServViewEvent /////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: CLogServViewBase derived class. sl@0: sl@0: @see CLogServViewBase sl@0: @internalComponent sl@0: */ sl@0: class CLogServViewEvent : public CLogServViewBase sl@0: { sl@0: public: sl@0: static CLogServViewEvent* NewL(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: sl@0: TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); sl@0: // sl@0: private: sl@0: CLogServViewEvent(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: }; sl@0: sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// CLogServViewRecent ////////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: CLogServViewBase derived class. sl@0: sl@0: @see CLogServViewBase sl@0: @internalComponent sl@0: */ sl@0: class CLogServViewRecent : public CLogServViewBase sl@0: { sl@0: public: sl@0: static CLogServViewRecent* NewL(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: sl@0: TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); sl@0: void RemoveL(const RMessage2& aMessage); sl@0: void ClearDuplicatesL(const RMessage2& aMessage); sl@0: // sl@0: sl@0: // sl@0: private: sl@0: CLogServViewRecent(MLogServDatabaseTransactionInterface& aDatabase, MLogServBackupInterface& aBackupInterface, CLogPackage& aPackage, TLogViewId aViewId, const RMessage2& aMessage); sl@0: void InitializeColumns2L(RDbRowSet& aRowSet); sl@0: // sl@0: private: sl@0: TLogRecentList iRecentList; sl@0: sl@0: static TDbColNo iIdColNo; sl@0: static TDbColNo iRecentColNo; sl@0: static TDbColNo iDuplicateColNo; sl@0: sl@0: }; sl@0: sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: ////////////////////// CLogServViewDuplicate /////////////////////////////////////////////////////// sl@0: /////////////////////////////////////////////////////////////////////////////////////////////////////// sl@0: sl@0: /** sl@0: CLogServViewBase derived class. sl@0: sl@0: @see CLogServViewBase sl@0: @internalComponent sl@0: */ sl@0: class CLogServViewDuplicate : public CLogServViewBase sl@0: { sl@0: public: sl@0: static CLogServViewDuplicate* NewL(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: sl@0: TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType); sl@0: void RemoveL(const RMessage2& aMessage); sl@0: // sl@0: private: sl@0: CLogServViewDuplicate(MLogServDatabaseTransactionInterface& aDatabase, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: CLogPackage& aPackage, sl@0: TLogViewId aViewId, sl@0: const RMessage2& aMessage); sl@0: // sl@0: private: sl@0: TLogId iSourceId; sl@0: }; sl@0: sl@0: #endif