|
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 __LOGSERVSESSION_H__ |
|
17 #define __LOGSERVSESSION_H__ |
|
18 |
|
19 #include <logcli.h> |
|
20 #include "LogServDefs.h" |
|
21 #include "LogServDatabaseChangeObserver.h" |
|
22 |
|
23 // Classes referenced |
|
24 class TLogClientServerData; |
|
25 class MLogServSessionLifetimeObserver; |
|
26 class MLogServTaskInterface; |
|
27 class MLogServOperationManager; |
|
28 class MLogServBackupInterface; |
|
29 class MLogServDatabaseChangeInterface; |
|
30 class MLogServDatabaseTransactionInterface; |
|
31 class CLogServServer; |
|
32 class CLogNotify; |
|
33 class CLogServViewBase; |
|
34 |
|
35 /** |
|
36 Handles client requests such as "add event", "change event", etc. |
|
37 and dispatches them for execution to the hitters. |
|
38 "Hitter" is an active object which class type is one of (CLogActive derived class): |
|
39 - CLogAddEvent; |
|
40 - CLogGetEvent; |
|
41 - CLogChangeEvent; |
|
42 - CLogDeleteEvent; |
|
43 - CLogChangeConfig; |
|
44 - CLogMaintenance; |
|
45 - CLogServViewWindowFetcher; |
|
46 |
|
47 Every client request is processed asynchronously and consists of two IPC calls: |
|
48 - ELogOperationInitiate - the client initiates asynchronous operation that will be executed by |
|
49 one of the hitters; |
|
50 - ELogOperationGetResult - after the hitter completes the execution of the requested operation and |
|
51 if there is a result for the client, the client can collect the result issuing this IPC request; |
|
52 |
|
53 The client requests processing is relatively complex and I hope the following "add event" step-by-step |
|
54 example can clarify how the LogEng server works. |
|
55 1. LogEng client issues "add event" request |
|
56 2. The request is handled by CLogServSession::ServiceL() |
|
57 3. CLogServSession::ServiceL() calls CLogServSession::ServiceOperationFunctionL() where the IPC command |
|
58 is identified as ELogOperationInitiate and a new operation is created by calling |
|
59 4. LogServFactory::NewOperationL(). Here the client request type is identified as ELogOperationEventAdd |
|
60 and an instance of CLogServOpEventAdd class is created |
|
61 5. The CLogServOpEventAdd class derives from CLogServOperationBase. The CLogServOperationBase constructor |
|
62 will add the just created operation to a queue of pending operations maintained by an instance of the |
|
63 CLogServOperationQueue class, which implements the MLogServOperationManager interface. |
|
64 The CLogServOpEventAdd instance is added to the queue by calling |
|
65 MLogServOperationManager::OMOperationQueueAdd(). |
|
66 6. The CLogServOperationQueue instance is an active object. |
|
67 CLogServOperationQueue::OMOperationQueueAdd() completes itsef and calls SetActive(). |
|
68 The execution control is returned to the server side session object. Later, when the active scheduler |
|
69 takes the execution control the CLogServOperationQueue::RunL() will be called. |
|
70 7. CLogServOperationQueue::RunL() will pick up the next pending operation from the queue and calls the |
|
71 operation's StartL() method - CLogServOpEventAdd::StartL(). |
|
72 8. CLogServOpEventAdd::StartL() reads the client "add event" data from the message object and calls |
|
73 MLogServTaskInterface::TaskEventAddL() passing the client data as call arguments. |
|
74 9. MLogServTaskInterface, as the class name states, is an interface class implemented by the |
|
75 CLogServDatabaseDriver class. |
|
76 10. CLogServDatabaseDriver::TaskEventAddL() will call the StartL() method of the hitter - |
|
77 CLogAddEvent::StartL(). |
|
78 11. CLogAddEvent::StartL() will complete itself and call SetActive(). |
|
79 12. The next time when the active scheduler takes the execution control, it will call |
|
80 CLogActive::RunL() --> CLogAddEvent::DoRunL(). And the "add event" request will be executed |
|
81 13. The LogEng client then can complete the "add event" request by calling the server using the |
|
82 ELogOperationGetResult IPC code. CLogServOperationQueue::OMGetResultL() will retrieve the result of the |
|
83 operation and destroy the "add event" oeration. |
|
84 |
|
85 @see LogServFactory |
|
86 @see CLogServOpEventAdd |
|
87 @see MLogServOperationManager |
|
88 @see CLogServOperationQueue |
|
89 @see MLogServTaskInterface |
|
90 @see CLogServDatabaseDriver |
|
91 @see CLogActive |
|
92 @see CLogAddEvent |
|
93 |
|
94 @internalComponent |
|
95 */ |
|
96 class CLogServSession : public CSession2, public MLogServDatabaseChangeObserver |
|
97 { |
|
98 public: |
|
99 CLogServSession(TLogServSessionId aSessionId, |
|
100 MLogServSessionLifetimeObserver& aObserver, |
|
101 MLogServBackupInterface& aBackupInterface, |
|
102 MLogServTaskInterface& aTaskInterface, |
|
103 MLogServOperationManager& aOperationManager, |
|
104 MLogServDatabaseChangeInterface& aChangeInterface, |
|
105 MLogServDatabaseTransactionInterface& aDatabase); |
|
106 ~CLogServSession(); |
|
107 |
|
108 inline TLogServSessionId Id() const; |
|
109 CLogServServer& Server() const; |
|
110 |
|
111 private: |
|
112 void DCOHandleGlobalChangeEventL(const TLogServDatabaseChangeDefinition& aChange);//FROM MLogServDatabaseChangeObserver |
|
113 void CreateL(); |
|
114 virtual void ServiceL(const RMessage2& aMessage); |
|
115 virtual void ServiceError(const RMessage2& aMessage,TInt aError); |
|
116 CLogServViewBase& ViewByIdL(TLogViewId aViewId); |
|
117 TInt ViewPositionById(TLogViewId aViewId) const; |
|
118 void ReadClientServerDataL(TLogClientServerData& aClientServerData, |
|
119 const RMessage2& aMessage, TInt aMinOperation, TInt aMaxOperation); |
|
120 void ServiceViewFunctionL(const RMessage2& aMessage); |
|
121 void ServiceOperationFunctionL(const RMessage2& aMessage); |
|
122 void ExtendedNotifyCompleteL(TInt aCompletionCode); |
|
123 |
|
124 private: |
|
125 TLogServSessionId iSessionId; |
|
126 MLogServSessionLifetimeObserver& iObserver; |
|
127 MLogServBackupInterface& iBackupInterface; |
|
128 MLogServTaskInterface& iTaskInterface; |
|
129 MLogServOperationManager& iOperationManager; |
|
130 MLogServDatabaseChangeInterface& iChangeInterface; |
|
131 MLogServDatabaseTransactionInterface& iDatabase; |
|
132 CLogPackage* iPackage; |
|
133 CLogNotify* iNotify; |
|
134 RPointerArray<CLogServViewBase> iViewList; |
|
135 RMessage2 iExtendedNotificationMessage; |
|
136 RArray<TLogServDatabaseChangeDefinition> iPendingGlobalChanges; |
|
137 TBool iExtendedNotificationRequested; |
|
138 #ifdef LOGGING_ENABLED |
|
139 TName iClientThreadName; |
|
140 #endif |
|
141 |
|
142 }; |
|
143 |
|
144 inline TLogServSessionId CLogServSession::Id() const |
|
145 { |
|
146 return iSessionId; |
|
147 } |
|
148 |
|
149 #endif//__LOGSERVSESSION_H__ |