terminalsecurity/SCP/SCPTimestampPlugin/src/SCPTimestampPlugin.cpp
branchRCL_3
changeset 11 06f47423ecee
parent 2 5594fba90824
child 13 86979fe66c4c
equal deleted inserted replaced
9:57a65a3a658c 11:06f47423ecee
    26 #include <bautils.h>
    26 #include <bautils.h>
    27 #include <hal.h>
    27 #include <hal.h>
    28 #include <AknGlobalNote.h>
    28 #include <AknGlobalNote.h>
    29 #include <AknGlobalConfirmationQuery.h>
    29 #include <AknGlobalConfirmationQuery.h>
    30 // For wipe
    30 // For wipe
    31 #include <starterclient.h>
    31 //#include <StarterClient.h>
    32 #include <sysutil.h>
    32 //#include <sysutil.h>
    33 #include <syslangutil.h>
    33 //#include <SysLangUtil.h>
    34 #include <rfsClient.h>
    34 //#include <rfsClient.h>
    35 #include "DMUtilClient.h"
    35 //#include "DMUtilClient.h"
    36 
    36 
    37 #include "SCPTimestampPlugin.h"
    37 #include "SCPTimestampPlugin.h"
    38 #include <featmgr.h>
    38 #include <featmgr.h>
    39 #ifdef RD_MULTIPLE_DRIVE
    39 //#ifdef RD_MULTIPLE_DRIVE
    40 #include <driveinfo.h>
    40 //#include <DriveInfo.h>
    41 #include <pathinfo.h>
    41 //#include <PathInfo.h>
    42 #include <f32file.h>
    42 //#include <f32file.h>
    43 #endif //RD_MULTIPLE_DRIVEs
    43 //#endif //RD_MULTIPLE_DRIVEs
    44 // CONSTANTS
    44 // CONSTANTS
    45 
    45 
    46 // ============================= LOCAL FUNCTIONS  =============================
    46 // ============================= LOCAL FUNCTIONS  =============================
    47 
    47 
    48 
    48 
    98 		{
    98 		{
    99     	FeatureManager::UnInitializeLib();
    99     	FeatureManager::UnInitializeLib();
   100    		User::Leave( KErrNotSupported );
   100    		User::Leave( KErrNotSupported );
   101   	}
   101   	}
   102    	FeatureManager::UnInitializeLib();  
   102    	FeatureManager::UnInitializeLib();  
       
   103 	iUserInfo = CSCPUserInf::NewL();
   103     Dprint ( ( _L( "CSCPTimestampPlugin::ConstructL()" ) ) );    
   104     Dprint ( ( _L( "CSCPTimestampPlugin::ConstructL()" ) ) );    
   104     
   105     
   105     return;
   106     return;
   106     }
   107     }
   107 
   108 
   123         {
   124         {
   124         delete iConfiguration;
   125         delete iConfiguration;
   125         iConfiguration = NULL;
   126         iConfiguration = NULL;
   126         }
   127         }
   127 
   128 
       
   129     if(iUserInfo)
       
   130         delete iUserInfo;
   128     Dprint( ( _L( "<-- CSCPTimestampPlugin::~CSCPTimestampPlugin()" ) ) );
   131     Dprint( ( _L( "<-- CSCPTimestampPlugin::~CSCPTimestampPlugin()" ) ) );
   129     return;
   132     return;
   130     }
   133     }
   131     
   134     
   132     
   135     
   483     {
   486     {
   484     if ( ReadConfiguration() != KErrNone )
   487     if ( ReadConfiguration() != KErrNone )
   485         {
   488         {
   486         return;
   489         return;
   487         }
   490         }
       
   491     Dprint( (_L("CSCPTimestampPlugin::AuthenticationAttempt()") )); 
   488         
   492         
   489     // Check if immediate expiration is set
   493     // Check if immediate expiration is set
   490     TInt expireNow = 0;
   494     TInt expireNow = 0;
   491     iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors  
   495     iConfiguration->Get( KSCPExpireOnNextCall, expireNow ); // ignore errors  
   492     
   496     
   502     else
   506     else
   503         {
   507         {
   504         // Failed authentication attempt
   508         // Failed authentication attempt
   505         if ( iMaxAttempts > 0 )
   509         if ( iMaxAttempts > 0 )
   506             {
   510             {
       
   511 		    Dprint( (_L("CSCPTimestampPlugin::iMaxAttempts > 0") )); 
   507             TInt failedCount = 0;
   512             TInt failedCount = 0;
   508             iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors
   513             iConfiguration->Get( KSCPFailedAttempts, failedCount ); // ignore errors
   509             failedCount++;                        
   514             failedCount++;                        
   510         
   515         
   511             if ( failedCount == iMaxAttempts - 1 )
   516             if ( failedCount == iMaxAttempts - 1 )
   512                 {
   517                 {
   513                 // Warn the user. Only one attempt left. There's no use handling the error
   518                 // Warn the user. Only one attempt left. There's no use handling the error
   514                 // so we'll just stay silent at this point on failure.
   519                 // so we'll just stay silent at this point on failure.
   515                 TRAP_IGNORE(                                        
   520 		        Dprint( (_L("CSCPTimestampPlugin::One Attempt Left") ));
   516                     HBufC16* resText = NULL;
   521 				HBufC16* resText = NULL;
   517                     resText = LoadResourceL( R_SET_SEC_CODE_WARNING_ATTEMPTS_LEFT );
   522                 resText = LoadResourceL( R_SET_SEC_CODE_WARNING_ATTEMPTS_LEFT );
   518                     FormatResourceString(*resText);
   523                 FormatResourceString(*resText);               
   519     		        CleanupStack::PushL( resText );
   524 				// Call the dialog from an ActiveObj framework so that we could give control back to secui
   520     		        
   525 		        Dprint( (_L("CSCPTimestampPlugin::start actv obj for dialog") ));
   521     			    TPtr16 bufDes = resText->Des();
   526                 iUserInfo->StartL(*resText);
   522     			    
       
   523     			    CAknGlobalConfirmationQuery* note = CAknGlobalConfirmationQuery::NewLC();
       
   524     			        			    
       
   525     			    TRequestStatus status;
       
   526     			    note->ShowConfirmationQueryL(status,
       
   527     			    							 bufDes,
       
   528     			    							 R_AVKON_SOFTKEYS_OK_EMPTY,
       
   529     			    							 R_QGN_NOTE_WARNING_ANIM );
       
   530     			    User::WaitForRequest( status );
       
   531                                   			    
       
   532     			    CleanupStack::PopAndDestroy( note );
       
   533     			     
       
   534                     CleanupStack::PopAndDestroy( resText );
       
   535                     );
       
   536                 }
   527                 }
   537             else if ( failedCount >= iMaxAttempts )
   528             else if ( failedCount >= iMaxAttempts )
   538                 {
   529                 {
   539                 // Try to wipe the device
   530                 // Try to wipe the device
   540                 TRAPD( err, WipeDeviceL( aRetParams ) );
   531                 TRAPD( err, WipeDeviceL( aRetParams ) );
   834 //     
   825 //     
   835 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject*& aRetParams )
   826 void CSCPTimestampPlugin::WipeDeviceL( CSCPParamObject*& aRetParams )
   836     {
   827     {
   837     (void)aRetParams;
   828     (void)aRetParams;
   838     
   829     
       
   830 	Dprint( (_L("CSCPTimestampPlugin::WipeDeviceL") ));
       
   831 	iUserInfo->DoRfsL();
       
   832     /*
   839     // First try to format other local drives than C:
   833     // First try to format other local drives than C:
   840     RRfsClient rfsClient;
   834     RRfsClient rfsClient;
   841     
   835     
   842     TInt ret = rfsClient.Connect();
   836     TInt ret = rfsClient.Connect();
   843     
   837     
   950             }
   944             }
   951                                            
   945                                            
   952     if ( ret != KErrNone )
   946     if ( ret != KErrNone )
   953         {
   947         {
   954         Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL(): Rfs FAILED: %d"), ret ) );
   948         Dprint( ( _L( "CSCPPatternPlugin::WipeDeviceL(): Rfs FAILED: %d"), ret ) );
   955         }                                                         
   949         }     */                                                    
       
   950 	Dprint( (_L("CSCPTimestampPlugin::~WipeDeviceL") ));
   956     }
   951     }
   957     
   952     
   958 // ----------------------------------------------------------------------------
   953 // ----------------------------------------------------------------------------
   959 // CSCPTimestampPlugin::ReadConfiguration()
   954 // CSCPTimestampPlugin::ReadConfiguration()
   960 // 
   955 //