|
1 // Copyright (c) 2004-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 #include "panic.h" |
|
17 #include "sessnotf.h" |
|
18 #include "srvreqs.h" |
|
19 #include "srvsess.h" |
|
20 #include "cachemgr.h" |
|
21 #include <centralrepository.h> |
|
22 |
|
23 #include "backup.h" |
|
24 |
|
25 using namespace NCentralRepositoryConstants; |
|
26 |
|
27 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
28 // Function EncodeEventAndData |
|
29 // Put event Id in upper 8 bit and data in lower 24 bit. |
|
30 inline |
|
31 TUint32 EncodeEventAndData(TUint aEventId, TUint32 aData) |
|
32 { |
|
33 return ((aEventId & KEventIdMask) << KEventIdShiftBits) | |
|
34 (aData & KDataMask); |
|
35 } |
|
36 #endif //__CENTREP_SERVER_PERFTEST__ |
|
37 |
|
38 inline CSessionManager& CServerSession::Server() |
|
39 {return *static_cast<CSessionManager*>(const_cast<CServer2*>(CSession2::Server()));} |
|
40 |
|
41 CServerSession::~CServerSession() |
|
42 { |
|
43 iFindResult.Close(); |
|
44 |
|
45 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
46 DoEventStart(); |
|
47 #endif |
|
48 |
|
49 iRepository.Close(iNotifier); |
|
50 |
|
51 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
52 if (iInitialised) |
|
53 { |
|
54 DoEventEnd(ESessionClose); |
|
55 } |
|
56 #endif |
|
57 } |
|
58 |
|
59 // if ServiceL Leaves, execution resumes in this method. |
|
60 // this allows us to panic clients using bad descriptors, to deal with OOM conditions |
|
61 // and to fail transactions with the correct reason: OOM etc. |
|
62 void CServerSession::ServiceError(const RMessage2 &aMessage, TInt aError) |
|
63 { |
|
64 // ensure any transaction is failed for the reason aError |
|
65 iRepository.FailTransaction(aError, KUnspecifiedKey); |
|
66 CSession2::ServiceError(aMessage, aError); |
|
67 } |
|
68 |
|
69 void CServerSession::ServiceL(const RMessage2& aMessage) |
|
70 { |
|
71 const TClientRequest msg(aMessage); |
|
72 |
|
73 struct SAction |
|
74 { |
|
75 TServerRequest req; |
|
76 TInt (CServerSession::*groupFuncL)(const TClientRequest&, TServerFunc); |
|
77 TServerFunc funcL; |
|
78 }; |
|
79 |
|
80 static const SAction actionTable[] = |
|
81 { |
|
82 {EInitialise, &CServerSession::GeneralOperationsL, &CServerSession::InitialiseL}, |
|
83 {ECreateInt, &CServerSession::WriteOperationsL, &CServerSession::CreateIntL}, |
|
84 {ECreateReal, &CServerSession::WriteOperationsL, &CServerSession::CreateRealL}, |
|
85 {ECreateString, &CServerSession::WriteOperationsL, &CServerSession::CreateStringL}, |
|
86 {EDelete, &CServerSession::WriteOperationsL, &CServerSession::DeleteL}, |
|
87 {EGetInt, &CServerSession::ReadOperationsL, &CServerSession::GetIntL}, |
|
88 {ESetInt, &CServerSession::WriteOperationsL, &CServerSession::SetIntL}, |
|
89 {EGetReal, &CServerSession::ReadOperationsL, &CServerSession::GetRealL}, |
|
90 {ESetReal, &CServerSession::WriteOperationsL, &CServerSession::SetRealL}, |
|
91 {EGetString, &CServerSession::ReadOperationsL, &CServerSession::GetStringL}, |
|
92 {ESetString, &CServerSession::WriteOperationsL, &CServerSession::SetStringL}, |
|
93 {EFind, &CServerSession::ReadOperationsL, &CServerSession::FindL}, |
|
94 {EFindEqInt, &CServerSession::ReadOperationsL, &CServerSession::FindEqIntL}, |
|
95 {EFindEqReal, &CServerSession::ReadOperationsL, &CServerSession::FindEqRealL}, |
|
96 {EFindEqString, &CServerSession::ReadOperationsL, &CServerSession::FindEqStringL}, |
|
97 {EFindNeqInt, &CServerSession::ReadOperationsL, &CServerSession::FindNeqIntL}, |
|
98 {EFindNeqReal, &CServerSession::ReadOperationsL, &CServerSession::FindNeqRealL}, |
|
99 {EFindNeqString, &CServerSession::ReadOperationsL, &CServerSession::FindNeqStringL}, |
|
100 {EGetFindResult, &CServerSession::ReadOperationsL, &CServerSession::GetFindResultL}, |
|
101 {ENotifyRequestCheck, &CServerSession::GeneralOperationsL, &CServerSession::NotifyRequestCheck}, |
|
102 {ENotifyRequest, &CServerSession::GeneralOperationsL, &CServerSession::NotifyRequest}, |
|
103 {ENotifyCancel, &CServerSession::GeneralOperationsL, &CServerSession::NotifyCancel}, |
|
104 {ENotifyCancelAll, &CServerSession::GeneralOperationsL, &CServerSession::NotifyCancelAll}, |
|
105 {EGroupNotifyRequest, &CServerSession::GeneralOperationsL, &CServerSession::GroupNotifyRequest}, |
|
106 {EGroupNotifyCancel, &CServerSession::GeneralOperationsL, &CServerSession::GroupNotifyCancel}, |
|
107 {EReset, &CServerSession::ResetOperationsL, &CServerSession::ResetL}, |
|
108 {EResetAll, &CServerSession::ResetOperationsL, &CServerSession::ResetAllL}, |
|
109 {ETransactionStart, &CServerSession::GeneralOperationsL, &CServerSession::TransactionStart}, |
|
110 {ETransactionCommit, &CServerSession::GeneralOperationsL, &CServerSession::TransactionCommitL}, |
|
111 {ETransactionCancel, &CServerSession::GeneralOperationsL, &CServerSession::TransactionCancel}, |
|
112 {EMove, &CServerSession::WriteOperationsL, &CServerSession::MoveL}, |
|
113 {ETransactionState, &CServerSession::GeneralOperationsL, &CServerSession::TransactionStateL}, |
|
114 {ETransactionFail, &CServerSession::GeneralOperationsL, &CServerSession::TransactionFail}, |
|
115 {EDeleteRange, &CServerSession::WriteOperationsL, &CServerSession::DeleteRangeL} |
|
116 }; |
|
117 |
|
118 TInt r; |
|
119 TServerRequest fn = static_cast<TServerRequest>(aMessage.Function()); |
|
120 |
|
121 #if defined(__CENTREP_SERVER_PERFTEST__) || defined(__CENTREP_SERVER_MEMTEST__) || defined(__CENTREP_SERVER_CACHETEST__) |
|
122 if (fn == EGetSetParameters) |
|
123 { |
|
124 r = GetSetParameters(msg); |
|
125 aMessage.Complete(r); |
|
126 return; |
|
127 } |
|
128 #endif |
|
129 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
130 DoEventStart(); |
|
131 if (EInitialise == fn) |
|
132 { |
|
133 iRepositoryUid = aMessage.Int0(); |
|
134 } |
|
135 #endif |
|
136 |
|
137 __ASSERT_ALWAYS(iInitialised || fn==EInitialise, |
|
138 PanicClient(ESessionNotInitialised, msg)); |
|
139 |
|
140 if(fn>ELastInTable) |
|
141 { |
|
142 r = KErrNotSupported; // or panic client?? |
|
143 } |
|
144 else |
|
145 { |
|
146 iRepository.RestoreConsistencyL(); |
|
147 // plus need to check we are initialised |
|
148 r = (this->*actionTable[fn].groupFuncL)(aMessage, actionTable[fn].funcL); |
|
149 } |
|
150 |
|
151 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
152 DoEventEnd(fn); |
|
153 #endif |
|
154 |
|
155 if (r != KDontComplete) |
|
156 { |
|
157 aMessage.Complete(r); |
|
158 } |
|
159 } |
|
160 |
|
161 //method allows transactions and notify requests to get through during backup/restore |
|
162 //process to prevent them from being blocked. |
|
163 //Transactions being blocked would lead clients to be panicked |
|
164 //if they were trying to open a second transaction in the same session. |
|
165 // Notify cancels must be allowed through because they must always succeed. |
|
166 TInt CServerSession::GeneralOperationsL(const TClientRequest& aMessage, TServerFunc aFuncL) |
|
167 { |
|
168 ASSERT(aFuncL != NULL); |
|
169 return (this->*aFuncL)(aMessage); |
|
170 } |
|
171 |
|
172 // method allows read operations to share transaction-related tasks. |
|
173 // Read operations are allowed only during backup process. |
|
174 // During restore it fails transactions with KErrLocked and returns KErrAbort |
|
175 // and if it is a standalone read oparation it rejects it with KErrServerBusy. |
|
176 TInt CServerSession::ReadOperationsL(const TClientRequest& aMessage, TServerFunc aFuncL) |
|
177 { |
|
178 TInt backupStatus = CRepositoryBackupClient::GetBackupStatus(); |
|
179 |
|
180 if (iRepository.IsInFailedTransaction()) |
|
181 { |
|
182 return KErrAbort; |
|
183 } |
|
184 else if (iRepository.IsInTransaction() && (backupStatus == ERestoreInProgress) ) |
|
185 { |
|
186 iRepository.FailTransaction(KErrLocked,KUnspecifiedKey); |
|
187 return KErrAbort; |
|
188 } |
|
189 else if (backupStatus == ERestoreInProgress) |
|
190 { |
|
191 return KErrServerBusy; |
|
192 } |
|
193 |
|
194 ASSERT(aFuncL != NULL); |
|
195 return (this->*aFuncL)(aMessage); |
|
196 } |
|
197 |
|
198 // method allows write operations to share transaction-related tasks |
|
199 // All write operations are not allowed either during backup or restore process. |
|
200 // If backup or restore is in progress it fails transaction with KErrLocked, |
|
201 // returns KErrAbort or if it is a standalone operation it returns KErrServerBusy. |
|
202 TInt CServerSession::WriteOperationsL(const TClientRequest& aMessage, TServerFunc aFuncL) |
|
203 { |
|
204 TInt backupStatus = CRepositoryBackupClient::GetBackupStatus(); |
|
205 |
|
206 if (iRepository.IsInFailedTransaction()) |
|
207 { |
|
208 return KErrAbort; |
|
209 } |
|
210 else if (iRepository.IsInTransaction() && (backupStatus != ENoBackupActivty) ) |
|
211 { |
|
212 iRepository.FailTransaction(KErrLocked,KUnspecifiedKey); |
|
213 return KErrAbort; |
|
214 } |
|
215 else if (CRepositoryBackupClient::GetBackupStatus() != ENoBackupActivty) |
|
216 { |
|
217 return KErrServerBusy; |
|
218 } |
|
219 |
|
220 // if not already in a transaction, create a temporary concurrent read/write transaction |
|
221 const TBool tempTransaction = !iRepository.IsInTransaction(); |
|
222 if (tempTransaction) |
|
223 { |
|
224 // concurrent read/write transaction is guaranteed to start |
|
225 iRepository.StartTransaction(EConcurrentReadWriteTransaction); |
|
226 // to protect against Leaves: |
|
227 iRepository.CleanupCancelTransactionPushL(); |
|
228 } |
|
229 else |
|
230 { |
|
231 if (iRepository.IsInActiveReadTransaction()) |
|
232 { |
|
233 // must be a read/write transaction to continue |
|
234 iRepository.AttemptPromoteTransactionToReadWrite(); |
|
235 // Note we don't check the return value of the above and return it here. |
|
236 // Instead we call the next level write function and expect it to have the |
|
237 // following code: |
|
238 // if (iRepository.IsInActiveReadTransaction()) |
|
239 // { |
|
240 // return iRepository.FailTransaction(KErrLocked, key); |
|
241 // } |
|
242 // this ensures CommitTransaction reports the failing key. |
|
243 } |
|
244 // Note ServiceError will fail the transaction if write operation leaves |
|
245 } |
|
246 |
|
247 // call the server function |
|
248 ASSERT(aFuncL != NULL); |
|
249 TInt result = (this->*aFuncL)(aMessage); |
|
250 |
|
251 // commit the temporary transaction |
|
252 if (tempTransaction) |
|
253 { |
|
254 CleanupStack::Pop(); // remove cleanup item from earlier |
|
255 // absorb result and keyInfo from commit of temporary transaction |
|
256 TUint32 tempKeyInfo; |
|
257 User::LeaveIfError(iRepository.CommitTransaction(tempKeyInfo)); |
|
258 } |
|
259 return result; |
|
260 } |
|
261 |
|
262 TInt CServerSession::ResetOperationsL(const TClientRequest& aMessage, TServerFunc aFuncL) |
|
263 { |
|
264 // reset operations are not currently supported in transactions |
|
265 if (iRepository.IsInTransaction()) |
|
266 { |
|
267 // fail transaction otherwise client may be misled to believe operation worked |
|
268 return iRepository.FailTransaction(KErrNotSupported, KUnspecifiedKey); |
|
269 } |
|
270 //can't reset when backup or restore is in progress |
|
271 else if (CRepositoryBackupClient::GetBackupStatus() != ENoBackupActivty) |
|
272 { |
|
273 return KErrServerBusy; |
|
274 } |
|
275 ASSERT(aFuncL != NULL); |
|
276 return (this->*aFuncL)(aMessage); |
|
277 } |
|
278 |
|
279 TInt CServerSession::InitialiseL(const TClientRequest& aMessage) |
|
280 { |
|
281 __ASSERT_ALWAYS(!iInitialised, |
|
282 PanicClient(ESessionAlreadyInitialised, aMessage)); |
|
283 // We let anyone to open a repository... |
|
284 // it's not considered a breach of security to let people know |
|
285 // that a repository is there... |
|
286 TUid repositoryUid = TUid::Uid(aMessage.Int0()); |
|
287 iRepository.OpenL(repositoryUid, iNotifier); |
|
288 |
|
289 iInitialised = ETrue; |
|
290 |
|
291 return KErrNone; |
|
292 } |
|
293 |
|
294 TInt CServerSession::CreateIntL(const TClientRequest& aMessage) |
|
295 { |
|
296 TUint32 key = aMessage.Int0(); |
|
297 |
|
298 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
299 if (iRepository.IsInActiveReadTransaction()) |
|
300 { |
|
301 return iRepository.FailTransaction(KErrLocked, key); |
|
302 } |
|
303 |
|
304 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
305 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::CreateIntL - Attempt made to create a setting"))) |
|
306 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
307 |
|
308 TInt val = aMessage.Int1(); |
|
309 |
|
310 TInt r = iRepository.TransactionCreateL(key, val, 0); |
|
311 |
|
312 return r; |
|
313 } |
|
314 |
|
315 TInt CServerSession::CreateRealL(const TClientRequest& aMessage) |
|
316 { |
|
317 TUint32 key = aMessage.Int0(); |
|
318 |
|
319 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
320 if (iRepository.IsInActiveReadTransaction()) |
|
321 { |
|
322 return iRepository.FailTransaction(KErrLocked, key); |
|
323 } |
|
324 |
|
325 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
326 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::CreateRealL - Attempt made to create a setting"))) |
|
327 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
328 |
|
329 TReal val; |
|
330 TPckg<TReal> p(val); |
|
331 aMessage.ReadL(1, p); |
|
332 |
|
333 TInt r = iRepository.TransactionCreateL(key, val, 0); |
|
334 |
|
335 return r; |
|
336 } |
|
337 |
|
338 TInt CServerSession::CreateStringL(const TClientRequest& aMessage) |
|
339 { |
|
340 TUint32 key = aMessage.Int0(); |
|
341 |
|
342 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
343 if (iRepository.IsInActiveReadTransaction()) |
|
344 { |
|
345 return iRepository.FailTransaction(KErrLocked, key); |
|
346 } |
|
347 |
|
348 // sometime: must ensure bad descriptor results in client being panic'd |
|
349 |
|
350 // check for descriptor-too-long was previously on the client side, |
|
351 // hence test code expects KErrArgument response before KErrPermissionDenied |
|
352 TInt length = aMessage.GetDesLengthL(1); |
|
353 if (length > KMaxBinaryLength) |
|
354 { |
|
355 return iRepository.FailTransaction(KErrArgument, key); |
|
356 } |
|
357 |
|
358 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
359 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::CreateStringL - Attempt made to create a setting"))) |
|
360 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
361 |
|
362 TBuf8<KMaxBinaryLength> val; |
|
363 aMessage.ReadL(1, val); |
|
364 |
|
365 TInt error = iRepository.TransactionCreateL(key, val, 0); |
|
366 |
|
367 return error; |
|
368 } |
|
369 |
|
370 TInt CServerSession::DeleteL(const TClientRequest& aMessage) |
|
371 { |
|
372 TUint32 key = aMessage.Int0(); |
|
373 |
|
374 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
375 if (iRepository.IsInActiveReadTransaction()) |
|
376 { |
|
377 return iRepository.FailTransaction(KErrLocked, key); |
|
378 } |
|
379 |
|
380 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
381 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::DeleteL - Attempt made to delete a setting"))) |
|
382 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
383 |
|
384 TInt r = iRepository.TransactionDeleteL(key); |
|
385 |
|
386 return r; |
|
387 } |
|
388 |
|
389 TInt CServerSession::GetIntL(const TClientRequest& aMessage) |
|
390 { |
|
391 TUint32 key = aMessage.Int0(); |
|
392 |
|
393 if(KErrNone != CheckPolicy(aMessage,iRepository.GetReadAccessPolicy(key), |
|
394 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::GetIntL - Attempt made to read a setting"))) |
|
395 return KErrPermissionDenied; |
|
396 |
|
397 TInt val; |
|
398 TInt error = iRepository.Get(key, val); |
|
399 |
|
400 if (error == KErrNone) |
|
401 { |
|
402 TPckg<TInt> p(val); |
|
403 aMessage.WriteL(1, p); |
|
404 } |
|
405 |
|
406 return error; |
|
407 } |
|
408 |
|
409 TInt CServerSession::SetIntL(const TClientRequest& aMessage) |
|
410 { |
|
411 TUint32 key = aMessage.Int0(); |
|
412 |
|
413 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
414 if (iRepository.IsInActiveReadTransaction()) |
|
415 { |
|
416 return iRepository.FailTransaction(KErrLocked, key); |
|
417 } |
|
418 |
|
419 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
420 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::SetIntL - Attempt made to write a setting"))) |
|
421 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
422 |
|
423 TInt val = aMessage.Int1(); |
|
424 TInt error = iRepository.TransactionSetL(key, val); |
|
425 |
|
426 return error; |
|
427 } |
|
428 |
|
429 TInt CServerSession::GetRealL(const TClientRequest& aMessage) |
|
430 { |
|
431 TUint32 key = aMessage.Int0(); |
|
432 |
|
433 if(KErrNone != CheckPolicy(aMessage,iRepository.GetReadAccessPolicy(key), |
|
434 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::GetRealL - Attempt made to read a setting"))) |
|
435 return KErrPermissionDenied; |
|
436 |
|
437 TReal val; |
|
438 TInt error = iRepository.Get(key, val); |
|
439 |
|
440 if(error==KErrNone) |
|
441 { |
|
442 TPckg<TReal> p(val); |
|
443 aMessage.WriteL(1, p); |
|
444 } |
|
445 |
|
446 return error; |
|
447 } |
|
448 |
|
449 TInt CServerSession::SetRealL(const TClientRequest& aMessage) |
|
450 { |
|
451 TUint32 key = aMessage.Int0(); |
|
452 |
|
453 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
454 if (iRepository.IsInActiveReadTransaction()) |
|
455 { |
|
456 return iRepository.FailTransaction(KErrLocked, key); |
|
457 } |
|
458 |
|
459 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
460 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::SetRealL - Attempt made to write a setting"))) |
|
461 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
462 |
|
463 TReal val; |
|
464 TPckg<TReal> p(val); |
|
465 aMessage.ReadL(1, p); |
|
466 |
|
467 TInt error = iRepository.TransactionSetL(key, val); |
|
468 |
|
469 return error; |
|
470 } |
|
471 |
|
472 TInt CServerSession::GetStringL(const TClientRequest& aMessage) |
|
473 { |
|
474 TUint32 key = aMessage.Int0(); |
|
475 |
|
476 if(KErrNone != CheckPolicy(aMessage,iRepository.GetReadAccessPolicy(key), |
|
477 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::GetStringL - Attempt made to read a setting"))) |
|
478 return KErrPermissionDenied; |
|
479 |
|
480 TBuf8<KMaxBinaryLength> val; |
|
481 |
|
482 TInt error = iRepository.Get(key, val); |
|
483 |
|
484 if(error==KErrNone) |
|
485 { |
|
486 TInt clientMaxDescriptorLength; |
|
487 TPckg<TInt> pInt (clientMaxDescriptorLength); |
|
488 aMessage.Read(2, pInt); |
|
489 |
|
490 TInt descriptorLength = val.Length(); |
|
491 |
|
492 // write the descriptor length to aMessage |
|
493 TPckg<TInt> p(descriptorLength); |
|
494 error = aMessage.Write(2, p); |
|
495 |
|
496 if(error==KErrNone) |
|
497 { |
|
498 if(descriptorLength > clientMaxDescriptorLength) |
|
499 { |
|
500 // if it is, fill the descriptor up to its max length |
|
501 error = aMessage.Write(1, val.Left(clientMaxDescriptorLength)); |
|
502 |
|
503 // if client-side descriptor is too small to take the value, which it is, returns KErrOverflow |
|
504 if(error == KErrNone) |
|
505 { |
|
506 error = KErrOverflow; |
|
507 } |
|
508 } |
|
509 else |
|
510 { |
|
511 error = aMessage.Write(1, val); |
|
512 } |
|
513 } |
|
514 |
|
515 // if error is KErrOverflow should not failing transaction |
|
516 if ((error != KErrNone) && (error != KErrOverflow)) |
|
517 { |
|
518 // ServiceError will fail transaction |
|
519 User::Leave(error); |
|
520 } |
|
521 } |
|
522 return error; |
|
523 } |
|
524 |
|
525 TInt CServerSession::SetStringL(const TClientRequest& aMessage) |
|
526 { |
|
527 TUint32 key = aMessage.Int0(); |
|
528 |
|
529 // cannot make changes in a read transaction - upgrade must have failed due to write lock being used |
|
530 if (iRepository.IsInActiveReadTransaction()) |
|
531 { |
|
532 return iRepository.FailTransaction(KErrLocked, key); |
|
533 } |
|
534 |
|
535 // check for descriptor-too-long was previously on the client side, |
|
536 // hence test code expects KErrArgument response before KErrPermissionDenied |
|
537 TInt length = aMessage.GetDesLengthL(1); |
|
538 if (length > KMaxBinaryLength) |
|
539 { |
|
540 return iRepository.FailTransaction(KErrArgument, key); |
|
541 } |
|
542 |
|
543 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
544 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::SetStringL - Attempt made to write a setting"))) |
|
545 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
546 |
|
547 TBuf8<KMaxBinaryLength> val; |
|
548 aMessage.ReadL(1, val); // no error if too long, truncated instead |
|
549 |
|
550 TInt error = iRepository.TransactionSetL(key, val); |
|
551 |
|
552 return error; |
|
553 } |
|
554 |
|
555 TInt CServerSession::FindL(const TClientRequest& aMessage) |
|
556 { |
|
557 // PLATSEC NOTE: |
|
558 // There are no read policy checks on FindL. |
|
559 // Client is returned the full list of keys whether they have read permission or not. |
|
560 // They were able to find this out by brute force using FindL on single setting ranges |
|
561 // anyway (because it would return KErrPermissionDenied if it existed, KErrNotFound otherwise). |
|
562 // Revealing the existence of settings is not considered a breach of security. |
|
563 TInt partialId = aMessage.Int0(); |
|
564 TInt idMask = aMessage.Int1(); |
|
565 // we reset results first since we do not police GetResult |
|
566 // and this way we can guarantee no results are available if access not granted |
|
567 iFindResult.Reset(); |
|
568 RSettingPointerArray settings; |
|
569 CleanupClosePushL(settings); |
|
570 TInt error = iRepository.FindSettings(partialId, idMask, settings); |
|
571 |
|
572 if(error == KErrNone) |
|
573 { |
|
574 const TInt numSettings = settings.Count(); |
|
575 |
|
576 if (numSettings == 0) |
|
577 { |
|
578 error = KErrNotFound; |
|
579 } |
|
580 else |
|
581 { |
|
582 RArray<TUint32> settingsToSend; |
|
583 CleanupClosePushL(settingsToSend); |
|
584 const TInt numInitial = numSettings > KCentRepFindBufSize ? KCentRepFindBufSize : numSettings; |
|
585 const TInt numFinal = numSettings > KCentRepFindBufSize ? numSettings - KCentRepFindBufSize : 0; |
|
586 |
|
587 //reserve memory for everything that needs to be added to the array |
|
588 settingsToSend.Reserve(numSettings + 1); |
|
589 |
|
590 //first append the number of found settings |
|
591 settingsToSend.AppendL(numSettings); |
|
592 |
|
593 //now append up to KCentRepFindBufSize settings |
|
594 for(TInt i = 0; i < numInitial; i++) |
|
595 { |
|
596 ASSERT(settings[i]); |
|
597 // all settings flagged as deleted should have been removed by now, but just to be safe: |
|
598 ASSERT(!settings[i]->IsDeleted()); |
|
599 settingsToSend.AppendL(settings[i]->Key()); |
|
600 } |
|
601 |
|
602 //fill the iFindResult array with any remaining settings that we were not able to send |
|
603 //with the first ipc |
|
604 if(numFinal) |
|
605 { |
|
606 for(TInt i = numInitial; i < numSettings; i++) |
|
607 { |
|
608 ASSERT(settings[i]); |
|
609 // all settings flagged as deleted should have been removed by now, but just to be safe: |
|
610 ASSERT(!settings[i]->IsDeleted()); |
|
611 iFindResult.AppendL(settings[i]->Key()); |
|
612 } |
|
613 } |
|
614 |
|
615 //send: |
|
616 //1 - the count of total settings found |
|
617 //2 - the settings that fit in the buffer allocated for the first IPC |
|
618 TPtrC8 p(reinterpret_cast<TUint8*>(&(settingsToSend[0])), (numInitial+1)*sizeof(TUint32)); |
|
619 error = aMessage.Write(3, p); |
|
620 CleanupStack::PopAndDestroy(); //settingsToSend |
|
621 } |
|
622 } |
|
623 |
|
624 if(error != KErrNone) |
|
625 { |
|
626 iFindResult.Reset(); |
|
627 if ((error != KErrNone) && (error != KErrNotFound)) |
|
628 { |
|
629 CleanupStack::PopAndDestroy(); //settings |
|
630 // ServiceError will fail transaction |
|
631 User::Leave(error); |
|
632 } |
|
633 } |
|
634 CleanupStack::PopAndDestroy(); //settings |
|
635 return error; |
|
636 } |
|
637 |
|
638 TInt CServerSession::FindEqIntL(const TClientRequest& aMessage) |
|
639 { |
|
640 TInt val = aMessage.Int2(); |
|
641 // PlatSec check done in FindValueL |
|
642 return FindValueL(aMessage, val); |
|
643 } |
|
644 |
|
645 TInt CServerSession::FindEqRealL(const TClientRequest& aMessage) |
|
646 { |
|
647 TReal val; |
|
648 TPckg<TReal> p(val); |
|
649 aMessage.Read(2, p); |
|
650 // PlatSec check done in FindValueL |
|
651 return FindValueL(aMessage, val); |
|
652 } |
|
653 |
|
654 TInt CServerSession::FindEqStringL(const TClientRequest& aMessage) |
|
655 { |
|
656 TBuf8<KMaxBinaryLength> val; |
|
657 aMessage.ReadL(2, val); // no error if too long, truncated instead |
|
658 // PlatSec check done in FindValueL |
|
659 return FindValueL(aMessage, val); |
|
660 } |
|
661 |
|
662 TInt CServerSession::FindNeqIntL(const TClientRequest& aMessage) |
|
663 { |
|
664 TInt val = aMessage.Int2(); |
|
665 // PlatSec check done in FindValueL |
|
666 return FindValueL(aMessage, val, ENotEqual); |
|
667 } |
|
668 |
|
669 TInt CServerSession::FindNeqRealL(const TClientRequest& aMessage) |
|
670 { |
|
671 TReal val; |
|
672 TPckg<TReal> p(val); |
|
673 aMessage.Read(2, p); |
|
674 // PlatSec check done in FindValueL |
|
675 return FindValueL(aMessage, val, ENotEqual); |
|
676 } |
|
677 |
|
678 TInt CServerSession::FindNeqStringL(const TClientRequest& aMessage) |
|
679 { |
|
680 TBuf8<KMaxBinaryLength> val; |
|
681 aMessage.ReadL(2, val); // no error if too long, truncated instead |
|
682 // PlatSec check done in FindValueL |
|
683 return FindValueL(aMessage, val, ENotEqual); |
|
684 } |
|
685 |
|
686 template <class T> |
|
687 TInt CServerSession::FindValueL(const TClientRequest& aMessage, const T& aVal, |
|
688 TComparison aComparison) |
|
689 { |
|
690 // IMPORTANT PLATSEC NOTE: |
|
691 // MUST return KErrPermissionDenied if read policy of ANY setting in the search range not passed. |
|
692 // MUST NOT merely check read policy of matching entries, otherwise it is possible to determine |
|
693 // secret values by brute force: Using single-value ranges, cycling through the possible values and |
|
694 // confirming a match when it returns KErrPermissionDenied rather than KErrNotFound. |
|
695 TInt partialId = aMessage.Int0(); |
|
696 TInt idMask = aMessage.Int1(); |
|
697 // we reset results first since we do not police GetResult |
|
698 // and this way we can guarantee no results are available if access not granted |
|
699 iFindResult.Reset(); |
|
700 RSettingPointerArray settings; |
|
701 CleanupClosePushL(settings); |
|
702 TInt error = iRepository.FindSettings(partialId, idMask, settings); |
|
703 if (error == KErrNone) |
|
704 { |
|
705 error = iRepository.MakeComparisonFindResultsCheckingReadPolicies(settings, aMessage, |
|
706 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::FindValueL - Attempt made to search settings"), |
|
707 aVal, aComparison, iFindResult); |
|
708 |
|
709 if ((error == KErrNone) && (iFindResult.Count() == 0)) |
|
710 { |
|
711 error = KErrNotFound; |
|
712 } |
|
713 |
|
714 if(error == KErrNone) |
|
715 { |
|
716 const TInt numSettings = iFindResult.Count(); |
|
717 const TInt numInitial = numSettings > KCentRepFindBufSize ? KCentRepFindBufSize : numSettings; |
|
718 RArray<TUint32> settingsToSend; |
|
719 CleanupClosePushL(settingsToSend); |
|
720 |
|
721 //reserve memory for everything that needs to be added to the array |
|
722 settingsToSend.Reserve(numInitial); |
|
723 |
|
724 //first append the number of found settings |
|
725 settingsToSend.AppendL(numSettings); |
|
726 |
|
727 //now append up to KCentRepFindBufSize settings |
|
728 for(TInt i = 0; i < numInitial; i++) |
|
729 { |
|
730 settingsToSend.AppendL(iFindResult[0]); |
|
731 iFindResult.Remove(0); |
|
732 } |
|
733 |
|
734 if(iFindResult.Count() == 0) |
|
735 { |
|
736 iFindResult.Reset(); |
|
737 } |
|
738 |
|
739 //send: |
|
740 //1 - the count of total settings found |
|
741 //2 - the settings that fit in the buffer allocated for the first IPC |
|
742 TPtrC8 p(reinterpret_cast<TUint8*>(&(settingsToSend[0])), (numInitial+1)*sizeof(TUint32)); |
|
743 error = aMessage.Write(3, p); |
|
744 CleanupStack::PopAndDestroy(); //settingsToSend |
|
745 } |
|
746 } |
|
747 |
|
748 if ((error != KErrNone) && (error != KErrNotFound) && (error != KErrPermissionDenied)) |
|
749 { |
|
750 iFindResult.Reset(); |
|
751 CleanupStack::PopAndDestroy(); //settings |
|
752 |
|
753 // ServiceError will fail transaction |
|
754 User::Leave(error); |
|
755 } |
|
756 |
|
757 CleanupStack::PopAndDestroy(); //settings |
|
758 return error; |
|
759 } |
|
760 |
|
761 TInt CServerSession::GetFindResultL(const TClientRequest& aMessage) |
|
762 { |
|
763 TInt n = iFindResult.Count(); |
|
764 if (n == 0) |
|
765 { |
|
766 // should never call this if it's zero |
|
767 return KErrNotFound; |
|
768 } |
|
769 TPtrC8 p(reinterpret_cast<TUint8*>(&(iFindResult[0])), n*sizeof(TUint32)); |
|
770 TInt error = aMessage.Write(0, p); |
|
771 // Free up iFindResult - it's no longer needed |
|
772 iFindResult.Reset(); |
|
773 // ServiceError will fail transaction |
|
774 return User::LeaveIfError(error); |
|
775 } |
|
776 |
|
777 TInt CServerSession::NotifyRequestCheck(const TClientRequest& aMessage) |
|
778 { |
|
779 TUint32 key = aMessage.Int0(); |
|
780 if(KErrNone != CheckPolicy(aMessage,iRepository.GetReadAccessPolicy(key), |
|
781 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::NotifyRequestCheck - Attempt made to check Notify request"))) |
|
782 return KErrPermissionDenied; |
|
783 |
|
784 return iRepository.GetPersistentSetting(key) ? KErrNone : KErrNotFound; |
|
785 } |
|
786 |
|
787 TInt CServerSession::NotifyRequest(const TClientRequest& aMessage) |
|
788 { |
|
789 TUint32 key = aMessage.Int0(); |
|
790 if(KErrNone != CheckPolicy(aMessage,iRepository.GetReadAccessPolicy(key), |
|
791 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::NotifyRequest - Attempt made to register for Notify"))) |
|
792 return KErrPermissionDenied; |
|
793 TInt r = iNotifier.AddRequest(key, aMessage); |
|
794 return r==KErrNone ? KDontComplete : r; |
|
795 } |
|
796 |
|
797 TInt CServerSession::NotifyCancel(const TClientRequest& aMessage) |
|
798 { |
|
799 TUint32 key = aMessage.Int0(); |
|
800 return iNotifier.CancelRequest(key); |
|
801 } |
|
802 |
|
803 TInt CServerSession::NotifyCancelAll(const TClientRequest& /*aMessage*/) |
|
804 { |
|
805 return iNotifier.CancelAllRequests(); |
|
806 } |
|
807 |
|
808 TInt CServerSession::GroupNotifyRequest(const TClientRequest& aMessage) |
|
809 { |
|
810 TUint32 partialId = aMessage.Int0(); |
|
811 TUint32 idMask = aMessage.Int1(); |
|
812 RSettingPointerArray settings; |
|
813 TInt error = iRepository.FindPersistentSettings(partialId, idMask, settings); |
|
814 if (error == KErrNone) |
|
815 { |
|
816 error = iRepository.CheckReadPermissions(settings, aMessage, |
|
817 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::GroupNotifyRequest - Attempt made to register for group Notify")); |
|
818 } |
|
819 settings.Reset(); |
|
820 if (error != KErrNone) |
|
821 { |
|
822 return KErrPermissionDenied; |
|
823 } |
|
824 |
|
825 error = iNotifier.AddRequest(partialId, idMask, aMessage); |
|
826 return error==KErrNone ? KDontComplete : error; |
|
827 } |
|
828 |
|
829 TInt CServerSession::GroupNotifyCancel(const TClientRequest& aMessage) |
|
830 { |
|
831 const TUint32 partialId = aMessage.Int0(); |
|
832 const TUint32 idMask = aMessage.Int1(); |
|
833 RSettingPointerArray settings; |
|
834 TInt error = iRepository.FindPersistentSettings(partialId, idMask, settings); |
|
835 settings.Reset(); |
|
836 if (error != KErrNone) |
|
837 { |
|
838 return error; |
|
839 } |
|
840 |
|
841 return iNotifier.CancelRequest(partialId, idMask); |
|
842 } |
|
843 |
|
844 TInt CServerSession::ResetL(const TClientRequest& aMessage) |
|
845 { |
|
846 // individual setting reset is not yet supported in transactions |
|
847 ASSERT(!iRepository.IsInTransaction()); |
|
848 TUint32 key = aMessage.Int0(); |
|
849 if(KErrNone != CheckPolicy(aMessage,iRepository.GetWriteAccessPolicy(key), |
|
850 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::ResetL - Attempt made to reset a setting"))) |
|
851 return iRepository.FailTransaction(KErrPermissionDenied, key); |
|
852 |
|
853 TInt r = iRepository.ResetL(key); |
|
854 |
|
855 return r; |
|
856 } |
|
857 |
|
858 TInt CServerSession::ResetAllL(const TClientRequest& aMessage) |
|
859 { |
|
860 // factory reset operation is not yet supported in transactions |
|
861 ASSERT(!iRepository.IsInTransaction()); |
|
862 if(KErrNone != CheckPolicy(aMessage,iRepository.GetDefaultWriteAccessPolicy(), |
|
863 __PLATSEC_DIAGNOSTIC_STRING("CenRep: CServerSession::ResetAllL - Attempt made to reset repository"))) |
|
864 return KErrPermissionDenied; |
|
865 |
|
866 iNotifier.IdReportingOff(); |
|
867 TInt r = iRepository.ResetAllL(); |
|
868 iNotifier.IdReportingOn(); |
|
869 |
|
870 if(r==KErrNone) |
|
871 iRepository.CommitChangesL(); // temporary measure |
|
872 |
|
873 return r; |
|
874 } |
|
875 |
|
876 TInt CServerSession::MoveL(const TClientRequest& aMessage) |
|
877 { |
|
878 if (iRepository.IsInActiveReadTransaction()) |
|
879 { |
|
880 // could not promote to read/write: fail & give the source partialKey as the error key |
|
881 TUint32 sourcePartialKey = aMessage.Int0(); |
|
882 return iRepository.FailTransaction(KErrLocked, sourcePartialKey); |
|
883 } |
|
884 TUint32 errorKey = KUnspecifiedKey; |
|
885 TInt result = iRepository.TransactionMoveL(aMessage, errorKey); |
|
886 if (result != KErrNone) |
|
887 { |
|
888 TPckg<TUint32> p(errorKey); |
|
889 aMessage.WriteL(3, p); |
|
890 } |
|
891 return result; |
|
892 } |
|
893 |
|
894 TInt CServerSession::TransactionStart(const TClientRequest& aMessage) |
|
895 { |
|
896 // panic client if attempting to start a transaction when already in one |
|
897 __ASSERT_ALWAYS(!iRepository.IsInTransaction(), PanicClient(EStartAlreadyInTransaction, aMessage)); |
|
898 |
|
899 const TInt mode = aMessage.Int0(); |
|
900 return iRepository.StartTransaction(mode); |
|
901 } |
|
902 |
|
903 // serves as both rollback and async cancel |
|
904 TInt CServerSession::TransactionCancel(const TClientRequest& /*aMessage*/) |
|
905 { |
|
906 iRepository.CancelTransaction(); |
|
907 return KErrNone; |
|
908 } |
|
909 |
|
910 TInt CServerSession::TransactionCommitL(const TClientRequest& aMessage) |
|
911 { |
|
912 __ASSERT_ALWAYS(iRepository.IsInTransaction(), PanicClient(ECommitNotInTransaction, aMessage)); |
|
913 |
|
914 TUint32 keyInfo = KUnspecifiedKey; |
|
915 TInt result = iRepository.CommitTransaction(keyInfo); |
|
916 |
|
917 TPckg<TUint32> p(keyInfo); |
|
918 aMessage.WriteL(0, p); |
|
919 |
|
920 return result; |
|
921 } |
|
922 |
|
923 TInt CServerSession::DeleteRangeL(const TClientRequest& aMessage) |
|
924 { |
|
925 if (iRepository.IsInActiveReadTransaction()) |
|
926 { |
|
927 // could not promote to read/write: fail & give the partialKey as the error key |
|
928 TUint32 partialKey = aMessage.Int0(); |
|
929 return iRepository.FailTransaction(KErrLocked, partialKey); |
|
930 } |
|
931 TUint32 errorKey = KUnspecifiedKey; |
|
932 TInt result = iRepository.TransactionDeleteRangeL(aMessage, errorKey); |
|
933 if (result != KErrNone) |
|
934 { |
|
935 TPckg<TUint32> p(errorKey); |
|
936 aMessage.WriteL(2, p); |
|
937 } |
|
938 return result; |
|
939 } |
|
940 |
|
941 TInt CServerSession::TransactionStateL(const TClientRequest& aMessage) |
|
942 { |
|
943 TInt iState = iRepository.TransactionState(); |
|
944 |
|
945 TPckg<TInt> p(iState); |
|
946 aMessage.WriteL(0, p); |
|
947 |
|
948 return KErrNone; |
|
949 } |
|
950 |
|
951 TInt CServerSession::TransactionFail(const TClientRequest& /*aMessage*/) |
|
952 { |
|
953 iRepository.FailTransaction(KErrAbort, KUnspecifiedKey); |
|
954 return KErrNone; |
|
955 } |
|
956 |
|
957 /** |
|
958 @internalTechnology |
|
959 Check the security policy against a RMessage. |
|
960 */ |
|
961 TInt CServerSession::CheckPolicy(const TClientRequest& msg, |
|
962 const TSecurityPolicy& aPolicy, |
|
963 const char *aDiagnostic) |
|
964 { |
|
965 return msg.CheckPolicy(aPolicy,aDiagnostic) ? KErrNone : KErrPermissionDenied; |
|
966 } |
|
967 |
|
968 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
969 // DoEventStart |
|
970 // Save initial values of timer and MEM allocated. |
|
971 void CServerSession::DoEventStart() |
|
972 { |
|
973 if(iPerfData.IsFinished()) |
|
974 return; |
|
975 |
|
976 iStartTick = User::FastCounter(); |
|
977 } |
|
978 |
|
979 // DoEventEnd |
|
980 // store CPU and MEM usage, time of event, etc. in performance |
|
981 // array. |
|
982 void CServerSession::DoEventEnd(TUint aEventId) |
|
983 { |
|
984 if (iPerfData.IsFinished()) |
|
985 return; |
|
986 |
|
987 TUint32 endTick = User::FastCounter(); |
|
988 |
|
989 // Performance data has 3 parts. First: time spent to |
|
990 // service the request. 2nd if event is open/close/evict |
|
991 // time of the event. 3rd, if open/close/evict repository UID |
|
992 |
|
993 // First part: event ID and CPU time spent servicing the request |
|
994 TUint32 entry = EncodeEventAndData(aEventId, endTick - iStartTick); |
|
995 iPerfData.Append(entry); |
|
996 |
|
997 if (aEventId == EInitialise) |
|
998 iPerfData.SessionOpen(); |
|
999 |
|
1000 TBool repOpenCloseEvict = aEventId == EInitialise || aEventId == ESessionClose || aEventId == EEvict; |
|
1001 |
|
1002 // Third part: repository UID if event is open/close/evict. |
|
1003 if (repOpenCloseEvict) |
|
1004 { |
|
1005 iPerfData.Append(iStartTick); |
|
1006 iPerfData.Append(iRepositoryUid); // Append will check if array IsFull. |
|
1007 } |
|
1008 |
|
1009 // One last thing to do: check if all concurrent sessions close. |
|
1010 if (aEventId == ESessionClose) |
|
1011 { |
|
1012 iPerfData.SessionClose(); |
|
1013 |
|
1014 // This is a temporary solution to detect end-of-boot until SS code is |
|
1015 // modified to return end-of-boot state and Centrep becomes SSA |
|
1016 if (iRepositoryUid == 0xCCCCCC00) |
|
1017 { |
|
1018 iPerfData.IncEndOfBoot(); |
|
1019 } |
|
1020 } |
|
1021 } |
|
1022 #endif // __CENTREP_SERVER_PERFTEST__ |
|
1023 |
|
1024 |
|
1025 #if defined(__CENTREP_SERVER_PERFTEST__) || defined (__CENTREP_SERVER_MEMTEST__) || defined(__CENTREP_SERVER_CACHETEST__) |
|
1026 // GetSetParameters |
|
1027 // The function code EGetSetParameters is a generic msg reserved |
|
1028 // for testing purpose. Int0 specifies the function to perform. |
|
1029 TInt CServerSession::GetSetParameters(const TClientRequest& aMessage) |
|
1030 { |
|
1031 TServerGetSetParametersSubCmd cmd = static_cast<TServerGetSetParametersSubCmd>(aMessage.Int0()); |
|
1032 |
|
1033 #ifdef __CENTREP_SERVER_PERFTEST__ |
|
1034 if (cmd == EGetPerfResults) |
|
1035 { |
|
1036 TInt desSize = aMessage.GetDesMaxLength(1); |
|
1037 TInt numVals = desSize / sizeof(TUint32); |
|
1038 if (numVals < KCentRepPerfTestArraySize) |
|
1039 { |
|
1040 return KErrOverflow; |
|
1041 } |
|
1042 TPtrC8 p(reinterpret_cast<const TUint8*>(iPerfData.Entries()), |
|
1043 KCentRepPerfTestArraySize * sizeof(TUint32)); |
|
1044 TInt ret = aMessage.Write(1, p); |
|
1045 if (ret == KErrNone) |
|
1046 { |
|
1047 TUint lastCompleteAccess = iPerfData.LastCompleteAccess(); |
|
1048 TPckg<TUint> p2(lastCompleteAccess); |
|
1049 ret = aMessage.Write(2, p2); |
|
1050 } |
|
1051 return ret; |
|
1052 } |
|
1053 else if (cmd == ERestartPerfTests) |
|
1054 { |
|
1055 iPerfData.Reset(); |
|
1056 return KErrNone; |
|
1057 } |
|
1058 else if (cmd == EStopPerfTests) |
|
1059 { |
|
1060 iPerfData.Stop(); |
|
1061 return KErrNone; |
|
1062 } |
|
1063 #endif // __CENTREP_SERVER_PERFTEST__ |
|
1064 |
|
1065 #ifdef __CENTREP_SERVER_MEMTEST__ |
|
1066 if(cmd == EGetMemResults) |
|
1067 { |
|
1068 TInt count = TServerResources::iMemTestDataCount; |
|
1069 TPckg<TInt> pCount(count); |
|
1070 |
|
1071 TInt err = aMessage.Write(1, pCount); |
|
1072 if(err == KErrNone && count > 0) |
|
1073 { |
|
1074 TPtrC8 pBuf(reinterpret_cast<TUint8*>(TServerResources::iMemTestData), (TServerResources::iMemTestDataCount)*sizeof(TInt32)); |
|
1075 err = aMessage.Write(2, pBuf); |
|
1076 } |
|
1077 // Stop recording results |
|
1078 TServerResources::StopRecordTimerResult(); |
|
1079 return err; |
|
1080 } |
|
1081 #endif // __CENTREP_SERVER_MEMTEST__ |
|
1082 |
|
1083 #ifdef __CENTREP_SERVER_CACHETEST__ |
|
1084 if (cmd == EEnableCache) |
|
1085 { |
|
1086 // First parameter is Timer Interval, second is cache size |
|
1087 TServerResources::iCacheManager->EnableCache(aMessage.Int1(), aMessage.Int2()); |
|
1088 return KErrNone; |
|
1089 } |
|
1090 |
|
1091 if (cmd == EDisableCache) |
|
1092 { |
|
1093 TServerResources::iCacheManager->DisableCache(); |
|
1094 return KErrNone; |
|
1095 } |
|
1096 #endif // __CENTREP_SERVER_CACHETEST__ |
|
1097 return KErrNotSupported; |
|
1098 } |
|
1099 #endif // __CENTREP_SERVER_PERFTEST__ || __CENTREP_SERVER_MEMTEST__ || __CENTREP_SERVER_CACHETEST__ |