securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp
changeset 0 164170e6151a
child 1 d5423fbb4f29
equal deleted inserted replaced
-1:000000000000 0:164170e6151a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  Provides api for handling security events.
       
    15 *
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #include <aknnotedialog.h>
       
    21 #include <etelmm.h>
       
    22 #include <SecUi.rsg>
       
    23 #include <exterror.h>
       
    24 #include <textresolver.h>
       
    25 
       
    26 #ifdef __COVER_DISPLAY
       
    27 #include <aknmediatorfacade.h>
       
    28 #include <secondarydisplay/SecondaryDisplayStartupAPI.h>
       
    29 #endif //__COVER_DISPLAY
       
    30 
       
    31 #include <centralrepository.h> 
       
    32 #include <starterclient.h>     //used for RemoveSplashScreen
       
    33 #include <e32property.h>
       
    34 #include <PSVariables.h>   // Property values
       
    35 #include <coreapplicationuisdomainpskeys.h>
       
    36 #include <startupdomainpskeys.h>
       
    37 #include <uikon/eiksrvui.h>
       
    38 #include <settingsinternalcrkeys.h>
       
    39 #include <securityuisprivatepskeys.h>
       
    40 #include <AknNotiferAppServerApplication.h>
       
    41 
       
    42 #include <SCPClient.h>
       
    43 #include <securitynotification.h>
       
    44 #include "secui.hrh"
       
    45 #include "secuisecurityhandler.h"
       
    46 #include "secuicodequerydialog.h"
       
    47 #include "secuisecuritysettings.h"
       
    48 #include "SecUiWait.h"
       
    49 #include "SecUiLockObserver.h"
       
    50 #ifdef RD_REMOTELOCK
       
    51 #include <RemoteLockSettings.h>
       
    52 #endif // RD_REMOTELOCK
       
    53 #include <StringLoader.h>
       
    54 #include <featmgr.h>
       
    55 //  LOCAL CONSTANTS AND MACROS
       
    56 const TInt KMaxNumberOfPUKAttempts(10);
       
    57 const TInt KMaxNumberOfPINAttempts(3);
       
    58 const TInt KLastRemainingInputAttempt(1);
       
    59 
       
    60 const TInt KTriesToConnectServer( 2 );
       
    61 const TInt KTimeBeforeRetryingRequest( 50000 );
       
    62 
       
    63 // ================= MEMBER FUNCTIONS =======================
       
    64 //
       
    65 // ----------------------------------------------------------
       
    66 // CSecurityHandler::CSecurityHandler()
       
    67 // C++ constructor
       
    68 // ----------------------------------------------------------
       
    69 //
       
    70 EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone):
       
    71         iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL) 
       
    72     {
       
    73         TInt result = iCustomPhone.Open(aPhone);
       
    74         TRAP_IGNORE( FeatureManager::InitializeLibL() ); //Shouldn't this panic if FM does not initialise??
       
    75     }
       
    76 
       
    77 //
       
    78 // ----------------------------------------------------------
       
    79 // CSecurityHandler::~CSecurityHandler()
       
    80 // Destructor
       
    81 // ----------------------------------------------------------
       
    82 //
       
    83 EXPORT_C CSecurityHandler::~CSecurityHandler()
       
    84     {
       
    85     #if defined(_DEBUG)
       
    86     RDebug::Print(_L("CSecurityHandler::~CSecurityHandler()"));
       
    87     #endif
       
    88     if ( iDestroyedPtr )
       
    89         {
       
    90         *iDestroyedPtr = ETrue;
       
    91         iDestroyedPtr = NULL;
       
    92         }
       
    93     CancelSecCodeQuery();
       
    94     iCustomPhone.Close();
       
    95     FeatureManager::UnInitializeLib();
       
    96     }
       
    97 //
       
    98 // ----------------------------------------------------------
       
    99 // CSecurityHandler::HandleEventL()
       
   100 // Handles different security events
       
   101 // ----------------------------------------------------------
       
   102 //
       
   103 EXPORT_C void CSecurityHandler::HandleEventL(
       
   104     RMobilePhone::TMobilePhoneSecurityEvent aEvent )
       
   105     {
       
   106     TInt result = KErrNone;
       
   107     HandleEventL( aEvent, result );
       
   108     }
       
   109 
       
   110 //
       
   111 // ----------------------------------------------------------
       
   112 // CSecurityHandler::HandleEventL()
       
   113 // Handles different security events
       
   114 // ----------------------------------------------------------
       
   115 //
       
   116 EXPORT_C void CSecurityHandler::HandleEventL(
       
   117     RMobilePhone::TMobilePhoneSecurityEvent aEvent,
       
   118     TBool aStartup, TInt& aResult )
       
   119     {
       
   120     iStartup = aStartup;
       
   121     HandleEventL( aEvent, aResult );
       
   122     }
       
   123     
       
   124 //
       
   125 // ----------------------------------------------------------
       
   126 // CSecurityHandler::HandleEventL()
       
   127 // Handles different security events
       
   128 // ----------------------------------------------------------
       
   129 //
       
   130 EXPORT_C void CSecurityHandler::HandleEventL(
       
   131     RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult )
       
   132     {
       
   133     /*****************************************************
       
   134     *    Series 60 Customer / ETel
       
   135     *    Series 60  ETel API
       
   136     *****************************************************/
       
   137     #if defined(_DEBUG)
       
   138     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL()"));
       
   139     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() EVENT: %d"), aEvent);
       
   140     #endif
       
   141     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
       
   142     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
   143  
       
   144     switch(aEvent)
       
   145             {
       
   146             case RMobilePhone::EPin1Required:
       
   147                 #if defined(_DEBUG)
       
   148                 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() Pin1Required"));
       
   149                 #endif
       
   150                 aResult = Pin1RequiredL();
       
   151                 break;
       
   152             case RMobilePhone::EPuk1Required:
       
   153                 #if defined(_DEBUG)
       
   154                 RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() PUK1Required"));
       
   155                 #endif
       
   156                 ((CAknNotifierAppServerAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(ETrue);
       
   157                 TRAPD(err,aResult = Puk1RequiredL());
       
   158                 ((CAknNotifierAppServerAppUi*)(CEikonEnv::Static())->EikAppUi())->SuppressAppSwitching(EFalse);
       
   159                 User::LeaveIfError(err);
       
   160                 break;
       
   161             case RMobilePhone::EPin2Required:
       
   162                 Pin2RequiredL();
       
   163                 break;
       
   164             case RMobilePhone::EPuk2Required:
       
   165                 Puk2RequiredL();        
       
   166                 break;
       
   167             case RMobilePhone::EUniversalPinRequired:
       
   168                 if(wcdmaSupported || upinSupported)
       
   169                    {
       
   170                        aResult = UPinRequiredL();
       
   171                    }
       
   172                 else
       
   173                     aResult = KErrNotSupported;
       
   174                 break;
       
   175             case RMobilePhone::EUniversalPukRequired:
       
   176                 if(wcdmaSupported || upinSupported)
       
   177                    {
       
   178                        aResult = UPukRequiredL();
       
   179                    }
       
   180                 else
       
   181                     aResult = KErrNotSupported;
       
   182                 break;
       
   183             case RMobilePhone::EPhonePasswordRequired:
       
   184                 aResult = PassPhraseRequiredL();
       
   185                 break;
       
   186             case RMobilePhone::EICCTerminated:
       
   187                 SimLockEventL();
       
   188                 break;
       
   189             default:
       
   190                 break;
       
   191             }
       
   192     #if defined(_DEBUG)
       
   193     RDebug::Print( _L( "CSecurityHandler::HandleEventL() returning %d." ), aResult );
       
   194     #endif
       
   195     }
       
   196 //
       
   197 // ----------------------------------------------------------
       
   198 // CSecurityHandler::AskSecCodeL()
       
   199 // For asking security code e.g in settings
       
   200 // ----------------------------------------------------------
       
   201 //
       
   202 EXPORT_C TBool CSecurityHandler::AskSecCodeL()
       
   203     {        
       
   204     /*****************************************************
       
   205     *    Series 60 Customer / ETel
       
   206     *    Series 60  ETel API
       
   207     *****************************************************/
       
   208     #if defined(_DEBUG)
       
   209     RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeL()"));
       
   210     #endif
       
   211     // Destructor sets thisDestroyed to ETrue
       
   212     TBool thisDestroyed( EFalse );
       
   213     iDestroyedPtr = &thisDestroyed;
       
   214     
       
   215     iQueryCanceled = EFalse;
       
   216     RMobilePhone::TMobilePassword password;
       
   217     RMobilePhone::TMobilePassword required_fourth;
       
   218         
       
   219     TInt ret = KErrNone;
       
   220     TInt err = KErrNone;
       
   221     TInt status = KErrNone;
       
   222     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   223     		FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   224     {
       
   225         // Connect to the SCP server, and request the code query
       
   226         RSCPClient scpClient;
       
   227         User::LeaveIfError( scpClient.Connect() );
       
   228         CleanupClosePushL( scpClient );      
       
   229         status = scpClient.SecCodeQuery( password, 
       
   230                                       RSCPClient::SCP_OK_CANCEL,
       
   231                                       EFalse,
       
   232                                       0 );         
       
   233                                               
       
   234         if ( status != KErrCancel )
       
   235             {
       
   236             // Set this "true" to indicate that the input wasn't cancelled
       
   237             ret = ETrue;
       
   238             }
       
   239         else
       
   240             {
       
   241             ret = EFalse;
       
   242             }
       
   243         
       
   244         CleanupStack::PopAndDestroy(); //scpClient                       
       
   245   }
       
   246   else
       
   247   {
       
   248     iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   249     #ifdef __COVER_DISPLAY
       
   250     iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   251     CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided
       
   252 	if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   253     	{
       
   254     	// … -  add data that cover ui is interested in
       
   255     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode);// adds int to additional data to be posted to cover ui
       
   256     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   257      	}  
       
   258     #endif //__COVER_DISPLAY
       
   259 	    CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   260 		CleanupStack::PushL(deviceLockStatusObserver);
       
   261 		err =KErrNone;
       
   262 	    TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY));
       
   263 		CleanupStack::PopAndDestroy(deviceLockStatusObserver);
       
   264   }
       
   265     
       
   266     // check if CSecurityHandler has been "killed"
       
   267     if ( thisDestroyed )
       
   268         {
       
   269         return EFalse;
       
   270         }
       
   271 
       
   272     iDestroyedPtr = NULL;
       
   273     iSecurityDlg = NULL;
       
   274 
       
   275     if (err != KErrNone)
       
   276         {
       
   277         User::Leave(err);
       
   278         }
       
   279 
       
   280     if (ret)
       
   281         {
       
   282         while (!iQueryCanceled)
       
   283             {
       
   284 	           if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   285 		           {           
       
   286 		                RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   287 		                secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
   288 		                CWait* wait = CWait::NewL();
       
   289 		                iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
       
   290 		                status = wait->WaitForRequestL();
       
   291 		                delete wait;
       
   292 		
       
   293 		           }
       
   294             
       
   295             switch(status)
       
   296                 {        
       
   297                 case KErrNone:
       
   298                     {
       
   299                     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   300     										!(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)))
       
   301     								{
       
   302                         RSCPClient scpClient;
       
   303                         User::LeaveIfError( scpClient.Connect() );
       
   304                         CleanupClosePushL( scpClient );
       
   305 
       
   306                         TSCPSecCode newCode;
       
   307                         newCode.Copy( password );
       
   308                         scpClient.StoreCode( newCode );
       
   309 
       
   310                         CleanupStack::PopAndDestroy(); //scpClient  
       
   311                   	}
       
   312                             	
       
   313                     iQueryCanceled = ETrue;
       
   314                     return ETrue;
       
   315                     }                    
       
   316                 case KErrGsmSSPasswordAttemptsViolation:
       
   317                 case KErrLocked:
       
   318                     {
       
   319                     iDestroyedPtr = &thisDestroyed;
       
   320                     // security code blocked! 
       
   321                     iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg));
       
   322                     iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   323                     iNoteDlg->SetTone(CAknNoteDialog::EErrorTone);
       
   324                     err =KErrNone;
       
   325                     TRAP(err,iNoteDlg->ExecuteLD(R_SEC_BLOCKED));
       
   326                     
       
   327                     // check if CSecurityHandler has been "killed"
       
   328                     if ( thisDestroyed )
       
   329                         {
       
   330                         return EFalse;
       
   331                         }
       
   332                     
       
   333                     iDestroyedPtr = NULL;
       
   334                     iNoteDlg = NULL;
       
   335 
       
   336                     if (err != KErrNone)
       
   337                         {
       
   338                         User::Leave(err);
       
   339                         }
       
   340                     break;
       
   341                     }
       
   342                 case KErrGsm0707IncorrectPassword:
       
   343                 case KErrAccessDenied:
       
   344                     {    
       
   345                     iDestroyedPtr = &thisDestroyed;
       
   346                     // code was entered erroneusly
       
   347                     iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg));
       
   348                     iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   349                     iNoteDlg->SetTone(CAknNoteDialog::EErrorTone);
       
   350                     err =KErrNone;
       
   351                     TRAP(err,iNoteDlg->ExecuteLD(R_CODE_ERROR));    
       
   352                     
       
   353                     // check if CSecurityHandler has been "killed"
       
   354                     if ( thisDestroyed )
       
   355                         {
       
   356                         return EFalse;
       
   357                         }
       
   358                     
       
   359                     iDestroyedPtr = NULL;
       
   360                     iNoteDlg = NULL;
       
   361                     
       
   362                     if (err != KErrNone)
       
   363                         {
       
   364                         User::Leave(err);
       
   365                         }
       
   366                     break;
       
   367                     }    
       
   368                 default:
       
   369                     {
       
   370                     iDestroyedPtr = &thisDestroyed;
       
   371                     err =KErrNone;
       
   372                     TRAP(err,ShowGenericErrorNoteL(status));
       
   373                                         
       
   374                     // check if CSecurityHandler has been "killed"
       
   375                     if ( thisDestroyed )
       
   376                         {
       
   377                         return EFalse;
       
   378                         }
       
   379                     
       
   380                     iDestroyedPtr = NULL;
       
   381                     iNoteDlg = NULL;
       
   382                     
       
   383                     if (err != KErrNone)
       
   384                         {
       
   385                         User::Leave(err);
       
   386                         }    
       
   387                     break;
       
   388                     }
       
   389                 }     
       
   390         
       
   391             if (iQueryCanceled)
       
   392                 {
       
   393                 ret = EFalse;
       
   394                 break;
       
   395                 }    
       
   396             
       
   397             password = _L("");
       
   398             iDestroyedPtr = &thisDestroyed;
       
   399              if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   400     						FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))  
       
   401     				{       
       
   402                 // Connect to the SCP server, and request the code query
       
   403                 RSCPClient scpClient;
       
   404                 User::LeaveIfError( scpClient.Connect() );
       
   405                 CleanupClosePushL( scpClient );
       
   406                 status = scpClient.SecCodeQuery( password, 
       
   407                                       RSCPClient::SCP_OK_CANCEL,
       
   408                                       EFalse,
       
   409                                       0 ); 
       
   410         
       
   411                 if ( status != KErrCancel )
       
   412                     {
       
   413                     // Set this "true" to indicate that the input wasn't cancelled
       
   414                     ret = ETrue;
       
   415                     }
       
   416                 else
       
   417                     {
       
   418                     ret = EFalse;
       
   419                     }                                
       
   420         
       
   421                 CleanupStack::PopAndDestroy(); //scpClient                              
       
   422           }
       
   423           else
       
   424           {
       
   425             iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   426             CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   427 						CleanupStack::PushL(deviceLockStatusObserver);
       
   428 						err =KErrNone;
       
   429             TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY));         
       
   430 						CleanupStack::PopAndDestroy(deviceLockStatusObserver);
       
   431           }
       
   432             
       
   433             // check if CSecurityHandler has been "killed"
       
   434             if ( thisDestroyed )
       
   435                 {
       
   436                 return EFalse;
       
   437                 }
       
   438     
       
   439             iDestroyedPtr = NULL;
       
   440             iSecurityDlg = NULL;
       
   441             
       
   442             if (err != KErrNone)
       
   443                 {
       
   444                 User::Leave(err);
       
   445                 }
       
   446 
       
   447             if (!ret)
       
   448                 break;
       
   449         } // while
       
   450     }    // if
       
   451 
       
   452     iQueryCanceled = ETrue;
       
   453     return ret;
       
   454     }
       
   455 //
       
   456 // ----------------------------------------------------------
       
   457 // CSecurityHandler::CancelSecCodeQuery()    
       
   458 // Cancels PIN2 and security code queries
       
   459 // ----------------------------------------------------------
       
   460 //
       
   461 EXPORT_C void CSecurityHandler::CancelSecCodeQuery()                
       
   462     {
       
   463     #if defined(_DEBUG)
       
   464     RDebug::Print(_L("(SECUI)CSecurityHandler::CancelSecCodeQuery()"));
       
   465     #endif
       
   466     if (!iQueryCanceled)
       
   467         {
       
   468         iQueryCanceled = ETrue;
       
   469         if (iSecurityDlg != NULL)
       
   470             {
       
   471             delete iSecurityDlg;
       
   472             }
       
   473         if (iNoteDlg != NULL)
       
   474             {
       
   475             delete iNoteDlg;
       
   476             }
       
   477         iNoteDlg = NULL;
       
   478         iSecurityDlg = NULL;
       
   479         }
       
   480     }
       
   481 //
       
   482 // ----------------------------------------------------------
       
   483 // CSecurityHandler::AskSecCodeInAutoLock()
       
   484 // for asking security code in autolock
       
   485 // ----------------------------------------------------------
       
   486 //
       
   487 EXPORT_C TBool CSecurityHandler::AskSecCodeInAutoLockL()
       
   488     {
       
   489     /*****************************************************
       
   490     *    Series 60 Customer / ETel
       
   491     *    Series 60  ETel API
       
   492     *****************************************************/
       
   493     
       
   494     #ifdef __WINS__
       
   495     return ETrue;
       
   496     #else
       
   497     #if defined(_DEBUG)
       
   498     RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL()"));
       
   499     #endif
       
   500     TInt res;
       
   501     CWait* wait;
       
   502         
       
   503     RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled);
       
   504     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
       
   505    
       
   506     #if defined(_DEBUG)
       
   507     RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() get autolock period"));
       
   508     #endif
       
   509 
       
   510     // get autolock period from Central Repository.
       
   511     CRepository* repository = CRepository::NewL(KCRUidSecuritySettings);
       
   512     TInt period = 0;
       
   513     res = repository->Get(KSettingsAutoLockTime, period);
       
   514     delete repository;
       
   515 
       
   516     #if defined(_DEBUG)
       
   517     RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() autolock period:%d"), res);
       
   518     #endif
       
   519     if (res == KErrNone)
       
   520         {
       
   521         // disable autolock in Domestic OS side too if autolock period is 0.
       
   522         if (period == 0 )
       
   523             {
       
   524             #if defined(_DEBUG)
       
   525             RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting"));
       
   526             #endif
       
   527 
       
   528 #ifdef RD_REMOTELOCK
       
   529 
       
   530             // If remote lock is enabled, don't disable the domestic OS device lock
       
   531             // since that would render the RemoteLock useless.
       
   532             // Instead just re-set the DOS lock to enabled which as a side effect
       
   533             // requests the security code from the user.
       
   534 
       
   535             TBool remoteLockStatus( EFalse );
       
   536             CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
   537 
       
   538             if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
   539                 {
       
   540                 if ( remoteLockStatus )
       
   541                     {
       
   542                     // Remote lock is enabled
       
   543                     #ifdef _DEBUG
       
   544                     RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) );
       
   545                     #endif // _DEBUG
       
   546 
       
   547                     lockChange = RMobilePhone::ELockSetEnabled;
       
   548                     }
       
   549                 else
       
   550                     {
       
   551                     // Remote lock is disabled
       
   552                     #ifdef _DEBUG
       
   553                     RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) );
       
   554                     #endif // _DEBUG
       
   555 
       
   556                     lockChange = RMobilePhone::ELockSetDisabled;
       
   557                     }
       
   558                 }
       
   559             else
       
   560                 {
       
   561                 // Failed to get remote lock status
       
   562                 #ifdef _DEBUG
       
   563                 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get RemoteLock status" ) );
       
   564                 #endif // _DEBUG
       
   565                 }
       
   566 
       
   567             delete remoteLockSettings;
       
   568             remoteLockSettings = NULL;
       
   569 
       
   570 #else // not defined RD_REMOTELOCK
       
   571 
       
   572                 lockChange = RMobilePhone::ELockSetDisabled;
       
   573 
       
   574 #endif // RD_REMOTELOCK
       
   575 
       
   576                 wait = CWait::NewL();
       
   577                 iPhone.SetLockSetting(wait->iStatus,lockType,lockChange);
       
   578                 res = wait->WaitForRequestL();
       
   579                 delete wait;
       
   580                 #if defined(_DEBUG)
       
   581                 RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() SetLockSetting RESULT:%d"), res);
       
   582                 #endif
       
   583             }
       
   584         else
       
   585             {	// ask security code
       
   586                 #if defined(_DEBUG)
       
   587             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Ask sec code via notifier"));
       
   588             	#endif
       
   589                 RNotifier codeQueryNotifier;
       
   590                 User::LeaveIfError(codeQueryNotifier.Connect());
       
   591                 CWait* wait = CWait::NewL();
       
   592                 CleanupStack::PushL(wait);
       
   593                 TInt queryResponse = 0;
       
   594                 TPckg<TInt> response(queryResponse);
       
   595                 TSecurityNotificationPckg params;
       
   596                 params().iEvent = static_cast<TInt>(RMobilePhone::EPhonePasswordRequired);
       
   597                 params().iStartup = EFalse;
       
   598                 #if defined(_DEBUG)
       
   599     			RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Start Notifier"));
       
   600     			#endif
       
   601                 codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid,params, response);
       
   602                 res = wait->WaitForRequestL();
       
   603                 CleanupStack::PopAndDestroy(); // wait
       
   604               	#if defined(_DEBUG)
       
   605             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() results:"));
       
   606             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() res:%d"), res);
       
   607             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() queryResponse:%d"), queryResponse);
       
   608             	#endif
       
   609             	if(res == KErrNone)
       
   610                 	res = queryResponse;
       
   611             }
       
   612         }
       
   613     else
       
   614         {
       
   615         #if defined(_DEBUG)
       
   616         RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KERRSOMETHING:Call SetLockSetting"));
       
   617         #endif
       
   618 
       
   619 #ifdef RD_REMOTELOCK
       
   620 
       
   621         // If remote lock is enabled, don't disable the domestic OS device lock
       
   622         // since that would render the RemoteLock useless.
       
   623         // Instead just re-set the DOS lock to enabled which as a side effect
       
   624         // requests the security code from the user.
       
   625 
       
   626         TBool remoteLockStatus( EFalse );
       
   627         CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
   628 
       
   629         if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
   630             {
       
   631             if ( remoteLockStatus )
       
   632                 {
       
   633                 // Remote lock is enabled
       
   634                 #ifdef _DEBUG
       
   635                 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) );
       
   636                 #endif // _DEBUG
       
   637 
       
   638                 lockChange = RMobilePhone::ELockSetEnabled;
       
   639                 }
       
   640             else
       
   641                 {
       
   642                 // Remote lock is disabled
       
   643                 #ifdef _DEBUG
       
   644                 RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) );
       
   645                 #endif // _DEBUG
       
   646 
       
   647                 lockChange = RMobilePhone::ELockSetDisabled;
       
   648                 }
       
   649             }
       
   650         else
       
   651             {
       
   652             // Failed to get remote lock status
       
   653             #ifdef _DEBUG
       
   654             RDebug::Print( _L( "(SecUi)CSecurityHandler::AskSecCodeInAutoLockL() - Failed to get AutoLock status and failed to get RemoteLock status" ) );
       
   655             #endif // _DEBUG
       
   656             }
       
   657 
       
   658         delete remoteLockSettings;
       
   659         remoteLockSettings = NULL;
       
   660 
       
   661 #else // not defined RD_REMOTELOCK
       
   662 
       
   663         // could not get the current autolock time... disable autolock in Domestic OS side.
       
   664         lockChange = RMobilePhone::ELockSetDisabled;
       
   665 
       
   666 #endif // RD_REMOTELOCK
       
   667 
       
   668         wait = CWait::NewL();
       
   669         iPhone.SetLockSetting(wait->iStatus,lockType,lockChange);
       
   670         res = wait->WaitForRequestL();
       
   671         delete wait;
       
   672         #if defined(_DEBUG)
       
   673         RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() KES: SetLockSetting RESULT:%d"), res);
       
   674         #endif
       
   675         }
       
   676         
       
   677     switch (res)
       
   678         {
       
   679         case KErrNone:
       
   680             {
       
   681                 return ETrue;
       
   682             }
       
   683 
       
   684         case KErrGsmSSPasswordAttemptsViolation:
       
   685         case KErrLocked:
       
   686         case KErrGsm0707IncorrectPassword:
       
   687         case KErrAccessDenied:
       
   688             {
       
   689 			return AskSecCodeInAutoLockL();
       
   690             }
       
   691         case KErrAbort:
       
   692         case KErrCancel:
       
   693             // user pressed "cancel"
       
   694             return EFalse;
       
   695         default:
       
   696             {
       
   697             return AskSecCodeInAutoLockL();
       
   698             }
       
   699         }
       
   700 #endif // WINS
       
   701     }
       
   702 //
       
   703 // ----------------------------------------------------------
       
   704 // CSecurityHandler::PassPhraseRequired()    
       
   705 // Handles PassPhraseRequired event
       
   706 // ----------------------------------------------------------
       
   707 //
       
   708 TInt CSecurityHandler::PassPhraseRequiredL()
       
   709     {
       
   710     /*****************************************************
       
   711     *    Series 60 Customer / ETel
       
   712     *    Series 60  ETel API
       
   713     *****************************************************/
       
   714     #if defined(_DEBUG)
       
   715     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()"));
       
   716     #endif
       
   717     TBool StartUp = iStartup;
       
   718 
       
   719     RMobilePhone::TMobilePassword password;
       
   720     RMobilePhone::TMobilePassword required_fourth;
       
   721     TInt status;
       
   722     TInt autolockState;
       
   723     TInt err( KErrGeneral );
       
   724     err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
       
   725     #if defined(_DEBUG)
       
   726     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Autolock Status result: %d"), err);
       
   727     #endif
       
   728     if(!StartUp)
       
   729         User::LeaveIfError( err );
       
   730 TBool isConditionSatisfied = EFalse;
       
   731 TInt tarmFlag=0;
       
   732 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   733   	{		
       
   734 	TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag );    
       
   735     
       
   736     if ( tRet != KErrNone )
       
   737         {
       
   738         #if defined(_DEBUG)
       
   739         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\
       
   740             Warning: failed to get TARM Admin Flag state"));
       
   741         #endif
       
   742         }
       
   743     else
       
   744         {
       
   745         #if defined(_DEBUG)
       
   746         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL(): TARM flag: %d"), tarmFlag );
       
   747         #endif
       
   748         }       
       
   749  
       
   750     if ( ( StartUp ) || ( tarmFlag & KSCPFlagResyncQuery ) )
       
   751 	    			isConditionSatisfied = ETrue;  
       
   752 		}
       
   753 		else
       
   754 		{
       
   755 		    if (StartUp)
       
   756 		    isConditionSatisfied = ETrue;  
       
   757 		}
       
   758 		if (isConditionSatisfied)
       
   759         {
       
   760         #if defined(_DEBUG)
       
   761         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1"));
       
   762         #endif
       
   763         // Security code at bootup: No "cancel" softkey; Emergency calls enabled.
       
   764       if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   765     			FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   766     		{                   	    		    		    		
       
   767             // Connect to the SCP server, and request the code query
       
   768             RSCPClient scpClient;
       
   769             User::LeaveIfError( scpClient.Connect() );
       
   770             CleanupClosePushL( scpClient );
       
   771                 
       
   772             status = scpClient.SecCodeQuery( password, 
       
   773                                              RSCPClient::SCP_OK_ETEL,
       
   774                                              ETrue,
       
   775                                              KSCPEtelRequest );              
       
   776             // Note that SecCodeQuery doesn't indicate the return value from the dialog            
       
   777         
       
   778             CleanupStack::PopAndDestroy();  //scpClient                                         
       
   779       }  
       
   780       else
       
   781       {     
       
   782         CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiCodeEtelReqest);
       
   783         if(AknLayoutUtils::PenEnabled())
       
   784             securityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
   785         else
       
   786             securityDlg->SetEmergencyCallSupport(ETrue);
       
   787         #ifdef __COVER_DISPLAY
       
   788         securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   789         CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided 
       
   790 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   791     		{
       
   792     		// … -  add data that cover ui is interested in
       
   793     		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
       
   794     		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   795      		}  
       
   796         #endif //__COVER_DISPLAY
       
   797         status = securityDlg->ExecuteLD(R_SECURITY_REQUEST_QUERY);
       
   798 			}
       
   799         }
       
   800     else if ( (autolockState > EAutolockOff))    
       
   801         {
       
   802         #if defined(_DEBUG)
       
   803         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 2"));
       
   804         #endif
       
   805             // Autolock is On. Security event came from user pressing "unlock".
       
   806             // Emergency call support must be enabled and there must be a "cancel" softkey.
       
   807          if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   808     				FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))     
       
   809 		    		{                                    
       
   810      	    // Connect to the SCP server, and request the code query
       
   811             RSCPClient scpClient;
       
   812             User::LeaveIfError( scpClient.Connect() );
       
   813             CleanupClosePushL( scpClient );
       
   814               
       
   815             status = scpClient.SecCodeQuery( password, 
       
   816                                              RSCPClient::SCP_OK_CANCEL,
       
   817                                              ETrue,
       
   818                                              KSCPEtelRequest );
       
   819             // Note that SecCodeQuery doesn't indicate the return value from the dialog   
       
   820         
       
   821             CleanupStack::PopAndDestroy(); //scpClient
       
   822 		    		}
       
   823 			    else
       
   824 			    {
       
   825         CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   826         if(AknLayoutUtils::PenEnabled())
       
   827             securityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
   828         else
       
   829             securityDlg->SetEmergencyCallSupport(ETrue);
       
   830         #ifdef __COVER_DISPLAY
       
   831         securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   832         CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided 
       
   833 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   834     	{
       
   835     	// … -  add data that cover ui is interested in
       
   836     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
       
   837     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   838      	}  
       
   839         #endif //__COVER_DISPLAY
       
   840         status = securityDlg->ExecuteLD(R_SECURITY_QUERY);
       
   841 			     }
       
   842         }
       
   843     else    
       
   844         {
       
   845         #if defined(_DEBUG)
       
   846         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 3"));
       
   847         #endif
       
   848             // Code query due to a setting change; "Cancel" softkey active;
       
   849             // no emergency call support.
       
   850 	        if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   851 	    			FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   852 	    		{
       
   853      	    // Connect to the SCP server, and request the code query
       
   854             RSCPClient scpClient;
       
   855             User::LeaveIfError( scpClient.Connect() );
       
   856             CleanupClosePushL( scpClient );
       
   857               
       
   858             status = scpClient.SecCodeQuery( password, 
       
   859                                              RSCPClient::SCP_OK_CANCEL,
       
   860                                              EFalse,
       
   861                                              KSCPEtelRequest );            
       
   862             // Note that SecCodeQuery doesn't indicate the return value from the dialog   
       
   863         
       
   864             CleanupStack::PopAndDestroy(); //scpClient
       
   865 			    }
       
   866 			    else
       
   867 			    {
       
   868         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   869         #ifdef __COVER_DISPLAY
       
   870         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   871         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
   872 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   873     	{
       
   874     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
       
   875     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   876      	}  
       
   877         #endif //__COVER_DISPLAY
       
   878         // read a flag to see whether the query is SecUi originated.
       
   879         TInt secUiOriginatedQuery(ESecurityUIsETelAPIOriginated);
       
   880         RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
       
   881         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   882         CleanupStack::PushL(deviceLockStatusObserver);
       
   883         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
   884         CleanupStack::PushL(queryStatusObserver);
       
   885         CSecUiLockObserver* callStatusObserver = NULL;
       
   886         if(secUiOriginatedQuery == ESecurityUIsSystemLockOriginated)
       
   887             {
       
   888                 callStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiCallStateObserver);
       
   889                 CleanupStack::PushL(callStatusObserver);
       
   890             }
       
   891         status = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY);
       
   892         
       
   893         if(callStatusObserver == NULL)
       
   894             CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
   895         else
       
   896             CleanupStack::PopAndDestroy(3); //deviceLockStatusObserver, queryStatusObserver, callStatusObserver
       
   897         iSecurityDlg = NULL;
       
   898 			      }
       
   899         }
       
   900 TBool isCondition = EFalse;		
       
   901 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   902 {
       
   903     if (!status || (status == ESecUiEmergencyCall)  
       
   904         || (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
       
   905     isCondition = ETrue;
       
   906 }
       
   907 else
       
   908 {
       
   909     if  ( ( status == KErrCancel ) || (status == ESecUiEmergencyCall)  ||
       
   910          (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
       
   911     isCondition = ETrue;
       
   912 }
       
   913 		if (isCondition)
       
   914         {
       
   915 		#if defined(_DEBUG)
       
   916 		RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DIALOG ERROR"));
       
   917 		#endif
       
   918         if (!StartUp)
       
   919             {
       
   920             #if defined(_DEBUG)
       
   921             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() ABORT CALLED!!!!!!"));
       
   922             #endif
       
   923             iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePhonePassword);
       
   924             }
       
   925         return KErrCancel;
       
   926         }
       
   927 
       
   928     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
   929      CWait* wait = NULL;
       
   930 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   931 { 
       
   932         #if defined(_DEBUG)
       
   933         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode"));
       
   934         #endif
       
   935         wait = CWait::NewL();
       
   936         iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
       
   937         status = wait->WaitForRequestL();
       
   938         #if defined(_DEBUG)
       
   939         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode STATUS: %d"), status);
       
   940         #endif
       
   941         delete wait;
       
   942   }
       
   943   else
       
   944   {
       
   945 		wait = NULL;
       
   946   }
       
   947     
       
   948     TInt returnValue = status;
       
   949     switch(status)
       
   950         {        
       
   951         case KErrNone:
       
   952             #if defined(_DEBUG)
       
   953             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrNone"));
       
   954             #endif
       
   955             // code approved 
       
   956             CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
       
   957         if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw))    
       
   958         {
       
   959                 // Unset the admin flag if set
       
   960                 if ( tarmFlag & KSCPFlagResyncQuery )
       
   961                     {
       
   962                     TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag );
       
   963                     
       
   964                     if ( tRet == KErrNone )
       
   965 	                    {
       
   966 	                    tarmFlag &= ~KSCPFlagResyncQuery;
       
   967 	                    tRet = RProperty::Set( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag );
       
   968 	                    }
       
   969 	            
       
   970 	                if ( tRet != KErrNone )
       
   971                         {
       
   972                         #if defined(_DEBUG)
       
   973                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\
       
   974                             FAILED to unset TARM Admin Flag"));
       
   975                         #endif
       
   976                         }                    
       
   977                     }                    	            
       
   978 				        if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) 
       
   979 				        {           
       
   980     			RSCPClient scpClient;
       
   981                 User::LeaveIfError( scpClient.Connect() );
       
   982                 CleanupClosePushL( scpClient );
       
   983                 TSCPSecCode newCode;
       
   984                 newCode.Copy( password );
       
   985                 scpClient.StoreCode( newCode );
       
   986                 CleanupStack::PopAndDestroy(); //scpClient
       
   987                 }
       
   988 
       
   989           }
       
   990         		
       
   991             if (StartUp)
       
   992                 {
       
   993                 #if defined(_DEBUG)
       
   994                 RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; get autolock period."));
       
   995                 #endif
       
   996 
       
   997                 // get autolock period from Central Repository.
       
   998                 CRepository* repository = CRepository::NewL(KCRUidSecuritySettings);
       
   999                 TInt period = 0;
       
  1000                 TInt res = repository->Get(KSettingsAutoLockTime, period);
       
  1001                 delete repository;
       
  1002   
       
  1003      						_LIT_SECURITY_POLICY_PASS(KReadPolicy); 
       
  1004 								_LIT_SECURITY_POLICY_C1(KWritePolicy, ECapabilityWriteDeviceData);
       
  1005     						RProperty::Define(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, RProperty::EInt, KReadPolicy, KWritePolicy);
       
  1006                 RProperty::Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOff);
       
  1007                 #if defined(_DEBUG)
       
  1008 								RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() EAutolockOff")); 
       
  1009 								#endif																
       
  1010 
       
  1011                 if (res == KErrNone)
       
  1012                     {
       
  1013                     // disable autolock in Domestic OS side too if autolock period is 0.
       
  1014                     if (period == 0 )
       
  1015                         {
       
  1016 #ifdef RD_REMOTELOCK
       
  1017                         // If remote lock is enabled, don't disable the domestic OS device lock
       
  1018                         // since that would render the RemoteLock useless.
       
  1019 
       
  1020                         TBool remoteLockStatus( EFalse );
       
  1021                         CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
  1022 
       
  1023                         if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
  1024                             {
       
  1025                             if ( !remoteLockStatus )
       
  1026                                 {
       
  1027                                 // Remote lock is disabled
       
  1028                                 #ifdef _DEBUG
       
  1029                                 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) );
       
  1030                                 #endif // _DEBUG
       
  1031 
       
  1032                                 // Disable DOS device lock setting
       
  1033                                 wait = CWait::NewL();
       
  1034                                 iCustomPhone.DisablePhoneLock(wait->iStatus,password);
       
  1035                                 wait->WaitForRequestL();
       
  1036                                 delete wait;
       
  1037                                 }
       
  1038                             }
       
  1039                         else
       
  1040                             {
       
  1041                             // Failed to get remote lock status
       
  1042                             #ifdef _DEBUG
       
  1043                             RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock is disabled, but failed to get RemoteLock status, so do nothing." ) );
       
  1044                             #endif // _DEBUG
       
  1045                             }
       
  1046 
       
  1047                         delete remoteLockSettings;
       
  1048                         remoteLockSettings = NULL;
       
  1049 
       
  1050 #else // not defined RD_REMOTELOCK
       
  1051 
       
  1052                         #if defined(_DEBUG)
       
  1053                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock."));
       
  1054                         #endif
       
  1055                         wait = CWait::NewL();
       
  1056                         iCustomPhone.DisablePhoneLock(wait->iStatus,password);
       
  1057                         wait->WaitForRequestL();
       
  1058                         #if defined(_DEBUG)
       
  1059                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock completed."));
       
  1060                         #endif
       
  1061                         delete wait;
       
  1062 #endif // RD_REMOTELOCK
       
  1063                         }
       
  1064                     }
       
  1065                 else
       
  1066                     {
       
  1067 #ifdef RD_REMOTELOCK
       
  1068                     // If remote lock is enabled, don't disable the domestic OS device lock
       
  1069                     // since that would render the RemoteLock useless.
       
  1070 
       
  1071                     TBool remoteLockStatus( EFalse );
       
  1072                     CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
  1073 
       
  1074                     if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
  1075                         {
       
  1076                         if ( !remoteLockStatus )
       
  1077                             {
       
  1078                             // Remote lock is disabled
       
  1079                             #ifdef _DEBUG
       
  1080                             RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock is disabled -> disable DOS device lock" ) );
       
  1081                             #endif // _DEBUG
       
  1082 
       
  1083                             wait = CWait::NewL();
       
  1084                             iCustomPhone.DisablePhoneLock(wait->iStatus,password);
       
  1085                             wait->WaitForRequestL();
       
  1086                             delete wait;
       
  1087                             }
       
  1088                         }
       
  1089                     else
       
  1090                         {
       
  1091                         // Failed to get remote lock status
       
  1092                         #ifdef _DEBUG
       
  1093                         RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock status, so do nothing." ) );
       
  1094                         #endif // _DEBUG
       
  1095                         }
       
  1096 
       
  1097                     delete remoteLockSettings;
       
  1098                     remoteLockSettings = NULL;
       
  1099 
       
  1100 #else // not defined RD_REMOTELOCK
       
  1101 
       
  1102                     #if defined(_DEBUG)
       
  1103                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; Could not get autolock period."));
       
  1104                     #endif
       
  1105                     // could not get the current autolock time... disable autolock in Domestic OS side. 
       
  1106                     wait = CWait::NewL();
       
  1107                     iCustomPhone.DisablePhoneLock(wait->iStatus,password);
       
  1108                     wait->WaitForRequestL();
       
  1109                     #if defined(_DEBUG)
       
  1110                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; NO AUTOLOCK PERIOD; DisablePhoneLock completed."));
       
  1111                     #endif
       
  1112                     delete wait;
       
  1113 
       
  1114 #endif // RD_REMOTELOCK
       
  1115                     }
       
  1116                 
       
  1117                 }
       
  1118 
       
  1119             break;    
       
  1120         case KErrGsmSSPasswordAttemptsViolation:
       
  1121         case KErrLocked:
       
  1122             // security code blocked!
       
  1123             #if defined(_DEBUG)
       
  1124             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() ErrGsmSSPasswordAttemptsViolation"));
       
  1125             #endif
       
  1126             CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
       
  1127             break;
       
  1128         case KErrGsm0707IncorrectPassword:
       
  1129         case KErrAccessDenied:
       
  1130             #if defined(_DEBUG)
       
  1131             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword"));
       
  1132             #endif
       
  1133             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1134             break;
       
  1135         default:
       
  1136             #if defined(_DEBUG)
       
  1137             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DEFAULT"));
       
  1138             #endif
       
  1139             CSecuritySettings::ShowErrorNoteL(status);
       
  1140             break;
       
  1141         }
       
  1142         
       
  1143     return returnValue;
       
  1144     }
       
  1145 //
       
  1146 // ----------------------------------------------------------
       
  1147 // CSecurityHandler::Pin1Required()    
       
  1148 // Handles Pin1Required event
       
  1149 // ----------------------------------------------------------
       
  1150 //
       
  1151 TInt CSecurityHandler::Pin1RequiredL()
       
  1152     {
       
  1153     /*****************************************************
       
  1154     *    Series 60 Customer / ETel
       
  1155     *    Series 60  ETel API
       
  1156     *****************************************************/
       
  1157     
       
  1158     RMobilePhone::TMobilePassword password;
       
  1159     RMobilePhone::TMobilePassword required_fourth;
       
  1160     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1;
       
  1161     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1162     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1163     TBool StartUp = ETrue;   
       
  1164     TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
       
  1165     TInt err = KErrNone;
       
  1166     TInt res = KErrGeneral;
       
  1167     CWait* wait = CWait::NewL();
       
  1168     CleanupStack::PushL(wait);
       
  1169     
       
  1170 
       
  1171     StartUp = iStartup;
       
  1172 
       
  1173     #if defined(_DEBUG)
       
  1174     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL()"));
       
  1175     #endif
       
  1176 
       
  1177     if(!StartUp)
       
  1178     {
       
  1179         // read a flag to see whether the query is SecUi originated.
       
  1180         err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
       
  1181         
       
  1182     if ( err != KErrNone )
       
  1183         {
       
  1184         #if defined(_DEBUG)
       
  1185         RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\
       
  1186             FAILED to get the SECUI query Flag: %d"), err);
       
  1187         #endif
       
  1188         }
       
  1189     else
       
  1190             {
       
  1191                #if defined(_DEBUG)
       
  1192                 RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL():\
       
  1193                     SECUI query Flag: %d"), secUiOriginatedQuery);
       
  1194                 #endif 
       
  1195             }
       
  1196     }  
       
  1197     #if defined(_DEBUG)
       
  1198     RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg"));
       
  1199     #endif
       
  1200 
       
  1201     if(StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
       
  1202     {	
       
  1203         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiCodeEtelReqest);
       
  1204         if(AknLayoutUtils::PenEnabled())
       
  1205             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1206         else
       
  1207             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1208         #ifdef __COVER_DISPLAY
       
  1209         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1210         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  1211 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1212     	{
       
  1213     	// … -  add data that cover ui is interested in
       
  1214     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui
       
  1215     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1216      	}  
       
  1217         #endif //__COVER_DISPLAY
       
  1218 
       
  1219         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1220         iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1221         res = wait->WaitForRequestL();
       
  1222         #if defined(_DEBUG)
       
  1223         TInt attempts(codeInfo.iRemainingEntryAttempts);
       
  1224         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts query status: %d"), res);
       
  1225         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts: %d"), attempts);
       
  1226         #endif
       
  1227         User::LeaveIfError(res);
       
  1228         
       
  1229         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1230             res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY);
       
  1231         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1232             {
       
  1233                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  1234                 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt);
       
  1235                 CleanupStack::PopAndDestroy(queryPrompt);
       
  1236             }
       
  1237         else
       
  1238             {
       
  1239                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT);
       
  1240                 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt);
       
  1241                 CleanupStack::PopAndDestroy(queryPrompt);   
       
  1242             }
       
  1243         
       
  1244         iSecurityDlg = NULL;
       
  1245         #if defined(_DEBUG)
       
  1246     	RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg RESULT: %d"), res);
       
  1247     	#endif
       
  1248         if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1249             { 
       
  1250             #if defined(_DEBUG)
       
  1251             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!"));
       
  1252             #endif
       
  1253             CleanupStack::PopAndDestroy(wait);   
       
  1254             return KErrCancel;
       
  1255             }
       
  1256     }
       
  1257     else
       
  1258     {	
       
  1259         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
  1260         #ifdef __COVER_DISPLAY
       
  1261         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1262         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided
       
  1263 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1264     		{
       
  1265     		// … -  add data that cover ui is interested in
       
  1266     		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui
       
  1267     		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1268      		}  
       
  1269         #endif //__COVER_DISPLAY
       
  1270         
       
  1271         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1272         iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1273         res = wait->WaitForRequestL();
       
  1274         User::LeaveIfError(res);
       
  1275         
       
  1276         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
  1277         CleanupStack::PushL(deviceLockStatusObserver);
       
  1278         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
  1279         CleanupStack::PushL(queryStatusObserver);
       
  1280         
       
  1281         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1282             res = iSecurityDlg->ExecuteLD(R_PIN_QUERY);
       
  1283         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1284             {
       
  1285                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts );
       
  1286                 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
  1287                 CleanupStack::PopAndDestroy(queryPrompt);
       
  1288             }
       
  1289         else
       
  1290             {
       
  1291                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT);
       
  1292                 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
  1293                 CleanupStack::PopAndDestroy(queryPrompt);   
       
  1294             }
       
  1295         
       
  1296         CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
  1297         iSecurityDlg = NULL;
       
  1298         if( !res || (res == ESecUiDeviceLocked))
       
  1299             {
       
  1300             #if defined(_DEBUG)
       
  1301             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_QUERY cancel!"));
       
  1302             #endif 
       
  1303             // cancel code request
       
  1304             iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1);
       
  1305             CleanupStack::PopAndDestroy(wait);
       
  1306             return KErrCancel;
       
  1307             }      
       
  1308     }
       
  1309     #if defined(_DEBUG)
       
  1310     RDebug::Print(_L("CSecurityNotifier::Pin1RequiredL()VerifySecurityCode"));
       
  1311     #endif
       
  1312     iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
       
  1313     res = wait->WaitForRequestL();
       
  1314     CleanupStack::PopAndDestroy(wait); 
       
  1315     #if defined(_DEBUG)
       
  1316     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL() VerifySecurityCode STATUS: %d"), res);
       
  1317     #endif
       
  1318     TInt returnValue = res;
       
  1319     switch(res)
       
  1320         {        
       
  1321         case KErrNone:
       
  1322             // code approved 
       
  1323             #if defined(_DEBUG)
       
  1324             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL()code approved "));
       
  1325             #endif
       
  1326             CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
       
  1327             break;
       
  1328         case KErrGsm0707IncorrectPassword:
       
  1329         case KErrAccessDenied:
       
  1330             // code was entered erroneously
       
  1331             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1332             if(StartUp)
       
  1333             {
       
  1334             returnValue = Pin1RequiredL();
       
  1335             }
       
  1336             break;
       
  1337         case KErrGsmSSPasswordAttemptsViolation:
       
  1338         case KErrLocked:
       
  1339             // code blocked; show error note and terminate.
       
  1340             // code blocked
       
  1341             if(StartUp)
       
  1342                 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); 
       
  1343             break;
       
  1344         case KErrGsm0707SimWrong:
       
  1345             // sim lock active
       
  1346             break;
       
  1347         default:
       
  1348             CSecuritySettings::ShowErrorNoteL(res);        
       
  1349             if(StartUp)
       
  1350             {        
       
  1351             returnValue = Pin1RequiredL();
       
  1352             }
       
  1353             break;
       
  1354         }
       
  1355     return returnValue;
       
  1356     }
       
  1357 //
       
  1358 // ----------------------------------------------------------
       
  1359 // CSecurityHandler::Puk1Required()
       
  1360 // Handles Puk1Required event
       
  1361 // ----------------------------------------------------------
       
  1362 //
       
  1363 TInt CSecurityHandler::Puk1RequiredL()
       
  1364     {
       
  1365     /*****************************************************
       
  1366     *    Series 60 Customer / ETel
       
  1367     *    Series 60  ETel API
       
  1368     *****************************************************/
       
  1369     #if defined(_DEBUG)
       
  1370     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL()"));
       
  1371     #endif            
       
  1372     RMobilePhone::TMobilePassword aPassword;
       
  1373     RMobilePhone::TMobilePassword aNewPassword;
       
  1374     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1375     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1376     RMobilePhone::TMobilePhoneSecurityCode blockCodeType;
       
  1377     blockCodeType = RMobilePhone::ESecurityCodePuk1;
       
  1378     CWait* wait = CWait::NewL();
       
  1379     CleanupStack::PushL(wait);
       
  1380     
       
  1381     TBool StartUp(ETrue);
       
  1382     StartUp = iStartup;
       
  1383 
       
  1384     TInt res(KErrNone);
       
  1385     wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1386     #if defined(_DEBUG)
       
  1387     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Get Code info"));
       
  1388     #endif
       
  1389     iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
       
  1390     res = wait->WaitForRequestL();
       
  1391     
       
  1392     TInt thisTry = 0;
       
  1393 
       
  1394 	// If there was a problem (as there might be in case we're dropping off SIM Access Profile); try again a couple of times.
       
  1395 	while ( res != KErrNone && ( thisTry++ ) <= KTriesToConnectServer )
       
  1396         {
       
  1397         User::After( KTimeBeforeRetryingRequest );
       
  1398         iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
       
  1399         res = wait->WaitForRequestL();
       
  1400         }
       
  1401     #if defined(_DEBUG)
       
  1402     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Get Code info result: %d"), res);
       
  1403     #endif
       
  1404     //If there's still an error we're doomed. Bail out.
       
  1405     User::LeaveIfError(res);
       
  1406     
       
  1407     #if defined(_DEBUG)
       
  1408     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Show last note"));
       
  1409     #endif
       
  1410     //show the last "Code Error" note of PIN verify result here so it won't be left under the PUK1 dialog
       
  1411     if(!StartUp && (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts))
       
  1412         CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1413     
       
  1414     // ask PUK code
       
  1415     iSecurityDlg = new (ELeave) CCodeQueryDialog (aPassword,SEC_C_PUK_CODE_MIN_LENGTH,SEC_C_PUK_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  1416     if(AknLayoutUtils::PenEnabled())
       
  1417         iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1418     else
       
  1419         iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1420     #ifdef __COVER_DISPLAY
       
  1421     iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1422     CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided
       
  1423 	if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1424     	{
       
  1425     	// … -  add data that cover ui is interested in
       
  1426     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPUK1); // adds int to additional data to be posted to cover ui
       
  1427     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1428      	}  
       
  1429     #endif //__COVER_DISPLAY   
       
  1430     
       
  1431     #if defined(_DEBUG)
       
  1432     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Show dialog"));
       
  1433     #endif    
       
  1434     if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts)
       
  1435             res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY);
       
  1436     else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1437        {
       
  1438          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PUK_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  1439          res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY, *queryPrompt);
       
  1440          CleanupStack::PopAndDestroy(queryPrompt);
       
  1441        }
       
  1442     else
       
  1443        {
       
  1444          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PUK_ATTEMPT);
       
  1445          res = iSecurityDlg->ExecuteLD(R_PUK_REQUEST_QUERY, *queryPrompt);
       
  1446          CleanupStack::PopAndDestroy(queryPrompt);   
       
  1447        }
       
  1448     
       
  1449     if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1450         {
       
  1451         CleanupStack::PopAndDestroy(wait);
       
  1452         return KErrCancel;
       
  1453         }
       
  1454         
       
  1455     RMobilePhone::TMobilePassword verifcationPassword;
       
  1456     // new pin code query
       
  1457     iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  1458     if(AknLayoutUtils::PenEnabled())
       
  1459         iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1460     else
       
  1461         iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1462     res = iSecurityDlg->ExecuteLD(R_NEW_PIN_CODE_REQUEST_QUERY);
       
  1463     if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1464         {
       
  1465         CleanupStack::PopAndDestroy(wait);    
       
  1466         return KErrCancel;
       
  1467         }
       
  1468   
       
  1469     // verification code query
       
  1470     iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  1471     if(AknLayoutUtils::PenEnabled())
       
  1472         iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1473     else
       
  1474         iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1475     res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_REQUEST_QUERY);
       
  1476     if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1477         {
       
  1478         CleanupStack::PopAndDestroy(wait);
       
  1479         return KErrCancel;
       
  1480         }
       
  1481                             
       
  1482     while (aNewPassword.CompareF(verifcationPassword) != 0) 
       
  1483         {
       
  1484         // codes do not match -> note -> ask new pin and verification codes again  
       
  1485         CSecuritySettings::ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
  1486         
       
  1487         verifcationPassword = _L("");
       
  1488         aNewPassword = _L("");
       
  1489 
       
  1490         // new pin code query
       
  1491         iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  1492         if(AknLayoutUtils::PenEnabled())
       
  1493             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1494         else
       
  1495             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1496         res = iSecurityDlg->ExecuteLD(R_NEW_PIN_CODE_REQUEST_QUERY);
       
  1497         if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1498             {
       
  1499             CleanupStack::PopAndDestroy(wait);
       
  1500             return KErrCancel;
       
  1501             }
       
  1502                 
       
  1503         // verification code query
       
  1504         iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  1505         if(AknLayoutUtils::PenEnabled())
       
  1506             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1507         else
       
  1508             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1509         res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_REQUEST_QUERY);
       
  1510     	if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1511             {
       
  1512             CleanupStack::PopAndDestroy(wait);
       
  1513             return KErrCancel;
       
  1514             }
       
  1515         }            
       
  1516         
       
  1517     // send code
       
  1518     #if defined(_DEBUG)
       
  1519     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk1RequiredL(): Verify Code"));
       
  1520     #endif
       
  1521     iPhone.VerifySecurityCode(wait->iStatus,blockCodeType,aNewPassword,aPassword);
       
  1522     res = wait->WaitForRequestL();
       
  1523     CleanupStack::PopAndDestroy(wait);
       
  1524     
       
  1525     TInt returnValue = res;
       
  1526     switch(res)
       
  1527         {
       
  1528         case KErrNone:
       
  1529             // code approved -> note
       
  1530             CSecuritySettings::ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  1531             break;
       
  1532            case KErrGsm0707IncorrectPassword:
       
  1533         case KErrAccessDenied:
       
  1534             // wrong PUK code -> note -> ask PUK code again        
       
  1535             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1536             returnValue = Puk1RequiredL();
       
  1537             break;
       
  1538         case KErrGsm0707SimWrong:
       
  1539             // sim lock active
       
  1540             break;
       
  1541         case KErrGsmSSPasswordAttemptsViolation:
       
  1542         case KErrLocked:
       
  1543             // sim card rejected.
       
  1544             break;
       
  1545         default:
       
  1546             CSecuritySettings::ShowErrorNoteL(res);        
       
  1547             returnValue = Puk1RequiredL();
       
  1548             break;
       
  1549         }    
       
  1550 
       
  1551         return returnValue;
       
  1552     }
       
  1553 //
       
  1554 // ----------------------------------------------------------
       
  1555 // CSecurityHandler::Pin2Required()
       
  1556 // Handles Pin2Required event
       
  1557 // ----------------------------------------------------------
       
  1558 //    
       
  1559 void CSecurityHandler::Pin2RequiredL()
       
  1560     {
       
  1561     /*****************************************************
       
  1562     *    Series 60 Customer / ETel
       
  1563     *    Series 60  ETel API
       
  1564     *****************************************************/
       
  1565     #if defined(_DEBUG)
       
  1566     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL() BEGIN"));
       
  1567     #endif
       
  1568     RMobilePhone::TMobilePassword password;
       
  1569     RMobilePhone::TMobilePassword required_fourth;
       
  1570     RMobilePhone::TMobilePhoneSecurityCode secCodeType(RMobilePhone::ESecurityCodePin2);
       
  1571     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1572     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1573     CWait* wait = CWait::NewL();
       
  1574     CleanupStack::PushL(wait);
       
  1575     
       
  1576     #if defined(_DEBUG)
       
  1577     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): create dialog"));
       
  1578     #endif
       
  1579     iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
  1580     #ifdef __COVER_DISPLAY
       
  1581     #if defined(_DEBUG)
       
  1582     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): publish dialog"));
       
  1583     #endif
       
  1584     iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1585     CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  1586 	if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1587     	{
       
  1588     	// … -  add data that cover ui is interested in
       
  1589     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN2); // adds int to additional data to be posted to cover ui
       
  1590     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1591      	}  
       
  1592     #endif //__COVER_DISPLAY
       
  1593     
       
  1594 	#if defined(_DEBUG)
       
  1595     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): get PIN2 info"));
       
  1596     #endif
       
  1597     
       
  1598 	wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1599     iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1600     TInt ret = wait->WaitForRequestL();
       
  1601         
       
  1602     #if defined(_DEBUG)
       
  1603     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): get PIN2 info result: %d"), ret);
       
  1604     TInt attempts(codeInfo.iRemainingEntryAttempts);
       
  1605     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): attempts remaining: %d"), attempts);
       
  1606     #endif
       
  1607     User::LeaveIfError(ret);
       
  1608     
       
  1609         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
  1610 	    CleanupStack::PushL(deviceLockStatusObserver);
       
  1611         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
  1612         CleanupStack::PushL(queryStatusObserver);
       
  1613         
       
  1614         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1615             ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY);
       
  1616         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1617             {
       
  1618                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN2_ATTEMPTS, codeInfo.iRemainingEntryAttempts );
       
  1619                 ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
       
  1620                 CleanupStack::PopAndDestroy(queryPrompt);
       
  1621             }
       
  1622         else
       
  1623             {
       
  1624                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN2_ATTEMPT);
       
  1625                 ret = iSecurityDlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
       
  1626                 CleanupStack::PopAndDestroy(queryPrompt);   
       
  1627             }
       
  1628     CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
  1629     iSecurityDlg = NULL;
       
  1630     if (!ret  || (ret == ESecUiDeviceLocked))
       
  1631         {
       
  1632         iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin2);
       
  1633         CleanupStack::PopAndDestroy(wait);
       
  1634         return;
       
  1635         }
       
  1636 
       
  1637     #if defined(_DEBUG)
       
  1638     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): Verify Code"));
       
  1639     #endif
       
  1640     iPhone.VerifySecurityCode(wait->iStatus,secCodeType,password,required_fourth);
       
  1641     TInt status = wait->WaitForRequestL();
       
  1642     #if defined(_DEBUG)
       
  1643     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): destroy wait"));
       
  1644     #endif
       
  1645     CleanupStack::PopAndDestroy(wait);
       
  1646 
       
  1647     switch(status)
       
  1648         {        
       
  1649         case KErrNone:
       
  1650             break;
       
  1651         case KErrGsm0707IncorrectPassword:
       
  1652         case KErrAccessDenied:
       
  1653             // code was entered erroneously
       
  1654             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);       
       
  1655             break;
       
  1656         case KErrGsmSSPasswordAttemptsViolation:
       
  1657         case KErrLocked:
       
  1658             // blocked
       
  1659             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1660             break;
       
  1661         default:
       
  1662             CSecuritySettings::ShowErrorNoteL(status);        
       
  1663             break;
       
  1664         }
       
  1665     #if defined(_DEBUG)
       
  1666     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): END"));
       
  1667     #endif
       
  1668     }
       
  1669 //
       
  1670 // ----------------------------------------------------------
       
  1671 // CSecurityHandler::Puk2Required()
       
  1672 // Handles Puk2Required event
       
  1673 // ----------------------------------------------------------
       
  1674 //    
       
  1675 void CSecurityHandler::Puk2RequiredL()
       
  1676     {    
       
  1677     /*****************************************************
       
  1678     *    Series 60 Customer / ETel
       
  1679     *    Series 60  ETel API
       
  1680     *****************************************************/
       
  1681     RMobilePhone::TMobilePassword aPassword;
       
  1682     RMobilePhone::TMobilePassword aNewPassword;
       
  1683     RMobilePhone::TMobilePassword verifcationPassword;
       
  1684     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1685     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1686     
       
  1687     RMobilePhone::TMobilePhoneSecurityCode blockCodeType;
       
  1688     blockCodeType = RMobilePhone::ESecurityCodePuk2;
       
  1689     CWait* wait = CWait::NewL();
       
  1690     CleanupStack::PushL(wait);
       
  1691     
       
  1692     #if defined(_DEBUG)
       
  1693     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL()"));
       
  1694     #endif
       
  1695     // ask PUK2
       
  1696     iSecurityDlg = new (ELeave) CCodeQueryDialog (aPassword,SEC_C_PUK2_CODE_MIN_LENGTH,SEC_C_PUK2_CODE_MAX_LENGTH,ESecUiNone);
       
  1697     #ifdef __COVER_DISPLAY
       
  1698     iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1699     CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  1700 	if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1701     	{
       
  1702     	// … -  add data that cover ui is interested in
       
  1703     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPUK2); // adds int to additional data to be posted to cover ui
       
  1704     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1705      	}  
       
  1706     #endif //__COVER_DISPLAY
       
  1707     CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
  1708 	CleanupStack::PushL(deviceLockStatusObserver);
       
  1709 	
       
  1710 	TInt ret(KErrNone);
       
  1711     wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1712     iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
       
  1713     ret = wait->WaitForRequestL();
       
  1714     User::LeaveIfError(ret);
       
  1715         
       
  1716     if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts)
       
  1717             ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY);
       
  1718     else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1719        {
       
  1720          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PUK2_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  1721          ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY, *queryPrompt);
       
  1722          CleanupStack::PopAndDestroy(queryPrompt);
       
  1723        }
       
  1724     else
       
  1725        {
       
  1726          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PUK2_ATTEMPT);
       
  1727          ret = iSecurityDlg->ExecuteLD(R_PUK2_REQUEST_QUERY, *queryPrompt);
       
  1728          CleanupStack::PopAndDestroy(queryPrompt);   
       
  1729        }
       
  1730 	
       
  1731 	iSecurityDlg = NULL;
       
  1732     if(!ret  || (ret == ESecUiDeviceLocked))
       
  1733         {
       
  1734         #if defined(_DEBUG)
       
  1735     	RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() PUK QUERY CANCEL"));
       
  1736     	#endif    
       
  1737         // cancel "get security unblock code" request
       
  1738         iPhone.AbortSecurityCode(blockCodeType);
       
  1739 		CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver
       
  1740         return;
       
  1741         }
       
  1742     #if defined(_DEBUG)
       
  1743     RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() NEW QUERY"));
       
  1744     #endif
       
  1745     // new pin2 code query
       
  1746     iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
  1747     deviceLockStatusObserver->SetAddress(iSecurityDlg);
       
  1748     ret = iSecurityDlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY);
       
  1749     if(!ret  || (ret == ESecUiDeviceLocked))
       
  1750         {
       
  1751         #if defined(_DEBUG)
       
  1752     	RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() NEW QUERY CANCEL"));
       
  1753     	#endif 
       
  1754         // cancel "get security unblock code" request
       
  1755         iPhone.AbortSecurityCode(blockCodeType);
       
  1756         CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver
       
  1757         return;
       
  1758         }
       
  1759 
       
  1760      // verification code query
       
  1761     iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
  1762     deviceLockStatusObserver->SetAddress(iSecurityDlg);
       
  1763     ret = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY);
       
  1764     if (!ret || (ret == ESecUiDeviceLocked))    
       
  1765         {
       
  1766         #if defined(_DEBUG)
       
  1767     	RDebug::Print(_L("(SECUI)CSecurityHandler::Puk2RequiredL() VERIFY QUERY CANCEL"));
       
  1768     	#endif 
       
  1769         // cancel "get security unblock code" request
       
  1770         iPhone.AbortSecurityCode(blockCodeType);
       
  1771         CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver
       
  1772         return;
       
  1773         }
       
  1774         
       
  1775     while (aNewPassword.CompareF(verifcationPassword) != 0) 
       
  1776         {
       
  1777         // codes do not match -> note -> ask new pin and verification codes again  
       
  1778         CSecuritySettings::ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
  1779         
       
  1780         verifcationPassword = _L("");
       
  1781         aNewPassword = _L("");
       
  1782 
       
  1783         // new pin2 code query
       
  1784         iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
  1785         deviceLockStatusObserver->SetAddress(iSecurityDlg);
       
  1786         deviceLockStatusObserver->StartObserver();
       
  1787         
       
  1788         ret = iSecurityDlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY);
       
  1789     
       
  1790         if(!ret || (ret == ESecUiDeviceLocked))
       
  1791             {
       
  1792             // cancel "get security unblock code" request
       
  1793             iPhone.AbortSecurityCode(blockCodeType);
       
  1794             CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver
       
  1795             return;
       
  1796             }
       
  1797                     
       
  1798         // verification code query
       
  1799         iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
  1800         deviceLockStatusObserver->SetAddress(iSecurityDlg);
       
  1801         deviceLockStatusObserver->StartObserver();
       
  1802         ret = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY);
       
  1803         
       
  1804         if (!ret || (ret == ESecUiDeviceLocked))    
       
  1805             {
       
  1806             // cancel "get security unblock code" request
       
  1807             iPhone.AbortSecurityCode(blockCodeType);
       
  1808             CleanupStack::PopAndDestroy(2); //wait, deviceLockStatusObserver
       
  1809             return;
       
  1810             }
       
  1811         }            
       
  1812     CleanupStack::PopAndDestroy(deviceLockStatusObserver);            
       
  1813     // send code
       
  1814     
       
  1815     iPhone.VerifySecurityCode(wait->iStatus,blockCodeType,aNewPassword,aPassword);
       
  1816     TInt res = wait->WaitForRequestL();
       
  1817     CleanupStack::PopAndDestroy(wait);
       
  1818     
       
  1819     switch(res)
       
  1820         {
       
  1821         case KErrNone:
       
  1822             // code approved -> note
       
  1823             CSecuritySettings::ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  1824             break;
       
  1825         case KErrGsm0707IncorrectPassword:
       
  1826         case KErrAccessDenied:
       
  1827             // wrong PUK2 code -> note -> ask PUK2 code again        
       
  1828             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  1829             Puk2RequiredL();
       
  1830             break;
       
  1831         case KErrGsmSSPasswordAttemptsViolation:
       
  1832         case KErrLocked:
       
  1833             // Pin2 features blocked permanently!
       
  1834             CSecuritySettings::ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone);    
       
  1835             break;    
       
  1836         default:
       
  1837             CSecuritySettings::ShowErrorNoteL(res);            
       
  1838             Puk2RequiredL();
       
  1839             break;
       
  1840         }            
       
  1841     }
       
  1842 
       
  1843 //
       
  1844 // ----------------------------------------------------------
       
  1845 // CSecurityHandler::UPinRequiredL()
       
  1846 // Hendles UniversalPinRequired event
       
  1847 // ----------------------------------------------------------
       
  1848 //  
       
  1849 TInt CSecurityHandler::UPinRequiredL()
       
  1850     {
       
  1851     /*****************************************************
       
  1852     *    Series 60 Customer / ETel
       
  1853     *    Series 60  ETel API
       
  1854     *****************************************************/
       
  1855     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
       
  1856     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
  1857     if(wcdmaSupported || upinSupported)
       
  1858        {
       
  1859         RMobilePhone::TMobilePassword password;
       
  1860         RMobilePhone::TMobilePassword required_fourth;
       
  1861         RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1862         RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1863         RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityUniversalPin;
       
  1864         CWait* wait = CWait::NewL();
       
  1865         CleanupStack::PushL(wait);
       
  1866         TBool StartUp = ETrue; 
       
  1867         TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
       
  1868         TInt err = KErrNone;
       
  1869         TInt res = KErrGeneral;
       
  1870     
       
  1871         StartUp = iStartup;
       
  1872     
       
  1873         #if defined(_DEBUG)
       
  1874         RDebug::Print(_L("(SECUI)CSecurityHandler::UPinRequiredL()"));
       
  1875         #endif
       
  1876     
       
  1877         if(!StartUp)
       
  1878         {
       
  1879             // read a flag to see whether the query is SecUi originated. 
       
  1880             err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
       
  1881         }
       
  1882         
       
  1883         #if defined(_DEBUG)
       
  1884         RDebug::Print(_L("CSecurityHandler::UPinRequiredL() Execute dlg"));
       
  1885         #endif 
       
  1886         if(StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
       
  1887         {
       
  1888             iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiCodeEtelReqest);
       
  1889             if(AknLayoutUtils::PenEnabled())
       
  1890                 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  1891             else
       
  1892                 iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  1893             #ifdef __COVER_DISPLAY
       
  1894             iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1895             CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  1896     		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1897         		{
       
  1898         		// … -  add data that cover ui is interested in
       
  1899         		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowUPIN); // adds int to additional data to be posted to cover ui
       
  1900         		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1901          		}  
       
  1902             #endif //__COVER_DISPLAY
       
  1903             
       
  1904             wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1905             iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1906             res = wait->WaitForRequestL();
       
  1907             User::LeaveIfError(res);
       
  1908             
       
  1909             if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1910                 res = iSecurityDlg->ExecuteLD(R_UPIN_REQUEST_QUERY);
       
  1911             else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1912                 {
       
  1913                     HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_UPIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  1914                     res = iSecurityDlg->ExecuteLD(R_UPIN_REQUEST_QUERY, *queryPrompt);
       
  1915                     CleanupStack::PopAndDestroy(queryPrompt);
       
  1916                 }
       
  1917             else
       
  1918                 {
       
  1919                     HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_UPIN_ATTEMPT);
       
  1920                     res = iSecurityDlg->ExecuteLD(R_UPIN_REQUEST_QUERY, *queryPrompt);
       
  1921                     CleanupStack::PopAndDestroy(queryPrompt);   
       
  1922                 }
       
  1923             
       
  1924             
       
  1925             if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  1926                 { 
       
  1927                 CleanupStack::PopAndDestroy(wait);   
       
  1928                 return KErrCancel;
       
  1929                 }
       
  1930         }
       
  1931         else
       
  1932         {
       
  1933             iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
  1934             #ifdef __COVER_DISPLAY
       
  1935             iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1936             CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  1937     		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1938         		{
       
  1939         		// … -  add data that cover ui is interested in
       
  1940         		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowUPIN); // adds int to additional data to be posted to cover ui
       
  1941         		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1942          		}  
       
  1943             #endif //__COVER_DISPLAY
       
  1944             
       
  1945     		wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1946             iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1947             res = wait->WaitForRequestL();
       
  1948             User::LeaveIfError(res);
       
  1949             
       
  1950             CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
  1951     		CleanupStack::PushL(deviceLockStatusObserver);
       
  1952     		CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
  1953             CleanupStack::PushL(queryStatusObserver);
       
  1954             
       
  1955             if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1956                 res = iSecurityDlg->ExecuteLD(R_UPIN_QUERY);
       
  1957             else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1958                 {
       
  1959                     HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_UPIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  1960                     res = iSecurityDlg->ExecuteLD(R_UPIN_QUERY, *queryPrompt);
       
  1961                     CleanupStack::PopAndDestroy(queryPrompt);
       
  1962                 }
       
  1963             else
       
  1964                 {
       
  1965                     HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_UPIN_ATTEMPT);
       
  1966                     res = iSecurityDlg->ExecuteLD(R_UPIN_QUERY, *queryPrompt);
       
  1967                     CleanupStack::PopAndDestroy(queryPrompt);   
       
  1968                 }
       
  1969     		
       
  1970     		CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
  1971     		iSecurityDlg = NULL;
       
  1972             if( !res || (res == ESecUiDeviceLocked))
       
  1973                 {
       
  1974                 // cancel code request
       
  1975                 CleanupStack::PopAndDestroy(wait);
       
  1976                 iPhone.AbortSecurityCode(RMobilePhone::ESecurityUniversalPin);
       
  1977                 return KErrCancel;
       
  1978                 }      
       
  1979         }
       
  1980         
       
  1981         #if defined(_DEBUG)
       
  1982         RDebug::Print(_L("CSecurityNotifier::UPinRequiredL()VerifySecurityCode"));
       
  1983         #endif
       
  1984         iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
       
  1985         res = wait->WaitForRequestL();
       
  1986         CleanupStack::PopAndDestroy(wait);
       
  1987         #if defined(_DEBUG)
       
  1988         RDebug::Print(_L("(SECUI)CSecurityHandler::UPinRequiredL() VerifySecurityCode STATUS: %d"), res);
       
  1989         #endif
       
  1990         TInt returnValue = res;
       
  1991         switch(res)
       
  1992             {        
       
  1993             case KErrNone:
       
  1994                 // code approved 
       
  1995                 #if defined(_DEBUG)
       
  1996                 RDebug::Print(_L("CSecurityHandler::UPinRequiredL()code approved "));
       
  1997                 #endif
       
  1998                 CSecuritySettings::ShowResultNoteL(R_CONFIRMATION_NOTE, CAknNoteDialog::EConfirmationTone);
       
  1999                 break;
       
  2000             case KErrGsm0707IncorrectPassword:
       
  2001             case KErrAccessDenied:
       
  2002                 // code was entered erroneously
       
  2003                 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2004                 if(StartUp)
       
  2005                 {
       
  2006                 returnValue = UPinRequiredL();
       
  2007                 }
       
  2008                 break;
       
  2009             case KErrGsmSSPasswordAttemptsViolation:
       
  2010             case KErrLocked:
       
  2011                 // code blocked; show error note and terminate.
       
  2012                 if(StartUp)
       
  2013                     CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); 
       
  2014                 break;
       
  2015             case KErrGsm0707SimWrong:
       
  2016                 // sim lock active
       
  2017                 break;
       
  2018             default:
       
  2019                 CSecuritySettings::ShowErrorNoteL(res);
       
  2020                 if(StartUp)
       
  2021                 {
       
  2022                 returnValue = UPinRequiredL();
       
  2023                 }
       
  2024                 break;
       
  2025             }
       
  2026     
       
  2027         return returnValue;
       
  2028        }
       
  2029     else
       
  2030         return KErrNone;
       
  2031     }
       
  2032 //
       
  2033 // ----------------------------------------------------------
       
  2034 // CSecurityHandler::UPukRequiredL()
       
  2035 // Handles UPukRequired event
       
  2036 // ----------------------------------------------------------
       
  2037 //
       
  2038 TInt CSecurityHandler::UPukRequiredL()
       
  2039     {
       
  2040     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
       
  2041     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
  2042     if(wcdmaSupported || upinSupported)
       
  2043        {
       
  2044         #if defined(_DEBUG)
       
  2045         RDebug::Print(_L("(SECUI)CSecurityHandler::UPukRequiredL()"));
       
  2046         #endif            
       
  2047         RMobilePhone::TMobilePassword aPassword;
       
  2048         RMobilePhone::TMobilePassword aNewPassword;
       
  2049         RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  2050         RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  2051     
       
  2052         RMobilePhone::TMobilePhoneSecurityCode blockCodeType;
       
  2053         blockCodeType = RMobilePhone::ESecurityUniversalPuk;
       
  2054         CWait* wait = CWait::NewL();
       
  2055         CleanupStack::PushL(wait);
       
  2056         
       
  2057         TBool StartUp(ETrue);
       
  2058         StartUp = iStartup;
       
  2059     
       
  2060         TInt res(KErrNone);
       
  2061         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  2062         iPhone.GetSecurityCodeInfo(wait->iStatus, blockCodeType, codeInfoPkg);
       
  2063         res = wait->WaitForRequestL();
       
  2064         User::LeaveIfError(res);
       
  2065         //show last "Code Error" note for UPIN verify result so it won't be left under the PUK1 dialog
       
  2066         if(!StartUp && (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts))
       
  2067             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2068         
       
  2069         // ask UPUK code
       
  2070         iSecurityDlg = new (ELeave) CCodeQueryDialog (aPassword,SEC_C_PUK_CODE_MIN_LENGTH,SEC_C_PUK_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  2071         if(AknLayoutUtils::PenEnabled())
       
  2072             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  2073         else
       
  2074             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  2075         #ifdef __COVER_DISPLAY
       
  2076         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  2077         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
  2078     		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  2079         		{
       
  2080         		// … -  add data that cover ui is interested in
       
  2081         		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowUPUK);// adds int to additional data to be posted to cover ui
       
  2082         		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  2083          		}  
       
  2084         #endif //__COVER_DISPLAY
       
  2085        
       
  2086             
       
  2087         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPUKAttempts)
       
  2088                 res = iSecurityDlg->ExecuteLD(R_UPUK_REQUEST_QUERY);
       
  2089         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  2090            {
       
  2091              HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_UPUK_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
  2092              res = iSecurityDlg->ExecuteLD(R_UPUK_REQUEST_QUERY, *queryPrompt);
       
  2093              CleanupStack::PopAndDestroy(queryPrompt);
       
  2094            }
       
  2095         else
       
  2096            {
       
  2097              HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_UPUK_ATTEMPT);
       
  2098              res = iSecurityDlg->ExecuteLD(R_UPUK_REQUEST_QUERY, *queryPrompt);
       
  2099              CleanupStack::PopAndDestroy(queryPrompt);   
       
  2100            }
       
  2101         
       
  2102         if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  2103             {
       
  2104             CleanupStack::PopAndDestroy(wait);
       
  2105             return KErrCancel;
       
  2106             }
       
  2107             
       
  2108         RMobilePhone::TMobilePassword verifcationPassword;
       
  2109         // new upin code query
       
  2110         iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  2111         if(AknLayoutUtils::PenEnabled())
       
  2112             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  2113         else
       
  2114             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  2115         res = iSecurityDlg->ExecuteLD(R_NEW_UPIN_CODE_REQUEST_QUERY);
       
  2116         if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  2117             {
       
  2118             CleanupStack::PopAndDestroy(wait);    
       
  2119             return KErrCancel;
       
  2120             }
       
  2121       
       
  2122         // verification code query
       
  2123         iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  2124         if(AknLayoutUtils::PenEnabled())
       
  2125             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  2126         else
       
  2127             iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  2128         res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_UPIN_CODE_REQUEST_QUERY);
       
  2129         if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  2130             {
       
  2131             CleanupStack::PopAndDestroy(wait);
       
  2132             return KErrCancel;
       
  2133             }
       
  2134                                 
       
  2135         while (aNewPassword.CompareF(verifcationPassword) != 0) 
       
  2136             {
       
  2137             // codes do not match -> note -> ask new upin and verification codes again  
       
  2138             CSecuritySettings::ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
  2139             
       
  2140             verifcationPassword = _L("");
       
  2141             aNewPassword = _L("");
       
  2142     
       
  2143             // new upin code query
       
  2144             iSecurityDlg = new (ELeave) CCodeQueryDialog (aNewPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  2145             if(AknLayoutUtils::PenEnabled())
       
  2146                 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  2147             else
       
  2148                 iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  2149             res = iSecurityDlg->ExecuteLD(R_NEW_UPIN_CODE_REQUEST_QUERY);
       
  2150         	if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  2151                 {
       
  2152                 CleanupStack::PopAndDestroy(wait);
       
  2153                 return KErrCancel;
       
  2154                 }
       
  2155                     
       
  2156             // verification code query
       
  2157             iSecurityDlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiPukRequired);
       
  2158             if(AknLayoutUtils::PenEnabled())
       
  2159                 iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
  2160             else
       
  2161                 iSecurityDlg->SetEmergencyCallSupport(ETrue);
       
  2162             res = iSecurityDlg->ExecuteLD(R_VERIFY_NEW_UPIN_CODE_REQUEST_QUERY);
       
  2163         	if((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
       
  2164                 {
       
  2165                 CleanupStack::PopAndDestroy(wait);
       
  2166                 return KErrCancel;
       
  2167                 }
       
  2168             }            
       
  2169             
       
  2170         // send code
       
  2171         iPhone.VerifySecurityCode(wait->iStatus,blockCodeType,aNewPassword,aPassword);
       
  2172         res = wait->WaitForRequestL();
       
  2173         CleanupStack::PopAndDestroy(wait);
       
  2174         
       
  2175         TInt returnValue = res;
       
  2176         switch(res)
       
  2177             {
       
  2178             case KErrNone:
       
  2179                 // code approved -> note
       
  2180                 CSecuritySettings::ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  2181                 break;
       
  2182             case KErrGsm0707IncorrectPassword:
       
  2183             case KErrAccessDenied:
       
  2184                 // wrong PUK code -> note -> ask UPUK code again        
       
  2185                 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2186                 returnValue = UPukRequiredL();
       
  2187                 break;
       
  2188             case KErrGsm0707SimWrong:
       
  2189                 // sim lock active
       
  2190                 break;
       
  2191             case KErrGsmSSPasswordAttemptsViolation:
       
  2192             case KErrLocked:
       
  2193                 // sim card rejected.
       
  2194                 break;
       
  2195             default:
       
  2196                 CSecuritySettings::ShowErrorNoteL(res);        
       
  2197                 returnValue = UPukRequiredL();
       
  2198                 break;
       
  2199             }   
       
  2200     
       
  2201         return returnValue;
       
  2202        }
       
  2203     else
       
  2204         return KErrNone;
       
  2205     }
       
  2206 
       
  2207 //
       
  2208 // ----------------------------------------------------------
       
  2209 // CSecurityHandler::SimLockEventL()
       
  2210 // Shows "SIM restriction on" note
       
  2211 // ----------------------------------------------------------
       
  2212 //    
       
  2213 void CSecurityHandler::SimLockEventL()
       
  2214     {
       
  2215     #if defined(_DEBUG)
       
  2216     RDebug::Print(_L("CSecurityHandler::SimLockEventL()"));
       
  2217     #endif
       
  2218     CSecuritySettings::ShowResultNoteL(R_SIM_ON, CAknNoteDialog::EConfirmationTone);    
       
  2219     }
       
  2220 // ---------------------------------------------------------
       
  2221 // CSecurityHandler::RemoveSplashScreenL()
       
  2222 // Removes splash screen
       
  2223 // ---------------------------------------------------------
       
  2224 void CSecurityHandler::RemoveSplashScreenL() const
       
  2225     {
       
  2226 
       
  2227     }
       
  2228 
       
  2229 // ---------------------------------------------------------
       
  2230 // CSecurityHandler::ShowGenericErrorNoteL(TInt aStatus)
       
  2231 // Shows a generic error note
       
  2232 // ---------------------------------------------------------
       
  2233 
       
  2234 void CSecurityHandler::ShowGenericErrorNoteL(TInt aStatus)
       
  2235     {
       
  2236        // Let's create TextResolver instance for error resolving...
       
  2237        CTextResolver* textresolver = CTextResolver::NewLC(); 
       
  2238        // Resolve the error
       
  2239        TPtrC errorstring;
       
  2240        errorstring.Set( textresolver->ResolveErrorString( aStatus ) );
       
  2241        iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg));
       
  2242        iNoteDlg->PrepareLC(R_CODE_ERROR);
       
  2243        iNoteDlg->SetTextL((TDesC&)errorstring);
       
  2244        iNoteDlg->RunDlgLD(CAknNoteDialog::ELongTimeout, CAknNoteDialog::EErrorTone);
       
  2245        CleanupStack::PopAndDestroy(textresolver); 
       
  2246     }
       
  2247                     
       
  2248 
       
  2249 // End of file