securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
changeset 17 8957df7b0072
parent 15 318c4eab2439
child 19 098e361762d2
equal deleted inserted replaced
15:318c4eab2439 17:8957df7b0072
    60 const TInt PhoneIndex( 0 );
    60 const TInt PhoneIndex( 0 );
    61 
    61 
    62 const TInt KMaxNumberOfPINAttempts(3);
    62 const TInt KMaxNumberOfPINAttempts(3);
    63 const TInt KLastRemainingInputAttempt(1);
    63 const TInt KLastRemainingInputAttempt(1);
    64 
    64 
       
    65 #define ESecUiTypeLock					0x00100000
       
    66 
    65 // ================= MEMBER FUNCTIONS =======================
    67 // ================= MEMBER FUNCTIONS =======================
    66 //
    68 //
    67 // ----------------------------------------------------------
    69 // ----------------------------------------------------------
    68 // CSecuritySettings::NewL()
    70 // CSecuritySettings::NewL()
    69 // ----------------------------------------------------------
    71 // ----------------------------------------------------------
    70 //
    72 // qtdone
    71 EXPORT_C CSecuritySettings* CSecuritySettings::NewL()
    73 EXPORT_C CSecuritySettings* CSecuritySettings::NewL()
    72     {
    74     {
    73     CSecuritySettings* self = new (ELeave) CSecuritySettings();
    75     CSecuritySettings* self = new (ELeave) CSecuritySettings();
    74     CleanupStack::PushL(self);
    76     CleanupStack::PushL(self);
    75     self->ConstructL();
    77     self->ConstructL();
    79 //
    81 //
    80 // ----------------------------------------------------------
    82 // ----------------------------------------------------------
    81 // CSecuritySettings::CSecuritySettings()
    83 // CSecuritySettings::CSecuritySettings()
    82 // constructor
    84 // constructor
    83 // ----------------------------------------------------------
    85 // ----------------------------------------------------------
    84 //
    86 // qtdone
    85 EXPORT_C CSecuritySettings::CSecuritySettings()
    87 EXPORT_C CSecuritySettings::CSecuritySettings()
    86     {
    88     {
    87     }
    89     }
    88 //
    90 //
    89 // ----------------------------------------------------------
    91 // ----------------------------------------------------------
    90 // CSecuritySettings::ConstructL()
    92 // CSecuritySettings::ConstructL()
    91 // Symbian OS constructor.
    93 // Symbian OS constructor.
    92 // ----------------------------------------------------------
    94 // ----------------------------------------------------------
    93 //
    95 // qtdone
    94 EXPORT_C void CSecuritySettings::ConstructL()
    96 EXPORT_C void CSecuritySettings::ConstructL()
    95     {
    97     {
    96     /*****************************************************
    98     /*****************************************************
    97     *    Series 60 Customer / ETel
    99     *    Series 60 Customer / ETel
    98     *    Series 60  ETel API
   100     *    Series 60  ETel API
   141 //
   143 //
   142 // ----------------------------------------------------------
   144 // ----------------------------------------------------------
   143 // CSecuritySettings::~CSecuritySettings()
   145 // CSecuritySettings::~CSecuritySettings()
   144 // Destructor
   146 // Destructor
   145 // ----------------------------------------------------------
   147 // ----------------------------------------------------------
   146 //
   148 // qtdone
   147 EXPORT_C CSecuritySettings::~CSecuritySettings()
   149 EXPORT_C CSecuritySettings::~CSecuritySettings()
   148     {
   150     {
   149     /*****************************************************
   151     /*****************************************************
   150     *    Series 60 Customer / ETel
   152     *    Series 60 Customer / ETel
   151     *    Series 60  ETel API
   153     *    Series 60  ETel API
   193 //
   195 //
   194 // ----------------------------------------------------------
   196 // ----------------------------------------------------------
   195 // CSecuritySettings::ChangePinL()
   197 // CSecuritySettings::ChangePinL()
   196 // Changes PIN1
   198 // Changes PIN1
   197 // ----------------------------------------------------------
   199 // ----------------------------------------------------------
   198 //
   200 // qtdone
   199 EXPORT_C void CSecuritySettings::ChangePinL()
   201 EXPORT_C void CSecuritySettings::ChangePinL()
   200     {
   202     {
   201     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   203     	RDEBUG( "0", 0 );
       
   204     RMobilePhone::TMobilePassword iOldPassword;
       
   205     RMobilePhone::TMobilePassword iNewPassword;
       
   206     TInt iFlags=ESecUiTypeLock;
       
   207 		iOldPassword.Copy(_L(""));
       
   208 		iNewPassword.Copy(_L(""));
       
   209 
       
   210     TBuf<0x80> iCaption;
       
   211     iCaption.Copy(_L("ChangePinL"));
       
   212     TInt iShowError=1;
       
   213   	ChangePinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
       
   214   		RDEBUG( "0", 0 );
       
   215     }
       
   216 
       
   217 //
       
   218 // ----------------------------------------------------------
       
   219 // CSecuritySettings::ChangeUPinL()
       
   220 // Changes Universal PIN
       
   221 // ----------------------------------------------------------
       
   222 // qtdone
       
   223 EXPORT_C void CSecuritySettings::ChangeUPinL()
       
   224     {
       
   225     	RDEBUG( "0", 0 );
       
   226     RMobilePhone::TMobilePassword iOldPassword;
       
   227     RMobilePhone::TMobilePassword iNewPassword;
       
   228     TInt iFlags=ESecUiTypeLock;
       
   229 		iOldPassword.Copy(_L(""));
       
   230 		iNewPassword.Copy(_L(""));
       
   231 
       
   232     TBuf<0x80> iCaption;
       
   233     iCaption.Copy(_L("ChangeUPinL"));
       
   234     TInt iShowError=1;
       
   235   	ChangeUPinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
       
   236   		RDEBUG( "0", 0 );
       
   237 
       
   238     }
       
   239 
       
   240 //
       
   241 // ----------------------------------------------------------
       
   242 // CSecuritySettings::ChangePin2L()
       
   243 // Changes PIN2
       
   244 // ----------------------------------------------------------
       
   245 // qtdone
       
   246 EXPORT_C void CSecuritySettings::ChangePin2L()
       
   247     {
       
   248     	RDEBUG( "0", 0 );
       
   249     RMobilePhone::TMobilePassword iOldPassword;
       
   250     RMobilePhone::TMobilePassword iNewPassword;
       
   251     TInt iFlags=ESecUiTypeLock;
       
   252 		iOldPassword.Copy(_L(""));
       
   253 		iNewPassword.Copy(_L(""));
       
   254 
       
   255     TBuf<0x80> iCaption;
       
   256     iCaption.Copy(_L("ChangePin2L"));
       
   257     TInt iShowError=1;
       
   258   	ChangePin2ParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
       
   259   	RDEBUG( "0", 0 );
       
   260 
       
   261      }
       
   262 //
       
   263 // ----------------------------------------------------------
       
   264 // CSecuritySettings::ChangeSecCodeL()
       
   265 // Changes security code 
       
   266 // ----------------------------------------------------------
       
   267 // qtdone
       
   268 EXPORT_C void CSecuritySettings::ChangeSecCodeL()
       
   269     {
       
   270     RDEBUG( "0", 0 );
   202     RMobilePhone::TMobilePassword iOldPassword;
   271     RMobilePhone::TMobilePassword iOldPassword;
   203     RMobilePhone::TMobilePassword iNewPassword;
   272     RMobilePhone::TMobilePassword iNewPassword;
   204     TInt iFlags=0;
   273     TInt iFlags=0;
   205     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   206 		iOldPassword.Copy(_L(""));
   274 		iOldPassword.Copy(_L(""));
   207     RDebug::Printf( "%s %s (%u) iNewPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   208 		iNewPassword.Copy(_L(""));
   275 		iNewPassword.Copy(_L(""));
   209 
   276 
   210     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   211     TBuf<0x80> iCaption;
   277     TBuf<0x80> iCaption;
   212     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   213     iCaption.Copy(_L("ChangePinL"));
       
   214     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   215    	RDebug::Print(iCaption);
       
   216     TInt iShowError=1;
       
   217   	ChangePinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
       
   218   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   219     }
       
   220 
       
   221 //
       
   222 // ----------------------------------------------------------
       
   223 // CSecuritySettings::ChangeUPinL()
       
   224 // Changes Universal PIN
       
   225 // ----------------------------------------------------------
       
   226 //
       
   227 EXPORT_C void CSecuritySettings::ChangeUPinL()
       
   228     {
       
   229     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
       
   230     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
   231     if(wcdmaSupported || upinSupported)
       
   232       {
       
   233         #if defined(_DEBUG)
       
   234         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinL()"));
       
   235         #endif
       
   236         TInt simState;
       
   237         TInt err( KErrGeneral );
       
   238         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
   239         User::LeaveIfError( err );
       
   240         TBool simRemoved(simState == ESimNotPresent);
       
   241     
       
   242         if ( simRemoved )
       
   243             {
       
   244             ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
   245             return;
       
   246             }
       
   247     
       
   248         RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   249         secCodeType = RMobilePhone::ESecurityUniversalPin;
       
   250     
       
   251         RMobilePhone::TMobilePassword oldPassword;
       
   252         RMobilePhone::TMobilePassword newPassword;
       
   253         RMobilePhone::TMobilePassword verifcationPassword;
       
   254         RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
   255         RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
   256         RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
   257     
       
   258         CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   259         CleanupStack::PushL(verdlg);
       
   260     
       
   261         CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog(newPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   262         CleanupStack::PushL(newdlg);
       
   263     
       
   264         CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (oldPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);       
       
   265         CleanupStack::PushL(dlg);
       
   266     
       
   267         RMobilePhone::TMobilePhoneLock lockType;
       
   268         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
   269         
       
   270         lockType = RMobilePhone::ELockUniversalPin;
       
   271         
       
   272         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
   273         iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
   274         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
   275         TInt res = iWait->WaitForRequestL();
       
   276         User::LeaveIfError(res);
       
   277     
       
   278         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
   279             {    
       
   280             CleanupStack::PopAndDestroy(3,verdlg);
       
   281             ShowResultNoteL(R_UPIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   282             return;
       
   283             }
       
   284         
       
   285         CleanupStack::Pop(); // dlg
       
   286         // ask pin
       
   287         iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
   288         iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
       
   289         res = iWait->WaitForRequestL();
       
   290         User::LeaveIfError(res);
       
   291             
       
   292         if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
   293             res = dlg->ExecuteLD(R_UPIN_QUERY);
       
   294         else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
   295             {
       
   296               HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_UPIN_ATTEMPTS, codeInfo.iRemainingEntryAttempts);
       
   297               res = dlg->ExecuteLD(R_UPIN_QUERY, *queryPrompt);
       
   298               CleanupStack::PopAndDestroy(queryPrompt);
       
   299             }
       
   300         else
       
   301             {
       
   302               HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_UPIN_ATTEMPT);
       
   303               res = dlg->ExecuteLD(R_UPIN_QUERY, *queryPrompt);
       
   304               CleanupStack::PopAndDestroy(queryPrompt);   
       
   305             }        
       
   306         
       
   307         
       
   308         
       
   309          if( !res )
       
   310             {
       
   311             CleanupStack::PopAndDestroy(2,verdlg);
       
   312             return;
       
   313             }      
       
   314         CleanupStack::Pop(); // newdlg
       
   315         // new pin code query
       
   316          if (!(newdlg->ExecuteLD(R_NEW_UPIN_CODE_QUERY)))
       
   317             {
       
   318             CleanupStack::PopAndDestroy(verdlg);
       
   319             return;
       
   320             }
       
   321     
       
   322         CleanupStack::Pop(); // verdlg
       
   323         // verification code query
       
   324         if (!(verdlg->ExecuteLD(R_VERIFY_NEW_UPIN_CODE_QUERY)))
       
   325                 return;
       
   326             
       
   327         while (newPassword.CompareF(verifcationPassword) != 0) 
       
   328             {
       
   329             // codes do not match -> note -> ask new pin and verification codes again  
       
   330             ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
   331         
       
   332             newPassword = _L("");
       
   333             verifcationPassword = _L("");
       
   334     
       
   335             // new pin code query
       
   336             CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog (newPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   337             if (!(newdlg->ExecuteLD(R_NEW_UPIN_CODE_QUERY)))
       
   338                   return;
       
   339             
       
   340             // verification code query
       
   341             CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);
       
   342             if (!(verdlg->ExecuteLD(R_VERIFY_NEW_UPIN_CODE_QUERY)))
       
   343                 return;
       
   344             }            
       
   345             
       
   346         // send code
       
   347         passwords.iOldPassword = oldPassword;
       
   348         passwords.iNewPassword = newPassword;
       
   349         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
   350         iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
       
   351         res = iWait->WaitForRequestL();
       
   352         #if defined(_DEBUG)
       
   353         RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinL(): RETURN CODE: %d"), res);
       
   354         #endif
       
   355         switch(res)
       
   356             {
       
   357             case KErrNone:
       
   358                 {
       
   359                 // code changed 
       
   360                 ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
   361                 break;
       
   362                 }        
       
   363             case KErrGsm0707IncorrectPassword:
       
   364             case KErrAccessDenied:
       
   365                 {    
       
   366                 // code was entered erroneously
       
   367                 ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
   368                 ChangeUPinL();
       
   369                 break;
       
   370                 }    
       
   371             case KErrGsmSSPasswordAttemptsViolation:
       
   372             case KErrLocked:
       
   373                 {
       
   374                 return;
       
   375                 }
       
   376             case KErrGsm0707OperationNotAllowed:
       
   377                 {
       
   378                 // not allowed with this sim
       
   379                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   380                 return;
       
   381                 }
       
   382             case KErrAbort:
       
   383                 {
       
   384                 break;
       
   385                 }
       
   386             default:
       
   387                 {
       
   388                 ShowErrorNoteL(res);
       
   389                 ChangeUPinL();
       
   390                 break;
       
   391                 }
       
   392             }
       
   393       }
       
   394 
       
   395     }
       
   396 
       
   397 //
       
   398 // ----------------------------------------------------------
       
   399 // CSecuritySettings::ChangePin2L()
       
   400 // Changes PIN2
       
   401 // ----------------------------------------------------------
       
   402 //
       
   403 EXPORT_C void CSecuritySettings::ChangePin2L()
       
   404     {
       
   405     /*****************************************************
       
   406     *    Series 60 Customer / ETel
       
   407     *    Series 60  ETel API
       
   408     *****************************************************/
       
   409     #if defined(_DEBUG)
       
   410     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePin2L()"));
       
   411     #endif
       
   412     TInt simState;
       
   413     TInt err( KErrGeneral );
       
   414     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
   415     User::LeaveIfError( err );
       
   416     TBool simRemoved(simState == ESimNotPresent);
       
   417 
       
   418     if ( simRemoved )
       
   419         {
       
   420         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
   421         return;
       
   422         }
       
   423 
       
   424     RMmCustomAPI::TSecurityCodeType secCodeType;
       
   425     RMobilePhone::TMobilePhoneSecurityCode EtelsecCodeType;
       
   426     secCodeType = RMmCustomAPI::ESecurityCodePin2;
       
   427     RMobilePhone::TMobilePassword oldPassword;
       
   428     RMobilePhone::TMobilePassword newPassword;
       
   429     RMobilePhone::TMobilePassword verifcationPassword;
       
   430     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
   431     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
   432     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
   433     
       
   434     // check if pin2 is blocked...
       
   435     TBool isBlocked = EFalse;
       
   436 
       
   437     TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
       
   438     
       
   439     if(isBlocked)
       
   440         return;
       
   441     
       
   442     if (ret != KErrNone)
       
   443         {    
       
   444         switch (ret)
       
   445             {
       
   446             // PIN2 Blocked.
       
   447             case KErrGsm0707SIMPuk2Required:
       
   448                 break;
       
   449             case KErrGsmSSPasswordAttemptsViolation:
       
   450             case KErrLocked:
       
   451                 // Pin2 features blocked permanently!
       
   452                 ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone);
       
   453                 break;
       
   454             case KErrGsm0707SimNotInserted:
       
   455                 // not allowed with this sim
       
   456                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   457                 break;
       
   458             default:
       
   459                 ShowErrorNoteL(ret);
       
   460                 break;
       
   461             }
       
   462         return;
       
   463         }
       
   464     
       
   465     CCodeQueryDialog* verdlg = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
   466     CleanupStack::PushL(verdlg);
       
   467 
       
   468     CCodeQueryDialog* newdlg = new (ELeave) CCodeQueryDialog(newPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);    
       
   469     CleanupStack::PushL(newdlg);
       
   470 
       
   471     CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (oldPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);      
       
   472     CleanupStack::PushL(dlg);
       
   473 
       
   474 
       
   475     // Security code must be changed to Etel API format
       
   476     // Custom API Pin1 and Pin2 have the same enum values as the Etel ones
       
   477     EtelsecCodeType = (RMobilePhone::TMobilePhoneSecurityCode)secCodeType;
       
   478     #ifndef __WINS__    
       
   479         iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
   480         iPhone.GetSecurityCodeInfo(iWait->iStatus, EtelsecCodeType, codeInfoPkg);
       
   481         ret = iWait->WaitForRequestL();
       
   482         User::LeaveIfError(ret);
       
   483     #else
       
   484         codeInfo.iRemainingEntryAttempts = 1;
       
   485     #endif //__WINS__
       
   486 
       
   487     if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
       
   488             ret = dlg->ExecuteLD(R_PIN2_QUERY);
       
   489     else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
       
   490        {
       
   491          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN2_ATTEMPTS, codeInfo.iRemainingEntryAttempts );
       
   492          ret = dlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
       
   493          CleanupStack::PopAndDestroy(queryPrompt);
       
   494        }
       
   495     else
       
   496        {
       
   497          HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN2_ATTEMPT);
       
   498          ret = dlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
       
   499          CleanupStack::PopAndDestroy(queryPrompt);   
       
   500        }
       
   501 
       
   502     CleanupStack::Pop(); // dlg
       
   503     if(!ret)
       
   504         {
       
   505         CleanupStack::PopAndDestroy(2,verdlg);
       
   506         return;
       
   507         }
       
   508 
       
   509     // new pin code query
       
   510     CleanupStack::Pop(); // newdlg
       
   511     if(!(newdlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY)))
       
   512         {
       
   513         CleanupStack::PopAndDestroy(verdlg);
       
   514         return;
       
   515         }
       
   516 
       
   517      // verification code query
       
   518     CleanupStack::Pop(); // verdlg
       
   519     if(!(verdlg->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY)))
       
   520         {
       
   521         return;
       
   522         }
       
   523 
       
   524     while (newPassword.CompareF(verifcationPassword) != 0)     
       
   525         {
       
   526         // codes do not match -> note -> ask new pin and verification codes again  
       
   527         ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
       
   528 
       
   529         newPassword = _L("");
       
   530         verifcationPassword = _L("");
       
   531         
       
   532         // new pin code query
       
   533         CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (newPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
   534         if(!(dlg->ExecuteLD(R_NEW_PIN2_CODE_QUERY)))
       
   535             return;
       
   536               
       
   537         // verification code query
       
   538         CCodeQueryDialog* dlg2 = new (ELeave) CCodeQueryDialog (verifcationPassword,SEC_C_PIN2_CODE_MIN_LENGTH,SEC_C_PIN2_CODE_MAX_LENGTH,ESecUiNone);
       
   539           if(!(dlg2->ExecuteLD(R_VERIFY_NEW_PIN2_CODE_QUERY)))
       
   540             return;
       
   541         }        
       
   542     
       
   543 
       
   544     passwords.iOldPassword = oldPassword;
       
   545     passwords.iNewPassword = newPassword;
       
   546     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
   547     iPhone.ChangeSecurityCode(iWait->iStatus,EtelsecCodeType,passwords);
       
   548     TInt res = iWait->WaitForRequestL();
       
   549         #if defined(_DEBUG)
       
   550     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePin2L(): RETURN CODE: %d"), res);
       
   551     #endif
       
   552     switch(res)
       
   553         {
       
   554         case KErrNone:
       
   555             {
       
   556             // code changed 
       
   557             ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
   558             break;
       
   559             }        
       
   560         case KErrGsm0707IncorrectPassword:
       
   561         case KErrAccessDenied:
       
   562             {    
       
   563             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
   564             ChangePin2L();
       
   565             break;
       
   566             }    
       
   567         case KErrGsmSSPasswordAttemptsViolation:
       
   568         case KErrLocked:
       
   569             {
       
   570             // Pin2 blocked!
       
   571             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
   572             CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone);
       
   573             CleanupStack::PushL(handler); 
       
   574             handler->HandleEventL(RMobilePhone::EPuk2Required);
       
   575             CleanupStack::PopAndDestroy(handler); // handler    
       
   576             return;
       
   577             }
       
   578         case KErrGsm0707OperationNotAllowed:
       
   579             {
       
   580             // not allowed with this sim
       
   581             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
   582             return;
       
   583             }
       
   584         case KErrAbort:
       
   585             {
       
   586             break;
       
   587             }
       
   588         default:
       
   589             {
       
   590             ShowErrorNoteL(res);
       
   591             ChangePin2L();
       
   592             break;
       
   593             }
       
   594         }
       
   595      }
       
   596 //
       
   597 // ----------------------------------------------------------
       
   598 // CSecuritySettings::ChangeSecCodeL()
       
   599 // Changes security code 
       
   600 // ----------------------------------------------------------
       
   601 //
       
   602 EXPORT_C void CSecuritySettings::ChangeSecCodeL()
       
   603     {
       
   604     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   605     RMobilePhone::TMobilePassword iOldPassword;
       
   606     RMobilePhone::TMobilePassword iNewPassword;
       
   607     TInt iFlags=0;
       
   608     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   609 		iOldPassword.Copy(_L(""));
       
   610     RDebug::Printf( "%s %s (%u) iNewPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   611 		iNewPassword.Copy(_L(""));
       
   612 
       
   613     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   614     TBuf<0x80> iCaption;
       
   615     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   616     iCaption.Copy(_L("ChangeSecCodeL"));
   278     iCaption.Copy(_L("ChangeSecCodeL"));
   617     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
   618    	RDebug::Print(iCaption);
       
   619     TInt iShowError=1;
   279     TInt iShowError=1;
   620   	ChangeSecCodeParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   280   	ChangeSecCodeParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   621   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   281   	RDEBUG( "0", 0 );
   622     }
   282     }
   623 //
   283 //
   624 // ----------------------------------------------------------
   284 // ----------------------------------------------------------
   625 // CSecuritySettings::ChangeAutoLockPeriodL()
   285 // CSecuritySettings::ChangeAutoLockPeriodL()
   626 // Changes autolock period
   286 // Changes autolock period
   627 // ----------------------------------------------------------
   287 // ----------------------------------------------------------
   628 //
   288 // qtdone
   629 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodL(TInt aPeriod)
   289 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodL(TInt aPeriod)
   630     {            
   290     {
   631     /*****************************************************
   291     TInt ret=0;
   632     *    Series 60 Customer / ETel
   292     RDEBUG( "aPeriod", aPeriod );
   633     *    Series 60  ETel API
   293     RMobilePhone::TMobilePassword iOldPassword;
   634     *****************************************************/
   294     TInt iFlags=0;
   635     #if defined(_DEBUG)
   295     TInt iShowError=1;
   636     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodLXXXX()"));
   296     TBuf<0x80> iCaption;
   637     #endif
   297     iCaption.Copy(_L("ChangeAutoLockPeriodL"));
   638     RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled);
   298     iOldPassword.Copy(_L(""));
   639     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
   299     ret = ChangeAutoLockPeriodParamsL(aPeriod, iOldPassword, iFlags, iCaption, iShowError);
   640     TInt currentItem = 0;
   300     RDEBUG( "ret", ret );
   641     TInt oldPeriod = aPeriod;
   301     return ret;
   642 
       
   643     #if defined(_DEBUG)
       
   644     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() ReadDesC16ArrayResourceL"));
       
   645     #endif
       
   646 
       
   647 
       
   648     CCoeEnv* coeEnv = CCoeEnv::Static();        
       
   649     CDesCArrayFlat* items =  coeEnv->ReadDesC16ArrayResourceL(R_AUTOLOCK_LBX);
       
   650     CleanupStack::PushL(items);
       
   651         
       
   652     if (aPeriod == 0)
       
   653         {
       
   654         currentItem = 0;  // autolock off
       
   655         }
       
   656     else
       
   657         {
       
   658         currentItem = 1;  // user defined
       
   659         }
       
   660     
       
   661 
       
   662     #if defined(_DEBUG)
       
   663     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() New autolocksettingpage"));
       
   664     #endif
       
   665     
       
   666     CAutoLockSettingPage* dlg = new (ELeave)CAutoLockSettingPage(R_AUTOLOCK_SETTING_PAGE, currentItem, items, aPeriod);
       
   667     CleanupStack::PushL(dlg);
       
   668     dlg->ConstructL();
       
   669     TInt maxPeriod;
       
   670     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   671 		{
       
   672     // Retrieve the current autolock period max. value from the SCP server, 
       
   673     // and check that the value the user
       
   674     // selected is ok from the Corporate Policy point of view.
       
   675 	RSCPClient scpClient;
       
   676     TInt ret = scpClient.Connect();
       
   677     if ( ret == KErrNone )
       
   678         {       
       
   679         CleanupClosePushL( scpClient );
       
   680         TBuf<KSCPMaxIntLength> maxPeriodBuf;
       
   681         if ( scpClient.GetParamValue( ESCPMaxAutolockPeriod, maxPeriodBuf ) == KErrNone )
       
   682             {
       
   683             TLex lex( maxPeriodBuf );          
       
   684             if ( ( lex.Val( maxPeriod ) == KErrNone ) && ( maxPeriod > 0 ) )
       
   685                 {               
       
   686                  dlg->SetPeriodMaximumValue(maxPeriod);
       
   687                 }
       
   688             else
       
   689                 {
       
   690                    maxPeriod = 0;
       
   691                    dlg->SetPeriodMaximumValue(maxPeriod);     
       
   692                 }
       
   693                 
       
   694             }
       
   695         else
       
   696             {
       
   697             #if defined(_DEBUG)
       
   698             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL():\
       
   699                 ERROR: Failed to retrieve max period"));
       
   700             #endif            
       
   701             }            
       
   702         }
       
   703     else
       
   704         {
       
   705         #if defined(_DEBUG)
       
   706         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL():\
       
   707             ERROR: Failed to connect to SCP."));
       
   708         #endif            
       
   709         }
       
   710     CleanupStack::PopAndDestroy(); // scpClient 
       
   711 }
       
   712     CleanupStack::Pop(); //dlg
       
   713     if (!dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged))
       
   714         {
       
   715         CleanupStack::PopAndDestroy(items);           
       
   716         return oldPeriod;
       
   717         }
       
   718     
       
   719     CleanupStack::PopAndDestroy();    // items
       
   720     
       
   721     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
   722 		{
       
   723     TBool allow = ETrue;               
       
   724                
       
   725     if ((aPeriod == 0) && (maxPeriod > 0))
       
   726        {
       
   727         #if defined(_DEBUG)
       
   728         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() \
       
   729         The period: %d is not allowed by TARM; max: %d"),aPeriod, maxPeriod );
       
   730         #endif                
       
   731         allow = EFalse;                                                
       
   732         HBufC* prompt;
       
   733         prompt = StringLoader::LoadLC( R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE );
       
   734         CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog( REINTERPRET_CAST(CEikDialog**,&noteDlg) );
       
   735         noteDlg->PrepareLC( R_CODE_ERROR );
       
   736         noteDlg->SetTextL( *prompt );
       
   737         noteDlg->SetTimeout( CAknNoteDialog::ELongTimeout );
       
   738         noteDlg->SetTone( CAknNoteDialog::EErrorTone );
       
   739         noteDlg->RunLD();                    
       
   740                     
       
   741         CleanupStack::PopAndDestroy( prompt );                      
       
   742         }          
       
   743         
       
   744     if ( !allow ) 
       
   745         {
       
   746          return ChangeAutoLockPeriodL( oldPeriod );
       
   747         }                       
       
   748   }
       
   749 
       
   750     if (aPeriod == 0)
       
   751         {
       
   752         
       
   753         #ifdef RD_REMOTELOCK
       
   754 
       
   755         // If remote lock is enabled, don't disable the domestic OS device lock
       
   756         // since that would render the RemoteLock useless.
       
   757         // Instead just re-set the DOS lock to enabled which as a side effect
       
   758         // requests the security code from the user.
       
   759 
       
   760         TBool remoteLockStatus( EFalse );
       
   761         CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
   762 
       
   763         if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
   764             {
       
   765             if ( remoteLockStatus )
       
   766                 {
       
   767                 // Remote lock is enabled
       
   768                 #ifdef _DEBUG
       
   769                 RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeAutoLockPeriodL() - RemoteLock is enabled: lockChange = RMobilePhone::ELockSetEnabled" ) );
       
   770                 #endif // _DEBUG
       
   771 
       
   772                 lockChange = RMobilePhone::ELockSetEnabled;
       
   773                 }
       
   774             else
       
   775                 {
       
   776                 // Remote lock is disabled
       
   777                 #ifdef _DEBUG
       
   778                 RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeAutoLockPeriodL() - RemoteLock is disabled: lockChange = RMobilePhone::ELockSetDisabled" ) );
       
   779                 #endif // _DEBUG
       
   780 
       
   781                 lockChange = RMobilePhone::ELockSetDisabled;
       
   782                 }
       
   783             }
       
   784         else
       
   785             {
       
   786             // Failed to get remote lock status
       
   787             #ifdef _DEBUG
       
   788             RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeAutoLockPeriodL() - Failed to get RemoteLock status" ) );
       
   789             #endif // _DEBUG
       
   790             }
       
   791 
       
   792         delete remoteLockSettings;
       
   793         remoteLockSettings = NULL;
       
   794 
       
   795         #else // not defined RD_REMOTELOCK
       
   796 
       
   797         lockChange = RMobilePhone::ELockSetDisabled;
       
   798 
       
   799         #endif // RD_REMOTELOCK
       
   800         }
       
   801     else
       
   802         {
       
   803         lockChange = RMobilePhone::ELockSetEnabled;
       
   804         }
       
   805     #if defined(_DEBUG)
       
   806     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() SetLockSetting"));
       
   807     #endif
       
   808         iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
   809         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
   810         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChange);
       
   811         TInt status = iWait->WaitForRequestL();
       
   812         #if defined(_DEBUG)
       
   813         RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL(): RETURN CODE: %d"), status);
       
   814         #endif
       
   815         switch(status)
       
   816         {
       
   817         case KErrNone:
       
   818             #if defined(_DEBUG)
       
   819             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() KErrNone"));
       
   820             #endif
       
   821             break;
       
   822         case KErrGsmSSPasswordAttemptsViolation:
       
   823         case KErrLocked:
       
   824             #if defined(_DEBUG)
       
   825             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() PasswordAttemptsViolation"));
       
   826             #endif
       
   827             return ChangeAutoLockPeriodL(oldPeriod);
       
   828         case KErrGsm0707IncorrectPassword:
       
   829         case KErrAccessDenied:
       
   830             #if defined(_DEBUG)
       
   831             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() IncorrectPassword"));
       
   832             #endif
       
   833             // code was entered erroneously
       
   834             return ChangeAutoLockPeriodL(oldPeriod);
       
   835         case KErrAbort:
       
   836             // User pressed "cancel" in the code query dialog.
       
   837             return oldPeriod;
       
   838         default:
       
   839             #if defined(_DEBUG)
       
   840             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() default"));
       
   841             #endif            
       
   842             return ChangeAutoLockPeriodL(oldPeriod);
       
   843         }
       
   844     #if defined(_DEBUG)
       
   845     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() END"));
       
   846     #endif
       
   847     return aPeriod; 
       
   848     }
   302     }
   849 
   303 
   850 
   304 
   851 
   305 
   852 //
   306 //
   853 // ----------------------------------------------------------
   307 // ----------------------------------------------------------
   854 // CSecuritySettings::ChangeRemoteLockStatusL()
   308 // CSecuritySettings::ChangeRemoteLockStatusL()
   855 // Changes remote lock status (on/off)
   309 // Changes remote lock status (on/off)
   856 // ----------------------------------------------------------
   310 // ----------------------------------------------------------
   857 //
   311 // no qtdone
   858 EXPORT_C TInt CSecuritySettings::ChangeRemoteLockStatusL( TBool& aRemoteLockStatus, TDes& aRemoteLockCode, TInt aAutoLockPeriod )
   312 EXPORT_C TInt CSecuritySettings::ChangeRemoteLockStatusL( TBool& aRemoteLockStatus, TDes& aRemoteLockCode, TInt aAutoLockPeriod )
   859     {
   313     {
   860    #ifdef RD_REMOTELOCK
   314    #ifdef RD_REMOTELOCK
   861     TInt retValue( KErrNone );
   315     TInt retValue( KErrNone );
   862 
   316 
   972 // CSecuritySettings::RemoteLockCodeQueryL()
   426 // CSecuritySettings::RemoteLockCodeQueryL()
   973 // Pops up remote lock code query. Requires user to enter a new remote lock 
   427 // Pops up remote lock code query. Requires user to enter a new remote lock 
   974 // code twice and if they match enables the domestic OS device lock (which as 
   428 // code twice and if they match enables the domestic OS device lock (which as 
   975 // a side effect pops up security code query).
   429 // a side effect pops up security code query).
   976 // ----------------------------------------------------------
   430 // ----------------------------------------------------------
   977 //
   431 // no qtdone
   978 TInt CSecuritySettings::RemoteLockCodeQueryL( TDes& aRemoteLockCode )
   432 TInt CSecuritySettings::RemoteLockCodeQueryL( TDes& aRemoteLockCode )
   979     {
   433     {
   980     #ifdef RD_REMOTELOCK
   434     #ifdef RD_REMOTELOCK
   981     TInt retValue( KErrNone );
   435     TInt retValue( KErrNone );
   982 
   436 
  1082 
   536 
  1083             if ( aRemoteLockCode.Length() <= RMobilePhone::KMaxMobilePasswordSize )
   537             if ( aRemoteLockCode.Length() <= RMobilePhone::KMaxMobilePasswordSize )
  1084                 {
   538                 {
  1085                 securityCode = aRemoteLockCode;
   539                 securityCode = aRemoteLockCode;
  1086                 iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
   540                 iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
       
   541                 RDEBUG( "VerifySecurityCode", 0 );
  1087                 iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
   542                 iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
       
   543                 	RDEBUG( "WaitForRequestL", 0 );
  1088                 TInt res = iWait->WaitForRequestL();
   544                 TInt res = iWait->WaitForRequestL();
       
   545                 	RDEBUG( "WaitForRequestL res", res );
       
   546 							  #ifdef __WINS__
       
   547 							  if (res == KErrNotSupported)
       
   548 								  res = KErrNone;
       
   549 							  #endif
  1089                 // The remote lock code matches the security code 
   550                 // The remote lock code matches the security code 
  1090                 // and that is not allowed
   551                 // and that is not allowed
  1091                 while ( (res == KErrNone) && (buttonId == EEikBidOk))
   552                 while ( (res == KErrNone) && (buttonId == EEikBidOk))
  1092                     {
   553                     {
  1093                     #ifdef _DEBUG
   554                     #ifdef _DEBUG
  1136                                 }
   597                                 }
  1137                             else //Check against security code
   598                             else //Check against security code
  1138                                 {
   599                                 {
  1139                                     securityCode = aRemoteLockCode;
   600                                     securityCode = aRemoteLockCode;
  1140                                     iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
   601                                     iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
       
   602                                     RDEBUG( "VerifySecurityCode", 0 );
  1141                                     iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
   603                                     iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
       
   604                                     	RDEBUG( "WaitForRequestL", 0 );
  1142                                     res = iWait->WaitForRequestL();
   605                                     res = iWait->WaitForRequestL();
       
   606 																	  #ifdef __WINS__
       
   607 																	  if (res == KErrNotSupported)
       
   608 																		  res = KErrNone;
       
   609 																	  #endif
       
   610                                     	RDEBUG( "WaitForRequestL res", res );
  1143                                 }
   611                                 }
  1144                         }
   612                         }
  1145 					
   613 					
  1146                     }
   614                     }
  1147                //User pressed cancel        
   615                //User pressed cancel        
  1187 // ----------------------------------------------------------
   655 // ----------------------------------------------------------
  1188 // CSecuritySettings::RemoteLockSetLockSettingL()
   656 // CSecuritySettings::RemoteLockSetLockSettingL()
  1189 // Changes lock setting in domestic OS. Changing the domestic OS lock setting
   657 // Changes lock setting in domestic OS. Changing the domestic OS lock setting
  1190 // requires user to enter the security code.
   658 // requires user to enter the security code.
  1191 // ----------------------------------------------------------
   659 // ----------------------------------------------------------
  1192 //
   660 // no qtdone
  1193 TInt CSecuritySettings::RemoteLockSetLockSettingL( TBool aLockSetting )
   661 TInt CSecuritySettings::RemoteLockSetLockSettingL( TBool aLockSetting )
  1194     {
   662     {
  1195     #ifdef RD_REMOTELOCK
   663     #ifdef RD_REMOTELOCK
  1196     TInt retValue( KErrNone );
   664     TInt retValue( KErrNone );
  1197 
   665 
  1211         lockSetting = RMobilePhone::ELockSetDisabled;
   679         lockSetting = RMobilePhone::ELockSetDisabled;
  1212         }
   680         }
  1213 
   681 
  1214     iWait->SetRequestType( EMobilePhoneSetLockSetting );
   682     iWait->SetRequestType( EMobilePhoneSetLockSetting );
  1215     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
   683     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
   684    	RDEBUG( "SetLockSetting", 0 );
  1216     iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );
   685     iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );
  1217 
   686 
  1218     // Wait for code verify to complete
   687     // Wait for code verify to complete
       
   688     	RDEBUG( "WaitForRequestL", 0 );
  1219     retValue = iWait->WaitForRequestL();
   689     retValue = iWait->WaitForRequestL();
       
   690     	RDEBUG( "WaitForRequestL retValue", retValue );
       
   691 	  #ifdef __WINS__
       
   692 	  if (retValue == KErrNotSupported)
       
   693 		  retValue = KErrNone;
       
   694 	  #endif
  1220 
   695 
  1221     switch( retValue )
   696     switch( retValue )
  1222         {
   697         {
  1223         case KErrNone:
   698         case KErrNone:
  1224             #ifdef _DEBUG
   699             #ifdef _DEBUG
  1271 //
   746 //
  1272 // ----------------------------------------------------------
   747 // ----------------------------------------------------------
  1273 // CSecuritySettings::ChangeSimSecurityL()
   748 // CSecuritySettings::ChangeSimSecurityL()
  1274 // Changes SIM security
   749 // Changes SIM security
  1275 // ----------------------------------------------------------
   750 // ----------------------------------------------------------
  1276 //
   751 // qtdone
  1277 EXPORT_C TBool CSecuritySettings::ChangeSimSecurityL()
   752 EXPORT_C TBool CSecuritySettings::ChangeSimSecurityL()
  1278     {    
   753     {    
  1279     /*****************************************************
   754     /*****************************************************
  1280     *    Series 60 Customer / ETel
   755     *    Series 60 Customer / ETel
  1281     *    Series 60  ETel API
   756     *    Series 60  ETel API
  1286 
   761 
  1287     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   762     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1288     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   763     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1289     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneToICC;
   764     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneToICC;
  1290     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
   765     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
  1291     CCoeEnv* coeEnv = CCoeEnv::Static();
       
  1292     CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL(R_SECURITY_LBX);
       
  1293     CleanupStack::PushL(items);
       
  1294                         
   766                         
  1295     //get lock info
   767     //get lock info
  1296     iWait->SetRequestType(EMobilePhoneGetLockInfo);
   768     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
   769     RDEBUG( "GetLockInfo", 0 );
  1297     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   770     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
   771     	RDEBUG( "WaitForRequestL", 0 );
  1298     TInt status = iWait->WaitForRequestL();
   772     TInt status = iWait->WaitForRequestL();
       
   773     	RDEBUG( "WaitForRequestL status", status );
       
   774 
       
   775 		#ifdef __WINS__
       
   776    	if (status == KErrTimedOut)
       
   777    		{
       
   778    		lockInfo.iSetting = RMobilePhone::ELockSetDisabled;
       
   779    		status = KErrNone;
       
   780    		}
       
   781     #endif
  1299     User::LeaveIfError(status);
   782     User::LeaveIfError(status);
  1300     TInt currentItem = 0;
   783     TInt currentItem = 0;
  1301 
   784 
  1302     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   785     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  1303         {
   786         {
  1305         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSimSecurityL()lockInfo: ELockSetDisabled"));
   788         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSimSecurityL()lockInfo: ELockSetDisabled"));
  1306         #endif
   789         #endif
  1307         currentItem = 1;  // off
   790         currentItem = 1;  // off
  1308         }
   791         }
  1309                         
   792                         
  1310     TInt oldItem = currentItem;
   793     if (currentItem == 0)	// switch the flag
  1311 
       
  1312 
       
  1313     if (currentItem == 1)
       
  1314         {
   794         {
  1315         lockChangeSetting = RMobilePhone::ELockSetDisabled;
   795         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1316         }
   796         }
  1317     else
   797     else
  1318         {
   798         {
  1319         lockChangeSetting = RMobilePhone::ELockSetEnabled;
   799         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1320         }
   800         }
  1321 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   801 		RDEBUG( "lockChangeSetting", lockChangeSetting );
  1322     
   802     
  1323     iWait->SetRequestType(EMobilePhoneSetLockSetting);
   803     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1324     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
   804     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1325     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
   805    		RDEBUG( "SetLockSetting", 0 );
       
   806     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);	// this invokes the handler
       
   807     	RDEBUG( "WaitForRequestL", 0 );
  1326     status = iWait->WaitForRequestL();
   808     status = iWait->WaitForRequestL();
  1327 
   809     	RDEBUG( "WaitForRequestL status", status );
       
   810 	  #ifdef __WINS__
       
   811 	  if (status == KErrNotSupported)
       
   812 		  status = KErrNone;
       
   813 	  #endif
       
   814 
       
   815 		// the error was displayed in the handler
  1328     #if defined(_DEBUG)
   816     #if defined(_DEBUG)
  1329     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSimSecurityL(): RETURN CODE: %d"), status);
   817     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSimSecurityL(): RETURN CODE: %d"), status);
  1330     #endif        
   818     #endif        
  1331     switch(status)
   819     switch(status)
  1332         {
   820         {
  1361 //
   849 //
  1362 // ----------------------------------------------------------
   850 // ----------------------------------------------------------
  1363 // CSecuritySettings::ChangePinRequestL()
   851 // CSecuritySettings::ChangePinRequestL()
  1364 // Changes PIN1 request
   852 // Changes PIN1 request
  1365 // ----------------------------------------------------------
   853 // ----------------------------------------------------------
  1366 //
   854 // qtdone
  1367 EXPORT_C TBool CSecuritySettings::ChangePinRequestL()
   855 EXPORT_C TBool CSecuritySettings::ChangePinRequestL()
  1368     {    
   856     {    
  1369     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   857     RDEBUG( "0", 0 );
       
   858     	
  1370     RMobilePhone::TMobilePassword iOldPassword;
   859     RMobilePhone::TMobilePassword iOldPassword;
  1371     TInt iFlags=0;
   860     TInt iFlags=0;
  1372     RDebug::Printf( "%s %s (%u) iOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  1373 		iOldPassword.Copy(_L(""));
   861 		iOldPassword.Copy(_L(""));
  1374 
   862 
  1375     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  1376     TBuf<0x80> iCaption;
   863     TBuf<0x80> iCaption;
  1377     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  1378     iCaption.Copy(_L("ChangePinRequestL"));
   864     iCaption.Copy(_L("ChangePinRequestL"));
  1379     RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  1380    	RDebug::Print(iCaption);
       
  1381     TInt iShowError=1;
   865     TInt iShowError=1;
  1382   	ChangePinRequestParamsL(1/* TODO it's imposible to know if we want to set or clear*/, iOldPassword, iFlags, iCaption, iShowError);
   866   	ChangePinRequestParamsL(1/* TODO it's imposible to know if we want to set or clear*/, iOldPassword, iFlags, iCaption, iShowError);
  1383   	RDebug::Printf( "%s %s (%u) iCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
   867   	RDEBUG( "0", 0 );
  1384 
   868 
  1385     return ETrue;
   869     return ETrue;
  1386     }
   870     }
  1387 
   871 
  1388 //
   872 //
  1389 // ----------------------------------------------------------
   873 // ----------------------------------------------------------
  1390 // CSecuritySettings::ChangeUPinRequestL()
   874 // CSecuritySettings::ChangeUPinRequestL()
  1391 // Changes UPIN request on/off
   875 // Changes UPIN request on/off
  1392 // ----------------------------------------------------------
   876 // ----------------------------------------------------------
  1393 //
   877 // qtdone
  1394 EXPORT_C TBool CSecuritySettings::ChangeUPinRequestL()
   878 EXPORT_C TBool CSecuritySettings::ChangeUPinRequestL()
  1395     {
   879     {
  1396     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
   880     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1397     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
   881     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1398     if(wcdmaSupported || upinSupported)
   882     if(wcdmaSupported || upinSupported)
  1416         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   900         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1417         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   901         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1418         RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockUniversalPin;
   902         RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockUniversalPin;
  1419     
   903     
  1420         RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetDisabled;
   904         RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1421         
   905                                     
  1422         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  1423         CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL(R_UPIN_LBX);
       
  1424         CleanupStack::PushL(items);
       
  1425                             
       
  1426         //get lock info
   906         //get lock info
  1427         iWait->SetRequestType(EMobilePhoneGetLockInfo);
   907         iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
   908         RDEBUG( "GetLockInfo", 0 );
  1428         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   909         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
   910         	RDEBUG( "WaitForRequestL", 0 );
  1429         TInt status = iWait->WaitForRequestL();
   911         TInt status = iWait->WaitForRequestL();
       
   912         	RDEBUG( "WaitForRequestL status", status );
       
   913 			  #ifdef __WINS__
       
   914 			  if (status == KErrNotSupported)
       
   915 				  status = KErrNone;
       
   916 			  #endif
  1430         User::LeaveIfError(status);                    
   917         User::LeaveIfError(status);                    
  1431         TInt currentItem = 0;
   918         TInt currentItem = 0;
  1432     
   919     
  1433         #if defined(_DEBUG)
   920         #if defined(_DEBUG)
  1434         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() GetLockInfo"));
   921         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() GetLockInfo"));
  1440             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() lockInfo: ELockSetDisabled"));
   927             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() lockInfo: ELockSetDisabled"));
  1441             #endif
   928             #endif
  1442             currentItem = 1;  // off
   929             currentItem = 1;  // off
  1443             }
   930             }
  1444                             
   931                             
  1445         TInt oldItem = currentItem;
   932 
  1446     
   933        if (currentItem == 0)	// switch the flag
  1447         CAknRadioButtonSettingPage* dlg = new (ELeave)CAknRadioButtonSettingPage(R_UPIN_SETTING_PAGE, currentItem, items);
       
  1448         CleanupStack::PushL(dlg);
       
  1449         
       
  1450     
       
  1451         CleanupStack::Pop(); // dlg
       
  1452         if ( !(dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) || oldItem==currentItem )
       
  1453             {
       
  1454             CleanupStack::PopAndDestroy();    // items
       
  1455             return EFalse;
       
  1456             }    
       
  1457     
       
  1458     
       
  1459        if (currentItem == 1)
       
  1460             {
   934             {
  1461             #if defined(_DEBUG)
   935             #if defined(_DEBUG)
  1462             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetDisabled"));
   936             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetDisabled"));
  1463             #endif
   937             #endif
  1464             lockChangeSetting = RMobilePhone::ELockSetDisabled;
   938             lockChangeSetting = RMobilePhone::ELockSetDisabled;
  1468             #if defined(_DEBUG)
   942             #if defined(_DEBUG)
  1469             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetEnabled"));
   943             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetEnabled"));
  1470             #endif
   944             #endif
  1471             lockChangeSetting = RMobilePhone::ELockSetEnabled;
   945             lockChangeSetting = RMobilePhone::ELockSetEnabled;
  1472             }
   946             }
  1473     
       
  1474         CleanupStack::PopAndDestroy();    // items 
       
  1475     
   947     
  1476         // Raise a flag to indicate that the UPIN
   948         // Raise a flag to indicate that the UPIN
  1477         // request coming from ETEL has originated from SecUi and not from Engine.
   949         // request coming from ETEL has originated from SecUi and not from Engine.
  1478         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);                              
   950         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);                              
  1479         // Change the lock setting
   951         // Change the lock setting
  1480         iWait->SetRequestType(EMobilePhoneSetLockSetting);
   952         iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1481         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
   953         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1482         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
   954         RDEBUG( "SetLockSetting", 0 );
       
   955         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);		// this calls something in the handler
       
   956         	RDEBUG( "WaitForRequestL", 0 );
  1483         status = iWait->WaitForRequestL();
   957         status = iWait->WaitForRequestL();
  1484         #if defined(_DEBUG)
   958 				RDEBUG( "WaitForRequestL status", status );
  1485         RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeUPinRequestL(): RETURN CODE: %d"), status);
       
  1486         #endif
       
  1487     
       
  1488         // Lower the flag                           
   959         // Lower the flag                           
  1489         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
   960         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
  1490         
   961 			  #ifdef __WINS__
       
   962 			  if (status == KErrNotSupported)
       
   963 			  	status = KErrNone;
       
   964 			  #endif
       
   965 
       
   966         // no need to show errors because they were displayed in the Handler
  1491         switch(status)
   967         switch(status)
  1492             {
   968             {
  1493             case KErrNone:
   969             case KErrNone:
  1494                 {
   970                 {
  1495                 break;
   971                 break;
  1532 //
  1008 //
  1533 // ----------------------------------------------------------
  1009 // ----------------------------------------------------------
  1534 // CSecuritySettings::SwitchPinCodesL()
  1010 // CSecuritySettings::SwitchPinCodesL()
  1535 // Changes the pin code currently in use (PIN/UPIN)
  1011 // Changes the pin code currently in use (PIN/UPIN)
  1536 // ----------------------------------------------------------
  1012 // ----------------------------------------------------------
  1537 //
  1013 // qtdone
  1538 EXPORT_C TBool CSecuritySettings::SwitchPinCodesL()
  1014 EXPORT_C TBool CSecuritySettings::SwitchPinCodesL()
  1539     { 
  1015     { 
  1540     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1016     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1541     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1017     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1542     if(wcdmaSupported || upinSupported)
  1018     if(wcdmaSupported || upinSupported)
  1574     
  1050     
  1575         if (activeCode == RMobilePhone::ESecurityUniversalPin)
  1051         if (activeCode == RMobilePhone::ESecurityUniversalPin)
  1576             {
  1052             {
  1577              lockType = RMobilePhone::ELockUniversalPin;
  1053              lockType = RMobilePhone::ELockUniversalPin;
  1578              iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
  1054              iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  1055              	RDEBUG( "WaitForRequestL", 0 );
  1579              TInt res = iWait->WaitForRequestL();
  1056              TInt res = iWait->WaitForRequestL();
       
  1057              	RDEBUG( "WaitForRequestL res", res );
       
  1058 						  #ifdef __WINS__
       
  1059 						  if (res == KErrNotSupported)
       
  1060 						  	res = KErrNone;
       
  1061 						  #endif
  1580              User::LeaveIfError(res);
  1062              User::LeaveIfError(res);
  1581             #if defined(_DEBUG)
       
  1582             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() Lock Info got: UPIN"));
       
  1583             #endif 
       
  1584             }
  1063             }
  1585         else
  1064         else
  1586             {
  1065             {
  1587              lockType = RMobilePhone::ELockICC;
  1066              lockType = RMobilePhone::ELockICC;
  1588              iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
  1067              iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  1068              	RDEBUG( "WaitForRequestL", 0 );
  1589              TInt res = iWait->WaitForRequestL();
  1069              TInt res = iWait->WaitForRequestL();
       
  1070              	RDEBUG( "WaitForRequestL res", res );
       
  1071 						  #ifdef __WINS__
       
  1072 						  if (res == KErrNotSupported)
       
  1073 						  	res = KErrNone;
       
  1074 						  #endif
  1590              User::LeaveIfError(res);
  1075              User::LeaveIfError(res);
  1591             #if defined(_DEBUG)
       
  1592             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() Lock Info got: PIN"));
       
  1593             #endif 
       
  1594             }
  1076             }
  1595     
  1077     
  1596         // code request must be ON to change active code.
  1078         // code request must be ON to change active code.
  1597         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  1079         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  1598            {
  1080            {
  1599             #if defined(_DEBUG)
  1081             #if defined(_DEBUG)
  1600             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON."));
  1082             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON."));
  1601             #endif
  1083             #endif
  1602             if (activeCode == RMobilePhone::ESecurityUniversalPin)
  1084             if (activeCode != RMobilePhone::ESecurityUniversalPin)
  1603                 {
  1085                 {
  1604                 ShowResultNoteL(R_UPIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1086                 ShowResultNoteL(R_UPIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1605                 }
  1087                 }
  1606             else
  1088             else
  1607                 {
  1089                 {
  1611             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON NOTE END."));
  1093             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON NOTE END."));
  1612             #endif 
  1094             #endif 
  1613             return EFalse;
  1095             return EFalse;
  1614             }
  1096             }
  1615     
  1097     
  1616         
       
  1617         
       
  1618         CCoeEnv* coeEnv = CCoeEnv::Static();
       
  1619         CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL(R_CODE_LBX);
       
  1620         CleanupStack::PushL(items);
       
  1621     
       
  1622         iCustomPhone.GetActivePin(activeCode);
  1098         iCustomPhone.GetActivePin(activeCode);
  1623         TInt currentItem = 0;
  1099         TInt currentItem = 0;
  1624     
  1100     
  1625         #if defined(_DEBUG)
  1101         #if defined(_DEBUG)
  1626         RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() GetLockInfo"));
  1102         RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() GetLockInfo"));
  1631             #if defined(_DEBUG)
  1107             #if defined(_DEBUG)
  1632             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() active code: UPIN"));
  1108             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() active code: UPIN"));
  1633             #endif
  1109             #endif
  1634             currentItem = 1;  // UPIN
  1110             currentItem = 1;  // UPIN
  1635             }
  1111             }
  1636                             
  1112 
  1637         TInt oldItem = currentItem;
  1113        if (currentItem == 0)	// switch the flag
  1638     
       
  1639         CAknRadioButtonSettingPage* dlg = new (ELeave)CAknRadioButtonSettingPage(R_CODE_IN_USE_SETTING_PAGE, currentItem, items);
       
  1640         CleanupStack::PushL(dlg);
       
  1641         
       
  1642     
       
  1643         CleanupStack::Pop(); // dlg
       
  1644         if ( !(dlg->ExecuteLD(CAknSettingPage::EUpdateWhenChanged)) || oldItem==currentItem )
       
  1645             {
       
  1646             CleanupStack::PopAndDestroy();    // items
       
  1647             return EFalse;
       
  1648             }    
       
  1649     
       
  1650     
       
  1651        if (currentItem == 1)
       
  1652             {
  1114             {
  1653             #if defined(_DEBUG)
  1115             #if defined(_DEBUG)
  1654             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: UPIN"));
  1116             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: UPIN"));
  1655             #endif
  1117             #endif
  1656             lockType = RMobilePhone::ELockUniversalPin;
  1118             lockType = RMobilePhone::ELockUniversalPin;
  1660             #if defined(_DEBUG)
  1122             #if defined(_DEBUG)
  1661             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: PIN1"));
  1123             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: PIN1"));
  1662             #endif
  1124             #endif
  1663             lockType = RMobilePhone::ELockICC;
  1125             lockType = RMobilePhone::ELockICC;
  1664             }
  1126             }
  1665     
       
  1666         CleanupStack::PopAndDestroy();    // items 
       
  1667     
  1127     
  1668         // Raise a flag to indicate that the code
  1128         // Raise a flag to indicate that the code
  1669         // request coming from ETEL has originated from SecUi and not from Engine.
  1129         // request coming from ETEL has originated from SecUi and not from Engine.
  1670         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);                           
  1130         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);                           
  1671         // Change the lock setting
  1131         // Change the lock setting
  1672         iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1132         iWait->SetRequestType(EMobilePhoneSetLockSetting);
  1673         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1133         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1674         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);
  1134        	RDEBUG( "SetLockSetting", 0 );
       
  1135         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);	// request from handler
       
  1136        		RDEBUG( "WaitForRequestL", 0 );
  1675         TInt status = iWait->WaitForRequestL();
  1137         TInt status = iWait->WaitForRequestL();
  1676         #if defined(_DEBUG)
  1138        	RDEBUG( "WaitForRequestL status", status );
  1677         RDebug::Print( _L("(SECUI)CSecuritySettings::SwitchPinCodesL(): RETURN CODE: %d"), status);
       
  1678         #endif
       
  1679         // Lower the flag                            
  1139         // Lower the flag                            
  1680         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
  1140         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
       
  1141 			  #ifdef __WINS__
       
  1142 			  if (status == KErrNotSupported)
       
  1143 			  	status = KErrNone;
       
  1144 			  #endif
       
  1145 
  1681         
  1146         
       
  1147        	// errors are shown in the handler
  1682         switch(status)
  1148         switch(status)
  1683             {
  1149             {
  1684             case KErrNone:
  1150             case KErrNone:
  1685                 {
  1151                 {
  1686                 break;
  1152                 break;
  1722 //
  1188 //
  1723 // ----------------------------------------------------------
  1189 // ----------------------------------------------------------
  1724 // CSecuritySettings::IsLockEnabledL()
  1190 // CSecuritySettings::IsLockEnabledL()
  1725 // Return is lock enabled/disabled
  1191 // Return is lock enabled/disabled
  1726 // ----------------------------------------------------------
  1192 // ----------------------------------------------------------
  1727 //
  1193 // qtdone
  1728 EXPORT_C TBool CSecuritySettings::IsLockEnabledL(RMobilePhone::TMobilePhoneLock aLockType)
  1194 EXPORT_C TBool CSecuritySettings::IsLockEnabledL(RMobilePhone::TMobilePhoneLock aLockType)
  1729     {
  1195     {
  1730     /*****************************************************
  1196     TBool ret=EFalse;
  1731     *    Series 60 Customer / ETel
       
  1732     *    Series 60  ETel API
       
  1733     *****************************************************/
       
  1734     #if defined(_DEBUG)
       
  1735     RDebug::Print(_L("(SECUI)CSecuritySettings::IsLockEnabledL()"));
       
  1736     #endif
       
  1737     #ifdef __WINS__
       
  1738 
       
  1739     return EFalse;
       
  1740 
       
  1741     #else  //WINS
       
  1742 
       
  1743     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1197     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1744     
       
  1745     //get lock info
  1198     //get lock info
  1746     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1199     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1747     iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1200     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
  1201     RDEBUG( "GetLockInfo", 0 );
  1748     iPhone.GetLockInfo(iWait->iStatus, aLockType, lockInfoPkg);
  1202     iPhone.GetLockInfo(iWait->iStatus, aLockType, lockInfoPkg);
       
  1203     	RDEBUG( "WaitForRequestL", 0 );
  1749     TInt res = iWait->WaitForRequestL();
  1204     TInt res = iWait->WaitForRequestL();
       
  1205     RDEBUG( "WaitForRequestL res", res );
  1750 
  1206 
  1751     if (res != KErrNone)
  1207     if (res != KErrNone)
  1752         return ETrue;
  1208         ret = ETrue;
  1753 
       
  1754      //lock is enabled return true
  1209      //lock is enabled return true
  1755     if (lockInfo.iSetting == RMobilePhone::ELockSetEnabled)
  1210     else if (lockInfo.iSetting == RMobilePhone::ELockSetEnabled)
  1756         {
  1211         {
  1757         return ETrue;                        
  1212         ret = ETrue;                        
  1758         }
  1213         }
  1759 
  1214 			RDEBUG( "ret", ret );
  1760     // lock is disabled return false
  1215 	  return ret;
  1761     return EFalse;
       
  1762         
       
  1763     #endif 
       
  1764 
       
  1765     }
  1216     }
  1766 //
  1217 //
  1767 // ----------------------------------------------------------
  1218 // ----------------------------------------------------------
  1768 // CSecuritySettings::AskSecCodeL()
  1219 // CSecuritySettings::AskSecCodeL()
  1769 // For asking security code e.g in settings
  1220 // For asking security code e.g in settings
  1770 // ----------------------------------------------------------
  1221 // ----------------------------------------------------------
  1771 //
  1222 // qtdone
  1772 EXPORT_C TBool CSecuritySettings::AskSecCodeL()
  1223 EXPORT_C TBool CSecuritySettings::AskSecCodeL()
  1773     {
  1224     {
  1774     return iSecurityHandler->AskSecCodeL();
  1225     return iSecurityHandler->AskSecCodeL();
  1775     }
  1226     }
  1776 //
  1227 //
  1777 // ----------------------------------------------------------
  1228 // ----------------------------------------------------------
  1778 // CSecuritySettings::AskPin2L()
  1229 // CSecuritySettings::AskPin2L()
  1779 // Asks PIN2
  1230 // Asks PIN2
  1780 // ----------------------------------------------------------
  1231 // ----------------------------------------------------------
  1781 //    
  1232 // qtdone
  1782 EXPORT_C TBool CSecuritySettings::AskPin2L()
  1233 EXPORT_C TBool CSecuritySettings::AskPin2L()
  1783     {    
  1234     {    
  1784     /*****************************************************
  1235     /*****************************************************
  1785     *    Series 60 Customer / ETel
  1236     *    Series 60 Customer / ETel
  1786     *    Series 60  ETel API
  1237     *    Series 60  ETel API
  1787     *****************************************************/
  1238     *****************************************************/
  1788     #if defined(_DEBUG)
  1239     	RDEBUG( "0", 0 );
  1789     RDebug::Print(_L("(SECUI)CSecuritySettings::AskPin2L()"));
  1240     TInt retPhone = 0;
  1790     #endif
       
  1791     TInt ret = 0;
       
  1792     // check if pin2 is blocked...
  1241     // check if pin2 is blocked...
  1793     RMmCustomAPI::TSecurityCodeType secCodeType = RMmCustomAPI::ESecurityCodePin2;
  1242     RMmCustomAPI::TSecurityCodeType secCodeType = RMmCustomAPI::ESecurityCodePin2;
  1794     RMobilePhone::TMobilePhoneSecurityCode etelsecCodeType(RMobilePhone::ESecurityCodePin2);
  1243     RMobilePhone::TMobilePhoneSecurityCode etelsecCodeType(RMobilePhone::ESecurityCodePin2);
  1795     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
  1244     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
  1796     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
  1245     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1246    	RMobilePhone::TMobilePassword password;
  1797     TBool isBlocked = EFalse;
  1247     TBool isBlocked = EFalse;
       
  1248     TInt queryAccepted = KErrCancel;
  1798     //Check whether PIN2 is blocked
  1249     //Check whether PIN2 is blocked
  1799     ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  1250     retPhone = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  1800     
  1251     
  1801 	#if defined(_DEBUG)
  1252 		RDEBUG( "retPhone", retPhone );
  1802     RDebug::Print(_L("(SECUI)CSecuritySettings::AskPin2L() IsBlocked return value: %d"), ret);
  1253 		RDEBUG( "isBlocked", isBlocked );
  1803     #endif
  1254   #ifdef __WINS__
       
  1255   if (retPhone == KErrNotSupported)
       
  1256   	retPhone = KErrNone;
       
  1257   #endif
  1804     if(isBlocked)
  1258     if(isBlocked)
  1805         return EFalse;
  1259         return EFalse;
  1806     
  1260     
  1807     if (ret != KErrNone)
  1261     if (retPhone != KErrNone)
  1808         {    
  1262         {    
  1809         switch (ret)
  1263         switch (retPhone)
  1810             {
  1264             {
  1811 			// PIN2 Blocked.
  1265 			// PIN2 Blocked.
  1812             case KErrGsm0707SIMPuk2Required:
  1266             case KErrGsm0707SIMPuk2Required:
  1813                 break;
  1267                 break;
  1814             case KErrGsmSSPasswordAttemptsViolation:
  1268             case KErrGsmSSPasswordAttemptsViolation:
  1819             case KErrGsm0707SimNotInserted:
  1273             case KErrGsm0707SimNotInserted:
  1820                 // not allowed with this sim
  1274                 // not allowed with this sim
  1821                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1275                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1822                 break;
  1276                 break;
  1823             default:
  1277             default:
  1824                 ShowErrorNoteL(ret);
  1278                 ShowErrorNoteL(retPhone);
  1825                 break;
  1279                 break;
  1826             }
  1280             }
  1827         return EFalse;
  1281         return EFalse;
  1828         }
  1282         }
  1829     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
  1283     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  1284     	RDEBUG( "GetSecurityCodeInfo", 0 );
  1830     iPhone.GetSecurityCodeInfo(iWait->iStatus, etelsecCodeType, codeInfoPkg);
  1285     iPhone.GetSecurityCodeInfo(iWait->iStatus, etelsecCodeType, codeInfoPkg);
  1831     ret = iWait->WaitForRequestL();
  1286     	RDEBUG( "WaitForRequestL", 0 );
       
  1287     retPhone = iWait->WaitForRequestL();
       
  1288     RDEBUG( "WaitForRequestL retPhone", retPhone );
       
  1289 	  #ifdef __WINS__
       
  1290 	  if (retPhone == KErrNotSupported || retPhone == KErrTimedOut)
       
  1291 	  	{
       
  1292 	  	retPhone = KErrNone;
       
  1293 	  	codeInfo.iRemainingEntryAttempts = 3;
       
  1294 	  	}
       
  1295 	  #endif
       
  1296     User::LeaveIfError(retPhone);
  1832         
  1297         
  1833     #if defined(_DEBUG)
       
  1834     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): get PIN2 info result: %d"), ret);
       
  1835     TInt attempts(codeInfo.iRemainingEntryAttempts);
  1298     TInt attempts(codeInfo.iRemainingEntryAttempts);
  1836     RDebug::Print(_L("(SECUI)CSecurityHandler::Pin2RequiredL(): attempts remaining: %d"), attempts);
  1299     	RDEBUG( "attempts", attempts );
  1837     #endif
       
  1838     User::LeaveIfError(ret);
       
  1839     
  1300     
  1840     // ask pin2 code  
  1301     // ask pin2 code  
  1841     RMobilePhone::TMobilePassword password;
  1302 			/* request PIN using QT */
  1842     CCodeQueryDialog* dlg = new (ELeave) CCodeQueryDialog (password,SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH,ESecUiNone);  
  1303 			queryAccepted = KErrCancel;
  1843     if(codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
  1304 			CSecQueryUi *iSecQueryUi;
  1844             ret = dlg->ExecuteLD(R_PIN2_QUERY);
  1305 			iSecQueryUi = CSecQueryUi::NewL();
  1845     else if(codeInfo.iRemainingEntryAttempts > KLastRemainingInputAttempt)
  1306 			TBuf<0x100> title;	title.Zero();	title.Append(_L("PIN2"));	title.Append(_L("#"));	title.AppendNum(codeInfo.iRemainingEntryAttempts);
  1846             {
  1307 			queryAccepted = iSecQueryUi->SecQueryDialog( title, password, SEC_C_PIN_CODE_MIN_LENGTH,SEC_C_PIN_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  1847                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_REMAINING_PIN2_ATTEMPTS, codeInfo.iRemainingEntryAttempts );
  1308 				RDEBUG( "password", 0 );
  1848                 ret = dlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
  1309 			RDebug::Print( password );
  1849                 CleanupStack::PopAndDestroy(queryPrompt);
  1310 			RDEBUG( "queryAccepted", queryAccepted );
  1850             }
  1311 			delete iSecQueryUi;
  1851     else
  1312 			if(queryAccepted!=KErrNone)
  1852             {
  1313 					return EFalse;
  1853                 HBufC* queryPrompt = StringLoader::LoadLC(R_SECUI_FINAL_PIN2_ATTEMPT);
       
  1854                 ret = dlg->ExecuteLD(R_PIN2_QUERY, *queryPrompt);
       
  1855                 CleanupStack::PopAndDestroy(queryPrompt);   
       
  1856             } 
       
  1857        
       
  1858     if (!ret)
       
  1859         {
       
  1860 		#if defined(_DEBUG)
       
  1861 		RDebug::Print(_L("(SECUI)CSecuritySettings::AskPin2L(): Cancel pressed"));
       
  1862 		#endif
       
  1863         return EFalse;
       
  1864         }
       
  1865     
  1314     
  1866     // verify code
  1315     // verify code
  1867     RMobilePhone::TMobilePassword required_fourth;
  1316     RMobilePhone::TMobilePassword required_fourth;
  1868     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
  1317     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
       
  1318     	RDEBUG( "VerifySecurityCode", 0 );
  1869     iPhone.VerifySecurityCode(iWait->iStatus,etelsecCodeType, password, required_fourth);
  1319     iPhone.VerifySecurityCode(iWait->iStatus,etelsecCodeType, password, required_fourth);
  1870     TInt res = iWait->WaitForRequestL();
  1320     	RDEBUG( "WaitForRequestL", 0 );
  1871 
  1321     retPhone = iWait->WaitForRequestL();
  1872 	#if defined(_DEBUG)
  1322     RDEBUG( "WaitForRequestL retPhone", retPhone );
  1873     RDebug::Print(_L("(SECUI)CSecuritySettings::AskPin2L() VerifySecurityCode return value: %d"), res);
  1323 	  #ifdef __WINS__
  1874     #endif
  1324 	  if (retPhone == KErrNotSupported)
  1875 
  1325 	  	retPhone = KErrNone;
  1876     switch(res)
  1326 	  #endif
       
  1327 
       
  1328     switch(retPhone)
  1877         {        
  1329         {        
  1878         case KErrNone:
  1330         case KErrNone:
  1879             break;
  1331             break;
  1880         case KErrGsm0707IncorrectPassword:
  1332         case KErrGsm0707IncorrectPassword:
  1881         case KErrAccessDenied:
  1333         case KErrAccessDenied:
  1890         case KErrLocked:
  1342         case KErrLocked:
  1891             // code was blocked
  1343             // code was blocked
  1892             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
  1344             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
  1893             return EFalse;        
  1345             return EFalse;        
  1894         default:
  1346         default:
  1895             ShowErrorNoteL(res);
  1347             ShowErrorNoteL(retPhone);
  1896             return    AskPin2L();
  1348             return    AskPin2L();
  1897         }
  1349         }
  1898 
  1350 
  1899     return ETrue;
  1351     return ETrue;
  1900     }
  1352     }
  1901 //
  1353 //
  1902 // ----------------------------------------------------------
  1354 // ----------------------------------------------------------
  1903 // CSecuritySettings::SetFdnModeL()
  1355 // CSecuritySettings::SetFdnModeL()
  1904 // Activates or deactivates Fixed Dialling Numbers (FDN) mode.  
  1356 // Activates or deactivates Fixed Dialling Numbers (FDN) mode.  
  1905 // ----------------------------------------------------------
  1357 // ----------------------------------------------------------
  1906 //
  1358 // not qtdone
  1907 EXPORT_C void CSecuritySettings::SetFdnModeL()
  1359 EXPORT_C void CSecuritySettings::SetFdnModeL()
  1908     {    
  1360     {    
  1909     /*****************************************************
  1361     /*****************************************************
  1910     *    Series 60 Customer / ETel
  1362     *    Series 60 Customer / ETel
  1911     *    Series 60  ETel API
  1363     *    Series 60  ETel API
  1915     #endif
  1367     #endif
  1916     RMmCustomAPI::TSecurityCodeType secCodeType = RMmCustomAPI::ESecurityCodePin2;
  1368     RMmCustomAPI::TSecurityCodeType secCodeType = RMmCustomAPI::ESecurityCodePin2;
  1917     
  1369     
  1918     TBool isBlocked = EFalse;
  1370     TBool isBlocked = EFalse;
  1919     TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  1371     TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  1920     
  1372     	RDEBUG( "isBlocked", isBlocked );
       
  1373     	RDEBUG( "ret", ret );
  1921     if(isBlocked)
  1374     if(isBlocked)
  1922         return;
  1375         return;
  1923     
  1376     
  1924     if (ret != KErrNone)
  1377     if (ret != KErrNone)
  1925         {    
  1378         {    
  1958         }
  1411         }
  1959     else
  1412     else
  1960         {
  1413         {
  1961         fdnSet = RMobilePhone::EFdnSetOn;   
  1414         fdnSet = RMobilePhone::EFdnSetOn;   
  1962         }
  1415         }
  1963         
  1416     	RDEBUG( "fdnSet", fdnSet );
  1964       // Change the FDN setting
  1417       // Change the FDN setting
  1965     iWait->SetRequestType(EMobilePhoneSetFdnSetting);
  1418     iWait->SetRequestType(EMobilePhoneSetFdnSetting);
  1966     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  1419     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
  1420     	RDEBUG( "SetFdnSetting", 0 );
  1967     iPhone.SetFdnSetting(iWait->iStatus, fdnSet);
  1421     iPhone.SetFdnSetting(iWait->iStatus, fdnSet);
       
  1422     	RDEBUG( "WaitForRequestL", 0 );
  1968     status = iWait->WaitForRequestL();
  1423     status = iWait->WaitForRequestL();
       
  1424     RDEBUG( "WaitForRequestL status", status );
       
  1425 	  #ifdef __WINS__
       
  1426 	  if (status == KErrNotSupported)
       
  1427 	  	status = KErrNone;
       
  1428 	  #endif
       
  1429 
  1969 
  1430 
  1970     #if defined(_DEBUG)
  1431     #if defined(_DEBUG)
  1971     RDebug::Print( _L("(SECUI)CSecuritySettings::SetFdnModeL(): RETURN CODE: %d"), status);
  1432     RDebug::Print( _L("(SECUI)CSecuritySettings::SetFdnModeL(): RETURN CODE: %d"), status);
  1972     #endif
  1433     #endif
  1973     switch(status)
  1434     switch(status)
  1996 //
  1457 //
  1997 // ----------------------------------------------------------
  1458 // ----------------------------------------------------------
  1998 // CSecuritySettings::GetFndMode()
  1459 // CSecuritySettings::GetFndMode()
  1999 // Retrieves the current Fixed Dialling Numbers mode
  1460 // Retrieves the current Fixed Dialling Numbers mode
  2000 // ----------------------------------------------------------
  1461 // ----------------------------------------------------------
  2001 //
  1462 // qtdone
  2002 EXPORT_C TInt CSecuritySettings::GetFdnMode (RMobilePhone::TMobilePhoneFdnStatus& aFdnMode)
  1463 EXPORT_C TInt CSecuritySettings::GetFdnMode (RMobilePhone::TMobilePhoneFdnStatus& aFdnMode)
  2003     {
  1464     {
  2004     /*****************************************************
  1465     /*****************************************************
  2005     *    Series 60 Customer / ETel
  1466     *    Series 60 Customer / ETel
  2006     *    Series 60  ETel API
  1467     *    Series 60  ETel API
  2014 //
  1475 //
  2015 // ----------------------------------------------------------
  1476 // ----------------------------------------------------------
  2016 // CSecuritySettings::ShowErrorNoteL()
  1477 // CSecuritySettings::ShowErrorNoteL()
  2017 // Shows error note
  1478 // Shows error note
  2018 // ----------------------------------------------------------
  1479 // ----------------------------------------------------------
  2019 //
  1480 // qtdone
  2020 void CSecuritySettings::ShowErrorNoteL(TInt aError)
  1481 void CSecuritySettings::ShowErrorNoteL(TInt aError)
  2021     {
  1482     {
  2022     #if defined(_DEBUG)
  1483    		RDEBUG( "aError", aError );
  2023     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowErrorNoteL()"));
       
  2024     #endif
       
  2025    	RDebug::Printf( "%s %s (%u) aError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aError );  
       
  2026     
  1484     
  2027     ShowResultNoteL(aError, CAknNoteDialog::EErrorTone);
  1485     ShowResultNoteL(aError, CAknNoteDialog::EErrorTone);
  2028     }
  1486     }
  2029 
  1487 
  2030 //
  1488 //
  2031 // ----------------------------------------------------------
  1489 // ----------------------------------------------------------
  2032 // CSecuritySettings::ShowResultNoteL()
  1490 // CSecuritySettings::ShowResultNoteL()
  2033 // Shows result note
  1491 // Shows result note
  2034 // ----------------------------------------------------------
  1492 // ----------------------------------------------------------
  2035 //
  1493 // qtdone
  2036 void CSecuritySettings::ShowResultNoteL(TInt aResourceID, CAknNoteDialog::TTone aTone)
  1494 void CSecuritySettings::ShowResultNoteL(TInt aResourceID, CAknNoteDialog::TTone aTone)
  2037     {  
  1495     {  
  2038     #if defined(_DEBUG)
  1496     	RDEBUG( "aResourceID", aResourceID );
  2039     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL()"));
       
  2040     RDebug::Print(_L("(SECUI)CSecuritySettings::ShowResultNoteL() Resource ID: %d"), aResourceID);
       
  2041     #endif
       
  2042     RDebug::Printf( "%s %s (%u) aResourceID=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aResourceID );
       
  2043     
  1497     
  2044     /*
  1498     /*
  2045     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
  1499     CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
  2046     noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
  1500     noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
  2047     noteDlg->SetTone(aTone);
  1501     noteDlg->SetTone(aTone);
  2049     */
  1503     */
  2050     CHbDeviceMessageBoxSymbian* messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
  1504     CHbDeviceMessageBoxSymbian* messageBox = CHbDeviceMessageBoxSymbian::NewL(CHbDeviceMessageBoxSymbian::EWarning);
  2051     CleanupStack::PushL(messageBox);
  1505     CleanupStack::PushL(messageBox);
  2052     _LIT(KText, "ShowResultNoteL: ");
  1506     _LIT(KText, "ShowResultNoteL: ");
  2053 		TBuf<0x200> title;
  1507 		TBuf<0x200> title;
       
  1508 		TBuf<0x200> titleTr;
  2054 		title.Zero();
  1509 		title.Zero();
       
  1510 		titleTr.Zero();
  2055 		title.Append(KText);
  1511 		title.Append(KText);
  2056 		title.AppendNum(aResourceID);
  1512 		title.AppendNum(aResourceID);
  2057     _LIT(KSeparator, " ");
  1513     _LIT(KSeparator, " ");
  2058 		title.Append(KSeparator);
  1514 		title.Append(KSeparator);
  2059     switch(aResourceID)
  1515     switch(aResourceID)
  2060     {
  1516     {
  2061     	case 0:
  1517     	case 0:
       
  1518 	    	titleTr.Append(_L("OK"));
  2062 	    	title.Append(_L("OK"));
  1519 	    	title.Append(_L("OK"));
  2063 	    	break;
  1520 	    	break;
  2064     	case KErrGsm0707IncorrectPassword:
  1521     	case KErrGsm0707IncorrectPassword:
  2065     		title.Append(_L("KErrGsm0707IncorrectPassword"));
  1522     		titleTr.Append(_L("KErrGsm0707IncorrectPassword"));
       
  1523     		title.Append(_L("Incorrect Password"));
  2066 	    	break;
  1524 	    	break;
  2067     	case KErrAccessDenied:
  1525     	case KErrAccessDenied:
  2068 	    	title.Append(_L("KErrAccessDenied"));
  1526 	    	titleTr.Append(_L("KErrAccessDenied"));
       
  1527 	    	title.Append(_L("Access Denied"));
  2069 	    	break;
  1528 	    	break;
  2070     	case KErrGsmSSPasswordAttemptsViolation:
  1529     	case KErrGsmSSPasswordAttemptsViolation:
  2071   	  	title.Append(_L("KErrGsmSSPasswordAttemptsViolation"));
  1530   	  	titleTr.Append(_L("KErrGsmSSPasswordAttemptsViolation"));
       
  1531   	  	title.Append(_L("Password Attempts Violation"));
  2072 	    	break;
  1532 	    	break;
  2073     	case KErrLocked:
  1533     	case KErrLocked:
  2074     		title.Append(_L("KErrLocked"));
  1534     		titleTr.Append(_L("KErrLocked"));
       
  1535     		title.Append(_L("Locked"));
  2075 	    	break;
  1536 	    	break;
  2076     	case KErrGsm0707OperationNotAllowed:
  1537     	case KErrGsm0707OperationNotAllowed:
  2077     		title.Append(_L("KErrGsm0707OperationNotAllowed"));
  1538     		titleTr.Append(_L("KErrGsm0707OperationNotAllowed"));
       
  1539     		title.Append(_L("Operation Not Allowed"));
  2078 	    	break;
  1540 	    	break;
  2079     	case KErrAbort:
  1541     	case KErrAbort:
  2080 	    	title.Append(_L("KErrAbort"));
  1542 	    	titleTr.Append(_L("KErrAbort"));
       
  1543 	    	title.Append(_L("Abort"));
  2081 	    	break;
  1544 	    	break;
  2082     	case KErrNotSupported:
  1545     	case KErrNotSupported:
  2083   	  	title.Append(_L("KErrNotSupported"));
  1546   	  	titleTr.Append(_L("KErrNotSupported"));
       
  1547   	  	title.Append(_L("Not Supported"));
  2084 	    	break;
  1548 	    	break;
  2085     	case R_SEC_BLOCKED:
  1549     	case R_SEC_BLOCKED:
  2086   	  	title.Append(_L("R_SEC_BLOCKED"));
  1550   	  	titleTr.Append(_L("R_SEC_BLOCKED"));
       
  1551   	  	title.Append(_L("BLOCKED"));
  2087 	    	break;
  1552 	    	break;
  2088     	case R_CODE_ERROR:
  1553     	case R_CODE_ERROR:
  2089   	  	title.Append(_L("R_CODE_ERROR"));
  1554   	  	titleTr.Append(_L("R_CODE_ERROR"));
       
  1555   	  	title.Append(_L("ERROR"));
  2090 	    	break;
  1556 	    	break;
  2091     	case KErrGsmInvalidParameter:
  1557     	case KErrGsmInvalidParameter:
  2092   	  	title.Append(_L("KErrGsmInvalidParameter"));
  1558   	  	titleTr.Append(_L("KErrGsmInvalidParameter"));
       
  1559   	  	title.Append(_L("Invalid Parameter"));
  2093 	    	break;
  1560 	    	break;
  2094     	case R_CONFIRMATION_NOTE:
  1561     	case R_CONFIRMATION_NOTE:
  2095   	  	title.Append(_L("R_CONFIRMATION_NOTE"));
  1562   	  	titleTr.Append(_L("R_CONFIRMATION_NOTE"));
       
  1563   	  	title.Append(_L("CONFIRMED"));
  2096 	    	break;
  1564 	    	break;
  2097     	case R_CODES_DONT_MATCH:
  1565     	case R_CODES_DONT_MATCH:
  2098   	  	title.Append(_L("R_CODES_DONT_MATCH"));
  1566   	  	titleTr.Append(_L("R_CODES_DONT_MATCH"));
       
  1567   	  	title.Append(_L("CODES DONT MATCH"));
  2099 	    	break;
  1568 	    	break;
  2100     	case R_PIN_CODE_CHANGED_NOTE:
  1569     	case R_PIN_CODE_CHANGED_NOTE:
  2101   	  	title.Append(_L("R_PIN_CODE_CHANGED_NOTE"));
  1570   	  	titleTr.Append(_L("R_PIN_CODE_CHANGED_NOTE"));
       
  1571   	  	title.Append(_L("PIN CODE CHANGED"));
  2102 	    	break;
  1572 	    	break;
  2103     	case R_SECURITY_CODE_CHANGED_NOTE:
  1573     	case R_SECURITY_CODE_CHANGED_NOTE:
  2104   	  	title.Append(_L("R_SECURITY_CODE_CHANGED_NOTE"));
  1574   	  	titleTr.Append(_L("R_SECURITY_CODE_CHANGED_NOTE"));
       
  1575   	  	title.Append(_L("SECURITY CODE CHANGED"));
  2105 	    	break;
  1576 	    	break;
  2106     	default:
  1577     	case R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE:
       
  1578   	  	titleTr.Append(_L("R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE"));
       
  1579   	  	title.Append(_L("AUTOLOCK MUST BE ACTIVE"));
       
  1580 	    	break;
       
  1581     	case KErrServerTerminated:
       
  1582   	  	titleTr.Append(_L("KErrServerTerminated"));
       
  1583   	  	title.Append(_L("Server Terminated"));
       
  1584 	    	break;
       
  1585     	case KErrServerBusy:
       
  1586   	  	titleTr.Append(_L("KErrServerBusy"));
       
  1587   	  	title.Append(_L("Server Busy"));
       
  1588 	    	break;
       
  1589     	case R_PIN2_REJECTED:
       
  1590   	  	titleTr.Append(_L("R_PIN2_REJECTED"));
       
  1591   	  	title.Append(_L("PIN2 REJECTED"));
       
  1592 	    	break;
       
  1593     	case R_OPERATION_NOT_ALLOWED:
       
  1594   	  	titleTr.Append(_L("R_OPERATION_NOT_ALLOWED"));
       
  1595   	  	title.Append(_L("OPERATION NOT ALLOWED"));
       
  1596 	    	break;
       
  1597     	case R_UPIN_NOT_ALLOWED:
       
  1598   	  	titleTr.Append(_L("R_UPIN_NOT_ALLOWED"));
       
  1599   	  	title.Append(_L("UPIN NOT ALLOWED"));
       
  1600 	    	break;
       
  1601     	case R_PIN_NOT_ALLOWED:
       
  1602   	  	titleTr.Append(_L("R_PIN_NOT_ALLOWED"));
       
  1603   	  	title.Append(_L("PIN NOT ALLOWED"));
       
  1604 	    	break;
       
  1605     	case R_INSERT_SIM:
       
  1606   	  	titleTr.Append(_L("R_INSERT_SIM"));
       
  1607   	  	title.Append(_L("INSERT SIM"));
       
  1608 	    	break;
       
  1609     	case R_SIM_ON:
       
  1610   	  	titleTr.Append(_L("R_SIM_ON"));
       
  1611   	  	title.Append(_L("SIM ON"));
       
  1612 	    	break;
       
  1613     	case KErrTimedOut:
       
  1614   	  	titleTr.Append(_L("KErrTimedOut"));
       
  1615   	  	title.Append(_L("Timed Out"));
       
  1616 	    	break;
       
  1617     	case R_PIN2_CODE_CHANGED_NOTE:
       
  1618   	  	titleTr.Append(_L("R_PIN2_CODE_CHANGED_NOTE"));
       
  1619   	  	title.Append(_L("PIN2 CODE CHANGED"));
       
  1620 	    	break;
       
  1621     	case KErrArgument:
       
  1622   	  	titleTr.Append(_L("KErrArgument"));
       
  1623   	  	title.Append(_L("Error Argument"));
       
  1624 	    	break;
       
  1625 
       
  1626     	default:	// " "
       
  1627     		titleTr.Append(_L("Specific Error"));
  2107     		title.Append(_L("Specific Error"));
  1628     		title.Append(_L("Specific Error"));
  2108 	    	break;
  1629 	    	break;
  2109 		}
  1630 		}
  2110 	  messageBox->SetTextL(title);
  1631 	  messageBox->SetTextL(title);
  2111 		RDebug::Printf( "%s %s (%u) aResourceID=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aResourceID );
  1632 			RDEBUG( "aResourceID", aResourceID );
       
  1633 		RDebug::Print( titleTr );
  2112 	
  1634 	
  2113     _LIT(KIconName, "qtg_small_smiley_wondering");
  1635     _LIT(KIconName, "qtg_small_smiley_wondering");
  2114     messageBox->SetIconNameL(KIconName);
  1636     messageBox->SetIconNameL(KIconName);
  2115 
  1637     // TODO use aTone for sound
  2116     messageBox->ExecL();
  1638 
       
  1639     // use default timeout
       
  1640     messageBox->ShowL();
  2117     CleanupStack::PopAndDestroy(); // messageBox
  1641     CleanupStack::PopAndDestroy(); // messageBox
  2118 
  1642 
  2119     }
  1643     }
  2120 
  1644 
  2121 //
  1645 //
  2122 // ----------------------------------------------------------
  1646 // ----------------------------------------------------------
  2123 // CSecuritySettings::IsUpinSupportedL()
  1647 // CSecuritySettings::IsUpinSupportedL()
  2124 // Return is UPIN supported
  1648 // Return is UPIN supported
  2125 // ----------------------------------------------------------
  1649 // ----------------------------------------------------------
  2126 //
  1650 // qtdone
  2127 EXPORT_C TBool CSecuritySettings::IsUpinSupportedL()
  1651 EXPORT_C TBool CSecuritySettings::IsUpinSupportedL()
  2128 {
  1652 {
  2129     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1653     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  2130     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1654     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
  1655    	TBool isSupported = EFalse;
  2131     if(wcdmaSupported || upinSupported)
  1656     if(wcdmaSupported || upinSupported)
  2132       {
  1657       {
  2133     	#if defined(_DEBUG)
  1658     	#if defined(_DEBUG)
  2134         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() BEGIN"));
  1659         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() BEGIN"));
  2135         #endif
  1660         #endif
  2136         #ifdef __WINS__
       
  2137     
       
  2138         return EFalse;
       
  2139     
       
  2140         #else  //WINS
       
  2141     
  1661     
  2142         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1662         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2143         
  1663         
  2144         //get lock info
  1664         //get lock info
  2145         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1665         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2146         iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1666         iWait->SetRequestType(EMobilePhoneGetLockInfo);
  2147         #if defined(_DEBUG)
  1667         RDEBUG( "GetLockInfo", 0 );
  2148         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() GetLockInfo"));
       
  2149         #endif
       
  2150         iPhone.GetLockInfo(iWait->iStatus, RMobilePhone::ELockUniversalPin, lockInfoPkg);
  1668         iPhone.GetLockInfo(iWait->iStatus, RMobilePhone::ELockUniversalPin, lockInfoPkg);
       
  1669        		RDEBUG( "WaitForRequestL", 0 );
  2151         TInt res = iWait->WaitForRequestL();
  1670         TInt res = iWait->WaitForRequestL();
  2152         #if defined(_DEBUG)
  1671         RDEBUG( "WaitForRequestL res", res );
  2153         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() GetLockInfo DONE"));
       
  2154         #endif
       
  2155         if ((res == KErrNotSupported) || (res == KErrGsmInvalidParameter))
  1672         if ((res == KErrNotSupported) || (res == KErrGsmInvalidParameter))
  2156         {
  1673         {
  2157             #if defined(_DEBUG)
  1674             #if defined(_DEBUG)
  2158             RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported(): NOT SUPPORTED"));
  1675             RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported(): NOT SUPPORTED"));
  2159             #endif
  1676             #endif
  2160             return EFalse;
  1677             isSupported = EFalse;
  2161         }
  1678         }
  2162         #if defined(_DEBUG)
  1679         else
  2163         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported(): SUPPORTED: %d"), res);
  1680         	{
  2164         #endif
  1681 	        	RDEBUG( "0", 0 );
  2165         #if defined(_DEBUG)
  1682 
  2166         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() END"));
  1683   	      isSupported = ETrue;
  2167         #endif
  1684   	    	}
  2168         return ETrue;
       
  2169             
       
  2170         #endif //WINS
       
  2171       }
  1685       }
  2172     else
  1686     else
  2173         return EFalse;
  1687         isSupported = EFalse;
       
  1688     	RDEBUG( "isSupported", isSupported );
       
  1689    	return isSupported;
  2174 }
  1690 }
  2175 //
  1691 //
  2176 // ----------------------------------------------------------
  1692 // ----------------------------------------------------------
  2177 // CSecuritySettings::IsCodeBlocked()
  1693 // CSecuritySettings::IsUpinBlocked()
  2178 // Return is a code blocked
  1694 // Return is a code blocked
  2179 // ----------------------------------------------------------
  1695 // ----------------------------------------------------------
  2180 //
  1696 // qtdone
  2181 EXPORT_C TBool CSecuritySettings::IsUpinBlocked()
  1697 EXPORT_C TBool CSecuritySettings::IsUpinBlocked()
  2182 {
  1698 {
  2183 TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1699 TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  2184     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1700     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  2185     if(wcdmaSupported || upinSupported)
  1701     if(wcdmaSupported || upinSupported)
  2186       {
  1702       {
  2187     #ifdef __WINS__
       
  2188         return EFalse;
       
  2189     #else//__WINS__
       
  2190         #if defined(_DEBUG)
       
  2191         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinBlocked() BEGIN"));
       
  2192         #endif
       
  2193     	RMmCustomAPI::TSecurityCodeType secCodeType;
  1703     	RMmCustomAPI::TSecurityCodeType secCodeType;
  2194         secCodeType = RMmCustomAPI::ESecurityUniversalPin;
  1704         secCodeType = RMmCustomAPI::ESecurityUniversalPin;
  2195         TBool isBlocked = EFalse;
  1705         TBool isBlocked = EFalse;
  2196         #if defined(_DEBUG)
  1706         	RDEBUG( "IsBlocked", 0 );
  2197         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinBlocked() IsBlocked"));
       
  2198         #endif
       
  2199         TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  1707         TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
  2200         #if defined(_DEBUG)
  1708         	RDEBUG( "ret", ret );
  2201         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinBlocked() DONE.RETURN: %d"), ret);
  1709         	RDEBUG( "isBlocked", isBlocked );
  2202         #endif
       
  2203         #if defined(_DEBUG)
       
  2204         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinBlocked():isblocked: %d"), isBlocked);
       
  2205         #endif
       
  2206         #if defined(_DEBUG)
       
  2207         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinBlocked() END"));
       
  2208         #endif
       
  2209         return isBlocked;
  1710         return isBlocked;
  2210     #endif //__WINS__
       
  2211       }
  1711       }
  2212     else
  1712     else
  2213         return EFalse;
  1713         return EFalse;
  2214 }
  1714 }
  2215 //
  1715 //
  2216 // ----------------------------------------------------------
  1716 // ----------------------------------------------------------
  2217 // CSecuritySettings::GetActivePinCode()
  1717 // CSecuritySettings::IsUpinActive()
  2218 // Return the code active in current application (PIN/UPIN)
  1718 // Return the code active in current application (PIN/UPIN)
  2219 // ----------------------------------------------------------
  1719 // ----------------------------------------------------------
  2220 //
  1720 // qtdone
  2221 EXPORT_C TBool CSecuritySettings::IsUpinActive()
  1721 EXPORT_C TBool CSecuritySettings::IsUpinActive()
  2222 {
  1722 {
  2223     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  1723     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
  2224     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  1724     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
  2225     if(wcdmaSupported || upinSupported)
  1725     if(wcdmaSupported || upinSupported)
  2226       {
  1726       {
  2227         #ifdef __WINS__
       
  2228         return EFalse;
       
  2229         #else//__WINS__
       
  2230         #if defined(_DEBUG)
       
  2231         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive() BEGIN"));
       
  2232         #endif
       
  2233     	RMobilePhone::TMobilePhoneSecurityCode activePin;
  1727     	RMobilePhone::TMobilePhoneSecurityCode activePin;
  2234         #if defined(_DEBUG)
  1728    			RDEBUG( "GetActivePin", 0 );
  2235         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive() GetActivePin"));
  1729       iCustomPhone.GetActivePin(activePin);
  2236         #endif
  1730    			RDEBUG( "activePin", activePin );
  2237         iCustomPhone.GetActivePin(activePin);
  1731    			RDEBUG( "RMobilePhone::ESecurityUniversalPin", RMobilePhone::ESecurityUniversalPin );
  2238         #if defined(_DEBUG)
       
  2239         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive() GetActivePin DONE"));
       
  2240         #endif
       
  2241     	if(activePin == RMobilePhone::ESecurityUniversalPin)
  1732     	if(activePin == RMobilePhone::ESecurityUniversalPin)
  2242         {
  1733         {
  2243             #if defined(_DEBUG)
       
  2244             RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive(): UPIN ACTIVE"));
       
  2245             #endif
       
  2246     		return ETrue;
  1734     		return ETrue;
  2247         }
  1735         }
  2248          #if defined(_DEBUG)
       
  2249          RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive(): UPIN NOT ACTIVE"));
       
  2250          #endif
       
  2251          #if defined(_DEBUG)
       
  2252          RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinActive(): END"));
       
  2253          #endif
       
  2254     	return EFalse;
  1736     	return EFalse;
  2255         #endif //__WINS__
       
  2256       }
  1737       }
  2257     else
  1738     else
  2258         return EFalse;
  1739         return EFalse;
  2259 }
  1740 }
  2260 
  1741 
       
  1742 /**************************/
       
  1743 // qtdone
  2261 EXPORT_C TInt  CSecuritySettings::ChangePinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  1744 EXPORT_C TInt  CSecuritySettings::ChangePinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2262 	{
  1745 	{
  2263 	TInt ret = KErrNone;
  1746 		RDEBUG( "aFlags", aFlags );
  2264 	RDebug::Printf( "%s %s (%u) aFlags=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags );
  1747 		RDEBUG( "aOldPassword", 0 );
  2265 	RDebug::Printf( "%s %s (%u) aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2266 	RDebug::Print(aOldPassword);
  1748 	RDebug::Print(aOldPassword);
  2267 	RDebug::Printf( "%s %s (%u) aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1749 		RDEBUG( "aNewPassword", 0 );
  2268 	RDebug::Print(aNewPassword);
  1750 	RDebug::Print(aNewPassword);
  2269 	RDebug::Printf( "%s %s (%u) aCaption=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1751 		RDEBUG( "aCaption", 0 );
  2270 	RDebug::Print(aCaption);
  1752 	RDebug::Print(aCaption);
  2271 	RDebug::Printf( "%s %s (%u) aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aShowError );
  1753 		RDEBUG( "aShowError", aShowError );
  2272 
  1754 
  2273 
  1755 
  2274     /*****************************************************
  1756     /*****************************************************
  2275     *    Series 60 Customer / ETel
  1757     *    Series 60 Customer / ETel
  2276     *    Series 60  ETel API
  1758     *    Series 60  ETel API
  2283     TBool simRemoved(simState == ESimNotPresent);
  1765     TBool simRemoved(simState == ESimNotPresent);
  2284 
  1766 
  2285     if ( simRemoved )
  1767     if ( simRemoved )
  2286         {
  1768         {
  2287         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  1769         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  2288         return;
  1770         return KErrAccessDenied;
  2289         }
  1771         }
  2290     #if defined(_DEBUG)
  1772     #if defined(_DEBUG)
  2291     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinParamsL()"));
  1773     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinParamsL()"));
  2292     #endif    
  1774     #endif    
  2293     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  1775     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  2297     RMobilePhone::TMobilePassword newPassword;
  1779     RMobilePhone::TMobilePassword newPassword;
  2298     RMobilePhone::TMobilePassword verifcationPassword;
  1780     RMobilePhone::TMobilePassword verifcationPassword;
  2299     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
  1781     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
  2300     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
  1782     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
  2301     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
  1783     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
  2302 		TBool queryAccepted = EFalse;
  1784 		TInt queryAccepted = KErrCancel;
  2303 
  1785 
  2304 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1786 			RDEBUG( "0", 0 );
  2305 
  1787 
  2306     RMobilePhone::TMobilePhoneLock lockType;
  1788     RMobilePhone::TMobilePhoneLock lockType;
  2307     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1789     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2308     
  1790     
  2309     lockType = RMobilePhone::ELockICC;
  1791     lockType = RMobilePhone::ELockICC;
  2310 
  1792 
  2311     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1793     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2312     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1794     	RDEBUG( "0", 0 );
  2313     iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1795     iWait->SetRequestType(EMobilePhoneGetLockInfo);
  2314     #ifndef __WINS__    
  1796     TInt res = KErrNone;
       
  1797     RDEBUG( "GetLockInfo", 0 );
  2315     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
  1798     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
  2316     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1799     	RDEBUG( "WaitForRequestL", 0 );
  2317     TInt res = iWait->WaitForRequestL();
  1800     res = iWait->WaitForRequestL();
  2318     #else
  1801 		RDEBUG( "WaitForRequestL res", res );
  2319     RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1802 		#ifdef __WINS__
  2320     TInt res = KErrNone;
  1803    	if (res == KErrTimedOut)
       
  1804    		{
       
  1805    		lockInfo.iSetting = RMobilePhone::ELockSetEnabled;
       
  1806    		res = KErrNone;
       
  1807    		}
  2321     #endif
  1808     #endif
       
  1809 
  2322     User::LeaveIfError(res);
  1810     User::LeaveIfError(res);
  2323 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2324 			
  1811 			
  2325     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  1812     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  2326         {    
  1813         {    
  2327 				RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1814 					RDEBUG( "RMobilePhone::ELockSetDisabled", RMobilePhone::ELockSetDisabled );
  2328         // CleanupStack::PopAndDestroy(1,dlg);	// TODO sure about dlg ?
       
  2329         ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1815         ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  2330         return;
  1816         return KErrAccessDenied;
  2331         }
  1817         }
  2332     
  1818 
  2333    	RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1819    		RDEBUG( "0", 0 );
  2334     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
  1820     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
  2335     #ifndef __WINS__    
  1821     RDEBUG( "GetSecurityCodeInfo", 0 );
  2336     iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
  1822     iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
       
  1823     	RDEBUG( "WaitForRequestL", 0 );
  2337     res = iWait->WaitForRequestL();
  1824     res = iWait->WaitForRequestL();
  2338     #else
  1825     RDEBUG( "WaitForRequestL res", res );
  2339     res = KErrNone;
  1826 	  #ifdef __WINS__
  2340     #endif
  1827 	  if (res == KErrNotSupported || res == KErrTimedOut)
       
  1828 	  	{
       
  1829 	  	res = KErrNone;
       
  1830 	  	codeInfo.iRemainingEntryAttempts=KMaxNumberOfPINAttempts;
       
  1831 	  	}
       
  1832 	  #endif
  2341     User::LeaveIfError(res);
  1833     User::LeaveIfError(res);
  2342    	RDebug::Printf( "%s %s (%u) codeInfo.iRemainingEntryAttempts=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, codeInfo.iRemainingEntryAttempts );
  1834    		RDEBUG( "codeInfo.iRemainingEntryAttempts", codeInfo.iRemainingEntryAttempts );
  2343  		codeInfo.iRemainingEntryAttempts=KMaxNumberOfPINAttempts;
  1835    		RDEBUG( "checking aOldPassword", 0 );
  2344 
       
  2345    	RDebug::Printf( "%s %s (%u) checking aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2346 		if(aOldPassword.Length()==0)
  1836 		if(aOldPassword.Length()==0)
  2347 			{
  1837 			{
  2348    		RDebug::Printf( "%s %s (%u) asking aOldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1838    			RDEBUG( "asking aOldPassword", 0 );
  2349 			/* request PIN using QT */
  1839 			/* request PIN using QT */
  2350 			queryAccepted = EFalse;
  1840 			queryAccepted = KErrCancel;
  2351 			CSecQueryUi *iSecQueryUi;
  1841 			CSecQueryUi *iSecQueryUi;
  2352 			iSecQueryUi = CSecQueryUi::NewL();
  1842 			iSecQueryUi = CSecQueryUi::NewL();
  2353 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-Old"), oldPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  1843 			TBuf<0x100> title;	title.Zero();	title.Append(_L("PIN1-Old"));	title.Append(_L("#"));	title.AppendNum(codeInfo.iRemainingEntryAttempts);
  2354 			RDebug::Printf( "%s %s (%u) oldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1844 			queryAccepted = iSecQueryUi->SecQueryDialog( title, oldPassword, 4, 8, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  1845 				RDEBUG( "oldPassword", 0 );
  2355 			RDebug::Print( oldPassword );
  1846 			RDebug::Print( oldPassword );
  2356 			RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1847 			RDEBUG( "queryAccepted", queryAccepted );
  2357 			delete iSecQueryUi;
  1848 			delete iSecQueryUi;
  2358 			if(!queryAccepted)
  1849 			if( queryAccepted!=KErrNone )
  2359 					return;
  1850 					return KErrAbort;
  2360 			res=1;	// indicate that everything is ok
  1851 			res=1;	// indicate that everything is ok
  2361 			/* end request PIN using QT */
  1852 			/* end request PIN using QT */
  2362 			newPassword = _L("");
  1853 			newPassword = _L("");
  2363 	    verifcationPassword = _L("");
  1854 	    verifcationPassword = _L("");
  2364 			}
  1855 			}
  2367 			oldPassword.Copy(aOldPassword);
  1858 			oldPassword.Copy(aOldPassword);
  2368 			newPassword.Copy(aNewPassword);
  1859 			newPassword.Copy(aNewPassword);
  2369 			verifcationPassword.Copy(aNewPassword);
  1860 			verifcationPassword.Copy(aNewPassword);
  2370 			}
  1861 			}
  2371     
  1862     
  2372    	RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  1863    		RDEBUG( "res", res );
  2373         
       
  2374 		RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
       
  2375     while (newPassword.Length()==0 || newPassword.CompareF(verifcationPassword) != 0) 
  1864     while (newPassword.Length()==0 || newPassword.CompareF(verifcationPassword) != 0) 
  2376         {
  1865         {
  2377         // codes do not match -> note -> ask new pin and verification codes again  
  1866         // codes do not match -> note -> ask new pin and verification codes again  
  2378         if(newPassword.Length()>0)
  1867         if(newPassword.Length()>0)
  2379         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
  1868         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
  2384         // new pin code query
  1873         // new pin code query
  2385 					if(aOldPassword.Length()==0)	// only if inout parameters are empty
  1874 					if(aOldPassword.Length()==0)	// only if inout parameters are empty
  2386 						{
  1875 						{
  2387 							/* request PIN using QT */
  1876 							/* request PIN using QT */
  2388 							{
  1877 							{
  2389 							queryAccepted = EFalse;
  1878 							queryAccepted = KErrCancel;
  2390 							CSecQueryUi *iSecQueryUi;
  1879 							CSecQueryUi *iSecQueryUi;
  2391 							iSecQueryUi = CSecQueryUi::NewL();
  1880 							iSecQueryUi = CSecQueryUi::NewL();
  2392 							queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-New"), newPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  1881 								// this queries both, and verifies itself
  2393 							RDebug::Printf( "%s %s (%u) newPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  1882 							queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-New|PIN1-Ver"), newPassword, 4, 8, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  1883 							RDEBUG( "newPassword", 1 );
  2394 							RDebug::Print( newPassword );
  1884 							RDebug::Print( newPassword );
  2395 							RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1885 							RDEBUG( "queryAccepted", queryAccepted );
  2396 							delete iSecQueryUi;
  1886 							delete iSecQueryUi;
  2397 							if(!queryAccepted)
  1887 							if( queryAccepted!=KErrNone )
  2398 									return;
  1888 									return KErrAbort;
  2399 							}
  1889 							}
  2400 							/* end request PIN using QT */
  1890 							/* end request PIN using QT */
  2401 
  1891 							verifcationPassword.Copy(newPassword);	// just to break the while
  2402 						  RDebug::Printf( "%s %s (%u) 1=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1892 						  	RDEBUG( "0", 0 );
  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 			  	}
  1893 			  	}
  2418         }            
  1894         }            
  2419         
  1895         
  2420     // send code
  1896     // send code
  2421     passwords.iOldPassword = oldPassword;
  1897     passwords.iOldPassword = oldPassword;
  2422     passwords.iNewPassword = newPassword;
  1898     passwords.iNewPassword = newPassword;
  2423 		RDebug::Printf( "%s %s (%u) SetRequestType=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  1899 			RDEBUG( "passwords", 0 );
  2424 		RDebug::Print( passwords.iOldPassword );
  1900 		RDebug::Print( passwords.iOldPassword );
  2425 		RDebug::Print( passwords.iNewPassword );
  1901 		RDebug::Print( passwords.iNewPassword );
       
  1902 			RDEBUG( "SetRequestType", 0 );
  2426     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
  1903     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
  2427     #ifndef __WINS__    
  1904     RDEBUG( "ChangeSecurityCode", 0 );
  2428     iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
  1905     iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
       
  1906     	RDEBUG( "WaitForRequestL", 0 );
  2429     res = iWait->WaitForRequestL();
  1907     res = iWait->WaitForRequestL();
  2430     #else
  1908 		RDEBUG( "WaitForRequestL res", res );
  2431     res = KErrNone;
  1909 	  #ifdef __WINS__
  2432     #endif
  1910 	  if (res == KErrNotSupported)
  2433 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  1911 	  	res = KErrNone;
  2434     #if defined(_DEBUG)
  1912 	  #endif
  2435     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinParamsL(): RETURN CODE: %d"), res);
  1913 
  2436     #endif
       
  2437     switch(res)
  1914     switch(res)
  2438         {
  1915         {
  2439         case KErrNone:
  1916         case KErrNone:
  2440             {
  1917             {
  2441             // code changed 
  1918             // code changed 
  2452             }    
  1929             }    
  2453         case KErrGsmSSPasswordAttemptsViolation:
  1930         case KErrGsmSSPasswordAttemptsViolation:
  2454         case KErrLocked:
  1931         case KErrLocked:
  2455             {
  1932             {
  2456             // Pin1 blocked! 
  1933             // Pin1 blocked! 
  2457             return;
  1934             return KErrLocked;
  2458             }
  1935             }
  2459         case KErrGsm0707OperationNotAllowed:
  1936         case KErrGsm0707OperationNotAllowed:
  2460             {
  1937             {
  2461             // not allowed with this sim
  1938             // not allowed with this sim
  2462             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1939             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  2463             return;
  1940             return KErrGsm0707OperationNotAllowed;
  2464             }
  1941             }
  2465         case KErrAbort:
  1942         case KErrAbort:
  2466             {
  1943             {
  2467             break;
  1944             break;
  2468             }
  1945             }
  2473             break;
  1950             break;
  2474             }
  1951             }
  2475         }
  1952         }
  2476 	return res;
  1953 	return res;
  2477 	}
  1954 	}
       
  1955 /*********************************************/
       
  1956 // qtdone
  2478 EXPORT_C TInt  CSecuritySettings::ChangeUPinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  1957 EXPORT_C TInt  CSecuritySettings::ChangeUPinParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2479 	{
  1958 	{
  2480 	TInt ret = KErrNone;
  1959 		RDEBUG( "aFlags", aFlags );
  2481 	#if defined(_DEBUG)
  1960 		
  2482 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
  1961 	RDebug::Print(aOldPassword);
  2483 	#endif
  1962 	RDebug::Print(aNewPassword);
       
  1963 	RDebug::Print(aCaption);
       
  1964 
       
  1965     TBool wcdmaSupported(FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma ));
       
  1966     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin ));
       
  1967     if(! (wcdmaSupported || upinSupported))
       
  1968     	{
       
  1969     			RDEBUG( "! upinSupported", upinSupported );
       
  1970     		return KErrAccessDenied;
       
  1971     	}
       
  1972 
       
  1973         	RDEBUG( "upinSupported", upinSupported );
       
  1974         TInt simState;
       
  1975         TInt err( KErrGeneral );
       
  1976         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
  1977         User::LeaveIfError( err );
       
  1978         TBool simRemoved(simState == ESimNotPresent);
       
  1979     
       
  1980         if ( simRemoved )
       
  1981             {
       
  1982             ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
  1983             return KErrAccessDenied;
       
  1984             }
       
  1985     
       
  1986         RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
  1987         secCodeType = RMobilePhone::ESecurityUniversalPin;
       
  1988     
       
  1989         RMobilePhone::TMobilePassword oldPassword;
       
  1990         RMobilePhone::TMobilePassword newPassword;
       
  1991         RMobilePhone::TMobilePassword verifcationPassword;
       
  1992         RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
  1993         RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  1994         RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  1995         RMobilePhone::TMobilePhoneLock lockType;
       
  1996         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
  1997         TInt queryAccepted = KErrCancel;
       
  1998         
       
  1999         lockType = RMobilePhone::ELockUniversalPin;
       
  2000         
       
  2001         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
  2002         iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
  2003         RDEBUG( "GetLockInfo", 0 );
       
  2004         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  2005         RDEBUG( "WaitForRequestL", 0 );
       
  2006         TInt res = iWait->WaitForRequestL();
       
  2007         RDEBUG( "WaitForRequestL res", res );
       
  2008 			  #ifdef __WINS__
       
  2009 			  if (res == KErrNotSupported)
       
  2010 			  	{
       
  2011 			  	res = KErrNone;
       
  2012 			  	lockInfo.iSetting = RMobilePhone::ELockSetEnabled;
       
  2013 			  	}
       
  2014 			  #endif
       
  2015         User::LeaveIfError(res);
       
  2016     
       
  2017         	RDEBUG( "lockInfo.iSetting", lockInfo.iSetting );
       
  2018         	RDEBUG( "RMobilePhone::ELockSetDisabled", RMobilePhone::ELockSetDisabled );
       
  2019         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
  2020             {    
       
  2021             ShowResultNoteL(R_UPIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2022             return KErrAccessDenied;
       
  2023             }
       
  2024         
       
  2025         iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  2026         RDEBUG( "GetSecurityCodeInfo", 0 );
       
  2027         iPhone.GetSecurityCodeInfo(iWait->iStatus, secCodeType, codeInfoPkg);
       
  2028         RDEBUG( "WaitForRequestL", 0 );
       
  2029         res = iWait->WaitForRequestL();
       
  2030         	RDEBUG( "WaitForRequestL res", res );
       
  2031 			  #ifdef __WINS__
       
  2032 			  if (res == KErrNotSupported || res == KErrTimedOut)
       
  2033 			  	{
       
  2034 			  	res = KErrNone;
       
  2035 			  	codeInfo.iRemainingEntryAttempts=KMaxNumberOfPINAttempts;
       
  2036 			  	}
       
  2037 			  #endif
       
  2038         User::LeaveIfError(res);
       
  2039             
       
  2040 			/* request PIN using QT */
       
  2041 			queryAccepted = KErrCancel;
       
  2042 			CSecQueryUi *iSecQueryUi;
       
  2043 			iSecQueryUi = CSecQueryUi::NewL();
       
  2044 			TBuf<0x100> title;	title.Zero();	title.Append(_L("UPIN-Old"));	title.Append(_L("#"));	title.AppendNum(codeInfo.iRemainingEntryAttempts);
       
  2045 			queryAccepted = iSecQueryUi->SecQueryDialog( title, oldPassword, 4, 8, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2046 				RDEBUG( "oldPassword", 0 );
       
  2047 			RDebug::Print( oldPassword );
       
  2048 			RDEBUG( "queryAccepted", queryAccepted );
       
  2049 			delete iSecQueryUi;
       
  2050 			if( queryAccepted!=KErrNone )
       
  2051 					return KErrAbort;
       
  2052 			res=1;	// indicate that everything is ok
       
  2053 
       
  2054 				{
       
  2055 				queryAccepted = KErrCancel;
       
  2056 				CSecQueryUi *iSecQueryUi;
       
  2057 				iSecQueryUi = CSecQueryUi::NewL();
       
  2058 					// this queries both, and verifies itself
       
  2059 				queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN1-New|PIN1-Ver"), newPassword, 4, 8, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2060 				RDEBUG( "newPassword", 0 );
       
  2061 				RDebug::Print( newPassword );
       
  2062 				RDEBUG( "queryAccepted", queryAccepted );
       
  2063 				delete iSecQueryUi;
       
  2064 				if( queryAccepted!=KErrNone )
       
  2065 						return KErrAbort;
       
  2066 				}
       
  2067 							        // send code
       
  2068         passwords.iOldPassword = oldPassword;
       
  2069         passwords.iNewPassword = newPassword;
       
  2070         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
  2071         RDEBUG( "ChangeSecurityCode", 0 );
       
  2072         iPhone.ChangeSecurityCode(iWait->iStatus, secCodeType, passwords);
       
  2073         RDEBUG( "WaitForRequestL", 0 );
       
  2074         res = iWait->WaitForRequestL();
       
  2075         	RDEBUG( "WaitForRequestL res", res );
       
  2076 			  #ifdef __WINS__
       
  2077 			  if (res == KErrNotSupported)
       
  2078 			  	res = KErrNone;
       
  2079 			  #endif
       
  2080         switch(res)
       
  2081             {
       
  2082             case KErrNone:
       
  2083                 {
       
  2084                 // code changed 
       
  2085                 ShowResultNoteL(R_UPIN_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  2086                 break;
       
  2087                 }        
       
  2088             case KErrGsm0707IncorrectPassword:
       
  2089             case KErrAccessDenied:
       
  2090                 {    
       
  2091                 // code was entered erroneously
       
  2092                 ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2093                 ChangeUPinParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2094                 break;
       
  2095                 }    
       
  2096             case KErrGsmSSPasswordAttemptsViolation:
       
  2097             case KErrLocked:
       
  2098                 {
       
  2099                 return KErrLocked;
       
  2100                 }
       
  2101             case KErrGsm0707OperationNotAllowed:
       
  2102                 {
       
  2103                 // not allowed with this sim
       
  2104                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2105                 return KErrGsm0707OperationNotAllowed;
       
  2106                 }
       
  2107             case KErrAbort:
       
  2108                 {
       
  2109                 break;
       
  2110                 }
       
  2111             default:
       
  2112                 {
       
  2113                 ShowErrorNoteL(res);
       
  2114                 ChangeUPinParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2115                 break;
       
  2116                 }
       
  2117             }
       
  2118       return res;
  2484 	}
  2119 	}
       
  2120 /***************************************/
       
  2121 // qtdone
  2485 EXPORT_C TInt  CSecuritySettings::ChangePin2ParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2122 EXPORT_C TInt  CSecuritySettings::ChangePin2ParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2486 	{
  2123 	{
  2487 	TInt ret = KErrNone;
  2124     #if defined(_DEBUG)
  2488 	#if defined(_DEBUG)
  2125     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePin2ParamsL()"));
  2489 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
  2126     #endif
  2490 	#endif
  2127     TInt simState;
       
  2128     TInt err( KErrGeneral );
       
  2129     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
       
  2130     User::LeaveIfError( err );
       
  2131     TBool simRemoved(simState == ESimNotPresent);
       
  2132 
       
  2133     if ( simRemoved )
       
  2134         {
       
  2135         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
       
  2136         return KErrAccessDenied;
       
  2137         }
       
  2138 
       
  2139     RMmCustomAPI::TSecurityCodeType secCodeType;
       
  2140     RMobilePhone::TMobilePhoneSecurityCode EtelsecCodeType;
       
  2141     secCodeType = RMmCustomAPI::ESecurityCodePin2;
       
  2142     RMobilePhone::TMobilePassword oldPassword;
       
  2143     RMobilePhone::TMobilePassword newPassword;
       
  2144     RMobilePhone::TMobilePassword verifcationPassword;
       
  2145     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
       
  2146     RMobilePhone::TMobilePhoneSecurityCodeInfoV5 codeInfo;
       
  2147     RMobilePhone::TMobilePhoneSecurityCodeInfoV5Pckg codeInfoPkg(codeInfo);
       
  2148     TInt queryAccepted = KErrCancel;
       
  2149     
       
  2150     // check if pin2 is blocked...
       
  2151     TBool isBlocked = EFalse;
       
  2152 
       
  2153     TInt ret = iCustomPhone.IsBlocked(secCodeType,isBlocked);
       
  2154     	RDEBUG( "isBlocked", isBlocked );
       
  2155     if(isBlocked)
       
  2156         return KErrAccessDenied;
       
  2157     	RDEBUG( "ret", ret );
       
  2158 	  #ifdef __WINS__
       
  2159 	  if (ret == KErrNotSupported)
       
  2160 	  	ret = KErrNone;
       
  2161 	  #endif
       
  2162 
       
  2163     if (ret != KErrNone)
       
  2164         {    
       
  2165         switch (ret)
       
  2166             {
       
  2167             // PIN2 Blocked.
       
  2168             case KErrGsm0707SIMPuk2Required:
       
  2169                 break;
       
  2170             case KErrGsmSSPasswordAttemptsViolation:
       
  2171             case KErrLocked:
       
  2172                 // Pin2 features blocked permanently!
       
  2173                 ShowResultNoteL(R_PIN2_REJECTED, CAknNoteDialog::EConfirmationTone);
       
  2174                 break;
       
  2175             case KErrGsm0707SimNotInserted:
       
  2176                 // not allowed with this sim
       
  2177                 ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2178                 break;
       
  2179             default:
       
  2180                 ShowErrorNoteL(ret);
       
  2181                 break;
       
  2182             }
       
  2183         return KErrAccessDenied;
       
  2184         }
       
  2185     
       
  2186 
       
  2187     // Security code must be changed to Etel API format
       
  2188     // Custom API Pin1 and Pin2 have the same enum values as the Etel ones
       
  2189     EtelsecCodeType = (RMobilePhone::TMobilePhoneSecurityCode)secCodeType;
       
  2190     iWait->SetRequestType(EMobilePhoneGetSecurityCodeInfo);
       
  2191     RDEBUG( "GetSecurityCodeInfo", 0 );
       
  2192     iPhone.GetSecurityCodeInfo(iWait->iStatus, EtelsecCodeType, codeInfoPkg);
       
  2193     RDEBUG( "WaitForRequestL", 0 );
       
  2194     ret = iWait->WaitForRequestL();
       
  2195     	RDEBUG( "WaitForRequestL ret", ret );
       
  2196  		#ifdef __WINS__
       
  2197    	if ( ret == KErrNotSupported || ret == KErrTimedOut)
       
  2198    		{
       
  2199    		codeInfo.iRemainingEntryAttempts = 1;
       
  2200    		ret = KErrNone;
       
  2201    		}
       
  2202    	#endif
       
  2203    	User::LeaveIfError(ret);
       
  2204 
       
  2205 			/* request PIN using QT */
       
  2206 			queryAccepted = KErrCancel;
       
  2207 			CSecQueryUi *iSecQueryUi;
       
  2208 			iSecQueryUi = CSecQueryUi::NewL();
       
  2209 			TBuf<0x100> title;	title.Zero();	title.Append(_L("PIN2-Old"));	title.Append(_L("#"));	title.AppendNum(codeInfo.iRemainingEntryAttempts);
       
  2210 			queryAccepted = iSecQueryUi->SecQueryDialog( title, oldPassword, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2211 				RDEBUG( "oldPassword", 0 );
       
  2212 			RDebug::Print( oldPassword );
       
  2213 			RDEBUG( "queryAccepted", queryAccepted );
       
  2214 			delete iSecQueryUi;
       
  2215 			if( queryAccepted!=KErrNone )
       
  2216 					return KErrAbort;
       
  2217 			/* end request PIN using QT */
       
  2218 
       
  2219 			/* request PIN using QT */
       
  2220 			{
       
  2221 			queryAccepted = KErrCancel;
       
  2222 			CSecQueryUi *iSecQueryUi;
       
  2223 			iSecQueryUi = CSecQueryUi::NewL();
       
  2224 				// this queries both, and verifies itself
       
  2225 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("PIN2-New|PIN2-Ver"), newPassword, SEC_C_PIN2_CODE_MIN_LENGTH, SEC_C_PIN2_CODE_MAX_LENGTH, ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
       
  2226 			RDEBUG( "newPassword", 0 );
       
  2227 			RDebug::Print( newPassword );
       
  2228 			RDEBUG( "queryAccepted", queryAccepted );
       
  2229 			delete iSecQueryUi;
       
  2230 			if( queryAccepted!=KErrNone )
       
  2231 					return KErrAbort;
       
  2232 			}
       
  2233 			/* end request PIN using QT */
       
  2234 
       
  2235     passwords.iOldPassword = oldPassword;
       
  2236     passwords.iNewPassword = newPassword;
       
  2237     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
       
  2238     RDEBUG( "ChangeSecurityCode", 0 );
       
  2239     iPhone.ChangeSecurityCode(iWait->iStatus,EtelsecCodeType,passwords);
       
  2240     RDEBUG( "WaitForRequestL", 0 );
       
  2241     TInt res = iWait->WaitForRequestL();
       
  2242     	RDEBUG( "WaitForRequestL res", res );
       
  2243 	  #ifdef __WINS__
       
  2244 	  if (res == KErrNotSupported)
       
  2245 	  	res = KErrNone;
       
  2246 	  #endif
       
  2247     switch(res)
       
  2248         {
       
  2249         case KErrNone:
       
  2250             {
       
  2251             // code changed 
       
  2252             ShowResultNoteL(R_PIN2_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
       
  2253             break;
       
  2254             }        
       
  2255         case KErrGsm0707IncorrectPassword:
       
  2256         case KErrAccessDenied:
       
  2257             {    
       
  2258             ShowResultNoteL(R_CODE_ERROR, CAknNoteDialog::EErrorTone);
       
  2259             ChangePin2ParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2260             break;
       
  2261             }    
       
  2262         case KErrGsmSSPasswordAttemptsViolation:
       
  2263         case KErrLocked:
       
  2264             {
       
  2265             // Pin2 blocked!
       
  2266             ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone);
       
  2267             CSecurityHandler* handler = new(ELeave) CSecurityHandler(iPhone);
       
  2268             CleanupStack::PushL(handler); 
       
  2269             handler->HandleEventL(RMobilePhone::EPuk2Required);
       
  2270             CleanupStack::PopAndDestroy(handler); // handler    
       
  2271             return KErrLocked;
       
  2272             }
       
  2273         case KErrGsm0707OperationNotAllowed:
       
  2274             {
       
  2275             // not allowed with this sim
       
  2276             ShowResultNoteL(R_OPERATION_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
       
  2277             return KErrGsm0707OperationNotAllowed;
       
  2278             }
       
  2279         case KErrAbort:
       
  2280             {
       
  2281             break;
       
  2282             }
       
  2283         default:
       
  2284             {
       
  2285             ShowErrorNoteL(res);
       
  2286             ChangePin2ParamsL(_L(""), _L(""), aFlags, aCaption, aShowError);
       
  2287             break;
       
  2288             }
       
  2289         }
       
  2290   return res;
  2491 	}
  2291 	}
       
  2292 /************************************************/
       
  2293 // qtdone
  2492 EXPORT_C TInt  CSecuritySettings::ChangeSecCodeParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2294 EXPORT_C TInt  CSecuritySettings::ChangeSecCodeParamsL(RMobilePhone::TMobilePassword aOldPassword, RMobilePhone::TMobilePassword aNewPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2493 	{
  2295 	{
  2494 	TInt ret = KErrNone;
  2296 	RDEBUG( "aFlags", aFlags );
  2495 	#if defined(_DEBUG)
  2297 	RDEBUG( "aShowError", aShowError );
  2496 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2497 	#endif
       
  2498     /*****************************************************
  2298     /*****************************************************
  2499     *    Series 60 Customer / ETel
  2299     *    Series 60 Customer / ETel
  2500     *    Series 60  ETel API
  2300     *    Series 60  ETel API
  2501     *****************************************************/
  2301     *****************************************************/
  2502     #if defined(_DEBUG)
  2302     #if defined(_DEBUG)
  2503     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL()"));
  2303     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL()"));
  2504     #endif
  2304     #endif
  2505     TInt res=0;
  2305     TInt res=0;
  2506     TBool queryAccepted = EFalse;
  2306     TInt queryAccepted = KErrCancel;
  2507     RMobilePhone::TMobilePassword newPassword;
  2307     RMobilePhone::TMobilePassword newPassword;
  2508          
  2308          
  2509     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  2309     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  2510     secCodeType = RMobilePhone::ESecurityCodePhonePassword;
  2310     secCodeType = RMobilePhone::ESecurityCodePhonePassword;
  2511     RMobilePhone::TMobilePassword oldPassword;
  2311     RMobilePhone::TMobilePassword oldPassword;
  2513     RMobilePhone::TMobilePassword required_fourth;
  2313     RMobilePhone::TMobilePassword required_fourth;
  2514     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
  2314     RMobilePhone::TMobilePhonePasswordChangeV1 passwords;
  2515 
  2315 
  2516 		if(aOldPassword.Length()==0)
  2316 		if(aOldPassword.Length()==0)
  2517 			{			/* request PIN using QT */
  2317 			{			/* request PIN using QT */
  2518 			queryAccepted = EFalse;
  2318 			queryAccepted = KErrCancel;
  2519 			CSecQueryUi *iSecQueryUi;
  2319 			CSecQueryUi *iSecQueryUi;
  2520 			iSecQueryUi = CSecQueryUi::NewL();
  2320 			iSecQueryUi = CSecQueryUi::NewL();
  2521 			// TODO allow and handle Cancel
  2321 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-Old"), oldPassword, 4, 8, ESecUiAlphaSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  2522 			queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-Old"), oldPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  2322 				RDEBUG( "oldPassword", 0 );
  2523 			RDebug::Printf( "%s %s (%u) oldPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
  2524 			RDebug::Print( oldPassword );
  2323 			RDebug::Print( oldPassword );
  2525 			RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  2324 			RDEBUG( "queryAccepted", queryAccepted );
  2526 			delete iSecQueryUi;
  2325 			delete iSecQueryUi;
  2527 			if(!queryAccepted)
  2326 			if( queryAccepted!=KErrNone )
  2528 					return KErrAbort;
  2327 					return KErrAbort;
  2529 			res=1;	// indicate that everything is ok
  2328 			res=1;	// indicate that everything is ok
  2530 			/* end request PIN using QT */
  2329 			/* end request PIN using QT */
  2531 			newPassword = _L("");
  2330 			newPassword = _L("");
  2532 	    verifcationPassword = _L("");
  2331 	    verifcationPassword = _L("");
  2536 			oldPassword.Copy(aOldPassword);
  2335 			oldPassword.Copy(aOldPassword);
  2537 			newPassword.Copy(aNewPassword);
  2336 			newPassword.Copy(aNewPassword);
  2538 			verifcationPassword.Copy(aNewPassword);
  2337 			verifcationPassword.Copy(aNewPassword);
  2539 			}
  2338 			}
  2540 
  2339 
  2541 		RDebug::Printf( "%s %s (%u) EMobilePhoneVerifySecurityCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, EMobilePhoneVerifySecurityCode );
  2340 			RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode );
  2542 	  iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
  2341 	  iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
  2543     // check code
  2342     // check code
       
  2343     RDEBUG( "VerifySecurityCode", 0 );
  2544     iPhone.VerifySecurityCode(iWait->iStatus,secCodeType, oldPassword, required_fourth);
  2344     iPhone.VerifySecurityCode(iWait->iStatus,secCodeType, oldPassword, required_fourth);
       
  2345     RDEBUG( "WaitForRequestL", 0 );
  2545     res = iWait->WaitForRequestL();
  2346     res = iWait->WaitForRequestL();
  2546 		RDebug::Printf( "%s %s (%u) VerifySecurityCode res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  2347     	RDEBUG( "WaitForRequestL res", res );
  2547 			
  2348 	  #ifdef __WINS__
       
  2349 	  if (res == KErrNotSupported)
       
  2350 	  	res = KErrNone;
       
  2351 	  #endif
       
  2352 
  2548 		if(res!=KErrNone)
  2353 		if(res!=KErrNone)
  2549 			{
  2354 			{
  2550 			ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
  2355 			ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
  2551 			return res;
  2356 			return res;
  2552 			}
  2357 			}
  2556         // codes do not match -> note -> ask new pin and verification codes again  
  2361         // codes do not match -> note -> ask new pin and verification codes again  
  2557         if(newPassword.Length()>0)
  2362         if(newPassword.Length()>0)
  2558         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
  2363         	ShowResultNoteL(R_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone);
  2559 
  2364 
  2560         	{
  2365         	{
  2561 					queryAccepted = EFalse;
  2366 					queryAccepted = KErrCancel;
  2562 					CSecQueryUi *iSecQueryUi;
  2367 					CSecQueryUi *iSecQueryUi;
  2563 					iSecQueryUi = CSecQueryUi::NewL();
  2368 					iSecQueryUi = CSecQueryUi::NewL();
  2564 					queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-New"), newPassword, 4, 8, ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType );
  2369 						// will ask both codes and compare itself
  2565 					RDebug::Printf( "%s %s (%u) newPassword=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
  2370 						// mix, max , is handled using TARM params, in the dialog itself
       
  2371 					TInt lType = ESecUiAlphaNotSupported | ESecUiCancelSupported | ESecUiEmergencyNotSupported | secCodeType;
       
  2372 						RDEBUG( "lType", lType );
       
  2373 					queryAccepted = iSecQueryUi->SecQueryDialog( _L("Lock-New|Lock-Verif"), newPassword, 4, 8, lType );
       
  2374 					RDEBUG( "newPassword", 0 );
  2566 					RDebug::Print( newPassword );
  2375 					RDebug::Print( newPassword );
  2567 					RDebug::Printf( "%s %s (%u) queryAccepted=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  2376 					RDEBUG( "queryAccepted", queryAccepted );
  2568 					delete iSecQueryUi;
  2377 					delete iSecQueryUi;
  2569 					if(!queryAccepted)
  2378 					if( queryAccepted!=KErrNone )
  2570 							return KErrAbort;
  2379 							return KErrAbort;
  2571 					}
  2380 					}
  2572 
  2381 					verifcationPassword.Copy(newPassword);	// break the while
  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 
  2382 
  2587         }	// while
  2383         }	// while
  2588 
  2384 
  2589     // change code 
  2385     // change code 
  2590 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  2386 			RDEBUG( "res", res );
  2591     if (res == KErrNone)
  2387     if (res == KErrNone)
  2592         {
  2388         {
  2593         passwords.iOldPassword = oldPassword;
  2389         passwords.iOldPassword = oldPassword;
  2594         passwords.iNewPassword = newPassword;
  2390         passwords.iNewPassword = newPassword;
  2595         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
  2391         iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
  2596 				RDebug::Printf( "%s %s (%u) ChangeSecurityCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  2392 				RDEBUG( "ChangeSecurityCode", 0 );
  2597         iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,passwords);
  2393         iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,passwords);
       
  2394         RDEBUG( "WaitForRequestL", 0 );
  2598         res = iWait->WaitForRequestL();
  2395         res = iWait->WaitForRequestL();
  2599 				RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  2396         	RDEBUG( "WaitForRequestL res", res );
       
  2397 			  #ifdef __WINS__
       
  2398 			  if (res == KErrNotSupported)
       
  2399 			  	res = KErrNone;
       
  2400 			  #endif
  2600 
  2401 
  2601 				if(res==KErrNone && 1==0 )	// TODO not possible to enable because it asks code again
  2402 				if(res==KErrNone && 1==0 )	// TODO not possible to enable because it asks code again
  2602 					{
  2403 					{
  2603 	        RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
  2404 	        RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
  2604  	        RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetEnabled;                       
  2405  	        RMobilePhone::TMobilePhoneLockSetting lockChangeSetting = RMobilePhone::ELockSetEnabled;                       
  2605 					if(oldPassword.Length()==6)
  2406 					if(oldPassword.Length()==6)
  2606 						{
  2407 						{
  2607 						lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2408 						lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2608 						RDebug::Printf( "%s %s (%u) RMobilePhone::ELockSetDisabled=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, RMobilePhone::ELockSetDisabled );
  2409 							RDEBUG( "RMobilePhone::ELockSetDisabled", RMobilePhone::ELockSetDisabled );
  2609 						}
  2410 						}
  2610 	        iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2411 	        iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2611 					RDebug::Printf( "%s %s (%u) SetLockSetting=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  2412 					RDEBUG( "SetLockSetting", 0 );
  2612 	        iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting );
  2413 	        iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting );
       
  2414 	        	RDEBUG( "WaitForRequestL", 0 );
  2613 	        res = iWait->WaitForRequestL();
  2415 	        res = iWait->WaitForRequestL();
  2614 					RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  2416 	        	RDEBUG( "WaitForRequestL res", res );
       
  2417 				  #ifdef __WINS__
       
  2418 				  if (res == KErrNotSupported)
       
  2419 				  	res = KErrNone;
       
  2420 				  #endif
  2615 	        }
  2421 	        }
  2616         }
  2422         }
  2617         
  2423         
  2618 		RDebug::Printf( "%s %s (%u) res=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, res );
  2424 			RDEBUG( "res", res );
  2619     #if defined(_DEBUG)
       
  2620     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL(): RETURN CODE: %d"), res);
       
  2621     #endif
       
  2622     switch(res)
  2425     switch(res)
  2623         {
  2426         {
  2624         case KErrNone:
  2427         case KErrNone:
  2625             {
  2428             {
  2626             // code changed 
  2429             // code changed 
  2627             ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
  2430             ShowResultNoteL(R_SECURITY_CODE_CHANGED_NOTE, CAknNoteDialog::EConfirmationTone);
  2628             if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ) &&
  2431             {
  2629 								!(FeatureManager::FeatureSupported(KFeatureIdSapDeviceLockEnhancements  )))
  2432             // Send the changed code to the SCP server, even with device lock enhancements.
  2630 						{
  2433          			RDEBUG( "scpClient.Connect", 0 );
  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;
  2434             RSCPClient scpClient;
  2634             TSCPSecCode newCode;
  2435             TSCPSecCode newCode;
       
  2436             TSCPSecCode oldPassword;
  2635             newCode.Copy( newPassword );
  2437             newCode.Copy( newPassword );
  2636             if ( scpClient.Connect() == KErrNone )
  2438             if ( scpClient.Connect() == KErrNone )
  2637                 {
  2439                 {
  2638 								RDebug::Printf( "%s %s (%u) scpClient.StoreCode=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 1 );
  2440 									RDEBUG( "scpClient.StoreCode", 0 );
  2639                 scpClient.StoreCode( newCode );
  2441 									/*
       
  2442                 // scpClient.StoreCode( newCode );
       
  2443                 RArray<TDevicelockPolicies> aFailedPolicies;
       
  2444                 TDevicelockPolicies failedPolicy;
       
  2445                 TInt retLockcode = KErrNone;
       
  2446                 retLockcode = scpClient.StoreLockcode( newCode, oldPassword, aFailedPolicies );
       
  2447                 	RDEBUG( "retLockcode", retLockcode );
       
  2448                 	RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
       
  2449                 for(TInt i=0; i<aFailedPolicies.Count(); i++)
       
  2450                 	{
       
  2451                		failedPolicy = aFailedPolicies[i];
       
  2452                 		RDEBUG( "failedPolicy", failedPolicy );
       
  2453                 	}
       
  2454                 */
  2640                 scpClient.Close();
  2455                 scpClient.Close();
  2641                 }                                               
  2456                 }                                               
  2642           	}
  2457           	}
  2643             break;
  2458             break;
  2644             }
  2459             }
  2666             ShowErrorNoteL(res);
  2481             ShowErrorNoteL(res);
  2667             ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError);
  2482             ChangeSecCodeParamsL(aOldPassword, aNewPassword, aFlags, aCaption, aShowError);
  2668             break;
  2483             break;
  2669             }
  2484             }
  2670        } // switch
  2485        } // switch
       
  2486 	return res;
  2671 	}
  2487 	}
       
  2488 
       
  2489 /**************************************/
       
  2490 // qtdone
  2672 EXPORT_C TInt  CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2491 EXPORT_C TInt  CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2673 	{
  2492 	{
  2674 	TInt ret = KErrNone;
  2493 	RDEBUG( "aPeriod", aPeriod );
  2675 	#if defined(_DEBUG)
  2494 	RDEBUG( "aFlags", aFlags );
  2676 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
  2495     /*****************************************************
  2677 	#endif
  2496     *    Series 60 Customer / ETel
       
  2497     *    Series 60  ETel API
       
  2498     *****************************************************/
       
  2499 
       
  2500     RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled);
       
  2501     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
       
  2502     TInt oldPeriod = aPeriod;
       
  2503 
       
  2504     TInt maxPeriod=0;
       
  2505     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
  2506 		{
       
  2507     // Retrieve the current autolock period max. value from the SCP server, 
       
  2508     // and check that the value the user
       
  2509     // selected is ok from the Corporate Policy point of view.
       
  2510 	RSCPClient scpClient;
       
  2511     TInt ret = scpClient.Connect();
       
  2512     if ( ret == KErrNone )
       
  2513         {       
       
  2514         CleanupClosePushL( scpClient );
       
  2515         TBuf<KSCPMaxIntLength> maxPeriodBuf;
       
  2516         if ( scpClient.GetParamValue( ESCPMaxAutolockPeriod, maxPeriodBuf ) == KErrNone )
       
  2517             {
       
  2518             TLex lex( maxPeriodBuf );          
       
  2519             if ( ( lex.Val( maxPeriod ) == KErrNone ) && ( maxPeriod > 0 ) )
       
  2520                 {
       
  2521                 		RDEBUG( "from SCP maxPeriod", maxPeriod );
       
  2522                  // nothing to do
       
  2523                 }
       
  2524             else
       
  2525                 {
       
  2526                    maxPeriod = 0;
       
  2527                    	RDEBUG( "not from SCP maxPeriod", maxPeriod );
       
  2528                 }
       
  2529             }
       
  2530         else
       
  2531             {
       
  2532             	RDEBUG( "Failed to retrieve max period", maxPeriod );
       
  2533             }            
       
  2534         }
       
  2535     else
       
  2536         {
       
  2537         RDEBUG( "Failed to connect to SCP", 0 );
       
  2538         }
       
  2539     CleanupStack::PopAndDestroy(); // scpClient 
  2678 	}
  2540 	}
       
  2541     	RDEBUG( "maxPeriod", maxPeriod );
       
  2542     if(FeatureManager::FeatureSupported(KFeatureIdSapTerminalControlFw ))
       
  2543 		{
       
  2544     TBool allow = ETrue;               
       
  2545                
       
  2546     if ((aPeriod == 0) && (maxPeriod > 0))
       
  2547        {
       
  2548         #if defined(_DEBUG)
       
  2549         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() \
       
  2550         The period: %d is not allowed by TARM; max: %d"),aPeriod, maxPeriod );
       
  2551         #endif                
       
  2552         allow = EFalse;                                                
       
  2553         ShowResultNoteL(R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE, CAknNoteDialog::EErrorTone);
       
  2554         }          
       
  2555     if ( !allow ) 
       
  2556         {
       
  2557          return ChangeAutoLockPeriodParamsL(aPeriod, aOldPassword, aFlags, aCaption, aShowError);	// ask again
       
  2558         }                       
       
  2559 		}
       
  2560 
       
  2561     if (aPeriod == 0)
       
  2562         {
       
  2563         #ifdef RD_REMOTELOCK
       
  2564 
       
  2565         // If remote lock is enabled, don't disable the domestic OS device lock
       
  2566         // since that would render the RemoteLock useless.
       
  2567         // Instead just re-set the DOS lock to enabled which as a side effect
       
  2568         // requests the security code from the user.
       
  2569 
       
  2570         TBool remoteLockStatus( EFalse );
       
  2571         CRemoteLockSettings* remoteLockSettings = CRemoteLockSettings::NewL();
       
  2572 
       
  2573         if ( remoteLockSettings->GetEnabled( remoteLockStatus ) )
       
  2574             {
       
  2575             if ( remoteLockStatus )
       
  2576                 {
       
  2577                 // Remote lock is enabled
       
  2578                 lockChange = RMobilePhone::ELockSetEnabled;
       
  2579                 	RDEBUG( "RemoteLock is enabled lockChange", lockChange );
       
  2580                 }
       
  2581             else
       
  2582                 {
       
  2583                 // Remote lock is disabled
       
  2584                 lockChange = RMobilePhone::ELockSetDisabled;
       
  2585                 	RDEBUG( "RemoteLock is disabled lockChange", lockChange );
       
  2586                 }
       
  2587             }
       
  2588         else
       
  2589             {
       
  2590             // Failed to get remote lock status
       
  2591             	RDEBUG( "Failed to get remote lock status lockChange", lockChange );
       
  2592             }
       
  2593 
       
  2594         delete remoteLockSettings;
       
  2595         remoteLockSettings = NULL;
       
  2596 
       
  2597         #else // not defined RD_REMOTELOCK
       
  2598 
       
  2599         lockChange = RMobilePhone::ELockSetDisabled;
       
  2600 
       
  2601         #endif // RD_REMOTELOCK
       
  2602         }
       
  2603     else
       
  2604         {
       
  2605         lockChange = RMobilePhone::ELockSetEnabled;
       
  2606         	RDEBUG( "aPeriod != 0 lockChange", lockChange );
       
  2607         }
       
  2608 
       
  2609         iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
  2610         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
  2611         RDEBUG( "SetLockSetting", 0 );
       
  2612         iPhone.SetLockSetting(iWait->iStatus,lockType,lockChange);	// this eventually calls PassPhraseRequiredL
       
  2613         RDEBUG( "WaitForRequestL", 0 );
       
  2614         TInt status = KErrNone;
       
  2615         status = iWait->WaitForRequestL();
       
  2616         	RDEBUG( "WaitForRequestL status", status );
       
  2617 			  #ifdef __WINS__
       
  2618 			  if (status == KErrNotSupported)
       
  2619 			  	status = KErrNone;
       
  2620 			  #endif
       
  2621         switch(status)
       
  2622         {
       
  2623         case KErrNone:
       
  2624             #if defined(_DEBUG)
       
  2625             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() KErrNone"));
       
  2626             #endif
       
  2627             break;
       
  2628         case KErrGsmSSPasswordAttemptsViolation:
       
  2629         case KErrLocked:
       
  2630             #if defined(_DEBUG)
       
  2631             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() PasswordAttemptsViolation"));
       
  2632             #endif
       
  2633             ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone);	// the old code didn't show messages
       
  2634             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError);	// ask again
       
  2635         case KErrGsm0707IncorrectPassword:
       
  2636         case KErrAccessDenied:
       
  2637             #if defined(_DEBUG)
       
  2638             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() IncorrectPassword"));
       
  2639             #endif
       
  2640             // code was entered erroneously
       
  2641             ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone);	// the old code didn't show messages
       
  2642             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError);	// ask again
       
  2643         case KErrAbort:
       
  2644             // User pressed "cancel" in the code query dialog.
       
  2645             return oldPeriod;
       
  2646         default:
       
  2647             #if defined(_DEBUG)
       
  2648             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() default"));
       
  2649             #endif
       
  2650             ShowResultNoteL(status, CAknNoteDialog::EErrorTone);	// the old code didn't show messages
       
  2651             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword, aFlags, aCaption, aShowError);	// ask again
       
  2652         }
       
  2653     #if defined(_DEBUG)
       
  2654     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() END"));
       
  2655     #endif
       
  2656     return aPeriod; 
       
  2657 	}
       
  2658 /*****************************/
       
  2659 // qtdone
  2679 EXPORT_C TInt  CSecuritySettings::ChangePinRequestParamsL(TInt aEnable, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2660 EXPORT_C TInt  CSecuritySettings::ChangePinRequestParamsL(TInt aEnable, RMobilePhone::TMobilePassword aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
  2680 	{
  2661 	{
  2681 	TInt ret = KErrNone;
  2662 	RDEBUG( "aEnable", aEnable );
  2682 	#if defined(_DEBUG)
  2663 	RDEBUG( "aFlags", aFlags );
  2683 	RDebug::Printf( "%s %s (%u) aFlags=%x aShowError=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, aFlags, aShowError );
       
  2684 	#endif
       
  2685     /*****************************************************
  2664     /*****************************************************
  2686     *    Series 60 Customer / ETel
  2665     *    Series 60 Customer / ETel
  2687     *    Series 60  ETel API
  2666     *    Series 60  ETel API
  2688     *****************************************************/
  2667     *****************************************************/
  2689     #if defined(_DEBUG)
  2668     #if defined(_DEBUG)
  2690     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL()"));
  2669     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL()"));
  2691     #endif      
  2670     #endif      
  2692     TInt simState=0;
  2671     TInt simState=0;
  2693     TInt lEnable=aEnable;
  2672     TInt lEnable=aEnable;
  2694     TInt err( KErrGeneral );
  2673     TInt err( KErrGeneral );
  2695     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  2674     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  2697     TBool simRemoved(simState == ESimNotPresent);
  2676     TBool simRemoved(simState == ESimNotPresent);
  2698 
  2677 
  2699     if ( simRemoved )
  2678     if ( simRemoved )
  2700         {
  2679         {
  2701         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  2680         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  2702         return EFalse;;
  2681         return EFalse;
  2703         }
  2682         }
  2704 
  2683 
  2705     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2684     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2706     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2685     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2707     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
  2686     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
  2710     
  2689     
  2711                         
  2690                         
  2712     //get lock info
  2691     //get lock info
  2713     iWait->SetRequestType(EMobilePhoneGetLockInfo);
  2692     iWait->SetRequestType(EMobilePhoneGetLockInfo);
  2714     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
  2693     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
  2694     	RDEBUG( "WaitForRequestL", 0 );
  2715     TInt status = iWait->WaitForRequestL();
  2695     TInt status = iWait->WaitForRequestL();
       
  2696     	RDEBUG( "WaitForRequestL status", status );
       
  2697 	  #ifdef __WINS__
       
  2698 	  if (status == KErrNotSupported)
       
  2699 	  	{
       
  2700 			lockInfo.iSetting = RMobilePhone::ELockSetDisabled;
       
  2701 		  status = KErrNone;
       
  2702 	  	}
       
  2703 	  #endif
  2716     User::LeaveIfError(status);                    
  2704     User::LeaveIfError(status);                    
  2717     TInt currentItem = 0;
       
  2718 
  2705 
  2719     #if defined(_DEBUG)
  2706     #if defined(_DEBUG)
  2720     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() GetLockInfo"));
  2707     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() GetLockInfo"));
  2721     #endif
  2708     #endif
  2722 
  2709 
  2723 		if(aOldPassword.Length()==0)	// only if input parameters are empty
  2710 		if(aOldPassword.Length()==0)	// only if input parameters are empty
  2724 			{
  2711 			{
  2725 				// switch the value.
  2712 				// switch the value.
  2730       }
  2717       }
  2731 
  2718 
  2732     if (lEnable == 0)
  2719     if (lEnable == 0)
  2733         {
  2720         {
  2734         #if defined(_DEBUG)
  2721         #if defined(_DEBUG)
  2735         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetDisabled"));
  2722         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() currentItem: ELockSetDisabled"));
  2736         #endif
  2723         #endif
  2737         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2724         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2738         }
  2725         }
  2739     else
  2726     else
  2740         {
  2727         {
  2741         #if defined(_DEBUG)
  2728         #if defined(_DEBUG)
  2742         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL() currentItem: ELockSetEnabled"));
  2729         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() currentItem: ELockSetEnabled"));
  2743         #endif
  2730         #endif
  2744         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  2731         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  2745         }
  2732         }
  2746 
  2733 
  2747     // Raise a flag to indicate that the PIN
  2734     // Raise a flag to indicate that the PIN
  2748     // request coming from ETEL has originated from SecUi and not from Engine.
  2735     // request coming from ETEL has originated from SecUi and not from Engine.
  2749     TInt tRet = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
  2736     TInt tRet = RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
  2750     if ( tRet != KErrNone )
  2737     if ( tRet != KErrNone )
  2751         {
  2738         {
  2752         #if defined(_DEBUG)
  2739         #if defined(_DEBUG)
  2753         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestL():\
  2740         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL():\
  2754             FAILED to set the SECUI query Flag: %d"), tRet);
  2741             FAILED to set the SECUI query Flag: %d"), tRet);
  2755         #endif
  2742         #endif
  2756         }
  2743         }
  2757 
  2744 
  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
  2745     // Change the lock setting
  2773     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2746     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2774     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
  2747     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
  2748    	RDEBUG( "SetLockSetting", 0 );
  2775     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);	// this will trigger Pin1RequiredL
  2749     iPhone.SetLockSetting(iWait->iStatus,lockType,lockChangeSetting);	// this will trigger Pin1RequiredL
       
  2750     	RDEBUG( "WaitForRequestL", 0 );
  2776     status = iWait->WaitForRequestL();
  2751     status = iWait->WaitForRequestL();
  2777     #if defined(_DEBUG)
  2752     	RDEBUG( "WaitForRequestL status", status );
  2778     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangePinRequestL(): RETURN CODE: %d"), status);
  2753 	  #ifdef __WINS__
  2779     #endif
  2754 	  if (status == KErrNotSupported)
       
  2755 		  status = KErrNone;
       
  2756 	  #endif
  2780 
  2757 
  2781     // Lower the flag                             
  2758     // Lower the flag                             
  2782     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
  2759     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsETelAPIOriginated);
  2783 
  2760 
  2784     switch(status)
  2761     switch(status)
  2811         default:
  2788         default:
  2812             {
  2789             {
  2813             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags, aCaption, aShowError);
  2790             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags, aCaption, aShowError);
  2814             }
  2791             }
  2815         }
  2792         }
  2816  	}
  2793 return ETrue;
       
  2794 }
       
  2795 
       
  2796 //
       
  2797 // ----------------------------------------------------------
       
  2798 // CSecuritySettings::AskSecCodeParamsL()
       
  2799 // For asking security code e.g in settings
       
  2800 // not used
       
  2801 // ----------------------------------------------------------
       
  2802 // qtdone
       
  2803 EXPORT_C TBool CSecuritySettings::AskSecCodeParamsL(RMobilePhone::TMobilePassword &aOldPassword, TInt aFlags, TDes& aCaption, TInt aShowError)
       
  2804     {
       
  2805     	RDEBUG( "aFlags", aFlags );
       
  2806     	RDEBUG( "aShowError", aShowError );
       
  2807     	RDEBUG( "This doesn't do anything", 0 );
       
  2808     return EFalse;
       
  2809     }
  2817 
  2810 
  2818 // End of file
  2811 // End of file