|
1 /* |
|
2 * Copyright (c) 2004 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: the server implementation of DRM Helper |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef DRMHELPERSERVER_H |
|
20 #define DRMHELPERSERVER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include "DRMHelperCommon.h" |
|
25 #include <DRMEventObserver.h> |
|
26 #include <caf/caf.h> |
|
27 #include <DRMRightsClient.h> // RDRMRightsClient |
|
28 // DATA TYPES |
|
29 // FORWARD DECLARATIONS |
|
30 class CEndTimeBased; |
|
31 class CEndTimeFactory; |
|
32 class RWriteStream; |
|
33 class RReadStream; |
|
34 class CDRMNotifier; |
|
35 class CIdleObserver; |
|
36 class CDRMRights; |
|
37 class CConfigObserver; |
|
38 class CDRMPermission; |
|
39 class CEnvironmentChangeNotifier; |
|
40 |
|
41 // CLASS DECLARATION |
|
42 class TTimeBased |
|
43 { |
|
44 public: |
|
45 void SetStart(const TTime& aStart) {iStartTime = aStart;}; |
|
46 void SetEnd(const TTime& aEnd) {iEndTime = aEnd;}; |
|
47 const TTime& StartTime(){return iStartTime;}; |
|
48 const TTime& EndTime(){return iEndTime;}; |
|
49 private: |
|
50 TTime iStartTime; |
|
51 TTime iEndTime; |
|
52 }; |
|
53 |
|
54 |
|
55 /** |
|
56 * This class implements the DRM5 Helper Server functionality. |
|
57 * |
|
58 * @lib DRMHelperServer.exe |
|
59 * @since S60Rel3.0 |
|
60 */ |
|
61 |
|
62 |
|
63 class CDRMHelperServer : public CServer2 , MDRMEventObserver |
|
64 { |
|
65 public: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Two-phased constructor. |
|
69 * @since S60Rel3.0 |
|
70 * @return Pointer to newly created server instance. And |
|
71 * push the oject into cleanup stack |
|
72 */ |
|
73 static CDRMHelperServer* NewLC(); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 * @since S60Rel3.0 |
|
78 */ |
|
79 ~CDRMHelperServer(); |
|
80 |
|
81 |
|
82 |
|
83 public: // New functions |
|
84 |
|
85 /** |
|
86 * Startup starts the actual DRM Helper server after initializing |
|
87 * the cleanup stack and active scheduler. |
|
88 * @since S60Rel3.0 |
|
89 * @return system error code if error happens |
|
90 */ |
|
91 static TInt Startup(); |
|
92 |
|
93 /** |
|
94 * HandleExpiredL handle expiration case for one item. |
|
95 * @since S60Rel3.0 |
|
96 * @param aUri the specific content uri for this item. |
|
97 * @param aTimes the times that this case has been informed . |
|
98 */ |
|
99 void HandleExpiredL( CEndTimeBased*& aItem ); |
|
100 |
|
101 /** |
|
102 * HandleIdleL inform all the cases that right is about to expire |
|
103 * @since S60Rel3.0 |
|
104 */ |
|
105 void HandleIdleL(); |
|
106 |
|
107 /** |
|
108 * UpdateL update items |
|
109 * @since S60Rel3.0 |
|
110 * @param aUri the specific content uri for this item. |
|
111 * @param aPermType permission type |
|
112 * @param aRegType regist type |
|
113 * @param aAutoType automatic type |
|
114 */ |
|
115 void UpdateL(); |
|
116 void UpdateL( const TDesC8& aUri ); |
|
117 void UpdateL( const TDesC8& aUri , const TUint8& aPermType ); |
|
118 void UpdateL( const TDesC8& aUri , const TUint8& aPermType , const TUint8& aRegType ); |
|
119 void UpdateL( |
|
120 const TDesC8& aUri , |
|
121 const TUint8& aPermType , |
|
122 const TUint8& aRegType , |
|
123 const TUint8& aAutoType ); |
|
124 |
|
125 /** |
|
126 * RegisterL register one item with specific content uri. |
|
127 * @since S60Rel3.0 |
|
128 * @param aUri the specific content uri for this item. |
|
129 * @param aPermType permission type |
|
130 * @param aRegType regist type |
|
131 * @param aAutoType automatic type |
|
132 */ |
|
133 void RegisterL( |
|
134 const TDesC8& aUri , |
|
135 const TUint8& aPermType , |
|
136 const TUint8& aRegType , |
|
137 const TUint8& aAutoType ); |
|
138 |
|
139 |
|
140 /** |
|
141 * IsRegistered register one item with specific content uri. |
|
142 * @since S60Rel3.0 |
|
143 * @param aUri the specific content uri for this item. |
|
144 * @param aPermType permission type |
|
145 * @param aRegType regist type |
|
146 * @param aAutoType automatic type |
|
147 * @return ETrue if registered, otherwise EFalse |
|
148 */ |
|
149 TBool IsRegistered( |
|
150 const TDesC8& aUri , |
|
151 const TUint8& aPermType , |
|
152 const TUint8& aRegType , |
|
153 const TUint8& aAutoType ); |
|
154 /** |
|
155 * IsRegistered register one item with specific content uri. |
|
156 * @since S60Rel3.0 |
|
157 * @param aUri the specific content uri for this item. |
|
158 * @param aPermType permission type |
|
159 * @param aRegType regist type |
|
160 * @return ETrue if registered, otherwise EFalse |
|
161 */ |
|
162 TBool IsRegistered( |
|
163 const TDesC8& aUri , |
|
164 const TUint8& aPermType , |
|
165 const TUint8& aRegType ); |
|
166 |
|
167 |
|
168 /** |
|
169 * IsRegistered register one item with specific content uri. |
|
170 * @since S60Rel3.0 |
|
171 * @param aUri the specific content uri for this item. |
|
172 * @param aRegType regist type |
|
173 * @return ETrue if registered, otherwise EFalse |
|
174 */ |
|
175 TBool IsRegistered2( |
|
176 const TDesC8& aUri , |
|
177 const TUint8& aRegType, |
|
178 const TUint8& aAutoType ); |
|
179 |
|
180 /** |
|
181 * RemoveL remove one item with specific content uri. |
|
182 * @since S60Rel3.0 |
|
183 * @param aPermType permission type |
|
184 * @param aRegType regist type |
|
185 * @param aAutoType automatic type |
|
186 * @param aUri the specific content uri for this item. |
|
187 */ |
|
188 void RemoveL( |
|
189 const TDesC8& aUri , |
|
190 const TUint8& aPermType , |
|
191 const TUint8& aRegType , |
|
192 const TUint8& aAutoType ); |
|
193 |
|
194 /** |
|
195 * StoreL store the list into data file |
|
196 * @since S60Rel3.0 |
|
197 */ |
|
198 void StoreL(); |
|
199 |
|
200 /** |
|
201 * RestoreL restore the list from data file |
|
202 * @since S60Rel3.0 |
|
203 */ |
|
204 void RestoreL(); |
|
205 |
|
206 /** |
|
207 * ExternalizeL externalize the list into data file |
|
208 * @param aStream the data file stream. |
|
209 * @since S60Rel3.0 |
|
210 */ |
|
211 void ExternalizeL(RWriteStream& aStream) const; |
|
212 |
|
213 /** |
|
214 * InternalizeL internalize the list from data file |
|
215 * @param aStream the data file stream. |
|
216 * @since S60Rel3.0 |
|
217 */ |
|
218 void InternalizeL(RReadStream& aStream); |
|
219 |
|
220 /** |
|
221 * RemoveAllL remove all the items in the list |
|
222 * @since S60Rel3.0 |
|
223 */ |
|
224 void RemoveAllL(); |
|
225 |
|
226 /** |
|
227 * GetNotificationL register one item to notifier in order to get notification if rights changed |
|
228 * @since S60Rel3.0 |
|
229 * @param aUri the content uri for the item. |
|
230 */ |
|
231 void GetNotificationL(const TDesC8& aUri); |
|
232 |
|
233 /** |
|
234 * RemoveNotificationL unregister item from notifier |
|
235 * @since S60Rel3.0 |
|
236 * @param aUri the content uri for the item. |
|
237 */ |
|
238 void RemoveNotificationL(const TDesC8& aUri); |
|
239 |
|
240 /** |
|
241 * UiTimeChanged |
|
242 * |
|
243 * callback function for CEnvironmentChangeNotifier when UI time is changed |
|
244 * @since S60Rel2.6 |
|
245 * @param aPointer a Helper Server instance |
|
246 */ |
|
247 static TInt UiTimeChanged(void* aPointer); |
|
248 |
|
249 public: // Functions from base classes |
|
250 /** |
|
251 * HandleEventL from MDRMEventObserver |
|
252 * @since S60Rel3.0 |
|
253 * @param aEvent an event from DRM notifier |
|
254 */ |
|
255 void HandleEventL( MDRMEvent* aEvent ); |
|
256 protected: // New functions |
|
257 |
|
258 protected: // Functions from base classes |
|
259 //class CServer |
|
260 /** |
|
261 * RunError. |
|
262 * @since S60Rel3.0 |
|
263 * @param aError Error code from RunL function. |
|
264 * @return An error is returned if RunError() cannot process the |
|
265 * error. |
|
266 */ |
|
267 TInt RunError( TInt aError ); |
|
268 |
|
269 private: |
|
270 /** |
|
271 * C++ default constructor. |
|
272 * @since S60Rel3.0 |
|
273 */ |
|
274 CDRMHelperServer(); |
|
275 |
|
276 /** |
|
277 * By default Symbian 2nd phase constructor is private. |
|
278 * @since S60Rel3.0 |
|
279 */ |
|
280 void ConstructL(); |
|
281 |
|
282 /** |
|
283 * @function PanicClient |
|
284 * @semantics panic the client |
|
285 * @param aMessage the message channel to the client |
|
286 * @param aReason the reason code for the panic. |
|
287 */ |
|
288 static void PanicClient(const RMessage2& aMessage, TDRMHelperServPanic aReason); |
|
289 |
|
290 /*! |
|
291 * @function PanicServer |
|
292 * @semantics panic the server |
|
293 * @param aReason the reason code for the panic. |
|
294 */ |
|
295 static void PanicServer(TDRMHelperServPanic aReason); |
|
296 |
|
297 /** |
|
298 * StartupL called by StartUp |
|
299 * @since S60Rel3.0 |
|
300 */ |
|
301 static void StartupL(); |
|
302 |
|
303 /** |
|
304 * CheckExpiration check the expiration info for one content uri |
|
305 * @since S60Rel3.0 |
|
306 * @param aUri content uri. |
|
307 * @param aEndTime end time for rights. |
|
308 * @param aPermType permission type |
|
309 * @param aRegType regist type |
|
310 * @return CDRMRights::EFullRights or DRMCommon::ENoRights or EOk |
|
311 */ |
|
312 void CheckExpirationL( |
|
313 const TDesC8& aUri , |
|
314 const TUint8& aPermType , |
|
315 const TUint8& aRegType , |
|
316 TTime& aEndTime ); |
|
317 |
|
318 /** |
|
319 * SetKeyValueL set key value for CenRep structure |
|
320 * @since S60Rel3.0 |
|
321 * @param aKeyValue key value. |
|
322 */ |
|
323 void SetKeyValueL( const TDesC8& aKeyValue , const TUint8& aRegType ); |
|
324 |
|
325 /** |
|
326 * FormatKeyValueL format key value for CenRep structure |
|
327 * |
|
328 * @since S60Rel3.0 |
|
329 * @param aBuf key value. it is pushed into cleanup stack |
|
330 * @param aUri the specific content uri for this item. |
|
331 * @param aTimes the times that this case has been informed. |
|
332 * @param aMark 'E' if expired 'V' if about to expire |
|
333 */ |
|
334 void FormatKeyValueLC( HBufC8*& aBuf , CEndTimeBased*& aItem , const TDesC8& aMark ); |
|
335 |
|
336 /** |
|
337 * CheckPermission get time based info from permission |
|
338 * |
|
339 * @since S60Rel3.0 |
|
340 * @param aPermission permission from DRM Rights database |
|
341 * @param aPermType permission type |
|
342 * @param aTime to store start and end time |
|
343 * @param aInterval to store time interval |
|
344 * @param aIndividual to check invididual constraints |
|
345 * @return |
|
346 */ |
|
347 void CheckPermission( |
|
348 CDRMPermission* aPermission , |
|
349 const TUint8& aPermType , |
|
350 TTimeBased& aTime , |
|
351 TTimeIntervalSeconds& aInterval, |
|
352 const RPointerArray<HBufC8>& aIndividual ); |
|
353 |
|
354 ContentAccess::TIntent MapPermissionType(TUint8 aPermType); |
|
355 private: // Functions from base classes |
|
356 // Class CServer |
|
357 /** |
|
358 * NewSessionL |
|
359 * @since S60Rel3.0 |
|
360 */ |
|
361 CSession2* NewSessionL( const TVersion& aVersion, |
|
362 const RMessage2& aMessage ) const; |
|
363 |
|
364 public: // Data |
|
365 //opcodes used in message passing between client and server |
|
366 enum TDRMHSServiceType |
|
367 { |
|
368 EActive = 101, |
|
369 EPassive = 102 |
|
370 }; |
|
371 protected: // Data |
|
372 |
|
373 private: // Data |
|
374 CEndTimeFactory* iEndTimeFactory; |
|
375 CDRMNotifier* iNotifier; |
|
376 CIdleObserver* iIdleObserver; |
|
377 CEnvironmentChangeNotifier* iUiTimeNotifier; |
|
378 RFs iFs; |
|
379 RDRMRightsClient iDrm; |
|
380 public: // Friend classes |
|
381 |
|
382 protected: // Friend classes |
|
383 |
|
384 private: // Friend classes |
|
385 |
|
386 }; |
|
387 |
|
388 |
|
389 |
|
390 #endif // DRMHELPERSERVER_H |
|
391 |
|
392 // End of File |