548 } |
482 } |
549 |
483 |
550 |
484 |
551 // *********** Device lock new features ************* -->> |
485 // *********** Device lock new features ************* -->> |
552 |
486 |
553 // --------------------------------------------------------- |
|
554 // RSCPClient::SecCodeQuery() |
|
555 // Request the security code from the user and authenticate |
|
556 // through the server. |
|
557 // |
|
558 // Status : Approved |
|
559 // --------------------------------------------------------- |
|
560 // |
|
561 EXPORT_C TInt RSCPClient::SecCodeQuery( RMobilePhone::TMobilePassword& aPassword, |
|
562 TSCPButtonConfig aButtonsShown, |
|
563 TBool aECSSupport, |
|
564 TInt aFlags ) |
|
565 { |
|
566 TInt lErr = KErrNone; |
|
567 TInt lStatus = KErrNone; |
|
568 TInt lResFileSCP = NULL; |
|
569 TInt lResFileSecUi = NULL; |
|
570 Dprint( (_L("--> RSCPClient::SecCodeQuery(%d, %d"), aButtonsShown, aECSSupport )); |
|
571 TRAP(lErr, lStatus = SetSecurityCodeL(aPassword, aButtonsShown, aECSSupport, aFlags, lResFileSCP, lResFileSecUi)); |
|
572 |
|
573 |
|
574 if(lResFileSCP) { |
|
575 CCoeEnv :: Static()->DeleteResourceFile(lResFileSCP); |
|
576 } |
|
577 |
|
578 if(lResFileSecUi) { |
|
579 |
|
580 |
|
581 CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi); |
|
582 } |
|
583 |
|
584 Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr)); |
|
585 return (lErr != KErrNone) ? lErr : lStatus; |
|
586 } |
|
587 |
|
588 // --------------------------------------------------------- |
|
589 // RSCPClient::ChangeCodeRequest() |
|
590 // Show the current code query dialog and continue in GetNew |
|
591 // CodeAndChange. |
|
592 // |
|
593 // Status : Approved |
|
594 // --------------------------------------------------------- |
|
595 // |
|
596 EXPORT_C TInt RSCPClient::ChangeCodeRequest() |
|
597 { |
|
598 Dprint((_L("[RSCPClient] ChangeCodeRequest() >>>"))); |
|
599 |
|
600 if(EFalse == isFlagEnabled) { |
|
601 Dprint((_L("[RSCPClient]-> ChangeCodeRequest(): ERROR: Function not supported in this variant"))); |
|
602 User :: Invariant(); |
|
603 return KErrNotSupported; |
|
604 } |
|
605 |
|
606 TInt lRet(KErrNone); |
|
607 TInt lErr(KErrNone); |
|
608 |
|
609 TInt resourceFileSCP(NULL); |
|
610 TInt resourceFileSecUi(NULL); |
|
611 |
|
612 // Check if the code change is allowed |
|
613 { |
|
614 HBufC8* addParamsHBuf = NULL; |
|
615 TRAP(lErr, addParamsHBuf = HBufC8 :: NewL(KSCPMaxTARMNotifParamLen)); |
|
616 |
|
617 if(lErr != KErrNone) { |
|
618 return lErr; |
|
619 } |
|
620 |
|
621 TPtr8 addParams = addParamsHBuf->Des(); |
|
622 addParams.Zero(); |
|
623 |
|
624 TInt status(KErrNone); |
|
625 TPckg<TInt> retPackage(status); |
|
626 |
|
627 TInt ret = SendReceive(ESCPServCodeChangeQuery, TIpcArgs(&retPackage, &addParams)); |
|
628 |
|
629 if((ret == KErrNone) && (addParams.Length() > 0)) { |
|
630 // The server has sent additional parameters, ignore errors in processing |
|
631 TRAP_IGNORE(ProcessServerCommandsL(addParams)); |
|
632 } |
|
633 |
|
634 delete addParamsHBuf; |
|
635 |
|
636 if((ret != KErrNone) || (status != KErrNone)) { |
|
637 // Password cannot be changed now |
|
638 return KErrAbort; |
|
639 } |
|
640 } |
|
641 |
|
642 // Load the required resource files into this process |
|
643 lRet = LoadResources(resourceFileSCP, resourceFileSecUi); |
|
644 |
|
645 if(lRet != KErrNone) { |
|
646 return lRet; |
|
647 } |
|
648 |
|
649 HBufC* codeHBuf = NULL; |
|
650 |
|
651 TRAP(lErr, codeHBuf = HBufC :: NewL(KSCPPasscodeMaxLength + 1)); |
|
652 |
|
653 if(lErr != KErrNone) { |
|
654 // Remove the resource files |
|
655 CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP); |
|
656 CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi); |
|
657 return lErr; |
|
658 } |
|
659 |
|
660 TPtr codeBuffer = codeHBuf->Des(); |
|
661 codeBuffer.Zero(); |
|
662 |
|
663 TInt def_code = -1; |
|
664 CRepository* lRepository = NULL; |
|
665 |
|
666 TRAP(lErr, lRepository = CRepository :: NewL(KCRUidSCPLockCode)); |
|
667 |
|
668 if(KErrNone == lErr) { |
|
669 lErr = lRepository->Get(KSCPLockCodeDefaultLockCode, def_code); |
|
670 |
|
671 if(def_code == 0) { |
|
672 TRAP(lErr, lRet = RunDialogL(codeBuffer, SCP_OK_CANCEL, KSCPPasscodeMinLength, |
|
673 KSCPPasscodeMaxLength, R_SECUI_TEXT_ENTER_SEC_CODE)); |
|
674 |
|
675 if((lRet) && (lErr == KErrNone) && (lRet != ESecUiEmergencyCall)) { |
|
676 lErr = GetNewCodeAndChange(codeBuffer, KSCPNormalChange); |
|
677 } |
|
678 |
|
679 if(lErr != KErrNone) { |
|
680 Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED: %d"), lErr)); |
|
681 } |
|
682 |
|
683 if(((!lRet) && (lErr == KErrNone)) || (lRet == ESecUiEmergencyCall)) { |
|
684 // Cancelled by user |
|
685 lErr = KErrAbort; |
|
686 } |
|
687 } |
|
688 else if(def_code != -1) { |
|
689 _LIT(KText, "12345"); |
|
690 TBufC<10> NBuf (KText); |
|
691 TPtr codeBuf = NBuf.Des(); |
|
692 |
|
693 lErr = GetNewCodeAndChange(codeBuf, KSCPNormalChange); |
|
694 |
|
695 if(lErr == KErrNone) { |
|
696 lRepository->Set(KSCPLockCodeDefaultLockCode, 0); |
|
697 } |
|
698 else { |
|
699 Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED automatic: %d"), lErr)); |
|
700 } |
|
701 } |
|
702 |
|
703 delete lRepository; |
|
704 } |
|
705 |
|
706 Dprint((_L("<-- RSCPClient::ChangeCodeRequest(): %d"), lErr )); |
|
707 |
|
708 // Remove the resource files |
|
709 CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP); |
|
710 CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi); |
|
711 delete codeHBuf; |
|
712 return lErr; |
|
713 } |
|
714 |
487 |
715 // --------------------------------------------------------- |
488 // --------------------------------------------------------- |
716 // RSCPClient::CheckConfiguration() |
489 // RSCPClient::CheckConfiguration() |
717 // Ask the server if the configuration is OK |
490 // Ask the server if the configuration is OK |
718 // |
491 // |
802 TPckgBuf<TInt> lAutoLockPeriod(aValue); |
617 TPckgBuf<TInt> lAutoLockPeriod(aValue); |
803 TInt ret = SendReceive(ESCPServUISetAutoLock, TIpcArgs(&lAutoLockPeriod)); |
618 TInt ret = SendReceive(ESCPServUISetAutoLock, TIpcArgs(&lAutoLockPeriod)); |
804 Dprint((_L("[RSCPClient]-> SetAutoLockPeriod(): %d <<<"), ret)); |
619 Dprint((_L("[RSCPClient]-> SetAutoLockPeriod(): %d <<<"), ret)); |
805 return ret; |
620 return ret; |
806 } |
621 } |
|
622 |
|
623 EXPORT_C TBool RSCPClient :: IsLockcodeChangeAllowedNow(RArray<TDevicelockPolicies>& aFailedPolicies) { |
|
624 Dprint((_L("[RSCPClient]-> IsLockcodeChangeAllowedNow() >>>"))); |
|
625 TInt lStatus = KErrNone; |
|
626 TInt lErr = KErrNone; |
|
627 |
|
628 // extra one for failed policies count |
|
629 //koys: if leave happens what errorcode we should return?? |
|
630 HBufC8* failedPoliciesBuff = NULL; |
|
631 TRAP(lStatus, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32))); |
|
632 |
|
633 if (lStatus == KErrNone) { |
|
634 lStatus = SendReceive(ESCPServCodeChangeQuery, TIpcArgs(&failedPoliciesBuff->Des())); |
|
635 //koya: if leave happens what errorcode we should return?? |
|
636 TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des(); |
|
637 TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies)); |
|
638 delete failedPoliciesBuff; |
|
639 } |
|
640 |
|
641 Dprint((_L("[RSCPClient]-> IsLockcodeChangeAllowedNow() <<<"))); |
|
642 return (lStatus != KErrNone) ? lStatus : ((lErr != KErrNone) ? lErr : KErrNone); |
|
643 } |
|
644 |
|
645 EXPORT_C TInt RSCPClient :: VerifyNewLockcodeAgainstPolicies(TDesC& aLockcode, RArray<TDevicelockPolicies>& aFailedPolicies) { |
|
646 Dprint((_L("[RSCPClient]-> VerifyNewLockcodeAgainstPolicies() >>>"))); |
|
647 TInt lRet = KErrNone; |
|
648 TInt lErr = KErrNone; |
|
649 // extra one for failed policies count |
|
650 HBufC8* failedPoliciesBuff = NULL; |
|
651 |
|
652 TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1) * sizeof(TInt32))); |
|
653 |
|
654 if(lRet == KErrNone) { |
|
655 lRet = SendReceive(ESCPServValidateLockcode, TIpcArgs(&aLockcode, &failedPoliciesBuff->Des())); |
|
656 |
|
657 TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des(); |
|
658 TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies)); |
|
659 |
|
660 delete failedPoliciesBuff; |
|
661 } |
|
662 |
|
663 Dprint((_L("[RSCPClient]-> VerifyNewLockcodeAgainstPolicies() <<<"))); |
|
664 return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone); |
|
665 } |
|
666 |
|
667 EXPORT_C TInt RSCPClient :: StoreLockcode (TDesC& aNewLockcode, TDesC& aOldLockcode, RArray<TDevicelockPolicies>& aFailedPolicies) { |
|
668 Dprint((_L("[RSCPClient]-> StoreLockcode() >>>"))); |
|
669 TInt lErr = KErrNone; |
|
670 TInt lRet = KErrNone; |
|
671 |
|
672 if (!IsLockcodeChangeAllowedNow(aFailedPolicies)) { |
|
673 return KErrAccessDenied; |
|
674 } |
|
675 |
|
676 HBufC8* failedPoliciesBuff = NULL; |
|
677 |
|
678 TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32))); |
|
679 |
|
680 if(lRet == KErrNone) { |
|
681 lRet = SendReceive(ESCPServChangeEnhCode, TIpcArgs(&aOldLockcode, &aNewLockcode, &failedPoliciesBuff->Des())); |
|
682 |
|
683 TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des(); |
|
684 TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies)); |
|
685 |
|
686 delete failedPoliciesBuff; |
|
687 } |
|
688 |
|
689 Dprint((_L("[RSCPClient]-> StoreLockcode() <<<"))); |
|
690 return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone); |
|
691 } |
|
692 |
|
693 EXPORT_C TInt RSCPClient :: VerifyCurrentLockcode (TDesC& aLockcode,RMobilePhone::TMobilePassword& aISACode,RArray< TDevicelockPolicies > &aFailedPolicies, TInt aFlags) { |
|
694 Dprint((_L("[RSCPClient]-> VerifyCurrentLockcode() >>>"))); |
|
695 TInt lErr = KErrNone; |
|
696 TInt lRet = KErrNone; |
|
697 |
|
698 // extra one for failed policies count |
|
699 HBufC8* failedPoliciesBuff = NULL; |
|
700 |
|
701 TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32))); |
|
702 |
|
703 if(lRet == KErrNone) { |
|
704 lRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&aLockcode, &aISACode, &failedPoliciesBuff->Des(), aFlags)); |
|
705 |
|
706 TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des(); |
|
707 TRAP(lRet, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies)); |
|
708 |
|
709 delete failedPoliciesBuff; |
|
710 } |
|
711 |
|
712 return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone); |
|
713 } |
|
714 |
807 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
715 //#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS |
808 |
716 |
809 // --------------------------------------------------------- |
|
810 // RSCPClient::GetNewCodeAndChange() |
|
811 // Show the new code request and verification dialogs and |
|
812 // send the change request to the server. |
|
813 // |
|
814 // Status : Approved |
|
815 // --------------------------------------------------------- |
|
816 // |
|
817 TInt RSCPClient::GetNewCodeAndChange( TDes& aOldCode, |
|
818 TInt aMode, |
|
819 TSCPSecCode* aNewDOSCode /*=NULL*/, |
|
820 HBufC** aNewCodePptr/* = NULL*/) |
|
821 { |
|
822 |
|
823 |
|
824 if(!isFlagEnabled) |
|
825 { |
|
826 return KErrNotSupported; |
|
827 } |
|
828 TInt err = KErrNone; |
|
829 TInt ret = KErrNone; |
|
830 |
|
831 |
|
832 TInt maxLen = KSCPPasscodeMaxLength; |
|
833 TInt minLen = 1; |
|
834 |
|
835 // Fetch the minimum and maximum lengths for the code, if available. |
|
836 // This feature is commented out for correction to BU error ID: BNIN-6LC3AP. |
|
837 // Left in the code for possible inclusion in the future. |
|
838 //FetchLimits( minLen, maxLen ); |
|
839 |
|
840 // Request the new code and verify it. Repeat this until the codes match. |
|
841 |
|
842 // Create the buffers on the heap |
|
843 HBufC* newCodeHBuf = NULL; |
|
844 HBufC* verifyCodeHBuf = NULL; |
|
845 |
|
846 TRAP( err, newCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) ); |
|
847 if ( err == KErrNone ) |
|
848 { |
|
849 TRAP( err, verifyCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) ); |
|
850 } |
|
851 |
|
852 if ( err != KErrNone ) |
|
853 { |
|
854 if ( newCodeHBuf != NULL ) |
|
855 { |
|
856 delete newCodeHBuf; |
|
857 } |
|
858 return err; |
|
859 } |
|
860 |
|
861 TPtr newCodeBuffer = newCodeHBuf->Des(); |
|
862 TPtr verifyCodeBuffer = verifyCodeHBuf->Des(); |
|
863 |
|
864 // Configure the buttons according to the mode |
|
865 TSCPButtonConfig bConfig; |
|
866 TBool ecSupport; |
|
867 if ( aMode == KSCPForcedChange ) |
|
868 { |
|
869 bConfig = SCP_OK_ETEL; |
|
870 ecSupport = ETrue; |
|
871 } |
|
872 else |
|
873 { |
|
874 bConfig = SCP_OK_CANCEL; |
|
875 ecSupport = EFalse; |
|
876 } |
|
877 |
|
878 TBool isMismatch = EFalse; |
|
879 do // Repeat loop BEGIN |
|
880 { |
|
881 isMismatch = EFalse; |
|
882 |
|
883 if ( err == KErrSCPInvalidCode ) |
|
884 { |
|
885 err = KErrNone; // "reset" |
|
886 } |
|
887 |
|
888 newCodeBuffer.Zero(); |
|
889 |
|
890 TRAP( err, ret = RunDialogL( newCodeBuffer, |
|
891 bConfig, |
|
892 minLen, |
|
893 maxLen, |
|
894 R_SECUI_TEXT_ENTER_NEW_SEC_CODE, |
|
895 NULL, |
|
896 ecSupport ) ); |
|
897 |
|
898 if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) ) |
|
899 { |
|
900 verifyCodeBuffer.Zero(); |
|
901 |
|
902 TRAP( err, ret = RunDialogL( verifyCodeBuffer, |
|
903 bConfig, |
|
904 minLen, |
|
905 maxLen, |
|
906 R_SECUI_TEXT_VERIFY_NEW_SEC_CODE, |
|
907 NULL, |
|
908 ecSupport ) ); |
|
909 } |
|
910 |
|
911 if ( ( !ret ) || ( err != KErrNone ) || ( ret == ESecUiEmergencyCall ) ) |
|
912 { |
|
913 break; |
|
914 } |
|
915 |
|
916 if ( verifyCodeBuffer.Compare( newCodeBuffer ) != 0 ) |
|
917 { |
|
918 // Ignore the errors from showing the note, it's better to continue if it fails |
|
919 |
|
920 TRAP_IGNORE( |
|
921 // Show an error note, the entered codes don't match |
|
922 CAknNoteDialog* noteDlg = |
|
923 new (ELeave) CAknNoteDialog(reinterpret_cast<CEikDialog**>( ¬eDlg ) ); |
|
924 noteDlg->SetTimeout( CAknNoteDialog::ELongTimeout ); |
|
925 noteDlg->SetTone( CAknNoteDialog::EErrorTone ); |
|
926 noteDlg->ExecuteLD( R_CODES_DONT_MATCH ); |
|
927 ); |
|
928 |
|
929 isMismatch = ETrue; // Repeat code query |
|
930 } |
|
931 |
|
932 if ( !isMismatch ) |
|
933 { |
|
934 HBufC8* addParamsHBuf = NULL; |
|
935 |
|
936 TRAP( err, addParamsHBuf = HBufC8::NewL( KSCPMaxTARMNotifParamLen ) ); |
|
937 if ( err != KErrNone ) |
|
938 { |
|
939 delete verifyCodeHBuf; |
|
940 delete newCodeHBuf; |
|
941 return err; |
|
942 } |
|
943 |
|
944 TPtr8 addParams = addParamsHBuf->Des(); |
|
945 addParams.Zero(); |
|
946 |
|
947 if ( !isMismatch ) |
|
948 { |
|
949 // Try to change the code |
|
950 TSCPSecCode newDOSCode; |
|
951 newDOSCode.Zero(); |
|
952 |
|
953 err = SendReceive( ESCPServChangeEnhCode, |
|
954 TIpcArgs( &aOldCode, &verifyCodeBuffer, &addParams, &newDOSCode ) |
|
955 ); |
|
956 |
|
957 if ( addParams.Length() > 0 ) |
|
958 { |
|
959 // The server has sent additional parameters |
|
960 TRAPD( err, ProcessServerCommandsL( addParams ) ); |
|
961 if ( err != KErrNone ) |
|
962 { |
|
963 Dprint( (_L("RSCPClient::GetNewCodeAndChange():\ |
|
964 Process cmds FAILED: %d"), err )); |
|
965 } |
|
966 } |
|
967 |
|
968 if ( aNewDOSCode != NULL ) |
|
969 { |
|
970 (*aNewDOSCode).Copy( newDOSCode ); |
|
971 } |
|
972 } |
|
973 |
|
974 delete addParamsHBuf; |
|
975 } |
|
976 |
|
977 } while ( ( isMismatch ) || ( err == KErrSCPInvalidCode ) ); // Loop END |
|
978 |
|
979 if ( ( ( !ret ) && ( err == KErrNone ) ) || ( ret == ESecUiEmergencyCall ) ) |
|
980 { |
|
981 // Cancelled by user |
|
982 err = KErrAbort; |
|
983 } |
|
984 |
|
985 if((KErrNone == err) && (aNewCodePptr != 0)) { |
|
986 Dprint(_L("[RSCPClient]-> INFO: Updating new lock code to aNewCodePptr")); |
|
987 TRAP(err, *aNewCodePptr = HBufC :: NewL(verifyCodeHBuf->Des().Length())); |
|
988 |
|
989 if(*aNewCodePptr != NULL) { |
|
990 (*aNewCodePptr)->Des().Copy(verifyCodeHBuf->Des()); |
|
991 Dprint(_L("[RSCPClient]-> INFO: Updated new lock code to aNewCodePptr")); |
|
992 } |
|
993 } |
|
994 |
|
995 delete verifyCodeHBuf; |
|
996 delete newCodeHBuf; |
|
997 |
|
998 return err; |
|
999 } |
|
1000 |
|
1001 |
|
1002 |
|
1003 // --------------------------------------------------------- |
|
1004 // RSCPClient::ProcessServerCommandsL() |
|
1005 // Handle the commands in the server's param-buffer |
|
1006 // |
|
1007 // Status : Approved |
|
1008 // --------------------------------------------------------- |
|
1009 // |
|
1010 void RSCPClient::ProcessServerCommandsL( TDes8& aInParams, |
|
1011 CSCPParamObject** aOutParams, |
|
1012 TBool isNotifierEvent ) |
|
1013 { |
|
1014 |
|
1015 if(!isFlagEnabled) |
|
1016 { |
|
1017 User::Leave(KErrNotSupported); |
|
1018 } |
|
1019 Dprint( (_L("--> RSCPClient::ProcessServerCommandsL()") )); |
|
1020 (void)aOutParams; |
|
1021 |
|
1022 CSCPParamObject* theParams = CSCPParamObject::NewL(); |
|
1023 CleanupStack::PushL( theParams ); |
|
1024 |
|
1025 theParams->Parse( aInParams ); |
|
1026 TInt actionID; |
|
1027 TInt ret = theParams->Get( KSCPParamAction, actionID ); |
|
1028 |
|
1029 Dprint( (_L("RSCPClient::ProcessServerCommandsL():Params parsed") )); |
|
1030 |
|
1031 if ( ret != KErrNone ) |
|
1032 { |
|
1033 Dprint( (_L("RSCPClient::ProcessServerCommands(): Can't get action ID: %d"), ret )); |
|
1034 } |
|
1035 else |
|
1036 { |
|
1037 switch ( actionID ) |
|
1038 { |
|
1039 case ( KSCPActionShowUI ): |
|
1040 { |
|
1041 TRAP( ret, ShowUIL( *theParams ) ); |
|
1042 break; |
|
1043 } |
|
1044 |
|
1045 case ( KSCPActionForceChange ): |
|
1046 { |
|
1047 if ( isNotifierEvent ) |
|
1048 { |
|
1049 break; // Calling this through the notifier would jam the system |
|
1050 // since the server is busy. |
|
1051 } |
|
1052 |
|
1053 HBufC* codeHBuf = NULL; |
|
1054 codeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ); |
|
1055 CleanupStack::PushL( codeHBuf ); |
|
1056 |
|
1057 TPtr codeBuf = codeHBuf->Des(); |
|
1058 codeBuf.Zero(); |
|
1059 |
|
1060 ret = theParams->Get( KSCPParamPassword, codeBuf ); |
|
1061 if ( ret == KErrNone ) |
|
1062 { |
|
1063 TSCPSecCode newDOSCode; |
|
1064 ret = GetNewCodeAndChange( codeBuf, KSCPForcedChange, &newDOSCode ); |
|
1065 |
|
1066 // If aOutParams is defined, return the new code |
|
1067 if ( aOutParams != NULL ) |
|
1068 { |
|
1069 (*aOutParams) = CSCPParamObject::NewL(); |
|
1070 (*aOutParams)->Set( KSCPParamPassword, newDOSCode ); |
|
1071 } |
|
1072 } |
|
1073 |
|
1074 CleanupStack::PopAndDestroy( codeHBuf ); |
|
1075 |
|
1076 break; |
|
1077 } |
|
1078 } |
|
1079 } |
|
1080 |
|
1081 CleanupStack::PopAndDestroy( theParams ); |
|
1082 |
|
1083 Dprint( (_L("<-- RSCPClient::ProcessServerCommandsL()") )); |
|
1084 User::LeaveIfError( ret ); |
|
1085 } |
|
1086 |
|
1087 // --------------------------------------------------------- |
|
1088 // RSCPClient::ShowUI() |
|
1089 // Show the requested UI through AVKON |
|
1090 // |
|
1091 // Status : Approved |
|
1092 // --------------------------------------------------------- |
|
1093 // |
|
1094 void RSCPClient::ShowUIL( CSCPParamObject& aContext ) |
|
1095 { |
|
1096 |
|
1097 if(!isFlagEnabled) |
|
1098 { |
|
1099 User::Leave(KErrNotSupported); |
|
1100 } |
|
1101 Dprint( (_L("--> RSCPClient::ShowUIL()") )); |
|
1102 TInt mode; |
|
1103 User::LeaveIfError( aContext.Get( KSCPParamUIMode, mode ) ); |
|
1104 |
|
1105 switch ( mode ) |
|
1106 { |
|
1107 case ( KSCPUINote ): |
|
1108 { |
|
1109 // Get prompt |
|
1110 TBuf<KSCPMaxPromptTextLen> promptText; |
|
1111 aContext.Get( KSCPParamPromptText, promptText ); |
|
1112 |
|
1113 // Try to get note icon, default is to use "error" |
|
1114 TInt noteType = KSCPUINoteError; |
|
1115 Dprint( (_L("RSCPClient::ShowUIL(): Creating note object") )); |
|
1116 |
|
1117 CAknResourceNoteDialog* note = NULL; |
|
1118 |
|
1119 if ( aContext.Get( KSCPParamNoteIcon, noteType ) != KErrNone ) |
|
1120 { |
|
1121 noteType = KSCPUINoteError; |
|
1122 } |
|
1123 |
|
1124 switch ( noteType ) |
|
1125 { |
|
1126 case ( KSCPUINoteWarning ): |
|
1127 { |
|
1128 note = new (ELeave) CAknWarningNote( ETrue ); |
|
1129 break; |
|
1130 } |
|
1131 |
|
1132 case ( KSCPUINoteError ): |
|
1133 default: // default to error |
|
1134 { |
|
1135 note = new (ELeave) CAknErrorNote( ETrue ); |
|
1136 break; |
|
1137 } |
|
1138 } |
|
1139 |
|
1140 if ( note != NULL ) |
|
1141 { |
|
1142 Dprint( (_L("RSCPClient::ShowUIL(): Showing note") )); |
|
1143 note->ExecuteLD( promptText ); |
|
1144 } |
|
1145 } |
|
1146 } |
|
1147 |
|
1148 Dprint( (_L("<-- RSCPClient::ShowUIL()") )); |
|
1149 } |
|
1150 |
|
1151 |
717 |
1152 // --------------------------------------------------------- |
718 // --------------------------------------------------------- |
1153 // RSCPClient::FetchLimits() |
719 // RSCPClient::FetchLimits() |
1154 // Retrieve the limit-parameter values if available |
720 // Retrieve the limit-parameter values if available |
1155 // |
721 // |
1191 if ( ( lex.Val( aMax ) != KErrNone ) || ( aMax <= 0 ) ) |
757 if ( ( lex.Val( aMax ) != KErrNone ) || ( aMax <= 0 ) ) |
1192 { |
758 { |
1193 aMax = KSCPPasscodeMaxLength; |
759 aMax = KSCPPasscodeMaxLength; |
1194 } |
760 } |
1195 } |
761 } |
1196 } |
762 } |
1197 TInt RSCPClient :: SetSecurityCodeL(RMobilePhone :: TMobilePassword& aPassword, |
763 |
1198 TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) { |
764 void RSCPClient :: ReadFailedPoliciesL(TDes8& aFailedPolicyBuf, RArray< TDevicelockPolicies>& aFailedPolicies) { |
1199 Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>"))); |
765 Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL() >>>"))); |
1200 Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport)); |
766 |
1201 |
767 if(aFailedPolicyBuf.Length() < 1) { |
1202 if(EFalse == isFlagEnabled) { |
768 return; |
1203 (void)aPassword; |
769 } |
1204 Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant"))); |
770 |
1205 User :: Invariant(); |
771 RDesReadStream readStream(aFailedPolicyBuf); |
1206 return KErrNotSupported; |
772 CleanupClosePushL(readStream); |
1207 } |
773 |
1208 TInt lRet = LoadResources(aResFileSCP, aResFileSecUi); |
774 TInt failedPoliciesCount = readStream.ReadInt32L(); |
1209 if(lRet != KErrNone) { |
775 aFailedPolicies.Reset(); |
1210 return lRet; |
776 Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL failedPoliciesCount =%d"), failedPoliciesCount)); |
1211 } |
777 for(int i=0; i < failedPoliciesCount; i++) { |
1212 TInt lDefCode = 0; |
778 TInt32 temp = readStream.ReadInt32L(); |
1213 CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode); |
779 //aFailedPolicies.Append((TDevicelockPolicies) readStream.ReadInt32L()); |
1214 lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode); |
780 aFailedPolicies.AppendL((TDevicelockPolicies)temp); |
1215 if(lRet != KErrNone) { |
781 Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL failed policy =%d"), temp)); |
1216 Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet); |
782 } |
1217 CleanupStack :: PopAndDestroy(lRepository); |
783 |
1218 return lRet; |
784 CleanupStack :: PopAndDestroy(&readStream); |
1219 } |
785 Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL() <<<"))); |
1220 HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1); |
|
1221 HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen); |
|
1222 TPtr codeBuffer = codeHBuf->Des(); |
|
1223 TPtr8 addParams = addParamsHBuf->Des(); |
|
1224 if(lDefCode == 0) { |
|
1225 Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user...")); |
|
1226 lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength, |
|
1227 R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport); |
|
1228 if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) { |
|
1229 Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code...")); |
|
1230 lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags)); |
|
1231 Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length()); |
|
1232 Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet); |
|
1233 } |
|
1234 else { |
|
1235 switch(lRet) { |
|
1236 case 0: |
|
1237 lRet = KErrCancel; |
|
1238 break; |
|
1239 case EAknSoftkeyEmergencyCall: |
|
1240 //lRet = KErrCancel; |
|
1241 break; |
|
1242 case ESecUiEmergencyCall: |
|
1243 lRet = ESecUiEmergencyCall; |
|
1244 break; |
|
1245 /*default: |
|
1246 break;*/ |
|
1247 } |
|
1248 } |
|
1249 } |
|
1250 else { |
|
1251 TRequestStatus statusSave; |
|
1252 Dprint(_L("[RSCPClient]-> INFO: Default lock code not set by the user, requesting for the same")); |
|
1253 |
|
1254 HBufC* msgConfirmSave = NULL; |
|
1255 CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC(); |
|
1256 |
|
1257 if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) { |
|
1258 //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
|
1259 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_SETTING_QUERY_SERVER); |
|
1260 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_OK_EMPTY__OK, R_QGN_NOTE_INFO_ANIM); |
|
1261 } |
|
1262 else { |
|
1263 msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE); |
|
1264 query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM); |
|
1265 } |
|
1266 |
|
1267 User :: WaitForRequest(statusSave); |
|
1268 CleanupStack :: PopAndDestroy(2); // msgConfirmSave query |
|
1269 |
|
1270 if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) { |
|
1271 Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ...")); |
|
1272 |
|
1273 TBufC<10> NBuf(KSCPDefaultEnchSecCode); |
|
1274 TPtr codeBuf = NBuf.Des(); |
|
1275 |
|
1276 TSCPSecCode lNewSecCode; |
|
1277 TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange; |
|
1278 HBufC* lNewLkCodeBuf = NULL; |
|
1279 lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf); |
|
1280 |
|
1281 Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet); |
|
1282 |
|
1283 if(KErrNone == lRet) { |
|
1284 /* This is being called as a workaround for a freezing issue with SecUI. This is in place |
|
1285 * as a temporary measure until the source is identified. |
|
1286 */ |
|
1287 TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags)); |
|
1288 |
|
1289 Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet); |
|
1290 if(KErrNone == lRet) { |
|
1291 Dprint(_L("[RSCPClient]-> INFO: updating CenRep ...")); |
|
1292 lRepository->Set(KSCPLockCodeDefaultLockCode, 0); |
|
1293 Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet); |
|
1294 } |
|
1295 } |
|
1296 |
|
1297 if(lNewLkCodeBuf) { |
|
1298 delete lNewLkCodeBuf; |
|
1299 } |
|
1300 } |
|
1301 else { |
|
1302 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
|
1303 lRet = KErrCancel; |
|
1304 } |
|
1305 |
|
1306 if(KErrAbort == lRet) { |
|
1307 Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel")); |
|
1308 lRet = KErrCancel; |
|
1309 } |
|
1310 |
|
1311 } |
|
1312 |
|
1313 if(addParams.Length() > 0) { |
|
1314 CSCPParamObject* tmp = CSCPParamObject :: NewLC(); |
|
1315 TInt lTempRet = tmp->Parse(addParams); |
|
1316 |
|
1317 if(lTempRet == KErrNone) { |
|
1318 lTempRet = tmp->Set(KSCPParamPassword, codeBuffer); |
|
1319 } |
|
1320 |
|
1321 if(lTempRet == KErrNone) { |
|
1322 addParams.Zero(); |
|
1323 HBufC8* tmpBuf; |
|
1324 lTempRet = tmp->GetBuffer(tmpBuf); |
|
1325 |
|
1326 if(lTempRet == KErrNone) { |
|
1327 addParams.Copy(tmpBuf->Des()); |
|
1328 delete tmpBuf; |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 if(lTempRet == KErrNone) { |
|
1333 CSCPParamObject* outParams = NULL; |
|
1334 ProcessServerCommandsL(addParams, &outParams); |
|
1335 |
|
1336 if(outParams != NULL) { |
|
1337 TSCPSecCode newSecCode; |
|
1338 if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) { |
|
1339 Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword..."))); |
|
1340 aPassword.Copy(newSecCode); |
|
1341 } |
|
1342 delete outParams; |
|
1343 } |
|
1344 } |
|
1345 CleanupStack :: PopAndDestroy(tmp); |
|
1346 } |
|
1347 CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf |
|
1348 Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet); |
|
1349 return lRet; |
|
1350 } |
786 } |
1351 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
787 //#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS |
1352 // <<-- *********** Device lock new features ************* |
788 // <<-- *********** Device lock new features ************* |
1353 |
789 |
1354 |
790 |