mmappcomponents/mmmtpdataprovider/tsrc/mtpdataprovidertestmodule/inc/cteststoragemgr.h
changeset 0 a2952bb97e68
equal deleted inserted replaced
-1:000000000000 0:a2952bb97e68
       
     1 /*
       
     2 * Copyright (c) 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:  Storage manager for test module dummy mtp implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CTESTSTORAGEMGR_H
       
    20 #define CTESTSTORAGEMGR_H
       
    21 
       
    22 #include <stiflogger.h>
       
    23 #include <e32base.h>
       
    24 #include <f32file.h>
       
    25 #include <mtp/mmtpstoragemgr.h>
       
    26 
       
    27 class CTestStorageMgr :
       
    28         public CBase,
       
    29         public MMTPStorageMgr
       
    30     {
       
    31 public:
       
    32     static CTestStorageMgr* NewL();
       
    33     ~CTestStorageMgr();
       
    34     
       
    35     static TUint LogicalStorageNumber( TUint32 aStorageId );
       
    36     static TUint LogicalStorageOwner( TUint32 aStorageId );
       
    37     static TUint PhysicalStorageNumber( TUint32 aStorageId );
       
    38     static TUint PhysicalStorageOwner( TUint32 aStorageId );
       
    39     
       
    40     void SetDefaultStorageId( TUint32 aStorageId );
       
    41     void SetDriveMappingL( TDriveNumber aDriveNumber, TUint32 aStorageId );
       
    42     void SetFrameworkId( TUint aDataProviderId );
       
    43 public: // From MMTPStorageMgr
       
    44     TUint32 AllocateLogicalStorageIdL( TUint aDataProviderId,
       
    45             TDriveNumber aDriveNumber, const CMTPStorageMetaData& aStorage );
       
    46     TUint32 AllocateLogicalStorageIdL( TUint aDataProviderId,
       
    47             TUint32 aPhysicalStorageId, const CMTPStorageMetaData& aStorage );
       
    48     TUint32 AllocatePhysicalStorageIdL( TUint aDataProviderId,
       
    49             const CMTPStorageMetaData& aStorage );
       
    50     TInt DeallocateLogicalStorageId( TUint aDataProviderId,
       
    51             TUint32 aLogicalStorageId );
       
    52     void DeallocateLogicalStorageIds( TUint aDataProviderId,
       
    53             TUint32 aPhysicalStorageId );
       
    54     TInt DeallocatePhysicalStorageId( TUint aDataProviderId,
       
    55             TUint32 aPhysicalStorageId );
       
    56     TUint32 DefaultStorageId() const;
       
    57     TInt DriveNumber( TUint32 aStorageId ) const;
       
    58     TInt32 FrameworkStorageId( TDriveNumber aDriveNumber ) const;
       
    59     void GetAvailableDrivesL( RArray<TDriveNumber>& aDrives ) const;
       
    60     void GetLogicalStoragesL( const TMTPStorageMgrQueryParams& aParams,
       
    61             RPointerArray<const CMTPStorageMetaData>& aStorages ) const;
       
    62     void GetPhysicalStoragesL( const TMTPStorageMgrQueryParams& aParams,
       
    63             RPointerArray<const CMTPStorageMetaData>& aStorages ) const;
       
    64     TUint32 LogicalStorageId( TUint32 aStorageId ) const;
       
    65     TInt32 LogicalStorageId( const TDesC& aStorageSuid ) const;
       
    66     TInt32 PhysicalStorageId( TDriveNumber aDriveNumber ) const;
       
    67     TUint32 PhysicalStorageId( TUint32 aStorageId ) const;
       
    68     const CMTPStorageMetaData& StorageL( TUint32 aStorageId ) const;
       
    69     TUint32 StorageId( TUint32 aPhysicalStorageId,
       
    70             TUint32 aLogicalStorageId ) const;
       
    71     TBool ValidStorageId( TUint32 aStorageId ) const;
       
    72     CMTPTypeString* VolumeIdL( TUint aDataProviderId, TUint32 aStorageId,
       
    73             const TDesC& aVolumeIdSuffix ) const;
       
    74 private:
       
    75     CTestStorageMgr();
       
    76     void ConstructL();
       
    77     
       
    78     TInt32 AllocateLogicalStorageId( TUint aDataProviderId,
       
    79             TUint32 aPhysicalStorageId );
       
    80     TInt32 AllocatePhysicalStorageId( TUint aDataProviderId );
       
    81     TUint32 EncodeLogicalStorageId( TUint32 aPhysicalStorageId,
       
    82             TUint aDataProviderId, TUint aStorageNumber );
       
    83     TUint32 EncodeLogicalStorageNumber( TUint aStorageNumber );
       
    84     TUint32 EncodeLogicalStorageOwner( TUint aDataProviderId );
       
    85     TUint32 EncodePhysicalStorageId( TUint aDataProviderId,
       
    86             TUint aStorageNumber );
       
    87     TUint32 EncodePhysicalStorageNumber( TUint aStorageNumber );
       
    88     TUint32 EncodePhysicalStorageOwner( TUint aDataProviderId );
       
    89     void RemoveLogicalStorageL( TUint aIdx );
       
    90     CMTPStorageMetaData& StorageMetaDataL( TUint32 aStorageId );
       
    91     
       
    92     static TBool StorageKeyMatchSuid( const TDesC* aSuid,
       
    93             const CMTPStorageMetaData& aStorage );
       
    94     static TInt StorageOrder( const CMTPStorageMetaData& aL,
       
    95             const CMTPStorageMetaData& aR );
       
    96     static TInt StorageOrder( const TUint32* aKey,
       
    97             const CMTPStorageMetaData& aStorage );
       
    98     
       
    99 private: // owned data
       
   100     /**
       
   101     The default MTP storage ID.
       
   102     */
       
   103     TUint32 iDefaultStorageId;
       
   104     
       
   105     /**
       
   106     The framework storages (drives) owning data provider ID.
       
   107     */
       
   108     TInt iFrameworkId;
       
   109 
       
   110     /**
       
   111     The Symbian OS drive number to default MTP StorageID mapping table. This 
       
   112     StorageID may either be the physical MTP StorageID or the default logical 
       
   113     MTP StorageID.
       
   114     */
       
   115     TFixedArray<TInt, KMaxDrives> iMapDriveToStorage;
       
   116     
       
   117     /**
       
   118     The physical storage numbers allocation table. Indexed by physical storage 
       
   119     owner data provider ID.
       
   120     */
       
   121     RArray<TUint> iPhysicalStorageNumbers;
       
   122     
       
   123     /**
       
   124     The storages table.
       
   125     */
       
   126     RPointerArray<CMTPStorageMetaData> iStorages;
       
   127     
       
   128     RFs iFs;
       
   129     static CStifLogger* iLog;
       
   130     };
       
   131 
       
   132 #endif // CTESTSTORAGEMGR_H