|
1 /* |
|
2 * Copyright (c) 2008 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: WMDRM data store implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ezlib.h> |
|
20 #include <e32math.h> |
|
21 #include <symmetric.h> |
|
22 #include <bacntf.h> |
|
23 #include <centralrepository.h> |
|
24 |
|
25 #include "wmdrmdatastore.h" |
|
26 #include "wmdrmprivatecrkeys.h" |
|
27 #include "wmdrmkeystorage.h" |
|
28 #include "slotdatacache.h" |
|
29 #include "wmdrmdb.h" |
|
30 #include "drmrightsstoringlocation.h" |
|
31 #include "drmutilityinternaltypes.h" |
|
32 |
|
33 #define _LOGGING_FILE L"wmdrmserver.txt" |
|
34 |
|
35 #include "flogger.h" |
|
36 #include "logfn.h" |
|
37 |
|
38 const TInt KMegaByte( 1024 * 1024 ); |
|
39 const TInt KTwoHundredMegaBytes ( 200 * 1024 * 1024 ); |
|
40 const TInt KMaxSpaceRatio( 85 ); |
|
41 const TInt KMaxSpaceRatio2( 20 ); |
|
42 const TInt KMaxTInt64BufLength( 20 ); |
|
43 const TInt KDummyDbInitialSize( 0 ); |
|
44 |
|
45 #if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__) |
|
46 _LIT8( KDummyKey, "0123456789012345" ); |
|
47 #endif |
|
48 |
|
49 CWmDrmDataStore* CWmDrmDataStore::NewL( CWmDrmServer* aServer ) |
|
50 { |
|
51 LOGFN( "CWmDrmDataStore::NewL" ); |
|
52 CWmDrmDataStore* self = new ( ELeave ) CWmDrmDataStore( aServer ); |
|
53 CleanupStack::PushL( self ); |
|
54 self->ConstructL(); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 CWmDrmDataStore::CWmDrmDataStore( CWmDrmServer* aServer ) |
|
60 : iServer( aServer ), iMinFreeSpace2( 0 ) |
|
61 { |
|
62 LOGFN( "CWmDrmDataStore::CWmDrmDataStore" ); |
|
63 } |
|
64 |
|
65 void CWmDrmDataStore::ConstructL() |
|
66 { |
|
67 TDrmScheme drmScheme( EDrmSchemeWmDrm ); |
|
68 TFileName tempFile, tempFile2; |
|
69 TChar driveLetter; |
|
70 |
|
71 LOGFN( "CWmDrmDataStore::ConstructL" ); |
|
72 |
|
73 // Check which drive is configured in the Central Repository Key |
|
74 // for the desired storing location of WM DRM rights (license store). |
|
75 iWmDrmRightsConfigFound = DrmRightsStoringLocation::CheckDrmRightsStorageDriveL( |
|
76 iServer->Fs(), drmScheme, driveLetter ); |
|
77 |
|
78 // If the storing location is configured to other drive than the default |
|
79 // system drive, prepare utility files for that drive, too. |
|
80 if ( iWmDrmRightsConfigFound ) |
|
81 { |
|
82 PrepareInfoFilesL( ETrue, driveLetter, iDummyDb2 ); |
|
83 } |
|
84 |
|
85 // Prepare the utility files for the default system drive |
|
86 PrepareInfoFilesL( EFalse, (TUint)iServer->Fs().GetSystemDriveChar(), |
|
87 iDummyDb ); |
|
88 } |
|
89 |
|
90 CWmDrmDataStore::~CWmDrmDataStore() |
|
91 { |
|
92 LOGFN( "CWmDrmDataStore::~CWmDrmDataStore" ); |
|
93 iDummyDb.Close(); |
|
94 // Close the database on the configured drive |
|
95 if ( iWmDrmRightsConfigFound ) |
|
96 { |
|
97 iDummyDb2.Close(); |
|
98 } |
|
99 } |
|
100 |
|
101 void CWmDrmDataStore::ReadInitialFreeSpaceL( const TDesC& aFileName, |
|
102 TBool& aConfiguredDrive ) |
|
103 { |
|
104 RFile file; |
|
105 TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> encryptedData; |
|
106 TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> decryptedData; |
|
107 TBuf8<KAESKeyLength> key; |
|
108 TBuf8<KAESKeyLength> iv; |
|
109 CBufferedDecryptor* decryptor = NULL; |
|
110 CModeCBCDecryptor* cbcDecryptor = NULL; |
|
111 CAESDecryptor* aesDecryptor = NULL; |
|
112 CPaddingPKCS7* padding = NULL; |
|
113 TInt size = 0; |
|
114 |
|
115 LOGFN( "CWmDrmDataStore::ReadInitialFreeSpaceL" ); |
|
116 User::LeaveIfError( file.Open( iServer->Fs(), aFileName, EFileRead ) ); |
|
117 CleanupClosePushL( file ); |
|
118 |
|
119 User::LeaveIfError( file.Size( size ) ); |
|
120 |
|
121 if( size != ( 2 * KAESKeyLength ) ) |
|
122 { |
|
123 User::Leave(KErrCorrupt); |
|
124 } |
|
125 |
|
126 User::LeaveIfError( file.Read( iv ) ); |
|
127 User::LeaveIfError( file.Read( encryptedData ) ); |
|
128 #if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__) |
|
129 key.Copy( KDummyKey ); |
|
130 #else |
|
131 iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key ); |
|
132 #endif |
|
133 aesDecryptor = CAESDecryptor::NewL( key ); |
|
134 CleanupStack::PushL( aesDecryptor ); |
|
135 |
|
136 cbcDecryptor = CModeCBCDecryptor::NewL( aesDecryptor, iv ); |
|
137 CleanupStack::Pop( aesDecryptor ); |
|
138 CleanupStack::PushL( cbcDecryptor ); |
|
139 |
|
140 padding = CPaddingPKCS7::NewL( KAESKeyLength ); |
|
141 CleanupStack::PushL( padding ); |
|
142 |
|
143 decryptor = CBufferedDecryptor::NewL( cbcDecryptor, padding ); |
|
144 CleanupStack::Pop( 2, cbcDecryptor ); //padding, cbcDecryptor |
|
145 CleanupStack::PushL( decryptor ); |
|
146 |
|
147 decryptor->ProcessFinalL( encryptedData, decryptedData ); |
|
148 CleanupStack::PopAndDestroy( 2, &file ); //decryptor, file |
|
149 TLex8 lex( decryptedData ); |
|
150 |
|
151 if ( aConfiguredDrive ) |
|
152 { |
|
153 User::LeaveIfError( lex.Val( iInitialFreeSpace2 ) ); |
|
154 } |
|
155 else |
|
156 { |
|
157 User::LeaveIfError( lex.Val( iInitialFreeSpace ) ); |
|
158 } |
|
159 } |
|
160 |
|
161 void CWmDrmDataStore::WriteInitialFreeSpaceL( const TDesC& aFileName, |
|
162 TBool& aConfiguredDrive ) |
|
163 { |
|
164 RFile file; |
|
165 TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> encryptedData; |
|
166 TBuf8<KMaxTInt64BufLength + 2 * KAESKeyLength> decryptedData; |
|
167 TBuf8<KAESKeyLength> key; |
|
168 TBuf8<KAESKeyLength> iv; |
|
169 CBufferedEncryptor* encryptor = NULL; |
|
170 CModeCBCEncryptor* cbcEncryptor = NULL; |
|
171 CAESEncryptor* aesEncryptor = NULL; |
|
172 CPaddingPKCS7* padding = NULL; |
|
173 |
|
174 LOGFN( "CWmDrmDataStore::WriteInitialFreeSpaceL" ); |
|
175 User::LeaveIfError( file.Create( iServer->Fs(), aFileName, EFileWrite ) ); |
|
176 CleanupClosePushL( file ); |
|
177 if ( aConfiguredDrive ) |
|
178 { |
|
179 iInitialFreeSpace2 = iServer->FreeSpaceL( aConfiguredDrive ); |
|
180 } |
|
181 else |
|
182 { |
|
183 iInitialFreeSpace = iServer->FreeSpaceL( aConfiguredDrive ); |
|
184 } |
|
185 iv.SetLength( KAESKeyLength ); |
|
186 TRandom::RandomL( iv ); |
|
187 #if defined(FF_PLATFORM_SIMULATOR) || defined(__WINSCW__) |
|
188 key.Copy( KDummyKey ); |
|
189 #else |
|
190 iServer->Cache()->iKeyStorage->GetDeviceSpecificKeyL( key ); |
|
191 #endif |
|
192 aesEncryptor = CAESEncryptor::NewL( key ); |
|
193 CleanupStack::PushL( aesEncryptor ); |
|
194 |
|
195 cbcEncryptor = CModeCBCEncryptor::NewL( aesEncryptor, iv ); |
|
196 CleanupStack::Pop( aesEncryptor ); |
|
197 CleanupStack::PushL( cbcEncryptor ); |
|
198 |
|
199 padding = CPaddingPKCS7::NewL( KAESKeyLength ); |
|
200 CleanupStack::PushL( padding ); |
|
201 |
|
202 encryptor = CBufferedEncryptor::NewL( cbcEncryptor, padding ); |
|
203 CleanupStack::Pop( 2, cbcEncryptor ); //padding, cbcEncryptor |
|
204 CleanupStack::PushL( encryptor ); |
|
205 |
|
206 if ( aConfiguredDrive ) |
|
207 { |
|
208 decryptedData.AppendNum( iInitialFreeSpace2 ); |
|
209 } |
|
210 else |
|
211 { |
|
212 decryptedData.AppendNum( iInitialFreeSpace ); |
|
213 } |
|
214 |
|
215 encryptor->ProcessFinalL( decryptedData, encryptedData ); |
|
216 User::LeaveIfError( file.Write( iv ) ); |
|
217 User::LeaveIfError( file.Write( encryptedData ) ); |
|
218 CleanupStack::PopAndDestroy( 2, &file ); //encryptor, file |
|
219 } |
|
220 |
|
221 TWmDrmStoreState CWmDrmDataStore::DataStoreStateL() |
|
222 { |
|
223 TWmDrmStoreState state; |
|
224 TInt64 freeSpace( 0 ); |
|
225 TInt64 freeSpace2( 0 ); |
|
226 TInt dataStoreSize( 0 ); |
|
227 TInt dummyDbSize( 0 ); |
|
228 TInt ratio( 0 ); |
|
229 TInt ratio2( 0 ); |
|
230 TBool internalMassDriveNotFull( ETrue ); |
|
231 |
|
232 LOGFN( "CWmDrmDataStore::DataStoreStateL" ); |
|
233 freeSpace = iServer->FreeSpaceL( EFalse ); |
|
234 |
|
235 if ( iWmDrmRightsConfigFound ) |
|
236 { |
|
237 // Check free space from the configured drive, too. |
|
238 freeSpace2 = iServer->FreeSpaceL( ETrue ); |
|
239 |
|
240 if ( freeSpace2 < iMinFreeSpace2 ) |
|
241 { |
|
242 internalMassDriveNotFull = EFalse; |
|
243 } |
|
244 |
|
245 dummyDbSize = DummyDBSizeL( ETrue ); |
|
246 dataStoreSize = DataStoreSizeL( ETrue ); |
|
247 ratio2 = dataStoreSize * 100 / iInitialFreeSpace2; |
|
248 freeSpace2 += dummyDbSize; |
|
249 #ifdef _LOGGING |
|
250 TBuf<KMaxTInt64BufLength> free2; |
|
251 LOG1( "CWmDrmDataStore::DataStoreStateL: Free space (2): "); |
|
252 free2.AppendNumUC( freeSpace2, EDecimal ); |
|
253 LOG( free2 ); |
|
254 TBuf<KMaxTInt64BufLength> free2Min; |
|
255 LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space (2): "); |
|
256 free2Min.AppendNumUC( iMinFreeSpace2, EDecimal ); |
|
257 LOG( free2Min ); |
|
258 #endif |
|
259 } |
|
260 |
|
261 // Check the system drive storage space next. |
|
262 dummyDbSize = DummyDBSizeL( EFalse ); |
|
263 dataStoreSize = DataStoreSizeL( EFalse ); |
|
264 ratio = dataStoreSize * 100 / iInitialFreeSpace; |
|
265 freeSpace += dummyDbSize; |
|
266 #ifdef _LOGGING |
|
267 TBuf<KMaxTInt64BufLength> free; |
|
268 LOG1( "CWmDrmDataStore::DataStoreStateL: Free space: "); |
|
269 free.AppendNumUC( freeSpace, EDecimal ); |
|
270 LOG( free ); |
|
271 TBuf<KMaxTInt64BufLength> freeMin; |
|
272 LOG1( "CWmDrmDataStore::DataStoreStateL: Minimum free space: "); |
|
273 freeMin.AppendNumUC( iMinFreeSpace, EDecimal ); |
|
274 LOG( freeMin ); |
|
275 #endif |
|
276 |
|
277 // Select the state of the storage space. |
|
278 if ( ( freeSpace > iMinFreeSpace ) && internalMassDriveNotFull ) |
|
279 { |
|
280 LOG1( "CWmDrmDataStore::DataStoreStateL: Store space Ok" ); |
|
281 state = EStoreSpaceOK; |
|
282 } |
|
283 else |
|
284 { |
|
285 // The configured drive is running out of space. The system drive |
|
286 // may also be running out of storage space, but calculate |
|
287 // the ratio of database size to initial free drive space and the |
|
288 // state of the drive storage space from the configured drive because |
|
289 // it is likely to fill up faster since the media files may be synced to it. |
|
290 if ( !internalMassDriveNotFull ) |
|
291 { |
|
292 LOG2( "Ratio (2): %d", ratio2 ); |
|
293 if ( ratio2 <= iMaxSpaceRatio2 ) |
|
294 { |
|
295 LOG1( "CWmDrmDataStore::DataStoreStateL: Store space low (2)" ); |
|
296 state = EStoreSpaceLow; |
|
297 } |
|
298 else |
|
299 { |
|
300 LOG1( "CWmDrmDataStore::DataStoreStateL: Store space full (2)" ); |
|
301 state = EStoreSpaceFull; |
|
302 } |
|
303 } |
|
304 else |
|
305 // Only the system drive is running out of storage space. |
|
306 { |
|
307 LOG2( "Ratio: %d", ratio ); |
|
308 if ( ratio <= iMaxSpaceRatio ) |
|
309 { |
|
310 LOG1( "CWmDrmDataStore::DataStoreStateL Store space low" ); |
|
311 state = EStoreSpaceLow; |
|
312 } |
|
313 else |
|
314 { |
|
315 LOG1( "CWmDrmDataStore::DataStoreStateL Store space full" ); |
|
316 state = EStoreSpaceFull; |
|
317 } |
|
318 } |
|
319 } |
|
320 |
|
321 LOG2( "DataStoreState: %d", state ); |
|
322 return state; |
|
323 } |
|
324 |
|
325 void CWmDrmDataStore::InitializeDummyDbFileL( const TDesC& aFileName, |
|
326 RFile& aDummyDb, TBool& aConfiguredDrive ) |
|
327 { |
|
328 TInt r( KErrNone ); |
|
329 |
|
330 LOGFN( "CWmDrmDataStore::InitializeDummyDbFileL" ); |
|
331 |
|
332 r = aDummyDb.Create( iServer->Fs(), aFileName, EFileWrite ); |
|
333 if ( r == KErrAlreadyExists ) |
|
334 { |
|
335 User::LeaveIfError( |
|
336 aDummyDb.Open( iServer->Fs(), aFileName, EFileWrite ) ); |
|
337 } |
|
338 else if( !r ) |
|
339 { |
|
340 TInt dataStoreSize( DataStoreSizeL( aConfiguredDrive ) ); |
|
341 if ( aConfiguredDrive ) |
|
342 { |
|
343 if ( dataStoreSize <= iDummyDbInitialSize2 ) |
|
344 { |
|
345 User::LeaveIfError( |
|
346 aDummyDb.SetSize( iDummyDbInitialSize2 - dataStoreSize ) ); |
|
347 } |
|
348 else |
|
349 { |
|
350 User::LeaveIfError( aDummyDb.SetSize( 0 ) ); |
|
351 } |
|
352 } |
|
353 else |
|
354 { |
|
355 if ( dataStoreSize <= iDummyDbInitialSize ) |
|
356 { |
|
357 User::LeaveIfError( |
|
358 aDummyDb.SetSize( iDummyDbInitialSize - dataStoreSize ) ); |
|
359 } |
|
360 else |
|
361 { |
|
362 User::LeaveIfError( aDummyDb.SetSize( 0 ) ); |
|
363 } |
|
364 } |
|
365 } |
|
366 else |
|
367 { |
|
368 User::Leave( r ); |
|
369 } |
|
370 } |
|
371 |
|
372 void CWmDrmDataStore::UpdateDummyDbFileL( TInt aSize, TBool aConfiguredDrive ) |
|
373 { |
|
374 LOGFN( "CWmDrmDataStore::UpdateDummyDbFileL" ); |
|
375 LOG2( "aSize: %d", aSize ); |
|
376 if ( aSize > 0 ) |
|
377 { |
|
378 TInt dummyDbSize( DummyDBSizeL( aConfiguredDrive ) ); |
|
379 LOG2( "dummyDbSize: %d", dummyDbSize ); |
|
380 if ( aSize <= dummyDbSize ) |
|
381 { |
|
382 if ( aConfiguredDrive ) |
|
383 { |
|
384 User::LeaveIfError( iDummyDb2.SetSize( dummyDbSize - aSize ) ); |
|
385 } |
|
386 else |
|
387 { |
|
388 User::LeaveIfError( iDummyDb.SetSize( dummyDbSize - aSize ) ); |
|
389 } |
|
390 } |
|
391 else |
|
392 { |
|
393 if ( aConfiguredDrive ) |
|
394 { |
|
395 User::LeaveIfError( iDummyDb2.SetSize( 0 ) ); |
|
396 } |
|
397 else |
|
398 { |
|
399 User::LeaveIfError( iDummyDb.SetSize( 0 ) ); |
|
400 } |
|
401 } |
|
402 } |
|
403 else |
|
404 { |
|
405 TInt dataStoreSize( DataStoreSizeL( aConfiguredDrive ) ); |
|
406 LOG2( "dataStoreSize: %d", dataStoreSize ); |
|
407 if ( aConfiguredDrive ) |
|
408 { |
|
409 if ( dataStoreSize <= iDummyDbInitialSize2 ) |
|
410 { |
|
411 User::LeaveIfError( |
|
412 iDummyDb2.SetSize( iDummyDbInitialSize2 - dataStoreSize ) ); |
|
413 } |
|
414 else |
|
415 { |
|
416 User::LeaveIfError( iDummyDb2.SetSize( 0 ) ); |
|
417 } |
|
418 } |
|
419 else |
|
420 { |
|
421 if ( dataStoreSize <= iDummyDbInitialSize ) |
|
422 { |
|
423 User::LeaveIfError( |
|
424 iDummyDb.SetSize( iDummyDbInitialSize - dataStoreSize ) ); |
|
425 } |
|
426 else |
|
427 { |
|
428 User::LeaveIfError( iDummyDb.SetSize( 0 ) ); |
|
429 } |
|
430 } |
|
431 } |
|
432 } |
|
433 |
|
434 TInt CWmDrmDataStore::DataStoreSizeL( TBool aConfiguredDrive ) |
|
435 { |
|
436 TInt dataStoreSize( iServer->Db()->DataBaseSize( aConfiguredDrive ) ); |
|
437 User::LeaveIfError( dataStoreSize ); |
|
438 return dataStoreSize; |
|
439 } |
|
440 |
|
441 TInt CWmDrmDataStore::DummyDBSizeL( TBool aConfiguredDrive ) |
|
442 { |
|
443 TInt dummyDbSize( 0 ); |
|
444 if ( aConfiguredDrive ) |
|
445 { |
|
446 User::LeaveIfError( iDummyDb2.Size( dummyDbSize ) ); |
|
447 } |
|
448 else |
|
449 { |
|
450 User::LeaveIfError( iDummyDb.Size( dummyDbSize ) ); |
|
451 } |
|
452 return dummyDbSize; |
|
453 } |
|
454 |
|
455 void CWmDrmDataStore::PrepareInfoFilesL( TBool aConfiguredDrive, |
|
456 TChar aDriveLetter, RFile& aDummyDb ) |
|
457 { |
|
458 LOGFN( "CWmDrmDataStore::PrepareInfoFilesL" ); |
|
459 CRepository* repository( NULL ); |
|
460 TInt r( KErrNone ); |
|
461 TFileName dummyDbFile; |
|
462 TFileName initialFreeSpaceFile; |
|
463 |
|
464 initialFreeSpaceFile.Format( KPrivateDir, (TUint)aDriveLetter ); |
|
465 iServer->Fs().MkDirAll( initialFreeSpaceFile ); |
|
466 initialFreeSpaceFile.Format( KInitialFreeSpaceFile, (TUint)aDriveLetter ); |
|
467 dummyDbFile.Format( KDummyDbFile, (TUint)aDriveLetter ); |
|
468 |
|
469 TRAP( r, WriteInitialFreeSpaceL( initialFreeSpaceFile, |
|
470 aConfiguredDrive ) ); |
|
471 if ( r ) |
|
472 { |
|
473 r = KErrNone; |
|
474 |
|
475 // catch the read error |
|
476 TRAP( r, ReadInitialFreeSpaceL( initialFreeSpaceFile, |
|
477 aConfiguredDrive ) ); |
|
478 |
|
479 // if an error occurs, this means that we are unable to read the info, |
|
480 // thus we need to delete the file and run write again. |
|
481 // hopefully this being a temporary error, but if we fail again we fail |
|
482 // until next ConstructL |
|
483 if( r != KErrNone ) |
|
484 { |
|
485 // delete the file: |
|
486 iServer->Fs().Delete( initialFreeSpaceFile ); |
|
487 |
|
488 // Calc & Write the new info |
|
489 WriteInitialFreeSpaceL( initialFreeSpaceFile, aConfiguredDrive ); |
|
490 } |
|
491 } |
|
492 |
|
493 if ( aConfiguredDrive ) |
|
494 { |
|
495 #ifdef _LOGGING |
|
496 TBuf<KMaxTInt64BufLength> freeSpace2; |
|
497 LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space (2): "); |
|
498 freeSpace2.AppendNumUC( iInitialFreeSpace2, EDecimal ); |
|
499 LOG( freeSpace2 ); |
|
500 #endif |
|
501 if ( iInitialFreeSpace2 <= 0 ) |
|
502 { |
|
503 User::Leave( KErrNotReady ); |
|
504 } |
|
505 } |
|
506 else |
|
507 { |
|
508 #ifdef _LOGGING |
|
509 TBuf<KMaxTInt64BufLength> freeSpace; |
|
510 LOG1( "CWmDrmDataStore::DataStoreStateL: Initial free space: "); |
|
511 freeSpace.AppendNumUC( iInitialFreeSpace, EDecimal ); |
|
512 LOG( freeSpace ); |
|
513 #endif |
|
514 if ( iInitialFreeSpace <= 0 ) |
|
515 { |
|
516 User::Leave( KErrNotReady ); |
|
517 } |
|
518 } |
|
519 |
|
520 //LOG1( "CWmDrmDataStore::PrepareInfoFilesL Check Cenrep" ); |
|
521 |
|
522 TRAP( r, repository = CRepository::NewL( KCRUidWMDRM ) ); |
|
523 if ( repository ) |
|
524 { |
|
525 TInt rate( 0 ); |
|
526 |
|
527 // Check the cenrep key parameters either for the default system drive |
|
528 // or for the internal mass drive depending whether the WMDRM rights |
|
529 // are configured to be partially stored to the internal mass drive or |
|
530 // not. |
|
531 if ( !aConfiguredDrive ) |
|
532 { |
|
533 r = repository->Get( KWMDRMLicStoreLowMem, rate ); |
|
534 if ( r ) |
|
535 { |
|
536 iMinFreeSpace = KMegaByte; |
|
537 } |
|
538 else |
|
539 { |
|
540 iMinFreeSpace = rate * KMegaByte; |
|
541 } |
|
542 r = repository->Get( KWMDRMLicStoreSizeRatio, iMaxSpaceRatio ); |
|
543 if ( r ) |
|
544 { |
|
545 iMaxSpaceRatio = KMaxSpaceRatio; |
|
546 } |
|
547 r = repository->Get( KWMDRMLicStoreReservedSpace, rate ); |
|
548 if ( r ) |
|
549 { |
|
550 iDummyDbInitialSize = KDummyDbInitialSize; |
|
551 } |
|
552 else |
|
553 { |
|
554 iDummyDbInitialSize = rate * KMegaByte; |
|
555 } |
|
556 } |
|
557 else |
|
558 { |
|
559 r = repository->Get( KWMDRM2LicStoreLowMem, rate ); |
|
560 if ( r ) |
|
561 { |
|
562 iMinFreeSpace2 = KTwoHundredMegaBytes; |
|
563 } |
|
564 else |
|
565 { |
|
566 iMinFreeSpace2 = rate * KMegaByte; |
|
567 } |
|
568 r = repository->Get( KWMDRM2LicStoreSizeRatio, iMaxSpaceRatio2 ); |
|
569 if ( r ) |
|
570 { |
|
571 iMaxSpaceRatio2 = KMaxSpaceRatio2; |
|
572 } |
|
573 r = repository->Get( KWMDRM2LicStoreReservedSpace, rate ); |
|
574 if ( r ) |
|
575 { |
|
576 iDummyDbInitialSize2 = KDummyDbInitialSize; |
|
577 } |
|
578 else |
|
579 { |
|
580 iDummyDbInitialSize2 = rate * KMegaByte; |
|
581 } |
|
582 } |
|
583 delete repository; |
|
584 } |
|
585 else |
|
586 { |
|
587 if ( !aConfiguredDrive ) |
|
588 { |
|
589 iMinFreeSpace = KMegaByte; |
|
590 iMaxSpaceRatio = KMaxSpaceRatio; |
|
591 iDummyDbInitialSize = KDummyDbInitialSize; |
|
592 } |
|
593 else |
|
594 { |
|
595 iMinFreeSpace2 = KTwoHundredMegaBytes; |
|
596 iMaxSpaceRatio2 = KMaxSpaceRatio2; |
|
597 iDummyDbInitialSize2 = KDummyDbInitialSize; |
|
598 } |
|
599 } |
|
600 |
|
601 InitializeDummyDbFileL( dummyDbFile, aDummyDb, aConfiguredDrive ); |
|
602 |
|
603 } |