securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
changeset 15 318c4eab2439
parent 0 164170e6151a
child 17 8957df7b0072
equal deleted inserted replaced
14:b75757c81051 15:318c4eab2439
    43 #include <StringLoader.h>
    43 #include <StringLoader.h>
    44 #include <RemoteLockSettings.h>
    44 #include <RemoteLockSettings.h>
    45 #include "SecUiRemoteLockSettingPage.h"
    45 #include "SecUiRemoteLockSettingPage.h"
    46 #endif // RD_REMOTELOCK
    46 #endif // RD_REMOTELOCK
    47 #include <featmgr.h>
    47 #include <featmgr.h>
       
    48 
       
    49 #include "SecQueryUi.h"
       
    50 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
       
    51 
    48     /*****************************************************
    52     /*****************************************************
    49     *    Series 60 Customer / TSY
    53     *    Series 60 Customer / TSY
    50     *    Needs customer TSY implementation
    54     *    Needs customer TSY implementation
    51     *****************************************************/
    55     *****************************************************/
    52 //  LOCAL CONSTANTS AND MACROS  
    56 //  LOCAL CONSTANTS AND MACROS  
   192 // Changes PIN1
   196 // Changes PIN1
   193 // ----------------------------------------------------------
   197 // ----------------------------------------------------------
   194 //
   198 //
   195 EXPORT_C void CSecuritySettings::ChangePinL()
   199 EXPORT_C void CSecuritySettings::ChangePinL()
   196     {
   200     {
   197     /*****************************************************
   201     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   198     *    Series 60 Customer / ETel
   202     RMobilePhone::TMobilePassword iOldPassword;
   199     *    Series 60  ETel API
   203     RMobilePhone::TMobilePassword iNewPassword;
   200     *****************************************************/
   204     TInt iFlags=0;
   201     
   205     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   202     TInt simState;
   206 		iOldPassword.Copy(_L(""));
   203     TInt err( KErrGeneral );
   207     RDebug::Printf( "%s %s (%u) iNewPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   204     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
   208 		iNewPassword.Copy(_L(""));
   205     User::LeaveIfError( err );
   209 
   206     TBool simRemoved(simState == ESimNotPresent);
   210     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   207 
   211     TBuf<0x80> iCaption;
   208     if ( simRemoved )
   212     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   209         {
   213     iCaption.Copy(_L("ChangePinL"));
   210         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
   214     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   211         return;
   215    	RDebug::Print(iCaption);
   212         }
   216     TInt iShowError=1;
   213 
   217   	ChangePinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   214     #if defined(_DEBUG)
   218   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   215     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinL()"));
       
   216     #endif    
       
   217     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   218     secCodeType = RMobilePhone::ESecurityCodePin1;
       
   219 
       
   220     RMobilePhone::TMobilePassword oldPassword;
       
   221     RMobilePhone::TMobilePassword newPassword;
       
   222     RMobilePhone::TMobilePassword verifcationPassword;
       
   223     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
   224     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
   225     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
   226 
       
   227     CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   228     CleanupStack::PushL(verdlg);
       
   229 
       
   230     CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog(newPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   231     CleanupStack::PushL(newdlg);
       
   232 
       
   233     CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (oldPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);       
       
   234     CleanupStack::PushL(dlg);
       
   235 
       
   236     RMobilePhone::TMobilePhoneLock lockType;
       
   237     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
   238     
       
   239     lockType = RMobilePhone::ELockICC;
       
   240 
       
   241     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
   242     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
   243     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
   244     TInt res = iWait->WaitForRequestL();
       
   245     User::LeaveIfError(res);
       
   246 
       
   247     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
   248         {    
       
   249         CleanupStack::PopAndDestroy(3,verdlg);
       
   250         ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   251         return;
       
   252         }
       
   253     
       
   254     CleanupStack::Pop(); // dlg
       
   255     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
   256     iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
       
   257     res = iWait->WaitForRequestL();
       
   258     User::LeaveIfError(res);
       
   259     // ask pin
       
   260     if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
   261             res = dlg->ExecuteLD(R_PIN_QUERY);
       
   262     else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
   263        {
       
   264          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
   265          res = dlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
   266          CleanupStack::PopAndDestroy(queryPrompt);
       
   267        }
       
   268     else
       
   269        {
       
   270          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN_ATTEMPT);
       
   271          res = dlg->ExecuteLD(R_PIN_QUERY, *queryPrompt);
       
   272          CleanupStack::PopAndDestroy(queryPrompt);   
       
   273        }  
       
   274     
       
   275       if( !res )
       
   276         {
       
   277         CleanupStack::PopAndDestroy(2,verdlg);
       
   278         return;
       
   279         }      
       
   280     CleanupStack::Pop(); // newdlg
       
   281     // new pin code query
       
   282      if (!(newdlg->ExecuteLD(R_NEW_PIN_CODE_QUERY)))
       
   283         {
       
   284         CleanupStack::PopAndDestroy(verdlg);
       
   285         return;
       
   286         }
       
   287 
       
   288     CleanupStack::Pop(); // verdlg
       
   289     // verification code query
       
   290     if (!(verdlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_QUERY)))
       
   291             return;
       
   292         
       
   293     while (newPassword.CompareF(verifcationPassword) != 0) 
       
   294         {
       
   295         // codes do not match -> note -> ask new pin and verification codes again  
       
   296         ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
   297     
       
   298         newPassword = _L("");
       
   299         verifcationPassword = _L("");
       
   300 
       
   301         // new pin code query
       
   302         CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog (newPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   303         if (!(newdlg->ExecuteLD(R_NEW_PIN_CODE_QUERY)))
       
   304               return;
       
   305         
       
   306         // verification code query
       
   307         CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   308         if (!(verdlg->ExecuteLD(R_VERIFY_NEW_PIN_CODE_QUERY)))
       
   309             return;
       
   310         }            
       
   311         
       
   312     // send code
       
   313     passwords.iOldPassword = oldPassword;
       
   314     passwords.iNewPassword = newPassword;
       
   315     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
   316     iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
       
   317     res = iWait->WaitForRequestL();
       
   318     #if defined(_DEBUG)
       
   319     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinL(): RETURN CODE: %d"), res);
       
   320     #endif
       
   321     switch(res)
       
   322         {
       
   323         case KErrNone:
       
   324             {
       
   325             // code changed 
       
   326             ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
   327             break;
       
   328             }        
       
   329         case KErrGsm0707IncorrectPassword:
       
   330         case KErrAccessDenied:
       
   331             {    
       
   332             // code was entered erroneously
       
   333             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
   334             ChangePinL();
       
   335             break;
       
   336             }    
       
   337         case KErrGsmSSPasswordAttemptsViolation:
       
   338         case KErrLocked:
       
   339             {
       
   340             // Pin1 blocked! 
       
   341             return;
       
   342             }
       
   343         case KErrGsm0707OperationNotAllowed:
       
   344             {
       
   345             // not allowed with this sim
       
   346             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   347             return;
       
   348             }
       
   349         case KErrAbort:
       
   350             {
       
   351             break;
       
   352             }
       
   353         default:
       
   354             {
       
   355             ShowErrorNoteL(res);
       
   356             ChangePinL();
       
   357             break;
       
   358             }
       
   359         }
       
   360 
       
   361     }
   219     }
   362 
   220 
   363 //
   221 //
   364 // ----------------------------------------------------------
   222 // ----------------------------------------------------------
   365 // CSecuritySettings::ChangeUPinL()
   223 // CSecuritySettings::ChangeUPinL()
   740 // CSecuritySettings::ChangeSecCodeL()
   598 // CSecuritySettings::ChangeSecCodeL()
   741 // Changes security code 
   599 // Changes security code 
   742 // ----------------------------------------------------------
   600 // ----------------------------------------------------------
   743 //
   601 //
   744 EXPORT_C void CSecuritySettings::ChangeSecCodeL()
   602 EXPORT_C void CSecuritySettings::ChangeSecCodeL()
   745     {  
   603     {
   746     /*****************************************************
   604     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   747     *    Series 60 Customer / ETel
   605     RMobilePhone::TMobilePassword iOldPassword;
   748     *    Series 60  ETel API
   606     RMobilePhone::TMobilePassword iNewPassword;
   749     *****************************************************/
   607     TInt iFlags=0;
   750     #if defined(_DEBUG)
   608     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   751     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSecCodeL()"));
   609 		iOldPassword.Copy(_L(""));
   752     #endif
   610     RDebug::Printf( "%s %s (%u) iNewPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   753     TInt res;
   611 		iNewPassword.Copy(_L(""));
   754     RMobilePhone::TMobilePassword newPassword;
   612 
   755 if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
   613     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   756 		(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements  )))   
   614     TBuf<0x80> iCaption;
   757 { 
   615     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   758     
   616     iCaption.Copy(_L("ChangeSecCodeL"));
   759     // Connect to the SCP server, and request the code change
   617     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   760     RSCPClient scpClient;
   618    	RDebug::Print(iCaption);
   761     User::LeaveIfError( scpClient.Connect() );
   619     TInt iShowError=1;
   762     CleanupClosePushL( scpClient );
   620   	ChangeSecCodeParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   763     res = scpClient.ChangeCodeRequest();
   621   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   764     CleanupStack::PopAndDestroy(); // scpClient
       
   765     
       
   766 }
       
   767 else
       
   768 {
       
   769          
       
   770     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   771     secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
   772     RMobilePhone::TMobilePassword oldPassword;
       
   773     RMobilePhone::TMobilePassword verifcationPassword;
       
   774     RMobilePhone::TMobilePassword required_fourth;
       
   775     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
   776 
       
   777     CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_CHANGE_MAX_LENGTH,ESecUiNone);
       
   778     CleanupStack::PushL(verdlg);
       
   779 
       
   780     CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog(newPassword,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_CHANGE_MAX_LENGTH,ESecUiNone);
       
   781     CleanupStack::PushL(newdlg);
       
   782 
       
   783     CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (oldPassword,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_MAX_LENGTH,ESecUiNone);
       
   784     CleanupStack::PushL(dlg);
       
   785 
       
   786     // ask security code
       
   787     CleanupStack::Pop(); // dlg
       
   788     if (!(dlg->ExecuteLD(R_SECURITY_QUERY)))
       
   789         {
       
   790         CleanupStack::PopAndDestroy(2,verdlg);
       
   791         return;
       
   792         }
       
   793     // new security code query
       
   794     CleanupStack::Pop(); // newdlg
       
   795     if(!(newdlg->ExecuteLD(R_NEW_SECURITY_CODE_QUERY)))
       
   796         {    
       
   797         CleanupStack::PopAndDestroy(verdlg);
       
   798         return;
       
   799         }
       
   800      
       
   801     // verification code query
       
   802     CleanupStack::Pop(); // verdlg
       
   803       if(!(verdlg->ExecuteLD(R_VERIFY_NEW_SECURITY_CODE_QUERY)))
       
   804         {
       
   805         return;
       
   806         }
       
   807 
       
   808     while (newPassword.CompareF(verifcationPassword) != 0)         
       
   809         {            
       
   810         // codes do not match -> note -> ask new pin and verification codes again  
       
   811         ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
   812         
       
   813         newPassword = _L("");
       
   814         verifcationPassword = _L("");
       
   815 
       
   816         // new pin code query
       
   817         CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (newPassword,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_CHANGE_MAX_LENGTH,ESecUiNone);
       
   818         if(!(dlg->ExecuteLD(R_NEW_SECURITY_CODE_QUERY)))
       
   819             return;
       
   820           
       
   821         // verification code query
       
   822         CCodeQueryDialog* dlg2 = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_SECURITY_CODE_MIN_LENGTH,SEC_C_SECURITY_CODE_CHANGE_MAX_LENGTH,ESecUiNone);
       
   823           if(!(dlg2->ExecuteLD(R_VERIFY_NEW_SECURITY_CODE_QUERY)))
       
   824             return;    
       
   825         }            
       
   826     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);    
       
   827     // check code
       
   828     iPhone.VerifySecurityCode(iWait->iStatus,secCodeType, oldPassword, required_fourth);
       
   829     res = iWait->WaitForRequestL();
       
   830     #if defined(_DEBUG)
       
   831     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSecCode(): CODE VERIFY RESP: %d"), res);
       
   832     #endif
       
   833     // change code 
       
   834     if (res == KErrNone)
       
   835         {
       
   836         passwords.iOldPassword = oldPassword;
       
   837         passwords.iNewPassword = newPassword;
       
   838         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
   839         iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,passwords);
       
   840         res = iWait->WaitForRequestL();
       
   841         }
       
   842         
       
   843 }
       
   844         
       
   845     #if defined(_DEBUG)
       
   846     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSecCode(): RETURN CODE: %d"), res);
       
   847     #endif
       
   848     switch(res)
       
   849         {
       
   850         case KErrNone:
       
   851             {
       
   852             // code changed 
       
   853             ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
   854             if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
   855 								!(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements  )))
       
   856 						{
       
   857             // Send the changed code to the SCP server. Not used with device lock enhancements.
       
   858             
       
   859             RSCPClient scpClient;
       
   860             TSCPSecCode newCode;
       
   861             newCode.Copy( newPassword );
       
   862             if ( scpClient.Connect() == KErrNone )
       
   863                 {
       
   864                 scpClient.StoreCode( newCode );
       
   865                 scpClient.Close();
       
   866                 }                                               
       
   867           }
       
   868                         
       
   869             break;
       
   870             }
       
   871         case KErrGsmSSPasswordAttemptsViolation:
       
   872         case KErrLocked:
       
   873             {
       
   874             ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
       
   875             ChangeSecCodeL();
       
   876             break;
       
   877             }
       
   878         case KErrGsm0707IncorrectPassword:
       
   879         case KErrAccessDenied:
       
   880             {    
       
   881             // code was entered erroneously
       
   882             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
   883             ChangeSecCodeL();
       
   884             break;
       
   885             }
       
   886         case KErrAbort:
       
   887             {
       
   888             break;
       
   889             }
       
   890         default:
       
   891             {
       
   892             ShowErrorNoteL(res);
       
   893             ChangeSecCodeL();
       
   894             break;
       
   895             }
       
   896         }
       
   897     }
   622     }
   898 //
   623 //
   899 // ----------------------------------------------------------
   624 // ----------------------------------------------------------
   900 // CSecuritySettings::ChangeAutoLockPeriodL()
   625 // CSecuritySettings::ChangeAutoLockPeriodL()
   901 // Changes autolock period
   626 // Changes autolock period
  1582         currentItem = 1;  // off
  1307         currentItem = 1;  // off
  1583         }
  1308         }
  1584                         
  1309                         
  1585     TInt oldItem = currentItem;
  1310     TInt oldItem = currentItem;
  1586 
  1311 
  1587     CAknRadioButtonSettingPage* dlg = new (ELeave)CAknRadioButtonSettingPage(R_SECURITY_SETTING_PAGE, currentItem, items);
       
  1588     CleanupStack::PushL(dlg);
       
  1589     
       
  1590 
       
  1591     CleanupStack::Pop(); // dlg
       
  1592     if ( !(dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) || oldItem==currentItem )
       
  1593         {
       
  1594         CleanupStack::PopAndDestroy();    // items
       
  1595         return EFalse;
       
  1596         }    
       
  1597 
       
  1598 
       
  1599 
  1312 
  1600     if (currentItem == 1)
  1313     if (currentItem == 1)
  1601         {
  1314         {
  1602         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1315         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1603         }
  1316         }
  1604     else
  1317     else
  1605         {
  1318         {
  1606         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1319         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1607         }
  1320         }
  1608 
  1321 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1609     CleanupStack::PopAndDestroy();    // items 
       
  1610     
  1322     
  1611     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1323     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1612     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1324     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1613     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
  1325     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
  1614     status = iWait->WaitForRequestL();
  1326     status = iWait->WaitForRequestL();
  1652 // Changes PIN1 request
  1364 // Changes PIN1 request
  1653 // ----------------------------------------------------------
  1365 // ----------------------------------------------------------
  1654 //
  1366 //
  1655 EXPORT_C TBool CSecuritySettings::ChangePinRequestL()
  1367 EXPORT_C TBool CSecuritySettings::ChangePinRequestL()
  1656     {    
  1368     {    
  1657     /*****************************************************
  1369     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1658     *    Series 60 Customer / ETel
  1370     RMobilePhone::TMobilePassword iOldPassword;
  1659     *    Series 60  ETel API
  1371     TInt iFlags=0;
  1660     *****************************************************/
  1372     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1661     #if defined(_DEBUG)
  1373 		iOldPassword.Copy(_L(""));
  1662     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL()"));
  1374 
  1663     #endif      
  1375     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1664     TInt simState;
  1376     TBuf<0x80> iCaption;
  1665     TInt err( KErrGeneral );
  1377     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1666     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  1378     iCaption.Copy(_L("ChangePinRequestL"));
  1667     User::LeaveIfError( err );
  1379     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1668     TBool simRemoved(simState == ESimNotPresent);
  1380    	RDebug::Print(iCaption);
  1669 
  1381     TInt iShowError=1;
  1670     if ( simRemoved )
  1382   	ChangePinRequestParamsL(1/* TODO it's imposible to know if we want to set or clear*/, iOldPassword, iFlags, iCaption, iShowError);
  1671         {
  1383   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1672         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  1384 
  1673         return EFalse;;
       
  1674         }
       
  1675 
       
  1676     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
  1677     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
  1678     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
       
  1679 
       
  1680     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
       
  1681     
       
  1682     CCoeEnv* coeEnv = CCoeEnv::Static();
       
  1683     CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL(R_PIN_LBX);
       
  1684     CleanupStack::PushL(items);
       
  1685                         
       
  1686     //get lock info
       
  1687     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
  1688     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  1689     TInt status = iWait->WaitForRequestL();
       
  1690     User::LeaveIfError(status);                    
       
  1691     TInt currentItem = 0;
       
  1692 
       
  1693     #if defined(_DEBUG)
       
  1694     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() GetLockInfo"));
       
  1695     #endif
       
  1696 
       
  1697     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
  1698         {
       
  1699         #if defined(_DEBUG)
       
  1700         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() lockInfo: ELockSetDisabled"));
       
  1701         #endif
       
  1702         currentItem = 1;  // off
       
  1703         }
       
  1704                         
       
  1705     TInt oldItem = currentItem;
       
  1706 
       
  1707     CAknRadioButtonSettingPage* dlg = new (ELeave)CAknRadioButtonSettingPage(R_PIN_SETTING_PAGE, currentItem, items);
       
  1708     CleanupStack::PushL(dlg);
       
  1709     
       
  1710 
       
  1711     CleanupStack::Pop(); // dlg
       
  1712     if ( !(dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) || oldItem==currentItem )
       
  1713         {
       
  1714         CleanupStack::PopAndDestroy();    // items
       
  1715         return EFalse;
       
  1716         }    
       
  1717 
       
  1718 
       
  1719     if (currentItem == 1)
       
  1720         {
       
  1721         #if defined(_DEBUG)
       
  1722         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetDisabled"));
       
  1723         #endif
       
  1724         lockChangeSetting = RMobilePhone::ELockSetDisabled;
       
  1725         }
       
  1726     else
       
  1727         {
       
  1728         #if defined(_DEBUG)
       
  1729         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetEnabled"));
       
  1730         #endif
       
  1731         lockChangeSetting = RMobilePhone::ELockSetEnabled;
       
  1732         }
       
  1733 
       
  1734     CleanupStack::PopAndDestroy();    // items 
       
  1735 
       
  1736     // Raise a flag to indicate that the PIN
       
  1737     // request coming from ETEL has originated from SecUi and not from Engine.
       
  1738     TInt tRet = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
       
  1739     if ( tRet != KErrNone )
       
  1740         {
       
  1741         #if defined(_DEBUG)
       
  1742         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL():\
       
  1743             FAILED to set the SECUI query Flag: %d"), tRet);
       
  1744         #endif
       
  1745         }
       
  1746     // Change the lock setting
       
  1747     iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
  1748     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
  1749     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
       
  1750     status = iWait->WaitForRequestL();
       
  1751     #if defined(_DEBUG)
       
  1752     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinRequestL(): RETURN CODE: %d"), status);
       
  1753     #endif
       
  1754 
       
  1755     // Lower the flag                             
       
  1756     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
       
  1757 
       
  1758     switch(status)
       
  1759         {
       
  1760         case KErrNone:
       
  1761             {
       
  1762             break;
       
  1763             }
       
  1764         case KErrGsm0707OperationNotAllowed:
       
  1765             {
       
  1766             // not allowed with this sim
       
  1767             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  1768             return EFalse;
       
  1769             }
       
  1770         case KErrGsm0707IncorrectPassword:
       
  1771         case KErrAccessDenied:
       
  1772             {    
       
  1773             // code was entered erroneously
       
  1774             return ChangePinRequestL();
       
  1775             }    
       
  1776         case KErrGsmSSPasswordAttemptsViolation:
       
  1777         case KErrLocked:
       
  1778             {
       
  1779             return ETrue;
       
  1780             }
       
  1781         case KErrAbort:
       
  1782             {
       
  1783             return EFalse;
       
  1784             }
       
  1785         default:
       
  1786             {
       
  1787             return ChangePinRequestL();
       
  1788             }
       
  1789         }
       
  1790     
       
  1791     return ETrue;
  1385     return ETrue;
  1792     }
  1386     }
  1793 
  1387 
  1794 //
  1388 //
  1795 // ----------------------------------------------------------
  1389 // ----------------------------------------------------------
  1863     
  1457     
  1864     
  1458     
  1865        if (currentItem == 1)
  1459        if (currentItem == 1)
  1866             {
  1460             {
  1867             #if defined(_DEBUG)
  1461             #if defined(_DEBUG)
  1868             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetDisabled"));
  1462             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetDisabled"));
  1869             #endif
  1463             #endif
  1870             lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1464             lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1871             }
  1465             }
  1872         else
  1466         else
  1873             {
  1467             {
  1874             #if defined(_DEBUG)
  1468             #if defined(_DEBUG)
  1875             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetEnabled"));
  1469             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetEnabled"));
  1876             #endif
  1470             #endif
  1877             lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1471             lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1878             }
  1472             }
  1879     
  1473     
  1880         CleanupStack::PopAndDestroy();    // items 
  1474         CleanupStack::PopAndDestroy();    // items 
  2426 void CSecuritySettings::ShowErrorNoteL(TInt aError)
  2020 void CSecuritySettings::ShowErrorNoteL(TInt aError)
  2427     {
  2021     {
  2428     #if defined(_DEBUG)
  2022     #if defined(_DEBUG)
  2429     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowErrorNoteL()"));
  2023     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowErrorNoteL()"));
  2430     #endif
  2024     #endif
  2431     // Let's create TextResolver instance for error resolving...
  2025    	RDebug::Printf( "%s %s (%u) aError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aError );  
  2432     CTextResolver* textresolver = CTextResolver::NewLC(); 
  2026     
  2433     // Resolve the error
  2027     ShowResultNoteL(aError, CAknNoteDialog::EErrorTone);
  2434     TPtrC errorstring;
       
  2435     errorstring.Set( textresolver->ResolveErrorString( aError ) );
       
  2436     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
       
  2437     noteDlg->PrepareLC(R_CODE_ERROR);
       
  2438     noteDlg->SetTextL((TDesC&)errorstring);
       
  2439     noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
  2440     noteDlg->SetTone(CAknNoteDialog::EErrorTone);
       
  2441     noteDlg->RunLD();
       
  2442     CleanupStack::PopAndDestroy(); // resolver    
       
  2443     }
  2028     }
  2444 
  2029 
  2445 //
  2030 //
  2446 // ----------------------------------------------------------
  2031 // ----------------------------------------------------------
  2447 // CSecuritySettings::ShowResultNoteL()
  2032 // CSecuritySettings::ShowResultNoteL()
  2452     {  
  2037     {  
  2453     #if defined(_DEBUG)
  2038     #if defined(_DEBUG)
  2454     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL()"));
  2039     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL()"));
  2455     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL() Resource ID: %d"), aResourceID);
  2040     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL() Resource ID: %d"), aResourceID);
  2456     #endif
  2041     #endif
       
  2042     RDebug::Printf( "%s %s (%u) aResourceID=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aResourceID );
       
  2043     
       
  2044     /*
  2457     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
  2045     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
  2458     noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
  2046     noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
  2459     noteDlg->SetTone(aTone);
  2047     noteDlg->SetTone(aTone);
  2460     noteDlg->ExecuteLD(aResourceID);
  2048     noteDlg->ExecuteLD(aResourceID);
       
  2049     */
       
  2050     CHbDeviceMessageBoxSymbian* messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
       
  2051     CleanupStack::PushL(messageBox);
       
  2052     _LIT(KText, "ShowResultNoteL: ");
       
  2053 		TBuf<0x200> title;
       
  2054 		title.Zero();
       
  2055 		title.Append(KText);
       
  2056 		title.AppendNum(aResourceID);
       
  2057     _LIT(KSeparator, " ");
       
  2058 		title.Append(KSeparator);
       
  2059     switch(aResourceID)
       
  2060     {
       
  2061     	case 0:
       
  2062 	    	title.Append(_L("OK"));
       
  2063 	    	break;
       
  2064     	case KErrGsm0707IncorrectPassword:
       
  2065     		title.Append(_L("KErrGsm0707IncorrectPassword"));
       
  2066 	    	break;
       
  2067     	case KErrAccessDenied:
       
  2068 	    	title.Append(_L("KErrAccessDenied"));
       
  2069 	    	break;
       
  2070     	case KErrGsmSSPasswordAttemptsViolation:
       
  2071   	  	title.Append(_L("KErrGsmSSPasswordAttemptsViolation"));
       
  2072 	    	break;
       
  2073     	case KErrLocked:
       
  2074     		title.Append(_L("KErrLocked"));
       
  2075 	    	break;
       
  2076     	case KErrGsm0707OperationNotAllowed:
       
  2077     		title.Append(_L("KErrGsm0707OperationNotAllowed"));
       
  2078 	    	break;
       
  2079     	case KErrAbort:
       
  2080 	    	title.Append(_L("KErrAbort"));
       
  2081 	    	break;
       
  2082     	case KErrNotSupported:
       
  2083   	  	title.Append(_L("KErrNotSupported"));
       
  2084 	    	break;
       
  2085     	case R_SEC_BLOCKED:
       
  2086   	  	title.Append(_L("R_SEC_BLOCKED"));
       
  2087 	    	break;
       
  2088     	case R_CODE_ERROR:
       
  2089   	  	title.Append(_L("R_CODE_ERROR"));
       
  2090 	    	break;
       
  2091     	case KErrGsmInvalidParameter:
       
  2092   	  	title.Append(_L("KErrGsmInvalidParameter"));
       
  2093 	    	break;
       
  2094     	case R_CONFIRMATION_NOTE:
       
  2095   	  	title.Append(_L("R_CONFIRMATION_NOTE"));
       
  2096 	    	break;
       
  2097     	case R_CODES_DONT_MATCH:
       
  2098   	  	title.Append(_L("R_CODES_DONT_MATCH"));
       
  2099 	    	break;
       
  2100     	case R_PIN_CODE_CHANGED_NOTE:
       
  2101   	  	title.Append(_L("R_PIN_CODE_CHANGED_NOTE"));
       
  2102 	    	break;
       
  2103     	case R_SECURITY_CODE_CHANGED_NOTE:
       
  2104   	  	title.Append(_L("R_SECURITY_CODE_CHANGED_NOTE"));
       
  2105 	    	break;
       
  2106     	default:
       
  2107     		title.Append(_L("Specific Error"));
       
  2108 	    	break;
       
  2109 		}
       
  2110 	  messageBox->SetTextL(title);
       
  2111 		RDebug::Printf( "%s %s (%u) aResourceID=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aResourceID );
       
  2112 	
       
  2113     _LIT(KIconName, "qtg_small_smiley_wondering");
       
  2114     messageBox->SetIconNameL(KIconName);
       
  2115 
       
  2116     messageBox->ExecL();
       
  2117     CleanupStack::PopAndDestroy(); // messageBox
       
  2118 
  2461     }
  2119     }
  2462 
  2120 
  2463 //
  2121 //
  2464 // ----------------------------------------------------------
  2122 // ----------------------------------------------------------
  2465 // CSecuritySettings::IsUpinSupportedL()
  2123 // CSecuritySettings::IsUpinSupportedL()
  2598       }
  2256       }
  2599     else
  2257     else
  2600         return EFalse;
  2258         return EFalse;
  2601 }
  2259 }
  2602 
  2260 
       
  2261 EXPORT_C TInt  CSecuritySettings::ChangePinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2262 	{
       
  2263 	TInt ret = KErrNone;
       
  2264 	RDebug::Printf( "%s %s (%u) aFlags=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags );
       
  2265 	RDebug::Printf( "%s %s (%u) aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2266 	RDebug::Print(aOldPassword);
       
  2267 	RDebug::Printf( "%s %s (%u) aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2268 	RDebug::Print(aNewPassword);
       
  2269 	RDebug::Printf( "%s %s (%u) aCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2270 	RDebug::Print(aCaption);
       
  2271 	RDebug::Printf( "%s %s (%u) aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aShowError );
       
  2272 
       
  2273 
       
  2274     /*****************************************************
       
  2275     *    Series 60 Customer / ETel
       
  2276     *    Series 60  ETel API
       
  2277     *****************************************************/
       
  2278     
       
  2279     TInt simState;
       
  2280     TInt err( KErrGeneral );
       
  2281     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
  2282     User::LeaveIfError( err );
       
  2283     TBool simRemoved(simState == ESimNotPresent);
       
  2284 
       
  2285     if ( simRemoved )
       
  2286         {
       
  2287         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
  2288         return;
       
  2289         }
       
  2290     #if defined(_DEBUG)
       
  2291     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinParamsL()"));
       
  2292     #endif    
       
  2293     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
  2294     secCodeType = RMobilePhone::ESecurityCodePin1;
       
  2295 
       
  2296     RMobilePhone::TMobilePassword oldPassword;
       
  2297     RMobilePhone::TMobilePassword newPassword;
       
  2298     RMobilePhone::TMobilePassword verifcationPassword;
       
  2299     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
  2300     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  2301     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  2302 		TBool queryAccepted = EFalse;
       
  2303 
       
  2304 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2305 
       
  2306     RMobilePhone::TMobilePhoneLock lockType;
       
  2307     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
  2308     
       
  2309     lockType = RMobilePhone::ELockICC;
       
  2310 
       
  2311     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
  2312     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2313     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
  2314     #ifndef __WINS__    
       
  2315     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  2316     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2317     TInt res = iWait->WaitForRequestL();
       
  2318     #else
       
  2319     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2320     TInt res = KErrNone;
       
  2321     #endif
       
  2322     User::LeaveIfError(res);
       
  2323 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2324 			
       
  2325     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
  2326         {    
       
  2327 				RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2328         // CleanupStack::PopAndDestroy(1,dlg);	// TODO sure about dlg ?
       
  2329         ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2330         return;
       
  2331         }
       
  2332     
       
  2333    	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2334     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  2335     #ifndef __WINS__    
       
  2336     iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
       
  2337     res = iWait->WaitForRequestL();
       
  2338     #else
       
  2339     res = KErrNone;
       
  2340     #endif
       
  2341     User::LeaveIfError(res);
       
  2342    	RDebug::Printf( "%s %s (%u) codeInfo.iRemainingEntryAttempts=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, codeInfo.iRemainingEntryAttempts );
       
  2343  		codeInfo.iRemainingEntryAttempts=KMaxNumberOfPINAttempts;
       
  2344 
       
  2345    	RDebug::Printf( "%s %s (%u) checking aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2346 		if(aOldPassword.Length()==0)
       
  2347 			{
       
  2348    		RDebug::Printf( "%s %s (%u) asking aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2349 			/* request PIN using QT */
       
  2350 			queryAccepted = EFalse;
       
  2351 			CSecQueryUi *iSecQueryUi;
       
  2352 			iSecQueryUi = CSecQueryUi::NewL();
       
  2353 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-Old"), oldPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2354 			RDebug::Printf( "%s %s (%u) oldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2355 			RDebug::Print( oldPassword );
       
  2356 			RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2357 			delete iSecQueryUi;
       
  2358 			if(!queryAccepted)
       
  2359 					return;
       
  2360 			res=1;	// indicate that everything is ok
       
  2361 			/* end request PIN using QT */
       
  2362 			newPassword = _L("");
       
  2363 	    verifcationPassword = _L("");
       
  2364 			}
       
  2365 		else
       
  2366 			{
       
  2367 			oldPassword.Copy(aOldPassword);
       
  2368 			newPassword.Copy(aNewPassword);
       
  2369 			verifcationPassword.Copy(aNewPassword);
       
  2370 			}
       
  2371     
       
  2372    	RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2373         
       
  2374 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2375     while (newPassword.Length()==0 || newPassword.CompareF(verifcationPassword) != 0) 
       
  2376         {
       
  2377         // codes do not match -> note -> ask new pin and verification codes again  
       
  2378         if(newPassword.Length()>0)
       
  2379         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
  2380     
       
  2381         newPassword = _L("");
       
  2382         verifcationPassword = _L("");
       
  2383 
       
  2384         // new pin code query
       
  2385 					if(aOldPassword.Length()==0)	// only if inout parameters are empty
       
  2386 						{
       
  2387 							/* request PIN using QT */
       
  2388 							{
       
  2389 							queryAccepted = EFalse;
       
  2390 							CSecQueryUi *iSecQueryUi;
       
  2391 							iSecQueryUi = CSecQueryUi::NewL();
       
  2392 							queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-New"), newPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2393 							RDebug::Printf( "%s %s (%u) newPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2394 							RDebug::Print( newPassword );
       
  2395 							RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2396 							delete iSecQueryUi;
       
  2397 							if(!queryAccepted)
       
  2398 									return;
       
  2399 							}
       
  2400 							/* end request PIN using QT */
       
  2401 
       
  2402 						  RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2403 							/* request PIN using QT */
       
  2404 							{
       
  2405 							queryAccepted = EFalse;
       
  2406 							CSecQueryUi *iSecQueryUi;
       
  2407 							iSecQueryUi = CSecQueryUi::NewL();
       
  2408 							queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-Ver"), verifcationPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2409 							RDebug::Printf( "%s %s (%u) verifcationPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2410 							RDebug::Print( verifcationPassword );
       
  2411 							RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2412 							delete iSecQueryUi;
       
  2413 							if(!queryAccepted)
       
  2414 									return;
       
  2415 						  }
       
  2416 							/* end request PIN using QT */
       
  2417 			  	}
       
  2418         }            
       
  2419         
       
  2420     // send code
       
  2421     passwords.iOldPassword = oldPassword;
       
  2422     passwords.iNewPassword = newPassword;
       
  2423 		RDebug::Printf( "%s %s (%u) SetRequestType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2424 		RDebug::Print( passwords.iOldPassword );
       
  2425 		RDebug::Print( passwords.iNewPassword );
       
  2426     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
  2427     #ifndef __WINS__    
       
  2428     iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
       
  2429     res = iWait->WaitForRequestL();
       
  2430     #else
       
  2431     res = KErrNone;
       
  2432     #endif
       
  2433 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2434     #if defined(_DEBUG)
       
  2435     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinParamsL(): RETURN CODE: %d"), res);
       
  2436     #endif
       
  2437     switch(res)
       
  2438         {
       
  2439         case KErrNone:
       
  2440             {
       
  2441             // code changed 
       
  2442             ShowResultNoteL(R_PIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  2443             break;
       
  2444             }        
       
  2445         case KErrGsm0707IncorrectPassword:
       
  2446         case KErrAccessDenied:
       
  2447             {    
       
  2448             // code was entered erroneously
       
  2449             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2450             ChangePinParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2451             break;
       
  2452             }    
       
  2453         case KErrGsmSSPasswordAttemptsViolation:
       
  2454         case KErrLocked:
       
  2455             {
       
  2456             // Pin1 blocked! 
       
  2457             return;
       
  2458             }
       
  2459         case KErrGsm0707OperationNotAllowed:
       
  2460             {
       
  2461             // not allowed with this sim
       
  2462             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2463             return;
       
  2464             }
       
  2465         case KErrAbort:
       
  2466             {
       
  2467             break;
       
  2468             }
       
  2469         default:
       
  2470             {
       
  2471             ShowErrorNoteL(res);
       
  2472             ChangePinParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2473             break;
       
  2474             }
       
  2475         }
       
  2476 	return res;
       
  2477 	}
       
  2478 EXPORT_C TInt  CSecuritySettings::ChangeUPinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2479 	{
       
  2480 	TInt ret = KErrNone;
       
  2481 	#if defined(_DEBUG)
       
  2482 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2483 	#endif
       
  2484 	}
       
  2485 EXPORT_C TInt  CSecuritySettings::ChangePin2ParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2486 	{
       
  2487 	TInt ret = KErrNone;
       
  2488 	#if defined(_DEBUG)
       
  2489 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2490 	#endif
       
  2491 	}
       
  2492 EXPORT_C TInt  CSecuritySettings::ChangeSecCodeParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2493 	{
       
  2494 	TInt ret = KErrNone;
       
  2495 	#if defined(_DEBUG)
       
  2496 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2497 	#endif
       
  2498     /*****************************************************
       
  2499     *    Series 60 Customer / ETel
       
  2500     *    Series 60  ETel API
       
  2501     *****************************************************/
       
  2502     #if defined(_DEBUG)
       
  2503     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL()"));
       
  2504     #endif
       
  2505     TInt res=0;
       
  2506     TBool queryAccepted = EFalse;
       
  2507     RMobilePhone::TMobilePassword newPassword;
       
  2508          
       
  2509     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
  2510     secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
  2511     RMobilePhone::TMobilePassword oldPassword;
       
  2512     RMobilePhone::TMobilePassword verifcationPassword;
       
  2513     RMobilePhone::TMobilePassword required_fourth;
       
  2514     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
  2515 
       
  2516 		if(aOldPassword.Length()==0)
       
  2517 			{			/* request PIN using QT */
       
  2518 			queryAccepted = EFalse;
       
  2519 			CSecQueryUi *iSecQueryUi;
       
  2520 			iSecQueryUi = CSecQueryUi::NewL();
       
  2521 			// TODO allow and handle Cancel
       
  2522 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-Old"), oldPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2523 			RDebug::Printf( "%s %s (%u) oldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2524 			RDebug::Print( oldPassword );
       
  2525 			RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2526 			delete iSecQueryUi;
       
  2527 			if(!queryAccepted)
       
  2528 					return KErrAbort;
       
  2529 			res=1;	// indicate that everything is ok
       
  2530 			/* end request PIN using QT */
       
  2531 			newPassword = _L("");
       
  2532 	    verifcationPassword = _L("");
       
  2533 	  	}
       
  2534 		else
       
  2535 			{
       
  2536 			oldPassword.Copy(aOldPassword);
       
  2537 			newPassword.Copy(aNewPassword);
       
  2538 			verifcationPassword.Copy(aNewPassword);
       
  2539 			}
       
  2540 
       
  2541 		RDebug::Printf( "%s %s (%u) EMobilePhoneVerifySecurityCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EMobilePhoneVerifySecurityCode );
       
  2542 	  iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
       
  2543     // check code
       
  2544     iPhone.VerifySecurityCode(iWait->iStatus,secCodeType, oldPassword, required_fourth);
       
  2545     res = iWait->WaitForRequestL();
       
  2546 		RDebug::Printf( "%s %s (%u) VerifySecurityCode res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2547 			
       
  2548 		if(res!=KErrNone)
       
  2549 			{
       
  2550 			ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
       
  2551 			return res;
       
  2552 			}
       
  2553 	
       
  2554     while (newPassword.Length()==0 || newPassword.CompareF(verifcationPassword) != 0)         
       
  2555         {            
       
  2556         // codes do not match -> note -> ask new pin and verification codes again  
       
  2557         if(newPassword.Length()>0)
       
  2558         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
  2559 
       
  2560         	{
       
  2561 					queryAccepted = EFalse;
       
  2562 					CSecQueryUi *iSecQueryUi;
       
  2563 					iSecQueryUi = CSecQueryUi::NewL();
       
  2564 					queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-New"), newPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2565 					RDebug::Printf( "%s %s (%u) newPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2566 					RDebug::Print( newPassword );
       
  2567 					RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2568 					delete iSecQueryUi;
       
  2569 					if(!queryAccepted)
       
  2570 							return KErrAbort;
       
  2571 					}
       
  2572 
       
  2573 					{
       
  2574 					queryAccepted = EFalse;
       
  2575 					CSecQueryUi *iSecQueryUi;
       
  2576 					iSecQueryUi = CSecQueryUi::NewL();
       
  2577 					queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-Verif"), verifcationPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2578 					RDebug::Printf( "%s %s (%u) verifcationPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2579 					RDebug::Print( verifcationPassword );
       
  2580 					RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2581 					delete iSecQueryUi;
       
  2582 					if(!queryAccepted)
       
  2583 							return KErrAbort;
       
  2584 					// TODO allow and handle Cancel
       
  2585 					}
       
  2586 
       
  2587         }	// while
       
  2588 
       
  2589     // change code 
       
  2590 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2591     if (res == KErrNone)
       
  2592         {
       
  2593         passwords.iOldPassword = oldPassword;
       
  2594         passwords.iNewPassword = newPassword;
       
  2595         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
  2596 				RDebug::Printf( "%s %s (%u) ChangeSecurityCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2597         iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,passwords);
       
  2598         res = iWait->WaitForRequestL();
       
  2599 				RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2600 
       
  2601 				if(res==KErrNone && 1==0 )	// TODO not possible to enable because it asks code again
       
  2602 					{
       
  2603 	        RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
       
  2604  	        RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetEnabled;                       
       
  2605 					if(oldPassword.Length()==6)
       
  2606 						{
       
  2607 						lockChangeSetting = RMobilePhone::ELockSetDisabled;
       
  2608 						RDebug::Printf( "%s %s (%u) RMobilePhone::ELockSetDisabled=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, RMobilePhone::ELockSetDisabled );
       
  2609 						}
       
  2610 	        iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
  2611 					RDebug::Printf( "%s %s (%u) SetLockSetting=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2612 	        iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting );
       
  2613 	        res = iWait->WaitForRequestL();
       
  2614 					RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2615 	        }
       
  2616         }
       
  2617         
       
  2618 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
       
  2619     #if defined(_DEBUG)
       
  2620     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL(): RETURN CODE: %d"), res);
       
  2621     #endif
       
  2622     switch(res)
       
  2623         {
       
  2624         case KErrNone:
       
  2625             {
       
  2626             // code changed 
       
  2627             ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  2628             if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
       
  2629 								!(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements  )))
       
  2630 						{
       
  2631             // Send the changed code to the SCP server. Not used with device lock enhancements.
       
  2632          		RDebug::Printf( "%s %s (%u) scpClient.Connect=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2633             RSCPClient scpClient;
       
  2634             TSCPSecCode newCode;
       
  2635             newCode.Copy( newPassword );
       
  2636             if ( scpClient.Connect() == KErrNone )
       
  2637                 {
       
  2638 								RDebug::Printf( "%s %s (%u) scpClient.StoreCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2639                 scpClient.StoreCode( newCode );
       
  2640                 scpClient.Close();
       
  2641                 }                                               
       
  2642           	}
       
  2643             break;
       
  2644             }
       
  2645         case KErrGsmSSPasswordAttemptsViolation:
       
  2646         case KErrLocked:
       
  2647             {
       
  2648             ShowResultNoteL(R_SEC_BLOCKED, CAknNoteDialog::EErrorTone);
       
  2649             ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError);
       
  2650             break;
       
  2651             }
       
  2652         case KErrGsm0707IncorrectPassword:
       
  2653         case KErrAccessDenied:
       
  2654             {    
       
  2655             // code was entered erroneously
       
  2656             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2657             ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError);
       
  2658             break;
       
  2659             }
       
  2660         case KErrAbort:
       
  2661             {
       
  2662             break;
       
  2663             }
       
  2664         default:
       
  2665             {
       
  2666             ShowErrorNoteL(res);
       
  2667             ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError);
       
  2668             break;
       
  2669             }
       
  2670        } // switch
       
  2671 	}
       
  2672 EXPORT_C TInt  CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2673 	{
       
  2674 	TInt ret = KErrNone;
       
  2675 	#if defined(_DEBUG)
       
  2676 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2677 	#endif
       
  2678 	}
       
  2679 EXPORT_C TInt  CSecuritySettings::ChangePinRequestParamsL(TInt aEnable, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2680 	{
       
  2681 	TInt ret = KErrNone;
       
  2682 	#if defined(_DEBUG)
       
  2683 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2684 	#endif
       
  2685     /*****************************************************
       
  2686     *    Series 60 Customer / ETel
       
  2687     *    Series 60  ETel API
       
  2688     *****************************************************/
       
  2689     #if defined(_DEBUG)
       
  2690     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL()"));
       
  2691     #endif      
       
  2692     TInt simState=0;
       
  2693     TInt lEnable=aEnable;
       
  2694     TInt err( KErrGeneral );
       
  2695     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
  2696     User::LeaveIfError( err );
       
  2697     TBool simRemoved(simState == ESimNotPresent);
       
  2698 
       
  2699     if ( simRemoved )
       
  2700         {
       
  2701         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
  2702         return EFalse;;
       
  2703         }
       
  2704 
       
  2705     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
  2706     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
  2707     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
       
  2708 
       
  2709     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
       
  2710     
       
  2711                         
       
  2712     //get lock info
       
  2713     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
  2714     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  2715     TInt status = iWait->WaitForRequestL();
       
  2716     User::LeaveIfError(status);                    
       
  2717     TInt currentItem = 0;
       
  2718 
       
  2719     #if defined(_DEBUG)
       
  2720     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() GetLockInfo"));
       
  2721     #endif
       
  2722 
       
  2723 		if(aOldPassword.Length()==0)	// only if input parameters are empty
       
  2724 			{
       
  2725 				// switch the value.
       
  2726 			   if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
  2727 			        lEnable=1;  // on
       
  2728          else
       
  2729          			lEnable=0;	// off
       
  2730       }
       
  2731 
       
  2732     if (lEnable == 0)
       
  2733         {
       
  2734         #if defined(_DEBUG)
       
  2735         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetDisabled"));
       
  2736         #endif
       
  2737         lockChangeSetting = RMobilePhone::ELockSetDisabled;
       
  2738         }
       
  2739     else
       
  2740         {
       
  2741         #if defined(_DEBUG)
       
  2742         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetEnabled"));
       
  2743         #endif
       
  2744         lockChangeSetting = RMobilePhone::ELockSetEnabled;
       
  2745         }
       
  2746 
       
  2747     // Raise a flag to indicate that the PIN
       
  2748     // request coming from ETEL has originated from SecUi and not from Engine.
       
  2749     TInt tRet = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
       
  2750     if ( tRet != KErrNone )
       
  2751         {
       
  2752         #if defined(_DEBUG)
       
  2753         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL():\
       
  2754             FAILED to set the SECUI query Flag: %d"), tRet);
       
  2755         #endif
       
  2756         }
       
  2757 
       
  2758 	    /* TODO do I really need this? wouldn't it just generate RMobilePhone::EPin1Required and then continue ? */
       
  2759 	    /*
       
  2760 	    RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePin1;
       
  2761       RMobilePhone::TMobilePassword oldPassword;
       
  2762 		  TBool queryAccepted = EFalse;
       
  2763 			CSecQueryUi *iSecQueryUi;
       
  2764 			iSecQueryUi = CSecQueryUi::NewL();
       
  2765 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-Curr"), oldPassword, 4, 8, secCodeType );
       
  2766 			RDebug::Printf( "%s %s (%u) oldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2767 			RDebug::Print( oldPassword );
       
  2768 			RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2769 			delete iSecQueryUi;
       
  2770 			*/
       
  2771     
       
  2772     // Change the lock setting
       
  2773     iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
  2774     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
  2775     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);	// this will trigger Pin1RequiredL
       
  2776     status = iWait->WaitForRequestL();
       
  2777     #if defined(_DEBUG)
       
  2778     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinRequestL(): RETURN CODE: %d"), status);
       
  2779     #endif
       
  2780 
       
  2781     // Lower the flag                             
       
  2782     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
       
  2783 
       
  2784     switch(status)
       
  2785         {
       
  2786         case KErrNone:
       
  2787             {
       
  2788             break;
       
  2789             }
       
  2790         case KErrGsm0707OperationNotAllowed:
       
  2791             {
       
  2792             // not allowed with this sim
       
  2793             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2794             return EFalse;
       
  2795             }
       
  2796         case KErrGsm0707IncorrectPassword:
       
  2797         case KErrAccessDenied:
       
  2798             {    
       
  2799             // code was entered erroneously
       
  2800             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags, aCaption, aShowError);
       
  2801             }    
       
  2802         case KErrGsmSSPasswordAttemptsViolation:
       
  2803         case KErrLocked:
       
  2804             {
       
  2805             return ETrue;
       
  2806             }
       
  2807         case KErrAbort:
       
  2808             {
       
  2809             return EFalse;
       
  2810             }
       
  2811         default:
       
  2812             {
       
  2813             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags, aCaption, aShowError);
       
  2814             }
       
  2815         }
       
  2816  	}
       
  2817 
  2603 // End of file
  2818 // End of file