phonebookui/Phonebook2/Commands/src/CPbk2DriveSpaceCheck.cpp
changeset 0 e686773b3f54
equal deleted inserted replaced
-1:000000000000 0:e686773b3f54
       
     1 /*
       
     2 * Copyright (c) 2007-2007 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:  Flash File System (FFS) check helper class methods.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CPbk2DriveSpaceCheck.h"
       
    21 #include <pathinfo.h>
       
    22 #include <sysutil.h>
       
    23 
       
    24 const TInt KDiskSpaceNeedNotknown = 0;
       
    25 
       
    26 // ================= MEMBER FUNCTIONS =======================
       
    27 
       
    28 inline CPbk2DriveSpaceCheck::CPbk2DriveSpaceCheck( RFs& aFs ) :
       
    29     iFs( aFs ),
       
    30     iDrive( KErrNotFound ),
       
    31     iStoreIsInDrive( ETrue )
       
    32     {
       
    33     }
       
    34 
       
    35 EXPORT_C CPbk2DriveSpaceCheck* CPbk2DriveSpaceCheck::NewL( RFs& aFs )
       
    36     {
       
    37     CPbk2DriveSpaceCheck* self = new (ELeave) CPbk2DriveSpaceCheck( aFs );
       
    38     return self;
       
    39     }
       
    40     
       
    41 
       
    42 CPbk2DriveSpaceCheck::~CPbk2DriveSpaceCheck()
       
    43     {
       
    44     }
       
    45 
       
    46 EXPORT_C void CPbk2DriveSpaceCheck::DriveSpaceCheckL()
       
    47     {
       
    48     TBool criticalLevel( EFalse );
       
    49     if ( iDrive == KErrNotFound && iStoreIsInDrive )
       
    50         {
       
    51         criticalLevel = SysUtil::FFSSpaceBelowCriticalLevelL( &iFs );
       
    52         }
       
    53     else if ( iDrive != KErrNotFound && iStoreIsInDrive )
       
    54         {
       
    55         criticalLevel = SysUtil::DiskSpaceBelowCriticalLevelL( 
       
    56             &iFs, KDiskSpaceNeedNotknown, iDrive );
       
    57         }
       
    58         
       
    59     if ( criticalLevel )
       
    60         {
       
    61         User::Leave( KErrDiskFull );
       
    62         }
       
    63     }
       
    64 
       
    65 EXPORT_C void CPbk2DriveSpaceCheck::SetStore( const TVPbkContactStoreUriPtr aUriPtr )
       
    66     {
       
    67     iStoreIsInDrive = EFalse;
       
    68     iDrive = KErrNotFound;
       
    69     
       
    70     const TPtrC driveLetter = 
       
    71         aUriPtr.Component( TVPbkContactStoreUriPtr::EContactStoreUriStoreDrive );
       
    72     if ( driveLetter.Length() > 0 )
       
    73         {
       
    74         iStoreIsInDrive = ETrue;
       
    75         TDriveUnit driveUnit( driveLetter );
       
    76         iDrive = driveUnit;
       
    77         }
       
    78     }
       
    79 
       
    80 EXPORT_C void CPbk2DriveSpaceCheck::SetStore( const TDesC& aFilePath )
       
    81     {
       
    82     iStoreIsInDrive = EFalse;
       
    83     iDrive = KErrNotFound;
       
    84     
       
    85     if( aFilePath.Length() )
       
    86         {
       
    87         //Extract the first char of the path -> its the drive name       
       
    88         const TPtrC driveLetter = aFilePath.Mid(0,1);
       
    89         
       
    90         if ( driveLetter.Length() > 0 )
       
    91             {
       
    92             iStoreIsInDrive = ETrue;
       
    93             TDriveUnit driveUnit( driveLetter );
       
    94             iDrive = driveUnit;
       
    95             }
       
    96         }
       
    97     }
       
    98 
       
    99 //  End of File