1 /* |
1 /* |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
34 /** Channel used to communicate with Security Notifier. */ |
34 /** Channel used to communicate with Security Notifier. */ |
35 static const TUid KSecurityNotifierChannel = { 0x1000598F }; |
35 static const TUid KSecurityNotifierChannel = { 0x1000598F }; |
36 |
36 |
37 // Type definitions for a buffer containing a drive id (drive letter + :). |
37 // Type definitions for a buffer containing a drive id (drive letter + :). |
38 const TInt KDriveIdLength = 2; |
38 const TInt KDriveIdLength = 2; |
|
39 //Number of clusterSize to be reserve for phone memory space |
|
40 const TInt KNumberOfCluster = 2; |
39 typedef TBuf<KDriveIdLength> TDriveId; |
41 typedef TBuf<KDriveIdLength> TDriveId; |
40 |
42 |
41 // ======== MEMBER FUNCTIONS ======== |
43 // ======== MEMBER FUNCTIONS ======== |
42 |
44 |
43 // --------------------------------------------------------------------------- |
45 // --------------------------------------------------------------------------- |
45 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
46 // |
48 // |
47 EXPORT_C CSsmUiSpecific::~CSsmUiSpecific() |
49 EXPORT_C CSsmUiSpecific::~CSsmUiSpecific() |
48 { |
50 { |
49 FUNC_LOG; |
51 FUNC_LOG; |
|
52 iReservedPhoneMemoryFs.Close(); |
50 } |
53 } |
51 |
54 |
52 |
55 |
53 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
54 // CSsmUiSpecific::InstanceL |
57 // CSsmUiSpecific::InstanceL |
429 |
433 |
430 // --------------------------------------------------------------------------- |
434 // --------------------------------------------------------------------------- |
431 // CSsmUiSpecific::CSsmUiSpecific |
435 // CSsmUiSpecific::CSsmUiSpecific |
432 // --------------------------------------------------------------------------- |
436 // --------------------------------------------------------------------------- |
433 // |
437 // |
434 CSsmUiSpecific::CSsmUiSpecific() : iReferenceCount( 1 ) |
438 CSsmUiSpecific::CSsmUiSpecific() : iReferenceCount(1), iReservedPhoneMemory(0) |
435 { |
439 { |
436 FUNC_LOG; |
440 FUNC_LOG; |
437 } |
441 } |
|
442 /** |
|
443 Leaving construction inside ConstructL |
|
444 */ |
|
445 void CSsmUiSpecific::ConstructL() |
|
446 { |
|
447 FUNC_LOG; |
|
448 |
|
449 User::LeaveIfError( iReservedPhoneMemoryFs.Connect() ); |
|
450 } |
|
451 |
|
452 /** |
|
453 ReservePhoneMemorySpace |
|
454 */ |
|
455 EXPORT_C TInt CSsmUiSpecific::ReservePhoneMemorySpace() |
|
456 { |
|
457 FUNC_LOG; |
|
458 TVolumeIOParamInfo volumeParamInfo; |
|
459 const TInt phoneMemoryDriveID = PhoneMemoryRootDriveId(); |
|
460 TInt errorCode = iReservedPhoneMemoryFs.VolumeIOParam(phoneMemoryDriveID, volumeParamInfo); |
|
461 if( KErrNone == errorCode ) |
|
462 { |
|
463 #ifdef __WINS__ |
|
464 //512 bytes for __WINS__ |
|
465 const TInt reservedMemory = 512; |
|
466 #else |
|
467 //Reserving two clusterSize Phone memory |
|
468 const TInt reservedMemory = KNumberOfCluster * (volumeParamInfo.iClusterSize); |
|
469 #endif //__WINS__ |
|
470 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace(phoneMemoryDriveID, reservedMemory); |
|
471 |
|
472 if ( KErrNone == errorCode ) |
|
473 { |
|
474 iReservedPhoneMemory = reservedMemory; |
|
475 } |
|
476 } |
|
477 return errorCode; |
|
478 } |
|
479 |
|
480 /** |
|
481 FreeReservedPhoneMemorySpace |
|
482 */ |
|
483 EXPORT_C TInt CSsmUiSpecific::FreeReservedPhoneMemorySpace(const TInt aSpaceToFree) |
|
484 { |
|
485 FUNC_LOG; |
|
486 TInt errorCode(KErrGeneral); |
|
487 INFO_2("Reserved memory is = %d bytes, Request to free memory is = %d bytes", iReservedPhoneMemory, aSpaceToFree); |
|
488 if(0 < iReservedPhoneMemory) |
|
489 { |
|
490 if(0 == aSpaceToFree) |
|
491 { |
|
492 //Free complete reserved phone memory |
|
493 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), 0 ); |
|
494 INFO_1("Freeing memory completed with = %d", errorCode); |
|
495 iReservedPhoneMemory = 0; |
|
496 } |
|
497 else |
|
498 { |
|
499 TInt newReserveSize = iReservedPhoneMemory - aSpaceToFree; |
|
500 newReserveSize = newReserveSize >= 0 ? newReserveSize : 0; |
|
501 errorCode = iReservedPhoneMemoryFs.ReserveDriveSpace( PhoneMemoryRootDriveId(), newReserveSize ); |
|
502 INFO_1("Freeing partial phone memory completed with = %d", errorCode); |
|
503 if(KErrNone == errorCode) |
|
504 { |
|
505 iReservedPhoneMemory = newReserveSize; |
|
506 } |
|
507 } |
|
508 } |
|
509 return errorCode; |
|
510 } |