|
1 /* |
|
2 * Copyright (c) 2002-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: Dialog used to selection target memory. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef C_AKNMEMORYSELECTIONDIALOG_H |
|
20 #define C_AKNMEMORYSELECTIONDIALOG_H |
|
21 |
|
22 #include <CAknCommonDialogsBase.h> |
|
23 #include <badesca.h> // CDesCArray |
|
24 |
|
25 class CAknMemorySelectionModel; |
|
26 class CAknMemorySelectionEventHandler; |
|
27 class MAknMemorySelectionObserver; |
|
28 class TDriveInfo; |
|
29 class CAknIconArray; |
|
30 |
|
31 /** |
|
32 * A class that launches a pop-up dialog for memory selection. |
|
33 * |
|
34 * @lib CommonDialogs.lib |
|
35 * @since S60 1.2 |
|
36 */ |
|
37 NONSHARABLE_CLASS(CAknMemorySelectionDialog) : public CAknCommonDialogsBase |
|
38 { |
|
39 |
|
40 public: |
|
41 |
|
42 // Enumerations |
|
43 /** |
|
44 * @Deprecated: This only works with fixed C: and E: drives. |
|
45 * Enumerations for memory items in listbox . |
|
46 */ |
|
47 enum TMemory |
|
48 { |
|
49 EPhoneMemory = 0, // C: |
|
50 EMemoryCard, // E: |
|
51 EMemoryCount // must remain last one |
|
52 }; |
|
53 |
|
54 // Constructors and destructors |
|
55 |
|
56 /** |
|
57 * Static constructor. |
|
58 * |
|
59 * @since S60 3.2 |
|
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. |
|
65 */ |
|
66 IMPORT_C static CAknMemorySelectionDialog* NewL( |
|
67 TCommonDialogType aDialogType, |
|
68 TBool aShowUnavailableDrives ); |
|
69 |
|
70 |
|
71 /** |
|
72 * Static constructor. |
|
73 * |
|
74 * @since S60 3.2 |
|
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. |
|
81 */ |
|
82 IMPORT_C static CAknMemorySelectionDialog* NewL( |
|
83 TCommonDialogType aDialogType, |
|
84 TInt aResourceId, |
|
85 TBool aShowUnavailableDrives ); |
|
86 |
|
87 /** |
|
88 * Static constructor. |
|
89 * |
|
90 * @since S60 3.2 |
|
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. |
|
99 */ |
|
100 IMPORT_C static CAknMemorySelectionDialog* NewL( |
|
101 TCommonDialogType aDialogType, |
|
102 TInt aResourceId, |
|
103 TBool aShowUnavailableDrives, |
|
104 TInt aIncludedMedias ); |
|
105 |
|
106 IMPORT_C virtual ~CAknMemorySelectionDialog(); |
|
107 |
|
108 // New functions |
|
109 |
|
110 /** |
|
111 * Sets an observer which is asked if the selected item can be selected. |
|
112 * |
|
113 * @param aObserver A pointer to an observer. |
|
114 */ |
|
115 IMPORT_C void SetObserver( MAknMemorySelectionObserver* aObserver ); |
|
116 |
|
117 /** |
|
118 * Sets title for the dialog. |
|
119 * |
|
120 * @param aText Title text. |
|
121 */ |
|
122 IMPORT_C void SetTitleL( const TDesC& aText ); |
|
123 |
|
124 /** |
|
125 * Sets the text used for left softkey. |
|
126 * |
|
127 * @param aText The text used for left softkey. |
|
128 */ |
|
129 IMPORT_C void SetLeftSoftkeyL( const TDesC& aText ); |
|
130 |
|
131 /** |
|
132 * Sets the text used for right softkey. |
|
133 * |
|
134 * @param aText The text used for right softkey. |
|
135 */ |
|
136 IMPORT_C void SetRightSoftkeyL( const TDesC& aText ); |
|
137 |
|
138 /** |
|
139 * Gets an item from memory selection dialog at specified index. |
|
140 * |
|
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. |
|
143 */ |
|
144 IMPORT_C void GetItem( TInt aIndex, TDes& aItem ); |
|
145 |
|
146 /** |
|
147 * Gets the location paths of a memory. |
|
148 * |
|
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. |
|
156 */ |
|
157 IMPORT_C void GetMemories( TMemory aSelectedMemory, |
|
158 TDes* aRootPath, |
|
159 TDes* aDefaultFolder ); |
|
160 |
|
161 /** |
|
162 * Executes the memory selection dialog. Virtual to allow derivation. |
|
163 * |
|
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. |
|
169 */ |
|
170 IMPORT_C virtual TReturnKey ExecuteL( TMemory& aSelectedMemory ); |
|
171 |
|
172 /** |
|
173 * Executes the memory selection dialog. Virtual to allow derivation. |
|
174 * |
|
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. |
|
184 */ |
|
185 IMPORT_C virtual TReturnKey ExecuteL( |
|
186 TMemory& aSelectedMemory, |
|
187 TDes* aRootPath, TDes* aDefaultFolder ); |
|
188 |
|
189 /** |
|
190 * A static method that launches a memory selection dialog. |
|
191 * @see RunL() |
|
192 */ |
|
193 IMPORT_C static TBool RunDlgLD( |
|
194 TMemory& aSelectedMemory, |
|
195 MAknMemorySelectionObserver* aObserver = NULL ); |
|
196 |
|
197 /** |
|
198 * A static method that launches a memory selection dialog. |
|
199 * @see RunL() |
|
200 */ |
|
201 IMPORT_C static TBool RunDlgLD( |
|
202 TMemory& aSelectedMemory, |
|
203 const TDesC& aTitle, |
|
204 MAknMemorySelectionObserver* aObserver = NULL ); |
|
205 |
|
206 /** |
|
207 * A static method that launches a memory selection dialog. |
|
208 * @see RunL() |
|
209 */ |
|
210 IMPORT_C static TBool RunDlgLD( |
|
211 TMemory& aSelectedMemory, |
|
212 TInt aResourceId, |
|
213 TDes* aRootPath = NULL, TDes* aDefaultFolder = NULL, |
|
214 MAknMemorySelectionObserver* aObserver = NULL ); |
|
215 |
|
216 /** |
|
217 * Returns the number of items in list box array. |
|
218 * Not exported, for CFD internal use only. |
|
219 * |
|
220 * @return Returns the number of items in list box array. |
|
221 */ |
|
222 TInt NumberOfItems() const; |
|
223 |
|
224 /** |
|
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. |
|
229 * |
|
230 * @since S60 3.2 |
|
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 |
|
237 * KMaxFileNamespace. |
|
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 |
|
242 */ |
|
243 TInt GetDrivePaths( TInt aLbxIndex, |
|
244 TDes* aRootPath, |
|
245 TDes* aDefaultFolder ); |
|
246 |
|
247 protected: |
|
248 |
|
249 // Constructors and destructors |
|
250 |
|
251 CAknMemorySelectionDialog( TCommonDialogType aDialogType ); |
|
252 |
|
253 /** |
|
254 * Constructs class from resource |
|
255 * |
|
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. |
|
259 */ |
|
260 virtual void ConstructFromResourceL( |
|
261 TInt aResourceId, |
|
262 TBool aShowUnavailableDrives ); |
|
263 |
|
264 /** |
|
265 * Constructs class from resource |
|
266 * |
|
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. |
|
272 */ |
|
273 virtual void ConstructFromResourceL( |
|
274 TInt aResourceId, |
|
275 TBool aShowUnavailableDrives, |
|
276 TInt aIncludedMedias ); |
|
277 |
|
278 private: |
|
279 |
|
280 // New functions |
|
281 |
|
282 /** |
|
283 * A static method for launching a memory selection dialog. |
|
284 * Creates, constructs, runs and deletes a memory selection dialog with |
|
285 * different parameters. |
|
286 * |
|
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.. |
|
296 */ |
|
297 static TBool RunL( |
|
298 TInt aResourceId, |
|
299 TMemory& aSelectedMemory, |
|
300 TDes* aRootPath, |
|
301 TDes* aDefaultFolder, |
|
302 const TDesC& aTitle, |
|
303 MAknMemorySelectionObserver* aObserver ); |
|
304 |
|
305 |
|
306 /** |
|
307 * Sets id to a default CFD resource depending on dialog type. |
|
308 */ |
|
309 void SetResourceId( TInt& aResourceId, TCommonDialogType aDialogType ) |
|
310 const; |
|
311 |
|
312 /** |
|
313 * Reads settings from resource. |
|
314 * |
|
315 * @param aResourceId Resource's ID to be read. |
|
316 * @param aResourceDefined If user defines the resource. |
|
317 */ |
|
318 void ReadFromResourceL( TInt aResourceId, TBool aResourceDefined ); |
|
319 |
|
320 /** |
|
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. |
|
324 */ |
|
325 void LoadIconsL( CAknIconArray* aIconArray, TBool aDoubleStyle ); |
|
326 |
|
327 /** |
|
328 * Loads default root and default paths of phone memory & memory card |
|
329 */ |
|
330 void GetSystemPathsL(); |
|
331 |
|
332 protected: // Data |
|
333 |
|
334 // Own: Dialog type |
|
335 TCommonDialogType iDialogType; |
|
336 |
|
337 // Own: Model |
|
338 CAknMemorySelectionModel* iModel; |
|
339 |
|
340 // Own: Event handler |
|
341 CAknMemorySelectionEventHandler* iEventHandler; |
|
342 |
|
343 // Ref: Observer |
|
344 MAknMemorySelectionObserver* iObserver; |
|
345 |
|
346 // Own: Title |
|
347 HBufC* iTitle; |
|
348 |
|
349 // Own: Left softkey text |
|
350 HBufC* iLeftSoftkey; |
|
351 |
|
352 // Own: Right softkey text |
|
353 HBufC* iRightSoftkey; |
|
354 |
|
355 // Own: Root path array |
|
356 // iDynamicDrivesEnabled indicates the content of this array. |
|
357 CDesCArrayFlat iRootPathArray; |
|
358 |
|
359 // Own: Default folder array |
|
360 CDesCArrayFlat iDefaultFolderArray; |
|
361 |
|
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 |
|
365 // ordering. |
|
366 TBool iDynamicDrivesEnabled; |
|
367 |
|
368 TInt iIncludedMedias; |
|
369 }; |
|
370 |
|
371 #endif // C_AKNMEMORYSELECTIONDIALOG_H |