coreapplicationuis/SysAp/Src/memorycard/sysapdrivelist.h
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     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:  SysAp drive list implementation
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef SYSAPDRIVELIST_H
       
    20 #define SYSAPDRIVELIST_H
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include "SysAp.hrh"
       
    25 
       
    26 // FORWARD DECLARATIONS
       
    27 class RFs;
       
    28 
       
    29 // CLASS DECLARATION
       
    30 class CSysApDriveList : public CBase
       
    31     {
       
    32 public:
       
    33 
       
    34     /**
       
    35      * Two-phased constructor.
       
    36      */
       
    37     static CSysApDriveList* NewL( RFs& aFs );
       
    38 
       
    39     /**
       
    40      * Destructor
       
    41      */
       
    42     ~CSysApDriveList();
       
    43 
       
    44 public: // New methods
       
    45 
       
    46     /**
       
    47     * Mounts drive
       
    48     *
       
    49     * @param aDrive Drive to mount
       
    50     * @return System wide error code
       
    51     */
       
    52     TInt MountDrive( TInt aDrive );
       
    53 
       
    54     /**
       
    55     * Dismounts drive
       
    56     *
       
    57     * @param aDrive Drive to dismount
       
    58     * @return System wide error code
       
    59     */
       
    60     TInt DismountDrive( TInt aDrive );
       
    61 
       
    62     /**
       
    63      * Updates drive state stored in the list
       
    64      *
       
    65      * @param aDrive Drive to update
       
    66      * @param aForceUpdate ETrue if forced update. Otherwise EFalse.
       
    67      */
       
    68     void UpdateDrive( TInt aDrive, TBool aForceUpdate );
       
    69 
       
    70     /**
       
    71      * Returns the status of the memory card
       
    72      *
       
    73      * @param aDrive Drive what status to get
       
    74      * @return The memory card status
       
    75      */
       
    76     TSysApMemoryCardStatus MemoryCardStatus( TInt aDrive );
       
    77 
       
    78     /**
       
    79      * Returns the drive id of default memory card
       
    80      */
       
    81     TInt DefaultMemoryCard() const;
       
    82 
       
    83     // For entry data used by GetMemoryCardsL
       
    84     class TMemoryCardEntry
       
    85         {        
       
    86         public:
       
    87             /**
       
    88              * Compare for RArray::Find()
       
    89              */
       
    90             static TInt CompareFind(
       
    91                 const TInt* aDrive,
       
    92                 const TMemoryCardEntry& aEntry );
       
    93 
       
    94         public:
       
    95             TInt iDrive;
       
    96             TSysApMemoryCardStatus iStatus;
       
    97             TUint iDriveStatus;
       
    98         };
       
    99     
       
   100     // For inclusition mask used by GetMemoryCardsL
       
   101     enum TMemoryCardInclusionMask
       
   102         {
       
   103         EIncludeAll = 0x0,
       
   104         EIncludeInserted = 0x1,
       
   105         EIncludeNonInserted = 0x2,
       
   106         EIncludeLocked = 0x4
       
   107         };
       
   108 
       
   109     /**
       
   110      * Gets the memory cards with requested status
       
   111      *
       
   112      * @param aDriveArray Array to store memory cards
       
   113      * @param aInclusionMask Memory card inclusion mask 
       
   114      *                       specified by TMemoryCardInclusionMask
       
   115      */
       
   116     void GetMemoryCardsL(
       
   117         RArray< TMemoryCardEntry >& aDriveArray,
       
   118         TUint aInclusionMask );
       
   119 
       
   120     /**
       
   121      * Gets the drive name with text formatting
       
   122      *
       
   123      * @param aDrive Drive that name is requested
       
   124      * @param aTextIdForDefaultName Text id containing %U
       
   125      * @param aTextIdForName Text id containing %0U and %1U
       
   126      * @return Pointer to allocated text
       
   127      */
       
   128     HBufC* GetFormattedDriveNameLC(
       
   129         const TInt aDrive,
       
   130         const TInt aTextIdForDefaultName,
       
   131         const TInt aTextIdForName = 0 ) const;
       
   132 
       
   133     /**
       
   134      * Returns drive index from given array or KErrNotFound if not found
       
   135      */
       
   136     static TInt Find(
       
   137         const RArray< TMemoryCardEntry >& aDriveArray,
       
   138         TInt aDrive );
       
   139 
       
   140     // Drive eject type used in MarkDriveToEject
       
   141     enum TDriveEjectType
       
   142         {
       
   143         EEjectNone = 0,
       
   144         EEjectFromMenu,
       
   145         EEjectRemovedWithoutEject
       
   146         };
       
   147     /**
       
   148      * Marks drive to be ejected
       
   149      */
       
   150     void MarkDriveToEject( TInt aDrive, TDriveEjectType aEjectUsed );
       
   151 
       
   152     /**
       
   153      * Resets drive marked to be ejected
       
   154      */
       
   155     void ResetDriveToEject( TInt aDrive );
       
   156 
       
   157     /**
       
   158      * Resets all drives marked to be ejected
       
   159      */
       
   160     void ResetDrivesToEject();
       
   161 
       
   162     /**
       
   163      * Gets next drive to be ejected, returns KErrNotFound if none marked
       
   164      */
       
   165     TInt DriveToEject( TDriveEjectType& aEjectUsed );
       
   166 
       
   167     /**
       
   168      * Checks is drive marked to be ejected
       
   169      */
       
   170     TBool IsDriveToEject( TInt aDrive );
       
   171 
       
   172     /**
       
   173      * Marks drive insert beeps to be ignored
       
   174      */
       
   175     void MarkDrivesInsertBeepIgnored( const RArray< TMemoryCardEntry >& aArray );
       
   176 
       
   177     /**
       
   178      * Mark drive insert beep to be ignored
       
   179      */
       
   180     void MarkDriveInsertBeepIgnored( TInt aDrive );
       
   181 
       
   182     /**
       
   183      * Resets drive insert beep marked to be ignored
       
   184      */
       
   185     void ResetDriveInsertBeepIgnored( TInt aDrive );
       
   186 
       
   187     /**
       
   188      * Resets all drives marked inserts beeps
       
   189      */
       
   190     void ResetDrivesInsertBeepIgnored();
       
   191 
       
   192     /**
       
   193      * Checks is insert beep ignored
       
   194      */
       
   195     TBool IsDriveInsertBeepIgnored( TInt aDrive );
       
   196 
       
   197     /**
       
   198      * Marks locked drive's unlock query status as shown
       
   199      */
       
   200     void MarkDriveUnlockQueryShown( TInt aDrive );
       
   201 
       
   202     /**
       
   203      * Resets locked drive's unlock query shown status
       
   204      */
       
   205     void ResetDriveUnlockQueryShown( TInt aDrive );
       
   206 
       
   207     /**
       
   208      * Gets next locked drive to be unlocked. Returns KErrNotFound if none.
       
   209      * The locked drives where unlock query has been shown are ignored.
       
   210      */
       
   211     TInt DriveToUnlock();
       
   212 
       
   213     /**
       
   214      * Returns number of non USB drives in the array
       
   215      */
       
   216     static TInt NonUsbDriveCount( const RArray< TMemoryCardEntry >& aDriveArray );
       
   217 
       
   218 private:
       
   219 
       
   220     /**
       
   221     * Constructors.
       
   222     */
       
   223     CSysApDriveList( RFs& aFs );
       
   224 
       
   225     void ConstructL();
       
   226 
       
   227     // Used internally for drive states
       
   228     enum TDriveState
       
   229         {
       
   230         EStateStatusUpdated = 0x1,
       
   231         EStateEjectedFromMenu = 0x2,
       
   232         EStateRemovedWithoutEject = 0x4,
       
   233         EStateBeepIgnored = 0x8,
       
   234         EStateUnlockQueryShown = 0x10,
       
   235         EStateAllEjected = EStateEjectedFromMenu | EStateRemovedWithoutEject
       
   236         };
       
   237 
       
   238     // Used internally for drive status caching
       
   239     class TDriveStateEntry
       
   240         {
       
   241         public:
       
   242             TSysApMemoryCardStatus iStatus;
       
   243             TUint iState;
       
   244             TUint iDriveStatus;
       
   245         };
       
   246 
       
   247 private: // Data
       
   248     // Reference to open file server session
       
   249     RFs& iFs;
       
   250 
       
   251     // The default memory card drive
       
   252     TInt iDefaultMemoryCard;
       
   253 
       
   254     // Array for drive state caching
       
   255     TFixedArray< TDriveStateEntry, KMaxDrives > iStatusCache;
       
   256 
       
   257     };
       
   258 
       
   259 #endif // SYSAPDRIVELIST_H
       
   260 
       
   261 // End of File