291 * @return resulted result set |
291 * @return resulted result set |
292 */ |
292 */ |
293 IMPORT_C RSqlStatement ExecuteSelectQueryOnAllDrivesL(TInt aDrive, TRefByValue<const TDesC> aFmt, |
293 IMPORT_C RSqlStatement ExecuteSelectQueryOnAllDrivesL(TInt aDrive, TRefByValue<const TDesC> aFmt, |
294 ...); |
294 ...); |
295 |
295 |
|
296 /** |
|
297 * Copy all databases from RAM disk back to normal drive, E, F,... |
|
298 * |
|
299 * @return none |
|
300 */ |
|
301 IMPORT_C void CopyDBsFromRamL(); |
|
302 |
|
303 /** |
|
304 * Copy all databases to RAM disk back from normal drive, E, F,... |
|
305 * |
|
306 * @return none |
|
307 */ |
|
308 IMPORT_C void CopyDBsToRamL( TBool aIsMTPInUse = EFalse); |
|
309 |
|
310 |
|
311 /** |
|
312 * Check if RAM disk is enough to operatte. If not, DBs will be copied back to drives. |
|
313 * |
|
314 * @return TInt index to the database handler |
|
315 */ |
|
316 IMPORT_C void EnsureRamSpaceL() ; |
|
317 |
|
318 /** |
|
319 * Move DBs from RAMDisk to disks |
|
320 */ |
|
321 //IMPORT_C void BackupDBsL(); |
|
322 |
|
323 private: |
|
324 |
|
325 /** |
|
326 * Find available RAMDISK |
|
327 * @return error code |
|
328 */ |
|
329 TInt GetRAMDiskPath(); |
|
330 |
|
331 /** |
|
332 * Check if RAM disk is available to copy. |
|
333 * |
|
334 * @return ETrue if there is enough space, EFalse otherwise |
|
335 */ |
|
336 TBool IsRamDiskSpaceAvailable(); |
|
337 |
|
338 /** |
|
339 * To block a diskspace so that it can gurantee for a write back from RAM disk |
|
340 * |
|
341 * @return ETrue if the dummy file is created successfully, EFalse otherwise |
|
342 */ |
|
343 TBool BlockDiskSpace( TDriveUnit aDrive, TInt aOrigDbSize, TBool aIsMTPInUse = EFalse ); |
|
344 |
|
345 /** |
|
346 * To copy db from regular drive to RAM |
|
347 * |
|
348 * @return ETrue if succeed |
|
349 * @leave KErrDiskFull if there is any difficulty copying files |
|
350 */ |
|
351 TBool DoCopyDBToRamL( TDriveUnit aDrive, TBool aIsMTPInUse ); |
|
352 |
|
353 /** |
|
354 * To copy db back regular drive from RAM |
|
355 * |
|
356 */ |
|
357 void DoCopyDBFromRamL( TInt aIndex ); |
|
358 |
|
359 /** |
|
360 * To replace dummy file with new content |
|
361 * Writes over previous dummy file without freeing disk space |
|
362 */ |
|
363 void ReplaceFileL( const TDesC& aSrcName, const TDesC& aDstName ); |
|
364 |
|
365 /** |
|
366 * To calculate necessary file size of the dummy file |
|
367 * |
|
368 * @return TInt64 estimated file size |
|
369 */ |
|
370 TInt64 CalculateInitalDummyDBSize( const TVolumeInfo& aVol, TInt aOrigDbSize, TBool aIsMTPInUse = EFalse); |
|
371 |
|
372 /** |
|
373 * Get database index by giving drive index |
|
374 * |
|
375 * @return TInt index to the database handler |
|
376 */ |
|
377 TInt GetDatabaseIndex(TInt aDrive); |
|
378 |
|
379 /** |
|
380 * Sum up the total size in bytes of the databases. |
|
381 * |
|
382 * @param aSize - On return, the total size of the databases. |
|
383 * @return TInt System error. |
|
384 */ |
|
385 TInt GetTotalDatabasesSize(TInt& aSize); |
|
386 |
|
387 /** |
|
388 * Sum up the total size in bytes of the databases on the RAM drive. |
|
389 * |
|
390 * @param aSize - On return, the total size of the databases on the RAM drive. |
|
391 * @return TInt System error. |
|
392 */ |
|
393 TInt GetTotalRamDatabasesSize(TInt& aSize); |
|
394 |
|
395 /** |
|
396 * Remove dummy file |
|
397 * |
|
398 * @return TInt index to the database handler |
|
399 */ |
|
400 void RemoveDummyFile( TInt index ); |
|
401 |
|
402 |
|
403 |
|
404 /** |
|
405 * Check if disksapce is enough to operatte. If not, it leaves with KErrDiskFull |
|
406 * |
|
407 */ |
|
408 void EnsureDiskSpaceL(TInt aDrive) ; |
|
409 |
|
410 /** |
|
411 * Begin transaction, leaves on error |
|
412 */ |
|
413 void DoBeginL(); |
|
414 |
|
415 /** |
|
416 * Commit transaction, leaves on error |
|
417 */ |
|
418 void DoCommitL(); |
|
419 |
296 protected: // Types |
420 protected: // Types |
297 |
421 |
298 typedef struct |
422 typedef struct |
299 { |
423 { |
300 TInt iDrive; |
424 TInt iDrive; |
301 TBool iOpen; |
425 TBool iOpen; |
302 HBufC* iAliasname; |
426 HBufC* iAliasname; |
|
427 #ifdef __RAMDISK_PERF_ENABLE |
|
428 TBool iUseRAMdb; |
|
429 HBufC* iOrigFullFilePath; |
|
430 HBufC* iTargetFullFilePath; |
|
431 TFileName iDummyFilePath; |
|
432 #endif //__RAMDISK_PERF_ENABLE |
303 } DatabaseHandle; |
433 } DatabaseHandle; |
304 |
434 |
305 protected: // Data |
435 protected: // Data |
306 |
436 |
307 HBufC* iDbFile; |
437 HBufC* iDbFile; |
490 TInt iTransactionCount; |
620 TInt iTransactionCount; |
491 RFs& iFs; |
621 RFs& iFs; |
492 |
622 |
493 RArray<TSqlStatementState> iPreparedStatements; |
623 RArray<TSqlStatementState> iPreparedStatements; |
494 RPointerArray<RSqlStatement> iStatements; |
624 RPointerArray<RSqlStatement> iStatements; |
|
625 |
|
626 // Defined for RAM disk performance |
|
627 TBool iRAMDiskPerfEnabled; // flag to indicate RAM disk feature is enabled from cenrep. |
|
628 TUint64 iMaximumAllowedRAMDiskSpaceToCopy; // maximum number of megabytes allow to do RAM disk operation. |
|
629 TFileName iRAMFolder; |
|
630 TChar iRAMDrive; |
|
631 TBool iRAMInUse; |
|
632 TInt64 iEstimatedDBSizes; |
495 }; |
633 }; |
496 |
634 |
497 #endif // MPXDBMANAGER_H |
635 #endif // MPXDBMANAGER_H |