|
1 /* |
|
2 * Copyright (c) 2003 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: DRM3 Engine manages all DRM related database operations. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef CDRMRIGHTSSERVER_H |
|
20 #define CDRMRIGHTSSERVER_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 #include <abclient.h> |
|
26 #include "drmcommonclientserver.h" |
|
27 #include "drmreplaycache.h" |
|
28 #include "drmmeteringdb.h" |
|
29 #include "drmclockclient.h" |
|
30 #include "dbwatcher.h" |
|
31 #include "procwatcher.h" |
|
32 #include "watcherobserver.h" |
|
33 |
|
34 // FORWARD DECLARATIONS |
|
35 class CDRMRightsDB; |
|
36 class CDRMNotifier; |
|
37 class CDRMClock; |
|
38 class CDRMXOma; |
|
39 class CDRMBackupObserver; |
|
40 class CDRMBackup; |
|
41 class RMobilePhone; |
|
42 |
|
43 // CLASS DECLARATION |
|
44 |
|
45 /** |
|
46 * This class implements the DRM5 Rights Server functionality. |
|
47 * |
|
48 * @lib RightsServer.exe |
|
49 * @since S60Rel2.5 |
|
50 */ |
|
51 NONSHARABLE_CLASS( CDRMRightsServer ) : public CServer2, public MWatcherObserver |
|
52 { |
|
53 public: // Constructors and destructor |
|
54 |
|
55 /** |
|
56 * Two-phased constructor. |
|
57 * @since S60Rel2.5 |
|
58 * @return Pointer to newly created server instance. |
|
59 */ |
|
60 static CDRMRightsServer* NewL(); |
|
61 |
|
62 /** |
|
63 * Destructor. |
|
64 * @since S60Rel2.5 |
|
65 */ |
|
66 ~CDRMRightsServer(); |
|
67 |
|
68 public: // New functions |
|
69 |
|
70 /** |
|
71 * This method returns a handle to DRM Notifier. |
|
72 * @since S60Rel2.6 |
|
73 * @return Handle to DRM Notifier. |
|
74 */ |
|
75 CDRMNotifier& Notifier(); |
|
76 |
|
77 /** |
|
78 * This method starts the ROAP storage server |
|
79 * |
|
80 * @since S60Rel3.0 |
|
81 */ |
|
82 void StartRoapStorageL(); |
|
83 |
|
84 /** |
|
85 * This method returns the handle to the rights database. |
|
86 * |
|
87 * @since S60Rel2.6 |
|
88 * @return Handle to the rights database. |
|
89 */ |
|
90 CDRMRightsDB& Database(); |
|
91 |
|
92 RFs& FileServerSession(); |
|
93 |
|
94 /** |
|
95 * This method returns the handle to the metering database. |
|
96 * |
|
97 * @since S60 3.2 |
|
98 * @return Handle to the metering database. |
|
99 */ |
|
100 RDrmMeteringDb& MeteringDatabase(); |
|
101 |
|
102 RDRMReplayCache& ReplayCache(); |
|
103 |
|
104 /** |
|
105 * List of the contents which may have rights objects on the way |
|
106 * |
|
107 * @since 2.6 |
|
108 * @return |
|
109 */ |
|
110 RPointerArray<CDRMXOma>& XOmaHeaders( void ); |
|
111 |
|
112 /** |
|
113 * This function is used to get the secure time. |
|
114 * |
|
115 * @since S60Rel2.5 |
|
116 * @param aTime Out-parameter where the time is stored. |
|
117 * @return Truth value: Is the time a secure time or not. |
|
118 */ |
|
119 TBool GetSecureTime( TTime& aTime ) const; |
|
120 |
|
121 /** |
|
122 * |
|
123 */ |
|
124 const TDesC& GetIMEIL(); |
|
125 |
|
126 /** |
|
127 * |
|
128 */ |
|
129 const CDRMPointerArray<HBufC8>& GetIMSIL(); |
|
130 |
|
131 /** |
|
132 * This function is used to handle backup restore events for |
|
133 * the DRM system |
|
134 */ |
|
135 void HandleBackupEventL( TInt aBackupEvent ); |
|
136 |
|
137 /** |
|
138 * Checks if a content ID is in the list of currently consumed contents |
|
139 * with count constraints |
|
140 * |
|
141 * @since 3.0 |
|
142 * @param aContentId content ID to search for |
|
143 * @return ETrue if the content ID is in the list |
|
144 */ |
|
145 TBool HasActiveCountConstraint( const TDesC8& aContentId ); |
|
146 |
|
147 /** |
|
148 * Removes a content ID from the list of currently consumed contents |
|
149 * with count constraints |
|
150 * |
|
151 * @since 3.0 |
|
152 * @param aContentId content ID to remove |
|
153 */ |
|
154 void RemoveActiveCountConstraint( const TDesC8& aContentId ); |
|
155 |
|
156 /** |
|
157 * Adds a content ID to the list of currently consumed contents |
|
158 * with count constraints |
|
159 * |
|
160 * @since 3.0 |
|
161 * @param aContentId content ID to add |
|
162 */ |
|
163 void AddActiveCountConstraintL( const TDesC8& aContentId ); |
|
164 |
|
165 /** |
|
166 * Import rights objects on startup |
|
167 * |
|
168 * @since 3.0 |
|
169 * @param aImportDir Directory to import from |
|
170 */ |
|
171 void ImportRightsObjectsL( const TDesC& aImportDir ); |
|
172 |
|
173 /** |
|
174 * Stop watching the DCF repository server and the rights DB |
|
175 * @since 3.1 |
|
176 */ |
|
177 void StopWatchingL(); |
|
178 |
|
179 public: // Functions from base classes |
|
180 |
|
181 //class MBackupOperationObserver |
|
182 |
|
183 /** |
|
184 * HandleNotifyL |
|
185 * @since S60Rel2.5 |
|
186 * @param aBackupOperationAttributes Event related attributes. |
|
187 */ |
|
188 void HandleNotifyL(const TUid aUid, const TDesC& aKey, |
|
189 const TDesC& aValue); |
|
190 |
|
191 //class MWatcherObserver |
|
192 |
|
193 /** |
|
194 * Called when the RDB has been modified |
|
195 * |
|
196 * @since S60 3.0 |
|
197 * @param aObject Changed directory |
|
198 */ |
|
199 void WatchedObjectChangedL( const TDesC& aObject ); |
|
200 |
|
201 protected: // New functions |
|
202 |
|
203 protected: // Functions from base classes |
|
204 |
|
205 //class CServer |
|
206 /** |
|
207 * RunError. |
|
208 * @since S60Rel2.5 |
|
209 * @param aError Error code from RunL function. |
|
210 * @return An error is returned if RunError() cannot process the |
|
211 * error. |
|
212 */ |
|
213 TInt RunError( TInt aError ); |
|
214 |
|
215 private: |
|
216 /** |
|
217 * C++ default constructor. |
|
218 * @since S60Rel2.5 |
|
219 */ |
|
220 CDRMRightsServer(); |
|
221 |
|
222 /** |
|
223 * By default Symbian 2nd phase constructor is private. |
|
224 * @since S60Rel2.5 |
|
225 */ |
|
226 void ConstructL(); |
|
227 |
|
228 /** |
|
229 * This method fetches the database key and stores |
|
230 * it to the given descriptor. |
|
231 * @since S60Rel2.5 |
|
232 * @param aKey Descriptor where the key is stored. |
|
233 */ |
|
234 void GetDbKeyL( TDRMKey& aKey ); |
|
235 |
|
236 /** |
|
237 * This method generates the actual key from key seed. |
|
238 * @since S60Rel2.5 |
|
239 * @param aKeySeed Key seed. |
|
240 * @param aKey The key produced. |
|
241 */ |
|
242 void GenerateKeyL( HBufC*& aKeySeed, |
|
243 TDRMKey& aKey ) const; |
|
244 |
|
245 |
|
246 void StartThreadL( const TDesC& aThreadName, |
|
247 TThreadFunction aFunc, |
|
248 RSemaphore& aSemaphore ); |
|
249 |
|
250 |
|
251 void AppendExtendedIndividualConstraintsL(RMobilePhone* aMobilePhone = NULL); |
|
252 static void Release(TAny* aIndividualConstraintExtension); |
|
253 |
|
254 private: // Functions from base classes |
|
255 // Class CServer |
|
256 /** |
|
257 * NewSessionL |
|
258 * @since S60Rel2.5 |
|
259 */ |
|
260 CSession2* NewSessionL( const TVersion& aVersion, |
|
261 const RMessage2& aMessage) const; |
|
262 |
|
263 public: // Data |
|
264 |
|
265 protected: // Data |
|
266 |
|
267 private: // Data |
|
268 CDRMRightsDB* iDb; |
|
269 |
|
270 CDRMNotifier* iNotifier; |
|
271 |
|
272 RFs iFs; |
|
273 RDRMReplayCache iCache; |
|
274 RDrmMeteringDb iMeteringDb; |
|
275 RDRMClockClient iClock; |
|
276 RPointerArray<CDRMXOma>* iXOmaHeaders; |
|
277 RPointerArray<HBufC8> iActiveCountConstraints; |
|
278 |
|
279 HBufC* iIMEI; |
|
280 |
|
281 // Backup Observer |
|
282 CDRMBackupObserver* iBackupObserver; |
|
283 |
|
284 // BackupHandler |
|
285 CDRMBackup* iBackupHandler; |
|
286 |
|
287 // Backup client |
|
288 conn::CActiveBackupClient* iActiveBackupClient; |
|
289 |
|
290 // RDB Watcher |
|
291 CDbWatcher* iDbWatcher; |
|
292 |
|
293 // Peer process watcher |
|
294 CProcWatcher* iProcWatcher; |
|
295 |
|
296 // Watching causes a restart |
|
297 TBool iArmed; |
|
298 |
|
299 CDRMPointerArray<HBufC8>* iIMSI; |
|
300 TBool iGetImsi; |
|
301 |
|
302 public: // Friend classes |
|
303 |
|
304 protected: // Friend classes |
|
305 |
|
306 private: // Friend classes |
|
307 |
|
308 }; |
|
309 |
|
310 #endif // CDRMRIGHTSSERVER_H |
|
311 |
|
312 // End of File |