|
1 /* |
|
2 * Copyright (c) 2005-2007 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_STUNTIMERUSER_H |
|
22 #define C_STUNTIMERUSER_H |
|
23 |
|
24 // INCLUDES |
|
25 #include <e32base.h> |
|
26 |
|
27 // FORWARD DECLARATIONS |
|
28 class CDeltaTimer; |
|
29 |
|
30 // CLASS DECLARATION |
|
31 /* |
|
32 * This class stores basic timer information needed for using CDeltaTimer. |
|
33 */ |
|
34 class CSTUNTimerUser : public CBase |
|
35 { |
|
36 public: // Constructor and destructor |
|
37 |
|
38 /** |
|
39 * Constructor. |
|
40 * |
|
41 * @param aDeltaTimer CDeltaTimer to provide timer services |
|
42 * @return value New CSTUNTimerUser object. Ownership is transferred. |
|
43 */ |
|
44 CSTUNTimerUser( CDeltaTimer& aDeltaTimer ); |
|
45 |
|
46 /** |
|
47 * Frees the resources of CSTUNTimerUser. If a timer is currently |
|
48 * running, it is stopped. |
|
49 */ |
|
50 ~CSTUNTimerUser(); |
|
51 |
|
52 public: // New pure virtual functions |
|
53 |
|
54 /** |
|
55 * Handles the timer expiration event. |
|
56 */ |
|
57 virtual void TimerExpiredL() = 0; |
|
58 |
|
59 /** |
|
60 * Called if leave occurred from TimerExpiredL. |
|
61 * @pre aError != KErrNone |
|
62 * @param aError Leave value from TimerExpiredL |
|
63 */ |
|
64 virtual void LeaveFromTimerExpired( TInt aError ) = 0; |
|
65 |
|
66 protected: // New functions |
|
67 |
|
68 /** |
|
69 * Start a timer. Only one timer can be running at a time. |
|
70 * @param aDuration Timer duration in milliseconds |
|
71 */ |
|
72 void StartTimer( TInt aDuration ); |
|
73 |
|
74 /** |
|
75 * Stop the timer. |
|
76 */ |
|
77 void StopTimer(); |
|
78 |
|
79 /** |
|
80 * This function is called by CDeltaTimer when a timer entry has expired. |
|
81 * @param aPtr Parameter that was specified when the timer was started. |
|
82 */ |
|
83 static TInt TimerExpired( TAny *aPtr ); |
|
84 |
|
85 /** |
|
86 * Obtain the CDeltaTimer instance. |
|
87 * @return CDeltaTimer |
|
88 */ |
|
89 CDeltaTimer& DeltaTimer(); |
|
90 |
|
91 /** |
|
92 * Obtain information is timer running or not |
|
93 * |
|
94 * @since s60 3.2 |
|
95 * @return ETrue if running, else EFalse |
|
96 */ |
|
97 TBool IsRunning() const; |
|
98 |
|
99 private: |
|
100 |
|
101 CSTUNTimerUser(); |
|
102 |
|
103 CSTUNTimerUser( const CSTUNTimerUser& aTimerUser ); |
|
104 |
|
105 private: // New functions, for internal use |
|
106 |
|
107 /** |
|
108 * Converts a duration of milliseconds to microseconds and returns a |
|
109 * TTimeIntervalMicroSeconds32 object, which can be passed to |
|
110 * CDeltaTimer. |
|
111 * @pre aMilliseconds <= KMaxTInt32 / 1000 |
|
112 * @param aMilliseconds Duration in milliseconds |
|
113 * @return TTimeIntervalMicroSeconds32 Duration converted to microseconds |
|
114 * @panic KErrOverflow In debug build, panics if aMilliseconds has too |
|
115 * large value. In release build, the duration is |
|
116 * decreased to a maximum value, if it is too large. |
|
117 */ |
|
118 TTimeIntervalMicroSeconds32 TimerDuration( TInt aMilliseconds ); |
|
119 |
|
120 protected: // Data |
|
121 |
|
122 CDeltaTimer& iDeltaTimer; |
|
123 |
|
124 private: // Data |
|
125 |
|
126 //Identifies the running timer so that it can be canceled. |
|
127 TDeltaTimerEntry iTimerEntry; |
|
128 |
|
129 //ETrue if a timer is currently running |
|
130 TBool iIsRunning; |
|
131 |
|
132 private: // For testing purposes |
|
133 |
|
134 #ifdef TEST_EUNIT |
|
135 friend class CSTUNClientImplementationTest; |
|
136 friend class CSTUNSharedSecretTest; |
|
137 friend class CSTUNBindingImplementationTest; |
|
138 friend class CSTUNTransactionTest; |
|
139 #endif |
|
140 }; |
|
141 |
|
142 #endif // end of C_STUNTIMERUSER_H |
|
143 |
|
144 // End of File |