securitydialogs/SecUi/Src/SecUiSecurityHandler.cpp
changeset 15 318c4eab2439
parent 1 d5423fbb4f29
child 17 8957df7b0072
equal deleted inserted replaced
14:b75757c81051 15:318c4eab2439
    50 #ifdef RD_REMOTELOCK
    50 #ifdef RD_REMOTELOCK
    51 #include <RemoteLockSettings.h>
    51 #include <RemoteLockSettings.h>
    52 #endif // RD_REMOTELOCK
    52 #endif // RD_REMOTELOCK
    53 #include <StringLoader.h>
    53 #include <StringLoader.h>
    54 #include <featmgr.h>
    54 #include <featmgr.h>
       
    55 
       
    56 #include "SecQueryUi.h"
       
    57 
    55 //  LOCAL CONSTANTS AND MACROS
    58 //  LOCAL CONSTANTS AND MACROS
    56 const TInt KMaxNumberOfPUKAttempts(10);
    59 const TInt KMaxNumberOfPUKAttempts(10);
    57 const TInt KMaxNumberOfPINAttempts(3);
    60 const TInt KMaxNumberOfPINAttempts(3);
    58 const TInt KLastRemainingInputAttempt(1);
    61 const TInt KLastRemainingInputAttempt(1);
    59 
    62 
    60 const TInt KTriesToConnectServer( 2 );
    63 const TInt KTriesToConnectServer( 2 );
    61 const TInt KTimeBeforeRetryingRequest( 50000 );
    64 const TInt KTimeBeforeRetryingRequest( 50000 );
    62 
    65 
       
    66 
    63 // ================= MEMBER FUNCTIONS =======================
    67 // ================= MEMBER FUNCTIONS =======================
    64 //
    68 //
    65 // ----------------------------------------------------------
    69 // ----------------------------------------------------------
    66 // CSecurityHandler::CSecurityHandler()
    70 // CSecurityHandler::CSecurityHandler()
    67 // C++ constructor
    71 // C++ constructor
    68 // ----------------------------------------------------------
    72 // ----------------------------------------------------------
    69 //
    73 //
    70 EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone):
    74 EXPORT_C CSecurityHandler::CSecurityHandler(RMobilePhone& aPhone):
    71         iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL) 
    75         iPhone(aPhone), iQueryCanceled(ETrue), iSecurityDlg(NULL), iNoteDlg(NULL) 
    72     {
    76     {
       
    77     		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    78 
    73         TInt result = iCustomPhone.Open(aPhone);
    79         TInt result = iCustomPhone.Open(aPhone);
    74         TRAP_IGNORE( FeatureManager::InitializeLibL() ); //Shouldn't this panic if FM does not initialise??
    80         TRAP_IGNORE( FeatureManager::InitializeLibL() ); //Shouldn't this panic if FM does not initialise??
    75     }
    81     }
    76 
    82 
    77 //
    83 //
    80 // Destructor
    86 // Destructor
    81 // ----------------------------------------------------------
    87 // ----------------------------------------------------------
    82 //
    88 //
    83 EXPORT_C CSecurityHandler::~CSecurityHandler()
    89 EXPORT_C CSecurityHandler::~CSecurityHandler()
    84     {
    90     {
       
    91     	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    92 
    85     #if defined(_DEBUG)
    93     #if defined(_DEBUG)
    86     RDebug::Print(_L("CSecurityHandler::~CSecurityHandler()"));
    94     RDebug::Print(_L("CSecurityHandler::~CSecurityHandler()"));
    87     #endif
    95     #endif
    88     if ( iDestroyedPtr )
    96     if ( iDestroyedPtr )
    89         {
    97         {
   101 // ----------------------------------------------------------
   109 // ----------------------------------------------------------
   102 //
   110 //
   103 EXPORT_C void CSecurityHandler::HandleEventL(
   111 EXPORT_C void CSecurityHandler::HandleEventL(
   104     RMobilePhone::TMobilePhoneSecurityEvent aEvent )
   112     RMobilePhone::TMobilePhoneSecurityEvent aEvent )
   105     {
   113     {
       
   114     	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   115 
   106     TInt result = KErrNone;
   116     TInt result = KErrNone;
   107     HandleEventL( aEvent, result );
   117     HandleEventL( aEvent, result );
   108     }
   118     }
   109 
   119 
   110 //
   120 //
   115 //
   125 //
   116 EXPORT_C void CSecurityHandler::HandleEventL(
   126 EXPORT_C void CSecurityHandler::HandleEventL(
   117     RMobilePhone::TMobilePhoneSecurityEvent aEvent,
   127     RMobilePhone::TMobilePhoneSecurityEvent aEvent,
   118     TBool aStartup, TInt& aResult )
   128     TBool aStartup, TInt& aResult )
   119     {
   129     {
       
   130     	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   131 
   120     iStartup = aStartup;
   132     iStartup = aStartup;
   121     HandleEventL( aEvent, aResult );
   133     HandleEventL( aEvent, aResult );
   122     }
   134     }
   123     
   135     
   124 //
   136 //
   128 // ----------------------------------------------------------
   140 // ----------------------------------------------------------
   129 //
   141 //
   130 EXPORT_C void CSecurityHandler::HandleEventL(
   142 EXPORT_C void CSecurityHandler::HandleEventL(
   131     RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult )
   143     RMobilePhone::TMobilePhoneSecurityEvent aEvent, TInt& aResult )
   132     {
   144     {
       
   145     	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   146 
   133     /*****************************************************
   147     /*****************************************************
   134     *    Series 60 Customer / ETel
   148     *    Series 60 Customer / ETel
   135     *    Series 60  ETel API
   149     *    Series 60  ETel API
   136     *****************************************************/
   150     *****************************************************/
   137     #if defined(_DEBUG)
   151     #if defined(_DEBUG)
   138     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL()"));
   152     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL()"));
   139     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() EVENT: %d"), aEvent);
   153     RDebug::Print(_L("(SECUI)CSecurityHandler::HandleEventL() EVENT: %d"), aEvent);
   140     #endif
   154     #endif
   141     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
   155     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
   142     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
   156     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
   157 		RDebug::Printf( "%s %s (%u) aEvent=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aEvent );
   143  
   158  
   144     switch(aEvent)
   159     switch(aEvent)
   145             {
   160             {
   146             case RMobilePhone::EPin1Required:
   161             case RMobilePhone::EPin1Required:
   147                 #if defined(_DEBUG)
   162                 #if defined(_DEBUG)
   228         // code is the default one; no need to request it.
   243         // code is the default one; no need to request it.
   229         return ETrue;
   244         return ETrue;
   230         }
   245         }
   231     /* end check for default code */
   246     /* end check for default code */
   232 
   247 
   233     // Destructor sets thisDestroyed to ETrue
       
   234     TBool thisDestroyed( EFalse );
       
   235     iDestroyedPtr = &thisDestroyed;
       
   236     
   248     
   237     iQueryCanceled = EFalse;
   249     iQueryCanceled = EFalse;
   238     RMobilePhone::TMobilePassword password;
       
   239     RMobilePhone::TMobilePassword required_fourth;
   250     RMobilePhone::TMobilePassword required_fourth;
   240         
   251         
   241     TInt ret = KErrNone;
   252     TInt ret = KErrNone;
   242     TInt err = KErrNone;
   253     TInt err = KErrNone;
   243     TInt status = KErrNone;
   254     TInt status = KErrNone;
   244     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   255     
   245     		FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
   256 		RMobilePhone::TMobilePassword iSecUi_password;
   246     {
   257     TBool queryAccepted = EFalse;
   247         // Connect to the SCP server, and request the code query
   258 
   248         RSCPClient scpClient;
   259 
   249         User::LeaveIfError( scpClient.Connect() );
   260         while (!queryAccepted)
   250         CleanupClosePushL( scpClient );      
   261             {
   251         status = scpClient.SecCodeQuery( password, 
   262 		        RMobilePhone::TMobilePhoneSecurityCode secCodeType;
   252                                       RSCPClient::SCP_OK_CANCEL,
   263 		        secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   253                                       EFalse,
   264 
   254                                       0 );         
   265 						/* request PIN using QT */
   255                                               
   266 						CSecQueryUi *iSecQueryUi;
   256         if ( status != KErrCancel )
   267 						RDebug::Printf( "%s %s (%u) CSecQueryUi=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   257             {
   268 						iSecQueryUi = CSecQueryUi::NewL();
   258             // Set this "true" to indicate that the input wasn't cancelled
   269 						RDebug::Printf( "%s %s (%u) Copy=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   259             ret = ETrue;
   270 						iSecUi_password.Copy(_L("666"));
   260             }
   271 						RDebug::Printf( "%s %s (%u) InstallConfirmationQueryL=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   261         else
   272 						queryAccepted = iSecQueryUi->SecQueryDialog( _L("AskSecCodeL"), iSecUi_password, 4, 8, secCodeType /*aMode*/ );
   262             {
   273 						RDebug::Printf( "%s %s (%u) iSecUi_password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   263             ret = EFalse;
   274 						RDebug::Print( iSecUi_password );
   264             }
   275 						RDebug::Printf( "%s %s (%u) delete=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   265         
   276 						delete iSecQueryUi;
   266         CleanupStack::PopAndDestroy(); //scpClient                       
   277 						RDebug::Printf( "%s %s (%u) done=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   267   }
   278 		        if(queryAccepted)	res=0xFFFFFFFE;	// this is the value returned from iSecurityDlg
   268   else
   279 						/* end request PIN using QT */
   269   {
       
   270     iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   271     #ifdef __COVER_DISPLAY
       
   272     iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   273     CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided
       
   274 	if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   275     	{
       
   276     	// … -  add data that cover ui is interested in
       
   277     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode);// adds int to additional data to be posted to cover ui
       
   278     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   279      	}  
       
   280     #endif //__COVER_DISPLAY
       
   281 	    CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   282 		CleanupStack::PushL(deviceLockStatusObserver);
       
   283 		err =KErrNone;
       
   284 	    TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY));
       
   285 		CleanupStack::PopAndDestroy(deviceLockStatusObserver);
       
   286   }
       
   287     
       
   288     // check if CSecurityHandler has been "killed"
       
   289     if ( thisDestroyed )
       
   290         {
       
   291         return EFalse;
       
   292         }
       
   293 
       
   294     iDestroyedPtr = NULL;
       
   295     iSecurityDlg = NULL;
       
   296 
       
   297     if (err != KErrNone)
       
   298         {
       
   299         User::Leave(err);
       
   300         }
       
   301 
       
   302     if (ret)
       
   303         {
       
   304         while (!iQueryCanceled)
       
   305             {
       
   306 	           if (!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   307 		           {           
       
   308 		                RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   309 		                secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
   310 		                CWait* wait = CWait::NewL();
       
   311 		                iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
       
   312 		                status = wait->WaitForRequestL();
       
   313 		                delete wait;
       
   314 		
   280 		
   315 		           }
   281 		        CWait* wait = CWait::NewL();
   316             
   282 		        iPhone.VerifySecurityCode(wait->iStatus,secCodeType, iSecUi_password, required_fourth);
       
   283 		        status = wait->WaitForRequestL();
       
   284 		        delete wait;
       
   285 		
       
   286 						ret = ETrue;
       
   287 		        if (!queryAccepted)
       
   288 		            {
       
   289 		            ret = EFalse;
       
   290 		            return ret;
       
   291 		            }
       
   292 		        queryAccepted = EFalse;	// because it's not yet validated
   317             switch(status)
   293             switch(status)
   318                 {        
   294                 {        
   319                 case KErrNone:
   295                 case KErrNone:
   320                     {
   296                     {
   321                     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   297                     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   324                         RSCPClient scpClient;
   300                         RSCPClient scpClient;
   325                         User::LeaveIfError( scpClient.Connect() );
   301                         User::LeaveIfError( scpClient.Connect() );
   326                         CleanupClosePushL( scpClient );
   302                         CleanupClosePushL( scpClient );
   327 
   303 
   328                         TSCPSecCode newCode;
   304                         TSCPSecCode newCode;
   329                         newCode.Copy( password );
   305                         newCode.Copy( iSecUi_password );
   330                         scpClient.StoreCode( newCode );
   306                         scpClient.StoreCode( newCode );
   331 
   307 
   332                         CleanupStack::PopAndDestroy(); //scpClient  
   308                         CleanupStack::PopAndDestroy(); //scpClient
       
   309                        	queryAccepted = ETrue;
   333                   	}
   310                   	}
   334                             	
   311                             	
   335                     iQueryCanceled = ETrue;
   312                     iQueryCanceled = ETrue;	// TODO
   336                     return ETrue;
   313                     return ETrue;
   337                     }                    
   314                     }                    
   338                 case KErrGsmSSPasswordAttemptsViolation:
   315                 case KErrGsmSSPasswordAttemptsViolation:
   339                 case KErrLocked:
   316                 case KErrLocked:
   340                     {
   317                     {
   341                     iDestroyedPtr = &thisDestroyed;
       
   342                     // security code blocked! 
   318                     // security code blocked! 
   343                     iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg));
   319                     CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);	// TODO
   344                     iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   345                     iNoteDlg->SetTone(CAknNoteDialog::EErrorTone);
       
   346                     err =KErrNone;
       
   347                     TRAP(err,iNoteDlg->ExecuteLD(R_SEC_BLOCKED));
       
   348                     
       
   349                     // check if CSecurityHandler has been "killed"
       
   350                     if ( thisDestroyed )
       
   351                         {
       
   352                         return EFalse;
       
   353                         }
       
   354                     
       
   355                     iDestroyedPtr = NULL;
       
   356                     iNoteDlg = NULL;
       
   357 
       
   358                     if (err != KErrNone)
       
   359                         {
       
   360                         User::Leave(err);
       
   361                         }
       
   362                     break;
   320                     break;
   363                     }
   321                     }
   364                 case KErrGsm0707IncorrectPassword:
   322                 case KErrGsm0707IncorrectPassword:
   365                 case KErrAccessDenied:
   323                 case KErrAccessDenied:
   366                     {    
   324                     {    
   367                     iDestroyedPtr = &thisDestroyed;
       
   368                     // code was entered erroneusly
   325                     // code was entered erroneusly
   369                     iNoteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNoteDlg));
   326                     CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);	// TODO
   370                     iNoteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   371                     iNoteDlg->SetTone(CAknNoteDialog::EErrorTone);
       
   372                     err =KErrNone;
       
   373                     TRAP(err,iNoteDlg->ExecuteLD(R_CODE_ERROR));    
       
   374                     
       
   375                     // check if CSecurityHandler has been "killed"
       
   376                     if ( thisDestroyed )
       
   377                         {
       
   378                         return EFalse;
       
   379                         }
       
   380                     
       
   381                     iDestroyedPtr = NULL;
       
   382                     iNoteDlg = NULL;
       
   383                     
       
   384                     if (err != KErrNone)
       
   385                         {
       
   386                         User::Leave(err);
       
   387                         }
       
   388                     break;
       
   389                     }    
   327                     }    
   390                 default:
   328                 default:
   391                     {
   329                     {
   392                     iDestroyedPtr = &thisDestroyed;
   330                     CSecuritySettings::ShowResultNoteL(status, CAknNoteDialog::EErrorTone);	// TODO
   393                     err =KErrNone;
       
   394                     TRAP(err,ShowGenericErrorNoteL(status));
       
   395                                         
       
   396                     // check if CSecurityHandler has been "killed"
       
   397                     if ( thisDestroyed )
       
   398                         {
       
   399                         return EFalse;
       
   400                         }
       
   401                     
       
   402                     iDestroyedPtr = NULL;
       
   403                     iNoteDlg = NULL;
       
   404                     
       
   405                     if (err != KErrNone)
       
   406                         {
       
   407                         User::Leave(err);
       
   408                         }    
       
   409                     break;
       
   410                     }
   331                     }
   411                 }     
   332                 }     
   412         
       
   413             if (iQueryCanceled)
       
   414                 {
       
   415                 ret = EFalse;
       
   416                 break;
       
   417                 }    
       
   418             
       
   419             password = _L("");
       
   420             iDestroyedPtr = &thisDestroyed;
       
   421              if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   422     						FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))  
       
   423     				{       
       
   424                 // Connect to the SCP server, and request the code query
       
   425                 RSCPClient scpClient;
       
   426                 User::LeaveIfError( scpClient.Connect() );
       
   427                 CleanupClosePushL( scpClient );
       
   428                 status = scpClient.SecCodeQuery( password, 
       
   429                                       RSCPClient::SCP_OK_CANCEL,
       
   430                                       EFalse,
       
   431                                       0 ); 
       
   432         
       
   433                 if ( status != KErrCancel )
       
   434                     {
       
   435                     // Set this "true" to indicate that the input wasn't cancelled
       
   436                     ret = ETrue;
       
   437                     }
       
   438                 else
       
   439                     {
       
   440                     ret = EFalse;
       
   441                     }                                
       
   442         
       
   443                 CleanupStack::PopAndDestroy(); //scpClient                              
       
   444           }
       
   445           else
       
   446           {
       
   447             iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   448             CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   449 						CleanupStack::PushL(deviceLockStatusObserver);
       
   450 						err =KErrNone;
       
   451             TRAP(err,ret = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY));         
       
   452 						CleanupStack::PopAndDestroy(deviceLockStatusObserver);
       
   453           }
       
   454             
       
   455             // check if CSecurityHandler has been "killed"
       
   456             if ( thisDestroyed )
       
   457                 {
       
   458                 return EFalse;
       
   459                 }
       
   460     
       
   461             iDestroyedPtr = NULL;
       
   462             iSecurityDlg = NULL;
       
   463             
       
   464             if (err != KErrNone)
       
   465                 {
       
   466                 User::Leave(err);
       
   467                 }
       
   468 
       
   469             if (!ret)
       
   470                 break;
       
   471         } // while
   333         } // while
   472     }    // if
       
   473 
   334 
   474     iQueryCanceled = ETrue;
   335     iQueryCanceled = ETrue;
   475     return ret;
   336     return ret;
   476     }
   337     }
   477 //
   338 //
   546             #if defined(_DEBUG)
   407             #if defined(_DEBUG)
   547             RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting"));
   408             RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Call SetLockSetting"));
   548             #endif
   409             #endif
   549 
   410 
   550 #ifdef RD_REMOTELOCK
   411 #ifdef RD_REMOTELOCK
   551 
       
   552             // If remote lock is enabled, don't disable the domestic OS device lock
   412             // If remote lock is enabled, don't disable the domestic OS device lock
   553             // since that would render the RemoteLock useless.
   413             // since that would render the RemoteLock useless.
   554             // Instead just re-set the DOS lock to enabled which as a side effect
   414             // Instead just re-set the DOS lock to enabled which as a side effect
   555             // requests the security code from the user.
   415             // requests the security code from the user.
   556 
   416 
   619                 params().iStartup = EFalse;
   479                 params().iStartup = EFalse;
   620                 #if defined(_DEBUG)
   480                 #if defined(_DEBUG)
   621     			RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Start Notifier"));
   481     			RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() Start Notifier"));
   622     			#endif
   482     			#endif
   623                 codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid,params, response);
   483                 codeQueryNotifier.StartNotifierAndGetResponse(wait->iStatus, KSecurityNotifierUid,params, response);
       
   484                 // this will eventually call PassPhraseRequiredL
   624                 res = wait->WaitForRequestL();
   485                 res = wait->WaitForRequestL();
   625                 CleanupStack::PopAndDestroy(); // wait
   486                 CleanupStack::PopAndDestroy(); // wait
   626               	#if defined(_DEBUG)
   487               	#if defined(_DEBUG)
   627             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() results:"));
   488             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() results:"));
   628             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() res:%d"), res);
   489             	RDebug::Print(_L("(SECUI)CSecurityHandler::AskSecCodeInAutoLockL() res:%d"), res);
   736     #if defined(_DEBUG)
   597     #if defined(_DEBUG)
   737     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()"));
   598     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()"));
   738     #endif
   599     #endif
   739     TBool StartUp = iStartup;
   600     TBool StartUp = iStartup;
   740 
   601 
   741     RMobilePhone::TMobilePassword password;
   602     RMobilePhone::TMobilePassword iSecUi_password;
   742     RMobilePhone::TMobilePassword required_fourth;
   603     RMobilePhone::TMobilePassword required_fourth;
   743     TInt status;
   604 	  TBool queryAccepted = EFalse;
   744     TInt autolockState;
   605 
       
   606     TInt status=0;
       
   607     TInt autolockState=0;
       
   608     TInt lCancelSupported=0;
       
   609     TInt lEmergencySupported=0;
       
   610     
   745     TInt err( KErrGeneral );
   611     TInt err( KErrGeneral );
   746     err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
   612     err = RProperty::Get(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, autolockState);
   747     #if defined(_DEBUG)
   613     #if defined(_DEBUG)
   748     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Autolock Status result: %d"), err);
   614     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Autolock Status result: %d"), err);
   749     #endif
   615     #endif
   751         User::LeaveIfError( err );
   617         User::LeaveIfError( err );
   752 TBool isConditionSatisfied = EFalse;
   618 TBool isConditionSatisfied = EFalse;
   753 TInt tarmFlag=0;
   619 TInt tarmFlag=0;
   754 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
   620 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
   755   	{		
   621   	{		
   756 	TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag );    
   622 		TInt tRet = RProperty::Get( KSCPSIDAutolock, SCP_TARM_ADMIN_FLAG_UID, tarmFlag );    
   757     
   623     
   758     if ( tRet != KErrNone )
   624     if ( tRet != KErrNone )
   759         {
   625         {
   760         #if defined(_DEBUG)
   626         #if defined(_DEBUG)
   761         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\
   627         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL():\
   775 		else
   641 		else
   776 		{
   642 		{
   777 		    if (StartUp)
   643 		    if (StartUp)
   778 		    isConditionSatisfied = ETrue;  
   644 		    isConditionSatisfied = ETrue;  
   779 		}
   645 		}
   780 		if (isConditionSatisfied)
       
   781         {
       
   782         #if defined(_DEBUG)
   646         #if defined(_DEBUG)
   783         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1"));
   647         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 1"));
   784         #endif
   648         #endif
   785         // Security code at bootup: No "cancel" softkey; Emergency calls enabled.
   649         // Security code at bootup: No "cancel" softkey; Emergency calls enabled.
   786       if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   650 						RMobilePhone::TMobilePhoneSecurityCode secCodeTypeToAsk = RMobilePhone::ESecurityCodePhonePassword;	// for starters
   787     			FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
   651 			        	
   788     		{                   	    		    		    		
   652 						if (isConditionSatisfied)
   789             // Connect to the SCP server, and request the code query
   653 				        {
   790             RSCPClient scpClient;
   654 				        	// starter or special TARM. NoCancel+Emergency
   791             User::LeaveIfError( scpClient.Connect() );
   655 				        	lCancelSupported = ESecUiCancelNotSupported;
   792             CleanupClosePushL( scpClient );
   656 				        	lEmergencySupported = ESecUiEmergencyNotSupported;
   793                 
   657 				      	}
   794             status = scpClient.SecCodeQuery( password, 
   658 	        	else if (autolockState > EAutolockOff)
   795                                              RSCPClient::SCP_OK_ETEL,
   659 	        		{
   796                                              ETrue,
   660 	        			// from unlock. Cancel+Emergency
   797                                              KSCPEtelRequest );              
   661 				        	lCancelSupported = ESecUiCancelSupported;
   798             // Note that SecCodeQuery doesn't indicate the return value from the dialog            
   662 				        	lEmergencySupported = ESecUiEmergencySupported;
   799         
   663 	        		}
   800             CleanupStack::PopAndDestroy();  //scpClient                                         
   664 	        	else
   801       }  
   665 	        		{
   802       else
   666 	        			// from settings. Cancel+NoEmergency
   803       {     
   667 				        	lCancelSupported = ESecUiCancelSupported;
   804         CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiCodeEtelReqest);
   668 				        	lEmergencySupported = ESecUiEmergencyNotSupported;
   805         if(AknLayoutUtils::PenEnabled())
   669 	        		}
   806             securityDlg->SetEmergencyCallSupportForCBA( ETrue );
   670 
   807         else
   671 						/* request PIN using QT */
   808             securityDlg->SetEmergencyCallSupport(ETrue);
   672 	        	status = KErrNone;
   809         #ifdef __COVER_DISPLAY
   673 						CSecQueryUi *iSecQueryUi;
   810         securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
   674 						RDebug::Printf( "%s %s (%u) CSecQueryUi=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   811         CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided 
   675 						iSecQueryUi = CSecQueryUi::NewL();
   812 		if (covercl) // returns null if __COVER_DISPLAY is not defined
   676 						RDebug::Printf( "%s %s (%u) Copy=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   813     		{
   677 						iSecUi_password.Copy(_L("666"));
   814     		// … -  add data that cover ui is interested in
   678 						RDebug::Printf( "%s %s (%u) SecQueryDialog aType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, lCancelSupported | lEmergencySupported | secCodeTypeToAsk );
   815     		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
   679 						queryAccepted = iSecQueryUi->SecQueryDialog( _L("PassPhraseRequiredL"), iSecUi_password, 4, 8, lCancelSupported | lEmergencySupported | secCodeTypeToAsk );
   816     		covercl->BufStream().CommitL(); // no more data to send so commit buf
   680 						RDebug::Printf( "%s %s (%u) iSecUi_password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   817      		}  
   681 						RDebug::Print( iSecUi_password );
   818         #endif //__COVER_DISPLAY
   682 						RDebug::Printf( "%s %s (%u) delete=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   819         status = securityDlg->ExecuteLD(R_SECURITY_REQUEST_QUERY);
   683 						delete iSecQueryUi;
   820 			}
   684 						RDebug::Printf( "%s %s (%u) done=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   821         }
   685 		        if(queryAccepted)	status=0xFFFFFFFE;	// this is the value returned from iSecurityDlg
   822     else if ( (autolockState > EAutolockOff))    
   686 						/* end request PIN using QT */
   823         {
   687 
   824         #if defined(_DEBUG)
   688 	        // TODO if Emergency was possible, then consider status == ESecUiEmergencyCall
   825         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 2"));
   689 	        /* I don't think I need this
   826         #endif
   690 	        TInt secUiOriginatedQuery(ESecurityUIsETelAPIOriginated);
   827             // Autolock is On. Security event came from user pressing "unlock".
   691         	RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
   828             // Emergency call support must be enabled and there must be a "cancel" softkey.
   692         	CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
   829          if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   693 				  */
   830     				FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))     
   694 
   831 		    		{                                    
   695 TBool wasCancelledOrEmergency = EFalse;		
   832      	    // Connect to the SCP server, and request the code query
       
   833             RSCPClient scpClient;
       
   834             User::LeaveIfError( scpClient.Connect() );
       
   835             CleanupClosePushL( scpClient );
       
   836               
       
   837             status = scpClient.SecCodeQuery( password, 
       
   838                                              RSCPClient::SCP_OK_CANCEL,
       
   839                                              ETrue,
       
   840                                              KSCPEtelRequest );
       
   841             // Note that SecCodeQuery doesn't indicate the return value from the dialog   
       
   842         
       
   843             CleanupStack::PopAndDestroy(); //scpClient
       
   844 		    		}
       
   845 			    else
       
   846 			    {
       
   847         CCodeQueryDialog* securityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   848         if(AknLayoutUtils::PenEnabled())
       
   849             securityDlg->SetEmergencyCallSupportForCBA( ETrue );
       
   850         else
       
   851             securityDlg->SetEmergencyCallSupport(ETrue);
       
   852         #ifdef __COVER_DISPLAY
       
   853         securityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   854         CAknMediatorFacade* covercl = AknMediatorFacade(securityDlg); // uses MOP, so control provided 
       
   855 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   856     	{
       
   857     	// … -  add data that cover ui is interested in
       
   858     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
       
   859     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   860      	}  
       
   861         #endif //__COVER_DISPLAY
       
   862         status = securityDlg->ExecuteLD(R_SECURITY_QUERY);
       
   863 			     }
       
   864         }
       
   865     else    
       
   866         {
       
   867         #if defined(_DEBUG)
       
   868         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() Dialog 3"));
       
   869         #endif
       
   870             // Code query due to a setting change; "Cancel" softkey active;
       
   871             // no emergency call support.
       
   872 	        if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   873 	    			FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
       
   874 	    		{
       
   875      	    // Connect to the SCP server, and request the code query
       
   876             RSCPClient scpClient;
       
   877             User::LeaveIfError( scpClient.Connect() );
       
   878             CleanupClosePushL( scpClient );
       
   879               
       
   880             status = scpClient.SecCodeQuery( password, 
       
   881                                              RSCPClient::SCP_OK_CANCEL,
       
   882                                              EFalse,
       
   883                                              KSCPEtelRequest );            
       
   884             // Note that SecCodeQuery doesn't indicate the return value from the dialog   
       
   885         
       
   886             CleanupStack::PopAndDestroy(); //scpClient
       
   887 			    }
       
   888 			    else
       
   889 			    {
       
   890         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   891         #ifdef __COVER_DISPLAY
       
   892         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
   893         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
       
   894 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
   895     	{
       
   896     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowSecCode); // adds int to additional data to be posted to cover ui
       
   897     	covercl->BufStream().CommitL(); // no more data to send so commit buf
       
   898      	}  
       
   899         #endif //__COVER_DISPLAY
       
   900         // read a flag to see whether the query is SecUi originated.
       
   901         TInt secUiOriginatedQuery(ESecurityUIsETelAPIOriginated);
       
   902         RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
       
   903         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
   904         CleanupStack::PushL(deviceLockStatusObserver);
       
   905         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
   906         CleanupStack::PushL(queryStatusObserver);
       
   907         CSecUiLockObserver* callStatusObserver = NULL;
       
   908         if(secUiOriginatedQuery == ESecurityUIsSystemLockOriginated)
       
   909             {
       
   910                 callStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiCallStateObserver);
       
   911                 CleanupStack::PushL(callStatusObserver);
       
   912             }
       
   913         status = iSecurityDlg->ExecuteLD(R_SECURITY_QUERY);
       
   914         
       
   915         if(callStatusObserver == NULL)
       
   916             CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
   917         else
       
   918             CleanupStack::PopAndDestroy(3); //deviceLockStatusObserver, queryStatusObserver, callStatusObserver
       
   919         iSecurityDlg = NULL;
       
   920 			      }
       
   921         }
       
   922 TBool isCondition = EFalse;		
       
   923 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
   696 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
   924 {
   697 {
   925     if (!status || (status == ESecUiEmergencyCall)  
   698     if (!status || (status == ESecUiEmergencyCall)  
   926         || (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
   699         || (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
   927     isCondition = ETrue;
   700     wasCancelledOrEmergency = ETrue;
   928 }
   701 }
   929 else
   702 else
   930 {
   703 {
   931     if  ( ( status == KErrCancel ) || (status == ESecUiEmergencyCall)  ||
   704     if  ( ( status == KErrCancel ) || (status == ESecUiEmergencyCall)  ||
   932          (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
   705          (status == EAknSoftkeyEmergencyCall) || (status == ESecUiDeviceLocked))
   933     isCondition = ETrue;
   706     wasCancelledOrEmergency = ETrue;
   934 }
   707 }
   935 		if (isCondition)
   708 RDebug::Printf( "%s %s (%u) wasCancelledOrEmergency=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, wasCancelledOrEmergency );
       
   709 			if (wasCancelledOrEmergency)
   936         {
   710         {
   937 		#if defined(_DEBUG)
   711 		#if defined(_DEBUG)
   938 		RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DIALOG ERROR"));
   712 		RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DIALOG ERROR"));
   939 		#endif
   713 		#endif
   940         if (!StartUp)
   714         if (!StartUp)
   947         return KErrCancel;
   721         return KErrCancel;
   948         }
   722         }
   949 
   723 
   950     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   724     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   951      CWait* wait = NULL;
   725      CWait* wait = NULL;
   952 if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements))
   726 
   953 { 
   727         RDebug::Printf( "%s %s (%u) VerifySecurityCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   954         #if defined(_DEBUG)
       
   955         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode"));
       
   956         #endif
       
   957         wait = CWait::NewL();
   728         wait = CWait::NewL();
   958         iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
   729         iPhone.VerifySecurityCode(wait->iStatus,secCodeType, iSecUi_password, required_fourth);
   959         status = wait->WaitForRequestL();
   730         status = wait->WaitForRequestL();
   960         #if defined(_DEBUG)
       
   961         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode STATUS: %d"), status);
   731         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() VerifySecurityCode STATUS: %d"), status);
   962         #endif
       
   963         delete wait;
   732         delete wait;
   964   }
       
   965   else
       
   966   {
       
   967 		wait = NULL;
       
   968   }
       
   969     
   733     
   970     TInt returnValue = status;
   734     TInt returnValue = status;
       
   735         RDebug::Printf( "%s %s (%u) status=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, status );
       
   736         RDebug::Printf( "%s %s (%u) tarmFlag=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, tarmFlag );
       
   737         RDebug::Printf( "%s %s (%u) StartUp=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, StartUp );
   971     switch(status)
   738     switch(status)
   972         {        
   739         {        
   973         case KErrNone:
   740         case KErrNone:
   974             #if defined(_DEBUG)
   741             #if defined(_DEBUG)
   975             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrNone"));
   742             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrNone"));
   997                         #endif
   764                         #endif
   998                         }                    
   765                         }                    
   999                     }                    	            
   766                     }                    	            
  1000 				        if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) 
   767 				        if(!FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements)) 
  1001 				        {           
   768 				        {           
  1002     			RSCPClient scpClient;
   769     						RSCPClient scpClient;
  1003                 User::LeaveIfError( scpClient.Connect() );
   770                 User::LeaveIfError( scpClient.Connect() );
  1004                 CleanupClosePushL( scpClient );
   771                 CleanupClosePushL( scpClient );
  1005                 TSCPSecCode newCode;
   772                 TSCPSecCode newCode;
  1006                 newCode.Copy( password );
   773                 newCode.Copy( iSecUi_password );
  1007                 scpClient.StoreCode( newCode );
   774                 scpClient.StoreCode( newCode );
  1008                 CleanupStack::PopAndDestroy(); //scpClient
   775                 CleanupStack::PopAndDestroy(); //scpClient
  1009                 }
   776                 }
  1010 
   777 
  1011           }
   778           }
  1051                                 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) );
   818                                 RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Autolock and RemoteLock are disabled -> disable DOS device lock" ) );
  1052                                 #endif // _DEBUG
   819                                 #endif // _DEBUG
  1053 
   820 
  1054                                 // Disable DOS device lock setting
   821                                 // Disable DOS device lock setting
  1055                                 wait = CWait::NewL();
   822                                 wait = CWait::NewL();
  1056                                 iCustomPhone.DisablePhoneLock(wait->iStatus,password);
   823                                 iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
  1057                                 wait->WaitForRequestL();
   824                                 wait->WaitForRequestL();
  1058                                 delete wait;
   825                                 delete wait;
  1059                                 }
   826                                 }
  1060                             }
   827                             }
  1061                         else
   828                         else
  1073 
   840 
  1074                         #if defined(_DEBUG)
   841                         #if defined(_DEBUG)
  1075                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock."));
   842                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock."));
  1076                         #endif
   843                         #endif
  1077                         wait = CWait::NewL();
   844                         wait = CWait::NewL();
  1078                         iCustomPhone.DisablePhoneLock(wait->iStatus,password);
   845                         iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
  1079                         wait->WaitForRequestL();
   846                         wait->WaitForRequestL();
  1080                         #if defined(_DEBUG)
   847                         #if defined(_DEBUG)
  1081                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock completed."));
   848                         RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; DisablePhoneLock completed."));
  1082                         #endif
   849                         #endif
  1083                         delete wait;
   850                         delete wait;
  1084 #endif // RD_REMOTELOCK
   851 #endif // RD_REMOTELOCK
  1085                         }
   852                         }
  1086                     }
   853                     }
  1087                 else
   854                 else	// error getting repository
  1088                     {
   855                     {
       
   856         					RDebug::Printf( "%s %s (%u) error getting repository=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1089 #ifdef RD_REMOTELOCK
   857 #ifdef RD_REMOTELOCK
  1090                     // If remote lock is enabled, don't disable the domestic OS device lock
   858                     // If remote lock is enabled, don't disable the domestic OS device lock
  1091                     // since that would render the RemoteLock useless.
   859                     // since that would render the RemoteLock useless.
  1092 
   860 
  1093                     TBool remoteLockStatus( EFalse );
   861                     TBool remoteLockStatus( EFalse );
  1101                             #ifdef _DEBUG
   869                             #ifdef _DEBUG
  1102                             RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock is disabled -> disable DOS device lock" ) );
   870                             RDebug::Print( _L( "(SecUi)CSecurityHandler::PassPhraseRequiredL() - Failed to get Autolock period and RemoteLock is disabled -> disable DOS device lock" ) );
  1103                             #endif // _DEBUG
   871                             #endif // _DEBUG
  1104 
   872 
  1105                             wait = CWait::NewL();
   873                             wait = CWait::NewL();
  1106                             iCustomPhone.DisablePhoneLock(wait->iStatus,password);
   874                             iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
  1107                             wait->WaitForRequestL();
   875                             wait->WaitForRequestL();
  1108                             delete wait;
   876                             delete wait;
  1109                             }
   877                             }
  1110                         }
   878                         }
  1111                     else
   879                     else
  1124                     #if defined(_DEBUG)
   892                     #if defined(_DEBUG)
  1125                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; Could not get autolock period."));
   893                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; Could not get autolock period."));
  1126                     #endif
   894                     #endif
  1127                     // could not get the current autolock time... disable autolock in Domestic OS side. 
   895                     // could not get the current autolock time... disable autolock in Domestic OS side. 
  1128                     wait = CWait::NewL();
   896                     wait = CWait::NewL();
  1129                     iCustomPhone.DisablePhoneLock(wait->iStatus,password);
   897                     iCustomPhone.DisablePhoneLock(wait->iStatus,iSecUi_password);
  1130                     wait->WaitForRequestL();
   898                     wait->WaitForRequestL();
  1131                     #if defined(_DEBUG)
   899                     #if defined(_DEBUG)
  1132                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; NO AUTOLOCK PERIOD; DisablePhoneLock completed."));
   900                     RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL()KErrNone: Startup; NO AUTOLOCK PERIOD; DisablePhoneLock completed."));
  1133                     #endif
   901                     #endif
  1134                     delete wait;
   902                     delete wait;
  1147             #endif
   915             #endif
  1148             CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
   916             CSecuritySettings::ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
  1149             break;
   917             break;
  1150         case KErrGsm0707IncorrectPassword:
   918         case KErrGsm0707IncorrectPassword:
  1151         case KErrAccessDenied:
   919         case KErrAccessDenied:
       
   920             	// TODO should this try again? It seems that it's not asked again.
  1152             #if defined(_DEBUG)
   921             #if defined(_DEBUG)
  1153             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword"));
   922             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() KErrGsm0707IncorrectPassword"));
  1154             #endif
   923             #endif
  1155             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
   924             CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
  1156             break;
   925             break;
  1157         default:
   926         default:
  1158             #if defined(_DEBUG)
   927             #if defined(_DEBUG)
  1159             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DEFAULT"));
   928             RDebug::Print(_L("(SECUI)CSecurityHandler::PassPhraseRequiredL() DEFAULT"));
  1160             #endif
   929             #endif
  1161             CSecuritySettings::ShowErrorNoteL(status);
   930             CSecuritySettings::ShowErrorNoteL(status);
       
   931             	// TODO should this try again? It seems that it's not asked again.
  1162             break;
   932             break;
  1163         }
   933         }
  1164         
   934         
  1165     return returnValue;
   935     return returnValue;
  1166     }
   936     }
  1174     {
   944     {
  1175     /*****************************************************
   945     /*****************************************************
  1176     *    Series 60 Customer / ETel
   946     *    Series 60 Customer / ETel
  1177     *    Series 60  ETel API
   947     *    Series 60  ETel API
  1178     *****************************************************/
   948     *****************************************************/
  1179     
   949 RDebug::Printf( "%s %s (%u) 11=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1180     RMobilePhone::TMobilePassword password;
   950 
       
   951 RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   952 		RMobilePhone::TMobilePassword iSecUi_password;
       
   953 		TInt lCancelSupported = ESecUiCancelNotSupported;
       
   954     TBool queryAccepted = EFalse;
  1181     RMobilePhone::TMobilePassword required_fourth;
   955     RMobilePhone::TMobilePassword required_fourth;
  1182     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1;
   956     RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1;
  1183     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
   957     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
  1184     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
   958     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
  1185     TBool StartUp = ETrue;   
   959     TBool StartUp = ETrue;   
  1186     TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
   960     TInt secUiOriginatedQuery(ESecurityUIsSecUIOriginatedUninitialized);
  1187     TInt err = KErrNone;
   961     TInt err = KErrNone;
  1188     TInt res = KErrGeneral;
   962     TInt res = KErrGeneral;
  1189     CWait* wait = CWait::NewL();
   963     CWait* wait = CWait::NewL();
  1190     CleanupStack::PushL(wait);
   964     CleanupStack::PushL(wait);
       
   965 RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1191     
   966     
  1192 
   967 
  1193     StartUp = iStartup;
   968     StartUp = iStartup;
  1194 
   969 
  1195     #if defined(_DEBUG)
   970     #if defined(_DEBUG)
  1196     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL()"));
   971     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL()"));
  1197     #endif
   972     #endif
  1198 
   973 
       
   974 RDebug::Printf( "%s %s (%u) StartUp=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, StartUp );
  1199     if(!StartUp)
   975     if(!StartUp)
  1200     {
   976     {
  1201         // read a flag to see whether the query is SecUi originated.
   977         // read a flag to see whether the query is SecUi originated. For example, from CSecuritySettings::ChangePinRequestParamsL
  1202         err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
   978         err = RProperty::Get(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, secUiOriginatedQuery);
  1203         
   979         
  1204     if ( err != KErrNone )
   980     if ( err != KErrNone )
  1205         {
   981         {
  1206         #if defined(_DEBUG)
   982         #if defined(_DEBUG)
  1218     }  
   994     }  
  1219     #if defined(_DEBUG)
   995     #if defined(_DEBUG)
  1220     RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg"));
   996     RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg"));
  1221     #endif
   997     #endif
  1222 
   998 
       
   999 RDebug::Printf( "%s %s (%u) StartUp=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, StartUp );
       
  1000 RDebug::Printf( "%s %s (%u) secUiOriginatedQuery=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, secUiOriginatedQuery );
       
  1001 RDebug::Printf( "%s %s (%u) ESecurityUIsSecUIOriginated=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, ESecurityUIsSecUIOriginated );
       
  1002 RDebug::Printf( "%s %s (%u) err=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, err );
  1223     if(StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
  1003     if(StartUp || (secUiOriginatedQuery != ESecurityUIsSecUIOriginated) || (err != KErrNone))
  1224     {	
  1004     {	
  1225         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiCodeEtelReqest);
  1005 				RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1226         if(AknLayoutUtils::PenEnabled())
  1006 					lCancelSupported = ESecUiCancelSupported;
  1227             iSecurityDlg->SetEmergencyCallSupportForCBA( ETrue );
  1007 		}
  1228         else
  1008 		else
  1229             iSecurityDlg->SetEmergencyCallSupport(ETrue);
  1009 			{
  1230         #ifdef __COVER_DISPLAY
  1010         /* TODO do I need this ? */
  1231         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
  1011         /*
  1232         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided 
  1012         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
  1233 		if (covercl) // returns null if __COVER_DISPLAY is not defined
  1013         CleanupStack::PushL(deviceLockStatusObserver);
  1234     	{
  1014         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
  1235     	// … -  add data that cover ui is interested in
  1015         CleanupStack::PushL(queryStatusObserver);
  1236     	covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui
  1016         ...
  1237     	covercl->BufStream().CommitL(); // no more data to send so commit buf
  1017         CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
  1238      	}  
  1018 				*/
  1239         #endif //__COVER_DISPLAY
  1019 				// it will be RMobilePhone::ESecurityCodePin1 , equivalent to ESecUiNone
  1240 
  1020 			}
  1241         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
  1021         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
  1242         iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
  1022         iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
  1243         res = wait->WaitForRequestL();
  1023         res = wait->WaitForRequestL();
  1244         #if defined(_DEBUG)
  1024         #if defined(_DEBUG)
  1245         TInt attempts(codeInfo.iRemainingEntryAttempts);
  1025         TInt attempts(codeInfo.iRemainingEntryAttempts);
  1246         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts query status: %d"), res);
  1026         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts query status: %d"), res);
  1247         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts: %d"), attempts);
  1027         RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Remaining Attempts: %d"), attempts);
  1248         #endif
  1028         #endif
       
  1029 				RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  1030     		#ifdef __WINS__
       
  1031 					RDebug::Printf( "%s %s (%u) emulator can't read PIN attempts=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  1032     			res=KErrNone;
       
  1033     			codeInfo.iRemainingEntryAttempts=3;
       
  1034  		    #endif
       
  1035 
  1249         User::LeaveIfError(res);
  1036         User::LeaveIfError(res);
  1250         
  1037 				/* request PIN using QT */
  1251         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
  1038 				CSecQueryUi *iSecQueryUi;
  1252             res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY);
  1039 				RDebug::Printf( "%s %s (%u) CSecQueryUi=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1253         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
  1040 				iSecQueryUi = CSecQueryUi::NewL();
  1254             {
  1041 				RDebug::Printf( "%s %s (%u) Copy=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1255                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
  1042 				iSecUi_password.Copy(_L("666"));
  1256                 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt);
  1043 				RDebug::Printf( "%s %s (%u) SecQueryDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1257                 CleanupStack::PopAndDestroy(queryPrompt);
  1044 				// TODO use codeInfo.iRemainingEntryAttempts for setting the Caption
  1258             }
  1045 				// TODO ESecUiCodeEtelReqest/ESecUiNone might be useful
  1259         else
  1046 				// TODO also support Emergency
  1260             {
  1047 				queryAccepted = iSecQueryUi->SecQueryDialog( _L("Pin1RequiredL"), iSecUi_password, 4, 8, lCancelSupported | secCodeType /*aMode*/ );
  1261                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT);
  1048 				RDebug::Printf( "%s %s (%u) iSecUi_password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1262                 res = iSecurityDlg->ExecuteLD(R_PIN_REQUEST_QUERY, *queryPrompt);
  1049 				RDebug::Print( iSecUi_password );
  1263                 CleanupStack::PopAndDestroy(queryPrompt);   
  1050 				RDebug::Printf( "%s %s (%u) delete=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1264             }
  1051 				delete iSecQueryUi;
  1265         
  1052 				RDebug::Printf( "%s %s (%u) done=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1266         iSecurityDlg = NULL;
  1053         if(queryAccepted)	res=0xFFFFFFFE;	// this is the value returned from iSecurityDlg
  1267         #if defined(_DEBUG)
  1054         	// TODO handle emergency
  1268     	RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() Execute dlg RESULT: %d"), res);
  1055 				/* end request PIN using QT */
  1269     	#endif
  1056 
       
  1057 				RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  1270         if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
  1058         if ((!res) || (res == ESecUiEmergencyCall) || (res == EAknSoftkeyEmergencyCall))
  1271             { 
  1059             { 
  1272             #if defined(_DEBUG)
  1060             #if defined(_DEBUG)
  1273             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!"));
  1061             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_REQUEST_QUERY CANCEL!"));
  1274             #endif
  1062             #endif
  1275             CleanupStack::PopAndDestroy(wait);   
  1063             CleanupStack::PopAndDestroy(wait);   // TODO this is needed ???
  1276             return KErrCancel;
  1064             return KErrCancel;
  1277             }
  1065             }
  1278     }
  1066         if( lCancelSupported && (!res || (res == ESecUiDeviceLocked)))
  1279     else
  1067         	  {
  1280     {	
  1068         	  // cancel code request
  1281         iSecurityDlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
  1282         #ifdef __COVER_DISPLAY
       
  1283         iSecurityDlg->PublishDialogL(SecondaryDisplay::ECmdShowSecurityQuery, SecondaryDisplay::KCatStartup);
       
  1284         CAknMediatorFacade* covercl = AknMediatorFacade(iSecurityDlg); // uses MOP, so control provided
       
  1285 		if (covercl) // returns null if __COVER_DISPLAY is not defined
       
  1286     		{
       
  1287     		// … -  add data that cover ui is interested in
       
  1288     		covercl->BufStream().WriteInt32L(SecondaryDisplay::EShowPIN1); // adds int to additional data to be posted to cover ui
       
  1289     		covercl->BufStream().CommitL(); // no more data to send so commit buf
       
  1290      		}  
       
  1291         #endif //__COVER_DISPLAY
       
  1292         
       
  1293         wait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1294         iPhone.GetSecurityCodeInfo(wait->iStatus, secCodeType, codeInfoPkg);
       
  1295         res = wait->WaitForRequestL();
       
  1296         User::LeaveIfError(res);
       
  1297         
       
  1298         CSecUiLockObserver* deviceLockStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg);
       
  1299         CleanupStack::PushL(deviceLockStatusObserver);
       
  1300         CSecUiLockObserver* queryStatusObserver = CSecUiLockObserver::NewL(iSecurityDlg, ESecUiRequestStateObserver);
       
  1301         CleanupStack::PushL(queryStatusObserver);
       
  1302         
       
  1303         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
  1304             res = iSecurityDlg->ExecuteLD(R_PIN_QUERY);
       
  1305         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
  1306             {
       
  1307                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts );
       
  1308                 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
  1309                 CleanupStack::PopAndDestroy(queryPrompt);
       
  1310             }
       
  1311         else
       
  1312             {
       
  1313                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT);
       
  1314                 res = iSecurityDlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
  1315                 CleanupStack::PopAndDestroy(queryPrompt);   
       
  1316             }
       
  1317         
       
  1318         CleanupStack::PopAndDestroy(2); //deviceLockStatusObserver, queryStatusObserver
       
  1319         iSecurityDlg = NULL;
       
  1320         if( !res || (res == ESecUiDeviceLocked))
       
  1321             {
       
  1322             #if defined(_DEBUG)
       
  1323             RDebug::Print(_L("CSecurityHandler::Pin1RequiredL() R_PIN_QUERY cancel!"));
       
  1324             #endif 
       
  1325             // cancel code request
       
  1326             iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1);
  1069             iPhone.AbortSecurityCode(RMobilePhone::ESecurityCodePin1);
  1327             CleanupStack::PopAndDestroy(wait);
  1070             CleanupStack::PopAndDestroy(wait);   // TODO this is needed ???
  1328             return KErrCancel;
  1071             return KErrCancel;
  1329             }      
  1072           }
  1330     }
  1073 
  1331     #if defined(_DEBUG)
  1074     #if defined(_DEBUG)
  1332     RDebug::Print(_L("CSecurityNotifier::Pin1RequiredL()VerifySecurityCode"));
  1075     RDebug::Print(_L("CSecurityNotifier::Pin1RequiredL()VerifySecurityCode"));
  1333     #endif
  1076     #endif
  1334     iPhone.VerifySecurityCode(wait->iStatus,secCodeType, password, required_fourth);
  1077 
       
  1078 		RDebug::Printf( "%s %s (%u) iSecUi_password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1079 		RDebug::Print( iSecUi_password );
       
  1080 		iPhone.VerifySecurityCode(wait->iStatus,secCodeType, iSecUi_password, required_fourth);
       
  1081     
  1335     res = wait->WaitForRequestL();
  1082     res = wait->WaitForRequestL();
  1336     CleanupStack::PopAndDestroy(wait); 
  1083     CleanupStack::PopAndDestroy(wait); 
  1337     #if defined(_DEBUG)
  1084     #if defined(_DEBUG)
  1338     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL() VerifySecurityCode STATUS: %d"), res);
  1085     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin1RequiredL() VerifySecurityCode STATUS: %d"), res);
  1339     #endif
  1086     #endif
  1357             }
  1104             }
  1358             break;
  1105             break;
  1359         case KErrGsmSSPasswordAttemptsViolation:
  1106         case KErrGsmSSPasswordAttemptsViolation:
  1360         case KErrLocked:
  1107         case KErrLocked:
  1361             // code blocked; show error note and terminate.
  1108             // code blocked; show error note and terminate.
  1362             // code blocked
  1109             // TODO what if not during Startup? Probably it's Ok since the SIM would had also failed at StartUp
  1363             if(StartUp)
  1110             if(StartUp)
  1364                 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); 
  1111                 CSecuritySettings::ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone); 
  1365             break;
  1112             break;
  1366         case KErrGsm0707SimWrong:
  1113         case KErrGsm0707SimWrong:
  1367             // sim lock active
  1114             // sim lock active
       
  1115             // TODO no error? This is strange
  1368             break;
  1116             break;
  1369         default:
  1117         default:
  1370             CSecuritySettings::ShowErrorNoteL(res);        
  1118             CSecuritySettings::ShowErrorNoteL(res);        
  1371             if(StartUp)
  1119             if(StartUp)
  1372             {        
  1120             {        
  1582     {
  1330     {
  1583     /*****************************************************
  1331     /*****************************************************
  1584     *    Series 60 Customer / ETel
  1332     *    Series 60 Customer / ETel
  1585     *    Series 60  ETel API
  1333     *    Series 60  ETel API
  1586     *****************************************************/
  1334     *****************************************************/
       
  1335 				/* request PIN using QT */
       
  1336 				TBool queryAccepted = EFalse;
       
  1337     		RMobilePhone::TMobilePassword iSecUi_password;
       
  1338 				CSecQueryUi *iSecQueryUi;
       
  1339 				RDebug::Printf( "%s %s (%u) CSecQueryUi=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1340 				iSecQueryUi = CSecQueryUi::NewL();
       
  1341 				RDebug::Printf( "%s %s (%u) Copy=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1342 				iSecUi_password.Copy(_L("666"));
       
  1343 				RDebug::Printf( "%s %s (%u) SecQueryDialog=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1344 				queryAccepted = iSecQueryUi->SecQueryDialog( _L("Pin2RequiredL"), iSecUi_password, 4, 8, RMobilePhone::ESecurityCodePin2 /*aMode*/ );
       
  1345 				RDebug::Printf( "%s %s (%u) iSecUi_password=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1346 				RDebug::Print( iSecUi_password );
       
  1347 				RDebug::Printf( "%s %s (%u) delete=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1348 				delete iSecQueryUi;
       
  1349 				RDebug::Printf( "%s %s (%u) done=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  1350         // if(queryAccepted)	res=0xFFFFFFFE;	// this is the value returned from iSecurityDlg
       
  1351 				/* end request PIN using QT */
       
  1352 
       
  1353 
  1587     #if defined(_DEBUG)
  1354     #if defined(_DEBUG)
  1588     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL() BEGIN"));
  1355     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL() BEGIN"));
  1589     #endif
  1356     #endif
  1590     RMobilePhone::TMobilePassword password;
  1357     RMobilePhone::TMobilePassword password;
  1591     RMobilePhone::TMobilePassword required_fourth;
  1358     RMobilePhone::TMobilePassword required_fourth;