|
1 /** @file |
|
2 * Copyright (c) 2005-2006 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: Declares virtual MUpnpNotifyTimerObserver callback class |
|
15 * and the implemented active object class CUpnpNotifyTimer |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #ifndef C_CUPNPNOTIFYTIMER_H |
|
21 #define C_CUPNPNOTIFYTIMER_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 |
|
26 // CONSTANTS |
|
27 static const TInt KSecond = 1000000; |
|
28 // Max number of seconds we can pass to RTime::After |
|
29 static const TInt KOneIterationSeconds = 1800; |
|
30 |
|
31 // FORWARD DECLARATIONS |
|
32 class CUpnpNotifyTimer; |
|
33 |
|
34 // CLASS DECLARATION |
|
35 /** |
|
36 * An interface from notifytimer to its customer (service) |
|
37 * |
|
38 * @since Series60 2.0 |
|
39 */ |
|
40 class MUpnpNotifyTimerObserver |
|
41 { |
|
42 public: |
|
43 |
|
44 /** |
|
45 * TimerEventL |
|
46 * A callback function to time updates. |
|
47 * @since Series60 2.0 |
|
48 * @param aTimer A pointer containing updated time. |
|
49 * @return None |
|
50 */ |
|
51 virtual void TimerEventL( CUpnpNotifyTimer* aTimer ) = 0; |
|
52 |
|
53 /** |
|
54 * TimerEventError |
|
55 * Called when RunL leaves. By default no implementation needed. |
|
56 * @since Series60 3.2 |
|
57 * @param aError Leave error |
|
58 * @return Error |
|
59 */ |
|
60 virtual void TimerEventError( CUpnpNotifyTimer* /*aTimer*/, TInt /*aError*/ ) |
|
61 { |
|
62 } |
|
63 |
|
64 }; |
|
65 |
|
66 // CLASS DECLARATION |
|
67 /** |
|
68 * Wrapper for RTimer classs to notify observer about elaspsed time |
|
69 * |
|
70 * @since Series60 2.0 |
|
71 */ |
|
72 class CUpnpNotifyTimer : public CActive |
|
73 { |
|
74 protected: |
|
75 |
|
76 /** |
|
77 * Constructor |
|
78 */ |
|
79 IMPORT_C CUpnpNotifyTimer( MUpnpNotifyTimerObserver* aObserver ); |
|
80 |
|
81 public: |
|
82 IMPORT_C static CUpnpNotifyTimer* NewL(MUpnpNotifyTimerObserver* aObserver); |
|
83 |
|
84 void ConstructL(); |
|
85 |
|
86 /** |
|
87 * Destructor. |
|
88 */ |
|
89 ~CUpnpNotifyTimer(); |
|
90 |
|
91 /** |
|
92 * At |
|
93 * @since Series60 2.0 |
|
94 * @param aTime |
|
95 */ |
|
96 IMPORT_C void AfterSeconds( TInt aIntervalInSeconds ); |
|
97 |
|
98 /** |
|
99 * After |
|
100 * @since Series60 2.0 |
|
101 * @param aInterval |
|
102 * @param aUnused this is unused now |
|
103 */ |
|
104 IMPORT_C void After( TInt aInterval = 1, TBool aUnused = EFalse ); |
|
105 |
|
106 /** |
|
107 * After |
|
108 * @since Series60 2.0 |
|
109 * @param aInterval |
|
110 * @param aUnused this is unused now |
|
111 */ |
|
112 IMPORT_C void After( TTimeIntervalMicroSeconds32 aInterval, TBool aUnused ); |
|
113 |
|
114 /** |
|
115 * Start |
|
116 * Start the CUpnpNotifyTimer object. |
|
117 * @since Series60 2.0 |
|
118 * @param aInterval |
|
119 * @param aUnused this is unused now |
|
120 */ |
|
121 IMPORT_C void Start( TTimeIntervalMicroSeconds32 aInterval, |
|
122 TBool aUnused = EFalse); |
|
123 |
|
124 /** |
|
125 * RunL |
|
126 * Active object state machine. |
|
127 * @since Series60 2.0 |
|
128 */ |
|
129 void RunL(); |
|
130 |
|
131 /** |
|
132 * RunError |
|
133 * RunError in case RunL leaves. |
|
134 * @since Series60 2.0 |
|
135 */ |
|
136 TInt RunError( TInt aError ); |
|
137 |
|
138 /** |
|
139 * DoCancel |
|
140 * Cancel outstanding request(s) and reset the iActive flag. |
|
141 * @since Series60 2.0 |
|
142 */ |
|
143 IMPORT_C void DoCancel(); |
|
144 |
|
145 /** |
|
146 * CompleteOneselfImmediate |
|
147 * Immediate completes oneself by call of User::RequestComplete(). |
|
148 * @since Series60 3.2 |
|
149 */ |
|
150 IMPORT_C void CompleteOneselfImmediate(); |
|
151 |
|
152 private: |
|
153 |
|
154 /** |
|
155 * StartNextIteration |
|
156 * only for internal use, decrease repeat counter |
|
157 * and waits for KOneIterationSeconds seconds it is required for long |
|
158 * run timers because of RTimer::After 32 bit limitation - about 35 minutes |
|
159 */ |
|
160 void StartNextIteration(); |
|
161 |
|
162 // Data |
|
163 |
|
164 // Interface observer object, owned |
|
165 MUpnpNotifyTimerObserver* iObserver; |
|
166 |
|
167 // Interval variable, owned |
|
168 TTimeIntervalMicroSeconds32 iInterval; |
|
169 |
|
170 // Timer, owned |
|
171 RTimer iTimer; |
|
172 |
|
173 // How many times timer need to be run for 30min |
|
174 // after that timer will run for {(total time) mod (1800)} seconds |
|
175 TInt iIterationsToRun; |
|
176 }; |
|
177 |
|
178 |
|
179 #endif // C_CUPNPNOTIFYTIMER_H |
|
180 |
|
181 // End Of File |