rtsecuritymanager/rtsecuritymanagerserver/src/rtsecmgrserver.cpp
author andy simpson <andrews@symbian.org>
Mon, 14 Dec 2009 16:23:13 +0000
branchRCL_1
changeset 19 63696a383c57
parent 0 99ef825efeca
child 21 bcef26ca2be3
permissions -rw-r--r--
Added tag PDK_2.0.2 for changeset a6f8379a869b

/*
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of the License "Eclipse Public License v1.0"
* which accompanies this distribution, and is available
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
*
* Initial Contributors:
* Nokia Corporation - initial contribution.
*
* Contributors:
*
* Description:      
*
*/





#include <e32svr.h>
#include <e32uid.h>

#include "rtsecmgrserver.h"
#include "rtsecmgrsession.h"
#include "rtsecmgrsubSession.h"
#include "rtsecmgrcommonDef.h"
#include "rtsecmgrstore.h"
#include "rtsecmgrpolicymanager.h"
#include "rtsecmgrscriptmanager.h"

CRTSecMgrServer* CRTSecMgrServer::NewL(CActive::TPriority aActiveObjectPriority)
	{
	CRTSecMgrServer* self=new (ELeave) CRTSecMgrServer(aActiveObjectPriority);
	CleanupStack::PushL(self);
	self->ConstructL();
	CleanupStack::Pop(self);
	return self;
	}

CRTSecMgrServer* CRTSecMgrServer::NewLC(CActive::TPriority aActiveObjectPriority)
	{
	CRTSecMgrServer* self=new (ELeave) CRTSecMgrServer(aActiveObjectPriority);
	CleanupStack::PushL(self);
	self->ConstructL();
	return self;
	}

void CRTSecMgrServer::ConstructL()
	{
	StartL(KSecServerProcessName);
	iContainerIndex = CObjectConIx::NewL();
	
	iSecMgrDb = CSecMgrStore::NewL();	
	iPolicyMgr = CPolicyManager::NewL(iSecMgrDb);
	iPolicyMgr->RestorePoliciesL();
	
	iScriptMgr = CScriptManager::NewL(iSecMgrDb,iPolicyMgr);
	
	// Start the shutDown timer
	iShutDown.ConstructL();

	iShutDown.Start ();
	}

CRTSecMgrServer::~CRTSecMgrServer()
	{
	if(iPolicyMgr)
	{
		delete iPolicyMgr;			
	}
	
	if(iScriptMgr)
	{
		delete iScriptMgr;
	}
	
	if(iSecMgrDb)
	{
		delete iSecMgrDb;
	}
			
	Delete(iContainerIndex); 
	
	iShutDown.Cancel();
	}

CSession2* CRTSecMgrServer::NewSessionL(const TVersion &aVersion,const RMessage2& /*aMessage*/) const
	{
	  // Check that the version is OK
	TVersion v(KRTSecMgrServMajorVersionNumber,KRTSecMgrServMinorVersionNumber,KRTSecMgrServBuildVersionNumber);
	if (!User::QueryVersionSupported(v,aVersion))
		User::Leave(KErrNotSupported);
	
	return CRTSecMgrSession::NewL();
	}