|
1 /* |
|
2 * Copyright (c) 2002-2004 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: USSD Reply Timer. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CPhSrvUssdReplyTimer.h" |
|
22 #include "MPhSrvUssdReplyTimerObserver.h" |
|
23 |
|
24 |
|
25 // CONSTANTS |
|
26 const TUint KPhSrvUssdReplyTimerInterval = 300000000; // 5 min |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CPhSrvUssdReplyTimer::CPhSrvUssdReplyTimer |
|
33 // |
|
34 // Constructor |
|
35 // |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CPhSrvUssdReplyTimer::CPhSrvUssdReplyTimer( |
|
39 MPhSrvUssdReplyTimerObserver& aObserver ) |
|
40 : CTimer( CActive::EPriorityStandard ), |
|
41 iObserver( aObserver ) |
|
42 { |
|
43 CActiveScheduler::Add( this ); |
|
44 } |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CPhSrvUssdReplyTimer::NewL |
|
49 // Two-phased constructor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CPhSrvUssdReplyTimer* CPhSrvUssdReplyTimer::NewL( |
|
53 MPhSrvUssdReplyTimerObserver& aObserver ) |
|
54 { |
|
55 CPhSrvUssdReplyTimer* self = |
|
56 new( ELeave ) CPhSrvUssdReplyTimer( aObserver ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop(); // self |
|
60 return self; |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CPhSrvUssdReplyTimer::~CPhSrvUssdReplyTimer |
|
66 // |
|
67 // Destructor |
|
68 // |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CPhSrvUssdReplyTimer::~CPhSrvUssdReplyTimer() |
|
72 { |
|
73 Cancel(); |
|
74 iTimer.Close(); |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CPhSrvUssdReplyTimer::ConstructL |
|
80 // |
|
81 // Symbian OS second phase constructor |
|
82 // |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CPhSrvUssdReplyTimer::ConstructL() |
|
86 { |
|
87 CTimer::ConstructL(); |
|
88 } |
|
89 |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CPhSrvUssdReplyTimer::IsTimerActive |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 TBool CPhSrvUssdReplyTimer::IsTimerActive() const |
|
96 { |
|
97 return iTimeLeft.Int() != 0; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CPhSrvUssdReplyTimer::Start |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 void CPhSrvUssdReplyTimer::Start() |
|
106 { |
|
107 Cancel(); |
|
108 iTimeLeft = KPhSrvUssdReplyTimerInterval; |
|
109 iLastStartTime.UniversalTime(); |
|
110 After( iTimeLeft ); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CPhSrvUssdReplyTimer::Pause |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CPhSrvUssdReplyTimer::Pause() |
|
119 { |
|
120 if ( !IsActive() ) |
|
121 { |
|
122 return; |
|
123 } |
|
124 Cancel(); |
|
125 iTimeLeft = KPhSrvUssdReplyTimerInterval; |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CPhSrvUssdReplyTimer::Continue |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 void CPhSrvUssdReplyTimer::Continue() |
|
134 { |
|
135 if ( IsActive() ) |
|
136 { |
|
137 return; |
|
138 } |
|
139 |
|
140 if ( iTimeLeft.Int() <= 0 ) |
|
141 { |
|
142 iTimeLeft = 0; |
|
143 TRAP_IGNORE( iObserver.UssdReplyTimerObserverHandleExpiredL( KErrNone ) ); |
|
144 return; |
|
145 } |
|
146 |
|
147 iLastStartTime.UniversalTime(); |
|
148 After( iTimeLeft ); |
|
149 } |
|
150 |
|
151 |
|
152 // ----------------------------------------------------------------------------- |
|
153 // CPhSrvUssdReplyTimer::Stop |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void CPhSrvUssdReplyTimer::Stop() |
|
157 { |
|
158 Cancel(); |
|
159 iTimeLeft = 0; |
|
160 } |
|
161 |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CPhSrvUssdReplyTimer::RunL |
|
165 // |
|
166 // Called when the timer expires. Notify observer |
|
167 // |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CPhSrvUssdReplyTimer::RunL() |
|
171 { |
|
172 // Called only when status is KErrNone, since when the system |
|
173 // time is changed, timers may be completed with KErrAbort. |
|
174 iTimeLeft = 0; |
|
175 if ( iStatus.Int() == KErrNone ) |
|
176 { |
|
177 iObserver.UssdReplyTimerObserverHandleExpiredL( KErrNone ); |
|
178 } |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CPhSrvUssdReplyTimer::RunError |
|
184 // |
|
185 // Called when RunL leaves. |
|
186 // The RunL can leave in observer side, then it is ok to just return KErrNone. |
|
187 // |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 TInt CPhSrvUssdReplyTimer::RunError( TInt /*aError*/ ) |
|
191 { |
|
192 return KErrNone; |
|
193 } |
|
194 |
|
195 |
|
196 // End of File |