|
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 #include <hash.h> |
|
29 |
|
30 |
|
31 const TInt KRandomBlockSize=1024; |
|
32 const TInt KRandomPoolSize=2048; |
|
33 |
|
34 class CRandomScheduler:public CActiveScheduler |
|
35 { |
|
36 public: |
|
37 static TBool New(void); |
|
38 void Error(TInt aError) const; |
|
39 }; |
|
40 |
|
41 class CRandomSession; |
|
42 |
|
43 class CRandomServer : public CServer2 |
|
44 { |
|
45 public: |
|
46 static CRandomServer* NewL(void); |
|
47 ~CRandomServer(void); |
|
48 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const; |
|
49 friend class CRandomSession; |
|
50 private: |
|
51 CRandomServer(void); |
|
52 void ConstructL(void); |
|
53 void Stir(void); |
|
54 TPtrC8 GetRandom(void); |
|
55 CMessageDigest* Hash(void) const; |
|
56 static TInt Tick(TAny* aPointer); |
|
57 TUint8* iPool; |
|
58 TInt iPoolIn; |
|
59 TInt iPoolOut; |
|
60 TInt iQuality; |
|
61 TBool iFast; |
|
62 CMessageDigest* iHash; |
|
63 CPeriodic* iTicker; |
|
64 }; |
|
65 |
|
66 class CRandomSession : public CSession2 |
|
67 { |
|
68 public: |
|
69 enum { KRandomRequest }; |
|
70 static CRandomSession* NewL(CRandomServer* aServer); |
|
71 ~CRandomSession(void); |
|
72 void ServiceL(const RMessage2& aMessage); |
|
73 private: |
|
74 TInt FillBuffer(const RMessage2& aMessage); |
|
75 CRandomServer* iServer; |
|
76 CRandomSession(CRandomServer* aServer); |
|
77 }; |
|
78 |
|
79 #endif // RANDSVRIMPL_H |