1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
13 * |
13 * |
14 * Description: voip audio service - |
14 * Description: voip audio service - |
15 * |
15 * |
16 */ |
16 */ |
17 |
|
18 |
|
19 |
17 |
20 #include "VoIPAudioServicesTestClass.h" |
18 #include "VoIPAudioServicesTestClass.h" |
21 #include "debug.h" |
19 #include "debug.h" |
22 |
20 |
23 /* |
21 /* |
24 ------------------------------------------------------------------------------- |
22 ------------------------------------------------------------------------------- |
25 |
23 |
26 Class: CSimpleTimeout |
24 Class: CSimpleTimeout |
27 |
25 |
28 Method: CSimpleTimeout |
26 Method: CSimpleTimeout |
29 |
27 |
30 Description: voip audio service - Default constructor |
28 Description: voip audio service - Default constructor |
31 |
29 |
32 C++ default constructor can NOT contain any code, that |
30 C++ default constructor can NOT contain any code, that might leave. |
33 might leave. |
31 |
34 |
32 Parameters: None |
35 Parameters: None |
33 |
36 |
34 Return Values: None |
37 Return Values: None |
35 |
38 |
36 ------------------------------------------------------------------------------- |
39 Errors/Exceptions: None |
37 */ |
40 |
38 CSimpleTimeout::CSimpleTimeout() : |
41 Status: Approved |
39 CActive(CActive::EPriorityStandard) |
42 |
40 { |
43 ------------------------------------------------------------------------------- |
|
44 */ |
|
45 CSimpleTimeout::CSimpleTimeout() : CActive (CActive::EPriorityStandard) |
|
46 { |
|
47 FTRACE(FPrint(_L("CSimpleTimeout::CSimpleTimeout"))); |
41 FTRACE(FPrint(_L("CSimpleTimeout::CSimpleTimeout"))); |
48 } |
42 } |
49 |
43 |
50 /* |
44 /* |
51 ------------------------------------------------------------------------------- |
45 ------------------------------------------------------------------------------- |
52 |
46 |
53 Class: CSimpleTimeout |
47 Class: CSimpleTimeout |
54 |
48 |
55 Method: ConstructL |
49 Method: ConstructL |
56 |
50 |
57 Description: voip audio service - Symbian OS second phase constructor |
51 Description: voip audio service - Symbian OS second phase constructor |
58 |
52 |
59 Symbian OS default constructor can leave. |
53 Symbian OS default constructor can leave. |
60 |
54 |
61 Parameters: |
55 Parameters: |
62 |
56 |
63 Return Values: None |
57 Return Values: None |
64 |
58 |
65 Errors/Exceptions: |
59 ------------------------------------------------------------------------------- |
66 |
60 */ |
67 Status: Approved |
61 void CSimpleTimeout::ConstructL(MTimeoutObserver* aObserver, |
68 |
62 CStifLogger* aLogger) |
69 ------------------------------------------------------------------------------- |
63 { |
70 */ |
|
71 void CSimpleTimeout::ConstructL( MTimeoutObserver* aObserver, |
|
72 CStifLogger* aLogger) |
|
73 { |
|
74 FTRACE(FPrint(_L("CSimpleTimeout::ConstructL"))); |
64 FTRACE(FPrint(_L("CSimpleTimeout::ConstructL"))); |
75 iObserver = aObserver; |
65 iObserver = aObserver; |
76 iLog = aLogger; |
66 iLog = aLogger; |
77 iTimer.CreateLocal(); |
67 iTimer.CreateLocal(); |
78 iTestCaseTimeout = 0; // Initialize |
68 iTestCaseTimeout = 0; // Initialize |
79 |
69 |
80 // Add to active scheduler |
70 // Add to active scheduler |
81 CActiveScheduler::Add ( this ); |
71 CActiveScheduler::Add(this); |
82 } |
72 } |
83 |
73 |
84 /* |
74 /* |
85 ------------------------------------------------------------------------------- |
75 ------------------------------------------------------------------------------- |
86 |
76 |
87 Class: CSimpleTimeout |
77 Class: CSimpleTimeout |
88 |
78 |
89 Method: NewL |
79 Method: NewL |
90 |
80 |
91 Description: voip audio service - Two-phased constructor. |
81 Description: voip audio service - Two-phased constructor. |
92 |
82 |
93 Parameters: const TTestReportOutput aReportOutput: in: Report output type |
83 Parameters: const TTestReportOutput aReportOutput: in: Report output type |
94 |
84 |
95 Return Values: CSimpleTimeout* : pointer to created object |
85 Return Values: CSimpleTimeout* : pointer to created object |
96 |
86 |
97 Errors/Exceptions: Leaves if memory allocation for object fails |
87 Errors/Exceptions: Leaves if memory allocation for object fails |
98 Leaves if ConstructL leaves |
88 Leaves if ConstructL leaves |
99 |
89 |
100 Status: Approved |
90 ------------------------------------------------------------------------------- |
101 |
91 */ |
102 ------------------------------------------------------------------------------- |
92 CSimpleTimeout* CSimpleTimeout::NewL(MTimeoutObserver* aTestClass, |
103 */ |
93 CStifLogger* aLogger) |
104 CSimpleTimeout* CSimpleTimeout::NewL( MTimeoutObserver* aTestClass, |
94 { |
105 CStifLogger* aLogger) |
|
106 { |
|
107 FTRACE(FPrint(_L("CSimpleTimeout::NewL"))); |
95 FTRACE(FPrint(_L("CSimpleTimeout::NewL"))); |
108 CSimpleTimeout* self = new ( ELeave ) CSimpleTimeout(); |
96 CSimpleTimeout* self = new (ELeave) CSimpleTimeout(); |
109 CleanupStack::PushL( self ); |
97 CleanupStack::PushL(self); |
110 self->ConstructL( aTestClass, aLogger); |
98 self->ConstructL(aTestClass, aLogger); |
111 CleanupStack::Pop( self ); |
99 CleanupStack::Pop(self); |
112 return self; |
100 return self; |
113 |
101 } |
114 } |
102 |
115 |
103 /* |
116 /* |
104 ------------------------------------------------------------------------------- |
117 ------------------------------------------------------------------------------- |
105 |
118 |
106 Class: CSimpleTimeout |
119 Class: CSimpleTimeout |
107 |
120 |
108 Method: ~CSimpleTimeout |
121 Method: ~CSimpleTimeout |
109 |
122 |
110 Description: voip audio service - Destructor. |
123 Description: voip audio service - Destructor. |
111 |
124 |
112 Cancel request |
125 Cancel request |
113 |
126 |
114 Parameters: None |
127 Parameters: None |
115 |
128 |
116 Return Values: None |
129 Return Values: None |
117 |
130 |
118 Errors/Exceptions: None |
131 Errors/Exceptions: None |
119 |
132 |
120 Status: Approved |
133 Status: Approved |
121 |
134 |
122 ------------------------------------------------------------------------------- |
135 ------------------------------------------------------------------------------- |
123 */ |
136 */ |
|
137 CSimpleTimeout::~CSimpleTimeout() |
124 CSimpleTimeout::~CSimpleTimeout() |
138 { |
125 { |
139 FTRACE(FPrint(_L("CSimpleTimeout::~CSimpleTimeout"))); |
126 FTRACE(FPrint(_L("CSimpleTimeout::~CSimpleTimeout"))); |
140 Cancel(); |
127 Cancel(); |
141 iTimer.Close(); |
128 iTimer.Close(); |
142 } |
129 } |
143 |
130 |
144 /* |
131 /* |
145 ------------------------------------------------------------------------------- |
132 ------------------------------------------------------------------------------- |
146 |
133 |
147 Class: CSimpleTimeout |
134 Class: CSimpleTimeout |
148 |
135 |
149 Method: Start |
136 Method: Start |
150 |
137 |
151 Description: voip audio service - Start timeout counting |
138 Description: voip audio service - Start timeout counting |
152 |
139 |
153 Parameters: None |
140 Parameters: None |
154 |
141 |
155 Return Values: None |
142 Return Values: None |
156 |
143 |
157 Errors/Exceptions: None |
144 Errors/Exceptions: None |
158 |
145 |
159 Status: Approved |
146 Status: Approved |
160 |
147 |
161 ------------------------------------------------------------------------------- |
148 ------------------------------------------------------------------------------- |
162 */ |
149 */ |
163 void CSimpleTimeout::Start(TTimeIntervalMicroSeconds aTimeout) |
150 void CSimpleTimeout::Start(TTimeIntervalMicroSeconds aTimeout) |
164 { |
151 { |
165 FTRACE(FPrint(_L("CSimpleTimeout::Start"))); |
152 FTRACE(FPrint(_L("CSimpleTimeout::Start"))); |
166 if (IsActive()) |
153 if (IsActive()) |
167 { |
154 { |
168 Cancel(); |
155 Cancel(); |
169 } |
156 } |
170 |
157 |
171 // Request timer |
158 // Request timer |
172 TTime endTime; |
159 TTime endTime; |
173 endTime.HomeTime(); |
160 endTime.HomeTime(); |
174 endTime = endTime + aTimeout; |
161 endTime = endTime + aTimeout; |
185 |
172 |
186 // Taken from STIF engine |
173 // Taken from STIF engine |
187 // Note: iTimer.After() method cannot use because there needed |
174 // Note: iTimer.After() method cannot use because there needed |
188 // TTimeIntervalMicroSeconds32 and it is 32 bit. So then cannot create |
175 // TTimeIntervalMicroSeconds32 and it is 32 bit. So then cannot create |
189 // timeout time that is long enough. At() uses 64 bit value=>Long enough. |
176 // timeout time that is long enough. At() uses 64 bit value=>Long enough. |
190 iTimer.At( iStatus, endTime ); |
177 iTimer.At(iStatus, endTime); |
191 SetActive(); |
178 SetActive(); |
192 } |
179 } |
193 |
180 |
194 |
181 /* |
195 /* |
182 ------------------------------------------------------------------------------- |
196 ------------------------------------------------------------------------------- |
183 |
197 |
184 Class: CSimpleTimeout |
198 Class: CSimpleTimeout |
185 |
199 |
186 Method: Start |
200 Method: Start |
187 |
201 |
188 Description: voip audio service - Start timeout counting |
202 Description: voip audio service - Start timeout counting |
189 |
203 |
190 Parameters: None |
204 Parameters: None |
191 |
205 |
192 Return Values: None |
206 Return Values: None |
193 |
207 |
194 Errors/Exceptions: None |
208 Errors/Exceptions: None |
195 |
209 |
196 Status: Approved |
210 Status: Approved |
197 |
211 |
198 ------------------------------------------------------------------------------- |
212 ------------------------------------------------------------------------------- |
199 */ |
213 */ |
|
214 void CSimpleTimeout::Stop() |
200 void CSimpleTimeout::Stop() |
215 { |
201 { |
216 FTRACE(FPrint(_L("CSimpleTimeout::Stop"))); |
202 FTRACE(FPrint(_L("CSimpleTimeout::Stop"))); |
217 if (IsActive()) |
203 if (IsActive()) |
218 { |
204 { |
219 Cancel(); |
205 Cancel(); |
220 } |
206 } |
221 } |
207 } |
222 /* |
208 /* |
223 ------------------------------------------------------------------------------- |
209 ------------------------------------------------------------------------------- |
224 |
210 |
225 Class: CSimpleTimeout |
211 Class: CSimpleTimeout |
226 |
212 |
227 Method: RunL |
213 Method: RunL |
228 |
214 |
229 Description: voip audio service - RunL handles completed timeouts. |
215 Description: voip audio service - RunL handles completed timeouts. |
230 |
216 |
231 Parameters: None |
217 Parameters: None |
232 |
218 |
233 Return Values: None |
219 Return Values: None |
234 |
220 |
235 Errors/Exceptions: None |
221 Errors/Exceptions: None |
236 |
222 |
237 Status: Approved |
223 Status: Approved |
238 |
224 |
239 ------------------------------------------------------------------------------- |
225 ------------------------------------------------------------------------------- |
240 */ |
226 */ |
241 void CSimpleTimeout::RunL() |
227 void CSimpleTimeout::RunL() |
242 { |
228 { |
243 FTRACE(FPrint(_L("CSimpleTimeout::RunL"))); |
229 FTRACE(FPrint(_L("CSimpleTimeout::RunL"))); |
244 iLog->Log(_L("CSimpleTimeout::RunL")); |
230 iLog->Log(_L("CSimpleTimeout::RunL")); |
245 TTime timeout; |
231 TTime timeout; |
246 timeout.HomeTime(); |
232 timeout.HomeTime(); |
247 // Handle the abort case when system time gets changed, but timeout is |
233 // Handle the abort case when system time gets changed, but timeout is |
248 // still valid. All other cases should timeout since they invalidate the |
234 // still valid. All other cases should timeout since they invalidate the |
249 // logic of the timers. |
235 // logic of the timers. |
250 if ( iStatus == KErrAbort) |
236 if (iStatus == KErrAbort) |
251 { |
|
252 if ( iTestCaseTimeout > timeout ) |
|
253 { |
237 { |
254 RDebug::Print( _L( "Absolute timer still valid. Restaring timer. iStatus: %d" ), iStatus.Int() ); |
238 if (iTestCaseTimeout > timeout) |
|
239 { |
|
240 RDebug::Print(_L( "Absolute timer still valid. Restaring timer. iStatus: %d" ), |
|
241 iStatus.Int()); |
255 // Start new timer |
242 // Start new timer |
256 iStatus = KErrNone; // reset value |
243 iStatus = KErrNone; // reset value |
257 iTimer.At ( iStatus, iTestCaseTimeout ); // restart timer |
244 iTimer.At(iStatus, iTestCaseTimeout); // restart timer |
258 SetActive(); |
245 SetActive(); |
259 } |
246 } |
260 else |
247 else |
261 { |
248 { |
262 // Absolute timer no longer valid. Must timeout. |
249 // Absolute timer no longer valid. Must timeout. |
263 iLog->Log(_L("Absolute timeout no longer valid")); |
250 iLog->Log(_L("Absolute timeout no longer valid")); |
264 iObserver->HandleTimeout(KErrNone); |
251 iObserver->HandleTimeout(KErrNone); |
|
252 } |
265 } |
253 } |
266 |
|
267 } |
|
268 else |
254 else |
269 { |
255 { |
270 // Status was not KErrAbort. Timing out! |
256 // Status was not KErrAbort. Timing out! |
271 // iLog->Log(_L("CSimpleTimeout::RunL - Timeout !!"), iTimeout); |
257 // iLog->Log(_L("CSimpleTimeout::RunL - Timeout !!"), iTimeout); |
272 iLog->Log(_L("Timing out")); |
258 iLog->Log(_L("Timing out")); |
273 iObserver->HandleTimeout(KErrNone); |
259 iObserver->HandleTimeout(KErrNone); |
274 } |
260 } |
275 |
261 } |
276 } |
262 |
277 |
263 /* |
278 /* |
264 ------------------------------------------------------------------------------- |
279 ------------------------------------------------------------------------------- |
265 |
280 |
266 Class: CSimpleTimeout |
281 Class: CSimpleTimeout |
267 |
282 |
268 Method: DoCancel |
283 Method: DoCancel |
269 |
284 |
270 Description: voip audio service - Cancel active request |
285 Description: voip audio service - Cancel active request |
271 |
286 |
272 Parameters: None |
287 Parameters: None |
273 |
288 |
274 Return Values: None |
289 Return Values: None |
275 |
290 |
276 Errors/Exceptions: None |
291 Errors/Exceptions: None |
277 |
292 |
278 Status: Approved |
293 Status: Approved |
279 |
294 |
280 ------------------------------------------------------------------------------- |
295 ------------------------------------------------------------------------------- |
281 */ |
296 */ |
|
297 void CSimpleTimeout::DoCancel() |
282 void CSimpleTimeout::DoCancel() |
298 { |
283 { |
299 FTRACE(FPrint(_L("CSimpleTimeout::DoCancel"))); |
284 FTRACE(FPrint(_L("CSimpleTimeout::DoCancel"))); |
300 iTimer.Cancel(); |
285 iTimer.Cancel(); |
301 } |
286 } |
302 |
287 |
303 /* |
288 /* |
304 ------------------------------------------------------------------------------- |
289 ------------------------------------------------------------------------------- |
305 |
290 |
306 Class: CSimpleTimeout |
291 Class: CSimpleTimeout |
307 |
292 |
308 Method: RunError |
293 Method: RunError |
309 |
294 |
310 Description: voip audio service - Handle errors. Just let framework handle errors because |
295 Description: Handle errors. Just let framework handle errors because |
311 RunL does not leave. |
296 RunL does not leave. |
312 |
297 |
313 Parameters: TInt aError: in: Symbian OS error: Error code |
298 Parameters: TInt aError: in: Symbian OS error: Error code |
314 |
299 |
315 Return Values: TInt: Symbian OS error code |
300 Return Values: TInt: Symbian OS error code |
316 |
301 |
317 Errors/Exceptions: None |
302 Errors/Exceptions: None |
318 |
303 |
319 Status: Approved |
304 Status: Approved |
320 |
305 |
321 ------------------------------------------------------------------------------- |
306 ------------------------------------------------------------------------------- |
322 */ |
307 */ |
323 TInt CSimpleTimeout::RunError( TInt aError ) |
308 TInt CSimpleTimeout::RunError(TInt aError) |
324 { |
309 { |
325 FTRACE(FPrint(_L("CSimpleTimeout::RunError"))); |
310 FTRACE(FPrint(_L("CSimpleTimeout::RunError"))); |
326 iLog->Log(_L("Timeout error %d"), aError); |
311 iLog->Log(_L("Timeout error %d"), aError); |
327 iObserver->HandleTimeout(aError); |
312 iObserver->HandleTimeout(aError); |
328 return aError; |
313 return aError; |
329 } |
314 } |
330 |
315 |