|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * This class implements a model of a file list. |
|
16 * The class is inherited from MDesCArray, so it can be used directly |
|
17 * as a model for a listbox. |
|
18 * |
|
19 * |
|
20 */ |
|
21 |
|
22 |
|
23 |
|
24 #ifndef __CFLDFILELISTMODEL_H__ |
|
25 #define __CFLDFILELISTMODEL_H__ |
|
26 |
|
27 // INTERNAL INCLUDES |
|
28 |
|
29 // EXTERNAL INCLUDES |
|
30 #include <e32base.h> |
|
31 #include <bamdesca.h> |
|
32 #include <badesca.h> |
|
33 #include <CLFContentListing.hrh> |
|
34 #include <MCLFChangedItemObserver.h> |
|
35 #include <MCLFPostFilter.h> |
|
36 |
|
37 // FORWARD DECLARATIONS |
|
38 class CFLDOperationObserver; |
|
39 class CFLDChangedItemObserver; |
|
40 class MCLFContentListingEngine; |
|
41 class MCLFItemListModel; |
|
42 class CFLDEntryReference; |
|
43 class MFLDEntryFormatter; |
|
44 class CFLDWaitNote; |
|
45 class RConeResourceLoader; |
|
46 class TResourceReader; |
|
47 class MCLFModifiableItem; |
|
48 class CFLDPopupList; |
|
49 |
|
50 // CLASS DECLARATION |
|
51 /** |
|
52 * This class implements a model of a file list. |
|
53 * The class is inherited from MDesCArray, so it can be used directly |
|
54 * as a model for a listbox. |
|
55 * |
|
56 * @lib filelist.lib |
|
57 * @since 2.1 |
|
58 */ |
|
59 NONSHARABLE_CLASS( CFLDFileListModel ) |
|
60 : public CBase, public MDesCArray, public MCLFPostFilter |
|
61 { |
|
62 public: // Constructors and destructors |
|
63 |
|
64 /** |
|
65 * Two-phased static constructor. |
|
66 * @param aModelResourceId A CLF model resource, see CLFContentListing.rh |
|
67 * @param aDirectoriesResourceId A resource using FILELISTDIRECTORIES |
|
68 * structure, see FileListModel.rh for details |
|
69 * @return A pointer to a constructed CFLDFileListModel object |
|
70 */ |
|
71 static CFLDFileListModel* NewL( |
|
72 const TInt aModelResourceId, const TInt aDirectoriesResourceId ); |
|
73 |
|
74 /** |
|
75 * Two-phased static constructor. |
|
76 * @param aModelResourceId A CLF model resource, see CLFContentListing.rh |
|
77 * @param aDirectoriesResourceId A resource using FILELISTDIRECTORIES |
|
78 * structure, see FileListModel.rh for details |
|
79 * @return A pointer to a constructed CFLDFileListModel object |
|
80 */ |
|
81 static CFLDFileListModel* NewLC( |
|
82 const TInt aModelResourceId, const TInt aDirectoriesResourceId ); |
|
83 |
|
84 /** |
|
85 * Destructor. |
|
86 */ |
|
87 virtual ~CFLDFileListModel(); |
|
88 |
|
89 private: // Constructors and destructors |
|
90 |
|
91 /** |
|
92 * Constructor |
|
93 */ |
|
94 CFLDFileListModel(); |
|
95 |
|
96 /** |
|
97 * Second phase constructor |
|
98 * @param aModelResourceId A CLF model resource, see CLFContentListing.rh |
|
99 * @param aDirectoriesResourceId A resource using FILELISTDIRECTORIES |
|
100 * structure, see FileListModel.rh for details |
|
101 */ |
|
102 void ConstructL( |
|
103 const TInt aModelResourceId, const TInt aDirectoriesResourceId ); |
|
104 |
|
105 public: // New methods |
|
106 |
|
107 /** |
|
108 * Returns file media type |
|
109 * @param aFileName A descriptor containing the media file name |
|
110 * @return Media file type (see TCLFMediaType enumeration |
|
111 * inside CFLContentListing.hrh) |
|
112 */ |
|
113 TInt32 MediaFileType( const TDesC& aFileName ) const; |
|
114 |
|
115 /** |
|
116 * Adds a new MIME type into blocking list. |
|
117 * @param aMimeType The blocked MIME type |
|
118 */ |
|
119 void AddExclusiveMimeTypeL( const TDesC& aMimeType ); |
|
120 |
|
121 /** |
|
122 * Adds a new media type into blocking list. |
|
123 * @param aMediaType The blocked media type (see TCLFMediaType enumeration |
|
124 * inside CFLContentListing.hrh) |
|
125 */ |
|
126 void AddExclusiveMediaTypeL( const TInt32 aMediaType ); |
|
127 |
|
128 /** |
|
129 * Removes all the defined exlusive MIME types |
|
130 */ |
|
131 void ResetExclusiveMimeTypes(); |
|
132 |
|
133 /** |
|
134 * Removes all the defined exlusive media types |
|
135 */ |
|
136 void ResetExclusiveMediaTypes(); |
|
137 |
|
138 /** |
|
139 * Sets wanted mime types. Overrides all settings defined inside |
|
140 * resource, defined with AddExclusive -methods or with |
|
141 * SetWanted -methods. |
|
142 * @param aMimeTypes The array containing wanted MIME types |
|
143 */ |
|
144 void SetWantedMimeTypesL( const MDesCArray& aMimeTypes ); |
|
145 |
|
146 /** |
|
147 * Sets wanted media types. Overrides all settings defined inside |
|
148 * resource, defined with AddExclusive -methods or with |
|
149 * SetWanted -methods. |
|
150 * @param aMediaTypes The array containing wanted media types |
|
151 */ |
|
152 void SetWantedMediaTypesL( const TArray<TCLFMediaType>& aMediaTypes ); |
|
153 |
|
154 /** |
|
155 * Refreshes the file list. |
|
156 */ |
|
157 void RefreshEntryListL(); |
|
158 |
|
159 /** |
|
160 * Sets popup list to Model. Needed to update the listbox after the |
|
161 * model has changed (e.g. after inserting a memory card). |
|
162 * @param aPopupList The popup list |
|
163 */ |
|
164 void SetPopupList( CFLDPopupList* aPopupList ); |
|
165 |
|
166 /** |
|
167 * Retrieves a full path of an entry (e.g. "c:\folder\file.ext") |
|
168 * @param aFileName A modifiable descriptor where the path and filename |
|
169 * is placed, or KNullDesc if aIndex points to the null text item. |
|
170 * Note: aFileName.Length() >= KMaxFileName |
|
171 * @param aIndex Index of the entry to retrieve |
|
172 */ |
|
173 void GetFileName( TDes& aFileName, const TInt aIndex ); |
|
174 |
|
175 /** |
|
176 * Sets an MFLDEntryFormatter inherited for the model. Ownership of the given |
|
177 * object is transferred to CFLDFileListModel. |
|
178 * @param aFormatter A pointer to a MFLDEntryFormatter inherited object. |
|
179 */ |
|
180 void SetEntryFormatter( MFLDEntryFormatter* aFormatter ); |
|
181 |
|
182 /** |
|
183 * Adds a text (e.g. "None") as the first item of the list, |
|
184 * which will not be sorted among the file name items. |
|
185 * @param aItemText A descriptor containing the null item text |
|
186 */ |
|
187 void InsertNullItemL( const TDesC& aItemText ); |
|
188 |
|
189 /** |
|
190 * Adds a text (e.g. "None") as the first item of the list, |
|
191 * which will not be sorted among the file name items. |
|
192 * @param aItemText A descriptor containing the null item text |
|
193 * @param aFileName A descriptor containing the ringing tone file name form null item |
|
194 */ |
|
195 void InsertNullItemL( const TDesC& aItemText, const TDesC& aFileName ); |
|
196 |
|
197 /** |
|
198 * Adds a text (e.g. "None") as the last item of the list, |
|
199 * which will not be sorted among the file name items. |
|
200 * @param aItemText A descriptor containing the null item text |
|
201 */ |
|
202 void InsertEndNullItemL( const TDesC& aItemText ); |
|
203 |
|
204 /** |
|
205 * Adds a text (e.g. "None") as the last item of the list, |
|
206 * which will not be sorted among the file name items. |
|
207 * @param aItemText A descriptor containing the null item text |
|
208 * @param aFileName A descriptor containing the ringing tone file name form null item |
|
209 */ |
|
210 void InsertEndNullItemL( const TDesC& aItemText, const TDesC& aFileName ); |
|
211 |
|
212 /** |
|
213 * Find a file from the model's list |
|
214 * @param aFileName The file name to be searched |
|
215 * @return An index to the searched file, or KErrNotFound |
|
216 */ |
|
217 TInt FindFileL( const TDesC& aFileName ); |
|
218 |
|
219 /** |
|
220 * Sets the maximum file size for the list. |
|
221 * @param aMaxFileSize The maximum file size in bytes. If you want to allow all file |
|
222 * sizes, set this to KFLDNoSizeFiltering (defined in FileListModel.hrh). |
|
223 */ |
|
224 void SetMaxFileSize( const TInt aMaxFileSize ); |
|
225 |
|
226 /** |
|
227 * Returns PopupList. |
|
228 */ |
|
229 CFLDPopupList* GetPopupList(); |
|
230 |
|
231 private: // Methods derived from MDesCArray |
|
232 |
|
233 TPtrC16 MdcaPoint( TInt aIndex ) const; |
|
234 |
|
235 TInt MdcaCount() const; |
|
236 |
|
237 private: // Methods derived from MCLFPostFilter |
|
238 |
|
239 void FilterItemsL( const TArray<MCLFItem*>& aItemList, |
|
240 RPointerArray<MCLFItem>& aFilteredItemList ); |
|
241 |
|
242 private: // New methods |
|
243 |
|
244 /* |
|
245 * Checks if file needs to be filtered out from model |
|
246 * @param aMimeType Media MIME type |
|
247 * @param aMediaType Media type |
|
248 * @param aPathAndFileName Path and filename |
|
249 * @return EFalse if MO should be filtered out |
|
250 */ |
|
251 TBool CheckRules( |
|
252 TPtrC& aMimeType, TInt32 aMediaType, TPtrC& aPathAndFileName ); |
|
253 |
|
254 /** |
|
255 * Fill the entry reference list according to the added directories list |
|
256 * and filtering parameters |
|
257 */ |
|
258 void PopulateReferenceListL(); |
|
259 |
|
260 /** |
|
261 * List all files from the list model to the list box. |
|
262 */ |
|
263 void PopulateListBoxL(); |
|
264 |
|
265 /** |
|
266 * Gets a filename at specific index. |
|
267 * @param aIndex Index of the file (whole list is indexed) |
|
268 * @param aFileName Descriptor where the filename is stored. |
|
269 */ |
|
270 void GetFileNameAtIndex( TInt aIndex, TDes& aFileName ) const; |
|
271 |
|
272 /** |
|
273 * Scans user defined Rom directories and adds found entries |
|
274 * into iRomRingingToneArray |
|
275 */ |
|
276 void ScanRomDirectoriesL(); |
|
277 |
|
278 /** |
|
279 * Scans user defined Rom directories and adds found entries |
|
280 * into iRomRingingToneArray |
|
281 */ |
|
282 void ScanRomDirectoriesAndInsertL(); |
|
283 |
|
284 /** |
|
285 * Adds directory into iDirectoryPaths |
|
286 * @param aDirectory Directory to be scanned |
|
287 */ |
|
288 TInt AddDirectoryL( const TDesC& aDirectory ); |
|
289 |
|
290 /** |
|
291 * Adds directory into iRomDirectoryPaths |
|
292 * @param aDirectory Directory to be scanned |
|
293 */ |
|
294 TInt AddRomDirectoryL( const TDesC& aDirectory ); |
|
295 |
|
296 /** |
|
297 * Loads directories from resource file |
|
298 * @param aDirectoriesResourceId Resource ID to directory structure |
|
299 */ |
|
300 void LoadDirectoriesL( const TInt aDirectoriesResourceId ); |
|
301 |
|
302 /** |
|
303 * Checks ringing tone file size. |
|
304 * @param aFile file to check. |
|
305 * @param aSizeLimit maximum allowed file size in bytes. |
|
306 * @return KErrNone, if ok. |
|
307 * KErrTooBig, if configurable file size limit exceeded. |
|
308 */ |
|
309 TInt CheckToneFileSizeL( const TDesC& aFile, TInt aSizeLimit ); |
|
310 |
|
311 private: // Data |
|
312 |
|
313 /// Own: Content listing engine |
|
314 MCLFContentListingEngine* iEngine; |
|
315 |
|
316 /// Own: Content listing model |
|
317 MCLFItemListModel* iModel; |
|
318 |
|
319 /// Own: Content listeng operation observer |
|
320 CFLDOperationObserver* iObserver; |
|
321 |
|
322 /// Own: Content listeng operation observer |
|
323 CFLDChangedItemObserver* iChangedItemObserver; |
|
324 |
|
325 /// Own: MFLDEntryFormatter to use in formatting the entries |
|
326 MFLDEntryFormatter* iEntryFormatter; |
|
327 |
|
328 /// Own: Wait note dialog for indicating refreshing process of the List Model |
|
329 CFLDWaitNote* iWaitNote; |
|
330 |
|
331 /// Contains references to all the entries. This is the list that |
|
332 /// gets sorted and filtered |
|
333 RPointerArray<CFLDEntryReference> iEntryReferences; |
|
334 |
|
335 /// Optional text items in the beginning of the list |
|
336 RPointerArray<HBufC> iNullTextArray; |
|
337 |
|
338 /// Optional ringing tones for null texts |
|
339 RPointerArray<HBufC> iNullTextRingingToneArray; |
|
340 |
|
341 /// Optional text items in the end of the list |
|
342 RPointerArray<HBufC> iEndNullTextArray; |
|
343 |
|
344 /// Optional ringing tones for end null items |
|
345 RPointerArray<HBufC> iEndNullTextRingingToneArray; |
|
346 |
|
347 /// For waiting the asynchronous refresh operation to complete |
|
348 CActiveSchedulerWait iWait; |
|
349 |
|
350 /// Array for exclusive mimetypes. |
|
351 CDesCArraySeg iExclusiveMimeTypes; |
|
352 |
|
353 /// Array for exclusive mediatypes. |
|
354 RArray<TInt32> iExclusiveMediaTypes; |
|
355 |
|
356 /// Contains descriptors containing |
|
357 /// the user-defined phone directory paths |
|
358 CDesCArraySeg iDirectoryPaths; |
|
359 |
|
360 /// Contains descriptors containing |
|
361 /// the user-defined ROM directory paths |
|
362 CDesCArraySeg iRomDirectoryPaths; |
|
363 |
|
364 /// Array for user-defined ringingtones |
|
365 RPointerArray<MCLFModifiableItem> iRomRingingToneArray; |
|
366 |
|
367 /// Maximum file size in bytes |
|
368 TInt iMaxFileSize; |
|
369 |
|
370 /// Popup list |
|
371 CFLDPopupList* iPopupList; |
|
372 |
|
373 /// Using ROM tones only |
|
374 TBool iRomTonesOnly; |
|
375 }; |
|
376 |
|
377 #endif // __CFLDFILELISTMODEL_H__ |
|
378 |
|
379 // End of File |