2 * Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Dialog used to selection target memory.
19 #ifndef C_AKNMEMORYSELECTIONDIALOG_H
20 #define C_AKNMEMORYSELECTIONDIALOG_H
22 #include <CAknCommonDialogsBase.h>
23 #include <badesca.h> // CDesCArray
25 class CAknMemorySelectionModel;
26 class CAknMemorySelectionEventHandler;
27 class MAknMemorySelectionObserver;
32 * A class that launches a pop-up dialog for memory selection.
34 * @lib CommonDialogs.lib
37 NONSHARABLE_CLASS(CAknMemorySelectionDialog) : public CAknCommonDialogsBase
44 * @Deprecated: This only works with fixed C: and E: drives.
45 * Enumerations for memory items in listbox .
49 EPhoneMemory = 0, // C:
51 EMemoryCount // must remain last one
54 // Constructors and destructors
60 * @param aDialogType Defines the type of the dialog in order to read
61 * correct default settings for title and softkeys from resource.
62 * @param aShowUnavailableDrives Defines whether unavailable or corrupted
63 * drives are shown in memory selection list or not.
64 * @return Returns a pointer to an instance of itself.
66 IMPORT_C static CAknMemorySelectionDialog* NewL(
67 TCommonDialogType aDialogType,
68 TBool aShowUnavailableDrives );
75 * @param aDialogType Defines the type of the dialog in order to read
76 * correct default settings for title and softkeys from resource.
77 * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
78 * @param aShowUnavailableDrives Defines whether unavailable or corrupted
79 * drives are shown in memory selection list or not.
80 * @return Returns a pointer to an instance of itself.
82 IMPORT_C static CAknMemorySelectionDialog* NewL(
83 TCommonDialogType aDialogType,
85 TBool aShowUnavailableDrives );
91 * @param aDialogType Defines the type of the dialog in order to read
92 * correct default settings for title and softkeys from resource.
93 * @param aResourceId A resource id (MEMORYSELECTIONDIALOG).
94 * @param aShowUnavailableDrives Defines whether unavailable or corrupted
95 * drives are shown in memory selection list or not.
96 * @param aIncludedMedias bit flag definition of which medias are
97 * included in the dialog. See TMemoryTypes.
98 * @return Returns a pointer to an instance of itself.
100 IMPORT_C static CAknMemorySelectionDialog* NewL(
101 TCommonDialogType aDialogType,
103 TBool aShowUnavailableDrives,
104 TInt aIncludedMedias );
106 IMPORT_C virtual ~CAknMemorySelectionDialog();
111 * Sets an observer which is asked if the selected item can be selected.
113 * @param aObserver A pointer to an observer.
115 IMPORT_C void SetObserver( MAknMemorySelectionObserver* aObserver );
118 * Sets title for the dialog.
120 * @param aText Title text.
122 IMPORT_C void SetTitleL( const TDesC& aText );
125 * Sets the text used for left softkey.
127 * @param aText The text used for left softkey.
129 IMPORT_C void SetLeftSoftkeyL( const TDesC& aText );
132 * Sets the text used for right softkey.
134 * @param aText The text used for right softkey.
136 IMPORT_C void SetRightSoftkeyL( const TDesC& aText );
139 * Gets an item from memory selection dialog at specified index.
141 * @param aIndex Index to the item in the memory selection list.
142 * @param aItem A reference to a descriptor where the item is stored.
144 IMPORT_C void GetItem( TInt aIndex, TDes& aItem );
147 * Gets the location paths of a memory.
149 * @param aSelectedMemory The memory that was selected.
150 * @param aRootPath A pointer to a descriptor where the root path
151 * of the selected memory is stored. Must have KMaxFileName space.
152 * Set to NULL to ignore.
153 * @param aDefaultFolder A pointer to a descriptor where the default folder
154 * of the selected memory is stored. Must have KMaxFileName space.
155 * Set to NULL to ignore.
157 IMPORT_C void GetMemories( TMemory aSelectedMemory,
159 TDes* aDefaultFolder );
162 * Executes the memory selection dialog. Virtual to allow derivation.
164 * @param aSelectedMemory A reference to a memory (TMemory).
165 * If one of the memories is selected, the selected memory is
166 * stored to the parameter.
167 * @return Returns true if user has selected an item and false
168 * if user hits cancel.
170 IMPORT_C virtual TReturnKey ExecuteL( TMemory& aSelectedMemory );
173 * Executes the memory selection dialog. Virtual to allow derivation.
175 * @param aSelectedMemory A reference to a memory (TMemory).
176 * If one of the memories is selected, the selected memory is
177 * stored to the parameter.
178 * @param aRootPath A pointer to a descriptor where the root path
179 * of the selected memory is stored.
180 * @param aDefaultFolder A pointer to a descriptor where the default folder
181 * of the selected memory is stored.
182 * @return Returns true if user has selected an item and false
183 * if user hits cancel.
185 IMPORT_C virtual TReturnKey ExecuteL(
186 TMemory& aSelectedMemory,
187 TDes* aRootPath, TDes* aDefaultFolder );
190 * A static method that launches a memory selection dialog.
193 IMPORT_C static TBool RunDlgLD(
194 TMemory& aSelectedMemory,
195 MAknMemorySelectionObserver* aObserver = NULL );
198 * A static method that launches a memory selection dialog.
201 IMPORT_C static TBool RunDlgLD(
202 TMemory& aSelectedMemory,
204 MAknMemorySelectionObserver* aObserver = NULL );
207 * A static method that launches a memory selection dialog.
210 IMPORT_C static TBool RunDlgLD(
211 TMemory& aSelectedMemory,
213 TDes* aRootPath = NULL, TDes* aDefaultFolder = NULL,
214 MAknMemorySelectionObserver* aObserver = NULL );
217 * Returns the number of items in list box array.
218 * Not exported, for CFD internal use only.
220 * @return Returns the number of items in list box array.
222 TInt NumberOfItems() const;
225 * Maps drive paths according to selected listbox item. This function is
226 * valid for dynamic drives. The prerequisite for this function is that
227 * iRootPathArray and additionally iDefaultFolderArray indexes map
228 * correctly to iModel's listbox items.
231 * @param aLbxIndex Index to the selected listbox item.
232 * @param aRootPath A pointer to a descriptor where the root path of the
233 * selected drive will be stored. Must have KMaxFileName space.
234 * Set to NULL to ignore.
235 * @param aDefaultFolder A pointer to a descriptor where the default folder
236 * of the selected drive will be stored. Must have
238 * Set to NULL to ignore.
239 * @return Return error code
240 * KErrNone The drive is found in internal drive list
241 * KErrNotFound The drive is not visible to user or does not exist
243 TInt GetDrivePaths( TInt aLbxIndex,
245 TDes* aDefaultFolder );
249 // Constructors and destructors
251 CAknMemorySelectionDialog( TCommonDialogType aDialogType );
254 * Constructs class from resource
256 * @param aResourceId ID of the resource. Can be zero.
257 * @param aShowUnavailableDrives Defines whether unavailable or corrupted
258 * drives are shown in memory selection list or not.
260 virtual void ConstructFromResourceL(
262 TBool aShowUnavailableDrives );
265 * Constructs class from resource
267 * @param aResourceId ID of the resource. Can be zero.
268 * @param aShowUnavailableDrives Defines whether unavailable or corrupted
269 * drives are shown in memory selection list or not.
270 * @param aIncludedMedias bit flag definition of which medias are
271 * included in the dialog. See TMemoryTypes.
273 virtual void ConstructFromResourceL(
275 TBool aShowUnavailableDrives,
276 TInt aIncludedMedias );
283 * A static method for launching a memory selection dialog.
284 * Creates, constructs, runs and deletes a memory selection dialog with
285 * different parameters.
287 * @param aResourceId An id of a resource.
288 * @param aSelectedMemory A reference to a memory described in ExecuteL.
289 * @param aRootPath A pointer to a descriptor where the root path
290 * of the selected memory is stored.
291 * @param aDefaultFolder A pointer to a descriptor where the default folder
292 * of the selected memory is stored.
293 * @param aTitle A title for memory selection dialog.
294 * @param aObserver An observer which is asked if the selected item
295 * can be selected. Implemented in application..
299 TMemory& aSelectedMemory,
301 TDes* aDefaultFolder,
303 MAknMemorySelectionObserver* aObserver );
307 * Sets id to a default CFD resource depending on dialog type.
309 void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType )
313 * Reads settings from resource.
315 * @param aResourceId Resource's ID to be read.
316 * @param aResourceDefined If user defines the resource.
318 void ReadFromResourceL( TInt aResourceId, TBool aResourceDefined );
321 * Loads icons into the icon-array.
322 * @param aIconArray Array of which to append the loaded icons.
323 * @param aDoubleStyle Is the dialog doublestyle.
325 void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle );
328 * Loads default root and default paths of phone memory & memory card
330 void GetSystemPathsL();
335 TCommonDialogType iDialogType;
338 CAknMemorySelectionModel* iModel;
340 // Own: Event handler
341 CAknMemorySelectionEventHandler* iEventHandler;
344 MAknMemorySelectionObserver* iObserver;
349 // Own: Left softkey text
352 // Own: Right softkey text
353 HBufC* iRightSoftkey;
355 // Own: Root path array
356 // iDynamicDrivesEnabled indicates the content of this array.
357 CDesCArrayFlat iRootPathArray;
359 // Own: Default folder array
360 CDesCArrayFlat iDefaultFolderArray;
362 // Own: ETrue if dynamic drive reading is enabled
363 // EFalse if drives are static (C: and E:).
364 // This affects iRootPathArray and iDefaultFolderArray content and
366 TBool iDynamicDrivesEnabled;
368 TInt iIncludedMedias;
371 #endif // C_AKNMEMORYSELECTIONDIALOG_H