|
1 /* |
|
2 * Copyright (c) 2007 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: New memory selection dialog to support multiple drives. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H |
|
21 #define C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H |
|
22 |
|
23 #include <CAknCommonDialogsBase.h> |
|
24 #include <badesca.h> // CDesCArray |
|
25 #include <f32file.h> // TDriveNumber |
|
26 |
|
27 class CAknMemorySelectionModelMultiDrive; |
|
28 class CAknMemorySelectionEventHandler; |
|
29 class MAknMemorySelectionObserver; |
|
30 class TDriveInfo; |
|
31 class CAknIconArray; |
|
32 |
|
33 /** |
|
34 * A class that launches a pop-up dialog for memory (drive) selection. |
|
35 * |
|
36 * It is used to replace CAknMemorySelectionDialog class to support multiple |
|
37 * drives. |
|
38 * |
|
39 * @lib CommonDialogs.lib |
|
40 * @since S60 5.0 |
|
41 */ |
|
42 NONSHARABLE_CLASS( CAknMemorySelectionDialogMultiDrive ) |
|
43 : public CAknCommonDialogsBase |
|
44 { |
|
45 public: |
|
46 |
|
47 |
|
48 // Constructors and destructors |
|
49 |
|
50 /** |
|
51 * Static constructor. |
|
52 * |
|
53 * @since S60 5.0 |
|
54 * @param aDialogType Defines the type of the dialog in order to read |
|
55 * correct default settings for title and softkeys from resource. |
|
56 * @param aShowUnavailableDrives Defines whether unavailable or corrupted |
|
57 * drives are shown in memory selection list or not. |
|
58 * @return Returns a pointer to an instance of itself. |
|
59 */ |
|
60 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL( |
|
61 TCommonDialogType aDialogType, |
|
62 TBool aShowUnavailableDrives ); |
|
63 |
|
64 |
|
65 /** |
|
66 * Static constructor. |
|
67 * |
|
68 * @since S60 5.0 |
|
69 * @param aDialogType Defines the type of the dialog in order to read |
|
70 * correct default settings for title and softkeys from resource. |
|
71 * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations" |
|
72 * part of resource is not used any more. |
|
73 * @param aShowUnavailableDrives Defines whether unavailable or corrupted |
|
74 * drives are shown in memory selection list or not. |
|
75 * @return Returns a pointer to an instance of itself. |
|
76 */ |
|
77 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL( |
|
78 TCommonDialogType aDialogType, |
|
79 TInt aResourceId, |
|
80 TBool aShowUnavailableDrives ); |
|
81 |
|
82 /** |
|
83 * Static constructor. |
|
84 * |
|
85 * @since S60 5.0 |
|
86 * @param aDialogType Defines the type of the dialog in order to read |
|
87 * correct default settings for title and softkeys from resource. |
|
88 * @param aResourceId A resource id (MEMORYSELECTIONDIALOG). "Locations" |
|
89 * part of resource is not used any more. |
|
90 * @param aShowUnavailableDrives Defines whether unavailable or corrupted |
|
91 * drives are shown in memory selection list or not. |
|
92 * @param aIncludedMedias bit flag definition of which medias are |
|
93 * included in the dialog. See TMemoryTypes. |
|
94 * @return Returns a pointer to an instance of itself. |
|
95 */ |
|
96 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL( |
|
97 TCommonDialogType aDialogType, |
|
98 TInt aResourceId, |
|
99 TBool aShowUnavailableDrives, |
|
100 TInt aIncludedMedias ); |
|
101 |
|
102 IMPORT_C virtual ~CAknMemorySelectionDialogMultiDrive(); |
|
103 |
|
104 // New functions |
|
105 |
|
106 /** |
|
107 * Sets title for the dialog. |
|
108 * |
|
109 * @since S60 5.0 |
|
110 * @param aText Title text. |
|
111 */ |
|
112 IMPORT_C void SetTitleL( const TDesC& aText ); |
|
113 |
|
114 /** |
|
115 * Sets the text used for left softkey. |
|
116 * |
|
117 * @since S60 5.0 |
|
118 * @param aText The text used for left softkey. |
|
119 */ |
|
120 IMPORT_C void SetLeftSoftkeyL( const TDesC& aText ); |
|
121 |
|
122 /** |
|
123 * Sets the text used for right softkey. |
|
124 * |
|
125 * @param aText The text used for right softkey. |
|
126 */ |
|
127 IMPORT_C void SetRightSoftkeyL( const TDesC& aText ); |
|
128 |
|
129 /** |
|
130 * Gets an item from memory selection dialog at specified index. |
|
131 * |
|
132 * @since S60 5.0 |
|
133 * @param aIndex Index to the item in the memory selection list. |
|
134 * @param aItem A reference to a descriptor where the item is stored. |
|
135 */ |
|
136 IMPORT_C void GetItem( TInt aIndex, TDes& aItem ); |
|
137 |
|
138 |
|
139 /** |
|
140 * Executes the memory selection dialog. Virtual to allow derivation. |
|
141 * |
|
142 * @since S60 5.0 |
|
143 * @param aSelectedDrive A reference to a drive. |
|
144 * If one of the drives is selected, the selected drive is |
|
145 * stored to the parameter. |
|
146 * @return Returns true if user has selected an item and false |
|
147 * if user hits cancel. |
|
148 */ |
|
149 IMPORT_C virtual TReturnKey ExecuteL( TDriveNumber& aSelectedDrive ); |
|
150 |
|
151 /** |
|
152 * Executes the memory selection dialog. Virtual to allow derivation. |
|
153 * |
|
154 * @since S60 5.0 |
|
155 * @param aSelectedDrive A reference to a drive. |
|
156 * If one of the drives is selected, the selected drive is |
|
157 * stored to the parameter. |
|
158 * @param aRootPath A pointer to a descriptor where the root path |
|
159 * of the selected memory is stored. |
|
160 * @param aDefaultFolder A pointer to a descriptor where the default folder |
|
161 * of the selected memory is stored. |
|
162 * @return Returns true if user has selected an item and false |
|
163 * if user hits cancel. |
|
164 */ |
|
165 IMPORT_C virtual TReturnKey ExecuteL( |
|
166 TDriveNumber& aSelectedDrive, |
|
167 TDes* aRootPath, TDes* aDefaultFolder ); |
|
168 |
|
169 /** |
|
170 * A static method that launches a memory selection dialog. |
|
171 * |
|
172 * @since S60 5.0 |
|
173 * @see RunL() |
|
174 */ |
|
175 IMPORT_C static TBool RunDlgLD( TDriveNumber& aSelectedDrive ); |
|
176 |
|
177 /** |
|
178 * New overloaded function to support multiple drives. |
|
179 * A static method that launches a memory selection dialog. |
|
180 * |
|
181 * @since S60 5.0 |
|
182 * @see RunL() |
|
183 */ |
|
184 IMPORT_C static TBool RunDlgLD( |
|
185 TDriveNumber& aSelectedDrive, const TDesC& aTitle ); |
|
186 |
|
187 /** |
|
188 * A static method that launches a memory selection dialog. |
|
189 * |
|
190 * @since S60 5.0 |
|
191 * @see RunL() |
|
192 */ |
|
193 IMPORT_C static TBool RunDlgLD( |
|
194 TDriveNumber& aSelectedDrive, |
|
195 TInt aResourceId, |
|
196 TDes* aRootPath = NULL, |
|
197 TDes* aDefaultFolder = NULL ); |
|
198 |
|
199 /** |
|
200 * Returns the number of items in list box array. |
|
201 * Not exported, for CFD internal use only. |
|
202 * |
|
203 * @return Returns the number of items in list box array. |
|
204 */ |
|
205 TInt NumberOfItems() const; |
|
206 |
|
207 /** |
|
208 * Maps drive paths according to drive number. This function is valid |
|
209 * for dynamic drives. |
|
210 * |
|
211 * @since S60 5.0 |
|
212 * @param aDrive Drive number. |
|
213 * @param aRootPath A pointer to a descriptor where the root path of the |
|
214 * selected drive will be stored. Must have KMaxFileName space. |
|
215 * Set to NULL to ignore. |
|
216 * @param aDefaultFolder A pointer to a descriptor where the default folder |
|
217 * of the selected drive will be stored. Must have |
|
218 * KMaxFileNamespace. |
|
219 * Set to NULL to ignore. |
|
220 * @return Return error code |
|
221 * KErrNone The drive is found in internal drive list |
|
222 * KErrNotFound The drive is not visible to user or does not exist |
|
223 */ |
|
224 TInt GetDrivePaths( TDriveNumber aDrive, |
|
225 TDes* aRootPath, |
|
226 TDes* aDefaultFolder ); |
|
227 |
|
228 /** |
|
229 * Maps drive paths according to selected listbox item. This function is |
|
230 * valid for dynamic drives. The prerequisite for this function is that |
|
231 * iRootPathArray and additionally iDefaultFolderArray indexes map |
|
232 * correctly to iModel's listbox items. |
|
233 * |
|
234 * @since S60 5.0 |
|
235 * @param aLbxIndex Index to the selected listbox item. |
|
236 * @param aRootPath A pointer to a descriptor where the root path of the |
|
237 * selected drive will be stored. Must have KMaxFileName space. |
|
238 * Set to NULL to ignore. |
|
239 * @param aDefaultFolder A pointer to a descriptor where the default folder |
|
240 * of the selected drive will be stored. Must have |
|
241 * KMaxFileNamespace. |
|
242 * Set to NULL to ignore. |
|
243 * @return Return error code |
|
244 * KErrNone The drive is found in internal drive list |
|
245 * KErrNotFound The drive is not visible to user or does not exist |
|
246 */ |
|
247 TInt GetDrivePaths( TInt aLbxIndex, |
|
248 TDes* aRootPath, |
|
249 TDes* aDefaultFolder ); |
|
250 |
|
251 /** |
|
252 * Add user defined root path and default folder into memory selection |
|
253 * dialog. It is used to replace old user defined resource. |
|
254 * |
|
255 * @since S60 5.0 |
|
256 * @param aRootPath A pointer to a descriptor where the root path of the |
|
257 * selected drive will be stored. Must have KMaxFileName space. |
|
258 * Set to NULL to ignore. |
|
259 * The user defined root path will be added after each drive's root |
|
260 * path. For example, if user specifics "Sounds\Digital\" for root |
|
261 * path, then the root paths for all drives will be: |
|
262 * C:\Data\Sounds\Digital\ |
|
263 * E:\Sounds\Digital\ |
|
264 * F:\Sounds\Digital\ |
|
265 * ... |
|
266 * |
|
267 * @param aDefaultFolder A pointer to a descriptor where the default folder |
|
268 * of the selected drive will be stored. Must have KMaxFileName |
|
269 * space. The user defined root path will be added after each drive's |
|
270 * root path. Set to NULL to ignore. For example, if user specifics |
|
271 * "MyFolder\" for default folder, then the default folders of all |
|
272 * drives will be: |
|
273 * <C drive's root path>\"MyFolder\" |
|
274 * ... |
|
275 * The trailing backslash will be added automatically whether user |
|
276 * add it or not. |
|
277 * |
|
278 * @return Return error code |
|
279 */ |
|
280 IMPORT_C TInt AddDrivePathsL( const TDesC& aRootPath, |
|
281 const TDesC& aDefaultFolder ); |
|
282 |
|
283 /** |
|
284 * Gets item index based on given drive number. |
|
285 * |
|
286 * @since S60 5.0 |
|
287 * @param aDrive Drive to be searched. |
|
288 * @return Return item index if given drive is found in memory selection |
|
289 * dialog's drive list. Othewise return KErrNotFound |
|
290 */ |
|
291 IMPORT_C TInt FindIndexByDrive( const TDriveNumber& aDrive ); |
|
292 |
|
293 /** |
|
294 * Get drive number based on item index in the listbox |
|
295 * |
|
296 * @param aIndex Listbox's item index. |
|
297 * @return Return drive number |
|
298 */ |
|
299 TDriveNumber FindDriveByIndex( const TInt aIndex ); |
|
300 |
|
301 /** |
|
302 * Check if there is any unavailable MMC (not inserted). |
|
303 * |
|
304 * @return ETrue There is at least one MMC unavailble. |
|
305 * EFalse MMC inserted. |
|
306 */ |
|
307 TBool HasUnavailbleMMC(); |
|
308 |
|
309 /** |
|
310 * Update model. |
|
311 * */ |
|
312 void UpdateModelL(); |
|
313 |
|
314 protected: |
|
315 |
|
316 // Constructors and destructors |
|
317 |
|
318 CAknMemorySelectionDialogMultiDrive( TCommonDialogType aDialogType ); |
|
319 |
|
320 /** |
|
321 * Constructs class from resource |
|
322 * |
|
323 * @param aResourceId ID of the resource. Can be zero. |
|
324 * @param aShowUnavailableDrives Defines whether unavailable or corrupted |
|
325 * drives are shown in memory selection list or not. |
|
326 */ |
|
327 virtual void ConstructFromResourceL( |
|
328 TInt aResourceId, |
|
329 TBool aShowUnavailableDrives ); |
|
330 |
|
331 /** |
|
332 * Constructs class from resource |
|
333 * |
|
334 * @param aResourceId ID of the resource. Can be zero. |
|
335 * @param aShowUnavailableDrives Defines whether unavailable or corrupted |
|
336 * drives are shown in memory selection list or not. |
|
337 * @param aIncludedMedias bit flag definition of which medias are |
|
338 * included in the dialog. See TMemoryTypes. |
|
339 */ |
|
340 virtual void ConstructFromResourceL( |
|
341 TInt aResourceId, |
|
342 TBool aShowUnavailableDrives, |
|
343 TInt aIncludedMedias ); |
|
344 |
|
345 private: |
|
346 |
|
347 // New functions |
|
348 |
|
349 /** |
|
350 * New overloaded function to support multiple drives. |
|
351 * A static method for launching a memory selection dialog. |
|
352 * Creates, constructs, runs and deletes a memory selection dialog with |
|
353 * different parameters. |
|
354 * |
|
355 * @since S60 5.0 |
|
356 * @param aResourceId An id of a resource. |
|
357 * @param aSelectedMemory A reference to a memory described in ExecuteL. |
|
358 * @param aRootPath A pointer to a descriptor where the root path |
|
359 * of the selected memory is stored. |
|
360 * @param aDefaultFolder A pointer to a descriptor where the default folder |
|
361 * of the selected memory is stored. |
|
362 * @param aTitle A title for memory selection dialog. |
|
363 */ |
|
364 static TBool RunL( |
|
365 TInt aResourceId, |
|
366 TDriveNumber& aSelectedDrive, |
|
367 TDes* aRootPath, |
|
368 TDes* aDefaultFolder, |
|
369 const TDesC& aTitle ); |
|
370 |
|
371 /** |
|
372 * Sets id to a default CFD resource depending on dialog type. |
|
373 */ |
|
374 void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType ) |
|
375 const; |
|
376 |
|
377 /** |
|
378 * Reads settings from resource. |
|
379 */ |
|
380 void ReadFromResourceL( TInt aResourceId ); |
|
381 |
|
382 /** |
|
383 * Loads icons into the icon-array. |
|
384 * @param aIconArray Array of which to append the loaded icons. |
|
385 * @param aDoubleStyle Is the dialog doublestyle. |
|
386 */ |
|
387 void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle ); |
|
388 |
|
389 /** |
|
390 * Get all user visible drives with information of their root paths and |
|
391 * default folders. |
|
392 * Internal usage for memory selection dialog |
|
393 * @param aUserDefinedId Is the user defined resource id; |
|
394 */ |
|
395 void GetSystemDrivesL( TInt aUserDefinedId ); |
|
396 |
|
397 protected: |
|
398 |
|
399 // Data |
|
400 |
|
401 // Own: Dialog type |
|
402 TCommonDialogType iDialogType; |
|
403 |
|
404 // Own: Model |
|
405 CAknMemorySelectionModelMultiDrive* iModel; |
|
406 |
|
407 // Own: Event handler |
|
408 CAknMemorySelectionEventHandler* iEventHandler; |
|
409 |
|
410 // Own: Title |
|
411 HBufC* iTitle; |
|
412 |
|
413 // Own: Left softkey text |
|
414 HBufC* iLeftSoftkey; |
|
415 |
|
416 // Own: Right softkey text |
|
417 HBufC* iRightSoftkey; |
|
418 |
|
419 // Own: Root path array |
|
420 CDesCArrayFlat iRootPathArray; |
|
421 |
|
422 // Own: Default folder array |
|
423 CDesCArrayFlat iDefaultFolderArray; |
|
424 |
|
425 // Own: ETrue if dynamic drive reading is enabled |
|
426 // EFalse if drives are static (C: and E:). |
|
427 // This affects iRootPathArray and iDefaultFolderArray content and |
|
428 // ordering. |
|
429 TBool iDynamicDrivesEnabled; |
|
430 |
|
431 /** |
|
432 * Indicate which media types of drives could be visible. |
|
433 */ |
|
434 TInt iIncludedMedias; |
|
435 |
|
436 }; |
|
437 |
|
438 #endif // C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H |