filemanager/src/fmbkupenginewrapper/private/symbian/fmbkupengine_p.cpp
changeset 16 ada7962b4308
parent 14 1957042d8c7e
child 18 edd66bde63a4
child 25 b7bfdea70ca2
child 37 15bc28c9dd51
equal deleted inserted replaced
14:1957042d8c7e 16:ada7962b4308
    17  */
    17  */
    18 
    18 
    19 #include "fmbkupengine_p.h"
    19 #include "fmbkupengine_p.h"
    20 
    20 
    21 // INCLUDE FILES
    21 // INCLUDE FILES
    22 /*#include <filemanagerengine.rsg>
       
    23 #include "cfilemanagerremovabledrivehandler.h"
       
    24 #include "mfilemanagerprocessobserver.h"
       
    25 #include "cfilemanagerutils.h"
       
    26 #include "cfilemanagerengine.h"
       
    27 */
       
    28 #include <coreapplicationuisdomainpskeys.h>
    22 #include <coreapplicationuisdomainpskeys.h>
    29 #include <coemain.h>
    23 #include <coemain.h>
    30 #include <apgwgnam.h>
    24 #include <apgwgnam.h>
    31 #include <apgtask.h>
    25 #include <apgtask.h>
    32 #include <bautils.h>
    26 #include <bautils.h>
    47 #include <eikdef.h>
    41 #include <eikdef.h>
    48 #include <eikenv.h>
    42 #include <eikenv.h>
    49 
    43 
    50 #include "fmcommon.h"
    44 #include "fmcommon.h"
    51 
    45 
       
    46 #include <f32file.h>
       
    47 
    52 /*
    48 /*
    53 #include "cfilemanageritemproperties.h"
    49 #include "cfilemanageritemproperties.h"
    54 #include "cfilemanagerbackupsettings.h"
    50 #include "cfilemanagerbackupsettings.h"
    55 #include "filemanagerprivatecrkeys.h"
    51 #include "filemanagerprivatecrkeys.h"
    56 #include "bkupengine.hrh"
    52 #include "bkupengine.hrh"
   100 
    96 
   101 bool FmBkupEnginePrivate::startBackup(QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
    97 bool FmBkupEnginePrivate::startBackup(QList<FmBkupDrivesAndOperation* > drivesAndOperationList,
   102 	    QList<FmBkupBackupCategory*> backupCategoryList,
    98 	    QList<FmBkupBackupCategory*> backupCategoryList,
   103 	    QString drive, quint32 content)
    99 	    QString drive, quint32 content)
   104 {
   100 {
       
   101     if( drive.isEmpty() ) {
       
   102         iError = KErrPathNotFound;
       
   103         return false;
       
   104     }
   105     QString logString;
   105     QString logString;
   106     logString = "startBackup";
   106     logString = "startBackup";
   107     FmLogger::log( logString );
   107     FmLogger::log( logString );
   108     iDrvAndOpList->Reset();
   108     iDrvAndOpList->Reset();
   109     iBkupCategoryList->ResetAndDestroy();
   109     iBkupCategoryList->ResetAndDestroy();
   180     eikonEnv->SetSystem(ETrue);
   180     eikonEnv->SetSystem(ETrue);
   181 
   181 
   182     logString = "startBackup_StartOperationL";
   182     logString = "startBackup_StartOperationL";
   183     FmLogger::log( logString );
   183     FmLogger::log( logString );
   184 
   184 
       
   185     QList< FmRestoreInfo > restoreInfoList;
       
   186     TInt driveNumber = DriverNameToNumber( drive );
       
   187     GetRestoreInfoArray( drivesAndOperationList, restoreInfoList, driveNumber );
       
   188     
       
   189     for ( TInt i( 0 ); i < restoreInfoList.count(); i++ )
       
   190         {        
       
   191         bool toContinue = false;
       
   192         FmRestoreInfo &info = restoreInfoList[ i ];
       
   193         TUint32 existContent( FmgrToBkupMask( info.content() ) );
       
   194         if ( bkupContent & existContent )
       
   195             {            
       
   196             notifyBackupFilesExistInternal( toContinue );
       
   197             if (!toContinue)
       
   198                 {
       
   199                 iError = KErrAlreadyExists;
       
   200                 return false;
       
   201                 }
       
   202             else
       
   203                 {
       
   204                 break;
       
   205                 }
       
   206             }
       
   207         }
       
   208     
       
   209     
   185     TRAPD( err, iBkupEngine->StartOperationL(
   210     TRAPD( err, iBkupEngine->StartOperationL(
   186         EMMCScBkupOperationTypeFullBackup, *this, params ) );
   211         EMMCScBkupOperationTypeFullBackup, *this, params ) );
   187 
   212 
   188     logString = "startBackup_end with error:" + QString::number(err) ;
   213     logString = "startBackup_end with error:" + QString::number(err) ;
   189     FmLogger::log( logString );
   214     FmLogger::log( logString );
   275 void FmBkupEnginePrivate::notifyMemoryLowInternal( int memoryValue, int &userError )
   300 void FmBkupEnginePrivate::notifyMemoryLowInternal( int memoryValue, int &userError )
   276 	{
   301 	{
   277 	emit notifyMemoryLow( memoryValue, userError );
   302 	emit notifyMemoryLow( memoryValue, userError );
   278 	}
   303 	}
   279 
   304 
       
   305 void FmBkupEnginePrivate::notifyBackupFilesExistInternal( bool &isContinue )
       
   306     {
       
   307     emit notifyBackupFilesExist( isContinue );
       
   308     }
       
   309 
   280 TInt FmBkupEnginePrivate::HandleBkupEngineEventL(
   310 TInt FmBkupEnginePrivate::HandleBkupEngineEventL(
   281         MMMCScBkupEngineObserver::TEvent aEvent, TInt aAssociatedData )
   311         MMMCScBkupEngineObserver::TEvent aEvent, TInt aAssociatedData )
   282     {
   312     {
   283     QString logString;
   313     QString logString;
   284     TInt ret( KErrNone );
   314     TInt ret( KErrNone );
   330                 }
   360                 }
   331             break;
   361             break;
   332             }
   362             }
   333         case MMMCScBkupEngineObserver::ECommonOperationError:
   363         case MMMCScBkupEngineObserver::ECommonOperationError:
   334             {
   364             {
   335             logString  = "ECommonOperationError:" + QString::number(aAssociatedData);
   365             logString  = "ECommonOperationError";
   336             iError = aAssociatedData;
   366             iError = aAssociatedData;
   337             break;
   367             break;
   338             }
   368             }
   339         case MMMCScBkupEngineObserver::ECommonProgress:
   369         case MMMCScBkupEngineObserver::ECommonProgress:
   340             {
   370             {
   385         return FmErrDiskFull;
   415         return FmErrDiskFull;
   386     case KErrAlreadyExists:
   416     case KErrAlreadyExists:
   387         return FmErrAlreadyExists;
   417         return FmErrAlreadyExists;
   388     case KErrCancel:
   418     case KErrCancel:
   389         return FmErrCancel;
   419         return FmErrCancel;
       
   420     case KErrPathNotFound:
       
   421         return FmErrPathNotFound;
   390     default: 
   422     default: 
   391         return FmErrUnKnown;
   423         return FmErrUnKnown;
   392     }    
   424     }    
   393 }
   425 }
   394 
   426 
   711     archive->Close();
   743     archive->Close();
   712     }
   744     }
   713 
   745 
   714 TUint32 FmBkupEnginePrivate::AllowedDriveAttMatchMask() const
   746 TUint32 FmBkupEnginePrivate::AllowedDriveAttMatchMask() const
   715     {
   747     {
   716     return KDriveAttRemovable | KDriveAttInternal;//KDriveAttRemovable;
   748     return KDriveAttRemovable;//KDriveAttRemovable;
   717     }
   749     }
   718 
   750 
   719 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   751 TInt FmBkupEnginePrivate::DriverNameToNumber( QString driverName )
   720     {
   752     {
   721         TInt drive = 0;
   753         TInt drive = 0;
   725 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   757 QString FmBkupEnginePrivate::NumberToDriverName( TInt driver )
   726     {
   758     {
   727         QChar driverChar( driver - EDriveA + 'A' );
   759         QChar driverChar( driver - EDriveA + 'A' );
   728         QString driverName = QString( driverChar ) + ':';
   760         QString driverName = QString( driverChar ) + ':';
   729         return driverName;
   761         return driverName;
       
   762     }
       
   763 
       
   764 void FmBkupEnginePrivate::getBackupDriveList( QStringList &driveList )
       
   765     {
       
   766     TUint32 driveAttMask( AllowedDriveAttMatchMask() );
       
   767     RFs fs;
       
   768     fs.Connect();
       
   769     for ( TInt i( 0 ); i < KMaxDrives; ++i )
       
   770         {
       
   771         TDriveInfo driveInfo;
       
   772         if ( fs.Drive( driveInfo, i ) == KErrNone )
       
   773             {
       
   774             // Do not allow backup for internal drives
       
   775             TUint driveStatus( 0 );
       
   776             DriveInfo::GetDriveStatus( fs, i, driveStatus );
       
   777             if ( driveStatus & DriveInfo::EDriveInternal )
       
   778                 {
       
   779                 continue;
       
   780                 }
       
   781             if ( driveInfo.iDriveAtt & driveAttMask )
       
   782                 {
       
   783                 driveList.append( NumberToDriverName( i ) );
       
   784                 }
       
   785             }
       
   786         }
       
   787     
       
   788     fs.Close();
   730     }
   789     }
   731 
   790 
   732 // -----------------------------------------------------------------------------
   791 // -----------------------------------------------------------------------------
   733 // CFileManagerEngine::PublishBurStatus()
   792 // CFileManagerEngine::PublishBurStatus()
   734 //
   793 //