securitydialogs/SecUi/Src/SecUiManualSecuritySettings.cpp
branchRCL_3
changeset 50 03674e5abf46
parent 49 09b1ac925e3f
child 67 79bd6bd83ec3
equal deleted inserted replaced
49:09b1ac925e3f 50:03674e5abf46
    16 *
    16 *
    17 */
    17 */
    18 
    18 
    19 
    19 
    20 #include <rmmcustomapi.h>
    20 #include <rmmcustomapi.h>
    21 #include "SecQueryUi.h"
    21 #include <SecUi.rsg>
    22 #include "secuimanualsecuritysettings.h"
    22 #include "secuimanualsecuritysettings.h"
    23 #include "secuisecuritysettings.h"
       
    24 #include <exterror.h>
    23 #include <exterror.h>
    25 #include "SecUi.h"
       
    26 #include "SecUiWait.h"
    24 #include "SecUiWait.h"
    27 #include <mmtsy_names.h>
    25 #include <mmtsy_names.h>
    28     /*****************************************************
    26     /*****************************************************
    29     *    Series 60 Customer / TSY
    27     *    Series 60 Customer / TSY
    30     *    Needs customer TSY implementation
    28     *    Needs customer TSY implementation
   107     if ( err != KErrAlreadyExists )
   105     if ( err != KErrAlreadyExists )
   108         {
   106         {
   109         // May also return KErrAlreadyExists if something else
   107         // May also return KErrAlreadyExists if something else
   110         // has already loaded the TSY module. And that is
   108         // has already loaded the TSY module. And that is
   111         // not an error.
   109         // not an error.
   112         RDEBUG("err", err);
       
   113         User::LeaveIfError( err );
   110         User::LeaveIfError( err );
   114         }
   111         }
   115 
   112 
   116     // open phones
   113     // open phones
   117     User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended));
   114     User::LeaveIfError(iServer.SetExtendedErrorGranularity(RTelServer::EErrorExtended));
   133     *****************************************************/
   130     *****************************************************/
   134     /*****************************************************
   131     /*****************************************************
   135     *    Series 60 Customer / TSY
   132     *    Series 60 Customer / TSY
   136     *    Needs customer TSY implementation
   133     *    Needs customer TSY implementation
   137     *****************************************************/
   134     *****************************************************/
   138 		RDEBUG("0", 0);
   135 	#if defined(_DEBUG)
       
   136 	RDebug::Print(_L("(SECUI)CManualSecuritySettings::~CManualSecuritySettings()"));
       
   137 	#endif
   139     // Cancel active requests
   138     // Cancel active requests
   140     if(iWait->IsActive())
   139     if(iWait->IsActive())
   141     {
   140     {
   142       RDEBUG("CancelAsyncRequest", 0);
   141         #if defined(_DEBUG)
       
   142 	    RDebug::Print(_L("(SECUI)CManualSecuritySettings::~CManualSecuritySettings() CANCEL REQ"));
       
   143 	    #endif
   143         iPhone.CancelAsyncRequest(iWait->GetRequestType());
   144         iPhone.CancelAsyncRequest(iWait->GetRequestType());
   144     }
   145     }
   145     // close phone
   146     // close phone
   146     if (iPhone.SubSessionHandle())
   147     if (iPhone.SubSessionHandle())
   147         iPhone.Close();
   148         iPhone.Close();
   154         iServer.UnloadPhoneModule(KMmTsyModuleName);
   155         iServer.UnloadPhoneModule(KMmTsyModuleName);
   155         iServer.Close();
   156         iServer.Close();
   156         }
   157         }
   157     delete iNote;
   158     delete iNote;
   158     delete iWait;
   159     delete iWait;
   159 	RDEBUG("0", 0);
   160 	#if defined(_DEBUG)
       
   161 	RDebug::Print(_L("(SECUI)CManualSecuritySettings::~CManualSecuritySettings() END"));
       
   162 	#endif  
   160     }
   163     }
   161 
   164 
   162 //
   165 //
   163 // ----------------------------------------------------------
   166 // ----------------------------------------------------------
   164 // CManualSecuritySettings::ChangePinL()
   167 // CManualSecuritySettings::ChangePinL()
   169     {    
   172     {    
   170     /*****************************************************
   173     /*****************************************************
   171     *    Series 60 Customer / ETel
   174     *    Series 60 Customer / ETel
   172     *    Series 60  ETel API
   175     *    Series 60  ETel API
   173     *****************************************************/
   176     *****************************************************/
   174     RDEBUG("aPin", aPin);
   177     #if defined(_DEBUG)
       
   178     RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL()"));
       
   179     #endif        
   175     if (aPin == EPin1)
   180     if (aPin == EPin1)
   176         {
   181         {
   177 				RDEBUG("EPin1", EPin1);
   182 		#if defined(_DEBUG)
       
   183 		RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL() PIN1"));
       
   184 		#endif        
   178         RMobilePhone::TMobilePhoneLock lockType;
   185         RMobilePhone::TMobilePhoneLock lockType;
   179         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   186         RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
   180         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   187         RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
   181 
   188 
   182 
   189 
   183         lockType = RMobilePhone::ELockICC;
   190         lockType = RMobilePhone::ELockICC;
   184         // check if pin code is enabled...
   191         // check if pin code is enabled...
   185         // The following is required, since the new multimode Etel is asynchronous
   192         // The following is required, since the new multimode Etel is asynchronous
   186         // rather than synchronous.
   193         // rather than synchronous.
   187     
   194     
   188 				RDEBUG("SetRequestType", EMobilePhoneGetLockInfo);
   195 		#if defined(_DEBUG)
       
   196 		RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL() GetLockInfo"));
       
   197 		#endif
       
   198 
   189         iWait->SetRequestType(EMobilePhoneGetLockInfo);
   199         iWait->SetRequestType(EMobilePhoneGetLockInfo);
   190         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   200         iPhone.GetLockInfo(iWait->iStatus, lockType, lockInfoPkg);
   191         RDEBUG("WaitForRequestL", 0);
       
   192         TInt res = iWait->WaitForRequestL();
   201         TInt res = iWait->WaitForRequestL();
   193         RDEBUG("WaitForRequestL res", res);
       
   194          
   202          
   195         if (res != KErrNone)
   203         if (res != KErrNone)
   196             return EFalse;
   204             return EFalse;
   197         // if pin is disabled -> pin code change is not allowed
   205         // if pin is disabled -> pin code change is not allowed
   198         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   206         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
   200             ShowResultNoteL(CAknNoteDialog::EErrorTone,R_PIN_NOT_ALLOWED);
   208             ShowResultNoteL(CAknNoteDialog::EErrorTone,R_PIN_NOT_ALLOWED);
   201             return EFalse;
   209             return EFalse;
   202             }
   210             }
   203         }
   211         }
   204     
   212     
   205 		RDEBUG("CompareF", 0);
   213 	#if defined(_DEBUG)
       
   214 	RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL() CompareF"));
       
   215 	#endif
   206     if (aNew.CompareF(aVerifyNew) != 0)     
   216     if (aNew.CompareF(aVerifyNew) != 0)     
   207         {
   217         {
   208         // codes do not match note 
   218         // codes do not match note 
   209         ShowResultNoteL(CAknNoteDialog::EErrorTone,R_CODES_DONT_MATCH);
   219         ShowResultNoteL(CAknNoteDialog::EErrorTone,R_CODES_DONT_MATCH);
   210         return EFalse;
   220         return EFalse;
   223 
   233 
   224     RMobilePhone::TMobilePhonePasswordChangeV1 aChange;
   234     RMobilePhone::TMobilePhonePasswordChangeV1 aChange;
   225     aChange.iOldPassword = aOld;
   235     aChange.iOldPassword = aOld;
   226     aChange.iNewPassword = aNew;
   236     aChange.iNewPassword = aNew;
   227 
   237 
   228 		RDEBUG("EMobilePhoneChangeSecurityCode", EMobilePhoneChangeSecurityCode);
   238 	#if defined(_DEBUG)
       
   239 	RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL() ChangeSecurityCode"));
       
   240 	#endif
   229     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
   241     iWait->SetRequestType(EMobilePhoneChangeSecurityCode);
   230     iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,aChange);
   242     iPhone.ChangeSecurityCode(iWait->iStatus,secCodeType,aChange);
   231     RDEBUG("WaitForRequestL", 0);
       
   232     TInt res = iWait->WaitForRequestL();
   243     TInt res = iWait->WaitForRequestL();
   233     RDEBUG("WaitForRequestL res", res);
   244     
   234     
   245 	#if defined(_DEBUG)
       
   246 	RDebug::Print(_L("(SECUI)CManualSecuritySettings::ChangePinL() ChangeSecurityCode RES: %d"), res);
       
   247 	#endif
       
   248 
   235     switch(res)
   249     switch(res)
   236         {        
   250         {        
   237         case KErrNone:
   251         case KErrNone:
   238             if (aPin == EPin1)
   252             if (aPin == EPin1)
   239                 {
   253                 {
   251                 ShowResultNoteL(CAknNoteDialog::EErrorTone,R_PIN_BLOCKED_NOTE);
   265                 ShowResultNoteL(CAknNoteDialog::EErrorTone,R_PIN_BLOCKED_NOTE);
   252                 }
   266                 }
   253             else
   267             else
   254                 {
   268                 {
   255                 iCustomPhone.CheckSecurityCode(iWait->iStatus,RMmCustomAPI::ESecurityCodePuk2);
   269                 iCustomPhone.CheckSecurityCode(iWait->iStatus,RMmCustomAPI::ESecurityCodePuk2);
   256                	RDEBUG("WaitForRequestL", 0);
       
   257                 TInt res = iWait->WaitForRequestL();
   270                 TInt res = iWait->WaitForRequestL();
   258                 RDEBUG("WaitForRequestL res", res);
       
   259                 }
   271                 }
   260             break;
   272             break;
   261         case KErrGsm0707OperationNotAllowed:
   273         case KErrGsm0707OperationNotAllowed:
   262             ShowResultNoteL(CAknNoteDialog::EErrorTone,R_OPERATION_NOT_ALLOWED);
   274             ShowResultNoteL(CAknNoteDialog::EErrorTone,R_OPERATION_NOT_ALLOWED);
   263             break;
   275             break;
   274 // Deletes pin operation note if necessary
   286 // Deletes pin operation note if necessary
   275 // ----------------------------------------------------------
   287 // ----------------------------------------------------------
   276 //
   288 //
   277 EXPORT_C void CManualSecuritySettings::CancelChangePin()
   289 EXPORT_C void CManualSecuritySettings::CancelChangePin()
   278     {
   290     {
   279     RDEBUG("0", 0);
   291     #if defined(_DEBUG)
       
   292     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelChangePin()"));
       
   293     #endif    
   280     delete iNote;
   294     delete iNote;
   281     iNote = NULL;
   295     iNote = NULL;
   282     }
   296     }
   283 //
   297 //
   284 // ----------------------------------------------------------
   298 // ----------------------------------------------------------
   290     {
   304     {
   291     /*****************************************************
   305     /*****************************************************
   292     *    Series 60 Customer / ETel
   306     *    Series 60 Customer / ETel
   293     *    Series 60  ETel API
   307     *    Series 60  ETel API
   294     *****************************************************/
   308     *****************************************************/
   295     RDEBUG("0", 0);  
   309     #if defined(_DEBUG)
       
   310     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnblockPinL()"));
       
   311     #endif        
   296     if (aNew.CompareF(aVerifyNew) != 0)     
   312     if (aNew.CompareF(aVerifyNew) != 0)     
   297         {
   313         {
   298         // codes do not match note 
   314         // codes do not match note 
   299         ShowResultNoteL(CAknNoteDialog::EErrorTone,R_CODES_DONT_MATCH);
   315         ShowResultNoteL(CAknNoteDialog::EErrorTone,R_CODES_DONT_MATCH);
   300         return EFalse;
   316         return EFalse;
   308         }
   324         }
   309     else
   325     else
   310         {
   326         {
   311         blockCodeType = RMobilePhone::ESecurityCodePuk2;
   327         blockCodeType = RMobilePhone::ESecurityCodePuk2;
   312         }
   328         }
   313 		RDEBUG("blockCodeType", blockCodeType);
   329 
   314     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
   330     iWait->SetRequestType(EMobilePhoneVerifySecurityCode);
   315     iPhone.VerifySecurityCode(iWait->iStatus, blockCodeType, aNew, aPuk);
   331     iPhone.VerifySecurityCode(iWait->iStatus, blockCodeType, aNew, aPuk);
   316     RDEBUG("WaitForRequestL", 0);
       
   317     TInt res = iWait->WaitForRequestL();
   332     TInt res = iWait->WaitForRequestL();
   318     RDEBUG("WaitForRequestL res", res);
       
   319 
   333 
   320     switch(res)
   334     switch(res)
   321         {        
   335         {        
   322         case KErrNone:
   336         case KErrNone:
   323             if (aPin == EPin1)
   337             if (aPin == EPin1)
   352 // Deletes unblock pin operation note if necessary
   366 // Deletes unblock pin operation note if necessary
   353 // ----------------------------------------------------------
   367 // ----------------------------------------------------------
   354 //    
   368 //    
   355 EXPORT_C void CManualSecuritySettings::CancelUnblockPin()
   369 EXPORT_C void CManualSecuritySettings::CancelUnblockPin()
   356     {
   370     {
   357     RDEBUG("0", 0);      
   371     #if defined(_DEBUG)
       
   372     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelUnblockPinL()"));
       
   373     #endif        
   358     delete iNote;
   374     delete iNote;
   359     iNote = NULL;        
   375     iNote = NULL;        
   360     }
   376     }
   361 //
   377 //
   362 // ----------------------------------------------------------
   378 // ----------------------------------------------------------
   368     {
   384     {
   369     /*****************************************************
   385     /*****************************************************
   370     *    Series 60 Customer / ETel
   386     *    Series 60 Customer / ETel
   371     *    Series 60  ETel API
   387     *    Series 60  ETel API
   372     *****************************************************/
   388     *****************************************************/
   373     RDEBUG("0", 0);
   389     #if defined(_DEBUG)
       
   390     RDebug::Print(_L("(SECUI)CManualSecuritySettings::LockSimL()"));
       
   391     #endif
       
   392 
       
   393     
   374     RMmCustomAPI::TLockNumber aLockType;
   394     RMmCustomAPI::TLockNumber aLockType;
   375     TInt ret = KErrGsm0707IncorrectPassword;
   395     TInt ret = KErrGsm0707IncorrectPassword;
   376     TInt length = aLockCode.Length();
   396     TInt length = aLockCode.Length();
   377 
   397 
   378     RDEBUG("length", length);
   398     #if defined(_DEBUG)
   379 		// from now on, it accepts restricted lengths, although some locks are 20, others are 13
   399     RDebug::Print(_L("(SECUI)CManualSecuritySettings::LockSimL(): Param length: %d"), length);
   380     if(aLockCode.Length() <= KSimLockMaxPasswordSize)
   400     #endif
   381     {
   401 
   382     if (aType.CompareF(Operator) == 0)
   402     if (aType.CompareF(Operator) == 0)
   383         {
   403         {
   384         aLockType = RMmCustomAPI::EOperator;
   404         aLockType = RMmCustomAPI::EOperator;
   385         ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
   405         ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
   386         }
   406         }
   412     if (aType.CompareF(Operator_Gid2) == 0)
   432     if (aType.CompareF(Operator_Gid2) == 0)
   413         {
   433         {
   414         aLockType = RMmCustomAPI::EOperator_Gid2;
   434         aLockType = RMmCustomAPI::EOperator_Gid2;
   415         ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
   435         ret = iCustomPhone.ActivateSimLock( aLockCode,aLockType );
   416         }
   436         }
   417     }
   437 
   418 
   438     #if defined(_DEBUG)
   419     RDEBUG("ret", ret);
   439     RDebug::Print(_L("(SECUI)CManualSecuritySettings::LockSimL() RESULT: %d"), ret);
       
   440     #endif
   420     switch (ret)
   441     switch (ret)
   421         {
   442         {
   422         case KErrNone:
   443         case KErrNone:
   423             ShowResultNoteL(CAknNoteDialog::EConfirmationTone,R_SIM_ON);
   444             ShowResultNoteL(CAknNoteDialog::EConfirmationTone,R_SIM_ON);
   424             return ETrue;
   445             return ETrue;
   449 // 
   470 // 
   450 // ----------------------------------------------------------
   471 // ----------------------------------------------------------
   451 //        
   472 //        
   452 EXPORT_C void CManualSecuritySettings::CancelLockSim()
   473 EXPORT_C void CManualSecuritySettings::CancelLockSim()
   453     {
   474     {
   454     RDEBUG("0", 0);
   475     #if defined(_DEBUG)
       
   476     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelLockSimL()"));
       
   477     #endif
   455     delete iNote;
   478     delete iNote;
   456     iNote = NULL;    
   479     iNote = NULL;    
   457     }    
   480     }    
   458 //
   481 //
   459 // ----------------------------------------------------------
   482 // ----------------------------------------------------------
   465     {
   488     {
   466     /*****************************************************
   489     /*****************************************************
   467     *    Series 60 Customer / ETel
   490     *    Series 60 Customer / ETel
   468     *    Series 60  ETel API
   491     *    Series 60  ETel API
   469     *****************************************************/
   492     *****************************************************/
   470     RDEBUG("0", 0);
   493     #if defined(_DEBUG)
       
   494     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnLockSimL()"));
       
   495     #endif
   471     RMmCustomAPI::TLockNumber aLockType;
   496     RMmCustomAPI::TLockNumber aLockType;
   472     TInt ret = KErrGsm0707IncorrectPassword;
   497     TInt ret = KErrGsm0707IncorrectPassword;
   473     TInt length = aUnlockCode.Length();
   498     TInt length = aUnlockCode.Length();
   474 
   499 
   475     RDEBUG("length", length);
   500     #if defined(_DEBUG)
   476 		// from now on, it accepts restricted lengths, although some locks are 20, others are 13
   501     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnLockSimL(): Param length: %d"), length);
   477     if(aUnlockCode.Length() <= KSimLockMaxPasswordSize)
   502     #endif
   478     {
   503     
   479     if (aType.CompareF(Operator) == 0)
   504     if (aType.CompareF(Operator) == 0)
   480         {
   505         {
   481         aLockType = RMmCustomAPI::EOperator;
   506         aLockType = RMmCustomAPI::EOperator;
   482         ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
   507         ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
   483         }
   508         }
   515         {
   540         {
   516         aLockType = RMmCustomAPI::EGlobalUnlock;
   541         aLockType = RMmCustomAPI::EGlobalUnlock;
   517         ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
   542         ret = iCustomPhone.DeActivateSimLock( aUnlockCode,aLockType );
   518         }    
   543         }    
   519         
   544         
   520     }
   545     #if defined(_DEBUG)
   521     RDEBUG("ret", ret);
   546     RDebug::Print(_L("(SECUI)CManualSecuritySettings::UnLockSimL() RESULT: %d"), ret);
       
   547     #endif
   522     switch (ret)
   548     switch (ret)
   523         {
   549         {
   524         case KErrNone:
   550         case KErrNone:
   525             ShowResultNoteL(CAknNoteDialog::EConfirmationTone,R_SIM_OFF);
   551             ShowResultNoteL(CAknNoteDialog::EConfirmationTone,R_SIM_OFF);
   526             return ETrue;
   552             return ETrue;
   549 // 
   575 // 
   550 // ----------------------------------------------------------
   576 // ----------------------------------------------------------
   551 //                
   577 //                
   552 EXPORT_C void CManualSecuritySettings::CancelUnlockSim()
   578 EXPORT_C void CManualSecuritySettings::CancelUnlockSim()
   553     {
   579     {
   554     RDEBUG("0", 0);
   580     #if defined(_DEBUG)
       
   581     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelUnLockSimL()"));
       
   582     #endif
   555     delete iNote;
   583     delete iNote;
   556     iNote = NULL;
   584     iNote = NULL;
   557     }
   585     }
   558 
   586 
   559 //
   587 //
   562 // Shows settingchange results
   590 // Shows settingchange results
   563 // ----------------------------------------------------------
   591 // ----------------------------------------------------------
   564 //
   592 //
   565 void CManualSecuritySettings::ShowResultNoteL(CAknNoteDialog::TTone aTone, TInt aResourceID)
   593 void CManualSecuritySettings::ShowResultNoteL(CAknNoteDialog::TTone aTone, TInt aResourceID)
   566     {
   594     {
   567     RDEBUG("aResourceID", aResourceID);
   595     #if defined(_DEBUG)
   568     CSecuritySettings::ShowResultNoteL(aResourceID, aTone);
   596     RDebug::Print(_L("(SECUI)CManualSecuritySettings::CancelUnLockSimL()"));
       
   597     #endif
       
   598     iNote = new (ELeave) CAknNoteDialog(REINTERPRET_CAST(CEikDialog**,&iNote));
       
   599     iNote->SetTimeout(CAknNoteDialog::ELongTimeout);
       
   600     iNote->SetTone(aTone);
       
   601     iNote->ExecuteLD(aResourceID);
   569     }
   602     }
   570 
   603 
   571 // End of file
   604 // End of file