|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef C_CTRANSACTIONIDGENERATOR_H |
|
22 #define C_CTRANSACTIONIDGENERATOR_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 #include "natfwunsaftransactionid.h" |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 |
|
30 // CLASS DECLARATION |
|
31 |
|
32 /** |
|
33 * This class provides unique UNSAF TransactionID values. |
|
34 */ |
|
35 class CTransactionIDGenerator : public CBase |
|
36 { |
|
37 public: // Constructors and destructor |
|
38 |
|
39 /** |
|
40 * Creates a new instance of CTransactionIDGenerator. |
|
41 * @return A new instance of CTransactionIDGenerator, ownership is |
|
42 * transferred. |
|
43 */ |
|
44 static CTransactionIDGenerator* NewL(); |
|
45 |
|
46 ~CTransactionIDGenerator(); |
|
47 |
|
48 public: // New functions |
|
49 |
|
50 /** |
|
51 * Creates a unique UNSAF TransactionID and writes it into |
|
52 * aTransactionID. |
|
53 * |
|
54 * @param aObject IN: Pointer to an object, whose state will be used as a |
|
55 * random input for creating the UNSAF TransactionID. |
|
56 * Ownership is not transferred. |
|
57 * @param aObjectSize Size in bytes, of the object pointed by aObject. |
|
58 * @param aTransactionID OUT: UNSAF TransactionID |
|
59 */ |
|
60 void GetIDL( TAny* aObject, |
|
61 TInt aObjectSize, |
|
62 TNATFWUNSAFTransactionID& aTransactionID ); |
|
63 |
|
64 private: |
|
65 |
|
66 CTransactionIDGenerator(); |
|
67 |
|
68 CTransactionIDGenerator( |
|
69 const CTransactionIDGenerator& aTransactionIDGenerator ); |
|
70 |
|
71 HBufC8* BuildInputDataLC( TAny* aObject, TInt aObjectSize ); |
|
72 |
|
73 void AddClockInfo( TDes8& aBuf ) const; |
|
74 |
|
75 void AddSystemInfo( TDes8& aBuf ) const; |
|
76 |
|
77 void ComputeChecksum( TDes8& aBuf, |
|
78 const TAny* aPtr, |
|
79 TInt aLength ) const; |
|
80 |
|
81 private: // Data |
|
82 |
|
83 //Seed value for Math::Rand() |
|
84 TInt64 iSeed; |
|
85 |
|
86 TUint32 iCounter; |
|
87 |
|
88 private: // For testing purposes |
|
89 |
|
90 #ifdef TEST_EUNIT |
|
91 friend class CSTUNClientImplementationTest; |
|
92 #endif |
|
93 __DECLARE_TEST; |
|
94 }; |
|
95 |
|
96 #endif // C_CTRANSACTIONIDGENERATOR_H |