--- a/terminalsecurity/SCP/SCPClient/src/SCPClient.cpp Fri Apr 16 15:52:47 2010 +0300
+++ b/terminalsecurity/SCP/SCPClient/src/SCPClient.cpp Mon May 03 13:19:46 2010 +0300
@@ -27,7 +27,6 @@
#include <AknGlobalConfirmationQuery.h>
#include "SCPClient.h"
-#include "SCPQueryDialog.h"
#include "SCPParamObject.h"
#include <SCPNotifier.rsg>
@@ -38,8 +37,7 @@
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
#include <TerminalControl3rdPartyAPI.h>
#include <SCPServerInterface.h>
-#include <SecUi.rsg>
-#include <secui.hrh>
+#include <SecUi.hrh>
#include <StringLoader.h>
#include <bautils.h>
//#endif // DEVICE_LOCK_ENHANCEMENTS
@@ -171,70 +169,6 @@
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
-// ---------------------------------------------------------
-// RunDialog() Dialog execution wrapper
-// Initialize and run the query dialog
-// Returns: TInt: The return code from the dialog.
-// Can leave with a generic error code.
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-TInt RunDialogL( TDes& aReplyBuf,
- RSCPClient::TSCPButtonConfig aButtonsShown,
- TInt aMinLen,
- TInt aMaxLen,
- TUint aResId = 0,
- TDesC* aPrompt = NULL,
- TBool aECSSupport = EFalse
- )
- {
- Dprint(_L("[RSCPClient]-> RunDialogL() >>> "));
- FeatureManager::InitializeLibL();
- if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
- {
- FeatureManager::UnInitializeLib();
- return KErrNotSupported;
- }
- FeatureManager::UnInitializeLib();
- if ( ( aPrompt == NULL ) && ( aResId == 0 ) )
- {
- return KErrArgument;
- }
- Dprint((_L("--> SCPClient::RunDialogL() start the dialog")));
- CSCPQueryDialog* dialog = new (ELeave) CSCPQueryDialog(
- aReplyBuf,
- aButtonsShown,
- aMinLen,
- aMaxLen,
- aECSSupport
- );
-
- CleanupStack::PushL( dialog );
-
- if ( aResId != 0 )
- {
- // Load and set the prompt from a resource ID
- HBufC* prompt;
-
- prompt = StringLoader::LoadLC( aResId );
- dialog->SetPromptL( *prompt );
-
- CleanupStack::PopAndDestroy( prompt );
- }
- else
- {
- // Set the given prompt
- dialog->SetPromptL( *aPrompt );
- }
- Dprint((_L("-- SCPClient::RunDialogL() dialog->ExecuteLD")));
- TInt ret = dialog->ExecuteLD( R_SCP_CODE_QUERY );
-
- CleanupStack::Pop( dialog );
- Dprint( (_L("-- SCPClient::RunDialogL(): ret val %d"), ret));
- return ret;
- }
-
// ---------------------------------------------------------
// LoadResources() Resource loader
@@ -550,167 +484,6 @@
// *********** Device lock new features ************* -->>
-// ---------------------------------------------------------
-// RSCPClient::SecCodeQuery()
-// Request the security code from the user and authenticate
-// through the server.
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-EXPORT_C TInt RSCPClient::SecCodeQuery( RMobilePhone::TMobilePassword& aPassword,
- TSCPButtonConfig aButtonsShown,
- TBool aECSSupport,
- TInt aFlags )
- {
- TInt lErr = KErrNone;
- TInt lStatus = KErrNone;
- TInt lResFileSCP = NULL;
- TInt lResFileSecUi = NULL;
- Dprint( (_L("--> RSCPClient::SecCodeQuery(%d, %d"), aButtonsShown, aECSSupport ));
- TRAP(lErr, lStatus = SetSecurityCodeL(aPassword, aButtonsShown, aECSSupport, aFlags, lResFileSCP, lResFileSecUi));
-
-
- if(lResFileSCP) {
- CCoeEnv :: Static()->DeleteResourceFile(lResFileSCP);
- }
-
- if(lResFileSecUi) {
-
-
- CCoeEnv :: Static()->DeleteResourceFile(lResFileSecUi);
- }
-
- Dprint((_L("<-- RSCPClient::SecCodeQuery(): lStatus= %d, lErr= %d"), lStatus, lErr));
- return (lErr != KErrNone) ? lErr : lStatus;
-}
-
-// ---------------------------------------------------------
-// RSCPClient::ChangeCodeRequest()
-// Show the current code query dialog and continue in GetNew
-// CodeAndChange.
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-EXPORT_C TInt RSCPClient::ChangeCodeRequest()
- {
- Dprint((_L("[RSCPClient] ChangeCodeRequest() >>>")));
-
- if(EFalse == isFlagEnabled) {
- Dprint((_L("[RSCPClient]-> ChangeCodeRequest(): ERROR: Function not supported in this variant")));
- User :: Invariant();
- return KErrNotSupported;
- }
-
- TInt lRet(KErrNone);
- TInt lErr(KErrNone);
-
- TInt resourceFileSCP(NULL);
- TInt resourceFileSecUi(NULL);
-
- // Check if the code change is allowed
- {
- HBufC8* addParamsHBuf = NULL;
- TRAP(lErr, addParamsHBuf = HBufC8 :: NewL(KSCPMaxTARMNotifParamLen));
-
- if(lErr != KErrNone) {
- return lErr;
- }
-
- TPtr8 addParams = addParamsHBuf->Des();
- addParams.Zero();
-
- TInt status(KErrNone);
- TPckg<TInt> retPackage(status);
-
- TInt ret = SendReceive(ESCPServCodeChangeQuery, TIpcArgs(&retPackage, &addParams));
-
- if((ret == KErrNone) && (addParams.Length() > 0)) {
- // The server has sent additional parameters, ignore errors in processing
- TRAP_IGNORE(ProcessServerCommandsL(addParams));
- }
-
- delete addParamsHBuf;
-
- if((ret != KErrNone) || (status != KErrNone)) {
- // Password cannot be changed now
- return KErrAbort;
- }
- }
-
- // Load the required resource files into this process
- lRet = LoadResources(resourceFileSCP, resourceFileSecUi);
-
- if(lRet != KErrNone) {
- return lRet;
- }
-
- HBufC* codeHBuf = NULL;
-
- TRAP(lErr, codeHBuf = HBufC :: NewL(KSCPPasscodeMaxLength + 1));
-
- if(lErr != KErrNone) {
- // Remove the resource files
- CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP);
- CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi);
- return lErr;
- }
-
- TPtr codeBuffer = codeHBuf->Des();
- codeBuffer.Zero();
-
- TInt def_code = -1;
- CRepository* lRepository = NULL;
-
- TRAP(lErr, lRepository = CRepository :: NewL(KCRUidSCPLockCode));
-
- if(KErrNone == lErr) {
- lErr = lRepository->Get(KSCPLockCodeDefaultLockCode, def_code);
-
- if(def_code == 0) {
- TRAP(lErr, lRet = RunDialogL(codeBuffer, SCP_OK_CANCEL, KSCPPasscodeMinLength,
- KSCPPasscodeMaxLength, R_SECUI_TEXT_ENTER_SEC_CODE));
-
- if((lRet) && (lErr == KErrNone) && (lRet != ESecUiEmergencyCall)) {
- lErr = GetNewCodeAndChange(codeBuffer, KSCPNormalChange);
- }
-
- if(lErr != KErrNone) {
- Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED: %d"), lErr));
- }
-
- if(((!lRet) && (lErr == KErrNone)) || (lRet == ESecUiEmergencyCall)) {
- // Cancelled by user
- lErr = KErrAbort;
- }
- }
- else if(def_code != -1) {
- _LIT(KText, "12345");
- TBufC<10> NBuf (KText);
- TPtr codeBuf = NBuf.Des();
-
- lErr = GetNewCodeAndChange(codeBuf, KSCPNormalChange);
-
- if(lErr == KErrNone) {
- lRepository->Set(KSCPLockCodeDefaultLockCode, 0);
- }
- else {
- Dprint((_L("RSCPClient::ChangeCodeRequest(): Code change FAILED automatic: %d"), lErr));
- }
- }
-
- delete lRepository;
- }
-
- Dprint((_L("<-- RSCPClient::ChangeCodeRequest(): %d"), lErr ));
-
- // Remove the resource files
- CCoeEnv :: Static()->DeleteResourceFile(resourceFileSCP);
- CCoeEnv :: Static()->DeleteResourceFile(resourceFileSecUi);
- delete codeHBuf;
- return lErr;
-}
// ---------------------------------------------------------
// RSCPClient::CheckConfiguration()
@@ -791,6 +564,48 @@
return ret;
}
+EXPORT_C TInt RSCPClient::GetPolicies(RArray<TInt>& aDeviceLockPolicies) {
+ Dprint(_L("[RSCPClient]-> GetPolicies >>>"));
+ HBufC8* lBuff = NULL;
+ TInt lStatus = KErrNone;
+
+ TRAP(lStatus, lBuff = HBufC8 :: NewL((EDevicelockTotalPolicies - 1) * sizeof(TInt)));
+
+ if (lStatus == KErrNone) {
+
+ lStatus = SendReceive(ESCPServGetParam, TIpcArgs(-1, &lBuff->Des()));
+
+ if (lStatus == KErrNone) {
+ // Copy data from lBuff to aDeviceLockPolicies
+ TPtr8 bufPtr = lBuff->Des();
+
+ if (bufPtr.Length() > 0) {
+ RDesReadStream lBufReadStream(bufPtr);
+ Dprint(_L("[RSCPClient]-> Get from server complete, returning service request..."));
+
+ for (TInt i = 0; i < 17; i++) {
+ TInt32 lParamValue = 0;
+ TRAP(lStatus, lParamValue = lBufReadStream.ReadInt32L());
+
+ if (lStatus != KErrNone) {
+ break;
+ }
+
+ aDeviceLockPolicies.Append(lParamValue);
+ }
+
+ lBufReadStream.Close();
+ }
+ else {
+ lStatus = KErrGeneral;
+ }
+ }
+ }
+ delete lBuff;
+ Dprint(_L("[RSCPClient]-> GetPolicies <<<"));
+ return lStatus;
+}
+
/* ---------------------------------------------------------
* Alternative function that can be used to set the Auto Lock period
* Caller should have AllFiles access level
@@ -804,350 +619,101 @@
Dprint((_L("[RSCPClient]-> SetAutoLockPeriod(): %d <<<"), ret));
return ret;
}
+
+EXPORT_C TBool RSCPClient :: IsLockcodeChangeAllowedNow(RArray<TDevicelockPolicies>& aFailedPolicies) {
+ Dprint((_L("[RSCPClient]-> IsLockcodeChangeAllowedNow() >>>")));
+ TInt lStatus = KErrNone;
+ TInt lErr = KErrNone;
+
+ // extra one for failed policies count
+ //koys: if leave happens what errorcode we should return??
+ HBufC8* failedPoliciesBuff = NULL;
+ TRAP(lStatus, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32)));
+
+ if (lStatus == KErrNone) {
+ lStatus = SendReceive(ESCPServCodeChangeQuery, TIpcArgs(&failedPoliciesBuff->Des()));
+ //koya: if leave happens what errorcode we should return??
+ TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des();
+ TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies));
+ delete failedPoliciesBuff;
+ }
+
+ Dprint((_L("[RSCPClient]-> IsLockcodeChangeAllowedNow() <<<")));
+ return (lStatus != KErrNone) ? lStatus : ((lErr != KErrNone) ? lErr : KErrNone);
+}
+
+EXPORT_C TInt RSCPClient :: VerifyNewLockcodeAgainstPolicies(TDesC& aLockcode, RArray<TDevicelockPolicies>& aFailedPolicies) {
+ Dprint((_L("[RSCPClient]-> VerifyNewLockcodeAgainstPolicies() >>>")));
+ TInt lRet = KErrNone;
+ TInt lErr = KErrNone;
+ // extra one for failed policies count
+ HBufC8* failedPoliciesBuff = NULL;
+
+ TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1) * sizeof(TInt32)));
+
+ if(lRet == KErrNone) {
+ lRet = SendReceive(ESCPServValidateLockcode, TIpcArgs(&aLockcode, &failedPoliciesBuff->Des()));
+
+ TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des();
+ TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies));
+
+ delete failedPoliciesBuff;
+ }
+
+ Dprint((_L("[RSCPClient]-> VerifyNewLockcodeAgainstPolicies() <<<")));
+ return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone);
+}
+
+EXPORT_C TInt RSCPClient :: StoreLockcode (TDesC& aNewLockcode, TDesC& aOldLockcode, RArray<TDevicelockPolicies>& aFailedPolicies) {
+ Dprint((_L("[RSCPClient]-> StoreLockcode() >>>")));
+ TInt lErr = KErrNone;
+ TInt lRet = KErrNone;
+
+ if (!IsLockcodeChangeAllowedNow(aFailedPolicies)) {
+ return KErrAccessDenied;
+ }
+
+ HBufC8* failedPoliciesBuff = NULL;
+
+ TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32)));
+
+ if(lRet == KErrNone) {
+ lRet = SendReceive(ESCPServChangeEnhCode, TIpcArgs(&aOldLockcode, &aNewLockcode, &failedPoliciesBuff->Des()));
+
+ TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des();
+ TRAP(lErr, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies));
+
+ delete failedPoliciesBuff;
+ }
+
+ Dprint((_L("[RSCPClient]-> StoreLockcode() <<<")));
+ return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone);
+}
+
+EXPORT_C TInt RSCPClient :: VerifyCurrentLockcode (TDesC& aLockcode,RMobilePhone::TMobilePassword& aISACode,RArray< TDevicelockPolicies > &aFailedPolicies, TInt aFlags) {
+ Dprint((_L("[RSCPClient]-> VerifyCurrentLockcode() >>>")));
+ TInt lErr = KErrNone;
+ TInt lRet = KErrNone;
+
+ // extra one for failed policies count
+ HBufC8* failedPoliciesBuff = NULL;
+
+ TRAP(lRet, failedPoliciesBuff = HBufC8 :: NewL((EDevicelockTotalPolicies + 1)* sizeof(TInt32)));
+
+ if(lRet == KErrNone) {
+ lRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&aLockcode, &aISACode, &failedPoliciesBuff->Des(), aFlags));
+
+ TPtr8 failedPoliciesBufPtr = failedPoliciesBuff->Des();
+ TRAP(lRet, ReadFailedPoliciesL(failedPoliciesBufPtr, aFailedPolicies));
+
+ delete failedPoliciesBuff;
+ }
+
+ return (lRet != KErrNone) ? lRet : ((lErr != KErrNone) ? lErr : KErrNone);
+}
+
//#ifdef __SAP_DEVICE_LOCK_ENHANCEMENTS
-// ---------------------------------------------------------
-// RSCPClient::GetNewCodeAndChange()
-// Show the new code request and verification dialogs and
-// send the change request to the server.
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-TInt RSCPClient::GetNewCodeAndChange( TDes& aOldCode,
- TInt aMode,
- TSCPSecCode* aNewDOSCode /*=NULL*/,
- HBufC** aNewCodePptr/* = NULL*/)
- {
-
-
- if(!isFlagEnabled)
- {
- return KErrNotSupported;
- }
- TInt err = KErrNone;
- TInt ret = KErrNone;
-
-
- TInt maxLen = KSCPPasscodeMaxLength;
- TInt minLen = 1;
-
- // Fetch the minimum and maximum lengths for the code, if available.
- // This feature is commented out for correction to BU error ID: BNIN-6LC3AP.
- // Left in the code for possible inclusion in the future.
- //FetchLimits( minLen, maxLen );
-
- // Request the new code and verify it. Repeat this until the codes match.
-
- // Create the buffers on the heap
- HBufC* newCodeHBuf = NULL;
- HBufC* verifyCodeHBuf = NULL;
-
- TRAP( err, newCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) );
- if ( err == KErrNone )
- {
- TRAP( err, verifyCodeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 ) );
- }
-
- if ( err != KErrNone )
- {
- if ( newCodeHBuf != NULL )
- {
- delete newCodeHBuf;
- }
- return err;
- }
-
- TPtr newCodeBuffer = newCodeHBuf->Des();
- TPtr verifyCodeBuffer = verifyCodeHBuf->Des();
-
- // Configure the buttons according to the mode
- TSCPButtonConfig bConfig;
- TBool ecSupport;
- if ( aMode == KSCPForcedChange )
- {
- bConfig = SCP_OK_ETEL;
- ecSupport = ETrue;
- }
- else
- {
- bConfig = SCP_OK_CANCEL;
- ecSupport = EFalse;
- }
-
- TBool isMismatch = EFalse;
- do // Repeat loop BEGIN
- {
- isMismatch = EFalse;
-
- if ( err == KErrSCPInvalidCode )
- {
- err = KErrNone; // "reset"
- }
-
- newCodeBuffer.Zero();
-
- TRAP( err, ret = RunDialogL( newCodeBuffer,
- bConfig,
- minLen,
- maxLen,
- R_SECUI_TEXT_ENTER_NEW_SEC_CODE,
- NULL,
- ecSupport ) );
-
- if ( ( ret ) && ( ret != ESecUiEmergencyCall ) && ( err == KErrNone ) )
- {
- verifyCodeBuffer.Zero();
-
- TRAP( err, ret = RunDialogL( verifyCodeBuffer,
- bConfig,
- minLen,
- maxLen,
- R_SECUI_TEXT_VERIFY_NEW_SEC_CODE,
- NULL,
- ecSupport ) );
- }
-
- if ( ( !ret ) || ( err != KErrNone ) || ( ret == ESecUiEmergencyCall ) )
- {
- break;
- }
-
- if ( verifyCodeBuffer.Compare( newCodeBuffer ) != 0 )
- {
- // Ignore the errors from showing the note, it's better to continue if it fails
-
- TRAP_IGNORE(
- // Show an error note, the entered codes don't match
- CAknNoteDialog* noteDlg =
- new (ELeave) CAknNoteDialog(reinterpret_cast<CEikDialog**>( ¬eDlg ) );
- noteDlg->SetTimeout( CAknNoteDialog::ELongTimeout );
- noteDlg->SetTone( CAknNoteDialog::EErrorTone );
- noteDlg->ExecuteLD( R_CODES_DONT_MATCH );
- );
-
- isMismatch = ETrue; // Repeat code query
- }
-
- if ( !isMismatch )
- {
- HBufC8* addParamsHBuf = NULL;
-
- TRAP( err, addParamsHBuf = HBufC8::NewL( KSCPMaxTARMNotifParamLen ) );
- if ( err != KErrNone )
- {
- delete verifyCodeHBuf;
- delete newCodeHBuf;
- return err;
- }
-
- TPtr8 addParams = addParamsHBuf->Des();
- addParams.Zero();
-
- if ( !isMismatch )
- {
- // Try to change the code
- TSCPSecCode newDOSCode;
- newDOSCode.Zero();
-
- err = SendReceive( ESCPServChangeEnhCode,
- TIpcArgs( &aOldCode, &verifyCodeBuffer, &addParams, &newDOSCode )
- );
-
- if ( addParams.Length() > 0 )
- {
- // The server has sent additional parameters
- TRAPD( err, ProcessServerCommandsL( addParams ) );
- if ( err != KErrNone )
- {
- Dprint( (_L("RSCPClient::GetNewCodeAndChange():\
- Process cmds FAILED: %d"), err ));
- }
- }
-
- if ( aNewDOSCode != NULL )
- {
- (*aNewDOSCode).Copy( newDOSCode );
- }
- }
-
- delete addParamsHBuf;
- }
-
- } while ( ( isMismatch ) || ( err == KErrSCPInvalidCode ) ); // Loop END
-
- if ( ( ( !ret ) && ( err == KErrNone ) ) || ( ret == ESecUiEmergencyCall ) )
- {
- // Cancelled by user
- err = KErrAbort;
- }
-
- if((KErrNone == err) && (aNewCodePptr != 0)) {
- Dprint(_L("[RSCPClient]-> INFO: Updating new lock code to aNewCodePptr"));
- TRAP(err, *aNewCodePptr = HBufC :: NewL(verifyCodeHBuf->Des().Length()));
-
- if(*aNewCodePptr != NULL) {
- (*aNewCodePptr)->Des().Copy(verifyCodeHBuf->Des());
- Dprint(_L("[RSCPClient]-> INFO: Updated new lock code to aNewCodePptr"));
- }
- }
-
- delete verifyCodeHBuf;
- delete newCodeHBuf;
-
- return err;
- }
-
-
-
-// ---------------------------------------------------------
-// RSCPClient::ProcessServerCommandsL()
-// Handle the commands in the server's param-buffer
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-void RSCPClient::ProcessServerCommandsL( TDes8& aInParams,
- CSCPParamObject** aOutParams,
- TBool isNotifierEvent )
- {
-
- if(!isFlagEnabled)
- {
- User::Leave(KErrNotSupported);
- }
- Dprint( (_L("--> RSCPClient::ProcessServerCommandsL()") ));
- (void)aOutParams;
-
- CSCPParamObject* theParams = CSCPParamObject::NewL();
- CleanupStack::PushL( theParams );
-
- theParams->Parse( aInParams );
- TInt actionID;
- TInt ret = theParams->Get( KSCPParamAction, actionID );
-
- Dprint( (_L("RSCPClient::ProcessServerCommandsL():Params parsed") ));
-
- if ( ret != KErrNone )
- {
- Dprint( (_L("RSCPClient::ProcessServerCommands(): Can't get action ID: %d"), ret ));
- }
- else
- {
- switch ( actionID )
- {
- case ( KSCPActionShowUI ):
- {
- TRAP( ret, ShowUIL( *theParams ) );
- break;
- }
-
- case ( KSCPActionForceChange ):
- {
- if ( isNotifierEvent )
- {
- break; // Calling this through the notifier would jam the system
- // since the server is busy.
- }
-
- HBufC* codeHBuf = NULL;
- codeHBuf = HBufC::NewL( KSCPPasscodeMaxLength + 1 );
- CleanupStack::PushL( codeHBuf );
-
- TPtr codeBuf = codeHBuf->Des();
- codeBuf.Zero();
-
- ret = theParams->Get( KSCPParamPassword, codeBuf );
- if ( ret == KErrNone )
- {
- TSCPSecCode newDOSCode;
- ret = GetNewCodeAndChange( codeBuf, KSCPForcedChange, &newDOSCode );
-
- // If aOutParams is defined, return the new code
- if ( aOutParams != NULL )
- {
- (*aOutParams) = CSCPParamObject::NewL();
- (*aOutParams)->Set( KSCPParamPassword, newDOSCode );
- }
- }
-
- CleanupStack::PopAndDestroy( codeHBuf );
-
- break;
- }
- }
- }
-
- CleanupStack::PopAndDestroy( theParams );
-
- Dprint( (_L("<-- RSCPClient::ProcessServerCommandsL()") ));
- User::LeaveIfError( ret );
- }
-
-// ---------------------------------------------------------
-// RSCPClient::ShowUI()
-// Show the requested UI through AVKON
-//
-// Status : Approved
-// ---------------------------------------------------------
-//
-void RSCPClient::ShowUIL( CSCPParamObject& aContext )
- {
-
- if(!isFlagEnabled)
- {
- User::Leave(KErrNotSupported);
- }
- Dprint( (_L("--> RSCPClient::ShowUIL()") ));
- TInt mode;
- User::LeaveIfError( aContext.Get( KSCPParamUIMode, mode ) );
-
- switch ( mode )
- {
- case ( KSCPUINote ):
- {
- // Get prompt
- TBuf<KSCPMaxPromptTextLen> promptText;
- aContext.Get( KSCPParamPromptText, promptText );
-
- // Try to get note icon, default is to use "error"
- TInt noteType = KSCPUINoteError;
- Dprint( (_L("RSCPClient::ShowUIL(): Creating note object") ));
-
- CAknResourceNoteDialog* note = NULL;
-
- if ( aContext.Get( KSCPParamNoteIcon, noteType ) != KErrNone )
- {
- noteType = KSCPUINoteError;
- }
-
- switch ( noteType )
- {
- case ( KSCPUINoteWarning ):
- {
- note = new (ELeave) CAknWarningNote( ETrue );
- break;
- }
-
- case ( KSCPUINoteError ):
- default: // default to error
- {
- note = new (ELeave) CAknErrorNote( ETrue );
- break;
- }
- }
-
- if ( note != NULL )
- {
- Dprint( (_L("RSCPClient::ShowUIL(): Showing note") ));
- note->ExecuteLD( promptText );
- }
- }
- }
-
- Dprint( (_L("<-- RSCPClient::ShowUIL()") ));
- }
-
// ---------------------------------------------------------
// RSCPClient::FetchLimits()
@@ -1193,160 +759,30 @@
aMax = KSCPPasscodeMaxLength;
}
}
- }
-TInt RSCPClient :: SetSecurityCodeL(RMobilePhone :: TMobilePassword& aPassword,
- TSCPButtonConfig aButtonsShown, TBool aECSSupport, TInt aFlags, TInt& aResFileSCP, TInt& aResFileSecUi) {
- Dprint((_L("[RSCPClient]-> SetSecurityCodeL() >>>")));
- Dprint((_L("[RSCPClient]-> input params - aButtonsShown=%d, aECSSupport=%d"), aButtonsShown, aECSSupport));
-
- if(EFalse == isFlagEnabled) {
- (void)aPassword;
- Dprint((_L("[RSCPClient]-> ERROR: Function not supported in this variant")));
- User :: Invariant();
- return KErrNotSupported;
}
- TInt lRet = LoadResources(aResFileSCP, aResFileSecUi);
- if(lRet != KErrNone) {
- return lRet;
- }
- TInt lDefCode = 0;
- CRepository* lRepository = CRepository :: NewLC(KCRUidSCPLockCode);
- lRet = lRepository->Get(KSCPLockCodeDefaultLockCode, lDefCode);
- if(lRet != KErrNone) {
- Dprint(_L("[RSCPClient]-> ERROR: Unable to perform get on CenRep, lErr=%d"), lRet);
- CleanupStack :: PopAndDestroy(lRepository);
- return lRet;
- }
- HBufC* codeHBuf = HBufC :: NewLC(KSCPPasscodeMaxLength + 1);
- HBufC8* addParamsHBuf = HBufC8 :: NewLC(KSCPMaxTARMNotifParamLen);
- TPtr codeBuffer = codeHBuf->Des();
- TPtr8 addParams = addParamsHBuf->Des();
- if(lDefCode == 0) {
- Dprint(_L("[RSCPClient]-> INFO: Default lock code has been set already by the user..."));
- lRet = RunDialogL(codeBuffer, aButtonsShown, KSCPPasscodeMinLength, KSCPPasscodeMaxLength,
- R_SECUI_TEXT_ENTER_SEC_CODE, NULL, aECSSupport);
- if((lRet) && (lRet != ESecUiEmergencyCall) && (lRet != EAknSoftkeyEmergencyCall)) {
- Dprint(_L("[RSCPClient]-> INFO: User has updated the lock code..."));
- lRet = SendReceive( ESCPServAuthenticateS60, TIpcArgs( &codeBuffer, &aPassword, &addParams, aFlags));
- Dprint((_L("[RSCPClient]-> INFO: addParams.Length()=%d")), addParams.Length());
- Dprint((_L("[RSCPClient]-> INFO: lRet=%d")), lRet);
- }
- else {
- switch(lRet) {
- case 0:
- lRet = KErrCancel;
- break;
- case EAknSoftkeyEmergencyCall:
- //lRet = KErrCancel;
- break;
- case ESecUiEmergencyCall:
- lRet = ESecUiEmergencyCall;
- break;
- /*default:
- break;*/
- }
- }
- }
- else {
- TRequestStatus statusSave;
- Dprint(_L("[RSCPClient]-> INFO: Default lock code not set by the user, requesting for the same"));
- HBufC* msgConfirmSave = NULL;
- CAknGlobalConfirmationQuery* query = CAknGlobalConfirmationQuery :: NewLC();
-
- if(aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) {
- //msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
- msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE_SETTING_QUERY_SERVER);
- query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_OK_EMPTY__OK, R_QGN_NOTE_INFO_ANIM);
- }
- else {
- msgConfirmSave = CEikonEnv :: Static()->AllocReadResourceLC(R_SET_SEC_CODE);
- query->ShowConfirmationQueryL(statusSave, *msgConfirmSave, R_AVKON_SOFTKEYS_YES_NO__YES, R_QGN_NOTE_QUERY_ANIM);
- }
-
- User :: WaitForRequest(statusSave);
- CleanupStack :: PopAndDestroy(2); // msgConfirmSave query
-
- if((statusSave == EAknSoftkeyYes) || (statusSave == EAknSoftkeyOk)) {
- Dprint(_L("[RSCPClient]-> INFO: calling GetNewCodeAndChange() ..."));
-
- TBufC<10> NBuf(KSCPDefaultEnchSecCode);
- TPtr codeBuf = NBuf.Des();
-
- TSCPSecCode lNewSecCode;
- TInt lButtonCfg = (aButtonsShown == SCP_OK || aButtonsShown == SCP_OK_ETEL) ? KSCPForcedChange : KSCPNormalChange;
- HBufC* lNewLkCodeBuf = NULL;
- lRet = GetNewCodeAndChange(codeBuf, lButtonCfg, &lNewSecCode, &lNewLkCodeBuf);
-
- Dprint(_L("[RSCPClient]-> INFO: GetNewCodeAndChange() complete, err=%d"), lRet);
-
- if(KErrNone == lRet) {
- /* This is being called as a workaround for a freezing issue with SecUI. This is in place
- * as a temporary measure until the source is identified.
- */
- TInt lTmpRet = SendReceive(ESCPServAuthenticateS60, TIpcArgs(&lNewLkCodeBuf->Des(), &aPassword, &addParams, aFlags));
-
- Dprint(_L("[RSCPClient]-> INFO: lTmpRet from SendReceive()=%d"), lTmpRet);
- if(KErrNone == lRet) {
- Dprint(_L("[RSCPClient]-> INFO: updating CenRep ..."));
- lRepository->Set(KSCPLockCodeDefaultLockCode, 0);
- Dprint(_L("[RSCPClient]-> INFO: User updated lock code for the first time...err= %d"), lRet);
- }
- }
-
- if(lNewLkCodeBuf) {
- delete lNewLkCodeBuf;
- }
- }
- else {
- Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
- lRet = KErrCancel;
- }
-
- if(KErrAbort == lRet) {
- Dprint(_L("[RSCPClient]-> INFO: Returning KErrCancel"));
- lRet = KErrCancel;
- }
-
+void RSCPClient :: ReadFailedPoliciesL(TDes8& aFailedPolicyBuf, RArray< TDevicelockPolicies>& aFailedPolicies) {
+ Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL() >>>")));
+
+ if(aFailedPolicyBuf.Length() < 1) {
+ return;
}
- if(addParams.Length() > 0) {
- CSCPParamObject* tmp = CSCPParamObject :: NewLC();
- TInt lTempRet = tmp->Parse(addParams);
-
- if(lTempRet == KErrNone) {
- lTempRet = tmp->Set(KSCPParamPassword, codeBuffer);
- }
-
- if(lTempRet == KErrNone) {
- addParams.Zero();
- HBufC8* tmpBuf;
- lTempRet = tmp->GetBuffer(tmpBuf);
-
- if(lTempRet == KErrNone) {
- addParams.Copy(tmpBuf->Des());
- delete tmpBuf;
- }
- }
-
- if(lTempRet == KErrNone) {
- CSCPParamObject* outParams = NULL;
- ProcessServerCommandsL(addParams, &outParams);
-
- if(outParams != NULL) {
- TSCPSecCode newSecCode;
- if(outParams->Get(KSCPParamPassword, newSecCode) == KErrNone) {
- Dprint((_L("[RSCPClient]-> INFO: Updating encoded password received from the server into aPassword...")));
- aPassword.Copy(newSecCode);
- }
- delete outParams;
- }
- }
- CleanupStack :: PopAndDestroy(tmp);
+ RDesReadStream readStream(aFailedPolicyBuf);
+ CleanupClosePushL(readStream);
+
+ TInt failedPoliciesCount = readStream.ReadInt32L();
+ aFailedPolicies.Reset();
+ Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL failedPoliciesCount =%d"), failedPoliciesCount));
+ for(int i=0; i < failedPoliciesCount; i++) {
+ TInt32 temp = readStream.ReadInt32L();
+ //aFailedPolicies.Append((TDevicelockPolicies) readStream.ReadInt32L());
+ aFailedPolicies.AppendL((TDevicelockPolicies)temp);
+ Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL failed policy =%d"), temp));
}
- CleanupStack :: PopAndDestroy(3); // repository, addParamsHBuf, codeHBuf
- Dprint(_L("[RSCPClient]-> SetSecurityCodeL() <<< lRet=%d"), lRet);
- return lRet;
+
+ CleanupStack :: PopAndDestroy(&readStream);
+ Dprint((_L("[RSCPClient]-> ReadFailedPoliciesL() <<<")));
}
//#endif // __SAP_DEVICE_LOCK_ENHANCEMENTS
// <<-- *********** Device lock new features *************