1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/persistentdata/persistentstorage/dbms/security/SC_StrmOut.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,75 @@
1.4 +// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// TPDStreamPersister class
1.18 +//
1.19 +//
1.20 +
1.21 +#include <s32file.h>
1.22 +#include "SC_Defs.h"
1.23 +#include "SC_StrmOut.h"
1.24 +
1.25 +namespace DBSC
1.26 +{
1.27 +
1.28 +/**
1.29 +MPolicyDomainPersister::RunL() implementation, which is used to store security policies
1.30 +to a binary file.
1.31 +It is not called directly, but will be called back.
1.32 +@param aPolicyDomainReader TPolicyDomainReader instance, which will be used to traverse
1.33 + security policy objects in the controlled by it collection.
1.34 +@leave System-wide error codes
1.35 +*/
1.36 +void TPDStreamPersister::RunL(const TPolicyDomainReader& aPolicyDomainReader)
1.37 + {
1.38 + //Write software version
1.39 + TVersion softVer(KDBSCMajorVersion, KDBSCMinorVersion, KDBSCBuild);
1.40 + iStream << softVer.iMajor;
1.41 + iStream << softVer.iMinor;
1.42 + iStream << softVer.iBuild;
1.43 + //Write database policy
1.44 + const CDbPolicy& dbPolicy = aPolicyDomainReader.DbPolicy();
1.45 + ExternalizePolicyCollectionL(dbPolicy.PolicyCollection());
1.46 + //Write table policies
1.47 + aPolicyDomainReader.ResetTblPos();
1.48 + iStream << TInt16(aPolicyDomainReader.TblPolicyCount());
1.49 + const CTblPolicy* tblPolicy;
1.50 + while((tblPolicy = aPolicyDomainReader.NextTblPolicy()) != NULL)
1.51 + {
1.52 + iStream << tblPolicy->TableName();
1.53 + ExternalizePolicyCollectionL(tblPolicy->PolicyCollection());
1.54 + }
1.55 + //Write backup&restore SID
1.56 + iStream << (TUint32)aPolicyDomainReader.BackupSID();
1.57 + }
1.58 +
1.59 +/**
1.60 +Stores security policies collection to a binary file
1.61 +@param aPolicyCollection A const reference to a security policy collection object which has
1.62 + to be stored to a binary file.
1.63 +@leave System-wide error codes
1.64 +*/
1.65 +void TPDStreamPersister::ExternalizePolicyCollectionL(const CPolicyBase::RPolicyCollection& aPolicyCollection)
1.66 + {
1.67 + TInt cnt = aPolicyCollection.Count();
1.68 + iStream << TInt8(cnt);
1.69 + for(TInt i=0;i<cnt;++i)
1.70 + {
1.71 + const CPolicyBase::TPolicy& policy = aPolicyCollection[i];
1.72 + iStream << TInt8(policy.iType);
1.73 + TPtrC8 packet = policy.iData.Package();
1.74 + iStream << packet;
1.75 + }
1.76 + }
1.77 +
1.78 +} //end of - namespace DBSC