sl@0: // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // TPDStreamPersister class sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include "SC_Defs.h" sl@0: #include "SC_StrmOut.h" sl@0: sl@0: namespace DBSC sl@0: { sl@0: sl@0: /** sl@0: MPolicyDomainPersister::RunL() implementation, which is used to store security policies sl@0: to a binary file. sl@0: It is not called directly, but will be called back. sl@0: @param aPolicyDomainReader TPolicyDomainReader instance, which will be used to traverse sl@0: security policy objects in the controlled by it collection. sl@0: @leave System-wide error codes sl@0: */ sl@0: void TPDStreamPersister::RunL(const TPolicyDomainReader& aPolicyDomainReader) sl@0: { sl@0: //Write software version sl@0: TVersion softVer(KDBSCMajorVersion, KDBSCMinorVersion, KDBSCBuild); sl@0: iStream << softVer.iMajor; sl@0: iStream << softVer.iMinor; sl@0: iStream << softVer.iBuild; sl@0: //Write database policy sl@0: const CDbPolicy& dbPolicy = aPolicyDomainReader.DbPolicy(); sl@0: ExternalizePolicyCollectionL(dbPolicy.PolicyCollection()); sl@0: //Write table policies sl@0: aPolicyDomainReader.ResetTblPos(); sl@0: iStream << TInt16(aPolicyDomainReader.TblPolicyCount()); sl@0: const CTblPolicy* tblPolicy; sl@0: while((tblPolicy = aPolicyDomainReader.NextTblPolicy()) != NULL) sl@0: { sl@0: iStream << tblPolicy->TableName(); sl@0: ExternalizePolicyCollectionL(tblPolicy->PolicyCollection()); sl@0: } sl@0: //Write backup&restore SID sl@0: iStream << (TUint32)aPolicyDomainReader.BackupSID(); sl@0: } sl@0: sl@0: /** sl@0: Stores security policies collection to a binary file sl@0: @param aPolicyCollection A const reference to a security policy collection object which has sl@0: to be stored to a binary file. sl@0: @leave System-wide error codes sl@0: */ sl@0: void TPDStreamPersister::ExternalizePolicyCollectionL(const CPolicyBase::RPolicyCollection& aPolicyCollection) sl@0: { sl@0: TInt cnt = aPolicyCollection.Count(); sl@0: iStream << TInt8(cnt); sl@0: for(TInt i=0;i