13 * |
13 * |
14 * Description: Provides api for handling security events. |
14 * Description: Provides api for handling security events. |
15 * |
15 * |
16 * |
16 * |
17 */ |
17 */ |
18 |
18 #include <e32notif.h> |
19 |
|
20 #include <aknnotedialog.h> |
19 #include <aknnotedialog.h> |
21 #include <etelmm.h> |
20 #include <etelmm.h> |
22 #include <SecUi.rsg> |
21 // #include <SecUi.rsg> |
23 #include <exterror.h> |
22 #include <exterror.h> |
24 #include <textresolver.h> |
23 #include <textresolver.h> |
25 |
24 |
26 #ifdef __COVER_DISPLAY |
25 #ifdef __COVER_DISPLAY |
27 #include <aknmediatorfacade.h> |
26 #include <aknmediatorfacade.h> |
28 // #include <secondarydisplay/SecondaryDisplayStartupAPI.h> |
27 // #include <secondarydisplay/SecondaryDisplayStartupAPI.h> |
29 #endif //__COVER_DISPLAY |
28 #endif //__COVER_DISPLAY |
30 #include <centralrepository.h> |
29 #include <centralrepository.h> |
31 #include <starterclient.h> //used for RemoveSplashScreen |
30 #include <starterclient.h> //used for RemoveSplashScreen |
32 #include <e32property.h> |
31 #include <e32property.h> |
|
32 |
33 #include <PSVariables.h> // Property values |
33 #include <PSVariables.h> // Property values |
34 #include <coreapplicationuisdomainpskeys.h> |
34 #include <coreapplicationuisdomainpskeys.h> |
35 #include <startupdomainpskeys.h> |
35 #include <startupdomainpskeys.h> |
36 #include <uikon/eiksrvui.h> |
36 #include <uikon/eiksrvui.h> |
37 #include <settingsinternalcrkeys.h> |
37 #include <settingsinternalcrkeys.h> |
39 #include <AknNotiferAppServerApplication.h> |
39 #include <AknNotiferAppServerApplication.h> |
40 |
40 |
41 #include <SCPClient.h> |
41 #include <SCPClient.h> |
42 #include <securitynotification.h> |
42 #include <securitynotification.h> |
43 #include "secui.hrh" |
43 #include "secui.hrh" |
|
44 #include "SecUi.h" |
44 #include "secuisecurityhandler.h" |
45 #include "secuisecurityhandler.h" |
45 #include "secuicodequerydialog.h" |
46 #include "secuicodequerydialog.h" |
46 #include "secuisecuritysettings.h" |
47 #include "secuisecuritysettings.h" |
47 #include "SecUiWait.h" |
48 #include "SecUiWait.h" |
48 #include "SecUiLockObserver.h" |
49 // #include "SecUiLockObserver.h" |
49 #ifdef RD_REMOTELOCK |
|
50 #include <RemoteLockSettings.h> |
50 #include <RemoteLockSettings.h> |
51 #endif // RD_REMOTELOCK |
|
52 #include <StringLoader.h> |
51 #include <StringLoader.h> |
53 #include <featmgr.h> |
52 #include <featmgr.h> |
54 |
53 |
55 #include "SecQueryUi.h" |
54 #include "SecQueryUi.h" |
56 |
55 |
57 // LOCAL CONSTANTS AND MACROS |
56 // LOCAL CONSTANTS AND MACROS |
58 const TInt KMaxNumberOfPUKAttempts(10); |
57 const TInt KMaxNumberOfPUKAttempts(10); |
59 const TInt KMaxNumberOfPINAttempts(3); |
58 const TInt KMaxNumberOfPINAttempts(3); |
60 const TInt KLastRemainingInputAttempt(1); |
59 // not used |
|
60 // const TInt KLastRemainingInputAttempt(1); |
61 |
61 |
62 const TInt KTriesToConnectServer(2); |
62 const TInt KTriesToConnectServer(2); |
63 const TInt KTimeBeforeRetryingRequest(50000); |
63 const TInt KTimeBeforeRetryingRequest(50000); |
64 |
64 |
65 // ================= MEMBER FUNCTIONS ======================= |
65 // ================= MEMBER FUNCTIONS ======================= |
348 iQueryCanceled = ETrue; |
347 iQueryCanceled = ETrue; |
349 return ret; |
348 return ret; |
350 } |
349 } |
351 // |
350 // |
352 // ---------------------------------------------------------- |
351 // ---------------------------------------------------------- |
|
352 // Cancels all security code queries |
|
353 // aStatus = -1 from destructor |
|
354 // aStatus = 1 from API. Will kill all dialogs through signal P&S |
|
355 // ---------------------------------------------------------- |
|
356 // qtdone |
|
357 TInt CSecurityHandler::CancelOpenQuery(TInt aStatus) |
|
358 { |
|
359 RDEBUG("aStatus", aStatus); |
|
360 RDEBUG("iQueryCanceled", iQueryCanceled); |
|
361 TInt res = 0; |
|
362 |
|
363 if(aStatus==1) // also signal all other dialogs |
|
364 { |
|
365 RDEBUG("set KSecurityUIsDismissDialog to ESecurityUIsDismissDialogOn", ESecurityUIsDismissDialogOn); |
|
366 TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn ); |
|
367 RDEBUG("err", err); |
|
368 res += 1; |
|
369 } |
|
370 |
|
371 if (!iQueryCanceled) |
|
372 { |
|
373 // notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged |
|
374 // this will cancel only the dialog which was opened by same client. |
|
375 res += 0x10; |
|
376 iQueryCanceled = ETrue; |
|
377 if (iSecurityDlg != NULL) |
|
378 { |
|
379 RDEBUG("deleting iSecurityDlg", 0); |
|
380 res += 0x100; |
|
381 delete iSecurityDlg; |
|
382 } |
|
383 if (iNoteDlg != NULL) |
|
384 { |
|
385 RDEBUG("deleting iNoteDlg", 0); |
|
386 res += 0x1000; |
|
387 delete iNoteDlg; |
|
388 } |
|
389 iNoteDlg = NULL; |
|
390 iSecurityDlg = NULL; |
|
391 } |
|
392 res += 0x10000; |
|
393 RDEBUG("res", res); |
|
394 return res; |
|
395 } |
|
396 |
|
397 // |
|
398 // ---------------------------------------------------------- |
353 // CSecurityHandler::CancelSecCodeQuery() |
399 // CSecurityHandler::CancelSecCodeQuery() |
354 // Cancels PIN2 and security code queries |
400 // Cancels PIN2 and security code queries |
355 // TODO is this used? |
401 // this is used by rfsHandler |
356 // ---------------------------------------------------------- |
402 // ---------------------------------------------------------- |
357 // qtdone |
403 // qtdone |
358 EXPORT_C void CSecurityHandler::CancelSecCodeQuery() |
404 EXPORT_C void CSecurityHandler::CancelSecCodeQuery() |
359 { |
405 { |
360 #if defined(_DEBUG) |
406 RDEBUG("0", 0); |
361 RDebug::Print(_L("(SECUI)CSecurityHandler::CancelSecCodeQuery()")); |
407 |
362 #endif |
408 TInt err = CancelOpenQuery(1); |
363 if (!iQueryCanceled) |
409 |
364 { |
410 RDEBUG("err", err); |
365 iQueryCanceled = ETrue; |
|
366 if (iSecurityDlg != NULL) |
|
367 { |
|
368 delete iSecurityDlg; |
|
369 } |
|
370 if (iNoteDlg != NULL) |
|
371 { |
|
372 delete iNoteDlg; |
|
373 } |
|
374 iNoteDlg = NULL; |
|
375 iSecurityDlg = NULL; |
|
376 } |
|
377 } |
411 } |
378 // |
412 // |
379 // ---------------------------------------------------------- |
413 // ---------------------------------------------------------- |
380 // CSecurityHandler::AskSecCodeInAutoLock() |
414 // CSecurityHandler::AskSecCodeInAutoLock() |
381 // for asking security code in autolock |
415 // for asking security code in autolock |
387 * Series 60 Customer / ETel |
421 * Series 60 Customer / ETel |
388 * Series 60 ETel API |
422 * Series 60 ETel API |
389 *****************************************************/ |
423 *****************************************************/ |
390 |
424 |
391 RDEBUG("0", 0); |
425 RDEBUG("0", 0); |
392 |
|
393 #if defined(_DEBUG) |
|
394 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL()")); |
|
395 #endif |
|
396 TInt res; |
426 TInt res; |
397 CWait* wait; |
427 CWait* wait; |
398 |
428 |
399 RMobilePhone::TMobilePhoneLockSetting lockChange( |
429 RMobilePhone::TMobilePhoneLockSetting lockChange( |
400 RMobilePhone::ELockSetDisabled); |
430 RMobilePhone::ELockSetDisabled); |
401 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
431 RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; |
402 |
|
403 #if defined(_DEBUG) |
|
404 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() get autolock period")); |
|
405 #endif |
|
406 |
432 |
407 // get autolock period from Central Repository. |
433 // get autolock period from Central Repository. |
408 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
434 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); |
409 TInt period = 0; |
435 TInt period = 0; |
410 res = repository->Get(KSettingsAutoLockTime, period); |
436 res = repository->Get(KSettingsAutoLockTime, period); |
411 delete repository; |
437 delete repository; |
412 |
438 |
413 RDEBUG("res", res); |
439 RDEBUG("res", res); |
414 |
440 RDEBUG("period", period); |
415 #if defined(_DEBUG) |
441 |
416 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() autolock period:%d"), res); |
|
417 #endif |
|
418 if (res == KErrNone) |
442 if (res == KErrNone) |
419 { |
443 { |
420 // disable autolock in Domestic OS side too if autolock period is 0. |
444 // disable autolock in Domestic OS side too if autolock period is 0. |
421 RDEBUG("period", period); |
|
422 if (period == 0) |
445 if (period == 0) |
423 { |
446 { |
424 #if defined(_DEBUG) |
447 RDEBUG("period", period); |
425 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting")); |
448 |
426 #endif |
|
427 |
|
428 #ifdef RD_REMOTELOCK |
|
429 // If remote lock is enabled, don't disable the domestic OS device lock |
449 // If remote lock is enabled, don't disable the domestic OS device lock |
430 // since that would render the RemoteLock useless. |
450 // since that would render the RemoteLock useless. |
431 // Instead just re-set the DOS lock to enabled which as a side effect |
451 // Instead just re-set the DOS lock to enabled which as a side effect |
432 // requests the security code from the user. |
452 // requests the security code from the user. |
433 |
453 |
438 { |
458 { |
439 RDEBUG( "0", 0 ); |
459 RDEBUG( "0", 0 ); |
440 if ( remoteLockStatus ) |
460 if ( remoteLockStatus ) |
441 { |
461 { |
442 // Remote lock is enabled |
462 // Remote lock is enabled |
443 #ifdef _DEBUG |
|
444 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) ); |
|
445 #endif // _DEBUG |
|
446 lockChange = RMobilePhone::ELockSetEnabled; |
463 lockChange = RMobilePhone::ELockSetEnabled; |
|
464 RDEBUG("lockChange", lockChange); |
447 } |
465 } |
448 else |
466 else |
449 { |
467 { |
450 // Remote lock is disabled |
468 // Remote lock is disabled |
451 #ifdef _DEBUG |
|
452 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) ); |
|
453 #endif // _DEBUG |
|
454 lockChange = RMobilePhone::ELockSetDisabled; |
469 lockChange = RMobilePhone::ELockSetDisabled; |
|
470 RDEBUG("lockChange", lockChange); |
455 } |
471 } |
456 } |
472 } |
457 else |
473 else |
458 { |
474 { |
459 // Failed to get remote lock status |
475 // Failed to get remote lock status |
460 #ifdef _DEBUG |
476 RDEBUG("Failed", lockChange); |
461 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get RemoteLock status" ) ); |
|
462 #endif // _DEBUG |
|
463 } |
477 } |
464 |
478 |
465 delete remoteLockSettings; |
479 delete remoteLockSettings; |
466 remoteLockSettings = NULL; |
480 remoteLockSettings = NULL; |
467 |
481 |
468 #else // not defined RD_REMOTELOCK |
|
469 lockChange = RMobilePhone::ELockSetDisabled; |
|
470 |
|
471 #endif // RD_REMOTELOCK |
|
472 RDEBUG("lockChange", lockChange); |
482 RDEBUG("lockChange", lockChange); |
473 wait = CWait::NewL(); |
483 wait = CWait::NewL(); |
474 RDEBUG("0", 0); |
484 RDEBUG("0", 0); |
475 // this also calls PassPhraseRequiredL ??? |
485 // this also calls PassPhraseRequiredL ??? |
476 RDEBUG("SetLockSetting", 1); |
486 RDEBUG("SetLockSetting", 1); |
536 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
535 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
537 { |
536 { |
538 if ( remoteLockStatus ) |
537 if ( remoteLockStatus ) |
539 { |
538 { |
540 // Remote lock is enabled |
539 // Remote lock is enabled |
541 #ifdef _DEBUG |
|
542 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) ); |
|
543 #endif // _DEBUG |
|
544 lockChange = RMobilePhone::ELockSetEnabled; |
540 lockChange = RMobilePhone::ELockSetEnabled; |
|
541 RDEBUG("lockChange", lockChange); |
545 } |
542 } |
546 else |
543 else |
547 { |
544 { |
548 // Remote lock is disabled |
545 // Remote lock is disabled |
549 #ifdef _DEBUG |
|
550 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) ); |
|
551 #endif // _DEBUG |
|
552 lockChange = RMobilePhone::ELockSetDisabled; |
546 lockChange = RMobilePhone::ELockSetDisabled; |
|
547 RDEBUG("lockChange", lockChange); |
553 } |
548 } |
554 } |
549 } |
555 else |
550 else |
556 { |
551 { |
557 // Failed to get remote lock status |
552 // Failed to get remote lock status |
558 #ifdef _DEBUG |
553 RDEBUG("Failed", lockChange); |
559 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and failed to get RemoteLock status" ) ); |
|
560 #endif // _DEBUG |
|
561 } |
554 } |
562 |
555 |
563 delete remoteLockSettings; |
556 delete remoteLockSettings; |
564 remoteLockSettings = NULL; |
557 remoteLockSettings = NULL; |
565 |
558 |
566 #else // not defined RD_REMOTELOCK |
|
567 // could not get the current autolock time... disable autolock in Domestic OS side. |
|
568 lockChange = RMobilePhone::ELockSetDisabled; |
|
569 |
|
570 #endif // RD_REMOTELOCK |
|
571 RDEBUG("0", 0); |
559 RDEBUG("0", 0); |
572 |
|
573 wait = CWait::NewL(); |
560 wait = CWait::NewL(); |
574 RDEBUG("SetLockSetting", 0); |
561 RDEBUG("SetLockSetting", 0); |
575 iPhone.SetLockSetting(wait->iStatus, lockType, lockChange); |
562 iPhone.SetLockSetting(wait->iStatus, lockType, lockChange); |
576 RDEBUG("WaitForRequestL", 0); |
563 RDEBUG("WaitForRequestL", 0); |
577 res = wait->WaitForRequestL(); |
564 res = wait->WaitForRequestL(); |
578 RDEBUG("WaitForRequestL", 1); |
565 RDEBUG("WaitForRequestL res", res); |
579 delete wait; |
566 delete wait; |
580 #if defined(_DEBUG) |
|
581 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KES: SetLockSetting RESULT:%d"), res); |
|
582 #endif |
|
583 } |
567 } |
584 |
568 |
585 RDEBUG("res", res); |
569 RDEBUG("res", res); |
586 switch (res) |
570 switch (res) |
587 { |
571 { |
635 err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, |
646 err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, |
636 autolockState); |
647 autolockState); |
637 RDEBUG("StartUp", StartUp); |
648 RDEBUG("StartUp", StartUp); |
638 RDEBUG("err", err); |
649 RDEBUG("err", err); |
639 if (!StartUp) |
650 if (!StartUp) |
|
651 { |
|
652 RDebug::Printf( "%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err ); |
640 User::LeaveIfError(err); |
653 User::LeaveIfError(err); |
|
654 } |
641 TBool isConditionSatisfied = EFalse; |
655 TBool isConditionSatisfied = EFalse; |
642 TInt tarmFlag = 0; |
656 TInt tarmFlag = 0; |
643 if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
657 if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) |
644 { |
658 { |
645 TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, |
659 TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, |
646 tarmFlag); |
660 tarmFlag); |
647 |
661 |
648 if (tRet != KErrNone) |
662 if (tRet != KErrNone) |
649 { |
663 { |
650 #if defined(_DEBUG) |
664 RDEBUG("Warning: failed to get TARM Admin Flag state", tRet); |
651 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\ |
|
652 Warning: failed to get TARM Admin Flag state")); |
|
653 #endif |
|
654 } |
665 } |
655 else |
666 else |
656 { |
667 { |
657 #if defined(_DEBUG) |
668 RDEBUG("TARM flag", tarmFlag); |
658 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL(): TARM flag: %d"), tarmFlag ); |
|
659 #endif |
|
660 } |
669 } |
661 |
670 |
662 if ((StartUp) || (tarmFlag & KSCPFlagResyncQuery)) |
671 if ((StartUp) || (tarmFlag & KSCPFlagResyncQuery)) |
663 isConditionSatisfied = ETrue; |
672 isConditionSatisfied = ETrue; |
664 } |
673 } |
665 else |
674 else |
666 { |
675 { |
667 if (StartUp) |
676 if (StartUp) |
668 isConditionSatisfied = ETrue; |
677 isConditionSatisfied = ETrue; |
669 } |
678 } |
670 #if defined(_DEBUG) |
679 |
671 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1")); |
|
672 #endif |
|
673 // Security code at bootup: No "cancel" softkey; Emergency calls enabled. |
680 // Security code at bootup: No "cancel" softkey; Emergency calls enabled. |
674 RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = |
681 RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = RMobilePhone::ESecurityCodePhonePassword; |
675 RMobilePhone::ESecurityCodePhonePassword; // for starters |
|
676 RDEBUG("isConditionSatisfied", isConditionSatisfied); |
682 RDEBUG("isConditionSatisfied", isConditionSatisfied); |
677 if (isConditionSatisfied) |
683 if (isConditionSatisfied) |
678 { |
684 { |
679 // starter or special TARM. NoCancel+Emergency |
685 // starter or special TARM. NoCancel+Emergency |
680 lCancelSupported = ESecUiCancelNotSupported; |
686 lCancelSupported = ESecUiCancelNotSupported; |
693 lEmergencySupported = ESecUiEmergencyNotSupported; |
699 lEmergencySupported = ESecUiEmergencyNotSupported; |
694 } |
700 } |
695 |
701 |
696 CSecQueryUi *iSecQueryUi; |
702 CSecQueryUi *iSecQueryUi; |
697 iSecQueryUi = CSecQueryUi::NewL(); |
703 iSecQueryUi = CSecQueryUi::NewL(); |
|
704 iQueryCanceled = EFalse; |
698 TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported |
705 TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported |
699 | lCancelSupported | lEmergencySupported | secCodeTypeToAsk; |
706 | lCancelSupported | lEmergencySupported | secCodeTypeToAsk; |
700 RDEBUG("lType", lType); |
707 RDEBUG("lType", lType); |
701 iSecUi_password.Copy(_L("12345")); |
|
702 queryAccepted = iSecQueryUi->SecQueryDialog(_L("PassPhraseRequiredL"), |
708 queryAccepted = iSecQueryUi->SecQueryDialog(_L("PassPhraseRequiredL"), |
703 iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, |
709 iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, |
704 SEC_C_SECURITY_CODE_MAX_LENGTH, lType); |
710 SEC_C_SECURITY_CODE_MAX_LENGTH, lType); |
705 RDEBUG("iSecUi_password", 0); |
711 RDEBUG("iSecUi_password", 0); |
706 RDebug::Print(iSecUi_password); |
712 RDebug::Print(iSecUi_password); |
707 RDEBUG("queryAccepted", queryAccepted); |
713 RDEBUG("queryAccepted", queryAccepted); |
|
714 iQueryCanceled = ETrue; |
708 delete iSecQueryUi; |
715 delete iSecQueryUi; |
709 |
716 |
710 TBool wasCancelledOrEmergency = EFalse; |
717 TBool wasCancelledOrEmergency = EFalse; |
711 RDEBUG("KFeatureIdSapDeviceLockEnhancements", |
718 RDEBUG("KFeatureIdSapDeviceLockEnhancements", |
712 KFeatureIdSapDeviceLockEnhancements); |
719 KFeatureIdSapDeviceLockEnhancements); |
779 SCP_TARM_ADMIN_FLAG_UID, tarmFlag); |
783 SCP_TARM_ADMIN_FLAG_UID, tarmFlag); |
780 } |
784 } |
781 |
785 |
782 if (tRet != KErrNone) |
786 if (tRet != KErrNone) |
783 { |
787 { |
784 #if defined(_DEBUG) |
788 RDEBUG( "FAILED to unset TARM Admin Flag tRet=", tRet ); |
785 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\ |
|
786 FAILED to unset TARM Admin Flag")); |
|
787 #endif |
|
788 } |
789 } |
789 } |
790 } |
790 if (!FeatureManager::FeatureSupported( |
791 if (!FeatureManager::FeatureSupported( |
791 KFeatureIdSapDeviceLockEnhancements)) |
792 KFeatureIdSapDeviceLockEnhancements)) |
792 { |
793 { |
793 RDEBUG("KFeatureIdSapDeviceLockEnhancements", |
794 RDEBUG("KFeatureIdSapDeviceLockEnhancements", |
794 KFeatureIdSapDeviceLockEnhancements); |
795 KFeatureIdSapDeviceLockEnhancements); |
795 RSCPClient scpClient; |
796 RSCPClient scpClient; |
796 RDEBUG("scpClient.Connect", 0); |
797 RDEBUG("scpClient.Connect", 0); |
797 User::LeaveIfError(scpClient.Connect()); |
798 TInt tRet = scpClient.Connect(); |
|
799 RDEBUG("tRet", tRet); |
|
800 User::LeaveIfError(tRet); |
798 RDEBUG("scpClient.Connect", 1); |
801 RDEBUG("scpClient.Connect", 1); |
799 CleanupClosePushL(scpClient); |
802 CleanupClosePushL(scpClient); |
800 TSCPSecCode newCode; |
803 TSCPSecCode newCode; |
801 newCode.Copy(iSecUi_password); |
804 newCode.Copy(iSecUi_password); |
802 scpClient.StoreCode(newCode); |
805 scpClient.StoreCode(newCode); |
806 |
809 |
807 } |
810 } |
808 RDEBUG("StartUp", StartUp); |
811 RDEBUG("StartUp", StartUp); |
809 if (StartUp) |
812 if (StartUp) |
810 { |
813 { |
811 #if defined(_DEBUG) |
|
812 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; get autolock period.")); |
|
813 #endif |
|
814 |
|
815 // get autolock period from Central Repository. |
814 // get autolock period from Central Repository. |
816 CRepository* repository = CRepository::NewL( |
815 CRepository* repository = CRepository::NewL( |
817 KCRUidSecuritySettings); |
816 KCRUidSecuritySettings); |
818 TInt period = 0; |
817 TInt period = 0; |
819 TInt res = repository->Get(KSettingsAutoLockTime, period); |
818 TInt res = repository->Get(KSettingsAutoLockTime, period); |
820 delete repository; |
819 delete repository; |
|
820 RDEBUG("res", res); |
|
821 RDEBUG("period", period); |
821 |
822 |
822 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
823 _LIT_SECURITY_POLICY_PASS( KReadPolicy); |
823 _LIT_SECURITY_POLICY_C1(KWritePolicy, |
824 _LIT_SECURITY_POLICY_C1(KWritePolicy, |
824 ECapabilityWriteDeviceData); |
825 ECapabilityWriteDeviceData); |
825 RProperty::Define(KPSUidCoreApplicationUIs, |
826 RProperty::Define(KPSUidCoreApplicationUIs, |
826 KCoreAppUIsAutolockStatus, RProperty::EInt, |
827 KCoreAppUIsAutolockStatus, RProperty::EInt, |
827 KReadPolicy, KWritePolicy); |
828 KReadPolicy, KWritePolicy); |
828 RProperty::Set(KPSUidCoreApplicationUIs, |
829 RProperty::Set(KPSUidCoreApplicationUIs, |
829 KCoreAppUIsAutolockStatus, EAutolockOff); |
830 KCoreAppUIsAutolockStatus, EAutolockOff); |
830 #if defined(_DEBUG) |
831 RDEBUG("KCoreAppUIsAutolockStatus", KCoreAppUIsAutolockStatus); |
831 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() EAutolockOff")); |
|
832 #endif |
|
833 |
832 |
834 if (res == KErrNone) |
833 if (res == KErrNone) |
835 { |
834 { |
836 // disable autolock in Domestic OS side too if autolock period is 0. |
835 // disable autolock in Domestic OS side too if autolock period is 0. |
837 if (period == 0) |
836 if (period == 0) |
838 { |
837 { |
839 #ifdef RD_REMOTELOCK |
838 // Don't disable the domestic OS device lock |
840 // If remote lock is enabled, don't disable the domestic OS device lock |
|
841 // since that would render the RemoteLock useless. |
839 // since that would render the RemoteLock useless. |
842 |
840 |
843 TBool remoteLockStatus( EFalse ); |
841 TBool remoteLockStatus( EFalse ); |
844 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
842 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
845 |
843 |
846 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
844 if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) |
847 { |
845 { |
848 if ( !remoteLockStatus ) |
846 if ( !remoteLockStatus ) |
849 { |
847 { |
850 // Remote lock is disabled |
848 // Remote lock is disabled |
851 #ifdef _DEBUG |
849 RDEBUG("Autolock and RemoteLock are disabled -> disable DOS device lock", 0); |
852 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) ); |
|
853 #endif // _DEBUG |
|
854 // Disable DOS device lock setting |
850 // Disable DOS device lock setting |
855 RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); |
851 RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); |
856 wait = CWait::NewL(); |
852 wait = CWait::NewL(); |
857 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); |
853 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); |
858 wait->WaitForRequestL(); |
854 RDEBUG( "WaitForRequestL", 0 ); |
859 RDEBUG( "iCustomPhone.DisablePhoneLock", 1 ); |
855 status = wait->WaitForRequestL(); |
|
856 RDEBUG( "WaitForRequestL", status ); |
860 delete wait; |
857 delete wait; |
861 } |
858 } |
862 } |
859 } |
863 else |
860 else |
864 { |
861 { |
865 // Failed to get remote lock status |
862 // Failed to get remote lock status |
866 #ifdef _DEBUG |
863 RDEBUG( "Autolock is disabled, but failed to get RemoteLock status, so do nothing", 0 ); |
867 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock is disabled, but failed to get RemoteLock status, so do nothing." ) ); |
|
868 #endif // _DEBUG |
|
869 } |
864 } |
870 |
865 |
871 delete remoteLockSettings; |
866 delete remoteLockSettings; |
872 remoteLockSettings = NULL; |
867 remoteLockSettings = NULL; |
873 |
868 |
874 #else // not defined RD_REMOTELOCK |
|
875 RDEBUG("iCustomPhone.DisablePhoneLock", 0); |
|
876 wait = CWait::NewL(); |
|
877 iCustomPhone.DisablePhoneLock(wait->iStatus, |
|
878 iSecUi_password); |
|
879 wait->WaitForRequestL(); |
|
880 RDEBUG("iCustomPhone.DisablePhoneLock", 1); |
|
881 delete wait; |
|
882 #endif // RD_REMOTELOCK |
|
883 } |
869 } |
884 } |
870 } |
885 else // error getting repository |
871 else // error getting repository |
886 { |
872 { |
887 RDEBUG("error getting repository", 0); |
873 RDEBUG("error getting repository", 0); |
888 #ifdef RD_REMOTELOCK |
874 // Don't disable the domestic OS device lock |
889 // If remote lock is enabled, don't disable the domestic OS device lock |
|
890 // since that would render the RemoteLock useless. |
875 // since that would render the RemoteLock useless. |
891 |
876 |
892 TBool remoteLockStatus( EFalse ); |
877 TBool remoteLockStatus( EFalse ); |
893 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
878 CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); |
894 |
879 |
898 { |
883 { |
899 // Remote lock is disabled |
884 // Remote lock is disabled |
900 RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); |
885 RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); |
901 wait = CWait::NewL(); |
886 wait = CWait::NewL(); |
902 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); |
887 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); |
903 wait->WaitForRequestL(); |
888 RDEBUG( "WaitForRequestL", 0 ); |
904 RDEBUG( "iCustomPhone.DisablePhoneLock", 1 ); |
889 status = wait->WaitForRequestL(); |
|
890 RDEBUG( "WaitForRequestL status", status ); |
905 delete wait; |
891 delete wait; |
906 } |
892 } |
907 } |
893 } |
908 else |
894 else |
909 { |
895 { |
910 // Failed to get remote lock status |
896 // Failed to get remote lock status |
911 #ifdef _DEBUG |
897 RDEBUG( "Failed to get Autolock period and RemoteLock status, so do nothing", 0 ); |
912 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock status, so do nothing." ) ); |
|
913 #endif // _DEBUG |
|
914 } |
898 } |
915 |
899 |
916 delete remoteLockSettings; |
900 delete remoteLockSettings; |
917 remoteLockSettings = NULL; |
901 remoteLockSettings = NULL; |
918 |
902 |
919 #else // not defined RD_REMOTELOCK |
|
920 // could not get the current autolock time... disable autolock in Domestic OS side. |
|
921 RDEBUG("iCustomPhone.DisablePhoneLock", 0); |
|
922 wait = CWait::NewL(); |
|
923 iCustomPhone.DisablePhoneLock(wait->iStatus, |
|
924 iSecUi_password); |
|
925 wait->WaitForRequestL(); |
|
926 RDEBUG("iCustomPhone.DisablePhoneLock", 1); |
|
927 delete wait; |
|
928 |
|
929 #endif // RD_REMOTELOCK |
|
930 } |
903 } |
931 |
904 |
932 } // no Startup |
905 } // no Startup |
933 |
906 |
934 break; |
907 break; |
935 case KErrGsmSSPasswordAttemptsViolation: |
908 case KErrGsmSSPasswordAttemptsViolation: |
936 case KErrLocked: |
909 case KErrLocked: |
937 // security code blocked! |
910 // security code blocked! |
938 #if defined(_DEBUG) |
911 RDEBUG("KErrLocked", KErrLocked); |
939 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() ErrGsmSSPasswordAttemptsViolation")); |
|
940 #endif |
|
941 CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, |
912 CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, |
942 CAknNoteDialog::EErrorTone); |
913 CAknNoteDialog::EErrorTone); |
943 break; |
914 break; |
944 case KErrGsm0707IncorrectPassword: |
915 case KErrGsm0707IncorrectPassword: |
945 case KErrAccessDenied: |
916 case KErrAccessDenied: |
946 RDEBUG("KErrAccessDenied", KErrAccessDenied); |
917 RDEBUG("KErrAccessDenied", KErrAccessDenied); |
947 // TODO should this try again? It seems that it's not asked again. |
918 // The Settings caller might retry |
948 #if defined(_DEBUG) |
|
949 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword")); |
|
950 #endif |
|
951 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
919 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
952 CAknNoteDialog::EErrorTone); |
920 CAknNoteDialog::EErrorTone); |
953 break; |
921 break; |
954 default: |
922 default: |
955 RDEBUG("default", status); |
923 RDEBUG("default", status); |
956 CSecuritySettings::ShowErrorNoteL(status); |
924 CSecuritySettings::ShowErrorNoteL(status); |
957 // TODO should this try again? It seems that it's not asked again. |
925 // The Settings caller might retry |
958 break; |
926 break; |
959 } |
927 } |
960 RDEBUG("returnValue", returnValue); |
928 RDEBUG("returnValue", returnValue); |
961 return returnValue; |
929 return returnValue; |
962 } |
930 } |
997 if (!StartUp) |
965 if (!StartUp) |
998 { |
966 { |
999 // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL |
967 // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL |
1000 err = RProperty::Get(KPSUidSecurityUIs, |
968 err = RProperty::Get(KPSUidSecurityUIs, |
1001 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
969 KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); |
1002 |
|
1003 if (err != KErrNone) |
970 if (err != KErrNone) |
1004 { |
971 { |
1005 #if defined(_DEBUG) |
972 RDEBUG("FAILED to get the SECUI query Flag err", err); |
1006 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\ |
973 } |
1007 FAILED to get the SECUI query Flag: %d"), err); |
974 } |
1008 #endif |
975 RDEBUG("err", err); |
1009 } |
|
1010 else |
|
1011 { |
|
1012 #if defined(_DEBUG) |
|
1013 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\ |
|
1014 SECUI query Flag: %d"), secUiOriginatedQuery); |
|
1015 #endif |
|
1016 } |
|
1017 } |
|
1018 #if defined(_DEBUG) |
|
1019 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg")); |
|
1020 #endif |
|
1021 |
|
1022 RDEBUG("StartUp", StartUp); |
|
1023 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
976 RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); |
1024 RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated); |
977 RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated); |
1025 RDEBUG("err", err); |
|
1026 if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) |
978 if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) |
1027 || (err != KErrNone)) |
979 || (err != KErrNone)) |
1028 { |
980 { |
1029 RDEBUG("0", 0); |
981 RDEBUG("0", 0); |
1030 lCancelSupported = ESecUiCancelNotSupported; |
982 lCancelSupported = ESecUiCancelNotSupported; |
1071 RDEBUG("amode", amode); |
1022 RDEBUG("amode", amode); |
1072 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, |
1023 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, |
1073 SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode); |
1024 SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode); |
1074 RDEBUG("iSecUi_password", 0); |
1025 RDEBUG("iSecUi_password", 0); |
1075 RDebug::Print(iSecUi_password); |
1026 RDebug::Print(iSecUi_password); |
|
1027 iQueryCanceled = ETrue; |
1076 delete iSecQueryUi; |
1028 delete iSecQueryUi; |
1077 RDEBUG("queryAccepted", queryAccepted); |
1029 RDEBUG("queryAccepted", queryAccepted); |
1078 // TODO handle emergency |
|
1079 /* end request PIN using QT */ |
1030 /* end request PIN using QT */ |
1080 |
1031 |
1081 if (queryAccepted == KErrAbort) // emergency call |
1032 if (queryAccepted == KErrAbort) // emergency call |
1082 { |
1033 { |
1083 #if defined(_DEBUG) |
1034 RDEBUG("queryAccepted", queryAccepted); |
1084 RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!")); |
|
1085 #endif |
|
1086 CleanupStack::PopAndDestroy(wait); // this is needed |
1035 CleanupStack::PopAndDestroy(wait); // this is needed |
1087 return KErrCancel; |
1036 return KErrCancel; |
1088 } |
1037 } |
1089 if (lCancelSupported && (queryAccepted == KErrCancel)) |
1038 if (lCancelSupported && (queryAccepted == KErrCancel)) |
1090 { |
1039 { |
1151 } |
1101 } |
1152 // |
1102 // |
1153 // ---------------------------------------------------------- |
1103 // ---------------------------------------------------------- |
1154 // CSecurityHandler::Puk1Required() |
1104 // CSecurityHandler::Puk1Required() |
1155 // Handles Puk1Required event |
1105 // Handles Puk1Required event |
|
1106 // First asks the PUK1, then verifies, then the newPIN + re-type , and then writes . This is odd, but the API needs the PUK and newPIN in same step. |
|
1107 // Afterwards, the PIN1 might be asked (because the initial program still needs it) |
1156 // ---------------------------------------------------------- |
1108 // ---------------------------------------------------------- |
1157 // qtdone |
1109 // qtdone |
1158 TInt CSecurityHandler::Puk1RequiredL() |
1110 TInt CSecurityHandler::Puk1RequiredL() |
1159 { |
1111 { |
1160 /***************************************************** |
1112 /***************************************************** |
1161 * Series 60 Customer / ETel |
1113 * Series 60 Customer / ETel |
1162 * Series 60 ETel API |
1114 * Series 60 ETel API |
1163 *****************************************************/ |
1115 *****************************************************/ |
1164 #if defined(_DEBUG) |
1116 RDEBUG("0", 0); |
1165 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL()")); |
|
1166 #endif |
|
1167 TInt queryAccepted = KErrCancel; |
1117 TInt queryAccepted = KErrCancel; |
1168 RMobilePhone::TMobilePassword iSecUi_password; |
1118 RMobilePhone::TMobilePassword puk1_password; |
1169 RMobilePhone::TMobilePassword aNewPassword; |
1119 RMobilePhone::TMobilePassword aNewPinPassword; |
1170 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1120 RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; |
1171 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1121 RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); |
1172 RMobilePhone::TMobilePhoneSecurityCode blockCodeType; |
1122 RMobilePhone::TMobilePhoneSecurityCode blockCodeType; |
1173 blockCodeType = RMobilePhone::ESecurityCodePuk1; |
1123 blockCodeType = RMobilePhone::ESecurityCodePuk1; |
1174 CWait* wait = CWait::NewL(); |
1124 CWait* wait = CWait::NewL(); |
1175 CleanupStack::PushL(wait); |
1125 CleanupStack::PushL(wait); |
1176 |
1126 |
1177 TBool StartUp(ETrue); |
1127 TBool StartUp(ETrue); |
1178 StartUp = iStartup; |
1128 StartUp = iStartup; |
1179 |
1129 |
1180 TInt res(KErrNone); |
1130 TInt res(KErrCancel); // for the first try |
1181 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1131 wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); |
1182 |
1132 |
1183 TInt thisTry = 0; |
1133 TInt thisTry = 0; |
1184 |
1134 |
1185 // If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times. |
1135 // If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times. |
1191 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
1141 iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); |
1192 RDEBUG("WaitForRequestL", 0); |
1142 RDEBUG("WaitForRequestL", 0); |
1193 res = wait->WaitForRequestL(); |
1143 res = wait->WaitForRequestL(); |
1194 RDEBUG("WaitForRequestL res", res); |
1144 RDEBUG("WaitForRequestL res", res); |
1195 } |
1145 } |
1196 #if defined(_DEBUG) |
1146 RDEBUG("res", res); |
1197 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Get Code info result: %d"), res); |
1147 // If there's still an error we're doomed. Bail out. |
1198 #endif |
|
1199 //If there's still an error we're doomed. Bail out. |
|
1200 User::LeaveIfError(res); |
1148 User::LeaveIfError(res); |
1201 |
|
1202 #if defined(_DEBUG) |
|
1203 RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Show last note")); |
|
1204 #endif |
|
1205 |
1149 |
1206 RDEBUG("StartUp", StartUp); |
1150 RDEBUG("StartUp", StartUp); |
1207 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1151 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1208 codeInfo.iRemainingEntryAttempts); |
1152 codeInfo.iRemainingEntryAttempts); |
1209 //show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog |
1153 TInt attempts(codeInfo.iRemainingEntryAttempts); |
1210 if (!StartUp && (codeInfo.iRemainingEntryAttempts |
1154 RDEBUG( "attempts", attempts ); |
|
1155 // show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog |
|
1156 if (!StartUp && (attempts |
1211 == KMaxNumberOfPUKAttempts)) |
1157 == KMaxNumberOfPUKAttempts)) |
1212 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
1158 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
1213 CAknNoteDialog::EErrorTone); |
1159 CAknNoteDialog::EErrorTone); |
1214 |
1160 |
1215 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1161 if (attempts == KMaxNumberOfPINAttempts) |
1216 codeInfo.iRemainingEntryAttempts); |
1162 attempts = -1; |
1217 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) |
1163 |
1218 codeInfo.iRemainingEntryAttempts = -1; |
|
1219 |
|
1220 // ask PUK code |
|
1221 /* request PIN using QT */ |
|
1222 CSecQueryUi *iSecQueryUi; |
1164 CSecQueryUi *iSecQueryUi; |
1223 RDEBUG("CSecQueryUi", 0); |
1165 RDEBUG("CSecQueryUi", 0); |
1224 iSecQueryUi = CSecQueryUi::NewL(); |
1166 iSecQueryUi = CSecQueryUi::NewL(); |
|
1167 iQueryCanceled = EFalse; |
1225 RDEBUG("SecQueryDialog", 1); |
1168 RDEBUG("SecQueryDialog", 1); |
1226 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful |
1169 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
1227 // TODO also support Emergency |
|
1228 TBuf<0x100> title; |
1170 TBuf<0x100> title; |
1229 title.Zero(); |
1171 title.Zero(); |
1230 title.Append(_L("Puk1RequiredL")); |
1172 title.Append(_L("Puk1RequiredL")); |
1231 title.Append(_L("#")); |
1173 title.Append(_L("#")); |
1232 title.AppendNum(codeInfo.iRemainingEntryAttempts); |
1174 title.AppendNum(attempts); |
1233 queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, |
1175 TInt lSecUiCancelSupported = ESecUiCancelSupported | ESecUiEmergencyNotSupported; |
|
1176 if(StartUp) // how to know whether PUK comes from failing at Starter, or failing at any other PIN (i.e. changing PIN, or changing PIN-request) ??? |
|
1177 lSecUiCancelSupported = ESecUiCancelNotSupported | ESecUiEmergencySupported; |
|
1178 queryAccepted = iSecQueryUi->SecQueryDialog(title, puk1_password, |
1234 SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, |
1179 SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, |
1235 ESecUiSecretNotSupported | ESecUiAlphaNotSupported |
1180 ESecUiSecretNotSupported | ESecUiAlphaNotSupported |
1236 | ESecUiCancelSupported | ESecUiPukRequired); |
1181 | lSecUiCancelSupported | ESecUiPukRequired); |
1237 RDEBUG("iSecUi_password", 0); |
1182 RDEBUG("puk1_password", 0); |
1238 RDebug::Print(iSecUi_password); |
1183 RDebug::Print(puk1_password); |
|
1184 iQueryCanceled = ETrue; |
1239 delete iSecQueryUi; |
1185 delete iSecQueryUi; |
1240 RDEBUG("queryAccepted", queryAccepted); |
1186 RDEBUG("queryAccepted", queryAccepted); |
1241 |
1187 |
1242 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
1188 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
1243 { |
1189 { |
1244 CleanupStack::PopAndDestroy(wait); // TODO this is needed ??? |
1190 CleanupStack::PopAndDestroy(wait); // this is needed |
1245 return KErrCancel; |
1191 return KErrCancel; |
1246 } |
1192 } |
1247 |
1193 |
1248 { |
|
1249 // new pin code query |
|
1250 CSecQueryUi * iSecQueryUi; |
|
1251 RDEBUG("CSecQueryUi", 0); |
|
1252 iSecQueryUi = CSecQueryUi::NewL(); |
|
1253 RDEBUG("SecQueryDialog", 1); |
|
1254 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful |
|
1255 // TODO also support Emergency |
|
1256 |
|
1257 queryAccepted = iSecQueryUi->SecQueryDialog( |
|
1258 _L("Puk1-New|Puk1-Verif"), aNewPassword, |
|
1259 SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, |
|
1260 ESecUiAlphaNotSupported | ESecUiCancelSupported |
|
1261 | ESecUiPukRequired); |
|
1262 RDEBUG("aNewPassword", 0); |
|
1263 RDebug::Print(aNewPassword); |
|
1264 delete iSecQueryUi; |
|
1265 RDEBUG("queryAccepted", queryAccepted); |
|
1266 } |
|
1267 |
|
1268 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
|
1269 { |
|
1270 CleanupStack::PopAndDestroy(wait); |
|
1271 return KErrCancel; |
|
1272 } |
|
1273 |
|
1274 // send code |
1194 // send code |
|
1195 // first we verify the puk. For this, we reset the PIN to the same as the PUK |
|
1196 // Hopefully this will never fail in the case "new PIN too long" |
1275 RDEBUG("VerifySecurityCode", 0); |
1197 RDEBUG("VerifySecurityCode", 0); |
1276 iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPassword, |
1198 iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, puk1_password, puk1_password); |
1277 iSecUi_password); |
|
1278 RDEBUG("WaitForRequestL", 0); |
1199 RDEBUG("WaitForRequestL", 0); |
1279 res = wait->WaitForRequestL(); |
1200 res = wait->WaitForRequestL(); |
1280 RDEBUG("WaitForRequestL res", res); |
1201 RDEBUG("WaitForRequestL res", res); |
1281 CleanupStack::PopAndDestroy(wait); |
1202 CleanupStack::PopAndDestroy(wait); |
1282 |
1203 |
1283 TInt returnValue = res; |
1204 TInt returnValue = res; |
1284 switch (res) |
1205 switch (res) |
1285 { |
1206 { |
1286 case KErrNone: |
1207 case KErrNone: |
1287 // code approved -> note |
1208 // code approved -> note . The process continue and new-pin is requested |
1288 CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, |
1209 CSecuritySettings::ShowResultNoteL(res, |
1289 CAknNoteDialog::EConfirmationTone); |
1210 CAknNoteDialog::EConfirmationTone); |
1290 break; |
1211 break; |
1291 case KErrGsm0707IncorrectPassword: |
1212 case KErrGsm0707IncorrectPassword: |
1292 case KErrAccessDenied: |
1213 case KErrAccessDenied: |
1293 // wrong PUK code -> note -> ask PUK code again |
1214 // wrong PUK code -> note -> ask PUK code again |
1307 CSecuritySettings::ShowErrorNoteL(res); |
1228 CSecuritySettings::ShowErrorNoteL(res); |
1308 returnValue = Puk1RequiredL(); |
1229 returnValue = Puk1RequiredL(); |
1309 break; |
1230 break; |
1310 } |
1231 } |
1311 |
1232 |
|
1233 // Now the PUK1 is validated. It's time for asking the new PIN1 |
|
1234 RDEBUG("new wait", 0); |
|
1235 wait = CWait::NewL(); |
|
1236 CleanupStack::PushL(wait); |
|
1237 { |
|
1238 // new-pin query |
|
1239 CSecQueryUi * iSecQueryUi; |
|
1240 RDEBUG("CSecQueryUi", 0); |
|
1241 iSecQueryUi = CSecQueryUi::NewL(); |
|
1242 iQueryCanceled = EFalse; |
|
1243 RDEBUG("SecQueryDialog", 1); |
|
1244 |
|
1245 queryAccepted = iSecQueryUi->SecQueryDialog( |
|
1246 _L("PIN1-New|PIN1-Verif"), aNewPinPassword, |
|
1247 SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, |
|
1248 ESecUiAlphaNotSupported | ESecUiCancelSupported |
|
1249 | ESecUiPukRequired); |
|
1250 RDEBUG("aNewPinPassword", 0); |
|
1251 RDebug::Print(aNewPinPassword); |
|
1252 iQueryCanceled = ETrue; |
|
1253 delete iSecQueryUi; |
|
1254 RDEBUG("queryAccepted", queryAccepted); |
|
1255 } |
|
1256 |
|
1257 if ((queryAccepted == KErrAbort) || (queryAccepted == KErrCancel)) |
|
1258 { |
|
1259 CleanupStack::PopAndDestroy(wait); |
|
1260 return KErrCancel; |
|
1261 } |
|
1262 |
|
1263 // send code again, now with the user pin |
|
1264 RDEBUG("VerifySecurityCode", 0); |
|
1265 iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPinPassword, |
|
1266 puk1_password); |
|
1267 RDEBUG("WaitForRequestL", 0); |
|
1268 res = wait->WaitForRequestL(); |
|
1269 RDEBUG("WaitForRequestL res", res); |
|
1270 CleanupStack::PopAndDestroy(wait); |
|
1271 |
|
1272 returnValue = res; |
|
1273 switch (res) |
|
1274 { |
|
1275 case KErrNone: |
|
1276 // code approved -> note |
|
1277 CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, |
|
1278 CAknNoteDialog::EConfirmationTone); |
|
1279 break; |
|
1280 case KErrGsm0707IncorrectPassword: |
|
1281 case KErrAccessDenied: |
|
1282 // wrong PUK code -> note -> ask PUK code again |
|
1283 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
|
1284 CAknNoteDialog::EErrorTone); |
|
1285 returnValue = Puk1RequiredL(); |
|
1286 break; |
|
1287 case KErrGsm0707SimWrong: |
|
1288 // sim lock active |
|
1289 // no message ? |
|
1290 break; |
|
1291 case KErrGsmSSPasswordAttemptsViolation: |
|
1292 case KErrLocked: |
|
1293 // sim card rejected. |
|
1294 break; |
|
1295 default: |
|
1296 CSecuritySettings::ShowErrorNoteL(res); |
|
1297 returnValue = Puk1RequiredL(); |
|
1298 break; |
|
1299 } |
|
1300 RDEBUG("returnValue", returnValue); |
1312 return returnValue; |
1301 return returnValue; |
1313 } |
1302 } |
1314 // |
1303 // |
1315 // ---------------------------------------------------------- |
1304 // ---------------------------------------------------------- |
1316 // CSecurityHandler::Pin2Required() |
1305 // CSecurityHandler::Pin2Required() |
1341 RDEBUG("GetSecurityCodeInfo", 0); |
1328 RDEBUG("GetSecurityCodeInfo", 0); |
1342 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
1329 iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg); |
1343 RDEBUG("WaitForRequestL", 0); |
1330 RDEBUG("WaitForRequestL", 0); |
1344 TInt ret = wait->WaitForRequestL(); |
1331 TInt ret = wait->WaitForRequestL(); |
1345 RDEBUG("WaitForRequestL ret", ret); |
1332 RDEBUG("WaitForRequestL ret", ret); |
1346 |
|
1347 User::LeaveIfError(ret); |
1333 User::LeaveIfError(ret); |
1348 |
1334 |
1349 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1335 RDEBUG("codeInfo.iRemainingEntryAttempts", |
1350 codeInfo.iRemainingEntryAttempts); |
1336 codeInfo.iRemainingEntryAttempts); |
1351 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) // TODO this might be 10 ? |
1337 if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) |
1352 codeInfo.iRemainingEntryAttempts = -1; |
1338 codeInfo.iRemainingEntryAttempts = -1; |
1353 |
1339 |
1354 /* request PIN using QT */ |
1340 /* request PIN using QT */ |
1355 CSecQueryUi *iSecQueryUi; |
1341 CSecQueryUi *iSecQueryUi; |
1356 RDEBUG("CSecQueryUi", 0); |
1342 RDEBUG("CSecQueryUi", 0); |
1357 iSecQueryUi = CSecQueryUi::NewL(); |
1343 iSecQueryUi = CSecQueryUi::NewL(); |
|
1344 iQueryCanceled = EFalse; |
1358 RDEBUG("SecQueryDialog", 1); |
1345 RDEBUG("SecQueryDialog", 1); |
1359 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful against KLastRemainingInputAttempt |
1346 // ESecUiCodeEtelReqest/ESecUiNone might be useful against KLastRemainingInputAttempt |
1360 // TODO also support Emergency |
|
1361 |
1347 |
1362 TBuf<0x100> title; |
1348 TBuf<0x100> title; |
1363 title.Zero(); |
1349 title.Zero(); |
1364 title.Append(_L("Pin2RequiredL")); |
1350 title.Append(_L("Pin2RequiredL")); |
1365 title.Append(_L("#")); |
1351 title.Append(_L("#")); |
1488 RDEBUG("AbortSecurityCode", 1); |
1471 RDEBUG("AbortSecurityCode", 1); |
1489 CleanupStack::PopAndDestroy(1); //wait |
1472 CleanupStack::PopAndDestroy(1); //wait |
1490 return; |
1473 return; |
1491 } |
1474 } |
1492 |
1475 |
1493 { |
1476 RDEBUG("VerifySecurityCode", 0); |
1494 // new pin code query |
1477 iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, iSecUi_password); |
|
1478 // this writes the newPIN2 with the value of PUK2. It's ok, since the user forgot it |
|
1479 RDEBUG("WaitForRequestL", 0); |
|
1480 TInt res = wait->WaitForRequestL(); |
|
1481 RDEBUG("WaitForRequestL res", res); |
|
1482 CleanupStack::PopAndDestroy(wait); |
|
1483 |
|
1484 switch (res) |
|
1485 { |
|
1486 case KErrNone: |
|
1487 // code approved -> note |
|
1488 CSecuritySettings::ShowResultNoteL(res, |
|
1489 CAknNoteDialog::EConfirmationTone); |
|
1490 break; |
|
1491 case KErrGsm0707IncorrectPassword: |
|
1492 case KErrAccessDenied: |
|
1493 // wrong PUK2 code -> note -> ask PUK2 code again |
|
1494 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, |
|
1495 CAknNoteDialog::EErrorTone); |
|
1496 Puk2RequiredL(); |
|
1497 break; |
|
1498 case KErrGsmSSPasswordAttemptsViolation: |
|
1499 case KErrLocked: |
|
1500 // Pin2 features blocked permanently! |
|
1501 CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, |
|
1502 CAknNoteDialog::EConfirmationTone); |
|
1503 break; |
|
1504 default: |
|
1505 CSecuritySettings::ShowErrorNoteL(res); |
|
1506 Puk2RequiredL(); |
|
1507 break; |
|
1508 } |
|
1509 |
|
1510 // now the PUK2 is valid. Time to get the new PIN2 |
|
1511 wait = CWait::NewL(); |
|
1512 CleanupStack::PushL(wait); |
|
1513 { |
|
1514 // new pin2 code query |
1495 CSecQueryUi * iSecQueryUi; |
1515 CSecQueryUi * iSecQueryUi; |
1496 RDEBUG("CSecQueryUi", 0); |
1516 RDEBUG("CSecQueryUi", 0); |
1497 iSecQueryUi = CSecQueryUi::NewL(); |
1517 iSecQueryUi = CSecQueryUi::NewL(); |
1498 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful |
1518 iQueryCanceled = EFalse; |
1499 // TODO also support Emergency |
1519 // ESecUiCodeEtelReqest/ESecUiNone might be useful |
1500 |
|
1501 queryAccepted |
1520 queryAccepted |
1502 = iSecQueryUi->SecQueryDialog(_L("Puk2-New|Puk2-Verif"), |
1521 = iSecQueryUi->SecQueryDialog(_L("PIN2-New|PIN2-Verif"), |
1503 aNewPassword, SEC_C_PUK2_CODE_MIN_LENGTH, |
1522 aNewPassword, SEC_C_PIN2_CODE_MIN_LENGTH, |
1504 SEC_C_PUK2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported |
1523 SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported |
1505 | ESecUiCancelSupported | secCodeType); |
1524 | ESecUiCancelSupported | secCodeType); |
1506 RDEBUG("aNewPassword", 0); |
1525 RDEBUG("aNewPassword", 0); |
1507 RDebug::Print(aNewPassword); |
1526 RDebug::Print(aNewPassword); |
|
1527 iQueryCanceled = ETrue; |
1508 delete iSecQueryUi; |
1528 delete iSecQueryUi; |
1509 RDEBUG("queryAccepted", queryAccepted); |
1529 RDEBUG("queryAccepted", queryAccepted); |
1510 if (queryAccepted != KErrNone) |
1530 if (queryAccepted != KErrNone) |
1511 { |
1531 { |
1512 // cancel "get security unblock code" request |
1532 // cancel "get security unblock code" request |
1768 { |
1791 { |
1769 /* request PIN using QT */ |
1792 /* request PIN using QT */ |
1770 CSecQueryUi *iSecQueryUi; |
1793 CSecQueryUi *iSecQueryUi; |
1771 RDEBUG("CSecQueryUi", 0); |
1794 RDEBUG("CSecQueryUi", 0); |
1772 iSecQueryUi = CSecQueryUi::NewL(); |
1795 iSecQueryUi = CSecQueryUi::NewL(); |
|
1796 iQueryCanceled = EFalse; |
1773 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful |
1797 // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful |
1774 // TODO also support Emergency |
1798 // TODO also support Emergency |
1775 |
1799 |
1776 queryAccepted = iSecQueryUi->SecQueryDialog(_L( |
1800 queryAccepted = iSecQueryUi->SecQueryDialog(_L( |
1777 "UPuk-New|UPuk-Verif"), aNewPassword, |
1801 "UPuk-New|UPuk-Verif"), aNewPassword, |
1778 SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, |
1802 SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, |
1779 ESecUiAlphaNotSupported | ESecUiCancelSupported |
1803 ESecUiAlphaNotSupported | ESecUiCancelSupported |
1780 | ESecUiPukRequired); |
1804 | ESecUiPukRequired); |
1781 RDEBUG("aNewPassword", 0); |
1805 RDEBUG("aNewPassword", 0); |
1782 RDebug::Print(aNewPassword); |
1806 RDebug::Print(aNewPassword); |
|
1807 iQueryCanceled = ETrue; |
1783 delete iSecQueryUi; |
1808 delete iSecQueryUi; |
1784 RDEBUG("queryAccepted", queryAccepted); |
1809 RDEBUG("queryAccepted", queryAccepted); |
1785 if (queryAccepted != KErrNone) |
1810 if (queryAccepted != KErrNone) |
1786 { |
1811 { |
1787 CleanupStack::PopAndDestroy(wait); |
1812 CleanupStack::PopAndDestroy(wait); |