1 /* |
|
2 * Copyright (c) 2002-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: View for backup settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StringLoader.h> |
|
21 #include <aknlists.h> |
|
22 #include <akntitle.h> |
|
23 #include <csxhelp/fmgr.hlp.hrh> |
|
24 #include <CFileManagerEngine.h> |
|
25 #include <filemanager.rsg> |
|
26 #include <CFileManagerBackupSettings.h> |
|
27 #include <FileManagerPrivateCRKeys.h> |
|
28 #include <FileManagerDlgUtils.h> |
|
29 #include <CAknMemorySelectionDialog.h> |
|
30 #include <CAknMemorySelectionSettingPage.h> |
|
31 #ifdef RD_MULTIPLE_DRIVE |
|
32 #include <AknCommonDialogsDynMem.h> |
|
33 #include <CAknMemorySelectionDialogMultiDrive.h> |
|
34 #endif // RD_MULTIPLE_DRIVE |
|
35 #include <FileManagerDebug.h> |
|
36 #include "CFileManagerBackupView.h" |
|
37 #include "CFileManagerTaskScheduler.h" |
|
38 #include "CFileManagerSettingListContainer.h" |
|
39 #include "CFileManagerAppUi.h" |
|
40 #include "FileManager.hrh" |
|
41 |
|
42 |
|
43 // ======== MEMBER FUNCTIONS ======== |
|
44 |
|
45 // ---------------------------------------------------------------------------- |
|
46 // CFileManagerBackupView::CFileManagerBackupView |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 CFileManagerBackupView::CFileManagerBackupView() |
|
50 { |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // CFileManagerBackupView::NewLC |
|
55 // ---------------------------------------------------------------------------- |
|
56 // |
|
57 CFileManagerBackupView* CFileManagerBackupView::NewLC() |
|
58 { |
|
59 CFileManagerBackupView* self = new( ELeave ) CFileManagerBackupView(); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL( R_FILEMANAGER_BACKUP_VIEW ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CFileManagerBackupView::~CFileManagerBackupView |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CFileManagerBackupView::~CFileManagerBackupView() |
|
70 { |
|
71 } |
|
72 |
|
73 // ---------------------------------------------------------------------------- |
|
74 // CFileManagerBackupView::DoActivateL |
|
75 // ---------------------------------------------------------------------------- |
|
76 // |
|
77 void CFileManagerBackupView::DoActivateL( |
|
78 const TVwsViewId& aPrevViewId, |
|
79 TUid aCustomMessageId, |
|
80 const TDesC8& aCustomMessage ) |
|
81 { |
|
82 FUNC_LOG |
|
83 |
|
84 CFileManagerViewBase::DoActivateL( |
|
85 aPrevViewId, aCustomMessageId, aCustomMessage ); |
|
86 |
|
87 static_cast< CFileManagerAppUi* >( AppUi() )->SetTitleL( |
|
88 R_QTN_FMGR_BACKUP_TITLE ); |
|
89 |
|
90 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
91 settings.RefreshL(); |
|
92 |
|
93 iContainer->RefreshListL( iIndex ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CFileManagerBackupView::DoDeactivate |
|
98 // ---------------------------------------------------------------------------- |
|
99 // |
|
100 void CFileManagerBackupView::DoDeactivate() |
|
101 { |
|
102 FUNC_LOG |
|
103 |
|
104 CFileManagerViewBase::DoDeactivate(); |
|
105 } |
|
106 |
|
107 // ---------------------------------------------------------------------------- |
|
108 // CFileManagerBackupView::DirectoryChangedL |
|
109 // ---------------------------------------------------------------------------- |
|
110 // |
|
111 void CFileManagerBackupView::DirectoryChangedL() |
|
112 { |
|
113 FUNC_LOG |
|
114 |
|
115 TRAP_IGNORE( RefreshSettingsL() ); |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------------------------- |
|
119 // CFileManagerBackupView::Id |
|
120 // ---------------------------------------------------------------------------- |
|
121 // |
|
122 TUid CFileManagerBackupView::Id() const |
|
123 { |
|
124 return CFileManagerAppUi::KFileManagerBackupViewId; |
|
125 } |
|
126 |
|
127 // ---------------------------------------------------------------------------- |
|
128 // CFileManagerBackupView::CreateContainerL |
|
129 // ---------------------------------------------------------------------------- |
|
130 // |
|
131 CFileManagerContainerBase* CFileManagerBackupView::CreateContainerL() |
|
132 { |
|
133 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
134 |
|
135 return CFileManagerSettingListContainer::NewL( |
|
136 ClientRect(), |
|
137 iIndex, |
|
138 CFileManagerSettingListContainer::EListBackup, |
|
139 &settings, |
|
140 KFMGR_HLP_BACKUP_VIEW ); |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CFileManagerBackupView::HandleCommandL |
|
145 // ---------------------------------------------------------------------------- |
|
146 // |
|
147 void CFileManagerBackupView::HandleCommandL( TInt aCommand ) |
|
148 { |
|
149 switch( aCommand ) |
|
150 { |
|
151 case EFileManagerSelectionKey: // FALLTHROUGH |
|
152 case EFileManagerOpen: |
|
153 { |
|
154 CmdChangeL(); |
|
155 break; |
|
156 } |
|
157 case EFileManagerBackup: |
|
158 { |
|
159 CmdBackupL(); |
|
160 break; |
|
161 } |
|
162 case EFileManagerRestore: |
|
163 { |
|
164 CmdRestoreL(); |
|
165 break; |
|
166 } |
|
167 case EFileManagerDeleteBackup: |
|
168 { |
|
169 CmdDeleteBackupL(); |
|
170 break; |
|
171 } |
|
172 case EAknSoftkeyBack: |
|
173 { |
|
174 CmdBackL(); |
|
175 break; |
|
176 } |
|
177 default: |
|
178 { |
|
179 CFileManagerViewBase::HandleCommandL( aCommand ); |
|
180 break; |
|
181 } |
|
182 } |
|
183 } |
|
184 |
|
185 // ---------------------------------------------------------------------------- |
|
186 // CFileManagerBackupView::CmdChangeL |
|
187 // ---------------------------------------------------------------------------- |
|
188 // |
|
189 void CFileManagerBackupView::CmdChangeL() |
|
190 { |
|
191 if ( !iContainer ) |
|
192 { |
|
193 return; |
|
194 } |
|
195 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
196 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
197 |
|
198 StoreIndex(); |
|
199 |
|
200 switch ( settings.SettingAt( index ) ) |
|
201 { |
|
202 case CFileManagerBackupSettings::EContents: |
|
203 { |
|
204 ChangeContentsL(); |
|
205 break; |
|
206 } |
|
207 case CFileManagerBackupSettings::EScheduling: |
|
208 { |
|
209 ChangeSchedulingL(); |
|
210 break; |
|
211 } |
|
212 case CFileManagerBackupSettings::EWeekday: |
|
213 { |
|
214 ChangeWeekdayL(); |
|
215 break; |
|
216 } |
|
217 case CFileManagerBackupSettings::ETime: |
|
218 { |
|
219 ChangeTimeL(); |
|
220 break; |
|
221 } |
|
222 case CFileManagerBackupSettings::ETarget: |
|
223 { |
|
224 ChangeTargetDriveL(); |
|
225 break; |
|
226 } |
|
227 default: |
|
228 { |
|
229 break; |
|
230 } |
|
231 } |
|
232 } |
|
233 |
|
234 // ---------------------------------------------------------------------------- |
|
235 // CFileManagerBackupView::CmdBackupL |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 void CFileManagerBackupView::CmdBackupL() |
|
239 { |
|
240 if ( !iContainer ) |
|
241 { |
|
242 return; |
|
243 } |
|
244 |
|
245 TBool isSystemStateNormal = static_cast< CFileManagerAppUi* >( AppUi() )->IsSystemStateNormal(); |
|
246 if ( !isSystemStateNormal ) |
|
247 { |
|
248 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_FMGR_SYSTEM_NOT_READY ); |
|
249 return; |
|
250 } |
|
251 |
|
252 StoreIndex(); |
|
253 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
254 TInt drive( settings.TargetDrive() ); |
|
255 TFileManagerDriveInfo drvInfo; |
|
256 if( !IsDriveAvailable( drive ) ) |
|
257 { |
|
258 for( TInt i ( EDriveA ) ; i <= EDriveZ ; i++ ) |
|
259 { |
|
260 iEngine.GetDriveInfoL( i , drvInfo ); |
|
261 if( ( IsDriveAvailable( i ) ) && ( drvInfo.iState & TFileManagerDriveInfo::EDriveEjectable ) ) |
|
262 { |
|
263 drive = i; |
|
264 settings.SetTargetDrive( drive ); |
|
265 settings.SaveL(); |
|
266 break; |
|
267 } |
|
268 } |
|
269 } |
|
270 RArray< CFileManagerRestoreSettings::TInfo > info; |
|
271 CleanupClosePushL( info ); |
|
272 iEngine.GetRestoreInfoArrayL( info, drive ); |
|
273 TInt count( info.Count() ); |
|
274 CleanupStack::PopAndDestroy( &info ); |
|
275 TPtrC driveName( iEngine.DriveName( drive ) ); |
|
276 TBool isContinue( true ); |
|
277 |
|
278 |
|
279 const TInt64 KBackupLimitSize = 10000000; |
|
280 |
|
281 //define a protected limit size to avoid not enough space during backup |
|
282 |
|
283 if( count ) |
|
284 { |
|
285 TInt textId( R_QTN_FMGR_BACKUP_QUERY_EXISTS ); |
|
286 |
|
287 if( !FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( |
|
288 textId, driveName ) ) |
|
289 { |
|
290 isContinue = false; |
|
291 } |
|
292 } |
|
293 if( isContinue ) |
|
294 { |
|
295 if ( !DriveReadOnlyMmcL( drive ) ) |
|
296 { |
|
297 if ( !IsDriveAvailable( drive ) ) |
|
298 { |
|
299 FileManagerDlgUtils::ShowErrorNoteL( |
|
300 R_QTN_FMGR_ERROR_BACKUP_MEMORYCARD_NOT_AVAILABLE ); |
|
301 } |
|
302 else if ( !CheckPhoneState() ) |
|
303 { |
|
304 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR ); |
|
305 } |
|
306 else if ( !iEngine.EnoughSpaceL( |
|
307 TDriveUnit( drive ).Name(), KBackupLimitSize, EBackupProcess ) ) |
|
308 { |
|
309 FileManagerDlgUtils::ShowConfirmQueryWithOkL( |
|
310 FileManagerDlgUtils::EErrorIcons, |
|
311 R_QTN_FMGR_BACKUP_DESTINATION_FULL, |
|
312 driveName ); |
|
313 } |
|
314 else |
|
315 { |
|
316 StartProcessL( EBackupProcess ); |
|
317 } |
|
318 } |
|
319 } |
|
320 } |
|
321 |
|
322 // ---------------------------------------------------------------------------- |
|
323 // CFileManagerBackupView::CmdRestoreL |
|
324 // ---------------------------------------------------------------------------- |
|
325 // |
|
326 void CFileManagerBackupView::CmdRestoreL() |
|
327 { |
|
328 StoreIndex(); |
|
329 static_cast< CFileManagerAppUi* >( AppUi() )->ActivateRestoreViewL(); |
|
330 } |
|
331 |
|
332 // ---------------------------------------------------------------------------- |
|
333 // CFileManagerBackupView::ChangeContentsL |
|
334 // ---------------------------------------------------------------------------- |
|
335 // |
|
336 void CFileManagerBackupView::ChangeContentsL() |
|
337 { |
|
338 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
339 TUint32 selection( settings.Content() ); |
|
340 |
|
341 if ( FileManagerDlgUtils::ShowNOfMSettingQueryL( |
|
342 R_QTN_FMGR_BACKUP_CONTENTS, |
|
343 R_FILEMANAGER_BACKUP_CONTENTS_TEXTS, |
|
344 selection, |
|
345 0 ) ) |
|
346 { |
|
347 settings.SetContent( selection ); |
|
348 settings.SaveL(); |
|
349 iContainer->RefreshListL( iIndex ); |
|
350 } |
|
351 } |
|
352 |
|
353 // ---------------------------------------------------------------------------- |
|
354 // CFileManagerBackupView::ChangeSchedulingL |
|
355 // ---------------------------------------------------------------------------- |
|
356 // |
|
357 void CFileManagerBackupView::ChangeSchedulingL() |
|
358 { |
|
359 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
360 TInt index( settings.Scheduling() ); |
|
361 |
|
362 if ( FileManagerDlgUtils::ShowOOfMSettingQueryL( |
|
363 R_QTN_FMGR_BACKUP_SCHEDULING, |
|
364 R_FILEMANAGER_BACKUP_SCHEDULING_TEXTS, |
|
365 index ) ) |
|
366 { |
|
367 settings.SetScheduling( index ); |
|
368 settings.SaveL(); |
|
369 iContainer->RefreshListL( iIndex ); |
|
370 UpdateScheduleL(); |
|
371 } |
|
372 } |
|
373 |
|
374 // ---------------------------------------------------------------------------- |
|
375 // CFileManagerBackupView::ChangeWeekdayL |
|
376 // ---------------------------------------------------------------------------- |
|
377 // |
|
378 void CFileManagerBackupView::ChangeWeekdayL() |
|
379 { |
|
380 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
381 TDay day( static_cast< TDay >( settings.Day() ) ); |
|
382 |
|
383 if ( FileManagerDlgUtils::ShowWeekdayQueryL( |
|
384 R_QTN_FMGR_BACKUP_WEEKDAY, |
|
385 day ) ) |
|
386 { |
|
387 settings.SetDay( day ); |
|
388 settings.SaveL(); |
|
389 iContainer->RefreshListL( iIndex ); |
|
390 UpdateScheduleL(); |
|
391 } |
|
392 } |
|
393 |
|
394 // ---------------------------------------------------------------------------- |
|
395 // CFileManagerBackupView::ChangeTargetDriveL |
|
396 // ---------------------------------------------------------------------------- |
|
397 // |
|
398 void CFileManagerBackupView::ChangeTargetDriveL() |
|
399 { |
|
400 #ifdef RD_MULTIPLE_DRIVE |
|
401 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
402 |
|
403 HBufC* title = StringLoader::LoadLC( |
|
404 R_QTN_FMGR_SELECT_BACKUP_DESTINATION ); |
|
405 |
|
406 TUint32 drvMask( settings.AllowedDriveAttMatchMask() ); |
|
407 TInt memType( AknCommonDialogsDynMem::EMemoryTypeMMCExternal ); |
|
408 if ( drvMask & KDriveAttRemote ) |
|
409 { |
|
410 memType |= AknCommonDialogsDynMem::EMemoryTypeRemote; |
|
411 } |
|
412 |
|
413 CAknMemorySelectionDialogMultiDrive* dlg = |
|
414 CAknMemorySelectionDialogMultiDrive::NewL( |
|
415 ECFDDialogTypeNormal, |
|
416 R_FILEMANAGER_FIND_MEMORY_SELECTIONDIALOG, |
|
417 ETrue, |
|
418 memType ); |
|
419 CleanupStack::PushL( dlg ); |
|
420 dlg->SetTitleL( *title ); |
|
421 TDriveNumber driveNumber( static_cast< TDriveNumber >( |
|
422 settings.TargetDrive() ) ); |
|
423 TBool ret( dlg->ExecuteL( driveNumber ) ); |
|
424 CleanupStack::PopAndDestroy( dlg ); |
|
425 CleanupStack::PopAndDestroy( title ); |
|
426 if ( ret ) |
|
427 { |
|
428 TInt drive( static_cast< TInt >( driveNumber ) ); |
|
429 if ( drive != settings.TargetDrive() ) |
|
430 { |
|
431 settings.SetTargetDrive( drive ); |
|
432 settings.SaveL(); |
|
433 iContainer->RefreshListL( iIndex ); |
|
434 } |
|
435 } |
|
436 #endif // RD_MULTIPLE_DRIVE |
|
437 } |
|
438 |
|
439 // ---------------------------------------------------------------------------- |
|
440 // CFileManagerBackupView::ChangeTimeL |
|
441 // ---------------------------------------------------------------------------- |
|
442 // |
|
443 void CFileManagerBackupView::ChangeTimeL() |
|
444 { |
|
445 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
446 TTime time( settings.Time() ); |
|
447 |
|
448 if ( FileManagerDlgUtils::ShowTimeSettingQueryL( |
|
449 R_QTN_FMGR_BACKUP_TIME, |
|
450 time ) ) |
|
451 { |
|
452 settings.SetTime( time ); |
|
453 settings.SaveL(); |
|
454 iContainer->RefreshListL( iIndex ); |
|
455 UpdateScheduleL(); |
|
456 } |
|
457 } |
|
458 |
|
459 // ---------------------------------------------------------------------------- |
|
460 // CFileManagerBackupView::CmdBackL |
|
461 // ---------------------------------------------------------------------------- |
|
462 // |
|
463 void CFileManagerBackupView::CmdBackL() |
|
464 { |
|
465 iIndex = 0; |
|
466 static_cast< CFileManagerAppUi* >( AppUi() )->CloseBackupViewL(); |
|
467 } |
|
468 |
|
469 // ---------------------------------------------------------------------------- |
|
470 // CFileManagerBackupView::UpdateScheduleL |
|
471 // ---------------------------------------------------------------------------- |
|
472 // |
|
473 void CFileManagerBackupView::UpdateScheduleL() |
|
474 { |
|
475 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
476 CFileManagerAppUi* appUi = |
|
477 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
478 CFileManagerTaskScheduler& scheduler( appUi->TaskSchedulerL() ); |
|
479 |
|
480 if ( settings.Scheduling() == EFileManagerBackupScheduleNone ) |
|
481 { |
|
482 scheduler.EnableBackupScheduleL( EFalse ); |
|
483 } |
|
484 else |
|
485 { |
|
486 scheduler.EnableBackupScheduleL( ETrue ); |
|
487 } |
|
488 } |
|
489 |
|
490 // ---------------------------------------------------------------------------- |
|
491 // CFileManagerBackupView::NotifyForegroundStatusChange |
|
492 // ---------------------------------------------------------------------------- |
|
493 // |
|
494 void CFileManagerBackupView::NotifyForegroundStatusChange( |
|
495 TBool aForeground ) |
|
496 { |
|
497 FUNC_LOG |
|
498 |
|
499 if ( aForeground ) |
|
500 { |
|
501 TRAP_IGNORE( RefreshSettingsL() ); |
|
502 } |
|
503 } |
|
504 |
|
505 // ---------------------------------------------------------------------------- |
|
506 // CFileManagerBackupView::RefreshSettingsL |
|
507 // ---------------------------------------------------------------------------- |
|
508 // |
|
509 void CFileManagerBackupView::RefreshSettingsL() |
|
510 { |
|
511 FUNC_LOG |
|
512 |
|
513 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
514 settings.RefreshL(); |
|
515 if ( iContainer ) |
|
516 { |
|
517 iContainer->RefreshListL( iIndex ); |
|
518 } |
|
519 } |
|
520 |
|
521 // ---------------------------------------------------------------------------- |
|
522 // CFileManagerBackupView::CmdDeleteBackupL |
|
523 // ---------------------------------------------------------------------------- |
|
524 // |
|
525 void CFileManagerBackupView::CmdDeleteBackupL() |
|
526 { |
|
527 StoreIndex(); |
|
528 static_cast< CFileManagerAppUi* >( AppUi() )->ActivateRestoreViewL( ETrue ); |
|
529 } |
|
530 |
|
531 // ---------------------------------------------------------------------------- |
|
532 // CFileManagerBackupView::DynInitMenuPaneL |
|
533 // ---------------------------------------------------------------------------- |
|
534 // |
|
535 void CFileManagerBackupView::DynInitMenuPaneL( |
|
536 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
537 { |
|
538 switch( aResourceId ) |
|
539 { |
|
540 case R_FILEMANAGER_BACKUP_VIEW_MENU: |
|
541 { |
|
542 BackupMenuFilteringL( *aMenuPane ); |
|
543 break; |
|
544 } |
|
545 default: |
|
546 { |
|
547 CFileManagerViewBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
548 break; |
|
549 } |
|
550 } |
|
551 } |
|
552 |
|
553 // ---------------------------------------------------------------------------- |
|
554 // CFileManagerBackupView::BackupMenuFilteringL |
|
555 // ---------------------------------------------------------------------------- |
|
556 // |
|
557 void CFileManagerBackupView::BackupMenuFilteringL( CEikMenuPane& aMenuPane ) |
|
558 { |
|
559 CFileManagerRestoreSettings& settings( iEngine.RestoreSettingsL() ); |
|
560 TRAP_IGNORE( settings.RefreshL() ); |
|
561 if ( !settings.MdcaCount() ) |
|
562 { |
|
563 aMenuPane.SetItemDimmed( EFileManagerDeleteBackup, ETrue ); |
|
564 } |
|
565 aMenuPane.SetItemDimmed( EFileManagerOpen, ETrue ); |
|
566 } |
|
567 |
|
568 // End of File |
|