2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: New memory selection dialog to support multiple drives.
20 #ifndef C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
21 #define C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H
23 #include <CAknCommonDialogsBase.h>
24 #include <badesca.h> // CDesCArray
25 #include <f32file.h> // TDriveNumber
27 class CAknMemorySelectionModelMultiDrive;
28 class CAknMemorySelectionEventHandler;
29 class MAknMemorySelectionObserver;
34 * A class that launches a pop-up dialog for memory (drive) selection.
36 * It is used to replace CAknMemorySelectionDialog class to support multiple
39 * @lib CommonDialogs.lib
42 NONSHARABLE_CLASS( CAknMemorySelectionDialogMultiDrive )
43 : public CAknCommonDialogsBase
48 // Constructors and destructors
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.
60 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
61 TCommonDialogType aDialogType,
62 TBool aShowUnavailableDrives );
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.
77 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
78 TCommonDialogType aDialogType,
80 TBool aShowUnavailableDrives );
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.
96 IMPORT_C static CAknMemorySelectionDialogMultiDrive* NewL(
97 TCommonDialogType aDialogType,
99 TBool aShowUnavailableDrives,
100 TInt aIncludedMedias );
102 IMPORT_C virtual ~CAknMemorySelectionDialogMultiDrive();
107 * Sets title for the dialog.
110 * @param aText Title text.
112 IMPORT_C void SetTitleL( const TDesC& aText );
115 * Sets the text used for left softkey.
118 * @param aText The text used for left softkey.
120 IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
123 * Sets the text used for right softkey.
125 * @param aText The text used for right softkey.
127 IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
130 * Gets an item from memory selection dialog at specified index.
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.
136 IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
140 * Executes the memory selection dialog. Virtual to allow derivation.
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.
149 IMPORT_C virtual TReturnKey ExecuteL( TDriveNumber& aSelectedDrive );
152 * Executes the memory selection dialog. Virtual to allow derivation.
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.
165 IMPORT_C virtual TReturnKey ExecuteL(
166 TDriveNumber& aSelectedDrive,
167 TDes* aRootPath, TDes* aDefaultFolder );
170 * A static method that launches a memory selection dialog.
175 IMPORT_C static TBool RunDlgLD( TDriveNumber& aSelectedDrive );
178 * New overloaded function to support multiple drives.
179 * A static method that launches a memory selection dialog.
184 IMPORT_C static TBool RunDlgLD(
185 TDriveNumber& aSelectedDrive, const TDesC& aTitle );
188 * A static method that launches a memory selection dialog.
193 IMPORT_C static TBool RunDlgLD(
194 TDriveNumber& aSelectedDrive,
196 TDes* aRootPath = NULL,
197 TDes* aDefaultFolder = NULL );
200 * Returns the number of items in list box array.
201 * Not exported, for CFD internal use only.
203 * @return Returns the number of items in list box array.
205 TInt NumberOfItems() const;
208 * Maps drive paths according to drive number. This function is valid
209 * for dynamic drives.
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
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
224 TInt GetDrivePaths( TDriveNumber aDrive,
226 TDes* aDefaultFolder );
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.
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
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
247 TInt GetDrivePaths( TInt aLbxIndex,
249 TDes* aDefaultFolder );
252 * Add user defined root path and default folder into memory selection
253 * dialog. It is used to replace old user defined resource.
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\
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
273 * <C drive's root path>\"MyFolder\"
275 * The trailing backslash will be added automatically whether user
278 * @return Return error code
280 IMPORT_C TInt AddDrivePathsL( const TDesC& aRootPath,
281 const TDesC& aDefaultFolder );
284 * Gets item index based on given drive number.
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
291 IMPORT_C TInt FindIndexByDrive( const TDriveNumber& aDrive );
294 * Get drive number based on item index in the listbox
296 * @param aIndex Listbox's item index.
297 * @return Return drive number
299 TDriveNumber FindDriveByIndex( const TInt aIndex );
302 * Check if there is any unavailable MMC (not inserted).
304 * @return ETrue There is at least one MMC unavailble.
305 * EFalse MMC inserted.
307 TBool HasUnavailbleMMC();
316 // Constructors and destructors
318 CAknMemorySelectionDialogMultiDrive( TCommonDialogType aDialogType );
321 * Constructs class from resource
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.
327 virtual void ConstructFromResourceL(
329 TBool aShowUnavailableDrives );
332 * Constructs class from resource
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.
340 virtual void ConstructFromResourceL(
342 TBool aShowUnavailableDrives,
343 TInt aIncludedMedias );
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.
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.
366 TDriveNumber& aSelectedDrive,
368 TDes* aDefaultFolder,
369 const TDesC& aTitle );
372 * Sets id to a default CFD resource depending on dialog type.
374 void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
378 * Reads settings from resource.
380 void ReadFromResourceL( TInt aResourceId );
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.
387 void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
390 * Get all user visible drives with information of their root paths and
392 * Internal usage for memory selection dialog
393 * @param aUserDefinedId Is the user defined resource id;
395 void GetSystemDrivesL( TInt aUserDefinedId );
402 TCommonDialogType iDialogType;
405 CAknMemorySelectionModelMultiDrive* iModel;
407 // Own: Event handler
408 CAknMemorySelectionEventHandler* iEventHandler;
413 // Own: Left softkey text
416 // Own: Right softkey text
417 HBufC* iRightSoftkey;
419 // Own: Root path array
420 CDesCArrayFlat iRootPathArray;
422 // Own: Default folder array
423 CDesCArrayFlat iDefaultFolderArray;
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
429 TBool iDynamicDrivesEnabled;
432 * Indicate which media types of drives could be visible.
434 TInt iIncludedMedias;
438 #endif // C_AKNMEMORYSELECTIONDIALOGMULTIDRIVE_H