securitydialogs/SecUi/Src/SecUiSecuritySettings.cpp
branchGCC_SURGE
changeset 40 604cd42065d1
parent 38 e0432375ea67
child 45 5d3e34b7618a
equal deleted inserted replaced
29:b63e8c2d8cff 40:604cd42065d1
    17 */
    17 */
    18 
    18 
    19 #include <etelmm.h>
    19 #include <etelmm.h>
    20 #include <exterror.h>
    20 #include <exterror.h>
    21 #include <textresolver.h>
    21 #include <textresolver.h>
    22 #include <SecUi.rsg>
       
    23 #include <aknnotedialog.h>
    22 #include <aknnotedialog.h>
    24 #include <mmtsy_names.h>
    23 #include <mmtsy_names.h>
    25 #include <centralrepository.h> 
    24 #include <centralrepository.h> 
    26 #include <gsmerror.h>
    25 #include <gsmerror.h>
    27 #include <SCPClient.h>
    26 #include <SCPClient.h>
    28 #include <StringLoader.h>
    27 #include <StringLoader.h>
    29 #include <e32property.h>
    28 #include <e32property.h>
    30 #include <PSVariables.h>   // Property values
    29 #include <PSVariables.h>   // Property values
    31 #include <securityuisprivatepskeys.h>
    30 #include <securityuisprivatepskeys.h>
    32 #include <startupdomainpskeys.h>
    31 #include <startupdomainpskeys.h>
       
    32 #include "SecUi.h"
    33 #include "secuisecuritysettings.h"
    33 #include "secuisecuritysettings.h"
    34 #include "SecUiAutoLockSettingPage.h"
       
    35 #include "secui.hrh"
    34 #include "secui.hrh"
    36 #include "secuisecurityhandler.h"
    35 #include "secuisecurityhandler.h"
    37 #include "secuicodequerydialog.h"
    36 #include "secuicodequerydialog.h"
    38 #include "SecUiWait.h"
    37 #include "SecUiWait.h"
    39 
    38 
    40 #ifdef RD_REMOTELOCK
       
    41 #include <aknnotewrappers.h>
    39 #include <aknnotewrappers.h>
    42 #include <StringLoader.h>
    40 #include <StringLoader.h>
    43 #include <RemoteLockSettings.h>
    41 #include <RemoteLockSettings.h>
    44 #include "SecUiRemoteLockSettingPage.h"
       
    45 #endif // RD_REMOTELOCK
       
    46 #include <featmgr.h>
    42 #include <featmgr.h>
    47 
    43 
    48 #include "SecQueryUi.h"
    44 #include "SecQueryUi.h"
    49 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
    45 #include <hb/hbwidgets/hbdevicemessageboxsymbian.h>
    50 
    46 
   100     /*****************************************************
    96     /*****************************************************
   101      *    Series 60 Customer / TSY
    97      *    Series 60 Customer / TSY
   102      *    Needs customer TSY implementation
    98      *    Needs customer TSY implementation
   103      *****************************************************/
    99      *****************************************************/
   104 
   100 
       
   101 		RDEBUG("0", 0);
   105     TInt err(KErrGeneral);
   102     TInt err(KErrGeneral);
   106     TInt thisTry(0);
   103     TInt thisTry(0);
   107     iWait = CWait::NewL();
   104     iWait = CWait::NewL();
   108     RTelServer::TPhoneInfo PhoneInfo;
   105     RTelServer::TPhoneInfo PhoneInfo;
   109     /* All server connections are tried to be made KTriesToConnectServer times because occasional
   106     /* All server connections are tried to be made KTriesToConnectServer times because occasional
   110      fails on connections are possible, at least on some servers */
   107      fails on connections are possible, at least on some servers */
   111 #if defined(_DEBUG)
       
   112     RDebug::Print(_L("(SECUI)CSecuritySettings::ConstructL()"));
       
   113 #endif
       
   114 
   108 
   115     FeatureManager::InitializeLibL();
   109     FeatureManager::InitializeLibL();
   116     // connect to ETel server
   110     // connect to ETel server
   117     while ((err = iServer.Connect()) != KErrNone && (thisTry++)
   111     while ((err = iServer.Connect()) != KErrNone && (thisTry++)
   118             <= KTriesToConnectServer)
   112             <= KTriesToConnectServer)
   159     delete iSecurityHandler;
   153     delete iSecurityHandler;
   160 
   154 
   161     // Cancel active requests
   155     // Cancel active requests
   162     if (iWait->IsActive())
   156     if (iWait->IsActive())
   163         {
   157         {
   164 #if defined(_DEBUG)
   158 				RDEBUG("CancelAsyncRequest", 0);
   165         RDebug::Print(_L("(SECUI)CManualSecuritySettings::~CSecuritySettings() CANCEL REQ"));
       
   166 #endif
       
   167         iPhone.CancelAsyncRequest(iWait->GetRequestType());
   159         iPhone.CancelAsyncRequest(iWait->GetRequestType());
   168 
   160 
   169         switch (iWait->GetRequestType())
   161         switch (iWait->GetRequestType())
   170             { //inform query that it has beeen canceled
   162             { //inform query that it has beeen canceled
   171             case EMobilePhoneSetLockSetting:
   163             case EMobilePhoneSetLockSetting:
   210     iNewPassword.Copy(_L(""));
   202     iNewPassword.Copy(_L(""));
   211 
   203 
   212     TBuf<0x80> iCaption;
   204     TBuf<0x80> iCaption;
   213     iCaption.Copy(_L("ChangePinL"));
   205     iCaption.Copy(_L("ChangePinL"));
   214     TInt iShowError = 1;
   206     TInt iShowError = 1;
   215     ChangePinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   207     TInt err = ChangePinParamsL(iOldPassword, iNewPassword, iFlags, iCaption, iShowError);
   216     RDEBUG("0", 0);
   208     RDEBUG("err", err);
   217     }
   209     }
   218 
   210 
   219 //
   211 //
   220 // ----------------------------------------------------------
   212 // ----------------------------------------------------------
   221 // CSecuritySettings::ChangeUPinL()
   213 // CSecuritySettings::ChangeUPinL()
   232     iNewPassword.Copy(_L(""));
   224     iNewPassword.Copy(_L(""));
   233 
   225 
   234     TBuf<0x80> iCaption;
   226     TBuf<0x80> iCaption;
   235     iCaption.Copy(_L("ChangeUPinL"));
   227     iCaption.Copy(_L("ChangeUPinL"));
   236     TInt iShowError = 1;
   228     TInt iShowError = 1;
   237     ChangeUPinParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   229     TInt err = ChangeUPinParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   238             iShowError);
   230             iShowError);
   239     RDEBUG("0", 0);
   231     RDEBUG("err", err);
   240 
   232 
   241     }
   233     }
   242 
   234 
   243 //
   235 //
   244 // ----------------------------------------------------------
   236 // ----------------------------------------------------------
   256     iNewPassword.Copy(_L(""));
   248     iNewPassword.Copy(_L(""));
   257 
   249 
   258     TBuf<0x80> iCaption;
   250     TBuf<0x80> iCaption;
   259     iCaption.Copy(_L("ChangePin2L"));
   251     iCaption.Copy(_L("ChangePin2L"));
   260     TInt iShowError = 1;
   252     TInt iShowError = 1;
   261     ChangePin2ParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   253     TInt err = ChangePin2ParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   262             iShowError);
   254             iShowError);
   263     RDEBUG("0", 0);
   255     RDEBUG("err", err);
   264 
       
   265     }
   256     }
   266 //
   257 //
   267 // ----------------------------------------------------------
   258 // ----------------------------------------------------------
   268 // CSecuritySettings::ChangeSecCodeL()
   259 // CSecuritySettings::ChangeSecCodeL()
   269 // Changes security code 
   260 // Changes security code 
   279     iNewPassword.Copy(_L(""));
   270     iNewPassword.Copy(_L(""));
   280 
   271 
   281     TBuf<0x80> iCaption;
   272     TBuf<0x80> iCaption;
   282     iCaption.Copy(_L("ChangeSecCodeL"));
   273     iCaption.Copy(_L("ChangeSecCodeL"));
   283     TInt iShowError = 1;
   274     TInt iShowError = 1;
   284     ChangeSecCodeParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   275     TInt err = ChangeSecCodeParamsL(iOldPassword, iNewPassword, iFlags, iCaption,
   285             iShowError);
   276             iShowError);
   286     RDEBUG("0", 0);
   277     RDEBUG("err", err);
   287     }
   278     }
   288 //
   279 //
   289 // ----------------------------------------------------------
   280 // ----------------------------------------------------------
   290 // CSecuritySettings::ChangeAutoLockPeriodL()
   281 // CSecuritySettings::ChangeAutoLockPeriodL()
   291 // Changes autolock period
   282 // Changes autolock period
   314 // ----------------------------------------------------------
   305 // ----------------------------------------------------------
   315 // no qtdone
   306 // no qtdone
   316 EXPORT_C TInt CSecuritySettings::ChangeRemoteLockStatusL(
   307 EXPORT_C TInt CSecuritySettings::ChangeRemoteLockStatusL(
   317         TBool& aRemoteLockStatus, TDes& aRemoteLockCode, TInt aAutoLockPeriod)
   308         TBool& aRemoteLockStatus, TDes& aRemoteLockCode, TInt aAutoLockPeriod)
   318     {
   309     {
   319 #ifdef RD_REMOTELOCK
       
   320     TInt retValue( KErrNone );
   310     TInt retValue( KErrNone );
   321 
   311 		RDEBUG("aRemoteLockStatus", aRemoteLockStatus);
   322 #ifdef _DEBUG
   312 		RDEBUG("aAutoLockPeriod", aAutoLockPeriod);
   323     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Enter, aRemoteLockStatus == %d, aAutoLockPeriod == %d" ), aRemoteLockStatus, aAutoLockPeriod );
       
   324 #endif // _DEBUG
       
   325     CCoeEnv* coeEnv = CCoeEnv::Static();
       
   326     CDesCArrayFlat* items = coeEnv->ReadDesC16ArrayResourceL( R_REMOTELOCK_LBX );
       
   327     CleanupStack::PushL( items );
       
   328 
       
   329     // Store the current remote lock setting 
       
   330     TInt previousItem( 0 );
       
   331     TInt currentItem( 0 );
       
   332 
   313 
   333     if ( aRemoteLockStatus )
   314     if ( aRemoteLockStatus )
   334         {
   315         {
   335         previousItem = KRemoteLockSettingItemOn;
   316         aRemoteLockStatus = ETrue;
   336         currentItem = KRemoteLockSettingItemOn;
   317 
       
   318         // If user wishes to enable remote lock
       
   319         // a new remote lock code is required.
       
   320         // RemoteLockCodeQueryL also 
       
   321         retValue = RemoteLockCodeQueryL( aRemoteLockCode );
   337         }
   322         }
   338     else
   323     else
   339         {
   324         {
   340         previousItem = KRemoteLockSettingItemOff;
   325         aRemoteLockStatus = EFalse;
   341         currentItem = KRemoteLockSettingItemOff;
   326         retValue = KErrNone;
   342         }
   327 				// TODO this should calculate aAutoLockPeriod itself, and not trust the input
   343 
   328 
   344     // Create Remote Lock setting page for user to enable or disable remote locking 
   329         // Check whether AutoLock is enabled (timeout value greater 
   345     CRemoteLockSettingPage* remoteLockSettingPage = new( ELeave ) CRemoteLockSettingPage( R_REMOTELOCK_SETTING_PAGE, currentItem, items );
   330         // than zero) or not. If AutoLock is enabled the domestic OS 
   346 
   331         // device lock should be left enabled.
   347 #ifdef _DEBUG
   332         if ( aAutoLockPeriod == 0 )
   348     RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Executing CRemoteLockSettingPage dialog" ) );
   333             {
   349 #endif // _DEBUG
   334             // Disable lock setting from domestic OS
   350     // Execute the remote lock enable/disable dialog
   335             retValue = RemoteLockSetLockSettingL( EFalse );
   351     TBool ret = remoteLockSettingPage->ExecuteLD( CAknSettingPage::EUpdateWhenChanged );
       
   352 
       
   353     // Setting page list box items (texts) no longer needed
       
   354     CleanupStack::PopAndDestroy( items );
       
   355 
       
   356     if ( ret )
       
   357         {
       
   358         if ( currentItem == KRemoteLockSettingItemOn )
       
   359             {
       
   360 #ifdef _DEBUG
       
   361             RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Remote lock status set to ON" ) );
       
   362 #endif // _DEBUG
       
   363             aRemoteLockStatus = ETrue;
       
   364 
       
   365             // If user wishes to enable remote lock
       
   366             // a new remote lock code is required.
       
   367             // RemoteLockCodeQueryL also 
       
   368             retValue = RemoteLockCodeQueryL( aRemoteLockCode );
       
   369             }
       
   370         else if ( currentItem == KRemoteLockSettingItemOff )
       
   371             {
       
   372 #ifdef _DEBUG
       
   373             RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Remote lock status set to OFF" ) );
       
   374 #endif // _DEBUG
       
   375             aRemoteLockStatus = EFalse;
       
   376             retValue = KErrNone;
       
   377 
       
   378             // Check whether the status was already off
       
   379             // If not don't make the user enter the security code
       
   380             // (which occurs when setting the DOS lock setting) for no reason.
       
   381             if ( currentItem != previousItem )
       
   382                 {
       
   383                 // Check whether AutoLock is enabled (timeout value greater 
       
   384                 // than zero) or not. If AutoLock is enabled the domestic OS 
       
   385                 // device lock should be left enabled.
       
   386                 if ( aAutoLockPeriod == 0 )
       
   387                     {
       
   388                     // Disable lock setting from domestic OS
       
   389                     retValue = RemoteLockSetLockSettingL( EFalse );
       
   390                     }
       
   391                 else
       
   392                     {
       
   393                     // If AutoLock is enabled, don't disable the DOS device lock
       
   394                     // Re-set (enable) the domestic OS device lock because as a 
       
   395                     // side effect it requires the security code from the user
       
   396                     retValue = RemoteLockSetLockSettingL( ETrue );
       
   397                     }
       
   398                 }
       
   399             }
   336             }
   400         else
   337         else
   401             {
   338             {
   402             // This should never happen. But if it does don't change anything
   339             // If AutoLock is enabled, don't disable the DOS device lock
   403             retValue = KErrUnknown;
   340             // Re-set (enable) the domestic OS device lock because as a 
   404             }
   341             // side effect it requires the security code from the user
   405         }
   342             retValue = RemoteLockSetLockSettingL( ETrue );
   406     else
   343             }
   407         {
   344         }
   408         // Something went wrong with the RemoteLockSettingPage dialog 
   345 		RDEBUG( "retValue", retValue );
   409         retValue = KErrGeneral;
       
   410 
       
   411 #ifdef _DEBUG
       
   412         RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - CRemoteLockSettingPage::ExecuteLD() failed" ) );
       
   413 #endif // _DEBUG
       
   414         }
       
   415 
       
   416 #ifdef _DEBUG
       
   417     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockStatusL() - Exit" ) );
       
   418 #endif
       
   419 
       
   420     return retValue;
   346     return retValue;
   421 #else //! RD_REMOTELOCK
       
   422     return KErrNotSupported;
       
   423 #endif //RD_REMOTELOCK
       
   424     }
   347     }
   425 //
   348 //
   426 // ----------------------------------------------------------
   349 // ----------------------------------------------------------
   427 // CSecuritySettings::RemoteLockCodeQueryL()
   350 // CSecuritySettings::RemoteLockCodeQueryL()
   428 // Pops up remote lock code query. Requires user to enter a new remote lock 
   351 // Pops up remote lock code query. Requires user to enter a new remote lock 
   429 // code twice and if they match enables the domestic OS device lock (which as 
   352 // code (RemoteMsg) twice and if they match enables the domestic OS device lock (which as 
   430 // a side effect pops up security code query).
   353 // a side effect pops up security code query).
   431 // ----------------------------------------------------------
   354 // Note: if the RemoteMsg is cancelled, nevertheless the lock is activated. This is done because the code is askedirst, and the only way to do so is by enabling the lock.
   432 // no qtdone
   355 // This is not a problem, because:
       
   356 // a) first the RemoteMsg is enable, and this function is used to change it
       
   357 // b) if lock was disabled, the "change RemoteMsg" menu is not available.
       
   358 // ----------------------------------------------------------
       
   359 // qtdone
   433 TInt CSecuritySettings::RemoteLockCodeQueryL(TDes& aRemoteLockCode)
   360 TInt CSecuritySettings::RemoteLockCodeQueryL(TDes& aRemoteLockCode)
   434     {
   361     {
   435 #ifdef RD_REMOTELOCK
   362 
   436     TInt retValue( KErrNone );
   363     TInt retValue( KErrNone );
   437 
   364 
   438 #ifdef _DEBUG
   365       // This is done because lock-code needs to be asked first.
   439     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Enter" ) );
   366       // Enable lock setting in domestic OS. It is safe to enable the 
   440 #endif // _DEBUG
   367       // lock setting since RemoteLock API requires remote locking to
   441     // Clear the remote lock code buffer
   368       // be enabled when changing or setting the remote lock message.
       
   369       retValue = RemoteLockSetLockSettingL( ETrue );
       
   370 		RDEBUG( "retValue", retValue );
       
   371 		if (retValue != KErrNone)
       
   372             return retValue;
   442     aRemoteLockCode.Zero();
   373     aRemoteLockCode.Zero();
   443 
   374 
   444     // ----- Remote lock code query -------------------------------------------
   375     TInt queryAccepted = KErrCancel;
   445 
   376         queryAccepted = KErrCancel;
   446     // Execute Remote Lock code query
   377         CSecQueryUi * iSecQueryUi;
   447 #ifdef _DEBUG
   378         iSecQueryUi = CSecQueryUi::NewL();
   448     RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Executing remote lock code query" ) );
   379         // this queries both, and verifies itself
   449 #endif // _DEBUG
   380         queryAccepted = iSecQueryUi->SecQueryDialog(
   450     // Load the query prompt from resources
   381                 _L("RemoteMsg-New|RemoteMsg-Ver"), aRemoteLockCode,
   451     CCodeQueryDialog* codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
   382                 SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH,
   452     TInt buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
   383                 ESecUiAlphaSupported | ESecUiCancelSupported
   453     if ( buttonId == EEikBidOk )
   384                         | ESecUiEmergencyNotSupported | ESecUiNone);
   454         {
   385         RDEBUG("aRemoteLockCode", 0);
   455         // Ok was pressed and the remote lock code seems fine
   386         RDebug::Print(aRemoteLockCode);
   456         retValue = KErrNone;
   387         RDEBUG("queryAccepted", queryAccepted);
   457         }
   388         delete iSecQueryUi;
   458     else
   389         if (queryAccepted != KErrNone)
   459         {
   390             return KErrAbort;
   460         // User pressed Cancel
   391 
   461         // Set the code length to zero leaving no trash for possible retry
   392             // Check that the new remote lock code doesn't match the security code of the device.
   462         aRemoteLockCode.Zero();
   393             RMobilePhone::TMobilePhoneSecurityCode secCodeType = RMobilePhone::ESecurityCodePhonePassword;
   463         retValue = KErrAbort;
       
   464         }
       
   465 
       
   466     if ( retValue != KErrNone )
       
   467         {
       
   468 #ifdef _DEBUG
       
   469         RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Exit, Remote lock code error" ) );
       
   470 #endif // _DEBUG
       
   471         // Can't continue beyond this 
       
   472         return retValue;
       
   473         }
       
   474 
       
   475     // ----- Remote lock code confirm query -----------------------------------
       
   476 
       
   477     // Confirm the code by asking it again
       
   478 #ifdef _DEBUG
       
   479     RDebug::Print( _L( "(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Executing remote lock code verify query" ) );
       
   480 #endif // _DEBUG
       
   481     // Buffer for the confirmation code
       
   482     TBuf<KRLockMaxLockCodeLength> confirmCode;
       
   483 
       
   484     // Load the confirmation query prompt from resources
       
   485     CCodeQueryDialog* codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   486     buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
       
   487 
       
   488     if ( buttonId == EEikBidOk )
       
   489         {
       
   490         // Compare codes. Compare returns zero if descriptors have
       
   491         // the same length and the same content
       
   492         while ( (aRemoteLockCode.CompareF( confirmCode ) != 0) && (buttonId == EEikBidOk))
       
   493             {
       
   494             //Codes didn't match; zero the bufffers and show the dialog again
       
   495             aRemoteLockCode.Zero();
       
   496             confirmCode.Zero();
       
   497             // Codes don't match. Notify user
       
   498             ShowResultNoteL( R_REMOTELOCK_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone );
       
   499             codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   500             buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
       
   501             //Unless user pressed Cancel show the verification query
       
   502             if(buttonId == EEikBidOk)
       
   503                 {
       
   504                 codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   505                 buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
       
   506                 }
       
   507 
       
   508             }
       
   509         //User pressed cancel        
       
   510         if(buttonId != EEikBidOk)
       
   511             {
       
   512             // Set the code length to zero leaving no trash for possible retry
       
   513             // Report error and let the user try again 
       
   514             aRemoteLockCode.Zero();
       
   515             confirmCode.Zero();
       
   516             retValue = KErrAbort;
       
   517             }
       
   518         else
       
   519             {
       
   520             // Codes match
       
   521             confirmCode.Zero();
       
   522 
       
   523             // ----- Check against security code ------------------------------
       
   524 
       
   525             // Check that the new remote lock code doesn't match the security 
       
   526             // code of the device.
       
   527 
       
   528             RMobilePhone::TMobilePhoneSecurityCode secCodeType;
       
   529             secCodeType = RMobilePhone::ESecurityCodePhonePassword;
       
   530             RMobilePhone::TMobilePassword securityCode;
   394             RMobilePhone::TMobilePassword securityCode;
   531             RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter 
   395             RMobilePhone::TMobilePassword unblockCode; // Required here only as a dummy parameter 
   532 
   396 
   533             if ( aRemoteLockCode.Length() <= RMobilePhone::KMaxMobilePasswordSize )
   397 
   534                 {
       
   535                 securityCode = aRemoteLockCode;
   398                 securityCode = aRemoteLockCode;
       
   399 								RDEBUG( "EMobilePhoneVerifySecurityCode", EMobilePhoneVerifySecurityCode );
   536                 iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
   400                 iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
   537                 RDEBUG( "VerifySecurityCode", 0 );
   401                 RDEBUG( "VerifySecurityCode", 0 );
   538                 iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
   402                 iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
   539                 RDEBUG( "WaitForRequestL", 0 );
   403                 RDEBUG( "WaitForRequestL", 0 );
   540                 TInt res = iWait->WaitForRequestL();
   404                 TInt res = iWait->WaitForRequestL();
   541                 RDEBUG( "WaitForRequestL res", res );
   405                 RDEBUG( "WaitForRequestL res", res );
   542 #ifdef __WINS__
   406 #ifdef __WINS__
   543                 if (res == KErrNotSupported || res == KErrTimedOut)
   407                 if (res == KErrNotSupported || res == KErrTimedOut)
   544                 res = KErrNone;
   408                 res = KErrGsm0707IncorrectPassword;	// KErrGsm0707IncorrectPassword = incorrect code
   545 #endif
   409 #endif
   546                 // The remote lock code matches the security code 
   410 								RDEBUG( "KErrGsm0707IncorrectPassword", KErrGsm0707IncorrectPassword );
   547                 // and that is not allowed
   411                 if(res == KErrNone)
   548                 while ( (res == KErrNone) && (buttonId == EEikBidOk))
       
   549                     {
   412                     {
   550 #ifdef _DEBUG
   413                     // The message is also valid as a lock-code, this means that
   551                     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Unacceptable remote lock code" ) );
   414 		                // remote lock code matches the security code 
   552 #endif // _DEBUG
   415 		                // and that is not allowed
   553                     aRemoteLockCode.Zero();
   416 		                RDEBUG( "return KErrCancel because msg matches code", KErrCancel );
   554                     confirmCode.Zero();
   417 		                ShowResultNoteL(R_REMOTELOCK_INVALID_CODE, CAknNoteDialog::EErrorTone);
   555 
   418 		                return KErrCancel;
   556                     ShowResultNoteL( R_REMOTELOCK_INVALID_CODE, CAknNoteDialog::EErrorTone );
       
   557 
       
   558                     codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   559                     buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
       
   560                     //Unless user pressed Cancel show the verification query
       
   561                     if(buttonId == EEikBidOk)
       
   562                         {
       
   563                         codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   564                         buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
       
   565 
       
   566                         // Compare codes. Compare returns zero if descriptors have
       
   567                         // the same length and the same content
       
   568                         while ( (aRemoteLockCode.CompareF( confirmCode ) != 0) && (buttonId == EEikBidOk))
       
   569                             {
       
   570                             //Codes didn't match; zero the bufffers and show the dialog again
       
   571                             aRemoteLockCode.Zero();
       
   572                             confirmCode.Zero();
       
   573                             // Codes don't match. Notify user
       
   574                             ShowResultNoteL( R_REMOTELOCK_CODES_DONT_MATCH, CAknNoteDialog::EErrorTone );
       
   575                             codeQuery = new( ELeave ) CCodeQueryDialog( aRemoteLockCode, SEC_REMOTELOCK_CODE_MIN_LENGTH,SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   576                             buttonId = codeQuery->ExecuteLD( R_REMOTELOCK_CODE_QUERY );
       
   577                             //Unless user pressed Cancel show the verification query
       
   578                             if(buttonId == EEikBidOk)
       
   579                                 {
       
   580                                 codeConfirmQuery = new( ELeave ) CCodeQueryDialog( confirmCode, SEC_REMOTELOCK_CODE_MIN_LENGTH, SEC_REMOTELOCK_CODE_MAX_LENGTH, ESecUiNone, ETrue );
       
   581                                 buttonId = codeConfirmQuery->ExecuteLD( R_VERIFY_REMOTELOCK_CODE_QUERY);
       
   582                                 }
       
   583 
       
   584                             }
       
   585                         //User pressed cancel        
       
   586                         if(buttonId != EEikBidOk)
       
   587                             {
       
   588                             // Set the code length to zero leaving no trash for possible retry
       
   589                             // Report error and let the user try again 
       
   590                             aRemoteLockCode.Zero();
       
   591                             confirmCode.Zero();
       
   592                             retValue = KErrAbort;
       
   593                             }
       
   594                         else //Check against security code
       
   595 
       
   596                             {
       
   597                             securityCode = aRemoteLockCode;
       
   598                             iWait->SetRequestType( EMobilePhoneVerifySecurityCode );
       
   599                             RDEBUG( "VerifySecurityCode", 0 );
       
   600                             iPhone.VerifySecurityCode( iWait->iStatus, secCodeType, securityCode, unblockCode );
       
   601                             RDEBUG( "WaitForRequestL", 0 );
       
   602                             res = iWait->WaitForRequestL();
       
   603 #ifdef __WINS__
       
   604                             if (res == KErrNotSupported || res == KErrTimedOut)
       
   605                             res = KErrNone;
       
   606 #endif
       
   607                             RDEBUG( "WaitForRequestL res", res );
       
   608                             }
       
   609                         }
       
   610 
       
   611                     }
   419                     }
   612                 //User pressed cancel        
   420 
   613                 if(buttonId != EEikBidOk)
   421 		RDEBUG( "retValue", retValue );
   614                     {
       
   615                     // Set the code length to zero leaving no trash for possible retry
       
   616                     // Report error and let the user try again 
       
   617                     aRemoteLockCode.Zero();
       
   618                     confirmCode.Zero();
       
   619                     retValue = KErrAbort;
       
   620                     }
       
   621                 }
       
   622 
       
   623             // ----- Enable DOS device lock (Security code query) -------------
       
   624 
       
   625             if ( retValue == KErrNone )
       
   626                 {
       
   627                 // Enable lock setting in domestic OS. It is safe to enable the 
       
   628                 // lock setting since RemoteLock API requires remote locking to
       
   629                 // be enabled when changing or setting the remote lock message.
       
   630                 retValue = RemoteLockSetLockSettingL( ETrue );
       
   631                 }
       
   632             }
       
   633         }
       
   634     else //User pressed Cancel
       
   635 
       
   636         {
       
   637         // Set the code length to zero leaving no trash for possible retry
       
   638         aRemoteLockCode.Zero();
       
   639         confirmCode.Zero();
       
   640         retValue = KErrAbort;
       
   641         }
       
   642 
       
   643 #ifdef _DEBUG
       
   644     RDebug::Print(_L("(SecUi)CSecuritySettings::ChangeRemoteLockCodeL() - Exit" ) );
       
   645 #endif // _DEBUG
       
   646     return retValue;
   422     return retValue;
   647 #else //! RD_REMOTELOCK
       
   648     return KErrNotSupported;
       
   649 #endif //RD_REMOTELOCK
       
   650     }
   423     }
   651 //
   424 //
   652 // ----------------------------------------------------------
   425 // ----------------------------------------------------------
   653 // CSecuritySettings::RemoteLockSetLockSettingL()
   426 // CSecuritySettings::RemoteLockSetLockSettingL()
   654 // Changes lock setting in domestic OS. Changing the domestic OS lock setting
   427 // Changes lock setting in domestic OS. Changing the domestic OS lock setting
   655 // requires user to enter the security code.
   428 // requires user to enter the security code.
   656 // ----------------------------------------------------------
   429 // ----------------------------------------------------------
   657 // no qtdone
   430 // qtdone
   658 TInt CSecuritySettings::RemoteLockSetLockSettingL(TBool aLockSetting)
   431 TInt CSecuritySettings::RemoteLockSetLockSettingL(TBool aLockSetting)
   659     {
   432     {
   660 #ifdef RD_REMOTELOCK
       
   661     TInt retValue( KErrNone );
   433     TInt retValue( KErrNone );
   662 
   434 		RDEBUG( "aLockSetting", aLockSetting );
   663 #ifdef _DEBUG
   435 
   664     RDebug::Print(_L("(SecUi)CSecuritySettings::RemoteLockSetLockSettingL( %d ) - Enter" ), aLockSetting );
   436 
   665 #endif // _DEBUG
       
   666     RMobilePhone::TMobilePhoneLockSetting lockSetting = RMobilePhone::ELockSetEnabled;
   437     RMobilePhone::TMobilePhoneLockSetting lockSetting = RMobilePhone::ELockSetEnabled;
   667     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
   438     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
   668 
   439 
   669     if ( aLockSetting )
       
   670         {
       
   671         lockSetting = RMobilePhone::ELockSetEnabled;
       
   672         }
       
   673     else
       
   674         {
       
   675         lockSetting = RMobilePhone::ELockSetDisabled;
       
   676         }
       
   677 
       
   678     iWait->SetRequestType( EMobilePhoneSetLockSetting );
       
   679     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
   680     RDEBUG( "SetLockSetting", 0 );
       
   681     iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );
       
   682 
       
   683     // Wait for code verify to complete
       
   684     RDEBUG( "WaitForRequestL", 0 );
       
   685     retValue = iWait->WaitForRequestL();
       
   686     RDEBUG( "WaitForRequestL retValue", retValue );
       
   687 #ifdef __WINS__
       
   688     if (retValue == KErrNotSupported || retValue == KErrTimedOut)
       
   689     retValue = KErrNone;
       
   690 #endif
       
   691 
       
   692     switch( retValue )
       
   693         {
       
   694         case KErrNone:
       
   695 #ifdef _DEBUG
       
   696         RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrNone" ) );
       
   697 #endif // _DEBUG
       
   698         break;
       
   699 
       
   700         case KErrGsmSSPasswordAttemptsViolation:
       
   701         case KErrLocked:
       
   702 #ifdef _DEBUG
       
   703         RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrLocked" ) );
       
   704 #endif // _DEBUG
       
   705         //Error note is shown in CSecurityHandler::PassPhraseRequired()
       
   706         break;
       
   707 
       
   708         case KErrGsm0707IncorrectPassword:
       
   709         case KErrAccessDenied:
       
   710 #ifdef _DEBUG
       
   711         RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrAccessDenied" ) );
       
   712 #endif // _DEBUG
       
   713         // Security code was entered erroneously
       
   714         //Error note is shown in CSecurityHandler::PassPhraseRequired()
       
   715         break;
       
   716 
       
   717         case KErrAbort:
       
   718 #ifdef _DEBUG
       
   719         RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned KErrAbort" ) );
       
   720 #endif // _DEBUG
       
   721         break;
       
   722 
       
   723         default:
       
   724 #ifdef _DEBUG
       
   725         RDebug::Print( _L( "(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - EMobilePhoneSetLockSetting request returned: %d"), retValue );
       
   726 #endif // _DEBUG
       
   727         break;
       
   728         }
       
   729 
       
   730 #ifdef _DEBUG
       
   731     RDebug::Print(_L("(SecUi)CSecuritySettings::RemoteLockSetLockSettingL() - Exit" ) );
       
   732 #endif // _DEBUG
       
   733     return retValue;
       
   734 #else //! RD_REMOTELOCK
       
   735     return KErrNotSupported;
       
   736 #endif //RD_REMOTELOCK
       
   737     }
       
   738 
       
   739 //
       
   740 // ----------------------------------------------------------
       
   741 // CSecuritySettings::ChangeSimSecurityL()
       
   742 // Changes SIM security
       
   743 // ----------------------------------------------------------
       
   744 // qtdone
       
   745 EXPORT_C TBool CSecuritySettings::ChangeSimSecurityL()
       
   746     {
       
   747     /*****************************************************
       
   748      *    Series 60 Customer / ETel
       
   749      *    Series 60  ETel API
       
   750      *****************************************************/
       
   751 #if defined(_DEBUG)
       
   752     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSimSecurityL()"));
       
   753 #endif
       
   754 
   440 
   755     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   441     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   756     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   442     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   757     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneToICC;
       
   758     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
       
   759 
   443 
   760     //get lock info
   444     //get lock info
   761     iWait->SetRequestType(EMobilePhoneGetLockInfo);
   445     iWait->SetRequestType(EMobilePhoneGetLockInfo);
   762     RDEBUG("GetLockInfo", 0);
   446     RDEBUG("GetLockInfo", 0);
   763     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   447     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   771         lockInfo.iSetting = RMobilePhone::ELockSetDisabled;
   455         lockInfo.iSetting = RMobilePhone::ELockSetDisabled;
   772         status = KErrNone;
   456         status = KErrNone;
   773         }
   457         }
   774 #endif
   458 #endif
   775     User::LeaveIfError(status);
   459     User::LeaveIfError(status);
       
   460 		RDEBUG("current lockInfo.iSetting", lockInfo.iSetting);
       
   461 
       
   462 		// disabled->disabled	should not happen
       
   463 		// enabled->enabled		happens because a change of message also forces a code re-validation
       
   464     if ( aLockSetting )
       
   465         {
       
   466         lockSetting = RMobilePhone::ELockSetEnabled;
       
   467         }
       
   468     else
       
   469         {
       
   470         lockSetting = RMobilePhone::ELockSetDisabled;
       
   471         }
       
   472 		RDEBUG("future lockSetting", lockSetting);
       
   473 
       
   474     iWait->SetRequestType( EMobilePhoneSetLockSetting );
       
   475     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel, ESecurityUIsQueryRequestOk);
       
   476     RDEBUG( "SetLockSetting", 0 );
       
   477     iPhone.SetLockSetting( iWait->iStatus, lockType, lockSetting );	// this will PassPhraseRequiredL
       
   478     RDEBUG( "WaitForRequestL", 0 );
       
   479     retValue = iWait->WaitForRequestL();
       
   480     RDEBUG( "WaitForRequestL retValue", retValue );
       
   481 #ifdef __WINS__
       
   482     if (retValue == KErrNotSupported || retValue == KErrTimedOut)
       
   483     retValue = KErrNone;
       
   484 #endif
       
   485 
       
   486     switch( retValue )
       
   487         {
       
   488         case KErrNone:
       
   489         break;
       
   490 
       
   491         case KErrGsmSSPasswordAttemptsViolation:
       
   492         case KErrLocked:
       
   493         case KErrGsm0707IncorrectPassword:
       
   494         case KErrAccessDenied:
       
   495         // Security code was entered erroneously
       
   496         //Error note is shown in CSecurityHandler::PassPhraseRequired()
       
   497         break;
       
   498 
       
   499         case KErrAbort:
       
   500         break;
       
   501 
       
   502         default:
       
   503         break;
       
   504         }
       
   505 
       
   506 		RDEBUG( "retValue", retValue );
       
   507     return retValue;
       
   508     }
       
   509 
       
   510 //
       
   511 // ----------------------------------------------------------
       
   512 // CSecuritySettings::ChangeSimSecurityL()
       
   513 // Changes SIM security
       
   514 // ----------------------------------------------------------
       
   515 // qtdone
       
   516 EXPORT_C TBool CSecuritySettings::ChangeSimSecurityL()
       
   517     {
       
   518     /*****************************************************
       
   519      *    Series 60 Customer / ETel
       
   520      *    Series 60  ETel API
       
   521      *****************************************************/
       
   522 		RDEBUG("0", 0);
       
   523     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
   524     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
   525     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneToICC;
       
   526     RMobilePhone::TMobilePhoneLockSetting lockChangeSetting;
       
   527 
       
   528     //get lock info
       
   529     iWait->SetRequestType(EMobilePhoneGetLockInfo);
       
   530     RDEBUG("GetLockInfo", 0);
       
   531     iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
       
   532     RDEBUG("WaitForRequestL", 0);
       
   533     TInt status = iWait->WaitForRequestL();
       
   534     RDEBUG("WaitForRequestL status", status);
       
   535 
       
   536 #ifdef __WINS__
       
   537     if (status == KErrNotSupported || status == KErrTimedOut)
       
   538         {
       
   539         lockInfo.iSetting = RMobilePhone::ELockSetDisabled;
       
   540         status = KErrNone;
       
   541         }
       
   542 #endif
       
   543     User::LeaveIfError(status);
   776     TInt currentItem = 0;
   544     TInt currentItem = 0;
   777 
   545 		RDEBUG("lockInfo.iSetting", lockInfo.iSetting);
   778     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   546     if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   779         {
   547         {
   780 #if defined(_DEBUG)
       
   781         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSimSecurityL()lockInfo: ELockSetDisabled"));
       
   782 #endif
       
   783         currentItem = 1; // off
   548         currentItem = 1; // off
   784         }
   549         }
   785 
   550 
   786     if (currentItem == 0) // switch the flag
   551     if (currentItem == 0) // switch the flag
   787         {
   552         {
   805     if (status == KErrNotSupported || status == KErrTimedOut)
   570     if (status == KErrNotSupported || status == KErrTimedOut)
   806     status = KErrNone;
   571     status = KErrNone;
   807 #endif
   572 #endif
   808 
   573 
   809     // the error was displayed in the handler
   574     // the error was displayed in the handler
   810 #if defined(_DEBUG)
   575 		RDEBUG("status", status);
   811     RDebug::Print( _L("(SECUI)CSecuritySettings::ChangeSimSecurityL(): RETURN CODE: %d"), status);
       
   812 #endif        
       
   813     switch (status)
   576     switch (status)
   814         {
   577         {
   815         case KErrNone:
   578         case KErrNone:
   816             {
   579             {
   817             break;
   580             break;
   855     iOldPassword.Copy(_L(""));
   618     iOldPassword.Copy(_L(""));
   856 
   619 
   857     TBuf<0x80> iCaption;
   620     TBuf<0x80> iCaption;
   858     iCaption.Copy(_L("ChangePinRequestL"));
   621     iCaption.Copy(_L("ChangePinRequestL"));
   859     TInt iShowError = 1;
   622     TInt iShowError = 1;
   860     ChangePinRequestParamsL(
   623     TInt err = ChangePinRequestParamsL(
   861             1/* TODO it's imposible to know if we want to set or clear*/,
   624             1/* it's imposible to know if we want to set or clear*/,
   862             iOldPassword, iFlags, iCaption, iShowError);
   625             iOldPassword, iFlags, iCaption, iShowError);
   863     RDEBUG("0", 0);
   626     RDEBUG("err", err);
   864 
   627 		if(err==KErrNone)
   865     return ETrue;
   628     	return ETrue;
       
   629 		else
       
   630    		return EFalse;
   866     }
   631     }
   867 
   632 
   868 //
   633 //
   869 // ----------------------------------------------------------
   634 // ----------------------------------------------------------
   870 // CSecuritySettings::ChangeUPinRequestL()
   635 // CSecuritySettings::ChangeUPinRequestL()
   874 EXPORT_C TBool CSecuritySettings::ChangeUPinRequestL()
   639 EXPORT_C TBool CSecuritySettings::ChangeUPinRequestL()
   875     {
   640     {
   876     TBool wcdmaSupported(
   641     TBool wcdmaSupported(
   877             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
   642             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
   878     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
   643     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
       
   644 		RDEBUG("wcdmaSupported", wcdmaSupported);
       
   645 		RDEBUG("upinSupported", upinSupported);
   879     if (wcdmaSupported || upinSupported)
   646     if (wcdmaSupported || upinSupported)
   880         {
   647         {
   881 #if defined(_DEBUG)
       
   882         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL()"));
       
   883 #endif
       
   884 
       
   885         TInt simState;
   648         TInt simState;
   886         TInt err(KErrGeneral);
   649         TInt err(KErrGeneral);
   887         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
   650         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
   888         User::LeaveIfError(err);
   651         User::LeaveIfError(err);
   889         TBool simRemoved(simState == ESimNotPresent);
   652         TBool simRemoved(simState == ESimNotPresent);
   914         status = KErrNone;
   677         status = KErrNone;
   915 #endif
   678 #endif
   916         User::LeaveIfError(status);
   679         User::LeaveIfError(status);
   917         TInt currentItem = 0;
   680         TInt currentItem = 0;
   918 
   681 
   919 #if defined(_DEBUG)
   682 				RDEBUG("lockInfo.iSetting", lockInfo.iSetting);
   920         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() GetLockInfo"));
       
   921 #endif
       
   922 
       
   923         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   683         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   924             {
   684             {
   925 #if defined(_DEBUG)
       
   926             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() lockInfo: ELockSetDisabled"));
       
   927 #endif
       
   928             currentItem = 1; // off
   685             currentItem = 1; // off
   929             }
   686             }
   930 
   687 
   931         if (currentItem == 0) // switch the flag
   688         if (currentItem == 0) // switch the flag
   932             {
   689             {
   933 #if defined(_DEBUG)
       
   934             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetDisabled"));
       
   935 #endif
       
   936             lockChangeSetting = RMobilePhone::ELockSetDisabled;
   690             lockChangeSetting = RMobilePhone::ELockSetDisabled;
   937             }
   691             }
   938         else
   692         else
   939             {
   693             {
   940 #if defined(_DEBUG)
       
   941             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeUPinRequestL() currentItem: ELockSetEnabled"));
       
   942 #endif
       
   943             lockChangeSetting = RMobilePhone::ELockSetEnabled;
   694             lockChangeSetting = RMobilePhone::ELockSetEnabled;
   944             }
   695             }
   945 
   696 				RDEBUG("lockChangeSetting", lockChangeSetting);
   946         // Raise a flag to indicate that the UPIN
   697         // Raise a flag to indicate that the UPIN
   947         // request coming from ETEL has originated from SecUi and not from Engine.
   698         // request coming from ETEL has originated from SecUi and not from Engine.
   948         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   699         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   949                 ESecurityUIsSecUIOriginated);
   700                 ESecurityUIsSecUIOriginated);
   950         // Change the lock setting
   701         // Change the lock setting
   956         RDEBUG("WaitForRequestL", 0);
   707         RDEBUG("WaitForRequestL", 0);
   957         status = iWait->WaitForRequestL();
   708         status = iWait->WaitForRequestL();
   958         RDEBUG("WaitForRequestL status", status);
   709         RDEBUG("WaitForRequestL status", status);
   959         // Lower the flag                           
   710         // Lower the flag                           
   960         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   711         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   961                 ESecurityUIsETelAPIOriginated);
   712                 ESecurityUIsSecUIOriginatedUninitialized);
   962 #ifdef __WINS__
   713 #ifdef __WINS__
   963         if (status == KErrNotSupported || status == KErrTimedOut)
   714         if (status == KErrNotSupported || status == KErrTimedOut)
   964         status = KErrNone;
   715         status = KErrNone;
   965 #endif
   716 #endif
   966 
   717 
  1016 EXPORT_C TBool CSecuritySettings::SwitchPinCodesL()
   767 EXPORT_C TBool CSecuritySettings::SwitchPinCodesL()
  1017     {
   768     {
  1018     TBool wcdmaSupported(
   769     TBool wcdmaSupported(
  1019             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
   770             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
  1020     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
   771     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
       
   772 				RDEBUG("wcdmaSupported", wcdmaSupported);
       
   773 				RDEBUG("upinSupported", upinSupported);
  1021     if (wcdmaSupported || upinSupported)
   774     if (wcdmaSupported || upinSupported)
  1022         {
   775         {
  1023 #if defined(_DEBUG)
       
  1024         RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL()"));
       
  1025 #endif 
       
  1026 
       
  1027         // If we are in simless offline mode the PIN codes can't obviously be switched
   776         // If we are in simless offline mode the PIN codes can't obviously be switched
  1028         TInt simState;
   777         TInt simState;
  1029         TInt err(KErrGeneral);
   778         TInt err(KErrGeneral);
  1030         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
   779         err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  1031         User::LeaveIfError(err);
   780         User::LeaveIfError(err);
  1045 
   794 
  1046         iCustomPhone.GetActivePin(activeCode);
   795         iCustomPhone.GetActivePin(activeCode);
  1047 
   796 
  1048         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   797         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1049         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   798         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1050 #if defined(_DEBUG)
   799 				RDEBUG("EMobilePhoneGetLockInfo", EMobilePhoneGetLockInfo);
  1051         RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() GetLockInfo"));
       
  1052 #endif    
       
  1053         iWait->SetRequestType(EMobilePhoneGetLockInfo);
   800         iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1054 
   801 
  1055         if (activeCode == RMobilePhone::ESecurityUniversalPin)
   802         if (activeCode == RMobilePhone::ESecurityUniversalPin)
  1056             {
   803             {
  1057             lockType = RMobilePhone::ELockUniversalPin;
   804             lockType = RMobilePhone::ELockUniversalPin;
  1078 #endif
   825 #endif
  1079             User::LeaveIfError(res);
   826             User::LeaveIfError(res);
  1080             }
   827             }
  1081 
   828 
  1082         // code request must be ON to change active code.
   829         // code request must be ON to change active code.
       
   830 				RDEBUG("lockInfo.iSetting", lockInfo.iSetting);
  1083         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   831         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  1084             {
   832             {
  1085 #if defined(_DEBUG)
   833 
  1086             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON."));
       
  1087 #endif
       
  1088             if (activeCode != RMobilePhone::ESecurityUniversalPin)
   834             if (activeCode != RMobilePhone::ESecurityUniversalPin)
  1089                 {
   835                 {
  1090                 ShowResultNoteL(R_UPIN_NOT_ALLOWED,
   836                 ShowResultNoteL(R_UPIN_NOT_ALLOWED,
  1091                         CAknNoteDialog::EErrorTone);
   837                         CAknNoteDialog::EErrorTone);
  1092                 }
   838                 }
  1093             else
   839             else
  1094                 {
   840                 {
  1095                 ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
   841                 ShowResultNoteL(R_PIN_NOT_ALLOWED, CAknNoteDialog::EErrorTone);
  1096                 }
   842                 }
  1097 #if defined(_DEBUG)
       
  1098             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() CODE REQ NOT ON NOTE END."));
       
  1099 #endif 
       
  1100             return EFalse;
   843             return EFalse;
  1101             }
   844             }
  1102 
   845 
  1103         iCustomPhone.GetActivePin(activeCode);
   846         iCustomPhone.GetActivePin(activeCode);
  1104         TInt currentItem = 0;
   847         TInt currentItem = 0;
  1105 
   848 
  1106 #if defined(_DEBUG)
   849 				RDEBUG("activeCode", activeCode);
  1107         RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() GetLockInfo"));
       
  1108 #endif
       
  1109 
       
  1110         if (activeCode == RMobilePhone::ESecurityUniversalPin)
   850         if (activeCode == RMobilePhone::ESecurityUniversalPin)
  1111             {
   851             {
  1112 #if defined(_DEBUG)
       
  1113             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() active code: UPIN"));
       
  1114 #endif
       
  1115             currentItem = 1; // UPIN
   852             currentItem = 1; // UPIN
  1116             }
   853             }
  1117 
       
  1118         if (currentItem == 0) // switch the flag
   854         if (currentItem == 0) // switch the flag
  1119             {
   855             {
  1120 #if defined(_DEBUG)
       
  1121             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: UPIN"));
       
  1122 #endif
       
  1123             lockType = RMobilePhone::ELockUniversalPin;
   856             lockType = RMobilePhone::ELockUniversalPin;
  1124             }
   857             }
  1125         else
   858         else
  1126             {
   859             {
  1127 #if defined(_DEBUG)
       
  1128             RDebug::Print(_L("(SECUI)CSecuritySettings::SwitchPinCodesL() currentItem: PIN1"));
       
  1129 #endif
       
  1130             lockType = RMobilePhone::ELockICC;
   860             lockType = RMobilePhone::ELockICC;
  1131             }
   861             }
       
   862 				RDEBUG("lockType", lockType);
  1132 
   863 
  1133         // Raise a flag to indicate that the code
   864         // Raise a flag to indicate that the code
  1134         // request coming from ETEL has originated from SecUi and not from Engine.
   865         // request coming from ETEL has originated from SecUi and not from Engine.
  1135         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   866         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
  1136                 ESecurityUIsSecUIOriginated);
   867                 ESecurityUIsSecUIOriginated);
  1143         RDEBUG("WaitForRequestL", 0);
   874         RDEBUG("WaitForRequestL", 0);
  1144         TInt status = iWait->WaitForRequestL();
   875         TInt status = iWait->WaitForRequestL();
  1145         RDEBUG("WaitForRequestL status", status);
   876         RDEBUG("WaitForRequestL status", status);
  1146         // Lower the flag                            
   877         // Lower the flag                            
  1147         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
   878         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
  1148                 ESecurityUIsETelAPIOriginated);
   879                 ESecurityUIsSecUIOriginatedUninitialized);
  1149 #ifdef __WINS__
   880 #ifdef __WINS__
  1150         if (status == KErrNotSupported || status == KErrTimedOut)
   881         if (status == KErrNotSupported || status == KErrTimedOut)
  1151         status = KErrNone;
   882         status = KErrNone;
  1152 #endif
   883 #endif
  1153 
   884 
  1384     {
  1115     {
  1385     /*****************************************************
  1116     /*****************************************************
  1386      *    Series 60 Customer / ETel
  1117      *    Series 60 Customer / ETel
  1387      *    Series 60  ETel API
  1118      *    Series 60  ETel API
  1388      *****************************************************/
  1119      *****************************************************/
  1389 #if defined(_DEBUG)
  1120 		RDEBUG("0", 0);
  1390     RDebug::Print(_L("(SECUI)CSecuritySettings::SetFdnModeL()"));
       
  1391 #endif
       
  1392     RMmCustomAPI::TSecurityCodeType secCodeType =
  1121     RMmCustomAPI::TSecurityCodeType secCodeType =
  1393             RMmCustomAPI::ESecurityCodePin2;
  1122             RMmCustomAPI::ESecurityCodePin2;
  1394 
  1123 
  1395     TBool isBlocked = EFalse;
  1124     TBool isBlocked = EFalse;
  1396     TInt ret = iCustomPhone.IsBlocked(secCodeType, isBlocked);
  1125     TInt ret = iCustomPhone.IsBlocked(secCodeType, isBlocked);
  1452 #ifdef __WINS__
  1181 #ifdef __WINS__
  1453     if (status == KErrNotSupported)
  1182     if (status == KErrNotSupported)
  1454     status = KErrNone;
  1183     status = KErrNone;
  1455 #endif
  1184 #endif
  1456 
  1185 
  1457 #if defined(_DEBUG)
  1186 		RDEBUG("status", status);
  1458     RDebug::Print( _L("(SECUI)CSecuritySettings::SetFdnModeL(): RETURN CODE: %d"), status);
       
  1459 #endif
       
  1460     switch (status)
  1187     switch (status)
  1461         {
  1188         {
  1462         case KErrNone:
  1189         case KErrNone:
  1463             break;
  1190             break;
  1464         case KErrGsm0707IncorrectPassword:
  1191         case KErrGsm0707IncorrectPassword:
  1492     {
  1219     {
  1493     /*****************************************************
  1220     /*****************************************************
  1494      *    Series 60 Customer / ETel
  1221      *    Series 60 Customer / ETel
  1495      *    Series 60  ETel API
  1222      *    Series 60  ETel API
  1496      *****************************************************/
  1223      *****************************************************/
  1497 #if defined(_DEBUG)
  1224 		RDEBUG("0", 0);
  1498     RDebug::Print(_L("(SECUI)CSecuritySettings::GetFdnMode()"));
       
  1499 #endif
       
  1500     return iPhone.GetFdnStatus(aFdnMode);
  1225     return iPhone.GetFdnStatus(aFdnMode);
  1501     }
  1226     }
  1502 
  1227 
  1503 //
  1228 //
  1504 // ----------------------------------------------------------
  1229 // ----------------------------------------------------------
  1522 void CSecuritySettings::ShowResultNoteL(TInt aResourceID,
  1247 void CSecuritySettings::ShowResultNoteL(TInt aResourceID,
  1523         CAknNoteDialog::TTone aTone)
  1248         CAknNoteDialog::TTone aTone)
  1524     {
  1249     {
  1525     RDEBUG("aResourceID", aResourceID);
  1250     RDEBUG("aResourceID", aResourceID);
  1526 
  1251 
  1527     /*
       
  1528      CAknNoteDialog* noteDlg = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&noteDlg));
       
  1529      noteDlg->SetTimeout(CAknNoteDialog::ELongTimeout);
       
  1530      noteDlg->SetTone(aTone);
       
  1531      noteDlg->ExecuteLD(aResourceID);
       
  1532      */
       
  1533     CHbDeviceMessageBoxSymbian* messageBox =
  1252     CHbDeviceMessageBoxSymbian* messageBox =
  1534             CHbDeviceMessageBoxSymbian::NewL(
  1253             CHbDeviceMessageBoxSymbian::NewL(
  1535                     CHbDeviceMessageBoxSymbian::EWarning);
  1254                     CHbDeviceMessageBoxSymbian::EWarning);
  1536     CleanupStack::PushL(messageBox);
  1255     CleanupStack::PushL(messageBox);
  1537     _LIT(KText, "ShowResultNoteL: ");
  1256     _LIT(KText, "ShowResultNoteL: ");
  1651             break;
  1370             break;
  1652         case KErrArgument:
  1371         case KErrArgument:
  1653             titleTr.Append(_L("KErrArgument"));
  1372             titleTr.Append(_L("KErrArgument"));
  1654             title.Append(_L("Error Argument"));
  1373             title.Append(_L("Error Argument"));
  1655             break;
  1374             break;
       
  1375         case R_SIM_OFF:
       
  1376             titleTr.Append(_L("R_SIM_OFF"));
       
  1377             title.Append(_L("SIM OFF"));
       
  1378             break;
       
  1379         case R_SIM_ALLREADY_OFF:
       
  1380             titleTr.Append(_L("R_SIM_ALLREADY_OFF"));
       
  1381             title.Append(_L("SIM ALLREADY OFF"));
       
  1382             break;
       
  1383         case R_SIM_NOT_ALLOWED:
       
  1384             titleTr.Append(_L("R_SIM_NOT_ALLOWED"));
       
  1385             title.Append(_L("SIM NOT ALLOWED"));
       
  1386             break;
       
  1387         case R_REMOTELOCK_INVALID_CODE:
       
  1388             titleTr.Append(_L("R_REMOTELOCK_INVALID_CODE"));
       
  1389             title.Append(_L("REMOTELOCK INVALID CODE"));
       
  1390             break;
  1656 
  1391 
  1657         default: // " "
  1392         default: // " "
  1658             titleTr.Append(_L("Specific Error"));
  1393             titleTr.Append(_L("Specific Error"));
  1659             title.Append(_L("Specific Error"));
  1394             title.Append(_L("Specific Error"));
  1660             break;
  1395             break;
  1661         }
  1396         }
  1662     messageBox->SetTextL(title);
  1397     messageBox->SetTextL(title);
  1663     RDEBUG("aResourceID", aResourceID);
  1398     RDEBUG("aResourceID", aResourceID);
  1664     RDebug::Print(titleTr);
  1399     RDebug::Print(titleTr);
  1665 
  1400 
  1666     _LIT(KIconName, "qtg_small_smiley_wondering");
  1401     _LIT(KIconNameWondering, "qtg_small_smiley_wondering");
  1667     messageBox->SetIconNameL(KIconName);
  1402     _LIT(KIconNameSmile, "qtg_small_smiley_smile");
       
  1403     if(aResourceID==0 || aResourceID==R_CONFIRMATION_NOTE)
       
  1404     	messageBox->SetIconNameL(KIconNameSmile);
       
  1405     else
       
  1406     	messageBox->SetIconNameL(KIconNameWondering);
       
  1407 
  1668     if (aTone == CAknNoteDialog::EErrorTone) // another case is EConfirmationTone
  1408     if (aTone == CAknNoteDialog::EErrorTone) // another case is EConfirmationTone
  1669         {
  1409         {
  1670         messageBox->SetTimeout(messageBox->Timeout() * 2); // errors are displayed double time
  1410         messageBox->SetTimeout(messageBox->Timeout() * 2); // errors are displayed double time
  1671         }
  1411         }
  1672 
  1412 
  1686     {
  1426     {
  1687     TBool wcdmaSupported(
  1427     TBool wcdmaSupported(
  1688             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
  1428             FeatureManager::FeatureSupported( KFeatureIdProtocolWcdma));
  1689     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
  1429     TBool upinSupported(FeatureManager::FeatureSupported( KFeatureIdUpin));
  1690     TBool isSupported = EFalse;
  1430     TBool isSupported = EFalse;
       
  1431 		RDEBUG("wcdmaSupported", wcdmaSupported);
       
  1432 		RDEBUG("upinSupported", upinSupported);
  1691     if (wcdmaSupported || upinSupported)
  1433     if (wcdmaSupported || upinSupported)
  1692         {
  1434         {
  1693 #if defined(_DEBUG)
       
  1694         RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported() BEGIN"));
       
  1695 #endif
       
  1696 
       
  1697         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1435         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  1698 
  1436 
  1699         //get lock info
  1437         //get lock info
  1700         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1438         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  1701         iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1439         iWait->SetRequestType(EMobilePhoneGetLockInfo);
  1705         RDEBUG("WaitForRequestL", 0);
  1443         RDEBUG("WaitForRequestL", 0);
  1706         TInt res = iWait->WaitForRequestL();
  1444         TInt res = iWait->WaitForRequestL();
  1707         RDEBUG("WaitForRequestL res", res);
  1445         RDEBUG("WaitForRequestL res", res);
  1708         if ((res == KErrNotSupported) || (res == KErrGsmInvalidParameter))
  1446         if ((res == KErrNotSupported) || (res == KErrGsmInvalidParameter))
  1709             {
  1447             {
  1710 #if defined(_DEBUG)
  1448             RDEBUG("0", 0);
  1711             RDebug::Print(_L("(SECUI)CSecuritySettings::IsUpinSupported(): NOT SUPPORTED"));
       
  1712 #endif
       
  1713             isSupported = EFalse;
  1449             isSupported = EFalse;
  1714             }
  1450             }
  1715         else
  1451         else
  1716             {
  1452             {
  1717             RDEBUG("0", 0);
  1453             RDEBUG("1", 1);
  1718 
       
  1719             isSupported = ETrue;
  1454             isSupported = ETrue;
  1720             }
  1455             }
  1721         }
  1456         }
  1722     else
  1457     else
  1723         isSupported = EFalse;
  1458         isSupported = EFalse;
  1803     TInt err(KErrGeneral);
  1538     TInt err(KErrGeneral);
  1804     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  1539     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  1805     User::LeaveIfError(err);
  1540     User::LeaveIfError(err);
  1806     TBool simRemoved(simState == ESimNotPresent);
  1541     TBool simRemoved(simState == ESimNotPresent);
  1807 
  1542 
       
  1543 		RDEBUG("simRemoved", simRemoved);
  1808     if (simRemoved)
  1544     if (simRemoved)
  1809         {
  1545         {
  1810         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  1546         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  1811         return KErrAccessDenied;
  1547         return KErrAccessDenied;
  1812         }
  1548         }
  1813 #if defined(_DEBUG)
       
  1814     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinParamsL()"));
       
  1815 #endif    
       
  1816     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  1549     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  1817     secCodeType = RMobilePhone::ESecurityCodePin1;
  1550     secCodeType = RMobilePhone::ESecurityCodePin1;
  1818 
  1551 
  1819     RMobilePhone::TMobilePassword oldPassword;
  1552     RMobilePhone::TMobilePassword oldPassword;
  1820     RMobilePhone::TMobilePassword newPassword;
  1553     RMobilePhone::TMobilePassword newPassword;
  1916         res = KErrNone;
  1649         res = KErrNone;
  1917 #endif
  1650 #endif
  1918         if (res != KErrNone)
  1651         if (res != KErrNone)
  1919             {
  1652             {
  1920             ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
  1653             ShowResultNoteL(res, CAknNoteDialog::EErrorTone);
  1921             return res; // TODO not sure if it's wise to exit now.
  1654             return res; // not sure if it's wise to exit now.
  1922             }
  1655             }
  1923 
  1656 
  1924         newPassword = _L("");
  1657         newPassword = _L("");
  1925         }
  1658         }
  1926     else
  1659     else
  2308 #endif
  2041 #endif
  2309     User::LeaveIfError(ret);
  2042     User::LeaveIfError(ret);
  2310 
  2043 
  2311     RDEBUG("codeInfo.iRemainingEntryAttempts",
  2044     RDEBUG("codeInfo.iRemainingEntryAttempts",
  2312             codeInfo.iRemainingEntryAttempts);
  2045             codeInfo.iRemainingEntryAttempts);
  2313     if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts) // TODO this might be 10
  2046     if (codeInfo.iRemainingEntryAttempts == KMaxNumberOfPINAttempts)
  2314         codeInfo.iRemainingEntryAttempts = -1;
  2047         codeInfo.iRemainingEntryAttempts = -1;
  2315 
  2048 
  2316     /* request PIN using QT */
  2049     /* request PIN using QT */
  2317     queryAccepted = KErrCancel;
  2050     queryAccepted = KErrCancel;
  2318     CSecQueryUi *iSecQueryUi;
  2051     CSecQueryUi *iSecQueryUi;
  2424     RDEBUG("aShowError", aShowError);
  2157     RDEBUG("aShowError", aShowError);
  2425     /*****************************************************
  2158     /*****************************************************
  2426      *    Series 60 Customer / ETel
  2159      *    Series 60 Customer / ETel
  2427      *    Series 60  ETel API
  2160      *    Series 60  ETel API
  2428      *****************************************************/
  2161      *****************************************************/
  2429 #if defined(_DEBUG)
       
  2430     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeSecCodeParamsL()"));
       
  2431 #endif
       
  2432     TInt res = KErrNone;
  2162     TInt res = KErrNone;
  2433     TInt queryAccepted = KErrCancel;
  2163     TInt queryAccepted = KErrCancel;
  2434     RMobilePhone::TMobilePassword newPassword;
  2164     RMobilePhone::TMobilePassword newPassword;
  2435 
  2165 
  2436     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  2166     RMobilePhone::TMobilePhoneSecurityCode secCodeType;
  2534             {
  2264             {
  2535             RMobilePhone::TMobilePhoneLock lockType =
  2265             RMobilePhone::TMobilePhoneLock lockType =
  2536                     RMobilePhone::ELockPhoneDevice;
  2266                     RMobilePhone::ELockPhoneDevice;
  2537             RMobilePhone::TMobilePhoneLockSetting lockChangeSetting =
  2267             RMobilePhone::TMobilePhoneLockSetting lockChangeSetting =
  2538                     RMobilePhone::ELockSetEnabled;
  2268                     RMobilePhone::ELockSetEnabled;
  2539             if (oldPassword.Length() == 6)
       
  2540                 {
       
  2541                 lockChangeSetting = RMobilePhone::ELockSetDisabled;
       
  2542                 RDEBUG("RMobilePhone::ELockSetDisabled",
       
  2543                         RMobilePhone::ELockSetDisabled);
       
  2544                 }
       
  2545             iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2269             iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2546             RDEBUG("SetLockSetting", 0);
  2270             RDEBUG("SetLockSetting", 0);
  2547             iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting);
  2271             iPhone.SetLockSetting(iWait->iStatus, lockType, lockChangeSetting);
  2548             RDEBUG("WaitForRequestL", 0);
  2272             RDEBUG("WaitForRequestL", 0);
  2549             res = iWait->WaitForRequestL();
  2273             res = iWait->WaitForRequestL();
  2571                 TSCPSecCode oldPassword;
  2295                 TSCPSecCode oldPassword;
  2572                 newCode.Copy(newPassword);
  2296                 newCode.Copy(newPassword);
  2573                 if (scpClient.Connect() == KErrNone)
  2297                 if (scpClient.Connect() == KErrNone)
  2574                     {
  2298                     {
  2575                     RDEBUG("scpClient.StoreCode", 0);
  2299                     RDEBUG("scpClient.StoreCode", 0);
  2576                     /*
  2300                      // this is the old method. Obsolete now
  2577                      // scpClient.StoreCode( newCode );
  2301                      // scpClient.StoreCode( newCode );
  2578                      RArray<TDevicelockPolicies> aFailedPolicies;
  2302                      RArray<TDevicelockPolicies> aFailedPolicies;
  2579                      TDevicelockPolicies failedPolicy;
  2303                      TDevicelockPolicies failedPolicy;
  2580                      TInt retLockcode = KErrNone;
  2304                      TInt retLockcode = KErrNone;
  2581                      retLockcode = scpClient.StoreLockcode( newCode, oldPassword, aFailedPolicies );
  2305                      retLockcode = scpClient.StoreLockcode( newCode, oldPassword, aFailedPolicies );
  2582                      RDEBUG( "retLockcode", retLockcode );
  2306                      RDEBUG( "retLockcode", retLockcode );
  2583                      RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2307                      RDEBUG( "aFailedPolicies.Count()", aFailedPolicies.Count() );
  2584                      for(TInt i=0; i<aFailedPolicies.Count(); i++)
  2308                      for(TInt i=0; i<aFailedPolicies.Count(); i++)
  2585                      {
  2309 	                     {
  2586                      failedPolicy = aFailedPolicies[i];
  2310 	                     failedPolicy = aFailedPolicies[i];
  2587                      RDEBUG( "failedPolicy", failedPolicy );
  2311 	                     RDEBUG( "failedPolicy", failedPolicy );
  2588                      }
  2312 	                     }
  2589                      */
       
  2590                     scpClient.Close();
  2313                     scpClient.Close();
  2591                     }
  2314                     }
  2592                 }
  2315                 }
  2593             break;
  2316             break;
  2594             }
  2317             }
  2624     return res;
  2347     return res;
  2625     }
  2348     }
  2626 
  2349 
  2627 /**************************************/
  2350 /**************************************/
  2628 // qtdone
  2351 // qtdone
       
  2352 // the params are changed in the settings,. This only asks for password.
  2629 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod,
  2353 EXPORT_C TInt CSecuritySettings::ChangeAutoLockPeriodParamsL(TInt aPeriod,
  2630         RMobilePhone::TMobilePassword aOldPassword, TInt aFlags,
  2354         RMobilePhone::TMobilePassword aOldPassword, TInt aFlags,
  2631         TDes& aCaption, TInt aShowError)
  2355         TDes& aCaption, TInt aShowError)
  2632     {
  2356     {
  2633     RDEBUG("aPeriod", aPeriod);
  2357     RDEBUG("aPeriod", aPeriod);
  2659                 {
  2383                 {
  2660                 TLex lex(maxPeriodBuf);
  2384                 TLex lex(maxPeriodBuf);
  2661                 if ((lex.Val(maxPeriod) == KErrNone) && (maxPeriod > 0))
  2385                 if ((lex.Val(maxPeriod) == KErrNone) && (maxPeriod > 0))
  2662                     {
  2386                     {
  2663                     RDEBUG("from SCP maxPeriod", maxPeriod);
  2387                     RDEBUG("from SCP maxPeriod", maxPeriod);
  2664                     // nothing to do
       
  2665                     }
  2388                     }
  2666                 else
  2389                 else
  2667                     {
  2390                     {
  2668                     maxPeriod = 0;
  2391                     maxPeriod = 0;
  2669                     RDEBUG("not from SCP maxPeriod", maxPeriod);
  2392                     RDEBUG("not from SCP maxPeriod", maxPeriod);
  2685         {
  2408         {
  2686         TBool allow = ETrue;
  2409         TBool allow = ETrue;
  2687 
  2410 
  2688         if ((aPeriod == 0) && (maxPeriod > 0))
  2411         if ((aPeriod == 0) && (maxPeriod > 0))
  2689             {
  2412             {
  2690 #if defined(_DEBUG)
  2413             	RDEBUG("The period is not allowed by TARM", aPeriod);
  2691             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() \
  2414             	RDEBUG( "maxPeriod", maxPeriod );
  2692         The period: %d is not allowed by TARM; max: %d"),aPeriod, maxPeriod );
       
  2693 #endif                
       
  2694             allow = EFalse;
  2415             allow = EFalse;
  2695             ShowResultNoteL(R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE,
  2416             ShowResultNoteL(R_SECUI_TEXT_AUTOLOCK_MUST_BE_ACTIVE,
  2696                     CAknNoteDialog::EErrorTone);
  2417                     CAknNoteDialog::EErrorTone);
  2697             }
  2418             }
  2698         if (!allow)
  2419         if (!allow)
  2702             }
  2423             }
  2703         }
  2424         }
  2704 
  2425 
  2705     if (aPeriod == 0)
  2426     if (aPeriod == 0)
  2706         {
  2427         {
  2707 #ifdef RD_REMOTELOCK
       
  2708 
       
  2709         // If remote lock is enabled, don't disable the domestic OS device lock
  2428         // If remote lock is enabled, don't disable the domestic OS device lock
  2710         // since that would render the RemoteLock useless.
  2429         // since that would render the RemoteLock useless.
  2711         // Instead just re-set the DOS lock to enabled which as a side effect
  2430         // Instead just re-set the DOS lock to enabled which as a side effect
  2712         // requests the security code from the user.
  2431         // requests the security code from the user.
  2713 
  2432 
  2736             }
  2455             }
  2737 
  2456 
  2738         delete remoteLockSettings;
  2457         delete remoteLockSettings;
  2739         remoteLockSettings = NULL;
  2458         remoteLockSettings = NULL;
  2740 
  2459 
  2741 #else // not defined RD_REMOTELOCK
       
  2742         lockChange = RMobilePhone::ELockSetDisabled;
       
  2743 
       
  2744 #endif // RD_REMOTELOCK
       
  2745         }
  2460         }
  2746     else
  2461     else
  2747         {
  2462         {
  2748         lockChange = RMobilePhone::ELockSetEnabled;
  2463         lockChange = RMobilePhone::ELockSetEnabled;
  2749         RDEBUG("aPeriod != 0 lockChange", lockChange);
  2464         RDEBUG("aPeriod != 0 lockChange", lockChange);
  2750         }
  2465         }
  2751 
  2466 
  2752     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2467     iWait->SetRequestType(EMobilePhoneSetLockSetting);
       
  2468     RDEBUG("lockChange", lockChange);
  2753     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel,
  2469     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel,
  2754             ESecurityUIsQueryRequestOk);
  2470             ESecurityUIsQueryRequestOk);
  2755     RDEBUG("SetLockSetting", 0);
  2471     RDEBUG("SetLockSetting", 0);
  2756     iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // this eventually calls PassPhraseRequiredL
  2472     iPhone.SetLockSetting(iWait->iStatus, lockType, lockChange); // this eventually calls PassPhraseRequiredL
  2757     RDEBUG("WaitForRequestL", 0);
  2473     RDEBUG("WaitForRequestL", 0);
  2763     status = KErrNone;
  2479     status = KErrNone;
  2764 #endif
  2480 #endif
  2765     switch (status)
  2481     switch (status)
  2766         {
  2482         {
  2767         case KErrNone:
  2483         case KErrNone:
  2768 #if defined(_DEBUG)
       
  2769             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() KErrNone"));
       
  2770 #endif
       
  2771             break;
  2484             break;
  2772         case KErrGsmSSPasswordAttemptsViolation:
  2485         case KErrGsmSSPasswordAttemptsViolation:
  2773         case KErrLocked:
  2486         case KErrLocked:
  2774 #if defined(_DEBUG)
  2487         		RDEBUG("KErrLocked", KErrLocked);
  2775             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() PasswordAttemptsViolation"));
       
  2776 #endif
       
  2777             ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2488             ShowResultNoteL(KErrLocked, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2778             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2489             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2779                     aFlags, aCaption, aShowError); // ask again
  2490                     aFlags, aCaption, aShowError); // ask again
  2780         case KErrGsm0707IncorrectPassword:
  2491         case KErrGsm0707IncorrectPassword:
  2781         case KErrAccessDenied:
  2492         case KErrAccessDenied:
  2782 #if defined(_DEBUG)
  2493         		RDEBUG("KErrAccessDenied", KErrAccessDenied);
  2783             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() IncorrectPassword"));
       
  2784 #endif
       
  2785             // code was entered erroneously
  2494             // code was entered erroneously
  2786             ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2495             ShowResultNoteL(KErrAccessDenied, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2787             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2496             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2788                     aFlags, aCaption, aShowError); // ask again
  2497                     aFlags, aCaption, aShowError); // ask again
  2789         case KErrAbort:
  2498         case KErrAbort:
  2790             // User pressed "cancel" in the code query dialog.
  2499             // User pressed "cancel" in the code query dialog.
  2791             return oldPeriod;
  2500             return oldPeriod;
  2792         default:
  2501         default:
  2793 #if defined(_DEBUG)
  2502         		RDEBUG("default", status);
  2794             RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() default"));
       
  2795 #endif
       
  2796             ShowResultNoteL(status, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2503             ShowResultNoteL(status, CAknNoteDialog::EErrorTone); // the old code didn't show messages
  2797             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2504             return ChangeAutoLockPeriodParamsL(oldPeriod, aOldPassword,
  2798                     aFlags, aCaption, aShowError); // ask again
  2505                     aFlags, aCaption, aShowError); // ask again
  2799         }
  2506         }
  2800 #if defined(_DEBUG)
  2507  		RDEBUG("aPeriod", aPeriod);
  2801     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangeAutoLockPeriodL() END"));
       
  2802 #endif
       
  2803     return aPeriod;
  2508     return aPeriod;
  2804     }
  2509     }
  2805 /*****************************/
  2510 /*****************************/
  2806 // qtdone
  2511 // qtdone
  2807 EXPORT_C TInt CSecuritySettings::ChangePinRequestParamsL(TInt aEnable,
  2512 EXPORT_C TInt CSecuritySettings::ChangePinRequestParamsL(TInt aEnable,
  2808         RMobilePhone::TMobilePassword aOldPassword, TInt aFlags,
  2513         RMobilePhone::TMobilePassword aOldPassword, TInt aFlags,
  2809         TDes& aCaption, TInt aShowError)
  2514         TDes& aCaption, TInt aShowError)
  2810     {
  2515     {
  2811     RDEBUG("aEnable", aEnable);
  2516     RDEBUG("aEnable", aEnable);
  2812     RDEBUG("aFlags", aFlags);
  2517     RDEBUG("aFlags", aFlags);
  2813     /*****************************************************
       
  2814      *    Series 60 Customer / ETel
       
  2815      *    Series 60  ETel API
       
  2816      *****************************************************/
       
  2817 #if defined(_DEBUG)
       
  2818     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL()"));
       
  2819 #endif      
       
  2820     TInt simState = 0;
  2518     TInt simState = 0;
  2821     TInt lEnable = aEnable;
  2519     TInt lEnable = aEnable;
  2822     TInt err(KErrGeneral);
  2520     TInt err(KErrGeneral);
  2823     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  2521     err = RProperty::Get(KPSUidStartup, KPSSimStatus, simState);
  2824     User::LeaveIfError(err);
  2522     User::LeaveIfError(err);
  2825     TBool simRemoved(simState == ESimNotPresent);
  2523     TBool simRemoved(simState == ESimNotPresent);
  2826 
  2524 
  2827     if (simRemoved)
  2525     if (simRemoved)
  2828         {
  2526         {
  2829         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  2527         ShowResultNoteL(R_INSERT_SIM, CAknNoteDialog::EErrorTone);
  2830         return EFalse;
  2528         return KErrAccessDenied;
  2831         }
  2529         }
  2832 
  2530 
  2833     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2531     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
  2834     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2532     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
  2835     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
  2533     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockICC;
  2849         status = KErrNone;
  2547         status = KErrNone;
  2850         }
  2548         }
  2851 #endif
  2549 #endif
  2852     User::LeaveIfError(status);
  2550     User::LeaveIfError(status);
  2853 
  2551 
  2854 #if defined(_DEBUG)
       
  2855     RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() GetLockInfo"));
       
  2856 #endif
       
  2857 
       
  2858     if (aOldPassword.Length() == 0) // only if input parameters are empty
  2552     if (aOldPassword.Length() == 0) // only if input parameters are empty
  2859         {
  2553         {
  2860         // switch the value.
  2554         // switch the value.
  2861         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  2555         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
  2862             lEnable = 1; // on
  2556             lEnable = 1; // on
  2863         else
  2557         else
  2864             lEnable = 0; // off
  2558             lEnable = 0; // off
  2865         }
  2559         }
  2866 
  2560 
       
  2561 		RDEBUG("lEnable", lEnable);
  2867     if (lEnable == 0)
  2562     if (lEnable == 0)
  2868         {
  2563         {
  2869 #if defined(_DEBUG)
       
  2870         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() currentItem: ELockSetDisabled"));
       
  2871 #endif
       
  2872         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2564         lockChangeSetting = RMobilePhone::ELockSetDisabled;
  2873         }
  2565         }
  2874     else
  2566     else
  2875         {
  2567         {
  2876 #if defined(_DEBUG)
       
  2877         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL() currentItem: ELockSetEnabled"));
       
  2878 #endif
       
  2879         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  2568         lockChangeSetting = RMobilePhone::ELockSetEnabled;
  2880         }
  2569         }
  2881 
  2570 
       
  2571 		RDEBUG("lockChangeSetting", lockChangeSetting);
  2882     // Raise a flag to indicate that the PIN
  2572     // Raise a flag to indicate that the PIN
  2883     // request coming from ETEL has originated from SecUi and not from Engine.
  2573     // request coming from ETEL has originated from SecUi and not from Engine.
  2884     TInt tRet = RProperty::Set(KPSUidSecurityUIs,
  2574     TInt tRet = RProperty::Set(KPSUidSecurityUIs,
  2885             KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
  2575             KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSecUIOriginated);
  2886     if (tRet != KErrNone)
  2576 		RDEBUG("tRet", tRet);
  2887         {
       
  2888 #if defined(_DEBUG)
       
  2889         RDebug::Print(_L("(SECUI)CSecuritySettings::ChangePinRequestParamsL():\
       
  2890             FAILED to set the SECUI query Flag: %d"), tRet);
       
  2891 #endif
       
  2892         }
       
  2893 
  2577 
  2894     // Change the lock setting
  2578     // Change the lock setting
  2895     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2579     iWait->SetRequestType(EMobilePhoneSetLockSetting);
  2896     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel,
  2580     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsQueryRequestCancel,
  2897             ESecurityUIsQueryRequestOk);
  2581             ESecurityUIsQueryRequestOk);
  2905     status = KErrNone;
  2589     status = KErrNone;
  2906 #endif
  2590 #endif
  2907 
  2591 
  2908     // Lower the flag                             
  2592     // Lower the flag                             
  2909     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
  2593     RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery,
  2910             ESecurityUIsETelAPIOriginated);
  2594             ESecurityUIsSecUIOriginatedUninitialized);
  2911 
  2595 
  2912     switch (status)
  2596     switch (status)
  2913         {
  2597         {
  2914         case KErrNone:
  2598         case KErrNone:
  2915             {
  2599             {
  2918         case KErrGsm0707OperationNotAllowed:
  2602         case KErrGsm0707OperationNotAllowed:
  2919             {
  2603             {
  2920             // not allowed with this sim
  2604             // not allowed with this sim
  2921             ShowResultNoteL(R_OPERATION_NOT_ALLOWED,
  2605             ShowResultNoteL(R_OPERATION_NOT_ALLOWED,
  2922                     CAknNoteDialog::EErrorTone);
  2606                     CAknNoteDialog::EErrorTone);
  2923             return EFalse;
  2607             return KErrGsm0707OperationNotAllowed;
  2924             }
  2608             }
  2925         case KErrGsm0707IncorrectPassword:
  2609         case KErrGsm0707IncorrectPassword:
  2926         case KErrAccessDenied:
  2610         case KErrAccessDenied:
  2927             {
  2611             {
  2928             // code was entered erroneously
  2612             // code was entered erroneously
  2930                     aCaption, aShowError);
  2614                     aCaption, aShowError);
  2931             }
  2615             }
  2932         case KErrGsmSSPasswordAttemptsViolation:
  2616         case KErrGsmSSPasswordAttemptsViolation:
  2933         case KErrLocked:
  2617         case KErrLocked:
  2934             {
  2618             {
  2935             return ETrue;
  2619             return KErrLocked;
  2936             }
  2620             }
  2937         case KErrAbort:
  2621         case KErrAbort:
  2938             {
  2622             {
  2939             return EFalse;
  2623             return KErrAbort;
  2940             }
  2624             }
  2941         default:
  2625         default:
  2942             {
  2626             {
  2943             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags,
  2627             return ChangePinRequestParamsL(aEnable, aOldPassword, aFlags,
  2944                     aCaption, aShowError);
  2628                     aCaption, aShowError);
  2945             }
  2629             }
  2946         }
  2630         }
  2947     return ETrue;
  2631     return KErrNone;
  2948     }
  2632     }
  2949 
  2633 
  2950 //
  2634 //
  2951 // ----------------------------------------------------------
  2635 // ----------------------------------------------------------
  2952 // CSecuritySettings::AskSecCodeParamsL()
  2636 // CSecuritySettings::AskSecCodeParamsL()