|
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 if ( iContainer ) |
|
116 { |
|
117 iContainer->RefreshListL( iIndex ); |
|
118 } |
|
119 } |
|
120 |
|
121 // ---------------------------------------------------------------------------- |
|
122 // CFileManagerBackupView::Id |
|
123 // ---------------------------------------------------------------------------- |
|
124 // |
|
125 TUid CFileManagerBackupView::Id() const |
|
126 { |
|
127 return CFileManagerAppUi::KFileManagerBackupViewId; |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // CFileManagerBackupView::CreateContainerL |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 CFileManagerContainerBase* CFileManagerBackupView::CreateContainerL() |
|
135 { |
|
136 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
137 |
|
138 return CFileManagerSettingListContainer::NewL( |
|
139 ClientRect(), |
|
140 iIndex, |
|
141 CFileManagerSettingListContainer::EListBackup, |
|
142 &settings, |
|
143 KFMGR_HLP_BACKUP_VIEW ); |
|
144 } |
|
145 |
|
146 // ---------------------------------------------------------------------------- |
|
147 // CFileManagerBackupView::HandleCommandL |
|
148 // ---------------------------------------------------------------------------- |
|
149 // |
|
150 void CFileManagerBackupView::HandleCommandL( TInt aCommand ) |
|
151 { |
|
152 switch( aCommand ) |
|
153 { |
|
154 case EFileManagerSelectionKey: // FALLTHROUGH |
|
155 case EFileManagerOpen: |
|
156 { |
|
157 CmdChangeL(); |
|
158 break; |
|
159 } |
|
160 case EFileManagerBackup: |
|
161 { |
|
162 CmdBackupL(); |
|
163 break; |
|
164 } |
|
165 case EFileManagerRestore: |
|
166 { |
|
167 CmdRestoreL(); |
|
168 break; |
|
169 } |
|
170 case EFileManagerDeleteBackup: |
|
171 { |
|
172 CmdDeleteBackupL(); |
|
173 break; |
|
174 } |
|
175 case EAknSoftkeyBack: |
|
176 { |
|
177 CmdBackL(); |
|
178 break; |
|
179 } |
|
180 default: |
|
181 { |
|
182 CFileManagerViewBase::HandleCommandL( aCommand ); |
|
183 break; |
|
184 } |
|
185 } |
|
186 } |
|
187 |
|
188 // ---------------------------------------------------------------------------- |
|
189 // CFileManagerBackupView::CmdChangeL |
|
190 // ---------------------------------------------------------------------------- |
|
191 // |
|
192 void CFileManagerBackupView::CmdChangeL() |
|
193 { |
|
194 if ( !iContainer ) |
|
195 { |
|
196 return; |
|
197 } |
|
198 TInt index( iContainer->ListBoxCurrentItemIndex() ); |
|
199 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
200 |
|
201 StoreIndex(); |
|
202 |
|
203 switch ( settings.SettingAt( index ) ) |
|
204 { |
|
205 case CFileManagerBackupSettings::EContents: |
|
206 { |
|
207 ChangeContentsL(); |
|
208 break; |
|
209 } |
|
210 case CFileManagerBackupSettings::EScheduling: |
|
211 { |
|
212 ChangeSchedulingL(); |
|
213 break; |
|
214 } |
|
215 case CFileManagerBackupSettings::EWeekday: |
|
216 { |
|
217 ChangeWeekdayL(); |
|
218 break; |
|
219 } |
|
220 case CFileManagerBackupSettings::ETime: |
|
221 { |
|
222 ChangeTimeL(); |
|
223 break; |
|
224 } |
|
225 case CFileManagerBackupSettings::ETarget: |
|
226 { |
|
227 ChangeTargetDriveL(); |
|
228 break; |
|
229 } |
|
230 default: |
|
231 { |
|
232 break; |
|
233 } |
|
234 } |
|
235 } |
|
236 |
|
237 // ---------------------------------------------------------------------------- |
|
238 // CFileManagerBackupView::CmdBackupL |
|
239 // ---------------------------------------------------------------------------- |
|
240 // |
|
241 void CFileManagerBackupView::CmdBackupL() |
|
242 { |
|
243 if ( !iContainer ) |
|
244 { |
|
245 return; |
|
246 } |
|
247 StoreIndex(); |
|
248 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
249 TInt drive( settings.TargetDrive() ); |
|
250 TInt MemoryCardDriveF( KFmgrMemoryCardDrive + 1 ); |
|
251 //KFmgrMemoryCardDrive has been changed as Mass memory,MemoryCard is changed to F |
|
252 |
|
253 if( drive != MemoryCardDriveF && !IsDriveAvailable( drive ) ) |
|
254 { |
|
255 drive = MemoryCardDriveF; |
|
256 settings.SetTargetDrive( drive ); |
|
257 settings.SaveL(); |
|
258 } |
|
259 TFileManagerDriveInfo drvInfo; |
|
260 iEngine.GetDriveInfoL( drive, drvInfo ); |
|
261 RArray< CFileManagerRestoreSettings::TInfo > info; |
|
262 CleanupClosePushL( info ); |
|
263 iEngine.GetRestoreInfoArrayL( info, drive ); |
|
264 TInt count( info.Count() ); |
|
265 CleanupStack::PopAndDestroy( &info ); |
|
266 TPtrC driveName( iEngine.DriveName( drive ) ); |
|
267 TBool isContinue( true ); |
|
268 |
|
269 |
|
270 const TInt64 KBackupLimitSize = 10000000; |
|
271 |
|
272 //define a protected limit size to avoid not enough space during backup |
|
273 |
|
274 if( count ) |
|
275 { |
|
276 TInt textId( R_QTN_FMGR_BACKUP_QUERY_EXISTS ); |
|
277 |
|
278 if( !FileManagerDlgUtils::ShowConfirmQueryWithYesNoL( |
|
279 textId, driveName ) ) |
|
280 { |
|
281 isContinue = false; |
|
282 } |
|
283 } |
|
284 if( isContinue ) |
|
285 { |
|
286 if ( !DriveReadOnlyMmcL( drive ) ) |
|
287 { |
|
288 if ( !IsDriveAvailable( drive ) ) |
|
289 { |
|
290 FileManagerDlgUtils::ShowErrorNoteL( |
|
291 R_QTN_FMGR_ERROR_BACKUP_MEMORYCARD_NOT_AVAILABLE ); |
|
292 } |
|
293 else if ( !CheckPhoneState() ) |
|
294 { |
|
295 FileManagerDlgUtils::ShowErrorNoteL( R_QTN_CRITICAL_ERROR ); |
|
296 } |
|
297 else if ( !iEngine.EnoughSpaceL( |
|
298 TDriveUnit( drive ).Name(), KBackupLimitSize, EBackupProcess ) ) |
|
299 { |
|
300 FileManagerDlgUtils::ShowConfirmQueryWithOkL( |
|
301 FileManagerDlgUtils::EErrorIcons, |
|
302 R_QTN_FMGR_BACKUP_DESTINATION_FULL, |
|
303 driveName ); |
|
304 } |
|
305 else |
|
306 { |
|
307 StartProcessL( EBackupProcess ); |
|
308 } |
|
309 } |
|
310 } |
|
311 } |
|
312 |
|
313 // ---------------------------------------------------------------------------- |
|
314 // CFileManagerBackupView::CmdRestoreL |
|
315 // ---------------------------------------------------------------------------- |
|
316 // |
|
317 void CFileManagerBackupView::CmdRestoreL() |
|
318 { |
|
319 StoreIndex(); |
|
320 static_cast< CFileManagerAppUi* >( AppUi() )->ActivateRestoreViewL(); |
|
321 } |
|
322 |
|
323 // ---------------------------------------------------------------------------- |
|
324 // CFileManagerBackupView::ChangeContentsL |
|
325 // ---------------------------------------------------------------------------- |
|
326 // |
|
327 void CFileManagerBackupView::ChangeContentsL() |
|
328 { |
|
329 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
330 TUint32 selection( settings.Content() ); |
|
331 |
|
332 if ( FileManagerDlgUtils::ShowNOfMSettingQueryL( |
|
333 R_QTN_FMGR_BACKUP_CONTENTS, |
|
334 R_FILEMANAGER_BACKUP_CONTENTS_TEXTS, |
|
335 selection, |
|
336 0 ) ) |
|
337 { |
|
338 settings.SetContent( selection ); |
|
339 settings.SaveL(); |
|
340 iContainer->RefreshListL( iIndex ); |
|
341 } |
|
342 } |
|
343 |
|
344 // ---------------------------------------------------------------------------- |
|
345 // CFileManagerBackupView::ChangeSchedulingL |
|
346 // ---------------------------------------------------------------------------- |
|
347 // |
|
348 void CFileManagerBackupView::ChangeSchedulingL() |
|
349 { |
|
350 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
351 TInt index( settings.Scheduling() ); |
|
352 |
|
353 if ( FileManagerDlgUtils::ShowOOfMSettingQueryL( |
|
354 R_QTN_FMGR_BACKUP_SCHEDULING, |
|
355 R_FILEMANAGER_BACKUP_SCHEDULING_TEXTS, |
|
356 index ) ) |
|
357 { |
|
358 settings.SetScheduling( index ); |
|
359 settings.SaveL(); |
|
360 iContainer->RefreshListL( iIndex ); |
|
361 UpdateScheduleL(); |
|
362 } |
|
363 } |
|
364 |
|
365 // ---------------------------------------------------------------------------- |
|
366 // CFileManagerBackupView::ChangeWeekdayL |
|
367 // ---------------------------------------------------------------------------- |
|
368 // |
|
369 void CFileManagerBackupView::ChangeWeekdayL() |
|
370 { |
|
371 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
372 TDay day( static_cast< TDay >( settings.Day() ) ); |
|
373 |
|
374 if ( FileManagerDlgUtils::ShowWeekdayQueryL( |
|
375 R_QTN_FMGR_BACKUP_WEEKDAY, |
|
376 day ) ) |
|
377 { |
|
378 settings.SetDay( day ); |
|
379 settings.SaveL(); |
|
380 iContainer->RefreshListL( iIndex ); |
|
381 UpdateScheduleL(); |
|
382 } |
|
383 } |
|
384 |
|
385 // ---------------------------------------------------------------------------- |
|
386 // CFileManagerBackupView::ChangeTargetDriveL |
|
387 // ---------------------------------------------------------------------------- |
|
388 // |
|
389 void CFileManagerBackupView::ChangeTargetDriveL() |
|
390 { |
|
391 #ifdef RD_MULTIPLE_DRIVE |
|
392 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
393 |
|
394 HBufC* title = StringLoader::LoadLC( |
|
395 R_QTN_FMGR_SELECT_BACKUP_DESTINATION ); |
|
396 |
|
397 TUint32 drvMask( settings.AllowedDriveAttMatchMask() ); |
|
398 TInt memType( AknCommonDialogsDynMem::EMemoryTypeMMCExternal ); |
|
399 if ( drvMask & KDriveAttRemote ) |
|
400 { |
|
401 memType |= AknCommonDialogsDynMem::EMemoryTypeRemote; |
|
402 } |
|
403 |
|
404 CAknMemorySelectionDialogMultiDrive* dlg = |
|
405 CAknMemorySelectionDialogMultiDrive::NewL( |
|
406 ECFDDialogTypeNormal, |
|
407 R_FILEMANAGER_FIND_MEMORY_SELECTIONDIALOG, |
|
408 ETrue, |
|
409 memType ); |
|
410 CleanupStack::PushL( dlg ); |
|
411 dlg->SetTitleL( *title ); |
|
412 TDriveNumber driveNumber( static_cast< TDriveNumber >( |
|
413 settings.TargetDrive() ) ); |
|
414 TBool ret( dlg->ExecuteL( driveNumber ) ); |
|
415 CleanupStack::PopAndDestroy( dlg ); |
|
416 CleanupStack::PopAndDestroy( title ); |
|
417 if ( ret ) |
|
418 { |
|
419 TInt drive( static_cast< TInt >( driveNumber ) ); |
|
420 if ( drive != settings.TargetDrive() ) |
|
421 { |
|
422 settings.SetTargetDrive( drive ); |
|
423 settings.SaveL(); |
|
424 iContainer->RefreshListL( iIndex ); |
|
425 } |
|
426 } |
|
427 #endif // RD_MULTIPLE_DRIVE |
|
428 } |
|
429 |
|
430 // ---------------------------------------------------------------------------- |
|
431 // CFileManagerBackupView::ChangeTimeL |
|
432 // ---------------------------------------------------------------------------- |
|
433 // |
|
434 void CFileManagerBackupView::ChangeTimeL() |
|
435 { |
|
436 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
437 TTime time( settings.Time() ); |
|
438 |
|
439 if ( FileManagerDlgUtils::ShowTimeSettingQueryL( |
|
440 R_QTN_FMGR_BACKUP_TIME, |
|
441 time ) ) |
|
442 { |
|
443 settings.SetTime( time ); |
|
444 settings.SaveL(); |
|
445 iContainer->RefreshListL( iIndex ); |
|
446 UpdateScheduleL(); |
|
447 } |
|
448 } |
|
449 |
|
450 // ---------------------------------------------------------------------------- |
|
451 // CFileManagerBackupView::CmdBackL |
|
452 // ---------------------------------------------------------------------------- |
|
453 // |
|
454 void CFileManagerBackupView::CmdBackL() |
|
455 { |
|
456 iIndex = 0; |
|
457 static_cast< CFileManagerAppUi* >( AppUi() )->CloseBackupViewL(); |
|
458 } |
|
459 |
|
460 // ---------------------------------------------------------------------------- |
|
461 // CFileManagerBackupView::UpdateScheduleL |
|
462 // ---------------------------------------------------------------------------- |
|
463 // |
|
464 void CFileManagerBackupView::UpdateScheduleL() |
|
465 { |
|
466 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
467 CFileManagerAppUi* appUi = |
|
468 static_cast< CFileManagerAppUi* >( AppUi() ); |
|
469 CFileManagerTaskScheduler& scheduler( appUi->TaskSchedulerL() ); |
|
470 |
|
471 if ( settings.Scheduling() == EFileManagerBackupScheduleNone ) |
|
472 { |
|
473 scheduler.EnableBackupScheduleL( EFalse ); |
|
474 } |
|
475 else |
|
476 { |
|
477 scheduler.EnableBackupScheduleL( ETrue ); |
|
478 } |
|
479 } |
|
480 |
|
481 // ---------------------------------------------------------------------------- |
|
482 // CFileManagerBackupView::NotifyForegroundStatusChange |
|
483 // ---------------------------------------------------------------------------- |
|
484 // |
|
485 void CFileManagerBackupView::NotifyForegroundStatusChange( |
|
486 TBool aForeground ) |
|
487 { |
|
488 FUNC_LOG |
|
489 |
|
490 if ( aForeground ) |
|
491 { |
|
492 TRAP_IGNORE( RefreshSettingsL() ); |
|
493 } |
|
494 } |
|
495 |
|
496 // ---------------------------------------------------------------------------- |
|
497 // CFileManagerBackupView::RefreshSettingsL |
|
498 // ---------------------------------------------------------------------------- |
|
499 // |
|
500 void CFileManagerBackupView::RefreshSettingsL() |
|
501 { |
|
502 FUNC_LOG |
|
503 |
|
504 CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() ); |
|
505 settings.RefreshL(); |
|
506 if ( iContainer ) |
|
507 { |
|
508 iContainer->RefreshListL( iIndex ); |
|
509 } |
|
510 } |
|
511 |
|
512 // ---------------------------------------------------------------------------- |
|
513 // CFileManagerBackupView::CmdDeleteBackupL |
|
514 // ---------------------------------------------------------------------------- |
|
515 // |
|
516 void CFileManagerBackupView::CmdDeleteBackupL() |
|
517 { |
|
518 StoreIndex(); |
|
519 static_cast< CFileManagerAppUi* >( AppUi() )->ActivateRestoreViewL( ETrue ); |
|
520 } |
|
521 |
|
522 // ---------------------------------------------------------------------------- |
|
523 // CFileManagerBackupView::DynInitMenuPaneL |
|
524 // ---------------------------------------------------------------------------- |
|
525 // |
|
526 void CFileManagerBackupView::DynInitMenuPaneL( |
|
527 TInt aResourceId, CEikMenuPane* aMenuPane) |
|
528 { |
|
529 switch( aResourceId ) |
|
530 { |
|
531 case R_FILEMANAGER_BACKUP_VIEW_MENU: |
|
532 { |
|
533 BackupMenuFilteringL( *aMenuPane ); |
|
534 break; |
|
535 } |
|
536 default: |
|
537 { |
|
538 CFileManagerViewBase::DynInitMenuPaneL( aResourceId, aMenuPane ); |
|
539 break; |
|
540 } |
|
541 } |
|
542 } |
|
543 |
|
544 // ---------------------------------------------------------------------------- |
|
545 // CFileManagerBackupView::BackupMenuFilteringL |
|
546 // ---------------------------------------------------------------------------- |
|
547 // |
|
548 void CFileManagerBackupView::BackupMenuFilteringL( CEikMenuPane& aMenuPane ) |
|
549 { |
|
550 CFileManagerRestoreSettings& settings( iEngine.RestoreSettingsL() ); |
|
551 TRAP_IGNORE( settings.RefreshL() ); |
|
552 if ( !settings.MdcaCount() ) |
|
553 { |
|
554 aMenuPane.SetItemDimmed( EFileManagerDeleteBackup, ETrue ); |
|
555 } |
|
556 aMenuPane.SetItemDimmed( EFileManagerOpen, ETrue ); |
|
557 } |
|
558 |
|
559 // End of File |