|         |      1 /* | 
|         |      2 * Copyright (c) 2002-2006 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:  This class caches strings | 
|         |     15 * | 
|         |     16 */ | 
|         |     17  | 
|         |     18  | 
|         |     19  | 
|         |     20 #ifndef CFILEMANAGERSTRINGCACHE_H | 
|         |     21 #define CFILEMANAGERSTRINGCACHE_H | 
|         |     22  | 
|         |     23 // INCLUDES | 
|         |     24 #include <e32base.h> | 
|         |     25 #include <f32file.h> | 
|         |     26 #include <badesca.h> | 
|         |     27  | 
|         |     28 // CONSTANTS | 
|         |     29 const TInt KNumStringCacheItems = 16; | 
|         |     30 const TInt KFormatStringLen = KMaxFileName * 2; | 
|         |     31  | 
|         |     32 // FORWARD DECLARATIONS | 
|         |     33 class CFileManagerEngine; | 
|         |     34 class CFileManagerIconArray; | 
|         |     35  | 
|         |     36  | 
|         |     37 // CLASS DECLARATION | 
|         |     38 /** | 
|         |     39 *  This class caches strings   | 
|         |     40 * | 
|         |     41 *  @since 2.7 | 
|         |     42 */ | 
|         |     43 class CFileManagerStringCache : public CBase, public MDesCArray | 
|         |     44     { | 
|         |     45     public: | 
|         |     46  | 
|         |     47         /** | 
|         |     48         * Two-phased constructor. | 
|         |     49         */ | 
|         |     50         static CFileManagerStringCache* NewL( | 
|         |     51             CFileManagerEngine& aEngine, | 
|         |     52             CFileManagerIconArray& aIconArray ); | 
|         |     53  | 
|         |     54         void Clear() const; | 
|         |     55          | 
|         |     56         /** | 
|         |     57         * Destructor. | 
|         |     58         */ | 
|         |     59         ~CFileManagerStringCache(); | 
|         |     60  | 
|         |     61         /** | 
|         |     62          * Gets last error | 
|         |     63          */ | 
|         |     64         TInt LastError() const; | 
|         |     65  | 
|         |     66     public: // From MDesCArray | 
|         |     67  | 
|         |     68         TInt MdcaCount() const; | 
|         |     69         TPtrC MdcaPoint(TInt aIndex) const; | 
|         |     70      | 
|         |     71     private: | 
|         |     72         /** | 
|         |     73         * C++ default constructor. | 
|         |     74         */ | 
|         |     75         CFileManagerStringCache( | 
|         |     76             CFileManagerEngine& aEngine, | 
|         |     77             CFileManagerIconArray& aIconArray ); | 
|         |     78  | 
|         |     79         /** | 
|         |     80         * By default Symbian 2nd phase constructor is private. | 
|         |     81         */ | 
|         |     82         void ConstructL(); | 
|         |     83  | 
|         |     84         /** | 
|         |     85          * Sets last error | 
|         |     86          */ | 
|         |     87         void SetError( TInt aError ) const; | 
|         |     88  | 
|         |     89     private: | 
|         |     90  | 
|         |     91         /** | 
|         |     92         * Searches index from cache and return cache index | 
|         |     93         * so it can be retrieve with FormattedString | 
|         |     94         */ | 
|         |     95         TInt FormattedStringFound( TInt aIndex ) const; | 
|         |     96  | 
|         |     97         /** | 
|         |     98         * Retrieve string from cache with FormattedStringFound() | 
|         |     99         * given index | 
|         |    100         */ | 
|         |    101         TPtrC FormattedString( TInt aIndex ) const; | 
|         |    102  | 
|         |    103         /**  | 
|         |    104         * Stores string in iFormatted string with given  | 
|         |    105         * listbox index. Checks the fartest position  | 
|         |    106         * and stores there. | 
|         |    107         */ | 
|         |    108         void StoreFormattedStringL( TInt aIndex ) const; | 
|         |    109  | 
|         |    110         /** | 
|         |    111         * Clears cache item | 
|         |    112         * given index | 
|         |    113         */ | 
|         |    114         void Clear( TInt aIndex ) const; | 
|         |    115  | 
|         |    116     private: // Data | 
|         |    117         class TCacheItem | 
|         |    118             { | 
|         |    119             public: | 
|         |    120                 HBufC* iString; | 
|         |    121                 TInt   iIndex; | 
|         |    122             }; | 
|         |    123  | 
|         |    124         // Ref: To get item details | 
|         |    125         CFileManagerEngine&  iEngine; | 
|         |    126  | 
|         |    127         // Ref: To resolve icons | 
|         |    128         CFileManagerIconArray& iIconArray; | 
|         |    129  | 
|         |    130         // Own: array of formatted listbox items | 
|         |    131         TFixedArray< TCacheItem, KNumStringCacheItems > mutable | 
|         |    132             iFormattedItems; | 
|         |    133  | 
|         |    134         // Own: String buffer for formatting string | 
|         |    135         TBuf< KFormatStringLen > mutable iFormatString; | 
|         |    136  | 
|         |    137         // Own: Last error | 
|         |    138         TInt mutable iError; | 
|         |    139  | 
|         |    140     }; | 
|         |    141  | 
|         |    142 #endif      // CFILEMANAGERSTRINGCACHE_H | 
|         |    143              | 
|         |    144 // End of File | 
|         |    145  |