harvester/monitorplugins/inc/fsutil.inl
changeset 0 c53acadfccc6
child 7 3cebc1a84278
equal deleted inserted replaced
-1:000000000000 0:c53acadfccc6
       
     1 /*
       
     2 * Copyright (c) 2007-2009 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:  Some generic utilities.*
       
    15 */
       
    16 
       
    17 
       
    18 #include "mdscommoninternal.h"
       
    19 #include "mdeharvestersession.h"
       
    20 #include <e32base.h>
       
    21 
       
    22 inline TUint32 FSUtil::MediaID( const RFs& aFs, TInt aDrive )
       
    23     {
       
    24     TVolumeInfo vi;
       
    25     
       
    26     TInt err = aFs.Volume(vi, aDrive);
       
    27     if(err == KErrNone)
       
    28         {
       
    29         return vi.iUniqueID;
       
    30         }
       
    31         
       
    32     return 0;
       
    33     }
       
    34 
       
    35 inline TUint32 FSUtil::MediaID( const RFs& aFs, const TDesC& aUri )
       
    36     {
       
    37     TInt drive = DriveNumber(aUri);
       
    38     if(drive == -1)
       
    39         {
       
    40         return 0;
       
    41         }
       
    42         
       
    43     return MediaID(aFs, drive);
       
    44     }
       
    45 
       
    46 inline TUint32 FSUtil::GetPreviousMediaIDL( const CMdEHarvesterSession* aMdeSession,
       
    47 											TChar aDrive )
       
    48 	{
       
    49 	RArray<TMdEMediaInfo> presentMedias;
       
    50 	CleanupClosePushL( presentMedias );
       
    51 	CMdEHarvesterSession* sess = (CMdEHarvesterSession*) aMdeSession;
       
    52 	sess->GetPresentMediasL( presentMedias );
       
    53 
       
    54     TUint32 mediaid = 0;
       
    55     TInt count = presentMedias.Count();
       
    56     for( TInt i=0;i<count;i++ )
       
    57     	{
       
    58     	TMdEMediaInfo info = presentMedias[i];
       
    59     	if( info.iDrive == aDrive )
       
    60     		{
       
    61     		mediaid = info.iMediaId;
       
    62     		break;
       
    63     		}
       
    64     	}
       
    65     CleanupStack::PopAndDestroy( &presentMedias );
       
    66     
       
    67     return mediaid;
       
    68 	}
       
    69 
       
    70 inline TInt FSUtil::DriveNumber( const TDesC& aUri )
       
    71     {
       
    72     TChar ch = aUri[0];
       
    73     TInt drive = 0;
       
    74     TInt err = RFs::CharToDrive(ch, drive);
       
    75     if(err == KErrNone)
       
    76         {
       
    77         return drive;
       
    78         }
       
    79         
       
    80     return -1;
       
    81     }
       
    82