|
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". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // TPDStreamPersister class |
|
15 // |
|
16 // |
|
17 |
|
18 #include <s32file.h> |
|
19 #include "SC_Defs.h" |
|
20 #include "SC_StrmOut.h" |
|
21 |
|
22 namespace DBSC |
|
23 { |
|
24 |
|
25 /** |
|
26 MPolicyDomainPersister::RunL() implementation, which is used to store security policies |
|
27 to a binary file. |
|
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 |
|
32 */ |
|
33 void TPDStreamPersister::RunL(const TPolicyDomainReader& aPolicyDomainReader) |
|
34 { |
|
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) |
|
48 { |
|
49 iStream << tblPolicy->TableName(); |
|
50 ExternalizePolicyCollectionL(tblPolicy->PolicyCollection()); |
|
51 } |
|
52 //Write backup&restore SID |
|
53 iStream << (TUint32)aPolicyDomainReader.BackupSID(); |
|
54 } |
|
55 |
|
56 /** |
|
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 |
|
61 */ |
|
62 void TPDStreamPersister::ExternalizePolicyCollectionL(const CPolicyBase::RPolicyCollection& aPolicyCollection) |
|
63 { |
|
64 TInt cnt = aPolicyCollection.Count(); |
|
65 iStream << TInt8(cnt); |
|
66 for(TInt i=0;i<cnt;++i) |
|
67 { |
|
68 const CPolicyBase::TPolicy& policy = aPolicyCollection[i]; |
|
69 iStream << TInt8(policy.iType); |
|
70 TPtrC8 packet = policy.iData.Package(); |
|
71 iStream << packet; |
|
72 } |
|
73 } |
|
74 |
|
75 } //end of - namespace DBSC |