filemanager/GFLM/inc/CGflmFileRecognizer.h
changeset 0 6a9f87576119
child 13 5181328fad28
equal deleted inserted replaced
-1:000000000000 0:6a9f87576119
       
     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:  Recogniser wrapper
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef CGFLMFILERECOGNIZER_H
       
    21 #define CGFLMFILERECOGNIZER_H
       
    22 
       
    23 
       
    24 //  INCLUDES
       
    25 #include <apgcli.h>
       
    26 #include <e32base.h>
       
    27 #include <barsc.h>
       
    28 
       
    29 
       
    30 // FORWARD DECLARATIONS
       
    31 class CGflmDriveResolver;
       
    32 
       
    33 
       
    34 // CLASS DECLARATION
       
    35 
       
    36 /**
       
    37 *  A class for wrapping recogniser functionality.
       
    38 *
       
    39 *  @lib GFLM.lib
       
    40 *  @since 2.0
       
    41 */
       
    42 NONSHARABLE_CLASS(CGflmFileRecognizer) : public CBase
       
    43     {
       
    44     public:  // Constructors and destructor
       
    45 
       
    46         /**
       
    47         * Two-phased constructor.
       
    48         */
       
    49         static CGflmFileRecognizer* NewL(
       
    50             RFs& aFs,
       
    51             TInt aMemoryConsumption,
       
    52             CGflmDriveResolver* aDriveResolver );
       
    53 
       
    54         /**
       
    55         * Destructor.
       
    56         */
       
    57         virtual ~CGflmFileRecognizer();
       
    58 
       
    59     public: // New functions
       
    60 
       
    61         /**
       
    62         * Recognises a MIME type of file.
       
    63         * @since S60 3.1
       
    64         * @param aFilename A name of the file
       
    65         * @return Pointer to MIME type. KNullDesC if not recognised.
       
    66         */
       
    67         TPtrC RecognizeL( const TDesC& aFilename );
       
    68 
       
    69          /**
       
    70         * Flushed recogniser cache.
       
    71         * @since S60 3.1
       
    72         */
       
    73         void FlushCache();
       
    74 
       
    75     private:
       
    76         
       
    77         NONSHARABLE_CLASS(CPathTypePair) : public CBase
       
    78             {
       
    79             public:
       
    80                 static CPathTypePair* NewLC( const TDesC& aFilename );
       
    81                 void ConstructL( const TDesC& aFilename );
       
    82                 CPathTypePair();
       
    83                 ~CPathTypePair();
       
    84                 TInt Size() const;
       
    85 
       
    86             public:
       
    87                 TDblQueLink iLink;
       
    88                 TInt iTypeIndex;
       
    89                 HBufC* iFilename;
       
    90             };
       
    91 
       
    92         NONSHARABLE_CLASS(CExtMimePair) : public CBase
       
    93             {
       
    94             public:
       
    95                 ~CExtMimePair();
       
    96 
       
    97             public:
       
    98                 HBufC* iExt;
       
    99                 HBufC* iMime;
       
   100             };
       
   101 
       
   102         /**
       
   103         * C++ default constructor.
       
   104         */
       
   105         CGflmFileRecognizer(
       
   106             CGflmDriveResolver* aDriveResolver,
       
   107             RFs& aFs );
       
   108 
       
   109         /**
       
   110         * By default Symbian 2nd phase constructor is private.
       
   111         */
       
   112         void ConstructL( TInt aMemoryConsumption );
       
   113 
       
   114         /**
       
   115         * Cleans old entries from cache according to specified per cent
       
   116         *
       
   117         */
       
   118         void CleanupCache( );
       
   119 
       
   120         /**
       
   121         * Constructs file extension mime pairs
       
   122         *
       
   123         */
       
   124         void ConstructExtMimePairsL(
       
   125             RResourceFile& aResFile,
       
   126             TInt aResId,
       
   127             RPointerArray< CExtMimePair >& aPairs );
       
   128 
       
   129         /**
       
   130         * Finds mime from file extension
       
   131         *
       
   132         */
       
   133         TPtrC FindMimeFromExt(
       
   134             const TDesC& aExt, RPointerArray< CExtMimePair >& aPairs );
       
   135 
       
   136         /**
       
   137         * Does actual recognition
       
   138         *
       
   139         */
       
   140         TPtrC DoRecognizeL( const TDesC& aFilename );
       
   141 
       
   142     private:    // Data
       
   143         // Own: For using the apparc recognisers
       
   144         RApaLsSession iApaSession;
       
   145 
       
   146         // Array for mime types, owned
       
   147         CDesCArraySeg* iMimeTypes;
       
   148 
       
   149         // Mime type cache, owned
       
   150         TDblQue< CPathTypePair > iCache;
       
   151 
       
   152         // Current memory usage for cache
       
   153         TInt iCacheMemoryUsage;
       
   154 
       
   155         // Maximum memory usage for cache
       
   156         TInt iCacheMaxMemoryUsage;
       
   157 
       
   158         // Ref: Pointer to drive resolver
       
   159         CGflmDriveResolver* iDriveResolver;
       
   160 
       
   161         // Own: General file extension mime pairs
       
   162         RPointerArray< CExtMimePair > iExtMimePairs;
       
   163 
       
   164         // Own: Remote drive specific file extension mime pairs
       
   165         RPointerArray< CExtMimePair > iRemoteExtMimePairs;
       
   166 
       
   167         // Ref: Open file server session
       
   168         RFs& iFs;
       
   169 
       
   170     };
       
   171 
       
   172 #endif      // CGFLMFILERECOGNIZER_H
       
   173 
       
   174 // End of File