|
1 /* |
|
2 * Copyright (c) 2006-2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0"" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Memory Scan Server |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef __MEMSCANSERV_H__ |
|
20 #define __MEMSCANSERV_H__ |
|
21 |
|
22 // SYSTEM INCLUDES |
|
23 #include <e32base.h> |
|
24 |
|
25 // USER INCLUDES |
|
26 #include "memscanclientserver.h" |
|
27 #include "msenguihandler.h" |
|
28 #include "mseng.h" |
|
29 |
|
30 |
|
31 |
|
32 // -------------------------------------------------------------------------- |
|
33 // Server's policy here |
|
34 // -------------------------------------------------------------------------- |
|
35 |
|
36 //Total number of ranges |
|
37 const TUint KMemScanServRangeCount = 2; |
|
38 |
|
39 //Definition of the ranges of IPC numbers |
|
40 const TInt KMemScanServRanges[KMemScanServRangeCount] = |
|
41 { |
|
42 0, // ECapabilityReadUserData |
|
43 /* |
|
44 0 EMemScanStartScan, |
|
45 1 EMemScanPrepareDataGroups, |
|
46 2 EMemScanGetDataGroups, |
|
47 3 EMemScanInProgress, |
|
48 4 EMemScanRequestScanEvents, |
|
49 5 EMemScanRequestScanEventsCancel, |
|
50 6 EMemScanPrepareScanResults, |
|
51 7 EMemScanGetScanResults |
|
52 */ |
|
53 |
|
54 8 // ENotSupported - Non implemented function end of range check |
|
55 }; |
|
56 |
|
57 //Policy to implement for each of the above ranges |
|
58 const TUint8 KMemScanServElementsIndex[KMemScanServRangeCount] = |
|
59 { |
|
60 0, // 0th range: Policy 0 in Elements |
|
61 CPolicyServer::ENotSupported // 1st range: Out of range IPC |
|
62 }; |
|
63 |
|
64 //Specific capability checks |
|
65 const CPolicyServer::TPolicyElement KMemScanServElements[] = |
|
66 { |
|
67 // Policy 0: Fail call if ReadUserData not present |
|
68 {_INIT_SECURITY_POLICY_C1(ECapabilityReadUserData), CPolicyServer::EFailClient} |
|
69 }; |
|
70 |
|
71 //Package all the above together into a policy |
|
72 const CPolicyServer::TPolicy KMemScanServPolicy = |
|
73 { |
|
74 CPolicyServer::EAlwaysPass, // All connect attempts should pass |
|
75 KMemScanServRangeCount, // Number of ranges |
|
76 KMemScanServRanges, // Ranges array |
|
77 KMemScanServElementsIndex, // Elements<->Ranges index |
|
78 KMemScanServElements, // Array of elements |
|
79 }; |
|
80 |
|
81 |
|
82 |
|
83 // -------------------------------------------------------------------------- |
|
84 // Server's panic codes here |
|
85 // -------------------------------------------------------------------------- |
|
86 enum TMemScanServPanic |
|
87 { |
|
88 EPanicGeneral, |
|
89 EPanicIllegalFunction |
|
90 }; |
|
91 |
|
92 void PanicClient(const RMessagePtr2& aMessage,TMemScanServPanic aPanic); |
|
93 |
|
94 |
|
95 // -------------------------------------------------------------------------- |
|
96 // Auto shutdown class (standard pattern) |
|
97 // -------------------------------------------------------------------------- |
|
98 class CShutdown : public CTimer |
|
99 { |
|
100 enum TMemScanShutdown |
|
101 { |
|
102 EMemScanServShutdownDelay=0x200000 |
|
103 }; |
|
104 public: |
|
105 inline CShutdown(); |
|
106 inline void ConstructL(); |
|
107 inline void Start(); |
|
108 private: |
|
109 void RunL(); |
|
110 }; |
|
111 |
|
112 // -------------------------------------------------------------------------- |
|
113 // Server |
|
114 // -------------------------------------------------------------------------- |
|
115 |
|
116 class CMemScanServ : public CPolicyServer |
|
117 { |
|
118 public: |
|
119 static CServer2* NewLC(); |
|
120 void AddSession(); |
|
121 void DropSession(); |
|
122 private: |
|
123 CMemScanServ(); |
|
124 void ConstructL(); |
|
125 CSession2* NewSessionL( const TVersion& aVersion, |
|
126 const RMessage2& aMessage) const; |
|
127 |
|
128 private: |
|
129 TInt iSessionCount; |
|
130 CShutdown iShutdown; |
|
131 }; |
|
132 |
|
133 |
|
134 |
|
135 // -------------------------------------------------------------------------- |
|
136 // Event object |
|
137 // -------------------------------------------------------------------------- |
|
138 struct TMemScanEventPackage |
|
139 { |
|
140 TMemScanEvent iEvent; |
|
141 TInt iError; |
|
142 }; |
|
143 |
|
144 |
|
145 // -------------------------------------------------------------------------- |
|
146 // Session |
|
147 // -------------------------------------------------------------------------- |
|
148 class CMemScanServSession : public CSession2, public MMsengUIHandler |
|
149 { |
|
150 public: |
|
151 CMemScanServSession(); |
|
152 void CreateL(); |
|
153 private: |
|
154 ~CMemScanServSession(); |
|
155 inline CMemScanServ& Server(); |
|
156 void ServiceL(const RMessage2& aMessage); |
|
157 void ServiceError(const RMessage2& aMessage,TInt aError); |
|
158 |
|
159 |
|
160 private: // Client <-> server functions |
|
161 void MemScanL(const RMessage2& aMessage); |
|
162 void RequestScanEventsL(const RMessage2& aMessage); |
|
163 void RequestScanEventsCancel(const RMessage2& aMessage); |
|
164 void ScanInProgress(const RMessage2& aMessage); |
|
165 void PrepareDataGroupsL(const RMessage2& aMessage); |
|
166 void GetDataGroupsL(const RMessage2& aMessage); |
|
167 void PrepareScanResultsL(const RMessage2& aMessage); |
|
168 void GetScanResultsL(const RMessage2& aMessage); |
|
169 |
|
170 private: // Internal utility functions |
|
171 void SendEventToClientL( TMemScanEvent aEventType, TInt aError=KErrNone ); |
|
172 void AddNewEventToBufferL( TMemScanEvent aEventType, TInt aError); |
|
173 TBool IsEventReady() const; |
|
174 void DeliverOldestEventToClientL(); |
|
175 |
|
176 private: //From MMsengUIHandler |
|
177 void StartL(); |
|
178 void QuitL(TInt aReason); |
|
179 void ErrorL(TInt aError); |
|
180 |
|
181 private: // Member variables |
|
182 CMseng* iMseng; |
|
183 RMessagePtr2 iScanEventMessage; |
|
184 RArray< TMemScanEventPackage > iEventBuffer; |
|
185 CBufBase* iTransferBuffer; |
|
186 }; |
|
187 |
|
188 |
|
189 |
|
190 #endif // __MEMSCANSERV_H__ |
|
191 |
|
192 // End of File |