|
1 /* |
|
2 * Copyright (c) 2002 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 * CSecObsNotify - starts and cancels notifier plug-ins. |
|
16 * Handles PIN/PIN2/PUK/PUK2/... notifiers |
|
17 * |
|
18 */ |
|
19 |
|
20 |
|
21 // Include Files |
|
22 #include "SecObsNotify.h" |
|
23 #include "SecurityObserver.h" |
|
24 #include <SecurityNotifier.h> |
|
25 |
|
26 #ifndef RD_STARTUP_CHANGE |
|
27 #include <SysStartup.h> |
|
28 #endif //RD_STARTUP_CHANGE |
|
29 |
|
30 #include "SecurityObserver.hrh" |
|
31 |
|
32 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
33 #include <SCPClient.h> |
|
34 #endif //__SAP_TERMINAL_CONTROL_FW |
|
35 |
|
36 //=========================================================== |
|
37 // MEMBER FUNCTIONS |
|
38 //=========================================================== |
|
39 // |
|
40 // ---------------------------------------------------------- |
|
41 // CSecObsNotify::NewL() |
|
42 // Constructs a new entry with given values. |
|
43 // ---------------------------------------------------------- |
|
44 // |
|
45 CSecObsNotify* CSecObsNotify::NewL(CSecurityObserver* aObserver) |
|
46 { |
|
47 CSecObsNotify* self = new(ELeave) CSecObsNotify(aObserver); |
|
48 CleanupStack::PushL(self); |
|
49 self->ConstructL(); |
|
50 CleanupStack::Pop(); |
|
51 return self; |
|
52 } |
|
53 // |
|
54 // ---------------------------------------------------------- |
|
55 // CSecObsNotify::~CSecObsNotify |
|
56 // C++ destructor. |
|
57 // ---------------------------------------------------------- |
|
58 // |
|
59 CSecObsNotify::~CSecObsNotify() |
|
60 { |
|
61 Cancel(); |
|
62 delete iPhoneObserver; |
|
63 } |
|
64 // |
|
65 // ---------------------------------------------------------- |
|
66 // CSecObsNotify::CSecObsNotify |
|
67 // C++ constructor |
|
68 // ---------------------------------------------------------- |
|
69 // |
|
70 CSecObsNotify::CSecObsNotify(CSecurityObserver* aObserver) : CActive(0), |
|
71 iObserver(aObserver), |
|
72 iActiveNotifier(ESecurityNotifierNone), |
|
73 iPendingNotifier(ESecurityNotifierNone) |
|
74 { |
|
75 } |
|
76 // |
|
77 // ---------------------------------------------------------- |
|
78 // CSecObsNotify::ConstructL |
|
79 // Adds this active object to the scheduler. |
|
80 // ---------------------------------------------------------- |
|
81 // |
|
82 void CSecObsNotify::ConstructL() |
|
83 { |
|
84 // Add this active object to the scheduler. |
|
85 CActiveScheduler::Add(this); |
|
86 iPhoneObserver = CPhoneObserver::NewL(this,iObserver); |
|
87 } |
|
88 |
|
89 // |
|
90 // ---------------------------------------------------------- |
|
91 // CSecObsNotify::RunL |
|
92 // |
|
93 // ---------------------------------------------------------- |
|
94 // |
|
95 void CSecObsNotify::RunL() |
|
96 { |
|
97 #if defined(_DEBUG) |
|
98 RDebug::Print(_L("CSecObsNotify::RunL()")); |
|
99 #endif |
|
100 #ifndef RD_STARTUP_CHANGE |
|
101 |
|
102 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
103 if (iActiveNotifier == ESecurityNotifierUPin) |
|
104 { |
|
105 if (iObserver->IsUPinRequired() && !iObserver->IsUPukRequired() && SysStartup::State() != ESWStateNormal) |
|
106 { |
|
107 iPhoneObserver->Stop(); |
|
108 iPhoneObserver->Start(iActiveNotifier); |
|
109 } |
|
110 } |
|
111 |
|
112 #endif //__PROTOCOL_WCDMA || __UPIN |
|
113 if (iActiveNotifier == ESecurityNotifierPin1) |
|
114 { |
|
115 if (iObserver->IsPin1Required() && !iObserver->IsPuk1Required() && SysStartup::State() != ESWStateNormal) |
|
116 { |
|
117 iPhoneObserver->Stop(); |
|
118 iPhoneObserver->Start(iActiveNotifier); |
|
119 } |
|
120 } |
|
121 #endif // RD_STARTUP_CHANGE |
|
122 |
|
123 if (iActiveNotifier == ESecurityNotifierPuk1) |
|
124 { |
|
125 if (iObserver->IsPuk1Required()) |
|
126 { |
|
127 iPhoneObserver->Stop(); |
|
128 iPhoneObserver->Start(iActiveNotifier); |
|
129 } |
|
130 } |
|
131 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
132 if (iActiveNotifier == ESecurityNotifierUPuk) |
|
133 { |
|
134 if (iObserver->IsUPukRequired()) |
|
135 { |
|
136 iPhoneObserver->Stop(); |
|
137 iPhoneObserver->Start(iActiveNotifier); |
|
138 } |
|
139 } |
|
140 #endif //__PROTOCOL_WCDMA || __UPIN |
|
141 |
|
142 #ifndef RD_STARTUP_CHANGE |
|
143 |
|
144 if (iActiveNotifier == ESecurityNotifierSecurityCode) |
|
145 { |
|
146 #if defined(_DEBUG) |
|
147 RDebug::Print(_L("CSecObsNotify::RunL(): ESecurityNotifierSecurityCode")); |
|
148 #endif |
|
149 if (iObserver->IsPassPhraseRequired() && SysStartup::State() != ESWStateNormal) |
|
150 { |
|
151 #if defined(_DEBUG) |
|
152 RDebug::Print(_L("CSecObsNotify::RunL(): ESecurityNotifierSecurityCode: IF")); |
|
153 #endif |
|
154 iPhoneObserver->Stop(); |
|
155 iPhoneObserver->Start(iActiveNotifier); |
|
156 #if defined(_DEBUG) |
|
157 RDebug::Print(_L("CSecObsNotify::RunL(): ESecurityNotifierSecurityCode: IF: END")); |
|
158 #endif |
|
159 } |
|
160 } |
|
161 #endif // RD_STARTUP_CHANGE |
|
162 |
|
163 CancelActiveNotifier(); |
|
164 |
|
165 if (iPendingNotifier != ESecurityNotifierNone) |
|
166 { |
|
167 #if defined(_DEBUG) |
|
168 RDebug::Print(_L("CSecObsNotify::RunL(): start pending notifier")); |
|
169 #endif |
|
170 // previous notifier cancelled and we have pending notifier |
|
171 StartNotifier(iPendingNotifier); |
|
172 |
|
173 #ifndef RD_STARTUP_CHANGE |
|
174 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
175 if(((iPendingNotifier == ESecurityNotifierPuk1) || (iPendingNotifier == ESecurityNotifierUPuk)) && iObserver->IsPassPhraseRequired()) |
|
176 #else |
|
177 if((iPendingNotifier == ESecurityNotifierPuk1) && iObserver->IsPassPhraseRequired()) |
|
178 #endif //__PROTOCOL_WCDMA || __UPIN |
|
179 { |
|
180 //PUK code query has been written in top of Sec code query in boot; |
|
181 //it arrived before PIN code event was completed and Sec code event |
|
182 //could be moved from pending to active. Putting sec code event |
|
183 //back to pending event. |
|
184 iPendingNotifier=ESecurityNotifierSecurityCode; |
|
185 } |
|
186 else |
|
187 { |
|
188 iPendingNotifier=ESecurityNotifierNone; |
|
189 } |
|
190 #else // RD_STARTUP_CHANGE |
|
191 iPendingNotifier=ESecurityNotifierNone; |
|
192 #endif // RD_STARTUP_CHANGE |
|
193 } |
|
194 |
|
195 } |
|
196 // |
|
197 // ---------------------------------------------------------- |
|
198 // CSecObsNotify::CancelActiveNotifier |
|
199 // Cancels notifier |
|
200 // ---------------------------------------------------------- |
|
201 // |
|
202 void CSecObsNotify::CancelActiveNotifier() |
|
203 { |
|
204 if (iActiveNotifier != ESecurityNotifierNone) |
|
205 { |
|
206 iNotifier.CancelNotifier(KSecurityNotifierUid); |
|
207 iNotifier.Close(); |
|
208 iActiveNotifier=ESecurityNotifierNone; |
|
209 } |
|
210 } |
|
211 // |
|
212 // ---------------------------------------------------------- |
|
213 // CSecObsNotify::StartNotifier |
|
214 // Starts given notifier asyncronously |
|
215 // ---------------------------------------------------------- |
|
216 // |
|
217 void CSecObsNotify::StartNotifier( TSecurityNotifier aNotifierToStart ) |
|
218 { |
|
219 #if defined(_DEBUG) |
|
220 RDebug::Print(_L("CSecObsNotify::StartNotifier")); |
|
221 #endif |
|
222 |
|
223 #ifdef __SAP_TERMINAL_CONTROL_FW |
|
224 // Check with the SCP Server whether this notification request resulted from an admin command, |
|
225 // we're only interested in the security code events |
|
226 if ( aNotifierToStart == ESecurityNotifierSecurityCode ) |
|
227 { |
|
228 TBool isNormalCall = ETrue; |
|
229 |
|
230 RSCPClient SCPClient; |
|
231 if ( SCPClient.Connect() == KErrNone ) |
|
232 { |
|
233 if ( SCPClient.QueryAdminCmd( ESCPCommandLockPhone ) ) |
|
234 { |
|
235 #if defined(_DEBUG) |
|
236 RDebug::Print(_L("CSecObsNotify::SCP admin command, no action required")); |
|
237 #endif |
|
238 |
|
239 isNormalCall = EFalse; |
|
240 } |
|
241 |
|
242 SCPClient.Close(); |
|
243 } |
|
244 |
|
245 if ( !isNormalCall ) |
|
246 { |
|
247 // Nothing further to be done in this method |
|
248 return; |
|
249 } |
|
250 } |
|
251 #endif //__SAP_TERMINAL_CONTROL_FW |
|
252 |
|
253 if(IsActive()) |
|
254 { |
|
255 #if defined(_DEBUG) |
|
256 RDebug::Print(_L("CSecObsNotify::StartNotifier IsActive")); |
|
257 #endif |
|
258 |
|
259 if (iActiveNotifier != ESecurityNotifierNone) |
|
260 { |
|
261 #if defined(_DEBUG) |
|
262 RDebug::Print(_L("CSecObsNotify::StartNotifier: iActiveNotifier != ESecurityNotifierNone")); |
|
263 #endif |
|
264 iPendingNotifier = aNotifierToStart; // to be started when previous has ended |
|
265 return; |
|
266 } |
|
267 |
|
268 } |
|
269 #if defined(_DEBUG) |
|
270 RDebug::Print(_L("CSecObsNotify::StartNotifier: SWITCH")); |
|
271 #endif |
|
272 TInt err = KErrNone; |
|
273 switch (aNotifierToStart) |
|
274 { |
|
275 #if defined(__PROTOCOL_WCDMA) || defined(__UPIN) |
|
276 case ESecurityNotifierUPin: |
|
277 { |
|
278 #if defined(_DEBUG) |
|
279 RDebug::Print(_L("CSecObsNotify::StartNotifier: UPin")); |
|
280 #endif |
|
281 err = iNotifier.Connect(); |
|
282 if(err == KErrNone) |
|
283 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KUPinRequired,iDummy); |
|
284 break; |
|
285 } |
|
286 case ESecurityNotifierUPuk: |
|
287 { |
|
288 #if defined(_DEBUG) |
|
289 RDebug::Print(_L("CSecObsNotify::StartNotifier: UPuk")); |
|
290 #endif |
|
291 err = iNotifier.Connect(); |
|
292 if(err == KErrNone) |
|
293 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KUPukRequired,iDummy); |
|
294 break; |
|
295 } |
|
296 #endif //__PROTOCOL_WCDMA |
|
297 case ESecurityNotifierPin1: |
|
298 { |
|
299 #if defined(_DEBUG) |
|
300 RDebug::Print(_L("CSecObsNotify::StartNotifier: Pin1")); |
|
301 #endif |
|
302 err = iNotifier.Connect(); |
|
303 if(err == KErrNone) |
|
304 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KPin1Required,iDummy); |
|
305 break; |
|
306 } |
|
307 case ESecurityNotifierPuk1: |
|
308 { |
|
309 #if defined(_DEBUG) |
|
310 RDebug::Print(_L("CSecObsNotify::StartNotifier: Puk1")); |
|
311 #endif |
|
312 err = iNotifier.Connect(); |
|
313 if(err == KErrNone) |
|
314 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KPuk1Required,iDummy); |
|
315 break; |
|
316 } |
|
317 case ESecurityNotifierPin2: |
|
318 { |
|
319 #if defined(_DEBUG) |
|
320 RDebug::Print(_L("CSecObsNotify::StartNotifier: Pin2")); |
|
321 #endif |
|
322 err = iNotifier.Connect(); |
|
323 if(err == KErrNone) |
|
324 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KPin2Required,iDummy); |
|
325 break; |
|
326 } |
|
327 case ESecurityNotifierPuk2: |
|
328 { |
|
329 #if defined(_DEBUG) |
|
330 RDebug::Print(_L("CSecObsNotify::StartNotifier: Puk2")); |
|
331 #endif |
|
332 err = iNotifier.Connect(); |
|
333 if(err == KErrNone) |
|
334 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KPuk2Required,iDummy); |
|
335 break; |
|
336 } |
|
337 case ESecurityNotifierSecurityCode: |
|
338 { |
|
339 #if defined(_DEBUG) |
|
340 RDebug::Print(_L("CSecObsNotify::StartNotifier: Security Code")); |
|
341 #endif |
|
342 #if defined(_DEBUG) |
|
343 RDebug::Print(_L("CSecObsNotify::StartNotifier ESecurityNotifierSecurityCode")); |
|
344 #endif |
|
345 err = iNotifier.Connect(); |
|
346 if(err == KErrNone) |
|
347 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KPassPhraseRequired,iDummy); |
|
348 #if defined(_DEBUG) |
|
349 RDebug::Print(_L("CSecObsNotify::StartNotifier SEC: StartNotifierAndGetResponse")); |
|
350 #endif |
|
351 break; |
|
352 } |
|
353 case ESecuritySimLockRestrictionOn: |
|
354 { |
|
355 #if defined(_DEBUG) |
|
356 RDebug::Print(_L("CSecObsNotify::StartNotifier: Sim Lock")); |
|
357 #endif |
|
358 err = iNotifier.Connect(); |
|
359 if(err == KErrNone) |
|
360 iNotifier.StartNotifierAndGetResponse(iStatus, KSecurityNotifierUid, KSimTerminated,iDummy); |
|
361 break; |
|
362 } |
|
363 default: |
|
364 iActiveNotifier = ESecurityNotifierNone; |
|
365 return; |
|
366 } |
|
367 if (err != KErrNone) |
|
368 { |
|
369 _LIT(panicCategory, "SecObsNotify PANIC"); |
|
370 TInt reason(1); |
|
371 User::Panic(panicCategory, reason); |
|
372 } |
|
373 |
|
374 iActiveNotifier = aNotifierToStart; |
|
375 #if defined(_DEBUG) |
|
376 RDebug::Print(_L("CSecObsNotify::StartNotifier SetActive")); |
|
377 #endif |
|
378 SetActive(); |
|
379 } |
|
380 |
|
381 // |
|
382 // ---------------------------------------------------------- |
|
383 // CSecObsNotify::StartNotifier |
|
384 // Close open notifier |
|
385 // ---------------------------------------------------------- |
|
386 // |
|
387 void CSecObsNotify::DoCancel() |
|
388 { |
|
389 CancelActiveNotifier(); |
|
390 } |
|
391 |
|
392 // End of File |