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 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef __CENREP_INIFILE_H__
|
sl@0
|
17 |
#define __CENREP_INIFILE_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
#include <s32file.h>
|
sl@0
|
20 |
#include "centralrepository.h"
|
sl@0
|
21 |
#include "log.h"
|
sl@0
|
22 |
#include "srvdefs.h"
|
sl@0
|
23 |
|
sl@0
|
24 |
using namespace NCentralRepositoryConstants;
|
sl@0
|
25 |
using namespace NCentralRepositoryResources;
|
sl@0
|
26 |
|
sl@0
|
27 |
//Forward declarations
|
sl@0
|
28 |
class RRangePolicyArray;
|
sl@0
|
29 |
class RDefaultMetaArray;
|
sl@0
|
30 |
class TServerSetting;
|
sl@0
|
31 |
class TSettingsAccessPolicy;
|
sl@0
|
32 |
class CSharedRepository;
|
sl@0
|
33 |
|
sl@0
|
34 |
//Max length of one setting statement
|
sl@0
|
35 |
const TInt KMaxLengthWithPolicyInfo = KMaxBinaryLength * 2 + 64;
|
sl@0
|
36 |
|
sl@0
|
37 |
////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
38 |
// CIniFileIn class
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
@internalTechnology
|
sl@0
|
41 |
*/
|
sl@0
|
42 |
class CIniFileIn : public CBase
|
sl@0
|
43 |
{
|
sl@0
|
44 |
enum {KReadPolicy,KWritePolicy};
|
sl@0
|
45 |
|
sl@0
|
46 |
public:
|
sl@0
|
47 |
enum TIniFileOpenMode {ERomOnly,EInstallOnly,EAuto};
|
sl@0
|
48 |
|
sl@0
|
49 |
public:
|
sl@0
|
50 |
static TInt NewLC(RFs& aFs,CIniFileIn*& aIniFile,const TDesC& aFullFileName);
|
sl@0
|
51 |
~CIniFileIn();
|
sl@0
|
52 |
|
sl@0
|
53 |
TInt ReadSettingL(TServerSetting& aSetting,TSecurityPolicy& aSingleReadPolicy,TSecurityPolicy& aSingleWritePolicy, TBool& aSingleReadPolicyFound, TBool& aSingleWritePolicyFound, TBool& aSingleMetaFound);
|
sl@0
|
54 |
|
sl@0
|
55 |
TInt ReadPlatSecSectionL(TSecurityPolicy& aDefaultReadPolicy, TBool& aGotDefaultReadPolicy,
|
sl@0
|
56 |
TSecurityPolicy& aDefaultWritePolicy, TBool& aGotDefaultWritePolicy,
|
sl@0
|
57 |
RRangePolicyArray& aRangePolicies);
|
sl@0
|
58 |
TInt ReadRdPolicyL(TSecurityPolicy& aReadPolicy);
|
sl@0
|
59 |
TInt ReadWrPolicyL(TSecurityPolicy& aWritePolicy);
|
sl@0
|
60 |
TInt ReadOwnerSectionL(TUint32 &aOwnerUID) ;
|
sl@0
|
61 |
TInt ReadTimeStampSectionL(TTime &aTimeStamp) ;
|
sl@0
|
62 |
TInt ReadDefaultMetaSecSectionL(TUint32& aDefaultMeta,
|
sl@0
|
63 |
RDefaultMetaArray& aDefaultMetaRanges) ;
|
sl@0
|
64 |
TInt SkipPlatSecSectionL();
|
sl@0
|
65 |
TInt SkipOwnerSectionL() ;
|
sl@0
|
66 |
TInt SkipDefaultMetaSectionL() ;
|
sl@0
|
67 |
TInt SkipTimeStampSectionL() ;
|
sl@0
|
68 |
|
sl@0
|
69 |
TInt FindMainSectionL(void) ;
|
sl@0
|
70 |
|
sl@0
|
71 |
#ifdef CENTREP_TRACE
|
sl@0
|
72 |
HBufC* FullName();
|
sl@0
|
73 |
#endif
|
sl@0
|
74 |
private:
|
sl@0
|
75 |
TInt ReadHeaderL();
|
sl@0
|
76 |
TInt ReadSettingOnlyL(TServerSetting& aSetting, TBool& aSingleMetaFound);
|
sl@0
|
77 |
TInt ReadStringL(HBufC8*& aString);
|
sl@0
|
78 |
TInt ReadString16To8L(HBufC8*& aString);
|
sl@0
|
79 |
TInt ReadBinaryL(HBufC8*& aString);
|
sl@0
|
80 |
void SkipComments();
|
sl@0
|
81 |
void SkipEqualSign();
|
sl@0
|
82 |
|
sl@0
|
83 |
TInt ReadNumber(TUint32& aVal);
|
sl@0
|
84 |
TInt ReadCapabilityL(TCapability& aCapability);
|
sl@0
|
85 |
void CheckForAlwaysPassOrFailL(TBool& aAlwaysPass,TBool& aAlwaysFail);
|
sl@0
|
86 |
TInt ReadPolicyL(TSecurityPolicy& aPolicy,TInt aPolicyType);
|
sl@0
|
87 |
TInt ReadCapabilitiesL(TSecurityPolicy& aPolicy);
|
sl@0
|
88 |
TInt ReadSidAndCapabilitiesL(TSecurityPolicy& aPolicy,const TDesC& aPolicyType,
|
sl@0
|
89 |
TSecureId& aSid);
|
sl@0
|
90 |
TInt ReadRangePoliciesL(const TSecurityPolicy& aDefaultReadPolicy,const TSecurityPolicy& aDefaultWritePolicy,
|
sl@0
|
91 |
RRangePolicyArray& aRangePolicies);
|
sl@0
|
92 |
TInt ReadRangeMetaDefaultsL(RDefaultMetaArray& aDefaultMetaRanges);
|
sl@0
|
93 |
|
sl@0
|
94 |
|
sl@0
|
95 |
TInt GetPlatSecSectionLC(HBufC*& aSection);
|
sl@0
|
96 |
TInt GetTimeStampSectionLC(HBufC*& aSection);
|
sl@0
|
97 |
TInt GetOwnerSectionLC(HBufC*& aSection) ;
|
sl@0
|
98 |
TInt GetDefaultMetaSectionLC(HBufC*& aSection) ;
|
sl@0
|
99 |
TInt GetSectionLC(const TDesC16& aSectionId, HBufC*& aSection) ;
|
sl@0
|
100 |
CIniFileIn(RFs& aFs):iFs(aFs){}
|
sl@0
|
101 |
private:
|
sl@0
|
102 |
HBufC* iBuf;
|
sl@0
|
103 |
#ifdef CENTREP_TRACE
|
sl@0
|
104 |
HBufC* iFullName;
|
sl@0
|
105 |
#endif
|
sl@0
|
106 |
TLex iLex;
|
sl@0
|
107 |
TLexMark iMainSectionMark;
|
sl@0
|
108 |
RFs iFs;
|
sl@0
|
109 |
//
|
sl@0
|
110 |
};
|
sl@0
|
111 |
|
sl@0
|
112 |
////////////////////////////////////////////////////////////////////////////////////////////////
|
sl@0
|
113 |
//The txt persistence is not needed inside the server but rather for the tool
|
sl@0
|
114 |
#ifdef CENTREP_CONV_TOOL
|
sl@0
|
115 |
|
sl@0
|
116 |
// CIniFileOut class
|
sl@0
|
117 |
enum TCapAccessMode
|
sl@0
|
118 |
{
|
sl@0
|
119 |
ECapReadAccess,
|
sl@0
|
120 |
ECapWriteAccess
|
sl@0
|
121 |
};
|
sl@0
|
122 |
/**
|
sl@0
|
123 |
@internalTechnology
|
sl@0
|
124 |
*/
|
sl@0
|
125 |
class CIniFileOut : public CBase
|
sl@0
|
126 |
{
|
sl@0
|
127 |
public:
|
sl@0
|
128 |
static CIniFileOut* NewLC(RFs& aFs,const TDesC& aOutFileName);
|
sl@0
|
129 |
~CIniFileOut();
|
sl@0
|
130 |
void CommitL();
|
sl@0
|
131 |
|
sl@0
|
132 |
void WriteHeaderL();
|
sl@0
|
133 |
void WriteOwnerSectionL(TUid aOwner);
|
sl@0
|
134 |
void WriteTimeStampL(const TTime& aTime);
|
sl@0
|
135 |
void WriteMetaDataL(TUint32 aDefaultMeta,
|
sl@0
|
136 |
const RDefaultMetaArray& aDefaultMetaRanges);
|
sl@0
|
137 |
|
sl@0
|
138 |
#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
|
sl@0
|
139 |
void WritePlatSecL(const TSettingsAccessPolicy& aDefaultAccessPolicy,
|
sl@0
|
140 |
const RRangePolicyArray& aRangePolicies,TUint32 aCreVersion);
|
sl@0
|
141 |
#else
|
sl@0
|
142 |
void WritePlatSecL(const TSecurityPolicy& aDefaultReadPolicy,
|
sl@0
|
143 |
const TSecurityPolicy& aDefaultWritePolicy,
|
sl@0
|
144 |
const RRangePolicyArray& aRangePolicies);
|
sl@0
|
145 |
#endif
|
sl@0
|
146 |
|
sl@0
|
147 |
void WriteMainSectionHeaderL();
|
sl@0
|
148 |
void WriteSettingL(const TServerSetting& aSetting
|
sl@0
|
149 |
#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
|
sl@0
|
150 |
,TUint32 aCreVersion
|
sl@0
|
151 |
#endif
|
sl@0
|
152 |
);
|
sl@0
|
153 |
void WriteSettingL(const TServerSetting& aSetting,
|
sl@0
|
154 |
const TSettingsAccessPolicy& aAccessPolicy
|
sl@0
|
155 |
#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
|
sl@0
|
156 |
,TUint32 aCreVersion
|
sl@0
|
157 |
#endif
|
sl@0
|
158 |
);
|
sl@0
|
159 |
private:
|
sl@0
|
160 |
CIniFileOut(RFs& aFs);
|
sl@0
|
161 |
void ConstructL(const TDesC& aOutFileName);
|
sl@0
|
162 |
void WriteLineL(const TDesC& aData);
|
sl@0
|
163 |
void AppendSecurityPolicyL(const TSecurityPolicy& aPolicy,
|
sl@0
|
164 |
TCapAccessMode aRdWrMode);
|
sl@0
|
165 |
void DoSettingL(const TServerSetting& aSetting
|
sl@0
|
166 |
#ifdef SYMBIAN_CENTREP_SUPPORT_MULTIROFS
|
sl@0
|
167 |
,TUint32 aCreVersion
|
sl@0
|
168 |
#endif
|
sl@0
|
169 |
);
|
sl@0
|
170 |
|
sl@0
|
171 |
private:
|
sl@0
|
172 |
TBool iCommited;
|
sl@0
|
173 |
RFile iTransFile; //Transaction file
|
sl@0
|
174 |
RFileBuf iTransFileBuf; //Transaction file buffer
|
sl@0
|
175 |
TParse iTransFilePath; //Transaction file name.
|
sl@0
|
176 |
TBuf<KMaxLengthWithPolicyInfo> iBuf;//General purpose buffer, used internally
|
sl@0
|
177 |
HBufC* iOutFileName;
|
sl@0
|
178 |
RFs iFs;
|
sl@0
|
179 |
};
|
sl@0
|
180 |
#endif //CENTREP_CONV_TOOL
|
sl@0
|
181 |
|
sl@0
|
182 |
#endif // __CENREP_INIFILE_H__
|