1 /* |
|
2 * Copyright (c) 2006-2008 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: Main view |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <aknlists.h> |
|
22 #include <CFileManagerEngine.h> |
|
23 #include <CFileManagerItemProperties.h> |
|
24 #include <filemanager.rsg> |
|
25 #include <csxhelp/fmgr.hlp.hrh> |
|
26 #include <FileManagerDlgUtils.h> |
|
27 #include <FileManagerDebug.h> |
|
28 #include <CFileManagerFeatureManager.h> |
|
29 #include <coreapplicationuisdomainpskeys.h> |
|
30 #include <StringLoader.h> |
|
31 #include <cmemstatepopup.h> |
|
32 #include "CFileManagerMainView.h" |
|
33 #include "CFileManagerFileListContainer.h" |
|
34 #include "CFileManagerAppUi.h" |
|
35 #include "CFileManagerDocument.h" |
|
36 #include "FileManager.hrh" |
|
37 |
|
38 |
|
39 // ======== MEMBER FUNCTIONS ======== |
|
40 |
|
41 // ---------------------------------------------------------------------------- |
|
42 // CFileManagerMainView::CFileManagerMainView |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 CFileManagerMainView::CFileManagerMainView() |
|
46 { |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CFileManagerMainView::NewLC |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CFileManagerMainView* CFileManagerMainView::NewLC() |
|
54 { |
|
55 CFileManagerMainView* self = new( ELeave ) CFileManagerMainView(); |
|
56 CleanupStack::PushL( self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 // ---------------------------------------------------------------------------- |
|
62 // CFileManagerMainView::ConstructL |
|
63 // ---------------------------------------------------------------------------- |
|
64 // |
|
65 void CFileManagerMainView::ConstructL() |
|
66 { |
|
67 CFileManagerViewBase::ConstructL( |
|
68 FeatureManager().IsEmbedded() ? |
|
69 R_FILEMANAGER_MAIN_VIEW_EMBEDDED : |
|
70 R_FILEMANAGER_MAIN_VIEW ); |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CFileManagerMainView::~CFileManagerMainView |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 CFileManagerMainView::~CFileManagerMainView() |
|
78 { |
|
79 } |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CFileManagerMainView::DoActivateL |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 void CFileManagerMainView::DoActivateL( |
|
86 const TVwsViewId& aPrevViewId, |
|
87 TUid aCustomMessageId, |
|
88 const TDesC8& aCustomMessage ) |
|
89 { |
|
90 FUNC_LOG |
|
91 |
|
92 CFileManagerViewBase::DoActivateL( |
|
93 aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
94 |
|
95 // Ensure that no directory is defined |
|
96 if ( iEngine.CurrentDirectory().Length() ) |
|
97 { |
|
98 TInt count( iEngine.NavigationLevel() ); |
|
99 ++count; |
|
100 for ( TInt i( 0 ); i < count; i++ ) |
|
101 { |
|
102 TRAP_IGNORE( iEngine.BackstepL() ); |
|
103 } |
|
104 } |
|
105 |
|
106 CFileManagerAppUi* appUi = |
|
107 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
108 appUi->RestoreDefaultTitleL(); |
|
109 iEngine.SetState( CFileManagerEngine::ENavigation ); |
|
110 iEngine.SetObserver( this ); |
|
111 appUi->ExitEmbeddedAppIfNeededL(); |
|
112 if ( !appUi->WaitingForInputParams() ) |
|
113 { |
|
114 iEngine.RefreshDirectory(); |
|
115 } |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------------------------- |
|
119 // CFileManagerMainView::DoDeactivate |
|
120 // ---------------------------------------------------------------------------- |
|
121 // |
|
122 void CFileManagerMainView::DoDeactivate() |
|
123 { |
|
124 FUNC_LOG |
|
125 |
|
126 CFileManagerViewBase::DoDeactivate(); |
|
127 } |
|
128 |
|
129 // ---------------------------------------------------------------------------- |
|
130 // CFileManagerMainView::DirectoryChangedL |
|
131 // ---------------------------------------------------------------------------- |
|
132 // |
|
133 void CFileManagerMainView::DirectoryChangedL() |
|
134 { |
|
135 FUNC_LOG |
|
136 |
|
137 CFileManagerAppUi* appUi = |
|
138 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
139 |
|
140 if ( iContainer && !appUi->WaitingForInputParams() ) |
|
141 { |
|
142 iContainer->RefreshListL( iIndex ); |
|
143 } |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // CFileManagerMainView::Id |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 TUid CFileManagerMainView::Id() const |
|
151 { |
|
152 return CFileManagerAppUi::KFileManagerMainViewId; |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CFileManagerMainView::CreateContainerL |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 CFileManagerContainerBase* CFileManagerMainView::CreateContainerL() |
|
160 { |
|
161 return CFileManagerFileListContainer::NewL( |
|
162 ClientRect(), |
|
163 iIndex, |
|
164 CFileManagerFileListContainer::EListMain, |
|
165 R_QTN_SELEC_EMPTY_LIST, |
|
166 KFMGR_HLP_MAIN_VIEW ); |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // CFileManagerMainView::DynInitMenuPaneL |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 void CFileManagerMainView::DynInitMenuPaneL( |
|
174 TInt aResourceId, |
|
175 CEikMenuPane* aMenuPane) |
|
176 { |
|
177 switch( aResourceId ) |
|
178 { |
|
179 // These menus are used only by main view |
|
180 case R_FILEMANAGER_MAIN_VIEW_MENU: |
|
181 { |
|
182 MainMenuFilteringL( *aMenuPane ); |
|
183 break; |
|
184 } |
|
185 case R_FILEMANAGER_REMOTE_DRIVES_MENU: |
|
186 { |
|
187 RemoteDrivesMenuFilteringL( *aMenuPane ); |
|
188 break; |
|
189 } |
|
190 case R_FILEMANAGER_MEMORY_STORAGE_MENU: |
|
191 { |
|
192 MemoryStorageMenuFilteringL( *aMenuPane ); |
|
193 break; |
|
194 } |
|
195 default: |
|
196 { |
|
197 CFileManagerViewBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
198 break; |
|
199 } |
|
200 } |
|
201 } |
|
202 |
|
203 // ---------------------------------------------------------------------------- |
|
204 // CFileManagerMainView::MainMenuFilteringL |
|
205 // ---------------------------------------------------------------------------- |
|
206 // |
|
207 void CFileManagerMainView::MainMenuFilteringL( CEikMenuPane& aMenuPane ) |
|
208 { |
|
209 RemoteDriveCommonFilteringL( aMenuPane ); |
|
210 |
|
211 if ( !iContainer->ListBoxNumberOfItems() ) |
|
212 { |
|
213 aMenuPane.SetItemDimmed( EFileManagerEject, ETrue ); |
|
214 aMenuPane.SetItemDimmed( EFileManagerFindFile, ETrue ); |
|
215 #ifndef RD_FILE_MANAGER_BACKUP |
|
216 aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue ); |
|
217 aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue ); |
|
218 #endif // RD_FILE_MANAGER_BACKUP |
|
219 aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue ); |
|
220 return; |
|
221 } |
|
222 |
|
223 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( |
|
224 iContainer->ListBoxCurrentItemIndex() ); |
|
225 TUint32 drvState( 0 ); |
|
226 if ( prop->IsDrive() ) |
|
227 { |
|
228 iEngine.DriveState( drvState, prop->FullPath() ); |
|
229 } |
|
230 |
|
231 TFileManagerDriveInfo drvInfo; |
|
232 if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 ) |
|
233 { |
|
234 // No drive selected |
|
235 aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue ); |
|
236 aMenuPane.SetItemDimmed( EFileManagerEject, ETrue ); |
|
237 aMenuPane.SetItemDimmed( EFileManagerRemoveDrives, ETrue ); |
|
238 } |
|
239 else |
|
240 { |
|
241 if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveEjectable ) || |
|
242 !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ) |
|
243 { |
|
244 aMenuPane.SetItemDimmed( EFileManagerEject, ETrue ); |
|
245 } |
|
246 if ( ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) && |
|
247 !( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ) |
|
248 { |
|
249 aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue ); |
|
250 } |
|
251 if ( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) |
|
252 { |
|
253 aMenuPane.SetItemDimmed( EFileManagerMemoryStorage, ETrue ); |
|
254 } |
|
255 if ( !FeatureManager().IsRemoteStorageFwSupported() || |
|
256 !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemote ) ) |
|
257 { |
|
258 aMenuPane.SetItemDimmed( EFileManagerRemoveDrives, ETrue ); |
|
259 } |
|
260 } |
|
261 |
|
262 #ifndef RD_FILE_MANAGER_BACKUP |
|
263 TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() ); |
|
264 if ( mmcinfo.iState & ( TFileManagerDriveInfo::EDriveLocked | |
|
265 TFileManagerDriveInfo::EDriveCorrupted ) ) |
|
266 { |
|
267 aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue ); |
|
268 aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue ); |
|
269 } |
|
270 else if ( !( mmcinfo.iState & TFileManagerDriveInfo::EDrivePresent ) ) |
|
271 { |
|
272 aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue ); |
|
273 aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue ); |
|
274 } |
|
275 else if ( !( mmcinfo.iState & TFileManagerDriveInfo::EDriveBackupped ) ) |
|
276 { |
|
277 aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue ); |
|
278 } |
|
279 if ( FeatureManager().IsEmbedded() ) |
|
280 { |
|
281 // Disable backup in embedded mode, because it messes up |
|
282 // backup and restore operations since embedded apps are closed. |
|
283 aMenuPane.SetItemDimmed( EFileManagerBackup, ETrue ); |
|
284 aMenuPane.SetItemDimmed( EFileManagerRestore, ETrue ); |
|
285 } |
|
286 #endif // RD_FILE_MANAGER_BACKUP |
|
287 |
|
288 if( !iEngine.IsDriverMounted( drvInfo.iDrive ) ) |
|
289 { |
|
290 aMenuPane.SetItemDimmed( EFileManagerEject, ETrue ); |
|
291 } |
|
292 CleanupStack::PopAndDestroy( prop ); |
|
293 } |
|
294 |
|
295 // ---------------------------------------------------------------------------- |
|
296 // CFileManagerMainView::RemoteDrivesMenuFilteringL |
|
297 // ---------------------------------------------------------------------------- |
|
298 // |
|
299 void CFileManagerMainView::RemoteDrivesMenuFilteringL( |
|
300 CEikMenuPane& aMenuPane ) |
|
301 { |
|
302 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
303 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index ); |
|
304 TUint32 drvState( 0 ); |
|
305 if ( iEngine.DriveState( drvState, prop->FullPath() ) == KErrNone ) |
|
306 { |
|
307 if ( !( drvState & TFileManagerDriveInfo::EDriveRemote ) || |
|
308 ( drvState & TFileManagerDriveInfo::EDriveConnected ) ) |
|
309 { |
|
310 aMenuPane.SetItemDimmed( |
|
311 EFileManagerRemoveDrivesSettings, ETrue ); |
|
312 aMenuPane.SetItemDimmed( |
|
313 EFileManagerRemoveDrivesDelete, ETrue ); |
|
314 } |
|
315 } |
|
316 else |
|
317 { |
|
318 aMenuPane.SetItemDimmed( EFileManagerRemoveDrivesSettings, ETrue ); |
|
319 aMenuPane.SetItemDimmed( EFileManagerRemoveDrivesDelete, ETrue ); |
|
320 } |
|
321 CleanupStack::PopAndDestroy( prop ); |
|
322 TBool dimAll( EFalse ); |
|
323 if ( !FeatureManager().IsRemoteStorageFwSupported() ) |
|
324 { |
|
325 dimAll = ETrue; |
|
326 } |
|
327 else |
|
328 { |
|
329 if ( drvState & TFileManagerDriveInfo::EDriveRemote ) |
|
330 { |
|
331 if ( drvState & TFileManagerDriveInfo::EDriveConnected ) |
|
332 { |
|
333 aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue ); |
|
334 } |
|
335 else |
|
336 { |
|
337 aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive,ETrue ); |
|
338 } |
|
339 } |
|
340 else |
|
341 { |
|
342 dimAll = ETrue; |
|
343 } |
|
344 } |
|
345 |
|
346 if ( dimAll ) |
|
347 { |
|
348 aMenuPane.SetItemDimmed( EFileManagerConnectRemoveDrive, ETrue ); |
|
349 aMenuPane.SetItemDimmed( EFileManagerDisconnectRemoveDrive, ETrue ); |
|
350 } |
|
351 } |
|
352 |
|
353 // ---------------------------------------------------------------------------- |
|
354 // CFileManagerMainView::HandleCommandL |
|
355 // ---------------------------------------------------------------------------- |
|
356 // |
|
357 void CFileManagerMainView::HandleCommandL( TInt aCommand ) |
|
358 { |
|
359 switch( aCommand ) |
|
360 { |
|
361 case EFileManagerOpen: |
|
362 { |
|
363 CmdOpenMemoryStoreL(); |
|
364 break; |
|
365 } |
|
366 case EFileManagerEject: |
|
367 { |
|
368 CmdEjectL(); |
|
369 break; |
|
370 } |
|
371 #ifndef RD_FILE_MANAGER_BACKUP |
|
372 case EFileManagerBackup: |
|
373 { |
|
374 CmdBackupL(); |
|
375 break; |
|
376 } |
|
377 case EFileManagerRestore: |
|
378 { |
|
379 CmdRestoreL(); |
|
380 break; |
|
381 } |
|
382 #endif // RD_FILE_MANAGER_BACKUP |
|
383 case EFileManagerRemoveDrivesMapDrive: |
|
384 { |
|
385 CmdMapRemoteDriveL(); |
|
386 break; |
|
387 } |
|
388 case EFileManagerRemoveDrivesSettings: |
|
389 { |
|
390 CmdRemoteDriveSettingsL(); |
|
391 break; |
|
392 } |
|
393 case EFileManagerDelete: // Fall through |
|
394 case EFileManagerRemoveDrivesDelete: |
|
395 { |
|
396 CmdRemoteDriveDeleteL(); |
|
397 break; |
|
398 } |
|
399 case EFileManagerSend: // Suppress |
|
400 { |
|
401 break; |
|
402 } |
|
403 case EFileManagerMemoryStorageDetails: |
|
404 { |
|
405 CmdMemoryStorageDetailsL(); |
|
406 break; |
|
407 } |
|
408 case EFileManagerMemoryStorageName: |
|
409 case EFileManagerMemoryStorageRename: // Fall through |
|
410 { |
|
411 CmdRenameDriveL(); |
|
412 break; |
|
413 } |
|
414 case EFileManagerMemoryStorageFormat: |
|
415 { |
|
416 CmdFormatDriveL(); |
|
417 break; |
|
418 } |
|
419 case EFileManagerMemoryStorageSetPassword: |
|
420 { |
|
421 CmdSetDrivePasswordL(); |
|
422 break; |
|
423 } |
|
424 case EFileManagerMemoryStorageChangePassword: |
|
425 { |
|
426 CmdChangeDrivePasswordL(); |
|
427 break; |
|
428 } |
|
429 case EFileManagerMemoryStorageRemovePassword: |
|
430 { |
|
431 CmdRemoveDrivePasswordL(); |
|
432 break; |
|
433 } |
|
434 case EFileManagerMemoryStorageUnlock: |
|
435 { |
|
436 CmdUnlockDriveL(); |
|
437 break; |
|
438 } |
|
439 default: |
|
440 { |
|
441 CFileManagerViewBase::HandleCommandL( aCommand ); |
|
442 break; |
|
443 } |
|
444 } |
|
445 } |
|
446 |
|
447 // ---------------------------------------------------------------------------- |
|
448 // CFileManagerMainView::CmdOpenMemoryStoreL |
|
449 // ---------------------------------------------------------------------------- |
|
450 // |
|
451 void CFileManagerMainView::CmdOpenMemoryStoreL() |
|
452 { |
|
453 StoreIndex(); |
|
454 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
455 if ( index >= 0 ) |
|
456 { |
|
457 CFileManagerAppUi* appUi = |
|
458 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
459 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index ); |
|
460 |
|
461 TRAPD( err, iEngine.OpenL( index ) ); |
|
462 if ( err == KErrNone && prop->FullPath().Length() ) |
|
463 { |
|
464 appUi->ActivateMemoryStoreViewL(); |
|
465 } |
|
466 CleanupStack::PopAndDestroy( prop ); |
|
467 } |
|
468 } |
|
469 |
|
470 // ---------------------------------------------------------------------------- |
|
471 // CFileManagerMainView::CmdEjectL |
|
472 // ---------------------------------------------------------------------------- |
|
473 // |
|
474 void CFileManagerMainView::CmdEjectL() |
|
475 { |
|
476 StoreIndex(); |
|
477 |
|
478 #ifdef RD_MULTIPLE_DRIVE |
|
479 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
480 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index ); |
|
481 TInt drive( prop->DriveId() ); |
|
482 const TInt KDriveShift = 16; |
|
483 |
|
484 // Let SysAp handle eject |
|
485 RProperty::Set( |
|
486 KPSUidCoreApplicationUIs, |
|
487 KCoreAppUIsMmcRemovedWithoutEject, |
|
488 ECoreAppUIsEjectCommandUsedToDrive | ( drive << KDriveShift ) |
|
489 ); |
|
490 |
|
491 CleanupStack::PopAndDestroy( prop ); |
|
492 #else // RD_MULTIPLE_DRIVE |
|
493 if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( R_QTN_CONF_EJECT ) ) |
|
494 { |
|
495 StartProcessL( EEjectProcess ); |
|
496 } |
|
497 #endif // RD_MULTIPLE_DRIVE |
|
498 } |
|
499 |
|
500 #ifndef RD_FILE_MANAGER_BACKUP |
|
501 // ---------------------------------------------------------------------------- |
|
502 // CFileManagerMainView::CmdBackupL |
|
503 // |
|
504 // ---------------------------------------------------------------------------- |
|
505 // |
|
506 void CFileManagerMainView::CmdBackupL() |
|
507 { |
|
508 StoreIndex(); |
|
509 TInt textId( R_QTN_CONFIRM_BACKUP_TEXT ); |
|
510 TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() ); |
|
511 |
|
512 if( mmcinfo.iState & TFileManagerDriveInfo::EDriveBackupped ) |
|
513 { |
|
514 textId = R_QTN_CONFIRM_BACKUP_TEXT2; |
|
515 } |
|
516 if( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( textId ) ) |
|
517 { |
|
518 if ( !DriveReadOnlyMmcL( mmcinfo.iDrive ) ) |
|
519 { |
|
520 if ( !IsDriveAvailable( mmcinfo.iDrive ) || |
|
521 !CheckPhoneState() ) |
|
522 { |
|
523 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR ); |
|
524 } |
|
525 else |
|
526 { |
|
527 StartProcessL( EBackupProcess ); |
|
528 } |
|
529 } |
|
530 } |
|
531 } |
|
532 |
|
533 // ---------------------------------------------------------------------------- |
|
534 // CFileManagerMainView::CmdRestoreL |
|
535 // ---------------------------------------------------------------------------- |
|
536 // |
|
537 void CFileManagerMainView::CmdRestoreL() |
|
538 { |
|
539 StoreIndex(); |
|
540 if( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( R_QTN_CONFIRM_RESTORE_TEXT ) ) |
|
541 { |
|
542 TFileManagerDriveInfo mmcinfo( iEngine.GetMMCInfoL() ); |
|
543 |
|
544 if ( !IsDriveAvailable( mmcinfo.iDrive ) || |
|
545 !CheckPhoneState() ) |
|
546 { |
|
547 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR ); |
|
548 } |
|
549 else |
|
550 { |
|
551 StartProcessL( ERestoreProcess ); |
|
552 } |
|
553 } |
|
554 } |
|
555 #endif // RD_FILE_MANAGER_BACKUP |
|
556 |
|
557 // ---------------------------------------------------------------------------- |
|
558 // CFileManagerMainView::CmdMapRemoteDriveL |
|
559 // ---------------------------------------------------------------------------- |
|
560 // |
|
561 void CFileManagerMainView::CmdMapRemoteDriveL() |
|
562 { |
|
563 StoreIndex(); |
|
564 const TInt KMaxRemoteDrives = 9; |
|
565 RFs& fs( CCoeEnv::Static()->FsSession() ); |
|
566 TDriveList driveList; |
|
567 User::LeaveIfError( fs.DriveList( driveList, KDriveAttRemote ) ); |
|
568 TInt numRemote( 0 ); |
|
569 TInt count( driveList.Length() ); |
|
570 for( TInt i( 0 ); i < count; ++i ) |
|
571 { |
|
572 if ( driveList[ i ] & KDriveAttRemote ) |
|
573 { |
|
574 ++numRemote; |
|
575 } |
|
576 } |
|
577 if ( numRemote < KMaxRemoteDrives ) |
|
578 { |
|
579 OpenRemoteDriveSettingsL(); |
|
580 } |
|
581 else |
|
582 { |
|
583 FileManagerDlgUtils::ShowConfirmQueryWithOkL( |
|
584 FileManagerDlgUtils::EErrorIcons, |
|
585 R_QTN_RD_ERROR_MAX_DRIVES ); |
|
586 } |
|
587 } |
|
588 |
|
589 // ---------------------------------------------------------------------------- |
|
590 // CFileManagerMainView::CmdRemoteDriveSettingsL |
|
591 // ------------------------------------------------------------------------------ |
|
592 // |
|
593 void CFileManagerMainView::CmdRemoteDriveSettingsL() |
|
594 { |
|
595 StoreIndex(); |
|
596 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
597 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index ); |
|
598 OpenRemoteDriveSettingsL( prop->DriveName() ); |
|
599 CleanupStack::PopAndDestroy( prop ); |
|
600 } |
|
601 |
|
602 // ------------------------------------------------------------------------------ |
|
603 // CFileManagerMainView::CmdRemoteDriveDeleteL |
|
604 // |
|
605 // ------------------------------------------------------------------------------ |
|
606 // |
|
607 void CFileManagerMainView::CmdRemoteDriveDeleteL() |
|
608 { |
|
609 StoreIndex(); |
|
610 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
611 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC( index ); |
|
612 if ( IsDisconnectedRemoteDrive( *prop ) ) |
|
613 { |
|
614 if ( FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( |
|
615 R_QTN_RD_QUERY_DELETE_DRIVE, prop->Name() ) ) |
|
616 { |
|
617 TInt drv = TDriveUnit( prop->FullPath() ); |
|
618 User::LeaveIfError( iEngine.DeleteRemoteDrive( drv ) ); |
|
619 } |
|
620 } |
|
621 CleanupStack::PopAndDestroy( prop ); |
|
622 } |
|
623 |
|
624 // ------------------------------------------------------------------------------ |
|
625 // CFileManagerMainView::NotifyL |
|
626 // |
|
627 // ------------------------------------------------------------------------------ |
|
628 // |
|
629 TInt CFileManagerMainView::NotifyL( |
|
630 TFileManagerNotify aType, TInt aData, const TDesC& aName ) |
|
631 { |
|
632 TInt ret( KErrNone ); |
|
633 switch ( aType ) |
|
634 { |
|
635 #ifdef RD_FILE_MANAGER_BACKUP |
|
636 case ENotifyActionSelected: |
|
637 { |
|
638 if ( aData == EFileManagerBackupAction ) |
|
639 { |
|
640 StoreIndex(); |
|
641 CFileManagerAppUi* appUi = |
|
642 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
643 appUi->ActivateBackupViewL(); |
|
644 } |
|
645 break; |
|
646 } |
|
647 #endif // RD_FILE_MANAGER_BACKUP |
|
648 default: |
|
649 { |
|
650 ret = CFileManagerViewBase::NotifyL( aType, aData, aName ); |
|
651 break; |
|
652 } |
|
653 } |
|
654 return ret; |
|
655 } |
|
656 |
|
657 // ----------------------------------------------------------------------------- |
|
658 // CFileManagerMainView::MemoryStorageMenuFilteringL |
|
659 // ----------------------------------------------------------------------------- |
|
660 // |
|
661 void CFileManagerMainView::MemoryStorageMenuFilteringL( CEikMenuPane& aMenuPane ) |
|
662 { |
|
663 TFileManagerDriveInfo drvInfo; |
|
664 if( DriveInfoAtCurrentPosL( drvInfo ) < 0 ) |
|
665 { |
|
666 // No drive selected |
|
667 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageUnlock, ETrue ); |
|
668 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue ); |
|
669 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue ); |
|
670 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue ); |
|
671 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue ); |
|
672 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue ); |
|
673 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue ); |
|
674 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue ); |
|
675 return; |
|
676 } |
|
677 |
|
678 if ( drvInfo.iState & TFileManagerDriveInfo::EDriveCorrupted ) |
|
679 { |
|
680 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue ); |
|
681 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue ); |
|
682 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue ); |
|
683 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue ); |
|
684 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue ); |
|
685 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue ); |
|
686 } |
|
687 else if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) || |
|
688 ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveLocked | |
|
689 TFileManagerDriveInfo::EDriveMassStorage ) ) ) |
|
690 { |
|
691 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue ); |
|
692 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue ); |
|
693 } |
|
694 else if ( drvInfo.iName.Length() > 0 ) |
|
695 { |
|
696 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageName, ETrue ); |
|
697 } |
|
698 else |
|
699 { |
|
700 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRename, ETrue ); |
|
701 } |
|
702 if (!( drvInfo.iState & TFileManagerDriveInfo::EDrivePresent) ) |
|
703 { |
|
704 aMenuPane.SetItemDimmed(EFileManagerMemoryStorageSetPassword, ETrue ); |
|
705 aMenuPane.SetItemDimmed(EFileManagerMemoryStorageName, ETrue ); |
|
706 aMenuPane.SetItemDimmed(EFileManagerMemoryStorageRename, ETrue ); |
|
707 aMenuPane.SetItemDimmed(EFileManagerMemoryStorageDetails, ETrue ); |
|
708 |
|
709 } |
|
710 |
|
711 if ( FeatureManager().IsEmbedded() || |
|
712 !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) || |
|
713 !( drvInfo.iState & TFileManagerDriveInfo::EDriveFormattable ) ) |
|
714 { |
|
715 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageFormat, ETrue ); |
|
716 } |
|
717 |
|
718 if ( drvInfo.iState & TFileManagerDriveInfo::EDriveLocked ) |
|
719 { |
|
720 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageDetails, ETrue ); |
|
721 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue ); |
|
722 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue ); |
|
723 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue ); |
|
724 } |
|
725 else |
|
726 { |
|
727 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageUnlock, ETrue ); |
|
728 } |
|
729 |
|
730 if ( !( drvInfo.iState & TFileManagerDriveInfo::EDriveRemovable ) || |
|
731 ( drvInfo.iState & ( TFileManagerDriveInfo::EDriveMassStorage | |
|
732 TFileManagerDriveInfo::EDriveUsbMemory ) ) ) |
|
733 { |
|
734 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue ); |
|
735 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue ); |
|
736 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue ); |
|
737 } |
|
738 else if ( drvInfo.iState & TFileManagerDriveInfo::EDrivePasswordProtected ) |
|
739 { |
|
740 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageSetPassword, ETrue ); |
|
741 } |
|
742 else |
|
743 { |
|
744 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageChangePassword, ETrue ); |
|
745 aMenuPane.SetItemDimmed( EFileManagerMemoryStorageRemovePassword, ETrue ); |
|
746 } |
|
747 } |
|
748 |
|
749 // ------------------------------------------------------------------------------ |
|
750 // CFileManagerMainView::CmdMemoryStorageDetailsL |
|
751 // ------------------------------------------------------------------------------ |
|
752 // |
|
753 void CFileManagerMainView::CmdMemoryStorageDetailsL() |
|
754 { |
|
755 StoreIndex(); |
|
756 TFileManagerDriveInfo drvInfo; |
|
757 TInt drive( DriveInfoAtCurrentPosL( drvInfo ) ); |
|
758 if ( drive < 0 ) |
|
759 { |
|
760 return; // No drive selected |
|
761 } |
|
762 HBufC* title = StringLoader::LoadLC( R_QTN_FMGR_MSTATE_HEADING ); |
|
763 CMemStatePopup::RunLD( |
|
764 static_cast< TDriveNumber >( drive ), *title ); |
|
765 CleanupStack::PopAndDestroy( title ); |
|
766 // TFileManagerDriveInfo drvInfo; |
|
767 // iEngine.GetDriveInfoL( iEngine.CurrentDrive(), drvInfo ); |
|
768 // FileManagerDlgUtils::ShowMemoryStoreInfoPopupL( drvInfo ); |
|
769 } |
|
770 |
|
771 // ------------------------------------------------------------------------------ |
|
772 // CFileManagerMainView::CmdRenameDriveL |
|
773 // ------------------------------------------------------------------------------ |
|
774 // |
|
775 void CFileManagerMainView::CmdRenameDriveL() |
|
776 { |
|
777 StoreIndex(); |
|
778 TFileManagerDriveInfo drvInfo; |
|
779 if ( DriveInfoAtCurrentPosL( drvInfo ) < 0 ) |
|
780 { |
|
781 return; // No drive selected |
|
782 } |
|
783 if ( drvInfo.iState & TFileManagerDriveInfo::EDriveWriteProtected ) |
|
784 { |
|
785 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_MEMORYCARD_READONLY ); |
|
786 return; |
|
787 } |
|
788 RenameDriveL( EFalse ); |
|
789 } |
|
790 |
|
791 // ------------------------------------------------------------------------------ |
|
792 // CFileManagerMainView::CmdSetDrivePasswordL |
|
793 // ------------------------------------------------------------------------------ |
|
794 // |
|
795 void CFileManagerMainView::CmdSetDrivePasswordL() |
|
796 { |
|
797 StoreIndex(); |
|
798 TInt drive( DriveAtCurrentPosL() ); |
|
799 if ( drive < 0 ) |
|
800 { |
|
801 return; // No drive selected |
|
802 } |
|
803 |
|
804 TBuf< KFmgrMaxMediaPassword > pwd; |
|
805 if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) ) |
|
806 { |
|
807 TBuf< KFmgrMaxMediaPassword > nullPwd; |
|
808 EmptyPwd( nullPwd ); |
|
809 if( UpdatePassword( drive, nullPwd, pwd ) == KErrNone ) |
|
810 { |
|
811 FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_SET_TEXT ); |
|
812 } |
|
813 else |
|
814 { |
|
815 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR ); |
|
816 } |
|
817 } |
|
818 } |
|
819 |
|
820 // ------------------------------------------------------------------------------ |
|
821 // CFileManagerMainView::CmdChangeDrivePasswordL |
|
822 // ------------------------------------------------------------------------------ |
|
823 // |
|
824 void CFileManagerMainView::CmdChangeDrivePasswordL() |
|
825 { |
|
826 StoreIndex(); |
|
827 TInt drive( DriveAtCurrentPosL() ); |
|
828 if ( drive < 0 ) |
|
829 { |
|
830 return; // No drive selected |
|
831 } |
|
832 |
|
833 TBuf< KFmgrMaxMediaPassword > pwd; |
|
834 TBuf< KFmgrMaxMediaPassword > oldPwd; |
|
835 TBool isDone( EFalse ); |
|
836 TBool isCanceled( EFalse ); |
|
837 TInt err( KErrNone ); |
|
838 |
|
839 // Ask for the old password until the correct one is given |
|
840 while( !isDone ) |
|
841 { |
|
842 EmptyPwd( oldPwd ); |
|
843 if( FileManagerDlgUtils::ShowSimplePasswordQueryL( |
|
844 R_QTN_PASSWORD_OLD_TEXT, oldPwd ) ) |
|
845 { |
|
846 TInt index(iContainer->ListBoxCurrentItemIndex()); |
|
847 CFileManagerItemProperties* prop = iEngine.GetItemInfoLC(index); |
|
848 TUint32 drvState(0); |
|
849 TInt error= iEngine.DriveState(drvState, prop->FullPath()); |
|
850 if ((error!=KErrNone)||(!(drvState & TFileManagerDriveInfo::EDrivePresent))) |
|
851 { |
|
852 isDone = ETrue; |
|
853 isCanceled = ETrue; |
|
854 FileManagerDlgUtils::ShowErrorNoteL(R_QTN_MEMC_NOT_AVAILABLE ); |
|
855 } |
|
856 else |
|
857 { |
|
858 err = UpdatePassword( drive, oldPwd, oldPwd ); |
|
859 if( err == KErrNone ) |
|
860 { |
|
861 isDone = ETrue; |
|
862 } |
|
863 else |
|
864 { |
|
865 FileManagerDlgUtils::ShowErrorNoteL( |
|
866 R_QTN_PASSWORDS_WRONG_TEXT ); |
|
867 } |
|
868 } |
|
869 CleanupStack::PopAndDestroy( prop ); |
|
870 } |
|
871 else |
|
872 { |
|
873 isDone = ETrue; |
|
874 isCanceled = ETrue; |
|
875 } |
|
876 } |
|
877 |
|
878 // Then query for the new password |
|
879 if( !isCanceled ) |
|
880 { |
|
881 if( FileManagerDlgUtils::ShowPasswordQueryL( pwd ) ) |
|
882 { |
|
883 err = UpdatePassword( drive, oldPwd, pwd ); |
|
884 if( err == KErrNone ) |
|
885 { |
|
886 FileManagerDlgUtils::ShowConfirmNoteL( |
|
887 R_QTN_PASSWORD_CHANGED_TEXT ); |
|
888 } |
|
889 else |
|
890 { |
|
891 FileManagerDlgUtils::ShowErrorNoteL( |
|
892 R_QTN_CRITICAL_ERROR ); |
|
893 } |
|
894 } |
|
895 } |
|
896 } |
|
897 |
|
898 // ------------------------------------------------------------------------------ |
|
899 // CFileManagerMainView::CmdRemoveDrivePasswordL |
|
900 // ------------------------------------------------------------------------------ |
|
901 // |
|
902 void CFileManagerMainView::CmdRemoveDrivePasswordL() |
|
903 { |
|
904 StoreIndex(); |
|
905 TInt drive( DriveAtCurrentPosL() ); |
|
906 if ( drive < 0 ) |
|
907 { |
|
908 return; // No drive selected |
|
909 } |
|
910 |
|
911 if( !UnlockRemovePasswordL( drive, ETrue ) ) |
|
912 { |
|
913 FileManagerDlgUtils::ShowConfirmNoteL( R_QTN_PASSWORD_REMOVED_TEXT ); |
|
914 } |
|
915 } |
|
916 |
|
917 // ------------------------------------------------------------------------------ |
|
918 // CFileManagerMainView::DriveAtCurrentPosL |
|
919 // ------------------------------------------------------------------------------ |
|
920 // |
|
921 TInt CFileManagerMainView::DriveAtCurrentPosL() |
|
922 { |
|
923 TFileManagerDriveInfo dummy; |
|
924 return DriveInfoAtCurrentPosL( dummy ); |
|
925 } |
|
926 |
|
927 // End of File |
|