sysstatemgmt/systemstatereferenceplugins/custcmd/src/cmddevicesecuritycheck.cpp
branchRCL_3
changeset 20 1ddbe54d0645
parent 5 1a73e8f1b64d
equal deleted inserted replaced
19:94cb00198351 20:1ddbe54d0645
    26 #include "ssmsecuritychecknotifier.h"
    26 #include "ssmsecuritychecknotifier.h"
    27 #include "cmddevicesecuritycheck.h"
    27 #include "cmddevicesecuritycheck.h"
    28 #include "ssmuiproviderdll.h"
    28 #include "ssmuiproviderdll.h"
    29 #include "ssmrefcustomcmdcommon.h"
    29 #include "ssmrefcustomcmdcommon.h"
    30 #include "ssmdebug.h"
    30 #include "ssmdebug.h"
       
    31 #include "starterdomaincrkeys.h"
       
    32 #include "startupdomainpskeys.h"
       
    33 
       
    34 #include <centralrepository.h>
       
    35 
    31 
    36 
    32 CCustomCmdDeviceSecurityCheck* CCustomCmdDeviceSecurityCheck::NewL()
    37 CCustomCmdDeviceSecurityCheck* CCustomCmdDeviceSecurityCheck::NewL()
    33 	{
    38 	{
    34 	CCustomCmdDeviceSecurityCheck* self = new (ELeave) CCustomCmdDeviceSecurityCheck();
    39 	CCustomCmdDeviceSecurityCheck* self = new (ELeave) CCustomCmdDeviceSecurityCheck();
    35 	CleanupStack::PushL(self);
    40 	CleanupStack::PushL(self);
    67     	{
    72     	{
    68     	DEBUGPRINT2A("Failed to open phone subsession with error %d", errorCode);
    73     	DEBUGPRINT2A("Failed to open phone subsession with error %d", errorCode);
    69     	User::Leave(errorCode);	
    74     	User::Leave(errorCode);	
    70     	}
    75     	}
    71 
    76 
       
    77 	iStartupRepository = CRepository::NewL(KCRUidStartup);
       
    78 
    72 	//Add active object to active scheduler
    79 	//Add active object to active scheduler
    73 	CActiveScheduler::Add(this);
    80 	CActiveScheduler::Add(this);
    74 	}
    81 	}
    75 
    82 
    76 CCustomCmdDeviceSecurityCheck::CCustomCmdDeviceSecurityCheck()
    83 CCustomCmdDeviceSecurityCheck::CCustomCmdDeviceSecurityCheck()
    90         {
    97         {
    91         iServer.UnloadPhoneModule(*iTsyModuleName);
    98         iServer.UnloadPhoneModule(*iTsyModuleName);
    92         iServer.Close();
    99         iServer.Close();
    93         }
   100         }
    94     delete iTsyModuleName;
   101     delete iTsyModuleName;
       
   102 	delete iStartupRepository;
    95 	}
   103 	}
    96 
   104 
    97 TInt CCustomCmdDeviceSecurityCheck::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/)
   105 TInt CCustomCmdDeviceSecurityCheck::Initialize(CSsmCustomCommandEnv* /*aCmdEnv*/)
    98 	{
   106 	{
    99 	return KErrNone;
   107 	return KErrNone;
   111 void CCustomCmdDeviceSecurityCheck::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus)
   119 void CCustomCmdDeviceSecurityCheck::Execute(const TDesC8& /*aParams*/, TRequestStatus& aStatus)
   112 	{
   120 	{
   113 	//Set the user request to pending
   121 	//Set the user request to pending
   114 	aStatus = KRequestPending;
   122 	aStatus = KRequestPending;
   115 	iExecuteRequest = &aStatus;
   123 	iExecuteRequest = &aStatus;
   116 
   124 	
       
   125 	TInt errorCode = KErrNone;
   117 #ifdef __WINS__
   126 #ifdef __WINS__
   118 #ifdef TEST_CUSTCMD_MACRO
   127 #ifdef TEST_CUSTCMD_MACRO
   119 	TRequestStatus* status = &iStatus;
   128 	TRequestStatus* status = &iStatus;
   120 	User::RequestComplete(status, KErrNone);
   129 	User::RequestComplete(status, KErrNone);
   121 	SetActive();
   130 	SetActive();
   122 #else
   131 #else
   123     // The device lock status can not be read in the emulator.
   132     // The device lock status can not be read in the emulator.
   124     // Just pretend the lock is not enabled.
   133     // Just pretend the lock is not enabled.
   125 	TInt errorCode = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSimOk);
   134 	errorCode = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSimOk);
   126     CompleteClientRequest(errorCode);
   135     CompleteClientRequest(errorCode);
   127 #endif //TEST_CUSTCMD_MACRO
   136 #endif //TEST_CUSTCMD_MACRO
   128 
   137 
   129 #else
   138 #else
   130     if (CSsmUiSpecific::IsNormalBoot() || CSsmUiSpecific::IsSimChangedReset())
   139 
       
   140 	TInt val(EStartupDevLockNotSucess);
       
   141 
       
   142 	errorCode = iStartupRepository->Get(KStartupDevLockStatus, val);
       
   143 	DEBUGPRINT3A("Getting KStartupDevLockStatus : %d completed with %d", val, errorCode);
       
   144 
       
   145 	TInt startupReason = 0;
       
   146 	if (EStartupDevLockNotSucess != val)
       
   147 		{
       
   148 		errorCode = iStartupRepository->Set(KStartupDevLockStatus, EStartupDevLockNotSucess);
       
   149 		DEBUGPRINT2A("Setting KStartupDevLockStatus to EStartupDevLockNotSucess completed with %d", errorCode);
       
   150 		}
       
   151 
       
   152 	errorCode = RProperty::Get(CSsmUiSpecific::StartupPSUid(), KPSStartupReason, startupReason);
       
   153 	DEBUGPRINT3A("Getting KPSStartupReason : %d completed with : %d", startupReason, errorCode);
       
   154 	
       
   155 	if (CSsmUiSpecific::IsNormalBoot() || CSsmUiSpecific::IsSimChangedReset() || (EStartupDevLockNotSucess ==  val && EUnknownReset == startupReason))
   131         {
   156         {
   132         iPhone.GetLockInfo( iStatus, RMobilePhone::ELockPhoneDevice, iLockInfoPckg );
   157         iPhone.GetLockInfo( iStatus, RMobilePhone::ELockPhoneDevice, iLockInfoPckg );
   133         SetActive();
   158         SetActive();
   134         }
   159         }
   135     else
   160     else
   136         {
   161         {
   137         TInt errorCode = RProperty::Set(
   162 		errorCode = RProperty::Set(
   138         		CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSecOk );
   163         		CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, EStarterSecurityPhaseSecOk );
   139         CompleteClientRequest( errorCode );
   164         CompleteClientRequest( errorCode );
   140         }
   165         }
   141 #endif //__WINS__
   166 #endif //__WINS__
   142 	}
   167 	}
   283 	return KErrNone;
   308 	return KErrNone;
   284 	}
   309 	}
   285 
   310 
   286 void CCustomCmdDeviceSecurityCheck::CompleteClientRequest(TInt aReason)
   311 void CCustomCmdDeviceSecurityCheck::CompleteClientRequest(TInt aReason)
   287 	{
   312 	{
       
   313 	DEBUGPRINT2A("Device Security Check completed with %d", aReason);
       
   314 
       
   315 	TInt err = iStartupRepository->Set(KStartupDevLockStatus, (aReason == KErrNone ? EStartupDevLockSucess : EStartupDevLockNotSucess));
       
   316     DEBUGPRINT2A("Setting KStartupDevLockStatus completed with error %d", err);
   288 	//Complete client request with reason code
   317 	//Complete client request with reason code
   289 	if (iExecuteRequest)
   318 	if (iExecuteRequest)
   290         {
   319         {
   291     	TInt errorCode = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, 
   320     	err = RProperty::Set(CSsmUiSpecific::StarterPSUid(), KStarterSecurityPhase, 
   292     			aReason == KErrNone ? EStarterSecurityPhaseSecOk : EStarterSecurityPhaseSecNok );
   321     			aReason == KErrNone ? EStarterSecurityPhaseSecOk : EStarterSecurityPhaseSecNok );
   293         User::RequestComplete(iExecuteRequest, aReason);
   322         User::RequestComplete(iExecuteRequest, aReason);
   294         }
   323         }
   295 	}
   324 	}