filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp
changeset 25 b7bfdea70ca2
parent 16 ada7962b4308
child 32 39cf9ced4cc4
equal deleted inserted replaced
16:ada7962b4308 25:b7bfdea70ca2
    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;
       
   438     case KErrDisMounted:
       
   439         return FmErrDisMounted;
   422     default: 
   440     default: 
   423         return FmErrUnKnown;
   441         return FmErrUnKnown;
   424     }    
   442     }    
   425 }
   443 }
   426 
   444 
   648     return true;
   666     return true;
   649     }
   667     }
   650 
   668 
   651 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   669 void FmBkupEnginePrivate::GetRestoreInfoArray( QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   652         QList< FmRestoreInfo > &restoreInfoList,
   670         QList< FmRestoreInfo > &restoreInfoList,
   653         const TInt aDrive )
   671         const QString& aDrive )
   654     {
   672     {
       
   673     int targetDrive = DriverNameToNumber( aDrive );
   655     FmBackupSettings& settings( *( q->BackupSettingsL() ) );
   674     FmBackupSettings& settings( *( q->BackupSettingsL() ) );
   656 
   675 
   657     restoreInfoList.clear();
   676     restoreInfoList.clear();
   658     
   677     
   659     ///////
   678     ///////
   682     CleanupStack::PushL( cleanupItem );
   701     CleanupStack::PushL( cleanupItem );
   683     iBkupEngine->ListArchivesL(
   702     iBkupEngine->ListArchivesL(
   684         archives,
   703         archives,
   685         params,
   704         params,
   686         AllowedDriveAttMatchMask(),
   705         AllowedDriveAttMatchMask(),
   687         aDrive );
   706         targetDrive );
   688 
   707 
   689     // Fill restore info
   708     // Fill restore info
   690     TInt count( archives.Count() );
   709     TInt count( archives.Count() );
   691 //    restoreInfoList.ReserveL( count );
   710 //    restoreInfoList.ReserveL( count );
   692 
   711 
   703         int h       = iDateTime.Hour();
   722         int h       = iDateTime.Hour();
   704         int m       = iDateTime.Minute();
   723         int m       = iDateTime.Minute();
   705         int s       = iDateTime.Second();
   724         int s       = iDateTime.Second();
   706         int year    = iDateTime.Year();
   725         int year    = iDateTime.Year();
   707         int month   = iDateTime.Month() + 1;
   726         int month   = iDateTime.Month() + 1;
   708         int day     = iDateTime.Day();
   727         int day     = iDateTime.Day()+1;
   709         QTime time( h, m, s);
   728         QTime time( h, m, s);
   710         QDate date( year, month, day );
   729         QDate date( year, month, day );
   711         
   730         
   712         QDateTime dateTime( date, time );
   731         QDateTime dateTime( date, time );
   713         dateTime = dateTime.toLocalTime();
   732         dateTime = dateTime.toLocalTime();
   748     return KDriveAttRemovable;//KDriveAttRemovable;
   767     return KDriveAttRemovable;//KDriveAttRemovable;
   749     }
   768     }
   750 
   769 
   751 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   770 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   752     {
   771     {
       
   772         if( driverName.isEmpty() ) {
       
   773             return KErrNotFound;
       
   774         }
   753         TInt drive = 0;
   775         TInt drive = 0;
   754         drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
   776         drive = driverName[0].toUpper().toAscii() - 'A' + EDriveA;
   755         return drive;
   777         return drive;
   756     }
   778     }
   757 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   779 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   782                 {
   804                 {
   783                 driveList.append( NumberToDriverName( i ) );
   805                 driveList.append( NumberToDriverName( i ) );
   784                 }
   806                 }
   785             }
   807             }
   786         }
   808         }
   787     
       
   788     fs.Close();
   809     fs.Close();
   789     }
   810     }
   790 
   811 
   791 // -----------------------------------------------------------------------------
   812 // -----------------------------------------------------------------------------
   792 // CFileManagerEngine::PublishBurStatus()
   813 // CFileManagerEngine::PublishBurStatus()