os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServView.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/persistentdata/loggingservices/eventlogger/LogServ/inc/LogServView.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,282 @@
     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 __LOGSERVVIEW_H__
    1.20 +#define __LOGSERVVIEW_H__
    1.21 +
    1.22 +#include <logcli.h>
    1.23 +#include "LOGQUERY.H"
    1.24 +#include "LogCliServShared.h"
    1.25 +#include "LogServBackupObserver.h"
    1.26 +#include "LogServDatabaseChangeObserver.h"
    1.27 +#include "LogServDatabaseTransactionInterface.h"
    1.28 +
    1.29 +// Classes referenced
    1.30 +class CLogPackage;
    1.31 +class CLogServViewLockObserver;
    1.32 +class CLogServViewChangeManager;
    1.33 +class MLogServDatabaseTransactionInterface;
    1.34 +class MLogServBackupInterface;
    1.35 +
    1.36 +///////////////////////////////////////////////////////////////////////////////////////////////////////
    1.37 +//////////////////////   CLogServViewBase /////////////////////////////////////////////////////////////
    1.38 +///////////////////////////////////////////////////////////////////////////////////////////////////////
    1.39 +
    1.40 +/**
    1.41 +Base class for the view that the LogEng server can create.
    1.42 +Implements MLogServBackupObserver and MLogServDatabaseChangeObserver interfaces. 
    1.43 +
    1.44 +@see MLogServBackupObserver 
    1.45 +@see MLogServDatabaseChangeObserver 
    1.46 +@internalComponent
    1.47 +*/
    1.48 +class CLogServViewBase : public CBase, public MLogServBackupObserver, public MLogServDatabaseChangeObserver
    1.49 +	{
    1.50 +public:
    1.51 +	~CLogServViewBase();
    1.52 +    void RequestChangeNotifications(const RMessage2& aMessage);
    1.53 +    void RequestChangeNotificationsCancel();
    1.54 +    void RequestLockStatusChanges(const RMessage2& aMessage);
    1.55 +    void RequestLockStatusChangesCancel();
    1.56 +    void RequestChangesL(const RMessage2& aMessage);
    1.57 +    void SetupL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType);
    1.58 +    virtual TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType)=0;
    1.59 +    virtual void RemoveL(const RMessage2& aMessage);
    1.60 +    virtual void ClearDuplicatesL(const RMessage2& aMessage);
    1.61 +    virtual void SetFlagsL(const RMessage2& aMessage);
    1.62 +    inline TLogViewId ViewId() const;
    1.63 +    TInt Count() const;
    1.64 +    TLogId At(TInt aIndex) const;
    1.65 +    inline TBool ViewIsReady() const;
    1.66 +
    1.67 +protected:
    1.68 +	CLogServViewBase(MLogServDatabaseTransactionInterface& aDatabase, 
    1.69 +	                 MLogServBackupInterface& aBackupInterface, 
    1.70 +	                 CLogPackage& aPackage, 
    1.71 +	                 TLogViewType aType, 
    1.72 +	                 TLogViewId aViewId, 
    1.73 +	                 const RMessage2& aMessage);
    1.74 +	                 
    1.75 +	void ConstructL();
    1.76 +    static void DestroyList(TAny *aPtr);
    1.77 +
    1.78 +private: // FROM MLogServDatabaseChangeObserver
    1.79 +	void DCOHandleChangeEventsL(const CLogChangeDefinition& aChanges);
    1.80 +    // FROM MLogServBackupObserver
    1.81 +	void BOHandleEventL(TLogServBackupEvent aEvent);
    1.82 +
    1.83 +	void InitializeColumnsL(RDbRowSet& aRowSet);
    1.84 +	inline TInt ClientSideCursorPosition() const;
    1.85 +	//
    1.86 +	void ResetViewContentsL(RDbRowSet& aRowSet);
    1.87 +	void PrepareViewContentsL(const TDesC& aSQL);
    1.88 +	TInt RebuildViewContentsIfNecessary();
    1.89 +	void DoHandleChangeEventsL(const CLogChangeDefinition& aChanges);
    1.90 +	void RebuildViewL();
    1.91 +	TBool IsAllowed(TEventOp aEventOp, TUint8 aEventTypeIndex);
    1.92 +
    1.93 +protected:
    1.94 +	MLogServDatabaseTransactionInterface& iDatabase;
    1.95 +	CLogPackage& iPackage;
    1.96 +
    1.97 +private:
    1.98 +	MLogServBackupInterface& iBackupInterface;
    1.99 +	TLogViewType iType;//The type of view that this object represents
   1.100 +	TLogViewId iViewId;//The id of this view
   1.101 +	RArray<TLogId> iViewContents;//An array which contains the log ids of all the items in this view
   1.102 +	TBool          iViewContentsReady;
   1.103 +	HBufC* iSql;//The SQL filter/condition which is used to build this view
   1.104 +	TBool iRebuildViewContents;//A flag to indicate that we need to rebuild the view because handling a change notification failed (e.g due to OOM).
   1.105 +	CLogServViewLockObserver* iLockChangeObserver;//Manages lock change events
   1.106 +	CLogServViewChangeManager* iChangeManager;//Manages change events for this view
   1.107 +	const RMessage2& iMessage;//Passed in the constructor by the LogServOperationFactory - used to check security
   1.108 +	/**
   1.109 +	Data structure for storage of cached security information
   1.110 +	@internalComponent
   1.111 +	*/
   1.112 +	struct SStandardTypeSecurity 
   1.113 +		{
   1.114 +		TUid eventType;
   1.115 +		TBool readAccess;
   1.116 +		TBool writeAccess;
   1.117 +		};
   1.118 +	RArray<SStandardTypeSecurity> iStandardTypeSecurityCache;
   1.119 +    static TDbColNo   iIdColNo;
   1.120 +    static TDbColNo   iTypeColNo;
   1.121 +    static TDbColNo   iFlagColNo[KLogFlagsCount];
   1.122 +
   1.123 +	};
   1.124 +
   1.125 +/**
   1.126 +Returns the id of this view
   1.127 +*/
   1.128 +inline TLogViewId CLogServViewBase::ViewId() const
   1.129 +	{
   1.130 +	return iViewId;
   1.131 +	}
   1.132 +
   1.133 +/**
   1.134 +Is the view ready?
   1.135 +*/
   1.136 +inline TBool CLogServViewBase::ViewIsReady() const
   1.137 +	{
   1.138 +	return (iViewContentsReady && iSql);
   1.139 +	}
   1.140 +
   1.141 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.142 +//////////////////////   CLogServViewLockObserver  ////////////////////////////////////////////////////
   1.143 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.144 +
   1.145 +/**
   1.146 +Implements MLogServBackupObserver interface.
   1.147 +An instance of this class is data member of CLogServViewBase.
   1.148 +It is used every time when the client side requests notification regarding the view status.
   1.149 +The view status changes to "locked" during the backup/restore operations.
   1.150 +
   1.151 +@see CLogServViewBase
   1.152 +@see MLogServBackupObserver
   1.153 +@internalComponent
   1.154 +*/
   1.155 +class CLogServViewLockObserver : public CBase, public MLogServBackupObserver
   1.156 +	{
   1.157 +public:
   1.158 +	static CLogServViewLockObserver* NewL(MLogServBackupInterface& aBackupInterface);
   1.159 +	~CLogServViewLockObserver();
   1.160 +    void RequestLockStatusChanges(const RMessage2& aMessage);
   1.161 +    void RequestLockStatusChangesCancel();
   1.162 +
   1.163 +private:
   1.164 +	CLogServViewLockObserver(MLogServBackupInterface& aBackupInterface);
   1.165 +	void ConstructL();
   1.166 +    // FROM MLogServBackupObserver
   1.167 +	void BOHandleEventL(TLogServBackupEvent aEvent);
   1.168 +
   1.169 +	inline TBool HaveLockStatusChangePointer() const;
   1.170 +	void CompleteLockStatusChangeMessage(TInt aCompletionCode);
   1.171 +
   1.172 +private:
   1.173 +	MLogServBackupInterface& iBackupInterface;
   1.174 +	RArray<TLogViewLockStatus> iLockEvents;//Holds state changes when the client isn't able to receive them immediately. 
   1.175 +	RMessagePtr2 iLockStatusChangeMessage;//Completed when the view is locked/unlocked
   1.176 +
   1.177 +	};
   1.178 +
   1.179 +inline TBool CLogServViewLockObserver::HaveLockStatusChangePointer() const
   1.180 +	{
   1.181 +	return (iLockStatusChangeMessage != RMessagePtr2());
   1.182 +	} 
   1.183 +
   1.184 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.185 +//////////////////////   CLogServViewEvent  ///////////////////////////////////////////////////////////
   1.186 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.187 +
   1.188 +/**
   1.189 +CLogServViewBase derived class.
   1.190 +
   1.191 +@see CLogServViewBase 
   1.192 +@internalComponent
   1.193 +*/
   1.194 +class CLogServViewEvent : public CLogServViewBase
   1.195 +	{
   1.196 +public:
   1.197 +	static CLogServViewEvent* NewL(MLogServDatabaseTransactionInterface& aDatabase, 
   1.198 +	                               MLogServBackupInterface& aBackupInterface, 
   1.199 +	                               CLogPackage& aPackage, 
   1.200 +	                               TLogViewId aViewId, 
   1.201 +	                               const RMessage2& aMessage);
   1.202 +	                               
   1.203 +	TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType);
   1.204 +	//
   1.205 +private:
   1.206 +	CLogServViewEvent(MLogServDatabaseTransactionInterface& aDatabase, 
   1.207 +	                  MLogServBackupInterface& aBackupInterface, 
   1.208 +	                  CLogPackage& aPackage, 
   1.209 +	                  TLogViewId aViewId, 
   1.210 +	                  const RMessage2& aMessage);
   1.211 +	};
   1.212 +
   1.213 +
   1.214 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.215 +//////////////////////   CLogServViewRecent  //////////////////////////////////////////////////////////
   1.216 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.217 +
   1.218 +/**
   1.219 +CLogServViewBase derived class.
   1.220 +
   1.221 +@see CLogServViewBase 
   1.222 +@internalComponent
   1.223 +*/
   1.224 +class CLogServViewRecent : public CLogServViewBase
   1.225 +	{
   1.226 +public:
   1.227 +	static CLogServViewRecent* NewL(MLogServDatabaseTransactionInterface& aDatabase, 
   1.228 +	                                MLogServBackupInterface& aBackupInterface, 
   1.229 +	                                CLogPackage& aPackage, 
   1.230 +	                                TLogViewId aViewId, 
   1.231 +	                                const RMessage2& aMessage);
   1.232 +	                                
   1.233 +	TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType);
   1.234 +	void RemoveL(const RMessage2& aMessage);
   1.235 +	void ClearDuplicatesL(const RMessage2& aMessage);
   1.236 +	//
   1.237 +
   1.238 +	//
   1.239 +private:
   1.240 +	CLogServViewRecent(MLogServDatabaseTransactionInterface& aDatabase, MLogServBackupInterface& aBackupInterface, CLogPackage& aPackage, TLogViewId aViewId, const RMessage2& aMessage);
   1.241 +    void InitializeColumns2L(RDbRowSet& aRowSet); 
   1.242 +	//
   1.243 +private:
   1.244 +	TLogRecentList iRecentList;
   1.245 +
   1.246 +    static TDbColNo   iIdColNo;
   1.247 +    static TDbColNo   iRecentColNo;
   1.248 +    static TDbColNo   iDuplicateColNo;
   1.249 +	
   1.250 +	};
   1.251 +
   1.252 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.253 +//////////////////////   CLogServViewDuplicate  ///////////////////////////////////////////////////////
   1.254 +///////////////////////////////////////////////////////////////////////////////////////////////////////
   1.255 +
   1.256 +/**
   1.257 +CLogServViewBase derived class.
   1.258 +
   1.259 +@see CLogServViewBase 
   1.260 +@internalComponent
   1.261 +*/
   1.262 +class CLogServViewDuplicate : public CLogServViewBase
   1.263 +	{
   1.264 +public:
   1.265 +	static CLogServViewDuplicate* NewL(MLogServDatabaseTransactionInterface& aDatabase, 
   1.266 +	                                   MLogServBackupInterface& aBackupInterface,
   1.267 +	                                   CLogPackage& aPackage, 
   1.268 +	                                   TLogViewId aViewId, 
   1.269 +	                                   const RMessage2& aMessage);
   1.270 +	                                   
   1.271 +	TPtrC GetQueryStringL(const RMessage2& aMessage, TLogFilterConstructionType aFilterType);
   1.272 +	void RemoveL(const RMessage2& aMessage);
   1.273 +	//
   1.274 +private:
   1.275 +	CLogServViewDuplicate(MLogServDatabaseTransactionInterface& aDatabase, 
   1.276 +	                      MLogServBackupInterface& aBackupInterface, 
   1.277 +	                      CLogPackage& aPackage, 
   1.278 +	                      TLogViewId aViewId, 
   1.279 +	                      const RMessage2& aMessage);
   1.280 +	//
   1.281 +private:
   1.282 +	TLogId iSourceId;
   1.283 +	};
   1.284 +
   1.285 +#endif