--- a/terminalsecurity/SCP/SCPTimestampPlugin/src/SCPTimestampPlugin.cpp Fri Apr 16 15:52:47 2010 +0300
+++ b/terminalsecurity/SCP/SCPTimestampPlugin/src/SCPTimestampPlugin.cpp Mon May 03 13:19:46 2010 +0300
@@ -21,6 +21,7 @@
#include <e32std.h>
#include <ecom/implementationproxy.h>
#include <SCPParamObject.h>
+#include <SCPServerInterface.h>
#include <SCPTimestampPluginLang.rsg>
#include "SCP_IDs.h"
#include <bautils.h>
@@ -138,11 +139,9 @@
// Status : Approved
// ----------------------------------------------------------------------------
//
-CSCPParamObject* CSCPTimestampPlugin::HandleEvent( TInt aID, CSCPParamObject& aParam )
- {
+void CSCPTimestampPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam )
+ {
Dprint ( ( _L( "CSCPTimestampPlugin::HandleEvent()" ) ) );
-
- CSCPParamObject* retParams = NULL;
// Get our current functional configuration
if ( iEventHandler->GetParameters().Get(
@@ -165,18 +164,8 @@
{
iMaxAttempts = 0;
}
-
- if ( !iResOpen )
- {
- // Load the resource file containing the localized texts
- TInt ret = GetResource();
- if ( ret == KErrNone )
- {
- iResOpen = ETrue;
- }
- // We'll continue without the resource if required
- }
-
+ Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iExpiration :%d, iExpiration :%d, iMinTolerance :%d, iMaxAttempts :%d"), iExpiration,iMinInterval,iMinTolerance,iMaxAttempts ) );
+ Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): aID is :%d"), aID) );
switch ( aID )
{
case ( KSCPEventPasswordChangeQuery ):
@@ -184,7 +173,7 @@
if ( iMinInterval > 0 )
{
// Ignore errors, the plugin will stay silent on error
- TRAP_IGNORE( IsChangeAllowedL( aParam, retParams ) );
+ TRAP_IGNORE( IsChangeAllowedL( aParam, aOutParam ) );
}
break;
}
@@ -196,7 +185,7 @@
if ( aParam.Get( KSCPParamID, paramID ) == KErrNone )
{
- ConfigurationQuery( paramID, aParam, retParams );
+ ConfigurationQuery( paramID, aParam, aOutParam );
}
break;
@@ -204,7 +193,7 @@
case ( KSCPEventPasswordChanged ):
{
- PasswordChanged( aParam, retParams );
+ PasswordChanged( aParam, aOutParam );
break;
}
@@ -215,7 +204,7 @@
{
TBool isSuccess = ( authStatus == KErrNone );
// No return value required in any case
- AuthenticationAttempt( isSuccess, aParam, retParams );
+ AuthenticationAttempt( isSuccess, aParam, aOutParam );
}
break;
@@ -239,7 +228,6 @@
}
// The caller will own this pointer from now on
- return retParams;
}
// ----------------------------------------------------------------------------
@@ -265,7 +253,7 @@
// Status : Approved
// ----------------------------------------------------------------------------
//
-void CSCPTimestampPlugin::IsChangeAllowedL( CSCPParamObject& aParam, CSCPParamObject*& aRetParams )
+void CSCPTimestampPlugin::IsChangeAllowedL( CSCPParamObject& aParam, CSCPParamObject& aRetParams )
{
(void)aParam;
@@ -311,79 +299,10 @@
if ( ret == KErrSCPCodeChangeNotAllowed )
{
- // Code change is not allowed, send the info back to the user
- aRetParams = CSCPParamObject::NewL();
-
- aRetParams->Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed );
- aRetParams->Set( KSCPParamAction, KSCPActionShowUI );
- aRetParams->Set( KSCPParamUIMode, KSCPUINote );
- aRetParams->Set( KSCPParamNoteIcon, KSCPUINoteError );
-
- HBufC16* resText = NULL;
- HBufC16* formatBuf = NULL;
-
- Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinInterval : %d"), iMinInterval ) );
- Dprint( ( _L( "CSCPPatternPlugin::IsChangeAllowedL(): iMinTolerance : %d"), iMinTolerance ) );
- if ( iMinInterval > 1 )
- {
- if ( iMinTolerance >1 )
- {
- Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance >= 1") ));
- resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_DAY );
- }
- else
- {
- Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval > 1,iMinTolerance !>= 1") ));
- resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_HOURS );
- }
- }
- else
- if ( iMinTolerance > 1 )
- {
- Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance >= 1") ));
- resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_TIMES );
- }
- else
- {
- Dprint( (_L("CSCPTimestampPlugin::IsChangeAllowedL(): iMinInterval !> 1,iMinTolerance !>= 1") ));
- resText = LoadResourceL( R_SET_SEC_CODE_CHANGE_ONES );
- }
-
- CleanupStack::PushL( resText );
-
- formatBuf = HBufC::NewL( resText->Length() + KSCPMaxMinChangeValueLen );
-
- TPtr16 bufDes = formatBuf->Des();
-
- if ( iMinInterval > 1 )
- {
- if ( iMinTolerance > 1 )
- {
- bufDes.Format( resText->Des(), iMinTolerance , iMinInterval );
- }
- else
- {
- bufDes.Format( resText->Des(), iMinInterval );
- }
- }
- else
- if ( iMinTolerance > 1 )
- {
- bufDes.Format( resText->Des(), iMinTolerance );
- }
- else
- {
- bufDes.Format( resText->Des() );
- }
-
- aRetParams->Set( KSCPParamPromptText, bufDes );
-
- delete formatBuf;
-
- CleanupStack::PopAndDestroy( resText );
+ Dprint ( ( _L( "EDeviceLockMinChangeTolerance Failed" ) ) );
+ aRetParams.AddtoFailedPolices(EDeviceLockMinChangeTolerance);
+ aRetParams.Set( KSCPParamStatus, KErrSCPCodeChangeNotAllowed );
}
-
- // No need to write configuration changes
}
@@ -394,10 +313,10 @@
// Status : Approved
// ----------------------------------------------------------------------------
//
-void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject*& aRetParams )
+void CSCPTimestampPlugin::PasswordChanged( CSCPParamObject& aParam, CSCPParamObject& aRetParams )
{
(void)aParam;
- (void)aRetParams;
+
Dprint( (_L("CSCPTimestampPlugin::PasswordChanged()") ));
TInt err = ReadConfiguration();
if ( err == KErrNone )
@@ -477,10 +396,11 @@
// Status : Approved
// ----------------------------------------------------------------------------
//
-void CSCPTimestampPlugin::AuthenticationAttempt( TBool aIsSuccessful,
+void CSCPTimestampPlugin :: AuthenticationAttempt( TBool aIsSuccessful,
CSCPParamObject& aParam,
- CSCPParamObject*& aRetParams )
+ CSCPParamObject& aRetParams )
{
+ Dprint( (_L("CSCPTimestampPlugin::AuthenticationAttempt") ));
if ( ReadConfiguration() != KErrNone )
{
return;
@@ -489,7 +409,7 @@
// Check if immediate expiration is set
TInt expireNow = 0;
iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors
-
+ Dprint( ( _L( "CSCPPatternPlugin::AuthenticationAttempt(): expireNow = %d"), expireNow ) );
if ( ( iExpiration == 0 ) && ( iMaxAttempts == 0) && ( expireNow == 0 ) )
{
return; // We have no interest in this call
@@ -510,34 +430,14 @@
if ( failedCount == iMaxAttempts - 1 )
{
- // Warn the user. Only one attempt left. There's no use handling the error
- // so we'll just stay silent at this point on failure.
- TRAP_IGNORE(
- HBufC16* resText = NULL;
- resText = LoadResourceL( R_SET_SEC_CODE_WARNING_ATTEMPTS_LEFT );
- FormatResourceString(*resText);
- CleanupStack::PushL( resText );
-
- TPtr16 bufDes = resText->Des();
-
- CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC();
-
- TRequestStatus status;
- note->ShowConfirmationQueryL(status,
- bufDes,
- R_AVKON_SOFTKEYS_OK_EMPTY,
- R_QGN_NOTE_WARNING_ANIM );
- User::WaitForRequest( status );
-
- CleanupStack::PopAndDestroy( note );
-
- CleanupStack::PopAndDestroy( resText );
- );
+ Dprint ( ( _L( "EDeviceLockAllowedMaxAtempts Failed" ) ) );
+ aRetParams.AddtoFailedPolices(EDeviceLockAllowedMaxAtempts);
}
else if ( failedCount >= iMaxAttempts )
{
// Try to wipe the device
TRAPD( err, WipeDeviceL( aRetParams ) );
+
if ( err != KErrNone )
{
Dprint( ( _L( "CSCPPatternPlugin::\
@@ -561,8 +461,9 @@
// ----------------------------------------------------------------------------
//
void CSCPTimestampPlugin::SuccessfulAuthenticationL( CSCPParamObject& aParam,
- CSCPParamObject*& aRetParams )
+ CSCPParamObject& aRetParams )
{
+ Dprint( (_L("CSCPTimestampPlugin::IsAfter()..enter") ));
// Reset the failed attempts -counter
if ( iMaxAttempts > 0 )
{
@@ -576,7 +477,7 @@
// Check if immediate expiration is set
TInt expireNow = 0;
iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors
-
+ Dprint( ( _L( "CSCPPatternPlugin::SuccessfulAuthenticationL(): expireNow = %d, iExpiration =%d"), expireNow,iExpiration ) );
// Check if the code should be changed now
if ( ( context != KSCPContextChangePsw ) &&
( ( iExpiration > 0 ) || ( expireNow ) ) )
@@ -584,39 +485,14 @@
if ( ( IsAfter( KSCPLastChangeTime, iExpiration, KSCPTypeDays ) == KSCPIsAfter ) ||
( expireNow ) )
{
- // Force password change
-
- HBufC16* resText = NULL;
- TRAPD( err, resText = LoadResourceL( R_SET_SEC_CODE_AGING ) );
- FormatResourceString(*resText);
- if (err == KErrNone) // If this fails, go on anyway to signal the psw change
- {
- TPtr16 bufDes = resText->Des();
- TRequestStatus userResponse;
-
- CAknGlobalNote* note = CAknGlobalNote::NewLC();
- TRAP_IGNORE(
- note->SetSoftkeys(R_AVKON_SOFTKEYS_OK_EMPTY);
- note->ShowNoteL(userResponse, EAknGlobalWarningNote,
- bufDes);
- );
-
- // Wait for the User Response
- User::WaitForRequest(userResponse);
- CleanupStack::PopAndDestroy(note);
-
- delete resText;
- }
-
- // Refill the parameters to inform the client that the password
- // should be changed.
- aRetParams = CSCPParamObject::NewL();
- aRetParams->Set( KSCPParamAction, KSCPActionForceChange );
+ Dprint ( ( _L( "EDeviceLockPasscodeExpiration Failed" ) ) );
+ aRetParams.AddtoFailedPolices(EDeviceLockPasscodeExpiration);
+ aRetParams.Set( KSCPParamStatus, KErrSCPInvalidCode );
}
}
+ Dprint( (_L("CSCPTimestampPlugin::IsAfter()..exit") ));
}
-
-
+
// ----------------------------------------------------------------------------
// CSCPTimestampPlugin::IsAfter()
//
@@ -633,6 +509,7 @@
TBuf<KSCPMaxInt64Length> savedTimeBuf;
TInt64 savedTime;
+ Dprint( ( _L( "CSCPPatternPlugin::IsAfter: aConfID value is :%d"), aConfID ) );
ret = iConfiguration->Get( aConfID, savedTimeBuf );
if ( ret == KErrNone )
{
@@ -682,7 +559,7 @@
}
}
}
-
+ Dprint( ( _L( "CSCPPatternPlugin::IsAfter: Retutn value is :%d"), ret ) );
return ret;
}
@@ -695,7 +572,7 @@
//
void CSCPTimestampPlugin::ConfigurationQuery( TInt aParamID,
CSCPParamObject& aParam,
- CSCPParamObject*& aRetParams )
+ CSCPParamObject& aRetParams )
{
// First check if this is our ID
if ( ( aParamID == RTerminalControl3rdPartySession::EPasscodeExpiration ) ||
@@ -810,21 +687,16 @@
// Something wrong, and this is our parameter. Signal an error
ret = KErrArgument;
}
+
+ aRetParams.Set( KSCPParamStatus, ret );
- TRAPD( err, aRetParams = CSCPParamObject::NewL() );
- if ( err == KErrNone ) // If we can't create a paramObject, there's nothing we can do
+ if ( setPrivateStorage )
{
- aRetParams->Set( KSCPParamStatus, ret );
- if ( setPrivateStorage )
- {
- aRetParams->Set( KSCPParamStorage, KSCPStoragePrivate );
- }
- }
- }
+ aRetParams.Set( KSCPParamStorage, KSCPStoragePrivate );
+ }
+ }
}
-
-
// ----------------------------------------------------------------------------
// CSCPTimestampPlugin::WipeDeviceL()
//
@@ -832,10 +704,8 @@
// Status : Approved
// ----------------------------------------------------------------------------
//
-void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject*& aRetParams )
+void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject& aRetParams )
{
- (void)aRetParams;
-
// First try to format other local drives than C:
RRfsClient rfsClient;
@@ -890,23 +760,15 @@
{
if (driveList[i])
{
- driveNumber = TDriveNumber(i);
- if (phoneMemoryDrive != driveNumber)
- {
- TBuf<KSCPFormatScriptMaxLen> formatScript;
- TChar driveLetter;
- RFs::DriveToChar(i,driveLetter);
- formatScript.Format(KSCPFormatScript, (TUint)driveLetter );
- Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL(): Formatting %c:"), driveLetter ) );
-
- ret = rfsClient.RunScriptInDescriptor(formatScript);
-
- if ( ret != KErrNone )
- {
- Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL():\
- FAILED to format %c: %d"), driveLetter, ret ) );
- }
- }
+ driveNumber = TDriveNumber(i);
+ if (phoneMemoryDrive != driveNumber)
+ {
+ TBuf<KSCPFormatScriptMaxLen> formatScript;
+ TChar driveLetter;
+ RFs::DriveToChar(i,driveLetter);
+ formatScript.Format(KSCPFormatScript, (TUint)driveLetter );
+ ret = rfsClient.RunScriptInDescriptor(formatScript);
+ }
}
}
@@ -1031,107 +893,4 @@
return ret;
}
-
-
-// ----------------------------------------------------------------------------
-// CSCPTimestampPlugin::GetResource
-// GetResource
-//
-// Status : Approved
-// ----------------------------------------------------------------------------
-//
-
-TInt CSCPTimestampPlugin::GetResource()
- {
- Dprint( (_L("CSCPTimestampPlugin::GetResource()") ));
- // The resource has to be loaded manually since this is not an application.
-
- // Build the resource file name and localize it
- TFileName resourceFile;
- resourceFile.Append( KDriveZ );
- resourceFile.Append( KSCPTimestampPluginResFilename );
- BaflUtils::NearestLanguageFile( *iFsSession, resourceFile );
-
- TRAPD( err, iResFile.OpenL( *iFsSession, resourceFile ) );
-
- if ( err == KErrNone )
- {
- TRAP( err, iResFile.ConfirmSignatureL() );
- }
-
- return err;
- }
-
-
-// ----------------------------------------------------------------------------
-// CSCPTimestampPlugin::LoadResourceLC
-//
-//
-// Status : Approved
-// ----------------------------------------------------------------------------
-//
-HBufC16* CSCPTimestampPlugin::LoadResourceL( TInt aResId )
- {
- if ( !iResOpen )
- {
- User::Leave( KErrNotReady );
- }
-
- Dprint( (_L("CSCPTimestampPlugin::LoadResourceL()") ));
-
- // Load the actual resource
- HBufC8* readBuffer = iResFile.AllocReadLC( aResId );
-
- // As we are expecting HBufC16
- const TPtrC16 ptrReadBuffer( (TText16*) readBuffer->Ptr(),
- ( readBuffer->Length() + 1 ) >> 1 );
-
- HBufC16* textBuffer = HBufC16::NewL( ptrReadBuffer.Length() );
-
- *textBuffer = ptrReadBuffer;
-
- FormatResourceString(*textBuffer);
- CleanupStack::PopAndDestroy( readBuffer );
-
- return textBuffer;
- }
-
-// ----------------------------------------------------------------------------
-// CSCPTimestampPlugin::FormatResourceString
-// The buffer that is passed is formatted to have only %i as a format specifier instead of %N or %0N etc.
-//
-// Status : Approved
-// ----------------------------------------------------------------------------
-//
-void CSCPTimestampPlugin::FormatResourceString(HBufC16 &aResStr)
-{
- TInt pos = 0;
- TInt flag = 0;
- TPtr16 bufPtr = aResStr.Des();
- _LIT (mess1, "%N");
- _LIT (mess2, "%i");
- _LIT (mess3, "%0N");
- _LIT (mess4, "%1N");
-
- while ((pos = bufPtr.Find(mess1)) !=KErrNotFound)
- {
- bufPtr.Replace(pos,2,mess2);
- flag = 1;
- break;
- }
-
- if(flag == 0)
- {
- while ((pos = bufPtr.Find(mess3)) != KErrNotFound)
- {
- bufPtr.Replace(pos,3,mess2);
- }
-
- while ((pos = bufPtr.Find(mess4)) != KErrNotFound)
- {
- bufPtr.Replace(pos,3,mess2);
- }
- }
-}
-
// End of File