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