filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp
changeset 37 15bc28c9dd51
parent 16 ada7962b4308
equal deleted inserted replaced
16:ada7962b4308 37:15bc28c9dd51
    96 
    96 
    97 bool FmBkupEnginePrivate::startBackup(QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
    97 bool FmBkupEnginePrivate::startBackup(QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
    98 	    QList<FmBkupBackupCategory*> backupCategoryList,
    98 	    QList<FmBkupBackupCategory*> backupCategoryList,
    99 	    QString drive, quint32 content)
    99 	    QString drive, quint32 content)
   100 {
   100 {
       
   101     FM_LOG( "FmBkupEnginePrivate::startBackup_with drive: " + drive +
       
   102             "_number:" + QString::number(DriverNameToNumber( drive )));
   101     if( drive.isEmpty() ) {
   103     if( drive.isEmpty() ) {
   102         iError = KErrPathNotFound;
   104         iError = KErrPathNotFound;
       
   105         FM_LOG( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is empty" );
       
   106         return false;
       
   107     }
       
   108     QStringList backupableDriveList;
       
   109     getBackupDriveList( backupableDriveList );
       
   110     if( !backupableDriveList.contains( drive, Qt::CaseInsensitive ) ) {
       
   111         iError = KErrPathNotFound;
       
   112         FM_LOG( "FmBkupEnginePrivate::startBackup_with return with KErrPathNotFound because drive is not available" );
   103         return false;
   113         return false;
   104     }
   114     }
   105     QString logString;
   115     QString logString;
   106     logString = "startBackup";
   116     logString = "startBackup";
   107     FmLogger::log( logString );
   117     FM_LOG( logString );
   108     iDrvAndOpList->Reset();
   118     iDrvAndOpList->Reset();
   109     iBkupCategoryList->ResetAndDestroy();
   119     iBkupCategoryList->ResetAndDestroy();
   110 	
   120 	
   111     logString = "startBackup_driveroperation count:" + QString::number(drivesAndOperationList.count());
   121     logString = "startBackup_driveroperation count:" + QString::number(drivesAndOperationList.count());
   112     FmLogger::log( logString );
   122     FM_LOG( logString );
   113     
   123     
   114     for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
   124     for( QList<FmBkupDrivesAndOperation* >::iterator it = drivesAndOperationList.begin();
   115         it != drivesAndOperationList.end(); ++it ) {
   125         it != drivesAndOperationList.end(); ++it ) {
   116 		FmBkupDrivesAndOperation* fmDrvAndOp = *it;
   126 		FmBkupDrivesAndOperation* fmDrvAndOp = *it;
   117 		TBkupDrivesAndOperation drvAndOp;
   127 		TBkupDrivesAndOperation drvAndOp;
   119 		drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
   129 		drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
   120 		iDrvAndOpList->AppendL( drvAndOp );
   130 		iDrvAndOpList->AppendL( drvAndOp );
   121 		}
   131 		}
   122 
   132 
   123     logString = "startBackup_backupCategoryList count:" + QString::number(backupCategoryList.count());
   133     logString = "startBackup_backupCategoryList count:" + QString::number(backupCategoryList.count());
   124     FmLogger::log( logString );
   134     FM_LOG( logString );
   125 
   135 
   126 	
   136 	
   127 	for( QList<FmBkupBackupCategory* >::iterator it = backupCategoryList.begin();
   137 	for( QList<FmBkupBackupCategory* >::iterator it = backupCategoryList.begin();
   128 		    it != backupCategoryList.end(); ++it ) {
   138 		    it != backupCategoryList.end(); ++it ) {
   129         FmBkupBackupCategory* fmbkupCategory = *it;
   139         FmBkupBackupCategory* fmbkupCategory = *it;
   158 	
   168 	
   159 	TUint32 bkupContent( FmgrToBkupMask( content ) );
   169 	TUint32 bkupContent( FmgrToBkupMask( content ) );
   160 	//TUint32 bkupContent = 63;
   170 	//TUint32 bkupContent = 63;
   161 	
   171 	
   162     logString = "startBackup_new param";
   172     logString = "startBackup_new param";
   163     FmLogger::log( logString );
   173     FM_LOG( logString );
   164 
   174 
   165 	CMMCScBkupOpParamsBackupFull* params =
   175 	CMMCScBkupOpParamsBackupFull* params =
   166         CMMCScBkupOpParamsBackupFull::NewL(
   176         CMMCScBkupOpParamsBackupFull::NewL(
   167             iDrvAndOpList,
   177             iDrvAndOpList,
   168             iBkupCategoryList,
   178             iBkupCategoryList,
   171     
   181     
   172     mProcess = FmBkupEngine::ProcessBackup;
   182     mProcess = FmBkupEngine::ProcessBackup;
   173 
   183 
   174 
   184 
   175     logString = "startBackup_param ok";
   185     logString = "startBackup_param ok";
   176     FmLogger::log( logString );
   186     FM_LOG( logString );
   177 
   187 
   178     CCoeEnv* coeEnv = CCoeEnv::Static();
   188     CCoeEnv* coeEnv = CCoeEnv::Static();
   179     CEikonEnv* eikonEnv = (STATIC_CAST(CEikonEnv*,coeEnv));
   189     CEikonEnv* eikonEnv = (STATIC_CAST(CEikonEnv*,coeEnv));
   180     eikonEnv->SetSystem(ETrue);
   190     eikonEnv->SetSystem(ETrue);
   181 
   191 
   182     logString = "startBackup_StartOperationL";
   192     logString = "startBackup_StartOperationL";
   183     FmLogger::log( logString );
   193     FM_LOG( logString );
   184 
   194 
   185     QList< FmRestoreInfo > restoreInfoList;
   195     QList< FmRestoreInfo > restoreInfoList;
   186     TInt driveNumber = DriverNameToNumber( drive );
   196     GetRestoreInfoArray( drivesAndOperationList, restoreInfoList, drive );
   187     GetRestoreInfoArray( drivesAndOperationList, restoreInfoList, driveNumber );
   197     
   188     
   198     for ( TInt i( 0 ); i < restoreInfoList.count(); ++i )
   189     for ( TInt i( 0 ); i < restoreInfoList.count(); i++ )
       
   190         {        
   199         {        
   191         bool toContinue = false;
   200         bool toContinue = false;
   192         FmRestoreInfo &info = restoreInfoList[ i ];
   201         FmRestoreInfo &info = restoreInfoList[ i ];
   193         TUint32 existContent( FmgrToBkupMask( info.content() ) );
   202         TUint32 existContent( FmgrToBkupMask( info.content() ) );
   194         if ( bkupContent & existContent )
   203         if ( bkupContent & existContent )
   209     
   218     
   210     TRAPD( err, iBkupEngine->StartOperationL(
   219     TRAPD( err, iBkupEngine->StartOperationL(
   211         EMMCScBkupOperationTypeFullBackup, *this, params ) );
   220         EMMCScBkupOperationTypeFullBackup, *this, params ) );
   212 
   221 
   213     logString = "startBackup_end with error:" + QString::number(err) ;
   222     logString = "startBackup_end with error:" + QString::number(err) ;
   214     FmLogger::log( logString );
   223     FM_LOG( logString );
   215     return (err == KErrNone);
   224     return (err == KErrNone);
   216 }
   225 }
   217 
   226 
   218 void FmBkupEnginePrivate::cancelBackup()
   227 void FmBkupEnginePrivate::cancelBackup()
   219 {
   228 {
   220 	QString logString  = "cancelBackup";
   229 	QString logString  = "cancelBackup";
   221 	FmLogger::log(logString);
   230 	FM_LOG(logString);
   222 	switch( mProcess )
   231 	switch( mProcess )
   223     {
   232     {
   224     case FmBkupEngine::ProcessBackup: // FALLTHROUGH
   233     case FmBkupEngine::ProcessBackup: // FALLTHROUGH
   225     case FmBkupEngine::ProcessRestore:
   234     case FmBkupEngine::ProcessRestore:
   226         {
   235         {
   397             {
   406             {
   398             logString  = "default";
   407             logString  = "default";
   399             break;
   408             break;
   400             }
   409             }
   401         }
   410         }
   402     FmLogger::log( logString );
   411     FM_LOG( logString );
   403     return ret;
   412     return ret;
   404     }
   413     }
   405 
   414 
   406 int FmBkupEnginePrivate::error()
   415 int FmBkupEnginePrivate::error()
   407 {
   416 {
       
   417     FM_LOG( "FmBkupEnginePrivate::error:" + QString::number( iError ) );
   408     switch (iError) 
   418     switch (iError) 
   409     {
   419     {
   410     case KErrNone: 
   420     case KErrNone: 
   411         return FmErrNone;
   421         return FmErrNone;
   412     case KErrNotFound:
   422     case KErrNotFound:
   417         return FmErrAlreadyExists;
   427         return FmErrAlreadyExists;
   418     case KErrCancel:
   428     case KErrCancel:
   419         return FmErrCancel;
   429         return FmErrCancel;
   420     case KErrPathNotFound:
   430     case KErrPathNotFound:
   421         return FmErrPathNotFound;
   431         return FmErrPathNotFound;
       
   432     case KErrLocked:
       
   433         return FmErrLocked;
       
   434     case KErrCorrupt:
       
   435         return FmErrCorrupt;
       
   436     case KErrNotReady:
       
   437         return FmErrNotReady;
       
   438     case KErrDisMounted:
       
   439         return FmErrDisMounted;
   422     default: 
   440     default: 
   423         return FmErrUnKnown;
   441         return FmErrUnKnown;
   424     }    
   442     }    
   425 }
   443 }
   426 
   444 
   534         drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
   552         drvAndOp.setOwnerDataType( fmDrvAndOp->ownerDataType() );
   535         drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
   553         drvAndOp.setDrvCategories( fmDrvAndOp->drvCategories() );
   536         iDrvAndOpList->AppendL( drvAndOp );
   554         iDrvAndOpList->AppendL( drvAndOp );
   537         }
   555         }
   538     ////////
   556     ////////
   539     
       
   540    FmBackupSettings& bkupSettings( *( q->BackupSettingsL() ) );
       
   541 
   557 
   542     // Create restore params - ownership is transferred to
   558     // Create restore params - ownership is transferred to
   543     // secure backup engine
   559     // secure backup engine
   544 
   560 
   545 #ifdef RD_FILE_MANAGER_BACKUP
   561 #ifdef RD_FILE_MANAGER_BACKUP
   614 
   630 
   615     CMMCScBkupOpParamsRestoreFull* params =
   631     CMMCScBkupOpParamsRestoreFull* params =
   616         CMMCScBkupOpParamsRestoreFull::NewL( driveReader, EBUCatAllInOne );
   632         CMMCScBkupOpParamsRestoreFull::NewL( driveReader, EBUCatAllInOne );
   617     CleanupStack::PopAndDestroy(); // driveReader
   633     CleanupStack::PopAndDestroy(); // driveReader
   618 
   634 
       
   635     FmBackupSettings& bkupSettings( *( q->BackupSettingsL() ) );
   619     // Get list of all archives
   636     // Get list of all archives
   620     RPointerArray< CMMCScBkupArchiveInfo > archives;
   637     RPointerArray< CMMCScBkupArchiveInfo > archives;
   621     TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
   638     TCleanupItem cleanupItem( ResetAndDestroyArchives, &archives );
   622     CleanupStack::PushL( cleanupItem );
   639     CleanupStack::PushL( cleanupItem );
   623     iBkupEngine->ListArchivesL(
   640     iBkupEngine->ListArchivesL(
   648     return true;
   665     return true;
   649     }
   666     }
   650 
   667 
   651 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   668 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   652         QList< FmRestoreInfo > &restoreInfoList,
   669         QList< FmRestoreInfo > &restoreInfoList,
   653         const TInt aDrive )
   670         const QString& aDrive )
   654     {
   671     {
   655     FmBackupSettings& settings( *( q->BackupSettingsL() ) );
   672     int targetDrive = DriverNameToNumber( aDrive );    
   656 
   673 
   657     restoreInfoList.clear();
   674     restoreInfoList.clear();
   658     
   675     
   659     ///////
   676     ///////
   660     iDrvAndOpList->Reset();
   677     iDrvAndOpList->Reset();
   682     CleanupStack::PushL( cleanupItem );
   699     CleanupStack::PushL( cleanupItem );
   683     iBkupEngine->ListArchivesL(
   700     iBkupEngine->ListArchivesL(
   684         archives,
   701         archives,
   685         params,
   702         params,
   686         AllowedDriveAttMatchMask(),
   703         AllowedDriveAttMatchMask(),
   687         aDrive );
   704         targetDrive );
   688 
   705 
   689     // Fill restore info
   706     // Fill restore info
   690     TInt count( archives.Count() );
   707     TInt count( archives.Count() );
   691 //    restoreInfoList.ReserveL( count );
   708 //    restoreInfoList.ReserveL( count );
   692 
   709 
   703         int h       = iDateTime.Hour();
   720         int h       = iDateTime.Hour();
   704         int m       = iDateTime.Minute();
   721         int m       = iDateTime.Minute();
   705         int s       = iDateTime.Second();
   722         int s       = iDateTime.Second();
   706         int year    = iDateTime.Year();
   723         int year    = iDateTime.Year();
   707         int month   = iDateTime.Month() + 1;
   724         int month   = iDateTime.Month() + 1;
   708         int day     = iDateTime.Day();
   725         int day     = iDateTime.Day()+1;
   709         QTime time( h, m, s);
   726         QTime time( h, m, s);
   710         QDate date( year, month, day );
   727         QDate date( year, month, day );
   711         
   728         
   712         QDateTime dateTime( date, time );
   729         QDateTime dateTime( date, time );
   713         dateTime = dateTime.toLocalTime();
   730         dateTime = dateTime.toLocalTime();
   748     return KDriveAttRemovable;//KDriveAttRemovable;
   765     return KDriveAttRemovable;//KDriveAttRemovable;
   749     }
   766     }
   750 
   767 
   751 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   768 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   752     {
   769     {
       
   770         if( driverName.isEmpty() ) {
       
   771             return KErrNotFound;
       
   772         }
   753         TInt drive = 0;
   773         TInt drive = 0;
   754         drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
   774         drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
   755         return drive;
   775         return drive;
   756     }
   776     }
   757 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   777 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   782                 {
   802                 {
   783                 driveList.append( NumberToDriverName( i ) );
   803                 driveList.append( NumberToDriverName( i ) );
   784                 }
   804                 }
   785             }
   805             }
   786         }
   806         }
   787     
       
   788     fs.Close();
   807     fs.Close();
   789     }
   808     }
   790 
   809 
   791 // -----------------------------------------------------------------------------
   810 // -----------------------------------------------------------------------------
   792 // CFileManagerEngine::PublishBurStatus()
   811 // CFileManagerEngine::PublishBurStatus()