securitydialogs/SecUi/Src/SecUiSystemLock.cpp
branchRCL_3
changeset 22 03674e5abf46
parent 21 09b1ac925e3f
equal deleted inserted replaced
21:09b1ac925e3f 22:03674e5abf46
    20 #include    <e32property.h>
    20 #include    <e32property.h>
    21 #include    <PSVariables.h>   // Property values
    21 #include    <PSVariables.h>   // Property values
    22 #include    <coreapplicationuisdomainpskeys.h>
    22 #include    <coreapplicationuisdomainpskeys.h>
    23 #include    "SecUiSystemLock.h"
    23 #include    "SecUiSystemLock.h"
    24 #include    <eikenv.h>
    24 #include    <eikenv.h>
    25 // #include    <AknNotifierController.h>
    25 #include    <AknNotifierController.h>
    26 #include    <rmmcustomapi.h>
    26 #include    <rmmcustomapi.h>
    27 #include    "secuisecuritysettings.h"
    27 #include    "secuisecuritysettings.h"
    28 #include    "SecUiWait.h"
    28 #include    "SecUiWait.h"
    29 #include    <mmtsy_names.h>
    29 #include    <mmtsy_names.h>
    30 #include 	<e32property.h>
    30 #include 	<e32property.h>
    31 #include <ctsydomainpskeys.h>
    31 #include <ctsydomainpskeys.h>
    32 #include    <securityuisprivatepskeys.h>
    32 #include    <securityuisprivatepskeys.h>
    33 #include    <devicelockaccessapi.h>
       
    34 
       
    35     /*****************************************************
    33     /*****************************************************
    36     *    Series 60 Customer / TSY
    34     *    Series 60 Customer / TSY
    37     *    Needs customer TSY implementation
    35     *    Needs customer TSY implementation
    38     *****************************************************/
    36     *****************************************************/
    39 //  LOCAL CONSTANTS AND MACROS  
    37 //  LOCAL CONSTANTS AND MACROS  
    48 // 
    46 // 
    49 // ----------------------------------------------------------
    47 // ----------------------------------------------------------
    50 // 
    48 // 
    51 EXPORT_C CSystemLock* CSystemLock::NewL()
    49 EXPORT_C CSystemLock* CSystemLock::NewL()
    52     {
    50     {
    53     RDebug::Printf( "%s %s (%u) this should not be called=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    54     CSystemLock* self = new(ELeave) CSystemLock();
    51     CSystemLock* self = new(ELeave) CSystemLock();
    55     CleanupStack::PushL(self);
    52     CleanupStack::PushL(self);
    56     self->ConstructL();
    53     self->ConstructL();
    57     CleanupStack::Pop();
    54     CleanupStack::Pop();
    58     return self;
    55     return self;
    63 // 
    60 // 
    64 // ----------------------------------------------------------
    61 // ----------------------------------------------------------
    65 // 
    62 // 
    66 void CSystemLock::ConstructL()    
    63 void CSystemLock::ConstructL()    
    67     {    
    64     {    
    68     RDebug::Printf( "%s %s (%u) this should not be called=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
    69     /*****************************************************
    65     /*****************************************************
    70     *    Series 60 Customer / ETel
    66     *    Series 60 Customer / ETel
    71     *    Series 60  ETel API
    67     *    Series 60  ETel API
    72     *****************************************************/
    68     *****************************************************/
    73     /*****************************************************
    69     /*****************************************************
   143         }
   139         }
   144     }
   140     }
   145 //
   141 //
   146 // ----------------------------------------------------------
   142 // ----------------------------------------------------------
   147 // CSystemLock::SetLockedL()
   143 // CSystemLock::SetLockedL()
   148 // Activates system lock
   144 // Activates system lock 
   149 // this was used by SysAp, but it's not longer used
       
   150 // ----------------------------------------------------------
   145 // ----------------------------------------------------------
   151 //
   146 //
   152 EXPORT_C void CSystemLock::SetLockedL()
   147 EXPORT_C void CSystemLock::SetLockedL()
   153     {
   148     {
   154     /*****************************************************
   149     /*****************************************************
   155     *    Series 60 Customer / ETel
   150     *    Series 60 Customer / ETel
   156     *    Series 60  ETel API
   151     *    Series 60  ETel API
   157     *****************************************************/
   152     *****************************************************/
   158     RDebug::Printf( "%s %s (%u) this should not be called=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   159     #if defined(_DEBUG)
   153     #if defined(_DEBUG)
   160     RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL()"));
   154     RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL()"));
   161     #endif
   155     #endif
   162     // close fast-swap window
   156     // close fast-swap window
   163             RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   157     CEikonEnv::Static()->DismissTaskList();
   164             CDevicelockAccessApi* iDevicelockAccess = CDevicelockAccessApi::NewL( );
   158 
   165            	RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   159 #ifdef __WINS__
   166 						iDevicelockAccess->OfferDevicelock();
   160     // can not verify security code in emulator ---> lock system 
   167 						// this will do				EnableDevicelock( EDevicelockManual );
   161 #ifdef RD_REMOTELOCK
   168 						RDebug::Printf( "%s %s (%u) value=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
   162 		iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked);
       
   163 #else// !RD_REMOTELOCK
       
   164         iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn);
       
   165 #endif//RD_REMOTELOCK
       
   166 #else //__WINS__
       
   167 
       
   168     if(IsActive())
       
   169         return;
       
   170 
       
   171 
       
   172     RMobilePhone::TMobilePhoneLock lockType = RMobilePhone::ELockPhoneDevice;
       
   173     RMobilePhone::TMobilePhoneLockInfoV1 lockInfo;
       
   174     RMobilePhone::TMobilePhoneLockInfoV1Pckg lockInfoPkg(lockInfo);
       
   175     RMobilePhone::TMobilePhoneLockSetting lockChange(RMobilePhone::ELockSetDisabled);
       
   176     CWait* wait = CWait::NewL();
       
   177     CleanupStack::PushL( wait );
       
   178     #if defined(_DEBUG)
       
   179     RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() GetLockInfo"));
       
   180     #endif
       
   181     iPhone.GetLockInfo(wait->iStatus, lockType, lockInfoPkg);
       
   182     if (wait->WaitForRequestL() == KErrNone)
       
   183         {
       
   184         #if defined(_DEBUG)
       
   185         RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() KErrNone"));
       
   186         #endif
       
   187         if (lockInfo.iSetting == RMobilePhone::ELockSetDisabled)
       
   188             {
       
   189             #if defined(_DEBUG)
       
   190             RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() ELockSetDisabled"));
       
   191             #endif
       
   192             // ask code
       
   193             #if defined(_DEBUG)
       
   194             RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() SetLockSetting"));
       
   195             #endif
       
   196             //iCustomPhone.CheckSecurityCode(iStatus, RMmCustomAPI::ESecurityCodePassPhrase);
       
   197             lockChange = RMobilePhone::ELockSetEnabled;
       
   198             RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated);
       
   199             iPhone.SetLockSetting(iStatus, lockType, lockChange);
       
   200             SetActive();
       
   201             }        
       
   202         else
       
   203             {
       
   204             #if defined(_DEBUG)
       
   205             RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() Lock System"));
       
   206             #endif
       
   207  // lock system 
       
   208 #ifdef RD_REMOTELOCK
       
   209 		iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked);
       
   210 #else// !RD_REMOTELOCK
       
   211         iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn);
       
   212 #endif //RD_REMOTELOCK
       
   213 
       
   214             #if defined(_DEBUG)
       
   215             RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() Lock System OK"));
       
   216             #endif
       
   217             }
       
   218         }
       
   219     else
       
   220         {
       
   221         // ask code 
       
   222         #if defined(_DEBUG)
       
   223         RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() ask code (SLS) "));
       
   224         #endif
       
   225         lockChange = RMobilePhone::ELockSetEnabled;
       
   226         RProperty::Set(KPSUidSecurityUIs, KSecurityUIsSecUIOriginatedQuery, ESecurityUIsSystemLockOriginated);
       
   227         iPhone.SetLockSetting(iStatus, lockType, lockChange);
       
   228         SetActive();
       
   229         }
       
   230     CleanupStack::PopAndDestroy();
       
   231     #if defined(_DEBUG)
       
   232     RDebug::Print(_L("(SECUI)CSystemLock::SetLockedL() END"));
       
   233     #endif // DEBUG
       
   234     #endif // WINS
   169     }
   235     }
   170 //
   236 //
   171 // ----------------------------------------------------------
   237 // ----------------------------------------------------------
   172 // CSystemLock::RunL()
   238 // CSystemLock::RunL()
   173 // Handles query result
   239 // Handles query result
   174 // this was used by SysAp, but it's not longer used
       
   175 // ----------------------------------------------------------
   240 // ----------------------------------------------------------
   176 // 
   241 // 
   177 void CSystemLock::RunL()
   242 void CSystemLock::RunL()
   178     {    
   243     {    
   179     RDebug::Printf( "%s %s (%u) this should not be called=%x", __FILE__, __PRETTY_FUNCTION__, __LINE__, 0 );
       
   180 
       
   181     #if defined(_DEBUG)
   244     #if defined(_DEBUG)
   182     TInt status(iStatus.Int());
   245     TInt status(iStatus.Int());
   183     RDebug::Print(_L("(SECUI)CSystemLock::RunL(): %d"), status);
   246     RDebug::Print(_L("(SECUI)CSystemLock::RunL(): %d"), status);
   184     #endif
   247     #endif
   185     //lower the flag
   248     //lower the flag
   193     		{
   256     		{
   194     			#if defined(_DEBUG)
   257     			#if defined(_DEBUG)
   195         		RDebug::Print(_L("(SECUI)CSystemLock::RunL() KErrNone"));
   258         		RDebug::Print(_L("(SECUI)CSystemLock::RunL() KErrNone"));
   196         		#endif
   259         		#endif
   197         		// clear notifiers
   260         		// clear notifiers
   198         		// not any more. Avkon is deprecated. Besides, this function should not be called.
   261         		AknNotifierController::HideAllNotifications(ETrue);
   199         		// AknNotifierController::HideAllNotifications(ETrue);
       
   200         		// query approved -> lock system  
   262         		// query approved -> lock system  
   201 			#ifdef RD_REMOTELOCK
   263 			#ifdef RD_REMOTELOCK
   202 				iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked);
   264 				iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EManualLocked);
   203 			#else// !RD_REMOTELOCK
   265 			#else// !RD_REMOTELOCK
   204         		iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn);
   266         		iProperty.Set(KPSUidCoreApplicationUIs, KCoreAppUIsAutolockStatus, EAutolockOn);
   205         	#endif//RD_REMOTELOCK
   267         	#endif//RD_REMOTELOCK
   206         		// not any more. Avkon is deprecated. Besides, this function should not be called.
   268         		AknNotifierController::HideAllNotifications(EFalse);
   207         		// AknNotifierController::HideAllNotifications(EFalse);
       
   208     		}
   269     		}
   209         }
   270         }
   210     else if((iStatus != KErrCancel) && (iStatus != KErrAbort))
   271     else if((iStatus != KErrCancel) && (iStatus != KErrAbort))
   211         {   //Code error or something like that. Show the dialog again.
   272         {   //Code error or something like that. Show the dialog again.
   212             #if defined(_DEBUG)
   273             #if defined(_DEBUG)