|
1 /* |
|
2 * Copyright (c) 2007-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 "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: Datatype for Rights Constraint |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DRMCONSTRAINT_H |
|
20 #define DRMCONSTRAINT_H |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <e32base.h> |
|
25 #include "DRMTypes.h" |
|
26 |
|
27 // CONSTANTS |
|
28 |
|
29 // MACROS |
|
30 |
|
31 // DATA TYPES |
|
32 |
|
33 // FORWARD DECLARATIONS |
|
34 class RReadStream; |
|
35 class RWriteStream; |
|
36 |
|
37 // TYPE DEFINITIONS |
|
38 |
|
39 // FUNCTION PROTOTYPES |
|
40 |
|
41 // CLASS DECLARATION |
|
42 |
|
43 /** |
|
44 * CDRMConstraint implements a constraint for OMA DRM usage |
|
45 * |
|
46 * @lib DrmRights.dll |
|
47 * @since S60 3.0 |
|
48 */ |
|
49 |
|
50 class CDRMConstraint : public CBase |
|
51 { |
|
52 |
|
53 public: |
|
54 |
|
55 struct TDrmMeteringInfo |
|
56 { |
|
57 TDrmMeteringInfo() : |
|
58 iGraceTime( 0 ), |
|
59 iAllowUseWithoutMetering( EFalse ){}; |
|
60 |
|
61 TTimeIntervalSeconds iGraceTime; |
|
62 TBool iAllowUseWithoutMetering; |
|
63 }; |
|
64 |
|
65 public: // Constructors and destructor |
|
66 /** |
|
67 * NewLC |
|
68 * |
|
69 * Creates a new CDRMConstraint object and returns a pointer to it. |
|
70 * The function leaves the object to the cleanup stack. |
|
71 * |
|
72 * @since 3.0 |
|
73 * @return a functional CDRMConstraint object, The function leaves |
|
74 * with SymbianOS error code if an error occurs. |
|
75 */ |
|
76 IMPORT_C static CDRMConstraint* NewLC(); |
|
77 |
|
78 /** |
|
79 * NewL |
|
80 * |
|
81 * Creates a new CDRMConstraint object and returns a pointer to it. |
|
82 * |
|
83 * @since 3.0 |
|
84 * @return a functional CDRMConstraint object, The function leaves |
|
85 * with SymbianOS error code if an error occurs. |
|
86 */ |
|
87 IMPORT_C static CDRMConstraint* NewL(); |
|
88 |
|
89 /* |
|
90 * Destructor |
|
91 */ |
|
92 IMPORT_C virtual ~CDRMConstraint(); |
|
93 |
|
94 |
|
95 public: // New functions |
|
96 /** |
|
97 * ExternalizeL |
|
98 * |
|
99 * Writes the data of the object into the stream |
|
100 * |
|
101 * @since 3.0 |
|
102 * @param aStream : the output stream to write to |
|
103 * @return The function leaves with Symbian OS error code if an |
|
104 * error occurs |
|
105 */ |
|
106 IMPORT_C void ExternalizeL( RWriteStream& aStream ) const; |
|
107 |
|
108 /** |
|
109 * InternalizeL |
|
110 * |
|
111 * Reads the data of the object from the stream |
|
112 * |
|
113 * @since 3.0 |
|
114 * @param aStream : the output stream to write to |
|
115 * @return The function leaves with Symbian OS error code if an |
|
116 * error occurs |
|
117 */ |
|
118 IMPORT_C void InternalizeL( RReadStream& aStream ); |
|
119 |
|
120 |
|
121 /** |
|
122 * Stateful |
|
123 * |
|
124 * The function checks if the constraint is stateful |
|
125 * |
|
126 * @since 3.0 |
|
127 * @return returns ETrue if the constraint is stateful |
|
128 * EFalse if it is not. |
|
129 */ |
|
130 IMPORT_C TBool Stateful() const; |
|
131 |
|
132 /** |
|
133 * Size |
|
134 * |
|
135 * returns the size of the externalized object |
|
136 * |
|
137 * @since 3.0 |
|
138 * @return returns the size of the constraint |
|
139 */ |
|
140 IMPORT_C TInt Size() const; |
|
141 |
|
142 /** |
|
143 * Expired |
|
144 * |
|
145 * returns a boolean valua about the validity of the constraint |
|
146 * Future rights are considered not be be expired and EFalse |
|
147 * is returned for them |
|
148 * |
|
149 * @since 3.0 |
|
150 * @param aTime : current secure time, if the time is |
|
151 * Time::NullTTime() time based constraints |
|
152 * will not be considered to be expised and |
|
153 * EFalse is returned for them |
|
154 * @return returns ETrue if the constraint is expired |
|
155 * EFalse if the constraint is not expired |
|
156 * |
|
157 */ |
|
158 IMPORT_C TBool Expired( const TTime& aTime ) const; |
|
159 |
|
160 /** |
|
161 * Merge |
|
162 * |
|
163 * Merges the two constraints |
|
164 * |
|
165 * @since 3.0 |
|
166 * @param aConstraint : the constraint merged to this one |
|
167 * @return none |
|
168 */ |
|
169 IMPORT_C void Merge( const CDRMConstraint& aConstraint ); |
|
170 |
|
171 |
|
172 /** |
|
173 * Consume |
|
174 * |
|
175 * Consumes rights |
|
176 * |
|
177 * @since 3.0 |
|
178 * @param aCurrentTime : The current secure time |
|
179 * @return none |
|
180 */ |
|
181 IMPORT_C void Consume( const TTime& aCurrentTime ); |
|
182 |
|
183 |
|
184 /** |
|
185 * DuplicateL |
|
186 * |
|
187 * copies all data from the given constraint to the current one |
|
188 * |
|
189 * @since 3.0 |
|
190 * @param aConstraint : the constraint to copy from |
|
191 * @return none, Leaves with symbian OS error code if an error occurs |
|
192 */ |
|
193 IMPORT_C void DuplicateL( const CDRMConstraint& aConstraint ); |
|
194 |
|
195 /** |
|
196 * Valid |
|
197 * |
|
198 * returns if the constraint is valid/usable at this time |
|
199 * |
|
200 * @since 3.0 |
|
201 * @param aTime : current secure time, if the time is |
|
202 * Time::NullTTime() time based constraints |
|
203 * will be considered to be invalid |
|
204 * @param aIndividual : the imsi of the phone |
|
205 * @param aRejection : return value for why the content was rejected |
|
206 * @return returns ETrue if the constraint is valid |
|
207 * EFalse if the constraint is not valid |
|
208 */ |
|
209 IMPORT_C TBool Valid( const TTime& aTime, |
|
210 const RPointerArray<HBufC8>& aIndividual, |
|
211 TUint32& aRejection ) const; |
|
212 |
|
213 public: |
|
214 |
|
215 // synchronizing marker |
|
216 TInt32 iSyncMark; |
|
217 |
|
218 // version number |
|
219 TInt32 iVersion; |
|
220 |
|
221 // usage start time |
|
222 TTime iStartTime; |
|
223 |
|
224 // usage end time |
|
225 TTime iEndTime; |
|
226 |
|
227 // interval start time |
|
228 TTime iIntervalStart; |
|
229 |
|
230 // interval duration |
|
231 TTimeIntervalSeconds iInterval; |
|
232 |
|
233 // counter |
|
234 TDRMCounter iCounter; |
|
235 |
|
236 // original counter value |
|
237 TDRMCounter iOriginalCounter; |
|
238 |
|
239 // timed counter |
|
240 TDRMCounter iTimedCounter; |
|
241 |
|
242 // Interval of the timed counter constraint |
|
243 TTimeIntervalSeconds iTimedInterval; |
|
244 |
|
245 // accumulated time |
|
246 TTimeIntervalSeconds iAccumulatedTime; |
|
247 |
|
248 // individual allowed usage |
|
249 RPointerArray<HBufC8> iIndividual; |
|
250 |
|
251 // Software Vendor Id |
|
252 TUid iVendorId; |
|
253 |
|
254 // Secure Id of the allowed application |
|
255 TUid iSecureId; |
|
256 |
|
257 // Bitmask of active constraints |
|
258 TUint32 iActiveConstraints; // Bitmask |
|
259 |
|
260 // Metering allowance information |
|
261 TDrmMeteringInfo* iDrmMeteringInfo; |
|
262 |
|
263 // system allowed usage |
|
264 RPointerArray<HBufC8> iSystem; |
|
265 |
|
266 // Original timed counter |
|
267 TDRMCounter iOriginalTimedCounter; |
|
268 |
|
269 protected: |
|
270 |
|
271 /* |
|
272 * Default Constructor |
|
273 */ |
|
274 IMPORT_C CDRMConstraint(); |
|
275 |
|
276 private: |
|
277 |
|
278 /** |
|
279 * 2nd phase constructor |
|
280 */ |
|
281 void ConstructL(); |
|
282 |
|
283 /** |
|
284 * Copy constructor. |
|
285 */ |
|
286 CDRMConstraint( const CDRMConstraint& aConstraint ); // Prevented |
|
287 |
|
288 /** |
|
289 * WriteInt64L |
|
290 * |
|
291 * Writes the 64 bit integer to the stream |
|
292 * |
|
293 * @since 3.0 |
|
294 * @param aWrite : the 64 bit integer to write |
|
295 * @param aStream : the output stream to write to |
|
296 * @return The function leaves with Symbian OS error code if an |
|
297 * error occurs |
|
298 */ |
|
299 void WriteInt64L( const TInt64& aWrite, RWriteStream& aStream ) const; |
|
300 |
|
301 /** |
|
302 * ReadInt64L |
|
303 * |
|
304 * Reads the 64 bit integer from the stream |
|
305 * |
|
306 * @since 3.0 |
|
307 * @param aRead : the 64 bit integer read |
|
308 * @param aStream : the output stream to write to |
|
309 * @return The function leaves with Symbian OS error code if an |
|
310 * error occurs |
|
311 */ |
|
312 void ReadInt64L( TInt64& aRead, RReadStream& aStream ); |
|
313 }; |
|
314 |
|
315 #endif // DRMCONSTRAINT_H |
|
316 |
|
317 // End of File |