|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 #include <rtsecmgrutility.h> |
|
23 #include <rtsecmgrscript.h> |
|
24 #include <s32mem.H> |
|
25 |
|
26 const TReal DEFAULT_VERSION(1.0); |
|
27 // --------------------------------------------------------------------------- |
|
28 // Destructor |
|
29 // --------------------------------------------------------------------------- |
|
30 // |
|
31 EXPORT_C CScript::~CScript() |
|
32 { |
|
33 delete iPermissionSet; |
|
34 if(iHashMark) |
|
35 delete iHashMark; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // Two-phased constructor |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C CScript* CScript::NewL(TPolicyID aPolicyID,TExecutableID aScriptID) |
|
43 { |
|
44 CScript* self = CScript::NewLC(aPolicyID,aScriptID); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // Two-phased constructor |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CScript* CScript::NewLC(TPolicyID aPolicyID,TExecutableID aScriptID) |
|
54 { |
|
55 CScript* self = new (ELeave) CScript(aPolicyID,aScriptID); |
|
56 CleanupStack::PushL(self); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // Two-phased constructor |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void CScript::ConstructL() |
|
66 { |
|
67 iPermissionSet = CPermissionSet::NewL (); |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Overloaded assignment operator |
|
72 // --------------------------------------------------------------------------- |
|
73 // |
|
74 EXPORT_C const CScript& CScript::operator=(const CScript& aRhs) |
|
75 { |
|
76 if(iPermissionSet ) |
|
77 { |
|
78 delete iPermissionSet; |
|
79 iPermissionSet = NULL; |
|
80 } |
|
81 |
|
82 iPermissionSet = CPermissionSet::NewL(*aRhs.iPermissionSet); |
|
83 iScriptID = aRhs.iScriptID; |
|
84 iPolicyID = aRhs.iPolicyID; |
|
85 iPermGrant = aRhs.iPermGrant; |
|
86 iPermDenied = aRhs.iPermDenied; |
|
87 |
|
88 if(iHashMark) |
|
89 { |
|
90 delete iHashMark; |
|
91 iHashMark = NULL; |
|
92 } |
|
93 |
|
94 if(aRhs.iHashMark) |
|
95 { |
|
96 iHashMark = aRhs.iHashMark->AllocLC(); |
|
97 CleanupStack::Pop(iHashMark); |
|
98 } |
|
99 return *this; |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Gets script identifier |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 EXPORT_C TExecutableID CScript::ScriptID() const |
|
107 { |
|
108 return iScriptID; |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------------------------- |
|
112 // Gets policy identifier |
|
113 // --------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C TPolicyID CScript::PolicyID() const |
|
116 { |
|
117 return iPolicyID; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // Sets permission set data of the script |
|
122 // --------------------------------------------------------------------------- |
|
123 // |
|
124 EXPORT_C void CScript::SetPermissionSet(const CPermissionSet& aPermSet) |
|
125 { |
|
126 if ( iPermissionSet) |
|
127 { |
|
128 delete iPermissionSet; |
|
129 iPermissionSet=NULL; |
|
130 } |
|
131 |
|
132 iPermissionSet = CPermissionSet::NewL (aPermSet); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Gets permission set data of the script |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C const CPermissionSet& CScript::PermissionSet() const |
|
140 { |
|
141 return *iPermissionSet; |
|
142 } |
|
143 // --------------------------------------------------------------------------- |
|
144 // Gets permission set data of the script |
|
145 // --------------------------------------------------------------------------- |
|
146 // |
|
147 EXPORT_C CPermissionSet& CScript::PermissionSet() |
|
148 { |
|
149 return *iPermissionSet; |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // Gets permanently granted permissions of the script |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 EXPORT_C TPermGrant CScript::PermGranted() const |
|
157 { |
|
158 return iPermGrant; |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // Gets permanently denied permissions of the script |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 EXPORT_C TPermGrant CScript::PermDenied() const |
|
166 { |
|
167 return iPermDenied; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // ExternalizeLs script data to stream |
|
172 // --------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C void CScript::ExternalizeL(RWriteStream& aSink) const |
|
175 { |
|
176 aSink.WriteReal32L(DEFAULT_VERSION); |
|
177 iPermissionSet->ExternalizeL (aSink); |
|
178 aSink.WriteInt32L (iScriptID); |
|
179 aSink.WriteInt32L (iPolicyID); |
|
180 aSink.WriteUint32L (iPermGrant); |
|
181 aSink.WriteUint32L (iPermDenied); |
|
182 if(iHashMark) |
|
183 { |
|
184 aSink.WriteUint32L(iHashMark->Length()); |
|
185 aSink.WriteL(*iHashMark,iHashMark->Length()); |
|
186 } |
|
187 else |
|
188 aSink.WriteInt32L(0); |
|
189 } |
|
190 |
|
191 // --------------------------------------------------------------------------- |
|
192 // InternalizeLs script data from stream |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 EXPORT_C void CScript::InternalizeL(RReadStream& aSource) |
|
196 { |
|
197 if ( iPermissionSet) |
|
198 { |
|
199 delete iPermissionSet; |
|
200 iPermissionSet=NULL; |
|
201 iPermissionSet = CPermissionSet::NewL (); |
|
202 } |
|
203 TReal version(aSource.ReadReal32L()); |
|
204 iPermissionSet->InternalizeL (aSource); |
|
205 iScriptID = aSource.ReadInt32L (); |
|
206 iPolicyID = aSource.ReadInt32L (); |
|
207 iPermGrant = aSource.ReadUint32L (); |
|
208 iPermDenied = aSource.ReadUint32L (); |
|
209 TInt hashMarkLen(aSource.ReadUint32L()); |
|
210 if(iHashMark) |
|
211 { |
|
212 delete iHashMark; |
|
213 iHashMark = NULL; |
|
214 } |
|
215 |
|
216 if(hashMarkLen) |
|
217 { |
|
218 iHashMark = HBufC::NewL(hashMarkLen); |
|
219 TPtr ptr(iHashMark->Des()); |
|
220 aSource.ReadL(ptr,hashMarkLen); |
|
221 } |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // Sets permanently granted permissions of the script |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C void CScript::SetPermGranted(TPermGrant aPermGrant) |
|
229 { |
|
230 iPermGrant = aPermGrant; |
|
231 } |
|
232 |
|
233 // --------------------------------------------------------------------------- |
|
234 // Sets permanently denied permissions of the script |
|
235 // --------------------------------------------------------------------------- |
|
236 // |
|
237 EXPORT_C void CScript::SetPermDenied(TPermGrant aPermDenied) |
|
238 { |
|
239 iPermDenied = aPermDenied; |
|
240 } |