filemanager/App/src/CFileManagerSchBackupHandler.cpp
branchRCL_3
changeset 10 875fd7f60fdf
parent 0 6a9f87576119
child 14 efe289f793e7
equal deleted inserted replaced
9:60626d494346 10:875fd7f60fdf
    14 * Description:  Handler for scheduled backup
    14 * Description:  Handler for scheduled backup
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 // #define FILE_MANAGER_POWER_SAVING_MODE
    19  #define FILE_MANAGER_POWER_SAVING_MODE
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 #include <StringLoader.h>
    22 #include <StringLoader.h>
    23 #include <centralrepository.h>
    23 #include <centralrepository.h>
    24 #include <avkon.hrh>
    24 #include <avkon.hrh>
   173 // CFileManagerSchBackupHandler::StartBackupL
   173 // CFileManagerSchBackupHandler::StartBackupL
   174 // ----------------------------------------------------------------------------
   174 // ----------------------------------------------------------------------------
   175 //
   175 //
   176 void CFileManagerSchBackupHandler::StartBackupL()
   176 void CFileManagerSchBackupHandler::StartBackupL()
   177     {
   177     {
   178     TBool drvAvailable( ETrue );
   178     CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() );
   179     TRAPD( err, drvAvailable = IsTargetDriveAvailableL() );
   179     TFileManagerDriveInfo drvInfo;
   180     if ( !drvAvailable && err == KErrNone )
   180     iEngine.GetDriveInfoL( settings.TargetDrive(), drvInfo );
       
   181     TBool drvAvailable( EFalse );
       
   182 
       
   183     if( !IsTargetDriveAvailableL(drvInfo ) )
       
   184         {
       
   185         for( TInt i ( EDriveA ); i <= EDriveZ; i++ )
       
   186             {
       
   187             iEngine.GetDriveInfoL( i , drvInfo );
       
   188             if( ( IsTargetDriveAvailableL( drvInfo ) ) && ( drvInfo.iState & TFileManagerDriveInfo::EDriveEjectable ) )
       
   189                 {
       
   190                  settings.SetTargetDrive( i );
       
   191                  settings.SaveL();
       
   192                  drvAvailable = ETrue;
       
   193                  break;
       
   194                 }
       
   195             }
       
   196         }
       
   197     else
       
   198         {
       
   199         drvAvailable = ETrue;
       
   200         }
       
   201     if ( !drvAvailable )
   181         {
   202         {
   182         iGlobalDlg->ShowDialogL(
   203         iGlobalDlg->ShowDialogL(
   183             CFileManagerGlobalDlg::EQueryWithWarningIcon,
   204             CFileManagerGlobalDlg::EQueryWithWarningIcon,
   184             R_QTN_FMGR_SCHEDULED_BACKUP_ERROR,
   205             R_QTN_FMGR_SCHEDULED_BACKUP_ERROR,
   185             R_AVKON_SOFTKEYS_OK_EMPTY );
   206             R_AVKON_SOFTKEYS_OK_EMPTY );
   186         CancelBackupStarter();
   207         CancelBackupStarter();
   187         return;
   208         return;
   188         }
   209         }
   189 
   210 
   190     CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() );
       
   191     HBufC* text = StringLoader::LoadLC(
   211     HBufC* text = StringLoader::LoadLC(
   192         R_QTN_FMGR_SCHEDULED_BACKUP_PROGRESS,
   212         R_QTN_FMGR_SCHEDULED_BACKUP_PROGRESS,
   193         iEngine.DriveName( settings.TargetDrive() ) );
   213         iEngine.DriveName( settings.TargetDrive() ) );
   194 
   214 
   195     iGlobalDlg->ShowDialogL(
   215     iGlobalDlg->ShowDialogL(
   378 
   398 
   379 // ----------------------------------------------------------------------------
   399 // ----------------------------------------------------------------------------
   380 // CFileManagerSchBackupHandler::IsTargetDriveAvailableL
   400 // CFileManagerSchBackupHandler::IsTargetDriveAvailableL
   381 // ----------------------------------------------------------------------------
   401 // ----------------------------------------------------------------------------
   382 //
   402 //
   383 TBool CFileManagerSchBackupHandler::IsTargetDriveAvailableL()
   403 TBool CFileManagerSchBackupHandler::IsTargetDriveAvailableL( const TFileManagerDriveInfo& aDrvInfo )
   384     {
   404     {
   385     // Start backup with cancelable global progress dialog
   405     // Start backup with cancelable global progress dialog
   386     CFileManagerBackupSettings& settings( iEngine.BackupSettingsL() );
       
   387 
   406 
   388     // Check is target drive available
   407     // Check is target drive available
   389     TBool ret( ETrue );
   408     TBool ret( ETrue );
   390     TFileManagerDriveInfo info;
   409     if ( !( aDrvInfo.iState & TFileManagerDriveInfo::EDrivePresent ) ||
   391     iEngine.GetDriveInfoL( settings.TargetDrive(), info );
   410          ( aDrvInfo.iState &
   392     if ( !( info.iState & TFileManagerDriveInfo::EDrivePresent ) ||
       
   393          ( info.iState &
       
   394             ( TFileManagerDriveInfo::EDriveLocked |
   411             ( TFileManagerDriveInfo::EDriveLocked |
   395               TFileManagerDriveInfo::EDriveCorrupted |
   412               TFileManagerDriveInfo::EDriveCorrupted |
   396               TFileManagerDriveInfo::EDriveWriteProtected ) ) )
   413               TFileManagerDriveInfo::EDriveWriteProtected ) ) )
   397         {
   414         {
   398         ERROR_LOG1(
   415         ERROR_LOG1(
   399             "CFileManagerSchBackupHandler::IsTargetDriveAvailableL-DrvState=%d",
   416             "CFileManagerSchBackupHandler::IsTargetDriveAvailableL-DrvState=%d",
   400             info.iState )
   417             aDrvInfo.iState )
   401         ret = EFalse;
   418         ret = EFalse;
   402         }
   419         }
   403     return ret;
   420     return ret;
   404     }
   421     }
   405 
   422