|
1 /* |
|
2 * Copyright (c) 2003-2009 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 the License "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: |
|
15 * Random Server Codes |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /** |
|
21 @file |
|
22 @internalTechnology |
|
23 */ |
|
24 |
|
25 #ifndef RANDSVRIMPL_H |
|
26 #define RANDSVRIMPL_H |
|
27 |
|
28 |
|
29 const TInt KRandomBlockSize=1024; |
|
30 const TInt KRandomPoolSize=2048; |
|
31 |
|
32 class CRandomScheduler:public CActiveScheduler |
|
33 { |
|
34 public: |
|
35 static TBool New(void); |
|
36 void Error(TInt aError) const; |
|
37 }; |
|
38 |
|
39 class CRandomSession; |
|
40 |
|
41 class CRandomServer : public CServer2 |
|
42 { |
|
43 public: |
|
44 static TInt New(void); |
|
45 ~CRandomServer(void); |
|
46 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
47 friend class CRandomSession; |
|
48 private: |
|
49 CRandomServer(void); |
|
50 void ConstructL(void); |
|
51 void Stir(void); |
|
52 TPtrC8 GetRandom(void); |
|
53 CMessageDigest* Hash(void) const; |
|
54 static TInt Tick(TAny* aPointer); |
|
55 TUint8* iPool; |
|
56 TInt iPoolIn; |
|
57 TInt iPoolOut; |
|
58 TInt iQuality; |
|
59 TBool iFast; |
|
60 CMessageDigest* iHash; |
|
61 CPeriodic* iTicker; |
|
62 }; |
|
63 |
|
64 class CRandomSession : public CSession2 |
|
65 { |
|
66 public: |
|
67 enum { KRandomRequest }; |
|
68 static CRandomSession* NewL(CRandomServer* aServer); |
|
69 ~CRandomSession(void); |
|
70 void ServiceL(const RMessage2& aMessage); |
|
71 private: |
|
72 TInt FillBuffer(const RMessage2& aMessage); |
|
73 CRandomServer* iServer; |
|
74 CRandomSession(CRandomServer* aServer); |
|
75 }; |
|
76 |
|
77 #endif // RANDSVRIMPL_H |