|
1 /* |
|
2 * Copyright (c) 2009-2010 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 * This class implements a system tick based timer service. |
|
16 * |
|
17 */ |
|
18 |
|
19 /* |
|
20 * %version: 1 % |
|
21 */ |
|
22 |
|
23 #include "wlanticktimer.h" |
|
24 #include "am_debug.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 CWlanTickTimer::CWlanTickTimer( |
|
32 const TCallBack& aTimerExpiredCB, |
|
33 const TCallBack& aTimerCancelledCB, |
|
34 const TCallBack& aTimerErrorCB ) : |
|
35 CActive( CActive::EPriorityStandard ), |
|
36 iTimerExpiredCB( aTimerExpiredCB ), |
|
37 iTimerCancelledCB( aTimerCancelledCB ), |
|
38 iTimerErrorCB( aTimerErrorCB ) |
|
39 { |
|
40 // No implementation required |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void CWlanTickTimer::ConstructL() |
|
47 { |
|
48 User::LeaveIfError( iTimer.CreateLocal() ); |
|
49 CActiveScheduler::Add( this ); |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CWlanTickTimer* CWlanTickTimer::NewL( |
|
56 const TCallBack& aTimerExpiredCB, |
|
57 const TCallBack& aTimerCancelledCB, |
|
58 const TCallBack& aTimerErrorCB ) |
|
59 { |
|
60 CWlanTickTimer* self = new (ELeave) CWlanTickTimer( |
|
61 aTimerExpiredCB, |
|
62 aTimerCancelledCB, |
|
63 aTimerErrorCB ); |
|
64 CleanupStack::PushL( self ); |
|
65 self->ConstructL(); |
|
66 CleanupStack::Pop( self ); |
|
67 return self; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CWlanTickTimer::~CWlanTickTimer() |
|
74 { |
|
75 iTimer.Close(); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 void CWlanTickTimer::After( |
|
82 TUint aTicks ) |
|
83 { |
|
84 DEBUG1( "CWlanTickTimer::After() - aTicks: %u", |
|
85 aTicks ); |
|
86 |
|
87 iTimer.AfterTicks( |
|
88 iStatus, |
|
89 aTicks ); |
|
90 SetActive(); |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 void CWlanTickTimer::RunL() |
|
97 { |
|
98 DEBUG1( "CWlanTickTimer::RunL() - iStatus: %d", |
|
99 iStatus.Int() ); |
|
100 |
|
101 switch( iStatus.Int() ) |
|
102 { |
|
103 case KErrNone: // Timer expired |
|
104 iTimerExpiredCB.CallBack(); |
|
105 break; |
|
106 case KErrCancel: // Timer cancelled |
|
107 iTimerCancelledCB.CallBack(); |
|
108 break; |
|
109 default: // Timer error code |
|
110 iTimerErrorCB.CallBack(); |
|
111 } |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 TInt CWlanTickTimer::RunError( |
|
118 TInt /* aError */ ) |
|
119 { |
|
120 DEBUG( "CWlanTickTimer::RunError()" ); |
|
121 |
|
122 return 0; |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------------------------- |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 void CWlanTickTimer::DoCancel() |
|
129 { |
|
130 DEBUG( "CWlanTickTimer::DoCancel()" ); |
|
131 |
|
132 iTimer.Cancel(); |
|
133 } |