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 __LOGSERVSESSION_H__ sl@0: #define __LOGSERVSESSION_H__ sl@0: sl@0: #include sl@0: #include "LogServDefs.h" sl@0: #include "LogServDatabaseChangeObserver.h" sl@0: sl@0: // Classes referenced sl@0: class TLogClientServerData; sl@0: class MLogServSessionLifetimeObserver; sl@0: class MLogServTaskInterface; sl@0: class MLogServOperationManager; sl@0: class MLogServBackupInterface; sl@0: class MLogServDatabaseChangeInterface; sl@0: class MLogServDatabaseTransactionInterface; sl@0: class CLogServServer; sl@0: class CLogNotify; sl@0: class CLogServViewBase; sl@0: sl@0: /** sl@0: Handles client requests such as "add event", "change event", etc. sl@0: and dispatches them for execution to the hitters. sl@0: "Hitter" is an active object which class type is one of (CLogActive derived class): sl@0: - CLogAddEvent; sl@0: - CLogGetEvent; sl@0: - CLogChangeEvent; sl@0: - CLogDeleteEvent; sl@0: - CLogChangeConfig; sl@0: - CLogMaintenance; sl@0: - CLogServViewWindowFetcher; sl@0: sl@0: Every client request is processed asynchronously and consists of two IPC calls: sl@0: - ELogOperationInitiate - the client initiates asynchronous operation that will be executed by sl@0: one of the hitters; sl@0: - ELogOperationGetResult - after the hitter completes the execution of the requested operation and sl@0: if there is a result for the client, the client can collect the result issuing this IPC request; sl@0: sl@0: The client requests processing is relatively complex and I hope the following "add event" step-by-step sl@0: example can clarify how the LogEng server works. sl@0: 1. LogEng client issues "add event" request sl@0: 2. The request is handled by CLogServSession::ServiceL() sl@0: 3. CLogServSession::ServiceL() calls CLogServSession::ServiceOperationFunctionL() where the IPC command sl@0: is identified as ELogOperationInitiate and a new operation is created by calling sl@0: 4. LogServFactory::NewOperationL(). Here the client request type is identified as ELogOperationEventAdd sl@0: and an instance of CLogServOpEventAdd class is created sl@0: 5. The CLogServOpEventAdd class derives from CLogServOperationBase. The CLogServOperationBase constructor sl@0: will add the just created operation to a queue of pending operations maintained by an instance of the sl@0: CLogServOperationQueue class, which implements the MLogServOperationManager interface. sl@0: The CLogServOpEventAdd instance is added to the queue by calling sl@0: MLogServOperationManager::OMOperationQueueAdd(). sl@0: 6. The CLogServOperationQueue instance is an active object. sl@0: CLogServOperationQueue::OMOperationQueueAdd() completes itsef and calls SetActive(). sl@0: The execution control is returned to the server side session object. Later, when the active scheduler sl@0: takes the execution control the CLogServOperationQueue::RunL() will be called. sl@0: 7. CLogServOperationQueue::RunL() will pick up the next pending operation from the queue and calls the sl@0: operation's StartL() method - CLogServOpEventAdd::StartL(). sl@0: 8. CLogServOpEventAdd::StartL() reads the client "add event" data from the message object and calls sl@0: MLogServTaskInterface::TaskEventAddL() passing the client data as call arguments. sl@0: 9. MLogServTaskInterface, as the class name states, is an interface class implemented by the sl@0: CLogServDatabaseDriver class. sl@0: 10. CLogServDatabaseDriver::TaskEventAddL() will call the StartL() method of the hitter - sl@0: CLogAddEvent::StartL(). sl@0: 11. CLogAddEvent::StartL() will complete itself and call SetActive(). sl@0: 12. The next time when the active scheduler takes the execution control, it will call sl@0: CLogActive::RunL() --> CLogAddEvent::DoRunL(). And the "add event" request will be executed sl@0: 13. The LogEng client then can complete the "add event" request by calling the server using the sl@0: ELogOperationGetResult IPC code. CLogServOperationQueue::OMGetResultL() will retrieve the result of the sl@0: operation and destroy the "add event" oeration. sl@0: sl@0: @see LogServFactory sl@0: @see CLogServOpEventAdd sl@0: @see MLogServOperationManager sl@0: @see CLogServOperationQueue sl@0: @see MLogServTaskInterface sl@0: @see CLogServDatabaseDriver sl@0: @see CLogActive sl@0: @see CLogAddEvent sl@0: sl@0: @internalComponent sl@0: */ sl@0: class CLogServSession : public CSession2, public MLogServDatabaseChangeObserver sl@0: { sl@0: public: sl@0: CLogServSession(TLogServSessionId aSessionId, sl@0: MLogServSessionLifetimeObserver& aObserver, sl@0: MLogServBackupInterface& aBackupInterface, sl@0: MLogServTaskInterface& aTaskInterface, sl@0: MLogServOperationManager& aOperationManager, sl@0: MLogServDatabaseChangeInterface& aChangeInterface, sl@0: MLogServDatabaseTransactionInterface& aDatabase); sl@0: ~CLogServSession(); sl@0: sl@0: inline TLogServSessionId Id() const; sl@0: CLogServServer& Server() const; sl@0: sl@0: private: sl@0: void DCOHandleGlobalChangeEventL(const TLogServDatabaseChangeDefinition& aChange);//FROM MLogServDatabaseChangeObserver sl@0: void CreateL(); sl@0: virtual void ServiceL(const RMessage2& aMessage); sl@0: virtual void ServiceError(const RMessage2& aMessage,TInt aError); sl@0: CLogServViewBase& ViewByIdL(TLogViewId aViewId); sl@0: TInt ViewPositionById(TLogViewId aViewId) const; sl@0: void ReadClientServerDataL(TLogClientServerData& aClientServerData, sl@0: const RMessage2& aMessage, TInt aMinOperation, TInt aMaxOperation); sl@0: void ServiceViewFunctionL(const RMessage2& aMessage); sl@0: void ServiceOperationFunctionL(const RMessage2& aMessage); sl@0: void ExtendedNotifyCompleteL(TInt aCompletionCode); sl@0: sl@0: private: sl@0: TLogServSessionId iSessionId; sl@0: MLogServSessionLifetimeObserver& iObserver; sl@0: MLogServBackupInterface& iBackupInterface; sl@0: MLogServTaskInterface& iTaskInterface; sl@0: MLogServOperationManager& iOperationManager; sl@0: MLogServDatabaseChangeInterface& iChangeInterface; sl@0: MLogServDatabaseTransactionInterface& iDatabase; sl@0: CLogPackage* iPackage; sl@0: CLogNotify* iNotify; sl@0: RPointerArray iViewList; sl@0: RMessage2 iExtendedNotificationMessage; sl@0: RArray iPendingGlobalChanges; sl@0: TBool iExtendedNotificationRequested; sl@0: #ifdef LOGGING_ENABLED sl@0: TName iClientThreadName; sl@0: #endif sl@0: sl@0: }; sl@0: sl@0: inline TLogServSessionId CLogServSession::Id() const sl@0: { sl@0: return iSessionId; sl@0: } sl@0: sl@0: #endif//__LOGSERVSESSION_H__