24 #include "AknCFDUtility.h" |
24 #include "AknCFDUtility.h" |
25 #include "CAknCFDFileSystemEvent.h" |
25 #include "CAknCFDFileSystemEvent.h" |
26 #include "MAknCFDFileSystemObserver.h" |
26 #include "MAknCFDFileSystemObserver.h" |
27 |
27 |
28 |
28 |
29 NONSHARABLE_CLASS(CAknMemorySelectionSettingItemExtension) : public CBase, |
29 NONSHARABLE_CLASS(CAknMemorySelectionSettingItemExtension) |
30 public MAknCFDFileSystemObserver |
30 : public CBase, |
|
31 public MAknCFDFileSystemObserver |
31 { |
32 { |
32 |
33 |
33 public: |
34 public: |
34 CAknMemorySelectionSettingItemExtension(CAknMemorySelectionSettingItemMultiDrive* aSettingItem); |
35 CAknMemorySelectionSettingItemExtension( |
|
36 CAknMemorySelectionSettingItemMultiDrive* aSettingItem ); |
35 ~CAknMemorySelectionSettingItemExtension(); |
37 ~CAknMemorySelectionSettingItemExtension(); |
36 |
38 |
37 // second phase construct |
39 /** |
38 void ConstructL(); |
40 * second phase construct |
|
41 * |
|
42 * @param aIncludedMedias bit flag definition of which medias are |
|
43 * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes. |
|
44 */ |
|
45 void ConstructL( TInt aIncludedMedias ); |
39 |
46 |
40 /** |
47 /** |
41 * Static constructor. |
48 * Static constructor. |
42 * |
49 * |
43 * @since S60 5.0 |
50 * @since S60 5.0 |
44 * @param aSettingItem defines a pointer to the setting item. |
51 * @param aSettingItem defines a pointer to the setting item. |
|
52 * @param aIncludedMedias bit flag definition of which medias are |
|
53 * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes. |
|
54 * if not set, use dialog default value. |
45 * @return Returns a pointer to an instance of itself. |
55 * @return Returns a pointer to an instance of itself. |
46 */ |
56 */ |
47 static CAknMemorySelectionSettingItemExtension* NewL(CAknMemorySelectionSettingItemMultiDrive* aSettingItem); |
57 static CAknMemorySelectionSettingItemExtension* NewL( |
48 |
58 CAknMemorySelectionSettingItemMultiDrive* aSettingItem, |
|
59 TInt aIncludedMedias = -1 ); |
|
60 |
|
61 /** |
|
62 * Construct memory selection dialog |
|
63 * |
|
64 * @param aIncludedMedias bit flag definition of which medias are |
|
65 * included in the dialog. See AknCommonDialogsDynMem::TMemoryTypes. |
|
66 */ |
|
67 void ConstructDialogL( TInt aIncludedMedias ); |
49 |
68 |
50 // Functions from base interface MAknCFDFileSystemObserver |
69 // Functions from base interface MAknCFDFileSystemObserver |
51 /** |
70 /** |
52 * From MAknCFDFileSystemObserver |
71 * From MAknCFDFileSystemObserver |
53 */ |
72 */ |
117 iExtension->iDialog->ExecuteL( iInternalData, NULL, NULL ); |
142 iExtension->iDialog->ExecuteL( iInternalData, NULL, NULL ); |
118 } |
143 } |
119 else |
144 else |
120 { |
145 { |
121 // Changed with selection key |
146 // Changed with selection key |
122 if( ( iExtension->iDialog->NumberOfItems() == 2 ) && |
147 if( ( iExtension->iDialog->NumberOfItems() == 2 ) ) |
123 ( !iExtension->iDialog->HasUnavailbleMMC() ) ) |
|
124 { |
148 { |
125 // Two items in list, function as binary pop-up setting page |
149 // Two items in list, function as binary pop-up setting page |
126 TInt selectedIndex = |
150 TInt selectedIndex = |
127 iExtension->iDialog->FindIndexByDrive( |
151 iExtension->iDialog->FindIndexByDrive( iInternalData ); |
128 iInternalData ); |
|
129 if ( selectedIndex == KErrNotFound ) |
152 if ( selectedIndex == KErrNotFound ) |
130 { |
153 { |
131 selectedIndex = 0; |
154 selectedIndex = 0; |
132 } |
155 } |
133 else |
156 else |
134 { |
157 { |
135 selectedIndex = 1 - selectedIndex; // switch to another one. |
158 TDriveNumber driveNum = |
|
159 iExtension->iDialog->FindDriveByIndex( 1 - selectedIndex ); |
|
160 if ( AknCFDUtility::DriveStatusL( driveNum ) == EDriveOK ) |
|
161 { |
|
162 selectedIndex = 1 - selectedIndex; // switch to another one. |
|
163 } |
136 } |
164 } |
137 iInternalData = |
165 iInternalData = |
138 iExtension->iDialog->FindDriveByIndex( selectedIndex ); |
166 iExtension->iDialog->FindDriveByIndex( selectedIndex ); |
139 } |
167 } |
140 else |
168 else |
141 { |
169 { |
142 iExtension->iDialog->ExecuteL( |
170 iExtension->iDialog->ExecuteL( iInternalData, NULL, NULL ); |
143 iInternalData, NULL, NULL ); |
|
144 } |
171 } |
145 } |
172 } |
146 |
173 |
147 UpdateListBoxTextL(); |
174 UpdateListBoxTextL(); |
148 |
175 |
180 { |
207 { |
181 // This in case application hasn't called CompleteConstructionL() |
208 // This in case application hasn't called CompleteConstructionL() |
182 CompleteConstructionL(); |
209 CompleteConstructionL(); |
183 } |
210 } |
184 |
211 |
185 TInt memoryIndex = iExtension->iDialog->FindIndexByDrive( |
212 TInt memoryIndex = iExtension->iDialog->FindIndexByDrive( iInternalData ); |
186 iInternalData ); |
213 if ( AknCFDUtility::DriveStatusL( iInternalData ) != EDriveOK ) |
187 if ( AknCFDUtility::DriveStatusL( iInternalData ) |
214 { |
188 != EDriveOK ) |
215 // Find the first proper drive in the dialog list. |
189 { |
216 memoryIndex = 0; |
190 TInt drive; |
217 while ( memoryIndex < iExtension->iDialog->NumberOfItems() ) |
191 User::LeaveIfError( DriveInfo::GetDefaultDrive( |
218 { |
192 DriveInfo::EDefaultSystem, drive ) ); |
219 iInternalData = iExtension->iDialog->FindDriveByIndex( memoryIndex ); |
193 memoryIndex = iExtension->iDialog->FindIndexByDrive( |
220 if ( AknCFDUtility::DriveStatusL( iInternalData ) == EDriveOK ) |
194 TDriveNumber( drive ) ); |
221 { |
195 } |
222 break; |
|
223 } |
|
224 memoryIndex++; |
|
225 } |
|
226 // Not find the proper drive. |
|
227 if ( memoryIndex == iExtension->iDialog->NumberOfItems() ) |
|
228 { |
|
229 iInternalData = EDriveC; |
|
230 memoryIndex = KErrNotFound; |
|
231 } |
|
232 } |
|
233 |
|
234 if ( memoryIndex == KErrNotFound ) |
|
235 { |
|
236 return KNullDesC; |
|
237 } |
|
238 |
196 if( !iSettingText ) |
239 if( !iSettingText ) |
197 iSettingText = HBufC::NewL( KMaxName ); |
240 iSettingText = HBufC::NewL( KMaxName ); |
198 TPtr ptrSettingText( iSettingText->Des() ); |
241 TPtr ptrSettingText( iSettingText->Des() ); |
199 iExtension->iDialog->GetItem( memoryIndex, ptrSettingText ); |
242 iExtension->iDialog->GetItem( memoryIndex, ptrSettingText ); |
|
243 |
200 return *iSettingText; |
244 return *iSettingText; |
201 } |
245 } |
202 |
246 |
203 |
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CAknMemorySelectionSettingItemMultiDrive::UpdateSettingItemContentL |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
204 void CAknMemorySelectionSettingItemMultiDrive::UpdateSettingItemContentL() |
252 void CAknMemorySelectionSettingItemMultiDrive::UpdateSettingItemContentL() |
205 { |
253 { |
206 if ( iExtension->iDialog != NULL ) |
254 if ( iExtension->iDialog != NULL ) |
207 { |
255 { |
208 // Update model. |
256 // Update model. |
209 iExtension->iDialog->UpdateModelL(); |
257 iExtension->iDialog->UpdateModelL(); |
210 |
258 |
211 // Update setting item value. |
259 // Update setting item value. |
212 TInt selectedIndex = iExtension->iDialog-> |
260 TInt selectedIndex = iExtension->iDialog-> |
213 FindIndexByDrive(iInternalData); |
261 FindIndexByDrive( iInternalData ); |
214 |
262 |
215 if (selectedIndex == KErrNotFound) |
263 if ( selectedIndex == KErrNotFound ) |
216 { |
264 { |
217 iInternalData = EDriveC; |
265 // If the selected index is not found, set it to the first one |
|
266 selectedIndex = 0; |
218 } |
267 } |
219 else |
268 iInternalData = iExtension->iDialog->FindDriveByIndex( selectedIndex ); |
220 { |
|
221 iInternalData = iExtension->iDialog-> |
|
222 FindDriveByIndex(selectedIndex); |
|
223 } |
|
224 |
269 |
225 UpdateListBoxTextL(); |
270 UpdateListBoxTextL(); |
226 } |
271 } |
227 } |
272 } |
228 |
273 |
|
274 // --------------------------------------------------------------------------- |
|
275 // CAknMemorySelectionSettingItemMultiDrive::SetIncludedMediasL |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C void CAknMemorySelectionSettingItemMultiDrive::SetIncludedMediasL( |
|
279 TInt aIncludedMedias ) |
|
280 { |
|
281 if ( !iExtension ) |
|
282 { |
|
283 iExtension = CAknMemorySelectionSettingItemExtension::NewL( |
|
284 this, aIncludedMedias ); |
|
285 } |
|
286 else if ( iExtension->iIncludedMedias != aIncludedMedias ) |
|
287 { |
|
288 iExtension->ConstructDialogL( aIncludedMedias ); |
|
289 } |
|
290 } |
|
291 |
229 |
292 |
230 // --------------------------------------------------------------------------- |
293 // --------------------------------------------------------------------------- |
231 // CAknMemorySelectionSettingItemExtension |
294 // CAknMemorySelectionSettingItemExtension |
232 // Constructor |
295 // Constructor |
233 // --------------------------------------------------------------------------- |
296 // --------------------------------------------------------------------------- |
234 // |
297 // |
235 CAknMemorySelectionSettingItemExtension:: |
298 CAknMemorySelectionSettingItemExtension:: |
236 CAknMemorySelectionSettingItemExtension(CAknMemorySelectionSettingItemMultiDrive* aSettingItem) |
299 CAknMemorySelectionSettingItemExtension( |
|
300 CAknMemorySelectionSettingItemMultiDrive* aSettingItem ) |
237 : iSettingItem( aSettingItem ) |
301 : iSettingItem( aSettingItem ) |
238 { |
302 { |
239 } |
303 } |
240 |
304 |
241 |
305 |
274 } |
338 } |
275 } |
339 } |
276 |
340 |
277 // --------------------------------------------------------------------------- |
341 // --------------------------------------------------------------------------- |
278 // CAknMemorySelectionSettingItemExtension |
342 // CAknMemorySelectionSettingItemExtension |
|
343 // ConstructDialogL |
|
344 // --------------------------------------------------------------------------- |
|
345 // |
|
346 void CAknMemorySelectionSettingItemExtension::ConstructDialogL( |
|
347 TInt aIncludedMedias ) |
|
348 { |
|
349 if ( iDialog ) |
|
350 { |
|
351 delete iDialog; |
|
352 iDialog = NULL; |
|
353 } |
|
354 |
|
355 iIncludedMedias = aIncludedMedias; |
|
356 |
|
357 if ( aIncludedMedias == -1 ) |
|
358 { |
|
359 iDialog = CAknMemorySelectionDialogMultiDrive::NewL( |
|
360 ECFDDialogTypeNormal, ETrue ); |
|
361 } |
|
362 else |
|
363 { |
|
364 iDialog = CAknMemorySelectionDialogMultiDrive::NewL( |
|
365 ECFDDialogTypeNormal, 0, ETrue, aIncludedMedias ); |
|
366 } |
|
367 } |
|
368 |
|
369 // --------------------------------------------------------------------------- |
|
370 // CAknMemorySelectionSettingItemExtension |
279 // ConstructL |
371 // ConstructL |
280 // --------------------------------------------------------------------------- |
372 // --------------------------------------------------------------------------- |
281 // |
373 // |
282 void CAknMemorySelectionSettingItemExtension::ConstructL() |
374 void CAknMemorySelectionSettingItemExtension::ConstructL( TInt aIncludedMedias ) |
283 { |
375 { |
284 |
376 ConstructDialogL( aIncludedMedias ); |
285 iDialog = CAknMemorySelectionDialogMultiDrive::NewL( |
377 |
286 ECFDDialogTypeNormal, ETrue); |
378 iFSEvent = CAknCFDFileSystemEvent::NewL( |
287 |
379 CCoeEnv::Static()->FsSession(), *this, ENotifyDisk ); |
288 iFSEvent = CAknCFDFileSystemEvent::NewL(CCoeEnv::Static()->FsSession(), *this, ENotifyDisk); |
|
289 } |
380 } |
290 |
381 |
291 // --------------------------------------------------------------------------- |
382 // --------------------------------------------------------------------------- |
292 // CAknMemorySelectionSettingItemExtension |
383 // CAknMemorySelectionSettingItemExtension |
293 // NewL |
384 // NewL |
294 // --------------------------------------------------------------------------- |
385 // --------------------------------------------------------------------------- |
295 // |
386 // |
296 CAknMemorySelectionSettingItemExtension* CAknMemorySelectionSettingItemExtension::NewL(CAknMemorySelectionSettingItemMultiDrive* aSettingItem) |
387 CAknMemorySelectionSettingItemExtension* |
|
388 CAknMemorySelectionSettingItemExtension::NewL( |
|
389 CAknMemorySelectionSettingItemMultiDrive* aSettingItem, |
|
390 TInt aIncludedMedias ) |
297 { |
391 { |
298 CAknMemorySelectionSettingItemExtension* self = |
392 CAknMemorySelectionSettingItemExtension* self = |
299 new( ELeave ) CAknMemorySelectionSettingItemExtension(aSettingItem); |
393 new( ELeave ) CAknMemorySelectionSettingItemExtension( aSettingItem ); |
300 |
394 |
301 CleanupStack::PushL( self ); |
395 CleanupStack::PushL( self ); |
302 self->ConstructL(); |
396 self->ConstructL( aIncludedMedias ); |
303 CleanupStack::Pop( self ); |
397 CleanupStack::Pop( self ); |
304 |
398 |
305 return self; |
399 return self; |
306 } |
400 } |