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