|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implements the Phone Security manipulation code. |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include "CSimPhone.h" |
|
23 #include "Simlog.h" |
|
24 #include "utils.h" |
|
25 #include "CSimPhoneSecurity.h" |
|
26 #include <testconfigfileparser.h> |
|
27 #include "CSimTsyMode.h" |
|
28 #include <e32math.h> |
|
29 |
|
30 // |
|
31 // CSimPhoneSecurity |
|
32 // |
|
33 const TInt KICCProfileGranularity=5; // < Granularity for Icc profile list array |
|
34 |
|
35 const TInt KDefaultPinEntryAttempts=3; // < default number of PIN entry attempts if not defined in the config file |
|
36 const TInt KDefaultPukEntryAttempts=10; // < default number of PUK entry attempts if not defined in the config file |
|
37 |
|
38 CSimPhoneSecurity* CSimPhoneSecurity::NewL(CSimPhone* aPhone) |
|
39 /** |
|
40 * Standard two phase constructor. |
|
41 * @param aPhone The phone object from which the PhoneSecurity was opened. |
|
42 */ |
|
43 { |
|
44 CSimPhoneSecurity* obj=new(ELeave) CSimPhoneSecurity(aPhone); |
|
45 CleanupStack::PushL(obj); |
|
46 obj->ConstructL(); |
|
47 CleanupStack::Pop(); |
|
48 return obj; |
|
49 } |
|
50 |
|
51 CSimPhoneSecurity::CSimPhoneSecurity(CSimPhone* aPhone) |
|
52 : iPhone(aPhone) |
|
53 /** |
|
54 * Trivial first phase constructor. |
|
55 * @param aPhone The phone object from which this phonebook was opened. |
|
56 */ |
|
57 {} |
|
58 |
|
59 void CSimPhoneSecurity::Init() |
|
60 {} |
|
61 |
|
62 void CSimPhoneSecurity::ConstructL() |
|
63 /** Change |
|
64 * Second phase constructor that allocates memory for the phonebook, batch read buffer and |
|
65 * a delayed completion timer. The constructor also reads the individual and batch read |
|
66 * delays from the configuration file. |
|
67 */ |
|
68 { |
|
69 LOGPHONE1("Starting to parse PhoneSecurity additional config parameters..."); |
|
70 |
|
71 iNotifySettingsTimer = CIccTimer::NewL(); |
|
72 iNotifySecurityEventsTimer = CIccTimer::NewL(); |
|
73 |
|
74 iNotifySettingsTimer->iTimer = CSimTimer::NewL(iPhone); |
|
75 iNotifySecurityEventsTimer->iTimer = CSimTimer::NewL(iPhone); |
|
76 const CTestConfigItem* item=NULL; |
|
77 TInt ret=KErrNone; |
|
78 TInt i; |
|
79 iICCStatusProfile=new(ELeave) CArrayFixFlat<TICCStatusEntry>(KICCProfileGranularity); |
|
80 iICCSettingProfile=new(ELeave) CArrayFixFlat<TICCSettingEntry>(KICCProfileGranularity); |
|
81 |
|
82 item=CfgFile()->Item(KSecurityCodes); |
|
83 if(item) |
|
84 { |
|
85 TPtrC8 temp; |
|
86 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,temp); |
|
87 if(ret!=KErrNone) |
|
88 { |
|
89 LOGPARSERR("temp",ret,0,&KSecurityCodes); |
|
90 } |
|
91 else |
|
92 iSecCodes.iPin1.Copy(temp); |
|
93 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,temp); |
|
94 if(ret!=KErrNone) |
|
95 { |
|
96 LOGPARSERR("temp",ret,1,&KSecurityCodes); |
|
97 } |
|
98 else |
|
99 iSecCodes.iPin2.Copy(temp); |
|
100 |
|
101 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,temp); |
|
102 if(ret!=KErrNone) |
|
103 { |
|
104 LOGPARSERR("temp",ret,2,&KSecurityCodes); |
|
105 } |
|
106 else |
|
107 iSecCodes.iPuk1.Copy(temp); |
|
108 |
|
109 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,temp); |
|
110 if(ret!=KErrNone) |
|
111 { |
|
112 LOGPARSERR("temp",ret,3,&KSecurityCodes); |
|
113 } |
|
114 else |
|
115 iSecCodes.iPuk2.Copy(temp); |
|
116 |
|
117 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,temp); |
|
118 if(ret!=KErrNone) |
|
119 { |
|
120 LOGPARSERR("temp",ret,4,&KSecurityCodes); |
|
121 } |
|
122 else |
|
123 iSecCodes.iPhonePassword.Copy(temp); |
|
124 |
|
125 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,temp); |
|
126 if(ret!=KErrNone) |
|
127 { |
|
128 LOGPARSERR("temp",ret,5,&KSecurityCodes); |
|
129 } |
|
130 else |
|
131 iSecCodes.iSPC.Copy(temp); |
|
132 |
|
133 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,temp); |
|
134 if(ret!=KErrNone) |
|
135 { |
|
136 LOGPARSERR("temp",ret,6,&KSecurityCodes); |
|
137 } |
|
138 else |
|
139 iSecCodes.iPhBkHiddenKey.Copy(temp); |
|
140 |
|
141 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,7,temp); |
|
142 if(ret!=KErrNone) |
|
143 { |
|
144 LOGPARSERR("temp",ret,7,&KSecurityCodes); |
|
145 } |
|
146 else |
|
147 iSecCodes.iUSimAppPin.Copy(temp); |
|
148 |
|
149 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,8,temp); |
|
150 if(ret!=KErrNone) |
|
151 { |
|
152 LOGPARSERR("temp",ret,8,&KSecurityCodes); |
|
153 } |
|
154 else |
|
155 iSecCodes.iSecondUSimAppPin.Copy(temp); |
|
156 |
|
157 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,9,temp); |
|
158 if(ret!=KErrNone) |
|
159 { |
|
160 LOGPARSERR("temp",ret,9,&KSecurityCodes); |
|
161 } |
|
162 else |
|
163 iSecCodes.iUniversalPin.Copy(temp); |
|
164 } |
|
165 |
|
166 |
|
167 item=CfgFile()->Item(KSecurityCodeAttempts); |
|
168 if(item) |
|
169 { |
|
170 TInt temp; |
|
171 |
|
172 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,temp); |
|
173 if(ret!=KErrNone) |
|
174 { |
|
175 LOGPARSERR(&KSecurityCodeAttempts,ret,0,&KSecurityCodeAttempts); |
|
176 } |
|
177 else |
|
178 { |
|
179 if (temp <= 0) |
|
180 { |
|
181 LOGPARSERRANGE(&KSecurityCodeAttempts,temp,"> 0",0,&KSecurityCodeAttempts); |
|
182 LOGCONFIG1("Using default value..."); |
|
183 temp = KDefaultPinEntryAttempts; |
|
184 } |
|
185 iSecurityCodeRemainigAttempts.iPin1=temp; |
|
186 iSecurityCodeDefaultRemainigAttempts.iPin1=temp; |
|
187 } |
|
188 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,temp); |
|
189 if(ret!=KErrNone) |
|
190 { |
|
191 LOGPARSERR(&KSecurityCodeAttempts,ret,1,&KSecurityCodeAttempts); |
|
192 } |
|
193 else |
|
194 { |
|
195 if (temp <= 0) |
|
196 { |
|
197 LOGPARSERRANGE(&KSecurityCodeAttempts,temp,"> 0",1,&KSecurityCodeAttempts); |
|
198 LOGCONFIG1("Using default value..."); |
|
199 temp = KDefaultPinEntryAttempts; |
|
200 } |
|
201 iSecurityCodeRemainigAttempts.iPin2=temp; |
|
202 iSecurityCodeDefaultRemainigAttempts.iPin2=temp; |
|
203 } |
|
204 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,temp); |
|
205 if(ret!=KErrNone) |
|
206 { |
|
207 LOGPARSERR(&KSecurityCodeAttempts,ret,2,&KSecurityCodeAttempts); |
|
208 } |
|
209 else |
|
210 { |
|
211 if (temp <= 0) |
|
212 { |
|
213 LOGPARSERRANGE(&KSecurityCodeAttempts,temp,"> 0",2,&KSecurityCodeAttempts); |
|
214 LOGCONFIG1("Using default value..."); |
|
215 temp = KDefaultPukEntryAttempts; |
|
216 } |
|
217 iSecurityCodeRemainigAttempts.iPuk1=temp; |
|
218 iSecurityCodeDefaultRemainigAttempts.iPuk1=temp; |
|
219 } |
|
220 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,temp); |
|
221 if(ret!=KErrNone) |
|
222 { |
|
223 LOGPARSERR(&KSecurityCodeAttempts,ret,3,&KSecurityCodeAttempts); |
|
224 } |
|
225 else |
|
226 { |
|
227 if (temp <= 0) |
|
228 { |
|
229 LOGPARSERRANGE(&KSecurityCodeAttempts,temp,"> 0",3,&KSecurityCodeAttempts); |
|
230 LOGCONFIG1("Using default value..."); |
|
231 temp = KDefaultPukEntryAttempts; |
|
232 } |
|
233 iSecurityCodeRemainigAttempts.iPuk2=temp; |
|
234 iSecurityCodeDefaultRemainigAttempts.iPuk2=temp; |
|
235 } |
|
236 } |
|
237 else |
|
238 { |
|
239 LOGPHONE2("NOTE tag %S not defined, using default values",&KSecurityCodeAttempts); |
|
240 iSecurityCodeDefaultRemainigAttempts.iPin1= KDefaultPinEntryAttempts; |
|
241 iSecurityCodeRemainigAttempts.iPin1= iSecurityCodeDefaultRemainigAttempts.iPin1; |
|
242 iSecurityCodeDefaultRemainigAttempts.iPin2= KDefaultPinEntryAttempts; |
|
243 iSecurityCodeRemainigAttempts.iPin2= iSecurityCodeDefaultRemainigAttempts.iPin2; |
|
244 iSecurityCodeDefaultRemainigAttempts.iPuk1= KDefaultPukEntryAttempts; |
|
245 iSecurityCodeRemainigAttempts.iPuk1= iSecurityCodeDefaultRemainigAttempts.iPuk1; |
|
246 iSecurityCodeDefaultRemainigAttempts.iPuk2= KDefaultPukEntryAttempts; |
|
247 iSecurityCodeRemainigAttempts.iPuk2 = iSecurityCodeDefaultRemainigAttempts.iPuk2; |
|
248 } |
|
249 |
|
250 item=CfgFile()->Item(KICCLockedAtStart); |
|
251 if(item) |
|
252 { |
|
253 TInt temp; |
|
254 |
|
255 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,temp); |
|
256 if(ret!=KErrNone) |
|
257 { |
|
258 LOGPARSERR("temp",ret,0,&KICCLockedAtStart); |
|
259 } |
|
260 else |
|
261 { |
|
262 iSecStatus.iPin1=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
263 iSecSetting.iPin1=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
264 } |
|
265 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,temp); |
|
266 if(ret!=KErrNone) |
|
267 { |
|
268 LOGPARSERR("temp",ret,1,&KICCLockedAtStart); |
|
269 } |
|
270 else |
|
271 { |
|
272 iSecStatus.iPin2=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
273 iSecSetting.iPin2=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
274 } |
|
275 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,temp); |
|
276 if(ret!=KErrNone) |
|
277 { |
|
278 LOGPARSERR("temp",ret,2,&KICCLockedAtStart); |
|
279 } |
|
280 else |
|
281 { |
|
282 iSecStatus.iPuk1=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
283 iSecSetting.iPuk1=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
284 } |
|
285 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,temp); |
|
286 if(ret!=KErrNone) |
|
287 { |
|
288 LOGPARSERR("temp",ret,3,&KICCLockedAtStart); |
|
289 } |
|
290 else |
|
291 { |
|
292 iSecStatus.iPuk2=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
293 iSecSetting.iPuk2=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
294 } |
|
295 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,4,temp); |
|
296 if(ret!=KErrNone) |
|
297 { |
|
298 LOGPARSERR("temp",ret,4,&KICCLockedAtStart); |
|
299 } |
|
300 else |
|
301 { |
|
302 iSecStatus.iPhonePassword=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
303 iSecSetting.iPhonePassword=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
304 } |
|
305 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,5,temp); |
|
306 if(ret!=KErrNone) |
|
307 { |
|
308 LOGPARSERR("temp",ret,5,&KICCLockedAtStart); |
|
309 } |
|
310 else |
|
311 iSecStatus.iSPC=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
312 |
|
313 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,6,temp); |
|
314 if(ret!=KErrNone) |
|
315 { |
|
316 LOGPARSERR("temp",ret,6,&KICCLockedAtStart); |
|
317 } |
|
318 else |
|
319 { |
|
320 iSecStatus.iPhBkHiddenKey=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
321 iSecSetting.iPhBkHiddenKey=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
322 } |
|
323 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,7,temp); |
|
324 if(ret!=KErrNone) |
|
325 { |
|
326 LOGPARSERR("temp",ret,7,&KICCLockedAtStart); |
|
327 } |
|
328 else |
|
329 { |
|
330 iSecStatus.iUSimAppPin=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
331 iSecSetting.iUSimAppPin=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
332 } |
|
333 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,8,temp); |
|
334 if(ret!=KErrNone) |
|
335 { |
|
336 LOGPARSERR("temp",ret,8,&KICCLockedAtStart); |
|
337 } |
|
338 else |
|
339 { |
|
340 iSecStatus.iSecondUSimAppPin=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
341 iSecSetting.iSecondUSimAppPin=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
342 } |
|
343 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,9,temp); |
|
344 if(ret!=KErrNone) |
|
345 { |
|
346 LOGPARSERR("temp",ret,9,&KICCLockedAtStart); |
|
347 } |
|
348 else |
|
349 { |
|
350 iSecStatus.iUniversalPin=(RMobilePhone::TMobilePhoneLockStatus) temp; |
|
351 iSecSetting.iUniversalPin=(RMobilePhone::TMobilePhoneLockSetting) temp; |
|
352 } |
|
353 } |
|
354 |
|
355 TInt count=CfgFile()->ItemCount(KICCStatus); |
|
356 for(i=0;i<count;i++) |
|
357 { |
|
358 item=CfgFile()->Item(KICCStatus,i); |
|
359 if(!item) |
|
360 break; |
|
361 |
|
362 TInt duration; |
|
363 TInt ICCStatus; |
|
364 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration); |
|
365 if(ret!=KErrNone) |
|
366 { |
|
367 LOGPARSERR("duration",ret,0,&KICCStatus); |
|
368 continue; |
|
369 } |
|
370 |
|
371 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,ICCStatus); |
|
372 if(ret!=KErrNone) |
|
373 { |
|
374 LOGPARSERR("ICCStatus",ret,1,&KICCStatus); |
|
375 continue; |
|
376 } |
|
377 |
|
378 TICCStatusEntry icc; |
|
379 icc.iDuration=duration; |
|
380 icc.iICCStatus=(RMobilePhone::TMobilePhoneSecurityEvent) ICCStatus; |
|
381 iICCStatusProfile->AppendL(icc); |
|
382 } |
|
383 |
|
384 |
|
385 count=CfgFile()->ItemCount(KICCSetting); |
|
386 for(i=0;i<count;i++) |
|
387 { |
|
388 item=CfgFile()->Item(KICCSetting,i); |
|
389 if(!item) |
|
390 break; |
|
391 |
|
392 |
|
393 TInt duration(0), lock(0), lockSetting(0), lockStatus(0); |
|
394 |
|
395 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,0,duration); |
|
396 if(ret!=KErrNone) |
|
397 { |
|
398 LOGPARSERR("duration",ret,0,&KICCSetting); |
|
399 continue; |
|
400 } |
|
401 |
|
402 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,1,lock); |
|
403 if(ret!=KErrNone) |
|
404 { |
|
405 LOGPARSERR("lock",ret,1,&KICCSetting); |
|
406 continue; |
|
407 } |
|
408 |
|
409 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,2,lockSetting); |
|
410 if(ret!=KErrNone) |
|
411 { |
|
412 LOGPARSERR("lockSetting",ret,2,&KICCSetting); |
|
413 continue; |
|
414 } |
|
415 |
|
416 ret=CTestConfig::GetElement(item->Value(),KStdDelimiter,3,lockStatus); |
|
417 if(ret!=KErrNone) |
|
418 { |
|
419 LOGPARSERR("lockStatus",ret,3,&KICCSetting); |
|
420 continue; |
|
421 } |
|
422 |
|
423 TICCSettingEntry icc; |
|
424 icc.iLock = (RMobilePhone::TMobilePhoneLock)lock; |
|
425 icc.iDuration=duration; |
|
426 icc.iLockInfo.iSetting=(RMobilePhone::TMobilePhoneLockSetting) lockSetting; |
|
427 icc.iLockInfo.iStatus=(RMobilePhone::TMobilePhoneLockStatus) lockStatus; |
|
428 iICCSettingProfile->AppendL(icc); |
|
429 } |
|
430 |
|
431 } |
|
432 |
|
433 |
|
434 CSimPhoneSecurity::~CSimPhoneSecurity() |
|
435 /** |
|
436 * Standard destructor. Any objects created by the ::ConstructL() function |
|
437 * will be destroyed here. |
|
438 */ |
|
439 { |
|
440 |
|
441 if(iICCStatusProfile) |
|
442 { |
|
443 iICCStatusProfile->Delete(0,iICCStatusProfile->Count()); |
|
444 delete iICCStatusProfile; |
|
445 } |
|
446 if(iICCSettingProfile) |
|
447 { |
|
448 iICCSettingProfile->Delete(0, iICCSettingProfile->Count()); |
|
449 delete iICCSettingProfile; |
|
450 } |
|
451 |
|
452 delete iNotifySettingsTimer; |
|
453 delete iNotifySecurityEventsTimer; |
|
454 |
|
455 if (iUnlockNamTimer) |
|
456 { |
|
457 iUnlockNamTimer->Cancel(); |
|
458 delete iUnlockNamTimer; |
|
459 iUnlockNamTimer = NULL; |
|
460 } |
|
461 if (iLockNamTimer) |
|
462 { |
|
463 iLockNamTimer->Cancel(); |
|
464 delete iLockNamTimer; |
|
465 iLockNamTimer = NULL; |
|
466 } |
|
467 } |
|
468 |
|
469 TInt CSimPhoneSecurity::ExtFunc(const TTsyReqHandle aReqHandle,const TInt aIpc, const TDataPackage& aPckg) |
|
470 /** |
|
471 * Dispatch function for all Phonebook Store requests. |
|
472 * @param aReqHandle The TSY request handle for this request. |
|
473 * @param aIpc The IPC number of this request. |
|
474 * @param aPckg The parameter package related to this request. |
|
475 * @return TInt The return error condition. |
|
476 */ |
|
477 { |
|
478 |
|
479 TAny* dataPtr = aPckg.Ptr1(); |
|
480 TAny* dataPtr2 = aPckg.Ptr2(); |
|
481 |
|
482 // The following requests can be completed even if the completion of another request is pending. |
|
483 switch(aIpc) |
|
484 { |
|
485 case EMobilePhoneGetSecurityCaps: |
|
486 return GetSecurityCaps(aReqHandle, |
|
487 REINTERPRET_CAST(TUint32*, dataPtr)); |
|
488 |
|
489 case EMobilePhoneNotifySecurityCapsChange: |
|
490 return NotifySecurityCapsChange(aReqHandle, |
|
491 REINTERPRET_CAST(TUint32*, dataPtr2)); |
|
492 |
|
493 case EMobilePhoneGetLockInfo: |
|
494 return GetLockInfo(aReqHandle, |
|
495 REINTERPRET_CAST(RMobilePhone::TMobilePhoneLock*, dataPtr), |
|
496 aPckg.Des2n()); |
|
497 |
|
498 case EMobilePhoneNotifyLockInfoChange: |
|
499 return NotifyLockInfoChange(aReqHandle, |
|
500 REINTERPRET_CAST(RMobilePhone::TMobilePhoneLock*, dataPtr), |
|
501 aPckg.Des2n()); |
|
502 |
|
503 case EMobilePhoneSetLockSetting: |
|
504 return SetLockSetting(aReqHandle, |
|
505 REINTERPRET_CAST(RMobilePhone::TMobilePhoneLock*, dataPtr), |
|
506 REINTERPRET_CAST(RMobilePhone::TMobilePhoneLockSetting*, dataPtr2)); |
|
507 |
|
508 case EMobilePhoneGetSecurityCodeInfo: |
|
509 return GetSecurityCodeInfo(aReqHandle, |
|
510 reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCode*> (dataPtr), |
|
511 aPckg.Des2n()); |
|
512 |
|
513 case EMobilePhoneNotifySecurityCodeInfoChange: |
|
514 return NotifySecurityCodeInfoChange(aReqHandle, |
|
515 reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCode*> (dataPtr), |
|
516 aPckg.Des2n()); |
|
517 |
|
518 case EMobilePhoneChangeSecurityCode: |
|
519 return ChangeSecurityCode(aReqHandle, |
|
520 REINTERPRET_CAST(RMobilePhone::TMobilePhoneSecurityCode*, dataPtr), |
|
521 aPckg.Des2n()); |
|
522 |
|
523 case EMobilePhoneNotifySecurityEvent: |
|
524 return NotifySecurityEvent(aReqHandle, aPckg.Des1n()); |
|
525 |
|
526 case EMobilePhoneVerifySecurityCode: |
|
527 return VerifySecurityCode(aReqHandle, |
|
528 REINTERPRET_CAST(RMobilePhone::TMobilePhoneSecurityCode*, dataPtr), |
|
529 REINTERPRET_CAST(RMobilePhone::TCodeAndUnblockCode*, dataPtr2)); |
|
530 |
|
531 case EMobilePhoneAbortSecurityCode: |
|
532 return AbortSecurityCode(aReqHandle, |
|
533 REINTERPRET_CAST(RMobilePhone::TMobilePhoneSecurityCode*, dataPtr)); |
|
534 default: |
|
535 break; |
|
536 } |
|
537 |
|
538 |
|
539 // The TSY can only process one of the following requests at a time. If a second is received |
|
540 // while processing the first, then it will be errored with KErrInUse. This restriction will |
|
541 // be removed later, by inserting a request queuing mechanism. Note that the standard TSY |
|
542 // "flow control" mechanism works phone-wide and so is not suitable. |
|
543 |
|
544 // switch(aIpc) |
|
545 // { |
|
546 // default: |
|
547 // break; |
|
548 // } |
|
549 |
|
550 return KErrNotSupported; |
|
551 } |
|
552 |
|
553 CTelObject* CSimPhoneSecurity::OpenNewObjectByNameL(const TDesC& /*aName*/) |
|
554 /** |
|
555 * The API does not support any objects that could be opened from this one. |
|
556 */ |
|
557 { |
|
558 User::Leave(KErrNotSupported); |
|
559 return NULL; |
|
560 } |
|
561 |
|
562 CTelObject* CSimPhoneSecurity::OpenNewObjectL(TDes&) |
|
563 /** |
|
564 * The API does not support any objects that could be opened from this one. |
|
565 */ |
|
566 { |
|
567 User::Leave(KErrNotSupported); |
|
568 return NULL; |
|
569 } |
|
570 |
|
571 CTelObject::TReqMode CSimPhoneSecurity::ReqModeL(const TInt aIpc) |
|
572 /** |
|
573 * This function returns the Request Mode for the request with the passed IPC value. |
|
574 * @param aIpc The IPC number of the request. |
|
575 * @return TReqMode The request mode. |
|
576 */ |
|
577 { |
|
578 CTelObject::TReqMode ret=0; |
|
579 // This function seems be unused. ReqModeL for security related IPC is in CSimPhone. |
|
580 switch(aIpc) |
|
581 { |
|
582 case EMobilePhoneGetSecurityCaps: |
|
583 case EMobilePhoneGetLockInfo: |
|
584 case EMobilePhoneSetLockSetting: |
|
585 case EMobilePhoneChangeSecurityCode: |
|
586 case EMobilePhoneVerifySecurityCode: |
|
587 case EMobilePhoneAbortSecurityCode: |
|
588 break; |
|
589 |
|
590 case EMobilePhoneNotifyLockInfoChange: |
|
591 case EMobilePhoneNotifySecurityCapsChange: |
|
592 case EMobilePhoneNotifySecurityEvent: |
|
593 ret=KReqModeMultipleCompletionEnabled | KReqModeRePostImmediately; |
|
594 break; |
|
595 |
|
596 default: |
|
597 User::Leave(KErrNotSupported); |
|
598 break; |
|
599 } |
|
600 |
|
601 return ret; |
|
602 } |
|
603 |
|
604 TInt CSimPhoneSecurity::RegisterNotification(const TInt /*aIpc*/) |
|
605 /** |
|
606 * The ETel Server calls this function when the first client makes a notification |
|
607 * request. If supported by the underlying protocol controlling the |
|
608 * signalling stack, this can be used to start requesting updates for the relevant |
|
609 * service. |
|
610 */ |
|
611 { |
|
612 return KErrNone; |
|
613 } |
|
614 |
|
615 TInt CSimPhoneSecurity::DeregisterNotification(const TInt /*aIpc*/) |
|
616 /** |
|
617 * The ETel Server calls this function when the last client that had previously |
|
618 * made a notification request closes its ETel Server handle. If supported by |
|
619 * the underlying protocol controlling the signalling stack, this can be used |
|
620 * to stop requesting updates for the relevant service. |
|
621 */ |
|
622 { |
|
623 return KErrNone; |
|
624 } |
|
625 |
|
626 TInt CSimPhoneSecurity::NumberOfSlotsL(const TInt aIpc) |
|
627 /** |
|
628 * Return the number of slots that the ETel Server should allocate for buffering requests |
|
629 * of the given IPC number. |
|
630 */ |
|
631 { |
|
632 switch(aIpc) |
|
633 { |
|
634 case EMobilePhoneNotifyLockInfoChange: |
|
635 case EMobilePhoneNotifySecurityCapsChange: |
|
636 case EMobilePhoneNotifySecurityEvent: |
|
637 return KDefaultNumberOfSlots; |
|
638 |
|
639 default: |
|
640 LOGPHONE1("CSimPhoneSecurity: Number of Slots error, unknown IPC"); |
|
641 User::Leave(KErrNotSupported); |
|
642 break; |
|
643 } |
|
644 return KDefaultNumberOfSlots; |
|
645 } |
|
646 |
|
647 TInt CSimPhoneSecurity::CancelService(const TInt aIpc, const TTsyReqHandle aReqHandle) |
|
648 /** |
|
649 * Cancel an outstanding request. |
|
650 * @param aIpc The IPC number of the request that is to be cancelled. |
|
651 * @param aTsyReqHandle The TSY request handle of the request that is to be cancelled. |
|
652 * @param TInt Standard return value. |
|
653 */ |
|
654 { |
|
655 switch(aIpc) |
|
656 { |
|
657 case EMobilePhoneNotifySecurityCapsChange: |
|
658 return NotifySecurityCapsChangeCancel(aReqHandle); |
|
659 |
|
660 case EMobilePhoneGetLockInfo: |
|
661 return GetLockInfoCancel(aReqHandle); |
|
662 |
|
663 case EMobilePhoneNotifyLockInfoChange: |
|
664 return NotifyLockInfoChangeCancel(aReqHandle); |
|
665 |
|
666 case EMobilePhoneSetLockSetting: |
|
667 return SetLockSettingCancel(aReqHandle); |
|
668 |
|
669 case EMobilePhoneGetSecurityCodeInfo: |
|
670 return GetSecurityCodeInfoCancel(aReqHandle); |
|
671 |
|
672 case EMobilePhoneNotifySecurityCodeInfoChange: |
|
673 return NotifySecurityCodeInfoChangeCancel(aReqHandle); |
|
674 |
|
675 case EMobilePhoneChangeSecurityCode: |
|
676 return ChangeSecurityCodeCancel(aReqHandle); |
|
677 |
|
678 case EMobilePhoneNotifySecurityEvent: |
|
679 return NotifySecurityEventCancel(aReqHandle); |
|
680 |
|
681 case EMobilePhoneVerifySecurityCode: |
|
682 return VerifySecurityCodeCancel(aReqHandle); |
|
683 default: |
|
684 break; |
|
685 } |
|
686 return KErrNone; |
|
687 } |
|
688 |
|
689 |
|
690 const CTestConfigSection* CSimPhoneSecurity::CfgFile() |
|
691 /** |
|
692 * Returns a pointer to the config file section |
|
693 * |
|
694 * @return CTestConfigSection a pointer to the configuration file data section |
|
695 */ |
|
696 { |
|
697 LOGPHONE1(">>CSimPhoneSecurity::CfgFile"); |
|
698 return iPhone->CfgFile(); |
|
699 } |
|
700 |
|
701 |
|
702 TInt CSimPhoneSecurity::GetSecurityCaps(const TTsyReqHandle aReqHandle, TUint32* aCaps) |
|
703 { |
|
704 //Support all the security features that can be configured using config.txt |
|
705 *aCaps= ( RMobilePhone::KCapsLockPhone | |
|
706 RMobilePhone::KCapsLockICC | |
|
707 RMobilePhone::KCapsAccessPin1 | |
|
708 RMobilePhone::KCapsAccessPin2 | |
|
709 RMobilePhone::KCapsAccessPhonePassword | |
|
710 RMobilePhone::KCapsAccessSPC | |
|
711 RMobilePhone::KCapsAccessHiddenKey | |
|
712 RMobilePhone::KCapsAccessUSIMAppPin | |
|
713 RMobilePhone::KCapsAccessUSIMAppSecondPin | |
|
714 RMobilePhone::KCapsAccessUniversalPin ); |
|
715 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
716 return KErrNone; |
|
717 } |
|
718 |
|
719 TInt CSimPhoneSecurity::NotifySecurityCapsChange(const TTsyReqHandle aReqHandle, TUint32* /*aCaps*/) |
|
720 { |
|
721 iPhone->ReqCompleted(aReqHandle,KErrNotSupported); |
|
722 return KErrNone; |
|
723 } |
|
724 |
|
725 TInt CSimPhoneSecurity::NotifySecurityCapsChangeCancel(const TTsyReqHandle aReqHandle) |
|
726 { |
|
727 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
728 return KErrNone; |
|
729 } |
|
730 |
|
731 TInt CSimPhoneSecurity::GetLockInfo(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneLock* aLock, TDes8* aLockInfo) |
|
732 { |
|
733 RMobilePhone::TMobilePhoneLockInfoV1Pckg* lockPckg = (RMobilePhone::TMobilePhoneLockInfoV1Pckg*) aLockInfo; |
|
734 RMobilePhone::TMobilePhoneLockInfoV1& lock = (*lockPckg)(); |
|
735 |
|
736 // Check that the data structure is supported by the simulated TSY version |
|
737 TInt err = iPhone->CheckSimTsyVersion(lock); |
|
738 if(err != KErrNone) |
|
739 { |
|
740 iPhone->ReqCompleted(aReqHandle, err); |
|
741 return KErrNone; |
|
742 } |
|
743 |
|
744 switch(*aLock) |
|
745 { |
|
746 case RMobilePhone::ELockICC: |
|
747 lock.iStatus=iSecStatus.iPin1; |
|
748 lock.iSetting=iSecSetting.iPin1; |
|
749 break; |
|
750 case RMobilePhone::ELockPin2: |
|
751 lock.iStatus=iSecStatus.iPin2; |
|
752 lock.iSetting=iSecSetting.iPin2; |
|
753 break; |
|
754 case RMobilePhone::ELockHiddenKey: |
|
755 lock.iStatus=iSecStatus.iPhBkHiddenKey; |
|
756 lock.iSetting=iSecSetting.iPhBkHiddenKey; |
|
757 break; |
|
758 case RMobilePhone::ELockUSimApp: |
|
759 lock.iStatus=iSecStatus.iUSimAppPin; |
|
760 lock.iSetting=iSecSetting.iUSimAppPin; |
|
761 break; |
|
762 case RMobilePhone::ELockSecondUSimApp: |
|
763 lock.iStatus=iSecStatus.iSecondUSimAppPin; |
|
764 lock.iSetting=iSecSetting.iSecondUSimAppPin; |
|
765 break; |
|
766 case RMobilePhone::ELockUniversalPin: |
|
767 lock.iStatus=iSecStatus.iUniversalPin; |
|
768 lock.iSetting=iSecSetting.iUniversalPin; |
|
769 break; |
|
770 |
|
771 case RMobilePhone::ELockNam: |
|
772 iPhone->ReqCompleted(aReqHandle,KErrNotSupported); |
|
773 return KErrNone; |
|
774 |
|
775 // Not supported! |
|
776 // case RMobilePhone::ELockPhoneDevice: |
|
777 // case RMobilePhone::ELockPhoneToIcc: |
|
778 // case RMobilePhone::ELockPhoneToFirstIcc: |
|
779 // case RMobilePhone::ELockOTA: |
|
780 default: |
|
781 iPhone->ReqCompleted(aReqHandle,KErrNotSupported); |
|
782 return KErrNone; |
|
783 } |
|
784 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
785 return KErrNone; |
|
786 } |
|
787 |
|
788 TInt CSimPhoneSecurity::GetLockInfoCancel(const TTsyReqHandle aReqHandle) |
|
789 { |
|
790 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
791 return KErrNone; |
|
792 } |
|
793 |
|
794 TInt CSimPhoneSecurity::NotifyLockInfoChange(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneLock* aLock, TDes8* aLockInfo) |
|
795 { |
|
796 RMobilePhone::TMobilePhoneLockInfoV1Pckg* lockPckg = (RMobilePhone::TMobilePhoneLockInfoV1Pckg*) aLockInfo; |
|
797 RMobilePhone::TMobilePhoneLockInfoV1& lock = (*lockPckg)(); |
|
798 |
|
799 // Check that the data structure is supported by the simulated TSY version |
|
800 TInt err = iPhone->CheckSimTsyVersion(lock); |
|
801 if(err != KErrNone) |
|
802 { |
|
803 iPhone->ReqCompleted(aReqHandle, err); |
|
804 return KErrNone; |
|
805 } |
|
806 |
|
807 __ASSERT_ALWAYS(!iNotifyLock.iNotifyPending,SimPanic(ENotificationReqAlreadyOutstanding)); |
|
808 |
|
809 if (iNotifySettingsTimer->iIndex < iICCSettingProfile->Count()) |
|
810 { |
|
811 TICCSettingEntry entry = iICCSettingProfile->At(iNotifySettingsTimer->iIndex); |
|
812 if(iNotifySettingsTimer->iTimerStarted) |
|
813 { |
|
814 delete iNotifySettingsTimer->iTimer; |
|
815 iNotifySettingsTimer->iTimer = NULL; |
|
816 TRAPD(err,iNotifySettingsTimer->iTimer=CSimTimer::NewL(iPhone)); |
|
817 if (err!=KErrNone) |
|
818 return (err); |
|
819 } |
|
820 iNotifySettingsTimer->iTimer->Start(entry.iDuration, this, ETimerIdSecurityNotifyLockInfo); |
|
821 iNotifySettingsTimer->iTimerStarted = ETrue; |
|
822 } |
|
823 |
|
824 iNotifyLock.iNotifyPending=ETrue; |
|
825 iNotifyLock.iNotifyHandle=aReqHandle; |
|
826 iNotifyLock.iNotifyData=&lock; |
|
827 iNotifyLock.iNotifyDataXtra=aLock; |
|
828 return KErrNone; |
|
829 } |
|
830 |
|
831 TInt CSimPhoneSecurity::NotifyLockInfoChangeCancel(const TTsyReqHandle aReqHandle) |
|
832 { |
|
833 if(iNotifyLock.iNotifyPending) |
|
834 { |
|
835 iNotifyLock.iNotifyPending=EFalse; |
|
836 iPhone->ReqCompleted(aReqHandle,KErrCancel); |
|
837 return KErrNone; |
|
838 } |
|
839 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
840 return KErrNone; |
|
841 } |
|
842 |
|
843 TInt CSimPhoneSecurity::SetLockSetting(const TTsyReqHandle aTsyReqHandle, |
|
844 RMobilePhone::TMobilePhoneLock* aLock, |
|
845 RMobilePhone::TMobilePhoneLockSetting* aSetting) |
|
846 { |
|
847 // create dummy RMobilePhone::TMobilePhoneLockInfoV1 for |
|
848 // UpdateLockInfo and CompleteNotifyLockInfoChange |
|
849 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
850 |
|
851 // Check that the data structure is supported by the simulated TSY version |
|
852 TInt err = iPhone->CheckSimTsyVersion(lockInfo); |
|
853 if(err != KErrNone) |
|
854 { |
|
855 iPhone->ReqCompleted(aTsyReqHandle, err); |
|
856 return KErrNone; |
|
857 } |
|
858 |
|
859 lockInfo.iSetting = *aSetting; |
|
860 |
|
861 // set the iStatus of our local lock info to whatever the current |
|
862 // lock info iStatus is set to. The reason is because the intent of |
|
863 // SetLockSetting is to set the iSetting value of the lock while |
|
864 // leaving the iStatus value untouched |
|
865 switch(*aLock) |
|
866 { |
|
867 case RMobilePhone::ELockICC: |
|
868 lockInfo.iStatus=iSecStatus.iPin1; |
|
869 break; |
|
870 case RMobilePhone::ELockPin2: |
|
871 lockInfo.iStatus=iSecStatus.iPin2; |
|
872 break; |
|
873 case RMobilePhone::ELockHiddenKey: |
|
874 lockInfo.iStatus=iSecStatus.iPhBkHiddenKey; |
|
875 break; |
|
876 case RMobilePhone::ELockUSimApp: |
|
877 lockInfo.iStatus=iSecStatus.iUSimAppPin; |
|
878 break; |
|
879 case RMobilePhone::ELockSecondUSimApp: |
|
880 lockInfo.iStatus=iSecStatus.iSecondUSimAppPin; |
|
881 break; |
|
882 case RMobilePhone::ELockUniversalPin: |
|
883 lockInfo.iStatus=iSecStatus.iUniversalPin; |
|
884 break; |
|
885 |
|
886 case RMobilePhone::ELockNam: |
|
887 iPhone->ReqCompleted(aTsyReqHandle,KErrNotSupported); |
|
888 return KErrNone; |
|
889 |
|
890 // Not supported! |
|
891 // case RMobilePhone::ELockPhoneDevice: |
|
892 // case RMobilePhone::ELockPhoneToIcc: |
|
893 // case RMobilePhone::ELockPhoneToFirstIcc: |
|
894 // case RMobilePhone::ELockOTA: |
|
895 default: |
|
896 iPhone->ReqCompleted(aTsyReqHandle,KErrNotSupported); |
|
897 return KErrNone; |
|
898 } |
|
899 |
|
900 err = UpdateLockInfo(*aLock, lockInfo); |
|
901 if(err) |
|
902 { |
|
903 iPhone->ReqCompleted(aTsyReqHandle,err); |
|
904 return KErrNone; |
|
905 } |
|
906 |
|
907 CompleteNotifyLockInfoChange(*aLock, lockInfo); |
|
908 |
|
909 iPhone->ReqCompleted(aTsyReqHandle,KErrNone); |
|
910 return KErrNone; |
|
911 } |
|
912 |
|
913 TInt CSimPhoneSecurity::SetLockSettingCancel(const TTsyReqHandle aReqHandle) |
|
914 { |
|
915 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
916 return KErrNone; |
|
917 } |
|
918 |
|
919 TInt CSimPhoneSecurity::GetSecurityCodeInfo(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TMobilePhoneSecurityCode* aSecurityCode,TDes8* aSecurityCodeInfo) |
|
920 /** |
|
921 Handle GetSecurityCodeInfo request |
|
922 |
|
923 @param aTsyReqHandle TSY handle associated with this request |
|
924 @param aSecurityCode Security code to get info on |
|
925 @param aSecurityCodeInfo The TMobilePhoneSecurityCodeInfoV5 that will be populated with the |
|
926 security code information |
|
927 @return KErrNone |
|
928 */ |
|
929 { |
|
930 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg* securityCodeInfoPckg = |
|
931 reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg*> (aSecurityCodeInfo); |
|
932 RMobilePhone::TMobilePhoneSecurityCodeInfoV5& securityCodeInfo = (*securityCodeInfoPckg)(); |
|
933 |
|
934 // Check that the data structure is supported by the simulated TSY version |
|
935 TInt err = iPhone->CheckSimTsyVersion(securityCodeInfo); |
|
936 if(err != KErrNone) |
|
937 { |
|
938 iPhone->ReqCompleted(aTsyReqHandle, err); |
|
939 return KErrNone; |
|
940 } |
|
941 |
|
942 switch(*aSecurityCode) |
|
943 { |
|
944 case RMobilePhone::ESecurityCodePin1: |
|
945 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin1; |
|
946 break; |
|
947 case RMobilePhone::ESecurityCodePin2: |
|
948 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin2; |
|
949 break; |
|
950 case RMobilePhone::ESecurityCodePuk1: |
|
951 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk1; |
|
952 break; |
|
953 case RMobilePhone::ESecurityCodePuk2: |
|
954 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk2; |
|
955 break; |
|
956 default: |
|
957 iPhone->ReqCompleted(aTsyReqHandle,KErrNotFound); |
|
958 return KErrNone; |
|
959 } |
|
960 iPhone->ReqCompleted(aTsyReqHandle,KErrNone); |
|
961 return KErrNone; |
|
962 } |
|
963 |
|
964 TInt CSimPhoneSecurity::GetSecurityCodeInfoCancel(const TTsyReqHandle aTsyReqHandle) |
|
965 /** |
|
966 Retrieve a security code information |
|
967 |
|
968 @param aTsyReqHandle TSY handle associated with this request |
|
969 @return KErrNone |
|
970 */ |
|
971 { |
|
972 iPhone->ReqCompleted(aTsyReqHandle,KErrNone); |
|
973 return KErrNone; |
|
974 } |
|
975 |
|
976 TInt CSimPhoneSecurity::NotifySecurityCodeInfoChange(const TTsyReqHandle aTsyReqHandle, RMobilePhone::TMobilePhoneSecurityCode* aSecurityCode,TDes8* aSecurityCodeInfo) |
|
977 /** |
|
978 Record a client's interest in being notified when information of asecurity code changes. |
|
979 |
|
980 @param aTsyReqHandle TSY handle associated with this request |
|
981 @param aSecurityCode pointer that will be populated with the security code that changed |
|
982 @param aSecurityCodeInfo The TMobilePhoneSecurityCodeInfoV5 that will be populated with the |
|
983 security code information |
|
984 @return KErrNone |
|
985 */ |
|
986 { |
|
987 __ASSERT_ALWAYS(!iNotifySecurityCodeInfo.iNotifyPending,SimPanic(ENotificationAlreadyPending)); |
|
988 |
|
989 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg* securityCodeInfoPckg = |
|
990 reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg*> (aSecurityCodeInfo); |
|
991 RMobilePhone::TMobilePhoneSecurityCodeInfoV5& securityCodeInfo = (*securityCodeInfoPckg)(); |
|
992 |
|
993 // Check that the data structure is supported by the simulated TSY version |
|
994 TInt err = iPhone->CheckSimTsyVersion(securityCodeInfo); |
|
995 if(err != KErrNone) |
|
996 { |
|
997 iPhone->ReqCompleted(aTsyReqHandle, err); |
|
998 return KErrNone; |
|
999 } |
|
1000 |
|
1001 iNotifySecurityCodeInfo.iNotifyPending=ETrue; |
|
1002 iNotifySecurityCodeInfo.iNotifyHandle=aTsyReqHandle; |
|
1003 iNotifySecurityCodeInfo.iNotifyData=&securityCodeInfo; |
|
1004 iNotifySecurityCodeInfo.iNotifyDataXtra=aSecurityCode; |
|
1005 return KErrNone; |
|
1006 } |
|
1007 |
|
1008 TInt CSimPhoneSecurity::NotifySecurityCodeInfoChangeCancel(const TTsyReqHandle aReqHandle) |
|
1009 /** |
|
1010 Cancel a client's interest in being notified when the RMobileCall capabilities change. |
|
1011 |
|
1012 @param aTsyReqHandle TSY handle associated with this request |
|
1013 @return KErrNone |
|
1014 */ |
|
1015 { |
|
1016 if(iNotifySecurityCodeInfo.iNotifyPending) |
|
1017 { |
|
1018 iNotifySecurityCodeInfo.iNotifyPending=EFalse; |
|
1019 iPhone->ReqCompleted(aReqHandle,KErrCancel); |
|
1020 return KErrNone; |
|
1021 } |
|
1022 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1023 return KErrNone; |
|
1024 } |
|
1025 |
|
1026 TInt CSimPhoneSecurity::ChangeSecurityCode(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneSecurityCode* aType,const TDes8* aChange) |
|
1027 { |
|
1028 TPckg<RMobilePhone::TMobilePhonePasswordChangeV1>* passPckg= (TPckg<RMobilePhone::TMobilePhonePasswordChangeV1>*)aChange; |
|
1029 RMobilePhone::TMobilePhonePasswordChangeV1& pass = (*passPckg)(); |
|
1030 |
|
1031 // Check that the data structure is supported by the simulated TSY version |
|
1032 TInt err = iPhone->CheckSimTsyVersion(pass); |
|
1033 if(err != KErrNone) |
|
1034 { |
|
1035 iPhone->ReqCompleted(aReqHandle, err); |
|
1036 return KErrNone; |
|
1037 } |
|
1038 |
|
1039 switch(*aType) |
|
1040 { |
|
1041 case RMobilePhone::ESecurityCodePin1: |
|
1042 if(iSecCodes.iPin1 == pass.iOldPassword) |
|
1043 { |
|
1044 iSecCodes.iPin1.Copy(pass.iNewPassword); |
|
1045 Pin1Success(); |
|
1046 } |
|
1047 else |
|
1048 { |
|
1049 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1050 Pin1Failure(); |
|
1051 return KErrNone; |
|
1052 } |
|
1053 break; |
|
1054 case RMobilePhone::ESecurityCodePin2: |
|
1055 if(iSecCodes.iPin2==pass.iOldPassword) |
|
1056 { |
|
1057 iSecCodes.iPin2.Copy(pass.iNewPassword); |
|
1058 Pin2Success(); |
|
1059 } |
|
1060 else |
|
1061 { |
|
1062 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1063 Pin2Failure(); |
|
1064 return KErrNone; |
|
1065 } |
|
1066 break; |
|
1067 case RMobilePhone::ESecurityCodePuk1: |
|
1068 if(iSecCodes.iPuk1==pass.iOldPassword) |
|
1069 { |
|
1070 iSecCodes.iPuk1.Copy(pass.iNewPassword); |
|
1071 Puk1Success(); |
|
1072 } |
|
1073 else |
|
1074 { |
|
1075 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1076 Puk1Failure(); |
|
1077 return KErrNone; |
|
1078 } |
|
1079 break; |
|
1080 case RMobilePhone::ESecurityCodePuk2: |
|
1081 if(iSecCodes.iPuk2==pass.iOldPassword) |
|
1082 { |
|
1083 iSecCodes.iPuk2.Copy(pass.iNewPassword); |
|
1084 Puk2Success(); |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1089 Puk2Failure(); |
|
1090 return KErrNone; |
|
1091 } |
|
1092 break; |
|
1093 case RMobilePhone::ESecurityHiddenKey: |
|
1094 if(iSecCodes.iPhBkHiddenKey==pass.iOldPassword) |
|
1095 iSecCodes.iPhBkHiddenKey.Copy(pass.iNewPassword); |
|
1096 else |
|
1097 { |
|
1098 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1099 return KErrNone; |
|
1100 } |
|
1101 break; |
|
1102 case RMobilePhone::ESecurityUSIMAppPin: |
|
1103 if(iSecCodes.iUSimAppPin==pass.iOldPassword) |
|
1104 iSecCodes.iUSimAppPin.Copy(pass.iNewPassword); |
|
1105 else |
|
1106 { |
|
1107 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1108 return KErrNone; |
|
1109 } |
|
1110 break; |
|
1111 case RMobilePhone::ESecuritySecondUSIMAppPin: |
|
1112 if(iSecCodes.iSecondUSimAppPin==pass.iOldPassword) |
|
1113 iSecCodes.iSecondUSimAppPin.Copy(pass.iNewPassword); |
|
1114 else |
|
1115 { |
|
1116 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1117 return KErrNone; |
|
1118 } |
|
1119 break; |
|
1120 case RMobilePhone::ESecurityUniversalPin: |
|
1121 if(iSecCodes.iUniversalPin==pass.iOldPassword) |
|
1122 iSecCodes.iUniversalPin.Copy(pass.iNewPassword); |
|
1123 else |
|
1124 { |
|
1125 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1126 return KErrNone; |
|
1127 } |
|
1128 break; |
|
1129 // Not supported |
|
1130 // case RMobilePhone::ESecurityCodePhonePassword: |
|
1131 // case RMobilePhone::ESecurityCodeSPC: |
|
1132 |
|
1133 default: |
|
1134 iPhone->ReqCompleted(aReqHandle,KErrNotSupported); |
|
1135 return KErrNone; |
|
1136 } |
|
1137 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1138 return KErrNone; |
|
1139 } |
|
1140 |
|
1141 TInt CSimPhoneSecurity::ChangeSecurityCodeCancel(const TTsyReqHandle aReqHandle) |
|
1142 { |
|
1143 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1144 return KErrNone; |
|
1145 } |
|
1146 |
|
1147 /*TInt CSimPhoneSecurity::UnlockNam(const TTsyReqHandle aReqHandle, const RMobilePhone::TMobilePassword* aSpc) |
|
1148 { |
|
1149 if(iSecStatus.iSPC==RMobilePhone::EStatusUnlocked) |
|
1150 { |
|
1151 iPhone->ReqCompleted(aReqHandle,KErrNotReady); |
|
1152 return KErrNone; |
|
1153 } |
|
1154 else if(iSecCodes.iSPC==*aSpc) |
|
1155 { |
|
1156 iUnlockNamHandle = aReqHandle; |
|
1157 iUnlockNamTimer->Start(KNamTimeout,this,ETimerIdSecurityUnlockNam); |
|
1158 return KErrNone; |
|
1159 } |
|
1160 else |
|
1161 { |
|
1162 iPhone->ReqCompleted(aReqHandle,KErrAccessDenied); |
|
1163 return KErrNone; |
|
1164 } |
|
1165 }*/ |
|
1166 |
|
1167 void CSimPhoneSecurity::TimerCallBackUnlockNam() |
|
1168 { |
|
1169 SecurityEvent(RMobilePhone::ESPCVerified); |
|
1170 iPhone->ReqCompleted(iUnlockNamHandle,KErrNone); |
|
1171 } |
|
1172 |
|
1173 TInt CSimPhoneSecurity::UnlockNamCancel(const TTsyReqHandle aReqHandle) |
|
1174 { |
|
1175 iUnlockNamTimer->Cancel(); |
|
1176 iPhone->ReqCompleted(aReqHandle,KErrCancel); |
|
1177 return KErrNone; |
|
1178 } |
|
1179 |
|
1180 void CSimPhoneSecurity::TimerCallBackLockNam() |
|
1181 { |
|
1182 LockSpc(); |
|
1183 iPhone->ReqCompleted(iLockNamHandle,KErrNone); |
|
1184 } |
|
1185 |
|
1186 TInt CSimPhoneSecurity::LockNamCancel(const TTsyReqHandle aReqHandle) |
|
1187 { |
|
1188 iLockNamTimer->Cancel(); |
|
1189 iPhone->ReqCompleted(aReqHandle,KErrCancel); |
|
1190 return KErrNone; |
|
1191 } |
|
1192 |
|
1193 |
|
1194 TInt CSimPhoneSecurity::VerifySecurityCode(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneSecurityCode* aType, const RMobilePhone::TCodeAndUnblockCode* aCode) |
|
1195 { |
|
1196 switch(*aType) |
|
1197 { |
|
1198 case RMobilePhone::ESecurityCodePin1: |
|
1199 if(iSecCodes.iPin1==(*aCode).iCode) |
|
1200 { |
|
1201 SecurityEvent(RMobilePhone::EPin1Verified); |
|
1202 Pin1Success(); |
|
1203 break; |
|
1204 } |
|
1205 else |
|
1206 { |
|
1207 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1208 Pin1Failure(); |
|
1209 return KErrNone; |
|
1210 } |
|
1211 case RMobilePhone::ESecurityCodePin2: |
|
1212 if(iSecCodes.iPin2==(*aCode).iCode) |
|
1213 { |
|
1214 SecurityEvent(RMobilePhone::EPin2Verified); |
|
1215 Pin2Success(); |
|
1216 break; |
|
1217 } |
|
1218 else |
|
1219 { |
|
1220 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1221 Pin2Failure(); |
|
1222 return KErrNone; |
|
1223 } |
|
1224 case RMobilePhone::ESecurityCodePuk1: |
|
1225 if(iSecCodes.iPuk1==(*aCode).iUnblockCode) |
|
1226 { |
|
1227 SecurityEvent(RMobilePhone::EPuk1Verified); |
|
1228 Puk1Success(); |
|
1229 break; |
|
1230 } |
|
1231 else |
|
1232 { |
|
1233 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1234 Puk1Failure(); |
|
1235 return KErrNone; |
|
1236 } |
|
1237 case RMobilePhone::ESecurityCodePuk2: |
|
1238 if(iSecCodes.iPuk2==(*aCode).iUnblockCode) |
|
1239 { |
|
1240 SecurityEvent(RMobilePhone::EPuk2Verified); |
|
1241 Puk2Success(); |
|
1242 break; |
|
1243 } |
|
1244 else |
|
1245 { |
|
1246 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1247 Puk2Failure(); |
|
1248 return KErrNone; |
|
1249 } |
|
1250 case RMobilePhone::ESecurityHiddenKey: |
|
1251 if(iSecCodes.iPhBkHiddenKey==(*aCode).iCode) |
|
1252 { |
|
1253 SecurityEvent(RMobilePhone::EHiddenKeyVerified); |
|
1254 break; |
|
1255 } |
|
1256 else |
|
1257 { |
|
1258 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1259 return KErrNone; |
|
1260 } |
|
1261 case RMobilePhone::ESecurityUSIMAppPin: |
|
1262 if(iSecCodes.iUSimAppPin==(*aCode).iCode) |
|
1263 { |
|
1264 SecurityEvent(RMobilePhone::EUSIMAppPinVerified); |
|
1265 break; |
|
1266 } |
|
1267 else |
|
1268 { |
|
1269 iPhone->ReqCompleted(aReqHandle,KErrAccessDenied); |
|
1270 return KErrNone; |
|
1271 } |
|
1272 case RMobilePhone::ESecuritySecondUSIMAppPin: |
|
1273 if(iSecCodes.iSecondUSimAppPin==(*aCode).iCode) |
|
1274 { |
|
1275 SecurityEvent(RMobilePhone::ESecondUSIMAppPinVerified); |
|
1276 break; |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1281 return KErrNone; |
|
1282 } |
|
1283 case RMobilePhone::ESecurityUniversalPin: |
|
1284 if(iSecCodes.iUniversalPin==(*aCode).iCode) |
|
1285 { |
|
1286 SecurityEvent(RMobilePhone::EUniversalPinVerified); |
|
1287 break; |
|
1288 } |
|
1289 else |
|
1290 { |
|
1291 iPhone->ReqCompleted(aReqHandle,KErrArgument); |
|
1292 return KErrNone; |
|
1293 } |
|
1294 // Not supported |
|
1295 // case RMobilePhone::ESecurityCodePhonePassword: |
|
1296 // case RMobilePhone::ESecurityCodeSPC: |
|
1297 |
|
1298 default: |
|
1299 iPhone->ReqCompleted(aReqHandle,KErrNotSupported); |
|
1300 return KErrNone; |
|
1301 } |
|
1302 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1303 return KErrNone; |
|
1304 } |
|
1305 |
|
1306 TInt CSimPhoneSecurity::VerifySecurityCodeCancel(const TTsyReqHandle aReqHandle) |
|
1307 { |
|
1308 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1309 return KErrNone; |
|
1310 } |
|
1311 |
|
1312 TInt CSimPhoneSecurity::AbortSecurityCode(const TTsyReqHandle aReqHandle, RMobilePhone::TMobilePhoneSecurityCode* /*aType*/) |
|
1313 { |
|
1314 iPhone->ReqCompleted(aReqHandle,KErrNone); |
|
1315 return KErrNone; |
|
1316 } |
|
1317 |
|
1318 |
|
1319 TInt CSimPhoneSecurity::NotifySecurityEvent(const TTsyReqHandle aTsyReqHandle, TDes8* aPckg1) |
|
1320 /** |
|
1321 * Registers a Client Interest in security event |
|
1322 * |
|
1323 */ |
|
1324 { |
|
1325 __ASSERT_ALWAYS(!iNotifyEvent.iNotifyPending,SimPanic(ENotificationReqAlreadyOutstanding)); |
|
1326 |
|
1327 TPckg<TUint32>* eventPckg=(TPckg<TUint32>*)aPckg1; |
|
1328 TUint32& event=(*eventPckg)(); |
|
1329 |
|
1330 TInt count = iICCStatusProfile->Count(); |
|
1331 |
|
1332 if (iNotifySecurityEventsTimer->iIndex < count) |
|
1333 { |
|
1334 TICCStatusEntry entry = iICCStatusProfile->At(iNotifySecurityEventsTimer->iIndex); |
|
1335 if(iNotifySecurityEventsTimer->iTimerStarted) |
|
1336 { |
|
1337 delete iNotifySecurityEventsTimer->iTimer; |
|
1338 iNotifySecurityEventsTimer->iTimer=NULL; |
|
1339 TRAPD(err,iNotifySecurityEventsTimer->iTimer=CSimTimer::NewL(iPhone)); |
|
1340 if (err!=KErrNone) |
|
1341 { |
|
1342 return (err); |
|
1343 } |
|
1344 } |
|
1345 iNotifySecurityEventsTimer->iTimer->Start(entry.iDuration, this, ETimerIdSecurityNotifyEvent); |
|
1346 iNotifySecurityEventsTimer->iTimerStarted = ETrue; |
|
1347 } |
|
1348 |
|
1349 iNotifyEvent.iNotifyPending=ETrue; |
|
1350 iNotifyEvent.iNotifyHandle=aTsyReqHandle; |
|
1351 iNotifyEvent.iNotifyData=&event; |
|
1352 |
|
1353 return KErrNone; |
|
1354 } |
|
1355 |
|
1356 TInt CSimPhoneSecurity::NotifySecurityEventCancel(const TTsyReqHandle aTsyReqHandle) |
|
1357 /** |
|
1358 * De-registeres the client interest in security events |
|
1359 * |
|
1360 */ |
|
1361 { |
|
1362 if(iNotifyEvent.iNotifyPending) |
|
1363 { |
|
1364 iNotifyEvent.iNotifyPending=EFalse; |
|
1365 iPhone->ReqCompleted(aTsyReqHandle, KErrCancel); |
|
1366 return KErrNone; |
|
1367 } |
|
1368 iPhone->ReqCompleted(aTsyReqHandle, KErrNone); |
|
1369 return KErrNone; |
|
1370 } |
|
1371 |
|
1372 |
|
1373 void CSimPhoneSecurity::SecurityEvent(RMobilePhone::TMobilePhoneSecurityEvent aEvent) |
|
1374 /** |
|
1375 * Hanldes events related to the ICC state (locked/unlocked) |
|
1376 * |
|
1377 */ |
|
1378 { |
|
1379 switch(aEvent) |
|
1380 { |
|
1381 case RMobilePhone::EPin1Required: |
|
1382 LockICC(); |
|
1383 break; |
|
1384 case RMobilePhone::EPin1Verified: |
|
1385 UnLockICC(); |
|
1386 break; |
|
1387 case RMobilePhone::EPin2Required: |
|
1388 LockPIN2(); |
|
1389 break; |
|
1390 case RMobilePhone::EPin2Verified: |
|
1391 UnLockPIN2(); |
|
1392 break; |
|
1393 case RMobilePhone::EHiddenKeyRequired: |
|
1394 HideEntries(); |
|
1395 break; |
|
1396 case RMobilePhone::EHiddenKeyVerified: |
|
1397 ShowHidden(); |
|
1398 break; |
|
1399 case RMobilePhone::ESPCVerified: |
|
1400 return; |
|
1401 |
|
1402 case RMobilePhone::ESPCRequired: |
|
1403 return; |
|
1404 case RMobilePhone::ENoICCFound: |
|
1405 case RMobilePhone::EICCTerminated: |
|
1406 case RMobilePhone::EPhonePasswordRequired: |
|
1407 case RMobilePhone::EPhonePasswordVerified: |
|
1408 case RMobilePhone::ESecondUSIMAppPinRequired: |
|
1409 case RMobilePhone::ESecondUSIMAppPinVerified: |
|
1410 case RMobilePhone::EUniversalPinRequired: |
|
1411 case RMobilePhone::EUniversalPinVerified: |
|
1412 return; |
|
1413 |
|
1414 case RMobilePhone::EUSIMAppPinRequired: |
|
1415 case RMobilePhone::EUSIMAppPinVerified: |
|
1416 break; |
|
1417 |
|
1418 case RMobilePhone::ESPCChanged: |
|
1419 // FALLTHRU |
|
1420 default: |
|
1421 LOGPHONE4("CSimPhoneSecurity::SecurityEvent %d OOR [%d,%d]", |
|
1422 aEvent, RMobilePhone::ENoICCFound, RMobilePhone::ESPCChanged); |
|
1423 return; |
|
1424 } |
|
1425 |
|
1426 if(iNotifyEvent.iNotifyPending) |
|
1427 { |
|
1428 iNotifyEvent.iNotifyPending=EFalse; |
|
1429 *(RMobilePhone::TMobilePhoneSecurityEvent*)iNotifyEvent.iNotifyData=aEvent; |
|
1430 iPhone->ReqCompleted(iNotifyEvent.iNotifyHandle, KErrNone); |
|
1431 } |
|
1432 } |
|
1433 |
|
1434 void CSimPhoneSecurity::TimerCallBack(TInt aId) |
|
1435 /** |
|
1436 * The timer callback function. This function will be called when the timer |
|
1437 * completes. It indicates a change in ICC state. So, the new |
|
1438 * ICC state settings must be loaded into the member variables representing |
|
1439 * the current settings Finally, the next timer is started. |
|
1440 * |
|
1441 * @param aId This parameter is unused. It is only required for CSimXxx classes |
|
1442 * that have more than one timer instance and need to identify which |
|
1443 * timer has expired. |
|
1444 */ |
|
1445 { |
|
1446 if(aId == ETimerIdSecurityNotifyEvent) |
|
1447 { |
|
1448 if((iNotifySecurityEventsTimer->iIndex < iICCStatusProfile->Count()) && iNotifyEvent.iNotifyPending) |
|
1449 { |
|
1450 TICCStatusEntry entry = iICCStatusProfile->At(iNotifySecurityEventsTimer->iIndex); |
|
1451 SecurityEvent(entry.iICCStatus); |
|
1452 iNotifySecurityEventsTimer->iIndex++; |
|
1453 } |
|
1454 } |
|
1455 else if(aId == ETimerIdSecurityNotifyLockInfo) |
|
1456 { |
|
1457 if((iNotifySettingsTimer->iIndex < iICCSettingProfile->Count()) && iNotifyLock.iNotifyPending) |
|
1458 { |
|
1459 TICCSettingEntry entry = iICCSettingProfile->At(iNotifySettingsTimer->iIndex); |
|
1460 UpdateLockInfo(entry.iLock, entry.iLockInfo); |
|
1461 iNotifySettingsTimer->iIndex++; |
|
1462 iNotifySettingsTimer->iTimerStarted = EFalse; |
|
1463 CompleteNotifyLockInfoChange(entry.iLock, entry.iLockInfo); |
|
1464 } |
|
1465 } |
|
1466 |
|
1467 } |
|
1468 |
|
1469 TBool CSimPhoneSecurity::IsICCLocked() |
|
1470 { |
|
1471 if((iSecStatus.iPin1==RMobilePhone::EStatusLocked) && |
|
1472 (iSecSetting.iPin1==RMobilePhone::ELockSetEnabled)) |
|
1473 return ETrue; |
|
1474 |
|
1475 return EFalse; |
|
1476 } |
|
1477 |
|
1478 TBool CSimPhoneSecurity::IsPIN2Locked() |
|
1479 { |
|
1480 if((iSecStatus.iPin2==RMobilePhone::EStatusLocked) && |
|
1481 (iSecSetting.iPin2==RMobilePhone::ELockSetEnabled)) |
|
1482 return ETrue; |
|
1483 |
|
1484 return EFalse; |
|
1485 } |
|
1486 |
|
1487 void CSimPhoneSecurity::LockICC() |
|
1488 { |
|
1489 iSecStatus.iPin1=RMobilePhone::EStatusLocked; |
|
1490 return; |
|
1491 } |
|
1492 |
|
1493 void CSimPhoneSecurity::UnLockICC() |
|
1494 { |
|
1495 iSecStatus.iPin1=RMobilePhone::EStatusUnlocked; |
|
1496 return; |
|
1497 } |
|
1498 |
|
1499 void CSimPhoneSecurity::LockPIN2() |
|
1500 { |
|
1501 iSecStatus.iPin2=RMobilePhone::EStatusLocked; |
|
1502 return; |
|
1503 } |
|
1504 |
|
1505 void CSimPhoneSecurity::UnLockPIN2() |
|
1506 { |
|
1507 iSecStatus.iPin2=RMobilePhone::EStatusUnlocked; |
|
1508 return; |
|
1509 } |
|
1510 |
|
1511 TBool CSimPhoneSecurity::IsHiddenEnabled() |
|
1512 { |
|
1513 if((iSecStatus.iPhBkHiddenKey==RMobilePhone::EStatusLocked) && |
|
1514 (iSecSetting.iPhBkHiddenKey==RMobilePhone::ELockSetEnabled)) |
|
1515 return ETrue; |
|
1516 |
|
1517 return EFalse; |
|
1518 } |
|
1519 |
|
1520 void CSimPhoneSecurity::HideEntries() |
|
1521 { |
|
1522 iSecStatus.iPhBkHiddenKey=RMobilePhone::EStatusLocked; |
|
1523 return; |
|
1524 } |
|
1525 |
|
1526 void CSimPhoneSecurity::ShowHidden() |
|
1527 { |
|
1528 iSecStatus.iPhBkHiddenKey=RMobilePhone::EStatusUnlocked; |
|
1529 return; |
|
1530 } |
|
1531 |
|
1532 void CSimPhoneSecurity::LockSpc() |
|
1533 { |
|
1534 if (iNotifyLock.iNotifyPending) |
|
1535 { |
|
1536 // there is a notification waiting |
|
1537 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
1538 |
|
1539 lockInfo.iStatus = RMobilePhone::EStatusLocked; |
|
1540 lockInfo.iSetting = RMobilePhone::ELockSetEnabled; |
|
1541 CompleteNotifyLockInfoChange(RMobilePhone::ELockNam, lockInfo); |
|
1542 } |
|
1543 iSecStatus.iSPC=RMobilePhone::EStatusLocked; |
|
1544 return; |
|
1545 } |
|
1546 |
|
1547 void CSimPhoneSecurity::UnLockSpc() |
|
1548 { |
|
1549 if (iNotifyLock.iNotifyPending) |
|
1550 { |
|
1551 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
1552 |
|
1553 lockInfo.iStatus = RMobilePhone::EStatusUnlocked; |
|
1554 lockInfo.iSetting = RMobilePhone::ELockSetEnabled; |
|
1555 // there is a notification waiting |
|
1556 CompleteNotifyLockInfoChange(RMobilePhone::ELockNam, lockInfo); |
|
1557 } |
|
1558 iSecStatus.iSPC=RMobilePhone::EStatusUnlocked; |
|
1559 return; |
|
1560 } |
|
1561 |
|
1562 CSimPhoneSecurity::CIccTimer::CIccTimer() |
|
1563 : iTimerStarted(EFalse) |
|
1564 , iIndex(0) |
|
1565 , iTimer(NULL) |
|
1566 { |
|
1567 } |
|
1568 |
|
1569 CSimPhoneSecurity::CIccTimer::~CIccTimer() |
|
1570 { |
|
1571 if(iTimer) |
|
1572 iTimer->Cancel(); |
|
1573 delete iTimer; |
|
1574 } |
|
1575 |
|
1576 CSimPhoneSecurity::CIccTimer* CSimPhoneSecurity::CIccTimer::NewL() |
|
1577 { |
|
1578 CSimPhoneSecurity::CIccTimer* self = new(ELeave)CSimPhoneSecurity::CIccTimer; |
|
1579 return self; |
|
1580 } |
|
1581 |
|
1582 TInt CSimPhoneSecurity::UpdateLockInfo(RMobilePhone::TMobilePhoneLock aLock, const RMobilePhone::TMobilePhoneLockInfoV1& aLockInfo) |
|
1583 { |
|
1584 TInt err = KErrNone; |
|
1585 switch(aLock) |
|
1586 { |
|
1587 case RMobilePhone::ELockICC: |
|
1588 iSecSetting.iPin1 = aLockInfo.iSetting; |
|
1589 iSecStatus.iPin1 = aLockInfo.iStatus; |
|
1590 break; |
|
1591 case RMobilePhone::ELockPin2: |
|
1592 iSecSetting.iPin2 = aLockInfo.iSetting; |
|
1593 iSecStatus.iPin2 = aLockInfo.iStatus; |
|
1594 break; |
|
1595 case RMobilePhone::ELockHiddenKey: |
|
1596 iSecSetting.iPhBkHiddenKey = aLockInfo.iSetting; |
|
1597 iSecStatus.iPhBkHiddenKey = aLockInfo.iStatus; |
|
1598 break; |
|
1599 case RMobilePhone::ELockUSimApp: |
|
1600 iSecSetting.iUSimAppPin = aLockInfo.iSetting; |
|
1601 iSecStatus.iUSimAppPin = aLockInfo.iStatus; |
|
1602 break; |
|
1603 case RMobilePhone::ELockSecondUSimApp: |
|
1604 iSecSetting.iSecondUSimAppPin = aLockInfo.iSetting; |
|
1605 iSecStatus.iSecondUSimAppPin = aLockInfo.iStatus; |
|
1606 break; |
|
1607 case RMobilePhone::ELockUniversalPin: |
|
1608 iSecSetting.iUniversalPin = aLockInfo.iSetting; |
|
1609 iSecStatus.iUniversalPin = aLockInfo.iStatus; |
|
1610 break; |
|
1611 |
|
1612 case RMobilePhone::ELockNam: |
|
1613 err = KErrNotSupported; |
|
1614 |
|
1615 break; |
|
1616 |
|
1617 // Not supported! |
|
1618 // case RMobilePhone::ELockPhoneDevice: |
|
1619 // case RMobilePhone::ELockPhoneToIcc: |
|
1620 // case RMobilePhone::ELockPhoneToFirstIcc: |
|
1621 // case RMobilePhone::ELockOTA: |
|
1622 |
|
1623 default: |
|
1624 err = KErrNotSupported; |
|
1625 } |
|
1626 return err; |
|
1627 } |
|
1628 |
|
1629 void CSimPhoneSecurity::Pin1Failure() |
|
1630 /** |
|
1631 Handle wrong PIN1 entry. Decrement the entry counter, lock the corresponding lock after the maximum |
|
1632 of entry. Complete the Security Code Info Change Notification if the counter has changed |
|
1633 */ |
|
1634 { |
|
1635 if (iSecurityCodeRemainigAttempts.iPin1 > 0) |
|
1636 { |
|
1637 iSecurityCodeRemainigAttempts.iPin1--; |
|
1638 if (iSecurityCodeRemainigAttempts.iPin1 == 0) |
|
1639 { |
|
1640 iSecStatus.iPin1 = RMobilePhone::EStatusBlocked; |
|
1641 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
1642 |
|
1643 lockInfo.iSetting = iSecSetting.iPin1; |
|
1644 lockInfo.iStatus = iSecStatus.iPin1; |
|
1645 CompleteNotifyLockInfoChange(RMobilePhone::ELockICC,lockInfo); |
|
1646 } |
|
1647 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1648 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1649 |
|
1650 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin1; |
|
1651 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePin1,securityCodeInfo); |
|
1652 } |
|
1653 } |
|
1654 |
|
1655 void CSimPhoneSecurity::Pin1Success() |
|
1656 /** |
|
1657 Handle correct PIN1 entry. if require, Reset the entry counter and complete the Security Code Info |
|
1658 Change Notification. |
|
1659 */ |
|
1660 { |
|
1661 if (iSecurityCodeRemainigAttempts.iPin1 < iSecurityCodeDefaultRemainigAttempts.iPin1) |
|
1662 { |
|
1663 iSecurityCodeRemainigAttempts.iPin1 = iSecurityCodeDefaultRemainigAttempts.iPin1; |
|
1664 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1665 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1666 |
|
1667 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin1; |
|
1668 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePin1,securityCodeInfo); |
|
1669 } |
|
1670 } |
|
1671 |
|
1672 void CSimPhoneSecurity::Pin2Failure() |
|
1673 /** |
|
1674 Handle wrong PIN2 entry. Decrement the entry counter, lock the corresponding lock after the maximum |
|
1675 of entry. Complete the Security Code Info Change Notification if the counter has changed |
|
1676 */ |
|
1677 { |
|
1678 if (iSecurityCodeRemainigAttempts.iPin2 > 0) |
|
1679 { |
|
1680 iSecurityCodeRemainigAttempts.iPin2--; |
|
1681 if (iSecurityCodeRemainigAttempts.iPin2 == 0) |
|
1682 { |
|
1683 iSecStatus.iPin2 = RMobilePhone::EStatusBlocked; |
|
1684 RMobilePhone::TMobilePhoneLockInfoV1 lockInfo; |
|
1685 |
|
1686 lockInfo.iSetting = iSecSetting.iPin2; |
|
1687 lockInfo.iStatus = iSecStatus.iPin2; |
|
1688 CompleteNotifyLockInfoChange(RMobilePhone::ELockPin2,lockInfo); |
|
1689 } |
|
1690 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1691 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1692 |
|
1693 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin2; |
|
1694 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePin2,securityCodeInfo); |
|
1695 } |
|
1696 } |
|
1697 |
|
1698 void CSimPhoneSecurity::Pin2Success() |
|
1699 /** |
|
1700 Handle correct PIN2 entry. if require, Reset the entry counter and complete the Security Code Info |
|
1701 Change Notification. |
|
1702 */ |
|
1703 { |
|
1704 if (iSecurityCodeRemainigAttempts.iPin2 < iSecurityCodeDefaultRemainigAttempts.iPin2) |
|
1705 { |
|
1706 iSecurityCodeRemainigAttempts.iPin2 = iSecurityCodeDefaultRemainigAttempts.iPin2; |
|
1707 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1708 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1709 |
|
1710 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPin2; |
|
1711 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePin2,securityCodeInfo); |
|
1712 } |
|
1713 } |
|
1714 |
|
1715 void CSimPhoneSecurity::Puk1Failure() |
|
1716 /** |
|
1717 Handle wrong PUK1 entry. Decrement the entry counter. Complete the Security Code Info Change Notification |
|
1718 if the counter has changed |
|
1719 */ |
|
1720 { |
|
1721 if (iSecurityCodeRemainigAttempts.iPuk1 > 0) |
|
1722 { |
|
1723 iSecurityCodeRemainigAttempts.iPuk1--; |
|
1724 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1725 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1726 |
|
1727 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk1; |
|
1728 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePuk1,securityCodeInfo); |
|
1729 } |
|
1730 } |
|
1731 |
|
1732 void CSimPhoneSecurity::Puk1Success() |
|
1733 /** |
|
1734 Handle correct PUK1 entry. if require, Reset the entry counter and complete the Security Code Info |
|
1735 Change Notification. |
|
1736 */ |
|
1737 { |
|
1738 if (iSecurityCodeRemainigAttempts.iPuk1 < iSecurityCodeDefaultRemainigAttempts.iPuk1) |
|
1739 { |
|
1740 iSecurityCodeRemainigAttempts.iPuk1 = iSecurityCodeDefaultRemainigAttempts.iPuk1; |
|
1741 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1742 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1743 |
|
1744 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk1; |
|
1745 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePuk1,securityCodeInfo); |
|
1746 } |
|
1747 } |
|
1748 |
|
1749 void CSimPhoneSecurity::Puk2Failure() |
|
1750 /** |
|
1751 Handle wrong PUK2 entry. Decrement the entry counter. Complete the Security Code Info Change Notification |
|
1752 if the counter has changed |
|
1753 */ |
|
1754 { |
|
1755 if (iSecurityCodeRemainigAttempts.iPuk2 > 0) |
|
1756 { |
|
1757 iSecurityCodeRemainigAttempts.iPuk2--; |
|
1758 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1759 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1760 |
|
1761 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk2; |
|
1762 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePuk2,securityCodeInfo); |
|
1763 } |
|
1764 } |
|
1765 |
|
1766 void CSimPhoneSecurity::Puk2Success() |
|
1767 /** |
|
1768 Handle correct PUK2 entry. if require, Reset the entry counter and complete the Security Code Info |
|
1769 Change Notification. |
|
1770 */ |
|
1771 { |
|
1772 if (iSecurityCodeRemainigAttempts.iPuk2 < iSecurityCodeDefaultRemainigAttempts.iPuk2) |
|
1773 { |
|
1774 iSecurityCodeRemainigAttempts.iPuk2 = iSecurityCodeDefaultRemainigAttempts.iPuk2; |
|
1775 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 securityCodeInfo; |
|
1776 // Simulated version checking is omitted in this case - function is called after a ReqCompleted |
|
1777 |
|
1778 securityCodeInfo.iRemainingEntryAttempts = iSecurityCodeRemainigAttempts.iPuk2; |
|
1779 CompleteNotifySecurityCodeInfoChange(RMobilePhone::ESecurityCodePuk2,securityCodeInfo); |
|
1780 } |
|
1781 } |
|
1782 |
|
1783 void CSimPhoneSecurity::CompleteNotifyLockInfoChange(RMobilePhone::TMobilePhoneLock aLock, const RMobilePhone::TMobilePhoneLockInfoV1& aLockInfo) |
|
1784 { |
|
1785 if (iNotifyLock.iNotifyPending) |
|
1786 { |
|
1787 *(RMobilePhone::TMobilePhoneLockInfoV1*)iNotifyLock.iNotifyData=aLockInfo; |
|
1788 *(RMobilePhone::TMobilePhoneLock*)iNotifyLock.iNotifyDataXtra=aLock; |
|
1789 iNotifyLock.iNotifyPending=EFalse; |
|
1790 iPhone->ReqCompleted(iNotifyLock.iNotifyHandle,KErrNone); |
|
1791 } |
|
1792 } |
|
1793 |
|
1794 void CSimPhoneSecurity::CompleteNotifySecurityCodeInfoChange(RMobilePhone::TMobilePhoneSecurityCode aSecurityCode, const RMobilePhone::TMobilePhoneSecurityCodeInfoV5& aSecurityCodeInfo) |
|
1795 /** |
|
1796 Complete a Security code info notification if pending. |
|
1797 |
|
1798 @param aSecurityCode security code that must be notified |
|
1799 @param aSecurityCodeInfo security code information for the notification |
|
1800 */ |
|
1801 { |
|
1802 if (iNotifySecurityCodeInfo.iNotifyPending) |
|
1803 { |
|
1804 *reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCodeInfoV5*>(iNotifySecurityCodeInfo.iNotifyData)=aSecurityCodeInfo; |
|
1805 *reinterpret_cast<RMobilePhone::TMobilePhoneSecurityCode*>(iNotifySecurityCodeInfo.iNotifyDataXtra)=aSecurityCode; |
|
1806 iNotifySecurityCodeInfo.iNotifyPending=EFalse; |
|
1807 iPhone->ReqCompleted(iNotifySecurityCodeInfo.iNotifyHandle,KErrNone); |
|
1808 } |
|
1809 } |
|
1810 |