Update contrib.
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // TPDStreamPersister class
20 #include "SC_StrmOut.h"
26 MPolicyDomainPersister::RunL() implementation, which is used to store security policies
28 It is not called directly, but will be called back.
29 @param aPolicyDomainReader TPolicyDomainReader instance, which will be used to traverse
30 security policy objects in the controlled by it collection.
31 @leave System-wide error codes
33 void TPDStreamPersister::RunL(const TPolicyDomainReader& aPolicyDomainReader)
35 //Write software version
36 TVersion softVer(KDBSCMajorVersion, KDBSCMinorVersion, KDBSCBuild);
37 iStream << softVer.iMajor;
38 iStream << softVer.iMinor;
39 iStream << softVer.iBuild;
40 //Write database policy
41 const CDbPolicy& dbPolicy = aPolicyDomainReader.DbPolicy();
42 ExternalizePolicyCollectionL(dbPolicy.PolicyCollection());
43 //Write table policies
44 aPolicyDomainReader.ResetTblPos();
45 iStream << TInt16(aPolicyDomainReader.TblPolicyCount());
46 const CTblPolicy* tblPolicy;
47 while((tblPolicy = aPolicyDomainReader.NextTblPolicy()) != NULL)
49 iStream << tblPolicy->TableName();
50 ExternalizePolicyCollectionL(tblPolicy->PolicyCollection());
52 //Write backup&restore SID
53 iStream << (TUint32)aPolicyDomainReader.BackupSID();
57 Stores security policies collection to a binary file
58 @param aPolicyCollection A const reference to a security policy collection object which has
59 to be stored to a binary file.
60 @leave System-wide error codes
62 void TPDStreamPersister::ExternalizePolicyCollectionL(const CPolicyBase::RPolicyCollection& aPolicyCollection)
64 TInt cnt = aPolicyCollection.Count();
65 iStream << TInt8(cnt);
66 for(TInt i=0;i<cnt;++i)
68 const CPolicyBase::TPolicy& policy = aPolicyCollection[i];
69 iStream << TInt8(policy.iType);
70 TPtrC8 packet = policy.iData.Package();
75 } //end of - namespace DBSC