21
|
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 |
/**
|
|
143 |
* Reset and Destroy the RPointArray of CExtMimePair
|
|
144 |
*
|
|
145 |
*/
|
|
146 |
static void ResetAndDestroyExtMimePairs( TAny* aPtr );
|
|
147 |
|
|
148 |
private: // Data
|
|
149 |
// Own: For using the apparc recognisers
|
|
150 |
RApaLsSession iApaSession;
|
|
151 |
|
|
152 |
// Array for mime types, owned
|
|
153 |
CDesCArraySeg* iMimeTypes;
|
|
154 |
|
|
155 |
// Mime type cache, owned
|
|
156 |
TDblQue< CPathTypePair > iCache;
|
|
157 |
|
|
158 |
// Current memory usage for cache
|
|
159 |
TInt iCacheMemoryUsage;
|
|
160 |
|
|
161 |
// Maximum memory usage for cache
|
|
162 |
TInt iCacheMaxMemoryUsage;
|
|
163 |
|
|
164 |
// Ref: Pointer to drive resolver
|
|
165 |
CGflmDriveResolver* iDriveResolver;
|
|
166 |
|
|
167 |
// Own: General file extension mime pairs
|
|
168 |
RPointerArray< CExtMimePair > iExtMimePairs;
|
|
169 |
|
|
170 |
// Own: Remote drive specific file extension mime pairs
|
|
171 |
RPointerArray< CExtMimePair > iRemoteExtMimePairs;
|
|
172 |
|
|
173 |
// Ref: Open file server session
|
|
174 |
RFs& iFs;
|
|
175 |
|
|
176 |
};
|
|
177 |
|
|
178 |
#endif // CGFLMFILERECOGNIZER_H
|
|
179 |
|
|
180 |
// End of File
|