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