diff -r 3aa774c655ac -r f1030a78d563 securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp --- a/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp Tue Jun 29 10:29:16 2010 +0300 +++ b/securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp Thu Jul 08 20:04:36 2010 +0300 @@ -1,20 +1,20 @@ /* -* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Provides api for handling security events. -* -* -*/ + * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Provides api for handling security events. + * + * + */ #include #include #include @@ -24,10 +24,8 @@ #ifdef __COVER_DISPLAY #include -// #include #endif //__COVER_DISPLAY #include -#include //used for RemoveSplashScreen #include #include // Property values @@ -50,6 +48,7 @@ #include #include #include +#include #include "SecQueryUi.h" @@ -75,7 +74,14 @@ RDEBUG("0", 0); TInt result = iCustomPhone.Open(aPhone); + RDEBUG("result", result); TRAP_IGNORE(FeatureManager::InitializeLibL()); //Shouldn't this panic if FM does not initialise?? + + _LIT(KFileName, "secui_"); + _LIT(KPath, "z:/resource/qt/translations/"); + RDEBUG("HbTextResolverSymbian", 0); + result = HbTextResolverSymbian::Init(KFileName, KPath); + RDEBUG("result", result); } // @@ -98,7 +104,7 @@ RDEBUG("err", err); iCustomPhone.Close(); FeatureManager::UnInitializeLib(); - RDEBUG("1", 1); + RDEBUG("1", 1); } // // ---------------------------------------------------------- @@ -106,8 +112,7 @@ // Handles different security events // ---------------------------------------------------------- // qtdone -EXPORT_C void CSecurityHandler::HandleEventL( - RMobilePhone::TMobilePhoneSecurityEvent aEvent) +EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent) { RDEBUG("0", 0); @@ -121,9 +126,7 @@ // Handles different security events // ---------------------------------------------------------- // qtdone -EXPORT_C void CSecurityHandler::HandleEventL( - RMobilePhone::TMobilePhoneSecurityEvent aEvent, TBool aStartup, - TInt& aResult) +EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TBool aStartup, TInt& aResult) { RDEBUG("0", 0); @@ -137,8 +140,7 @@ // Handles different security events // ---------------------------------------------------------- // qtdone -EXPORT_C void CSecurityHandler::HandleEventL( - RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult) +EXPORT_C void CSecurityHandler::HandleEventL(RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult) { RDEBUG("0", 0); @@ -146,19 +148,20 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ - TBool wcdmaSupported( - FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma)); - TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin)); + TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)); + TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin)); RDEBUG("aEvent", aEvent); switch (aEvent) { case RMobilePhone::EPin1Required: - RDEBUG("RMobilePhone::EPin1Required", 0); + RDEBUG("RMobilePhone::EPin1Required", 0) + ; aResult = Pin1RequiredL(); break; case RMobilePhone::EPuk1Required: - RDEBUG("RMobilePhone::EPuk1Required", 0); + RDEBUG("RMobilePhone::EPuk1Required", 0) + ; Puk1RequiredL(); break; case RMobilePhone::EPin2Required: @@ -190,7 +193,8 @@ SimLockEventL(); break; default: - RDEBUG("default", aEvent); + RDEBUG("default", aEvent) + ; break; } RDEBUG("aResult", aResult); @@ -207,9 +211,8 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ - RDEBUG("0", 0); - - /* if code is still not initialized, then there's no need to ask it. This fixes the error when the RFS requests the code */ + RDEBUG("0", 0); + // if code is still not initialized, then there's no need to ask it. This fixes the error when the RFS requests the code. const TUid KCRUidSCPLockCode = { 0x2002677B @@ -221,24 +224,27 @@ TInt res = -1; TInt lAlphaSupported = 0; TInt lCancelSupported = 0; + RMobilePhone::TMobilePassword iSecUi_password; - res = repository->Get(KSCPLockCodeDefaultLockCode, currentLockStatus); + res = repository->Get(KSCPLockCodeDefaultLockCode, currentLockStatus); // 0x3039 = 12345 RDEBUG("res", res); RDEBUG("currentLockStatus", currentLockStatus); delete repository; - if (res == 0 && currentLockStatus == 1) + if (res == 0 && (currentLockStatus == 1 || currentLockStatus == 12345) ) { - // code is the default one; no need to request it. - return ETrue; + // code is the default one + RDEBUG("code is the default one; supply as default", 1); + iSecUi_password.Copy(_L("12345")); + // RDEBUG("code is the default one; no need to request it", 1); + // return ETrue; } - /* end check for default code */ + // end check for default code RMobilePhone::TMobilePassword required_fourth; TInt ret = KErrNone; TInt status = KErrNone; - RMobilePhone::TMobilePassword iSecUi_password; TInt queryAccepted = KErrCancel; while (queryAccepted != KErrNone) @@ -250,22 +256,20 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; lAlphaSupported = ESecUiAlphaSupported; lCancelSupported = ESecUiCancelSupported; TBuf<0x100> title; title.Zero(); - title.Append(_L("AskSecCodeL")); - title.Append(_L("#")); - title.AppendNum(-1); - queryAccepted - = iSecQueryUi->SecQueryDialog(title, iSecUi_password, - SEC_C_SECURITY_CODE_MIN_LENGTH, - SEC_C_SECURITY_CODE_MAX_LENGTH, ESecUiSecretSupported - | lAlphaSupported | lCancelSupported - | secCodeType ); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("AskSecCodeL")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); + title.AppendNum(-1); // Don't know the number of remaining attempts + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, ESecUiSecretSupported | lAlphaSupported + | lCancelSupported | secCodeType); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); RDEBUG("delete", 0); iQueryCanceled = ETrue; delete iSecQueryUi; @@ -279,17 +283,16 @@ CWait* wait = CWait::NewL(); RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, - iSecUi_password, required_fourth); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); RDEBUG("WaitForRequestL", 0); status = wait->WaitForRequestL(); RDEBUG("status", status); delete wait; #ifdef __WINS__ - if(status==KErrNotSupported || status == KErrTimedOut) + if (status == KErrNotSupported || status == KErrTimedOut) { - RDEBUG( "status", status ); - status=KErrNone; + RDEBUG("status", status); + status = KErrNone; } #endif @@ -299,10 +302,7 @@ { case KErrNone: { - if (FeatureManager::FeatureSupported( - KFeatureIdSapTerminalControlFw) - && !(FeatureManager::FeatureSupported( - KFeatureIdSapDeviceLockEnhancements))) + if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw) && !(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))) { RDEBUG("calling RSCPClient", 0); RSCPClient scpClient; @@ -310,7 +310,12 @@ CleanupClosePushL(scpClient); TSCPSecCode newCode; + RDEBUG("iSecUi_password", 1); + RDEBUGSTR(iSecUi_password); newCode.Copy(iSecUi_password); + RDEBUG( + "!!!!!!! ***** deprecated **** !!!!! scpClient.StoreCode", + 0); scpClient.StoreCode(newCode); RDEBUG("called StoreCode", 1); @@ -325,21 +330,19 @@ case KErrLocked: { // security code blocked! - CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); break; } case KErrGsm0707IncorrectPassword: case KErrAccessDenied: { // code was entered erroneusly - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); + break; } default: { - CSecuritySettings::ShowResultNoteL(status, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(status, CAknNoteDialog::EErrorTone); } } } // while @@ -350,49 +353,51 @@ // // ---------------------------------------------------------- // Cancels all security code queries -// aStatus = -1 from destructor -// aStatus = 1 from API. Will kill all dialogs through signal P&S +// aStatus = -1 from destructor +// aStatus = 1 from API. Will kill all dialogs through signal P&S // ---------------------------------------------------------- // qtdone TInt CSecurityHandler::CancelOpenQuery(TInt aStatus) { - RDEBUG("aStatus", aStatus); - RDEBUG("iQueryCanceled", iQueryCanceled); - TInt res = 0; - - if(aStatus==1) // also signal all other dialogs - { - RDEBUG("set KSecurityUIsDismissDialog to ESecurityUIsDismissDialogOn", ESecurityUIsDismissDialogOn); - TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn ); - RDEBUG("err", err); - res += 1; - } + RDEBUG("aStatus", aStatus); + RDEBUG("iQueryCanceled", iQueryCanceled); + TInt res = 0; + + if (aStatus == 1) // also signal all other dialogs + { + RDEBUG( + "set KSecurityUIsDismissDialog to ESecurityUIsDismissDialogOn", + ESecurityUIsDismissDialogOn); + TInt err = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsDismissDialog, ESecurityUIsDismissDialogOn); + RDEBUG("err", err); + res += 1; + } if (!iQueryCanceled) { - // notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged - // this will cancel only the dialog which was opened by same client. - res += 0x10; + // notify all dialogs, in particular SecUiNotificationDialog::subscriberKSecurityUIsDismissDialogChanged + // this will cancel only the dialog which was opened by same client. + res += 0x10; iQueryCanceled = ETrue; if (iSecurityDlg != NULL) { RDEBUG("deleting iSecurityDlg", 0); - res += 0x100; + res += 0x100; delete iSecurityDlg; } if (iNoteDlg != NULL) { RDEBUG("deleting iNoteDlg", 0); - res += 0x1000; + res += 0x1000; delete iNoteDlg; } iNoteDlg = NULL; iSecurityDlg = NULL; } - res += 0x10000; - RDEBUG("res", res); - return res; - } + res += 0x10000; + RDEBUG("res", res); + return res; + } // // ---------------------------------------------------------- @@ -403,11 +408,11 @@ // qtdone EXPORT_C void CSecurityHandler::CancelSecCodeQuery() { - RDEBUG("0", 0); + RDEBUG("0", 0); - TInt err = CancelOpenQuery(1); + TInt err = CancelOpenQuery(1); - RDEBUG("err", err); + RDEBUG("err", err); } // // ---------------------------------------------------------- @@ -426,8 +431,7 @@ TInt res; CWait* wait; - RMobilePhone::TMobilePhoneLockSetting lockChange( - RMobilePhone::ELockSetDisabled); + RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled); RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice; // get autolock period from Central Repository. @@ -444,20 +448,20 @@ // disable autolock in Domestic OS side too if autolock period is 0. if (period == 0) { - RDEBUG("period", period); + RDEBUG("period", period); // If remote lock is enabled, don't disable the domestic OS device lock // since that would render the RemoteLock useless. // Instead just re-set the DOS lock to enabled which as a side effect // requests the security code from the user. - TBool remoteLockStatus( EFalse ); + TBool remoteLockStatus(EFalse); CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); - if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) + if (remoteLockSettings->GetEnabled(remoteLockStatus)) { - RDEBUG( "0", 0 ); - if ( remoteLockStatus ) + RDEBUG("0", 0); + if (remoteLockStatus) { // Remote lock is enabled lockChange = RMobilePhone::ELockSetEnabled; @@ -473,7 +477,7 @@ else { // Failed to get remote lock status - RDEBUG("Failed", lockChange); + RDEBUG("Failed", lockChange); } delete remoteLockSettings; @@ -502,13 +506,11 @@ TPckg response(queryResponse); RDEBUG("0", 0); TSecurityNotificationPckg params; - params().iEvent - = static_cast (RMobilePhone::EPhonePasswordRequired); + params().iEvent = static_cast (RMobilePhone::EPhonePasswordRequired); params().iStartup = EFalse; RDEBUG("StartNotifierAndGetResponse", 0); - codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, - KSecurityNotifierUid, params, response); + codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid, params, response); // this will eventually call PassPhraseRequiredL RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); @@ -529,12 +531,12 @@ // Instead just re-set the DOS lock to enabled which as a side effect // requests the security code from the user. - TBool remoteLockStatus( EFalse ); + TBool remoteLockStatus(EFalse); CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); - if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) + if (remoteLockSettings->GetEnabled(remoteLockStatus)) { - if ( remoteLockStatus ) + if (remoteLockStatus) { // Remote lock is enabled lockChange = RMobilePhone::ELockSetEnabled; @@ -583,32 +585,32 @@ } case KErrInUse: { - RDEBUG("KErrInUse", KErrInUse); - return EFalse; + RDEBUG("KErrInUse", KErrInUse); + return EFalse; } - case KErrDied : + case KErrDied: { - RDEBUG("KErrDied ", KErrDied ); - return EFalse; + RDEBUG("KErrDied ", KErrDied); + return EFalse; } - case KErrServerTerminated : + case KErrServerTerminated: { - RDEBUG("KErrServerTerminated ", KErrServerTerminated ); - return EFalse; + RDEBUG("KErrServerTerminated ", KErrServerTerminated); + return EFalse; } - case KErrServerBusy : + case KErrServerBusy: { - RDEBUG("KErrServerBusy ", KErrServerBusy ); - return EFalse; + RDEBUG("KErrServerBusy ", KErrServerBusy); + return EFalse; } case KErrAbort: { - RDEBUG("KErrAbort", KErrAbort); - return EFalse; + RDEBUG("KErrAbort", KErrAbort); + return EFalse; } case KErrCancel: { - RDEBUG("KErrCancel", KErrCancel); + RDEBUG("KErrCancel", KErrCancel); // user pressed "cancel" return EFalse; } @@ -643,21 +645,19 @@ TInt lEmergencySupported = 0; TInt err(KErrGeneral); - err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, - autolockState); + err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState); RDEBUG("StartUp", StartUp); RDEBUG("err", err); if (!StartUp) - { - RDebug::Printf( "%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err ); + { + RDebug::Printf("%s %s (%u) might leave if StartUp=0 and err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err); User::LeaveIfError(err); - } + } TBool isConditionSatisfied = EFalse; TInt tarmFlag = 0; - if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw )) + if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) { - TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, - tarmFlag); + TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); if (tRet != KErrNone) { @@ -701,15 +701,17 @@ CSecQueryUi *iSecQueryUi; iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; - TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported - | lCancelSupported | lEmergencySupported | secCodeTypeToAsk; + iQueryCanceled = EFalse; + TInt lType = ESecUiSecretSupported | ESecUiAlphaSupported | lCancelSupported | lEmergencySupported | secCodeTypeToAsk; RDEBUG("lType", lType); - queryAccepted = iSecQueryUi->SecQueryDialog(_L("PassPhraseRequiredL"), - iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, - SEC_C_SECURITY_CODE_MAX_LENGTH, lType); + TBuf<0x100> title; + title.Zero(); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("PassPhraseRequiredL")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_SECURITY_CODE_MIN_LENGTH, SEC_C_SECURITY_CODE_MAX_LENGTH, lType); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); RDEBUG("queryAccepted", queryAccepted); iQueryCanceled = ETrue; delete iSecQueryUi; @@ -717,13 +719,12 @@ TBool wasCancelledOrEmergency = EFalse; RDEBUG("KFeatureIdSapDeviceLockEnhancements", KFeatureIdSapDeviceLockEnhancements); - if ((queryAccepted == KErrAbort /* =emergency */) || (queryAccepted - == KErrCancel)) + if ((queryAccepted == KErrAbort /* =emergency */) || (queryAccepted == KErrCancel)) wasCancelledOrEmergency = ETrue; RDEBUG("wasCancelledOrEmergency", wasCancelledOrEmergency); if (wasCancelledOrEmergency) { - RDEBUG("StartUp", StartUp); + RDEBUG("StartUp", StartUp); if (!StartUp) { RDEBUG("AbortSecurityCode", 0); @@ -733,26 +734,98 @@ return KErrCancel; } - RMobilePhone::TMobilePhoneSecurityCode secCodeType = - RMobilePhone::ESecurityCodePhonePassword; + RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword; CWait* wait = NULL; TInt status = KErrNone; - - wait = CWait::NewL(); - RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, - required_fourth); - RDEBUG("WaitForRequestL", 0); - status = wait->WaitForRequestL(); - RDEBUG("WaitForRequestL status", status); - delete wait; + + // Validate the code using SCP. This is needed to check expiration + RDEBUG("AbortSecurityCode", 0); + RSCPClient scpClient; + RDEBUG("scpClient.Connect", 0); + TInt tRet = scpClient.Connect(); + RDEBUG("tRet", tRet); + + CleanupClosePushL(scpClient); + + RArray aFailedPolicies; + TDevicelockPolicies failedPolicy; + TInt retLockcode = KErrNone; + RMobilePhone::TMobilePassword aISACode; + TInt aFlags = 0; + RDEBUG("scpClient.VerifyCurrentLockcode", 0); + // this validate on ISA . No need to do iPhone.VerifySecurityCode + retLockcode = scpClient.VerifyCurrentLockcode(iSecUi_password, aISACode, aFailedPolicies, aFlags); + RDEBUG("retLockcode", retLockcode); + + RDEBUG("aISACode", 0); + RDEBUGSTR(aISACode); + + RDEBUG("aFailedPolicies.Count()", aFailedPolicies.Count()); + RDEBUG("EDeviceLockPasscodeExpiration", EDeviceLockPasscodeExpiration); // 8 + TInt failedEDeviceLockPasscodeExpiration = 0; + for (TInt i = 0; i < aFailedPolicies.Count(); i++) + { + failedPolicy = aFailedPolicies[i]; + RDEBUG("failedPolicy", failedPolicy); + if (failedPolicy == EDeviceLockPasscodeExpiration) + failedEDeviceLockPasscodeExpiration = EDeviceLockPasscodeExpiration; + } + RDEBUG("Close", 0); + scpClient.Close(); + RDEBUG("PopAndDestroy", 0); + CleanupStack::PopAndDestroy(); //scpClient + + RDEBUG("failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration); + if (failedEDeviceLockPasscodeExpiration > 0) + { + // the password has expired. Note that it has NOT been validated. It will be revalidated inside ChangeSecCodeParamsL + RMobilePhone::TMobilePassword iNewPassword; + TInt iFlags = 0; + iNewPassword.Copy(_L("")); + TBuf<0x80> iCaption; + iCaption.Copy(_L("ChangeSecCodeL")); // no need to translate because it's not used + TInt iShowError = 1; + CSecuritySettings* iSecSettings; + iSecSettings = CSecuritySettings::NewL(); + TSecUi::InitializeLibL(); + RDEBUG("calling ChangeSecCodeParamsL", 0); + status = iSecSettings->ChangeSecCodeParamsL(iSecUi_password, iNewPassword, iFlags, iCaption, iShowError); + // note that it might have been aborted. The error KErrAbort is shown in this method, not inside ChangeSecCodeParamsL + if(status==KErrAccessDenied || status==KErrGsm0707IncorrectPassword) + { + // the password expired, but the user typed wrongly. The error was already displayed. + RDEBUG("SCP returned ", KErrAccessDenied); + status=R_CODES_DONT_MATCH; + RDEBUG("SCP changed to R_CODES_DONT_MATCH", R_CODES_DONT_MATCH); + } + RDEBUG("status", status); + RDEBUG("iNewPassword", 0); + RDEBUGSTR(iNewPassword); + TSecUi::UnInitializeLib(); + RDEBUG("deleting iSecSettings", 0); + delete iSecSettings; + RDEBUG("deleted iSecSettings", 1); + } + else + { + RDEBUG( "wait", 0 ); + wait = CWait::NewL(); + RDEBUG("VerifySecurityCode", 0); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); + RDEBUG("WaitForRequestL", + 0); + status = wait->WaitForRequestL(); + RDEBUG("WaitForRequestL status", + status); + delete wait; #ifdef __WINS__ - if(status==KErrNotSupported || status == KErrTimedOut) - { - RDEBUG( "status", status ); - status=KErrNone; + if (status == KErrNotSupported || status == KErrTimedOut) + { + RDEBUG( "status", status ); + status = KErrNone; + } +#endif } -#endif TInt returnValue = status; RDEBUG("tarmFlag", tarmFlag); @@ -762,9 +835,16 @@ { case KErrNone: // code approved - RDEBUG( "KErrNone", KErrNone ); - CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, - CAknNoteDialog::EConfirmationTone); + { + RDEBUG("KErrNone", KErrNone); + if( failedEDeviceLockPasscodeExpiration > 0) + { + RDEBUG("code has just been changed. No need to show Confirmation note. failedEDeviceLockPasscodeExpiration", failedEDeviceLockPasscodeExpiration); + } + else + { + CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); + } RDEBUG("R_CONFIRMATION_NOTE", R_CONFIRMATION_NOTE); if (FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw)) { @@ -773,26 +853,24 @@ // Unset the admin flag if set if (tarmFlag & KSCPFlagResyncQuery) { - TInt tRet = RProperty::Get(KSCPSIDAutolock, - SCP_TARM_ADMIN_FLAG_UID, tarmFlag); + TInt tRet = RProperty::Get(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); if (tRet == KErrNone) { tarmFlag &= ~KSCPFlagResyncQuery; - tRet = RProperty::Set(KSCPSIDAutolock, - SCP_TARM_ADMIN_FLAG_UID, tarmFlag); + tRet = RProperty::Set(KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag); } if (tRet != KErrNone) { - RDEBUG( "FAILED to unset TARM Admin Flag tRet=", tRet ); + RDEBUG( + "FAILED to unset TARM Admin Flag tRet=", + tRet); } } - if (!FeatureManager::FeatureSupported( - KFeatureIdSapDeviceLockEnhancements)) + if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) { - RDEBUG("KFeatureIdSapDeviceLockEnhancements", - KFeatureIdSapDeviceLockEnhancements); + RDEBUG("KFeatureIdSapDeviceLockEnhancements", KFeatureIdSapDeviceLockEnhancements); RSCPClient scpClient; RDEBUG("scpClient.Connect", 0); TInt tRet = scpClient.Connect(); @@ -802,8 +880,13 @@ CleanupClosePushL(scpClient); TSCPSecCode newCode; newCode.Copy(iSecUi_password); + RDEBUG( + "!!!!!!! ***** TODO deprecated **** !!!!! scpClient.StoreCode", + 0); scpClient.StoreCode(newCode); RDEBUG("scpClient.StoreCode", 1); + // TODO check whether code is expired. + // This should be done by TARM, and they should ask to change the code CleanupStack::PopAndDestroy(); //scpClient } @@ -812,23 +895,19 @@ if (StartUp) { // get autolock period from Central Repository. - CRepository* repository = CRepository::NewL( - KCRUidSecuritySettings); + CRepository* repository = CRepository::NewL(KCRUidSecuritySettings); TInt period = 0; TInt res = repository->Get(KSettingsAutoLockTime, period); delete repository; RDEBUG("res", res); RDEBUG("period", period); - _LIT_SECURITY_POLICY_PASS( KReadPolicy); _LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData); - RProperty::Define(KPSUidCoreApplicationUIs, - KCoreAppUIsAutolockStatus, RProperty::EInt, - KReadPolicy, KWritePolicy); - RProperty::Set(KPSUidCoreApplicationUIs, - KCoreAppUIsAutolockStatus, EAutolockOff); - RDEBUG("KCoreAppUIsAutolockStatus", KCoreAppUIsAutolockStatus); + RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy); + RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff); + RDEBUG("KCoreAppUIsAutolockStatus", + KCoreAppUIsAutolockStatus); if (res == KErrNone) { @@ -838,29 +917,35 @@ // Don't disable the domestic OS device lock // since that would render the RemoteLock useless. - TBool remoteLockStatus( EFalse ); + TBool remoteLockStatus(EFalse); CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); - if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) + if (remoteLockSettings->GetEnabled(remoteLockStatus)) { - if ( !remoteLockStatus ) + if (!remoteLockStatus) { // Remote lock is disabled - RDEBUG("Autolock and RemoteLock are disabled -> disable DOS device lock", 0); + RDEBUG( + "Autolock and RemoteLock are disabled -> disable DOS device lock", + 0); // Disable DOS device lock setting - RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); + RDEBUG( + "iCustomPhone.DisablePhoneLock", + 0); wait = CWait::NewL(); - iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); - RDEBUG( "WaitForRequestL", 0 ); + iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password); + RDEBUG("WaitForRequestL", 0); status = wait->WaitForRequestL(); - RDEBUG( "WaitForRequestL", status ); + RDEBUG("WaitForRequestL", status); delete wait; } } else { // Failed to get remote lock status - RDEBUG( "Autolock is disabled, but failed to get RemoteLock status, so do nothing", 0 ); + RDEBUG( + "Autolock is disabled, but failed to get RemoteLock status, so do nothing", + 0); } delete remoteLockSettings; @@ -874,27 +959,29 @@ // Don't disable the domestic OS device lock // since that would render the RemoteLock useless. - TBool remoteLockStatus( EFalse ); + TBool remoteLockStatus(EFalse); CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL(); - if ( remoteLockSettings->GetEnabled( remoteLockStatus ) ) + if (remoteLockSettings->GetEnabled(remoteLockStatus)) { - if ( !remoteLockStatus ) + if (!remoteLockStatus) { // Remote lock is disabled - RDEBUG( "iCustomPhone.DisablePhoneLock", 0 ); + RDEBUG("iCustomPhone.DisablePhoneLock", 0); wait = CWait::NewL(); - iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password); - RDEBUG( "WaitForRequestL", 0 ); - status = wait->WaitForRequestL(); - RDEBUG( "WaitForRequestL status", status ); + iCustomPhone.DisablePhoneLock(wait->iStatus, iSecUi_password); + RDEBUG("WaitForRequestL", 0); + status = wait->WaitForRequestL(); + RDEBUG("WaitForRequestL status", status); delete wait; } } else { // Failed to get remote lock status - RDEBUG( "Failed to get Autolock period and RemoteLock status, so do nothing", 0 ); + RDEBUG( + "Failed to get Autolock period and RemoteLock status, so do nothing", + 0); } delete remoteLockSettings; @@ -903,26 +990,38 @@ } } // no Startup - + } break; case KErrGsmSSPasswordAttemptsViolation: case KErrLocked: + { // security code blocked! - RDEBUG("KErrLocked", KErrLocked); - CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, - CAknNoteDialog::EErrorTone); + RDEBUG("KErrLocked", KErrLocked) + ; + CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone); + } break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: + { RDEBUG("KErrAccessDenied", KErrAccessDenied); // The Settings caller might retry - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); + } + break; + case R_CODES_DONT_MATCH: // if password was supposed to be changed, but it failed (the initial verification) + { + RDEBUG("R_CODES_DONT_MATCH", R_CODES_DONT_MATCH); + // Error was already displayed + returnValue = KErrAccessDenied; + } break; default: + { RDEBUG("default", status); CSecuritySettings::ShowErrorNoteL(status); // The Settings caller might retry + } break; } RDEBUG("returnValue", returnValue); @@ -947,8 +1046,7 @@ TInt queryAccepted = KErrCancel; TInt lAlphaSupported = 0; RMobilePhone::TMobilePassword required_fourth; - RMobilePhone::TMobilePhoneSecurityCode secCodeType = - RMobilePhone::ESecurityCodePin1; + RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1; RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); TBool StartUp = ETrue; @@ -965,18 +1063,16 @@ if (!StartUp) { // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL - err = RProperty::Get(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); + err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); if (err != KErrNone) { - RDEBUG("FAILED to get the SECUI query Flag err", err); + RDEBUG("FAILED to get the SECUI query Flag err", err); } } RDEBUG("err", err); RDEBUG("secUiOriginatedQuery", secUiOriginatedQuery); RDEBUG("ESecurityUIsSecUIOriginated", ESecurityUIsSecUIOriginated); - if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) - || (err != KErrNone)) + if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone)) { RDEBUG("0", 0); lCancelSupported = ESecUiCancelNotSupported; @@ -993,9 +1089,9 @@ RDEBUG("res", res); #ifdef __WINS__ - RDEBUG( "emulator can't read PIN attempts", res ); - res=KErrNone; - codeInfo.iRemainingEntryAttempts=3; + RDEBUG("emulator can't read PIN attempts", res); + res = KErrNone; + codeInfo.iRemainingEntryAttempts = 3; #endif User::LeaveIfError(res); @@ -1008,22 +1104,22 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; RDEBUG("SecQueryDialog", 1); // ESecUiCodeEtelReqest/ESecUiNone might be useful lAlphaSupported = ESecUiAlphaNotSupported; TBuf<0x100> title; title.Zero(); - title.Append(_L("Pin1RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(codeInfo.iRemainingEntryAttempts); - TInt amode = ESecUiSecretSupported | lAlphaSupported | lCancelSupported - | ESecUiEmergencySupported | secCodeType; + TInt amode = ESecUiSecretSupported | lAlphaSupported | lCancelSupported | ESecUiEmergencySupported | secCodeType; RDEBUG("amode", amode); - queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, - SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, amode); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1031,7 +1127,7 @@ if (queryAccepted == KErrAbort) // emergency call { - RDEBUG("queryAccepted", queryAccepted); + RDEBUG("queryAccepted", queryAccepted); CleanupStack::PopAndDestroy(wait); // this is needed return KErrCancel; } @@ -1046,10 +1142,9 @@ } RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, - required_fourth); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); @@ -1060,18 +1155,17 @@ { case KErrNone: // code approved - RDEBUG("code approved", res); - if(lCancelSupported == ESecUiCancelNotSupported) - { // OK note is not displayed in boot-up, to make things faster - CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, - CAknNoteDialog::EConfirmationTone); - } + RDEBUG("code approved", res) + ; + if (lCancelSupported == ESecUiCancelNotSupported) + { // OK note is not displayed in boot-up, to make things faster + CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); + } break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // code was entered erroneously - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); if (StartUp) { returnValue = Pin1RequiredL(); @@ -1082,19 +1176,20 @@ // code blocked; show error note and terminate. // what if not during Startup? Probably it's Ok since the SIM would had also failed at StartUp if (StartUp) - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); break; case KErrGsm0707SimWrong: // sim lock active // no error? This is strange break; default: + { CSecuritySettings::ShowErrorNoteL(res); if (StartUp) { returnValue = Pin1RequiredL(); } + } break; } return returnValue; @@ -1113,7 +1208,7 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ - RDEBUG("0", 0); + RDEBUG("0", 0); TInt queryAccepted = KErrCancel; RMobilePhone::TMobilePassword puk1_password; RMobilePhone::TMobilePassword aNewPinPassword; @@ -1127,7 +1222,7 @@ TBool StartUp(ETrue); StartUp = iStartup; - TInt res(KErrCancel); // for the first try + TInt res(KErrCancel); // for the first try wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo); TInt thisTry = 0; @@ -1136,27 +1231,25 @@ while (res != KErrNone && (thisTry++) <= KTriesToConnectServer) { if (thisTry > 0) - User::After( KTimeBeforeRetryingRequest); + User::After(KTimeBeforeRetryingRequest); RDEBUG("GetSecurityCodeInfo", 0); iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); } - RDEBUG("res", res); + RDEBUG("res", res); // If there's still an error we're doomed. Bail out. User::LeaveIfError(res); RDEBUG("StartUp", StartUp); RDEBUG("codeInfo.iRemainingEntryAttempts", codeInfo.iRemainingEntryAttempts); - TInt attempts(codeInfo.iRemainingEntryAttempts); - RDEBUG( "attempts", attempts ); + TInt attempts(codeInfo.iRemainingEntryAttempts); + RDEBUG("attempts", attempts); // show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog - if (!StartUp && (attempts - == KMaxNumberOfPUKAttempts)) - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + if (!StartUp && (attempts == KMaxNumberOfPUKAttempts)) + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); if (attempts == KMaxNumberOfPINAttempts) attempts = -1; @@ -1164,23 +1257,23 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; RDEBUG("SecQueryDialog", 1); // ESecUiCodeEtelReqest/ESecUiNone might be useful TBuf<0x100> title; title.Zero(); - title.Append(_L("Puk1RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_puk_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(attempts); TInt lSecUiCancelSupported = ESecUiCancelSupported | ESecUiEmergencyNotSupported; - 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) ??? - lSecUiCancelSupported = ESecUiCancelNotSupported | ESecUiEmergencySupported; - queryAccepted = iSecQueryUi->SecQueryDialog(title, puk1_password, - SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, - ESecUiSecretNotSupported | ESecUiAlphaNotSupported - | lSecUiCancelSupported | ESecUiPukRequired); + 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) ??? + lSecUiCancelSupported = ESecUiCancelNotSupported | ESecUiEmergencySupported; + queryAccepted = iSecQueryUi->SecQueryDialog(title, puk1_password, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported + | lSecUiCancelSupported | ESecUiPukRequired); RDEBUG("puk1_password", 0); - RDebug::Print(puk1_password); + RDEBUGSTR(puk1_password); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1199,21 +1292,19 @@ RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); - CleanupStack::PopAndDestroy(wait); - + CleanupStack::PopAndDestroy(wait); + TInt returnValue = res; switch (res) { case KErrNone: // code approved -> note . The process continue and new-pin is requested - CSecuritySettings::ShowResultNoteL(res, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // wrong PUK code -> note -> ask PUK code again - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); returnValue = Puk1RequiredL(); break; case KErrGsm0707SimWrong: @@ -1230,25 +1321,30 @@ break; } - // Now the PUK1 is validated. It's time for asking the new PIN1 - RDEBUG("new wait", 0); - wait = CWait::NewL(); - CleanupStack::PushL(wait); + // Now the PUK1 is validated. It's time for asking the new PIN1 + RDEBUG("new wait", 0); + wait = CWait::NewL(); + CleanupStack::PushL(wait); { // new-pin query CSecQueryUi * iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; RDEBUG("SecQueryDialog", 1); - - queryAccepted = iSecQueryUi->SecQueryDialog( - _L("PIN1-New|PIN1-Verif"), aNewPinPassword, - SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, - ESecUiAlphaNotSupported | ESecUiCancelSupported - | ESecUiPukRequired); + TBuf<0x100> title; + title.Zero(); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_pin_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("|")); + HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_verify_new_pin_code")); + title.Append(stringHolder2->Des()); + CleanupStack::PopAndDestroy(stringHolder2); + queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPinPassword, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported + | ESecUiPukRequired); RDEBUG("aNewPinPassword", 0); - RDebug::Print(aNewPinPassword); + RDEBUGSTR(aNewPinPassword); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1262,8 +1358,7 @@ // send code again, now with the user pin RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPinPassword, - puk1_password); + iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPinPassword, puk1_password); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); @@ -1274,14 +1369,12 @@ { case KErrNone: // code approved -> note - CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // wrong PUK code -> note -> ask PUK code again - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); returnValue = Puk1RequiredL(); break; case KErrGsm0707SimWrong: @@ -1297,7 +1390,7 @@ returnValue = Puk1RequiredL(); break; } - RDEBUG("returnValue", returnValue); + RDEBUG("returnValue", returnValue); return returnValue; } // @@ -1313,12 +1406,11 @@ * Series 60 ETel API *****************************************************/ - RDEBUG("0", 0); + RDEBUG("0", 0); TInt queryAccepted = KErrCancel; RMobilePhone::TMobilePassword iSecUi_password; RMobilePhone::TMobilePassword required_fourth; - RMobilePhone::TMobilePhoneSecurityCode secCodeType( - RMobilePhone::ESecurityCodePin2); + RMobilePhone::TMobilePhoneSecurityCode secCodeType(RMobilePhone::ESecurityCodePin2); RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); CWait* wait = CWait::NewL(); @@ -1341,21 +1433,21 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; RDEBUG("SecQueryDialog", 1); // ESecUiCodeEtelReqest/ESecUiNone might be useful against KLastRemainingInputAttempt TBuf<0x100> title; title.Zero(); - title.Append(_L("Pin2RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_pin2_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(codeInfo.iRemainingEntryAttempts); - queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, - SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, - ESecUiSecretNotSupported | ESecUiAlphaNotSupported - | ESecUiCancelSupported | secCodeType); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported + | ESecUiCancelSupported | secCodeType); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); RDEBUG("queryAccepted", queryAccepted); iQueryCanceled = ETrue; delete iSecQueryUi; @@ -1371,8 +1463,7 @@ } RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, - required_fourth); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); RDEBUG("WaitForRequestL", 0); TInt status = wait->WaitForRequestL(); RDEBUG("WaitForRequestL status", status); @@ -1385,14 +1476,12 @@ case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // code was entered erroneously - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); break; case KErrGsmSSPasswordAttemptsViolation: case KErrLocked: // blocked - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); break; default: CSecuritySettings::ShowErrorNoteL(status); @@ -1411,7 +1500,7 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ - RDEBUG("0", 0); + RDEBUG("0", 0); TInt queryAccepted = KErrCancel; RMobilePhone::TMobilePassword iSecUi_password; RMobilePhone::TMobilePassword aNewPassword; @@ -1419,8 +1508,7 @@ RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); - RMobilePhone::TMobilePhoneSecurityCode secCodeType = - RMobilePhone::ESecurityCodePuk2; + RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePuk2; CWait* wait = CWait::NewL(); CleanupStack::PushL(wait); @@ -1439,7 +1527,7 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; RDEBUG("SecQueryDialog", 1); // ESecUiCodeEtelReqest/ESecUiNone might be useful @@ -1450,15 +1538,15 @@ TBuf<0x100> title; title.Zero(); - title.Append(_L("Puk2RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("Puk2RequiredL")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(codeInfo.iRemainingEntryAttempts); - queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, - SEC_C_PUK2_CODE_MIN_LENGTH, SEC_C_PUK2_CODE_MAX_LENGTH, - ESecUiSecretNotSupported | ESecUiAlphaNotSupported - | ESecUiCancelSupported | secCodeType ); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PUK2_CODE_MIN_LENGTH, SEC_C_PUK2_CODE_MAX_LENGTH, ESecUiSecretNotSupported | ESecUiAlphaNotSupported + | ESecUiCancelSupported | secCodeType); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1485,21 +1573,18 @@ { case KErrNone: // code approved -> note - CSecuritySettings::ShowResultNoteL(res, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // wrong PUK2 code -> note -> ask PUK2 code again - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); Puk2RequiredL(); break; case KErrGsmSSPasswordAttemptsViolation: case KErrLocked: // Pin2 features blocked permanently! - CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone); break; default: CSecuritySettings::ShowErrorNoteL(res); @@ -1507,23 +1592,25 @@ break; } - // now the PUK2 is valid. Time to get the new PIN2 - wait = CWait::NewL(); + // now the PUK2 is valid. Time to get the new PIN2 + wait = CWait::NewL(); CleanupStack::PushL(wait); - { + { // new pin2 code query CSecQueryUi * iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; + TBuf<0x100> title; + title.Zero(); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("PIN2-New|PIN2-Verif")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); // ESecUiCodeEtelReqest/ESecUiNone might be useful - queryAccepted - = iSecQueryUi->SecQueryDialog(_L("PIN2-New|PIN2-Verif"), - aNewPassword, SEC_C_PIN2_CODE_MIN_LENGTH, - SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported - | ESecUiCancelSupported | secCodeType); + queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPassword, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported + | secCodeType); RDEBUG("aNewPassword", 0); - RDebug::Print(aNewPassword); + RDEBUGSTR(aNewPassword); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1539,8 +1626,7 @@ } // send code. The code was temporarilly changed before. Thus, this really done to set the new-new one RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, aNewPassword, - iSecUi_password); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, aNewPassword, iSecUi_password); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); @@ -1550,21 +1636,18 @@ { case KErrNone: // code approved -> note - CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // wrong PUK2 code -> note -> ask PUK2 code again - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); Puk2RequiredL(); break; case KErrGsmSSPasswordAttemptsViolation: case KErrLocked: // Pin2 features blocked permanently! - CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone); break; default: CSecuritySettings::ShowErrorNoteL(res); @@ -1585,11 +1668,10 @@ * Series 60 Customer / ETel * Series 60 ETel API *****************************************************/ - TBool wcdmaSupported( - FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma)); - TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin)); - RDEBUG("wcdmaSupported", wcdmaSupported); - RDEBUG("upinSupported", upinSupported); + TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)); + TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin)); + RDEBUG("wcdmaSupported", wcdmaSupported); + RDEBUG("upinSupported", upinSupported); if (wcdmaSupported || upinSupported) { TInt queryAccepted = KErrCancel; @@ -1597,10 +1679,8 @@ RMobilePhone::TMobilePassword iSecUi_password; RMobilePhone::TMobilePassword required_fourth; RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; - RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg - codeInfoPkg(codeInfo); - RMobilePhone::TMobilePhoneSecurityCode secCodeType = - RMobilePhone::ESecurityUniversalPin; + RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); + RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityUniversalPin; CWait* wait = CWait::NewL(); CleanupStack::PushL(wait); TBool StartUp = ETrue; @@ -1622,34 +1702,32 @@ if (!StartUp) { // read a flag to see whether the query is SecUi originated. - err = RProperty::Get(KPSUidSecurityUIs, - KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); + err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery); } /* request PIN using QT */ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; // ESecUiCodeEtelReqest/ESecUiNone might be useful // TODO also support Emergency - if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) - || (err != KErrNone)) + if (StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone)) lCancelSupported = ESecUiCancelNotSupported; else lCancelSupported = ESecUiCancelSupported; TBuf<0x100> title; title.Zero(); - title.Append(_L("UPin1RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_upin_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(codeInfo.iRemainingEntryAttempts); - queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, - SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, - ESecUiSecretSupported | ESecUiAlphaNotSupported - | lCancelSupported | ESecUiCodeEtelReqest); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PIN_CODE_MIN_LENGTH, SEC_C_PIN_CODE_MAX_LENGTH, ESecUiSecretSupported | ESecUiAlphaNotSupported + | lCancelSupported | ESecUiCodeEtelReqest); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1663,8 +1741,7 @@ return KErrCancel; } RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, secCodeType, - iSecUi_password, required_fourth); + iPhone.VerifySecurityCode(wait->iStatus, secCodeType, iSecUi_password, required_fourth); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); @@ -1675,15 +1752,14 @@ { case KErrNone: // code approved - RDEBUG("code approved ", 0); - CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, - CAknNoteDialog::EConfirmationTone); + RDEBUG("code approved ", 0) + ; + CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // code was entered erroneously - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); if (StartUp) { returnValue = UPinRequiredL(); @@ -1693,13 +1769,12 @@ case KErrLocked: // code blocked; show error note and terminate. if (StartUp) - CSecuritySettings::ShowResultNoteL(res, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(res, CAknNoteDialog::EErrorTone); break; case KErrGsm0707SimWrong: // sim lock active break; - default: // for example, KErrArgument + default: // for example, KErrArgument CSecuritySettings::ShowErrorNoteL(res); if (StartUp) { @@ -1721,9 +1796,8 @@ // qtdone TInt CSecurityHandler::UPukRequiredL() { - TBool wcdmaSupported( - FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma)); - TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin)); + TBool wcdmaSupported(FeatureManager::FeatureSupported(KFeatureIdProtocolWcdma)); + TBool upinSupported(FeatureManager::FeatureSupported(KFeatureIdUpin)); if (wcdmaSupported || upinSupported) { RDEBUG("0", 0); @@ -1731,8 +1805,7 @@ RMobilePhone::TMobilePassword iSecUi_password; RMobilePhone::TMobilePassword aNewPassword; RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo; - RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg - codeInfoPkg(codeInfo); + RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo); RMobilePhone::TMobilePhoneSecurityCode blockCodeType; blockCodeType = RMobilePhone::ESecurityUniversalPuk; @@ -1751,10 +1824,8 @@ RDEBUG("WaitForRequestL res", res); User::LeaveIfError(res); //show last "Code Error" note for UPIN verify result so it won't be left under the PUK1 dialog - if (!StartUp && (codeInfo.iRemainingEntryAttempts - == KMaxNumberOfPUKAttempts)) - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + if (!StartUp && (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts)) + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); // ask UPUK code /* request PIN using QT */ @@ -1762,21 +1833,21 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful // TODO also support Emergency TBuf<0x100> title; title.Zero(); - title.Append(_L("Pin1RequiredL")); - title.Append(_L("#")); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("UPuk1RequiredL")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("$")); title.AppendNum(codeInfo.iRemainingEntryAttempts); - queryAccepted = iSecQueryUi->SecQueryDialog(title, - iSecUi_password, SEC_C_PUK_CODE_MIN_LENGTH, - SEC_C_PUK_CODE_MAX_LENGTH, ESecUiAlphaNotSupported - | ESecUiCancelSupported | ESecUiPukRequired); + queryAccepted = iSecQueryUi->SecQueryDialog(title, iSecUi_password, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiAlphaNotSupported + | ESecUiCancelSupported | ESecUiPukRequired); RDEBUG("iSecUi_password", 0); - RDebug::Print(iSecUi_password); + RDEBUGSTR(iSecUi_password); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1793,17 +1864,22 @@ CSecQueryUi *iSecQueryUi; RDEBUG("CSecQueryUi", 0); iSecQueryUi = CSecQueryUi::NewL(); - iQueryCanceled = EFalse; + iQueryCanceled = EFalse; // TODO ESecUiCodeEtelReqest/ESecUiNone might be useful // TODO also support Emergency - - queryAccepted = iSecQueryUi->SecQueryDialog(_L( - "UPuk-New|UPuk-Verif"), aNewPassword, - SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, - ESecUiAlphaNotSupported | ESecUiCancelSupported - | ESecUiPukRequired); + TBuf<0x100> title; + title.Zero(); + HBufC* stringHolder = HbTextResolverSymbian::LoadLC(_L("txt_pin_code_dialog_new_upin_code")); + title.Append(stringHolder->Des()); + CleanupStack::PopAndDestroy(stringHolder); + title.Append(_L("|")); + HBufC* stringHolder2 = HbTextResolverSymbian::LoadLC(_L("Verify")); + title.Append(stringHolder2->Des()); + CleanupStack::PopAndDestroy(stringHolder2); + queryAccepted = iSecQueryUi->SecQueryDialog(title, aNewPassword, SEC_C_PUK_CODE_MIN_LENGTH, SEC_C_PUK_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported + | ESecUiPukRequired); RDEBUG("aNewPassword", 0); - RDebug::Print(aNewPassword); + RDEBUGSTR(aNewPassword); iQueryCanceled = ETrue; delete iSecQueryUi; RDEBUG("queryAccepted", queryAccepted); @@ -1816,8 +1892,7 @@ // send code RDEBUG("VerifySecurityCode", 0); - iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPassword, - iSecUi_password); + iPhone.VerifySecurityCode(wait->iStatus, blockCodeType, aNewPassword, iSecUi_password); RDEBUG("WaitForRequestL", 0); res = wait->WaitForRequestL(); RDEBUG("WaitForRequestL res", res); @@ -1828,14 +1903,12 @@ { case KErrNone: // code approved -> note - CSecuritySettings::ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone); break; case KErrGsm0707IncorrectPassword: case KErrAccessDenied: // wrong PUK code -> note -> ask UPUK code again - CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, - CAknNoteDialog::EErrorTone); + CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); returnValue = UPukRequiredL(); break; case KErrGsm0707SimWrong: @@ -1867,8 +1940,7 @@ void CSecurityHandler::SimLockEventL() { RDEBUG("0", 0); - CSecuritySettings::ShowResultNoteL(R_SIM_ON, - CAknNoteDialog::EConfirmationTone); + CSecuritySettings::ShowResultNoteL(R_SIM_ON, CAknNoteDialog::EConfirmationTone); } // --------------------------------------------------------- // CSecurityHandler::RemoveSplashScreenL()