filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp
changeset 18 edd66bde63a4
parent 16 ada7962b4308
child 21 15299bc55001
equal deleted inserted replaced
16:ada7962b4308 18:edd66bde63a4
    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     FmLogger::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         FmLogger::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         FmLogger::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     FmLogger::log( logString );
   181 
   191 
   182     logString = "startBackup_StartOperationL";
   192     logString = "startBackup_StartOperationL";
   183     FmLogger::log( logString );
   193     FmLogger::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 )
   403     return ret;
   412     return ret;
   404     }
   413     }
   405 
   414 
   406 int FmBkupEnginePrivate::error()
   415 int FmBkupEnginePrivate::error()
   407 {
   416 {
       
   417     FmLogger::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;
   422     default: 
   438     default: 
   423         return FmErrUnKnown;
   439         return FmErrUnKnown;
   424     }    
   440     }    
   425 }
   441 }
   426 
   442 
   648     return true;
   664     return true;
   649     }
   665     }
   650 
   666 
   651 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   667 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   652         QList< FmRestoreInfo > &restoreInfoList,
   668         QList< FmRestoreInfo > &restoreInfoList,
   653         const TInt aDrive )
   669         const QString& aDrive )
   654     {
   670     {
       
   671     int targetDrive = DriverNameToNumber( aDrive );
   655     FmBackupSettings& settings( *( q->BackupSettingsL() ) );
   672     FmBackupSettings& settings( *( q->BackupSettingsL() ) );
   656 
   673 
   657     restoreInfoList.clear();
   674     restoreInfoList.clear();
   658     
   675     
   659     ///////
   676     ///////
   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 
   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()