|
1 /* |
|
2 * Copyright (c) 2000 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Implementation of policymanagement components |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef REPOSITORY_SESSION_HEADER_ |
|
21 #define REPOSITORY_SESSION_HEADER_ |
|
22 |
|
23 // INCLUDES |
|
24 |
|
25 #include <e32base.h> |
|
26 #include <f32file.h> |
|
27 #include <s32file.h> |
|
28 #include <s32strm.h> |
|
29 |
|
30 #include "constants.h" |
|
31 #include "IniFileHelper.h" |
|
32 |
|
33 // CONSTANTS |
|
34 // MACROS |
|
35 // DATA TYPES |
|
36 // FUNCTION PROTOTYPES |
|
37 // FORWARD DECLARATIONS |
|
38 |
|
39 class CRepositorySession; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 class CRepositoryContent : public CBase |
|
44 { |
|
45 public: |
|
46 //constructors |
|
47 ~CRepositoryContent(); |
|
48 |
|
49 static CRepositoryContent * NewL( const TUid& aUid); |
|
50 static CRepositoryContent * NewL( const TUid& aUid, HBufC* aContent); |
|
51 |
|
52 void ReleaseResources(); |
|
53 |
|
54 //file streaming |
|
55 void ReadStreamL( RReadStream& aStream, TBool aOnlyHeader ); |
|
56 void WriteStreamL( RWriteStream& aStream ); |
|
57 |
|
58 |
|
59 //File reading |
|
60 void ReadHeaderL(); |
|
61 void ReadOptionalDataL(); |
|
62 void ReadPlatSecL(); |
|
63 void ReadMainL(); |
|
64 |
|
65 //File writing |
|
66 void WriteFileL( RFile& aFile); |
|
67 |
|
68 //Search setting |
|
69 CIndividualSetting* FindIndividualSetting( const TUint32 aSettingId); |
|
70 void CreateRangeSettingsL( RPointerArray<CRangeSetting>& aSettings, TUint32 aRangeStart, TUint32 aRangeEnd); |
|
71 void CreateMaskSettingsL( RPointerArray<CRangeSetting>& aSettings, TUint32 aCompareValue, TUint32 aMask); |
|
72 void CreateMaskBackupL( RPointerArray<CRangeMeta>& aSettings, TUint32 aCompareValue, TUint32 aMask); |
|
73 void CreateRangeBackupL( RPointerArray<CRangeMeta>& aSettings, TUint32 aRangeStart, TUint32 aRangeEnd); |
|
74 |
|
75 TBool CheckRangeValidity(); |
|
76 |
|
77 TBool CheckAccess( const RMessage2& aMessage, TUint32 aSettingId, TAccessType aAccessType); |
|
78 private: |
|
79 //private constructors |
|
80 CRepositoryContent( const TUid& aUid); |
|
81 CRepositoryContent( const TUid& aUid, HBufC* aContent); |
|
82 void ConstructL(); |
|
83 |
|
84 //repository file management |
|
85 void DeleteRepositoryFile(); |
|
86 void CREFileCreationOk( TBool aState); |
|
87 |
|
88 //setting handling methods |
|
89 CIndividualSetting* FindSettingOrCreateL( const TUint32& aSettingId); |
|
90 void AddIndividualSettingL( CIndividualSetting* aSetting); |
|
91 TInt SingleSecuritySettingsCount(); |
|
92 private: |
|
93 CDefaultSetting * iDefaultSetting; |
|
94 TUint32 iDefaultMeta; |
|
95 RPointerArray<CRangeSetting> iRangeSettings; |
|
96 RPointerArray<CRangeMeta> iRangeMetas; |
|
97 RPointerArray<CIndividualSetting> iIndividualSettings; |
|
98 |
|
99 TPtrC iContentPtr; |
|
100 TPtrC iHeaderPtr; |
|
101 TPtrC iOwnerPtr; |
|
102 TPtrC iDefaultMetaPtr; |
|
103 |
|
104 HBufC* iContent; |
|
105 |
|
106 //repository info |
|
107 TUid iUid; |
|
108 TUid iOwner; |
|
109 TTime iTimeStamp ; |
|
110 |
|
111 TInt iSingleSecuritySettingCount; |
|
112 |
|
113 friend class CRepositorySession; |
|
114 }; |
|
115 |
|
116 class CRepositorySession : public CObject |
|
117 { |
|
118 public: |
|
119 |
|
120 CRepositorySession( TUid aRepositoryId); |
|
121 ~CRepositorySession(); |
|
122 |
|
123 static CRepositorySession * NewL( TUid aRepositoryId); |
|
124 |
|
125 //repository management |
|
126 void InitRepositorySessionL(); |
|
127 void CommitRepositoryL(); |
|
128 |
|
129 void SetSecurityIdForSettingL( const RMessage2& aMessage); |
|
130 void SetSecurityIdForRangeL( const RMessage2& aMessage); |
|
131 void SetSecurityIdForMaskL( const RMessage2& aMessage); |
|
132 |
|
133 void RestoreSettingL( const RMessage2& aMessage); |
|
134 void RestoreRangeL( const RMessage2& aMessage); |
|
135 |
|
136 void AddSidForDefaultsL( const RMessage2& aMessage); |
|
137 void RestoreDefaultsL( const RMessage2& aMessage); |
|
138 void RestoreMaskL( const RMessage2& aMessage); |
|
139 |
|
140 void RemoveBackupForMaskL( const RMessage2& aMessage); |
|
141 void RestoreMaskBackupL( const RMessage2& aMessage); |
|
142 void RemoveBackupForRangeL( const RMessage2& aMessage); |
|
143 void RestoreRangeBackupL( const RMessage2& aMessage); |
|
144 void RemoveDefaultBackup(); |
|
145 void RestoreDefaultBackupL(); |
|
146 |
|
147 void CheckAccessL( const RMessage2& aMessage); |
|
148 |
|
149 //Commit functions |
|
150 static void CheckCommitStateL(); |
|
151 private: |
|
152 //File reading |
|
153 void ReadFileL(); |
|
154 |
|
155 //Utility |
|
156 void ReleaseResources(); |
|
157 void CheckRepositoryState( TInt& aFileOpenResult); |
|
158 |
|
159 |
|
160 TInt ReadRAML( TBool aOnlyHeader); |
|
161 void CreateAndReadROML(); |
|
162 CRepositoryContent* ReadROMFileL( TBool aReadSettings); |
|
163 |
|
164 //Backup handling |
|
165 void MakeBackupL( RFile& aFile); |
|
166 static void RestoreBackupL(); |
|
167 static void RemoveBackupL(); |
|
168 static TInt CreatePath(); |
|
169 |
|
170 private: |
|
171 //repository specific data |
|
172 TUid iRepositoryId; |
|
173 RFs iFs; |
|
174 RFile iFile; |
|
175 TBool iStreamed; //if file repository is opened as a streamed this flag is set TRUE (*.CRE files are streamed) |
|
176 TBool iRepositoryInUse; |
|
177 |
|
178 |
|
179 //file is restored if commit is not called before close!! |
|
180 TBuf<IniConstants::KUidLengthRep> iRepName; |
|
181 |
|
182 CRepositoryContent* iRepContent; |
|
183 }; |
|
184 |
|
185 |
|
186 #endif |